// Author : Anthony Geay (CEA/DEN)
#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingCMesh.hxx"
#include "MEDCoupling1GTUMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingSkyLineArray.hxx"
if(!da)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Build0DMeshFromCoords : instance of DataArrayDouble must be not null !");
da->checkAllocated();
- MCAuto<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(da->getName(),0);
+ std::string name(da->getName());
+ MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::New(name,0));
+ if(name.empty())
+ ret->setName("Mesh");
ret->setCoords(da);
- int nbOfTuples=da->getNumberOfTuples();
- MCAuto<DataArrayInt> c=DataArrayInt::New();
- MCAuto<DataArrayInt> cI=DataArrayInt::New();
+ int nbOfTuples(da->getNumberOfTuples());
+ MCAuto<DataArrayInt> c(DataArrayInt::New()),cI(DataArrayInt::New());
c->alloc(2*nbOfTuples,1);
cI->alloc(nbOfTuples+1,1);
- int *cp=c->getPointer();
- int *cip=cI->getPointer();
+ int *cp(c->getPointer()),*cip(cI->getPointer());
*cip++=0;
for(int i=0;i<nbOfTuples;i++)
{
ret->setConnectivity(c,cI,true);
return ret.retn();
}
+
+MCAuto<MEDCouplingUMesh> MEDCouplingUMesh::Build1DMeshFromCoords(DataArrayDouble *da)
+{
+ if(!da)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Build01MeshFromCoords : instance of DataArrayDouble must be not null !");
+ da->checkAllocated();
+ std::string name(da->getName());
+ MCAuto<MEDCouplingUMesh> ret;
+ {
+ MCAuto<MEDCouplingCMesh> tmp(MEDCouplingCMesh::New());
+ MCAuto<DataArrayDouble> arr(DataArrayDouble::New());
+ arr->alloc(da->getNumberOfTuples());
+ tmp->setCoordsAt(0,arr);
+ ret=tmp->buildUnstructured();
+ }
+ ret->setCoords(da);
+ if(name.empty())
+ ret->setName("Mesh");
+ else
+ ret->setName(name);
+ return ret;
+}
+
/*!
* Creates a new MEDCouplingUMesh by concatenating two given meshes of the same dimension.
* Cells and nodes of
MEDCOUPLING_EXPORT DataArrayInt *colinearize2D(double eps);
MEDCOUPLING_EXPORT int split2DCells(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *midOpt=0, const DataArrayInt *midOptI=0);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da);
+ MEDCOUPLING_EXPORT static MCAuto<MEDCouplingUMesh> Build1DMeshFromCoords(DataArrayDouble *da);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(const std::vector<const MEDCouplingUMesh *>& a);
MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2);
self.assertEqual(f2.getArray().getHiddenCppPointer(),f3.getArray().getHiddenCppPointer())
self.assertEqual(f3.getTime(),[0.5,2,3])
pass
+
+ def testBuild1DMeshFromCoords1(self):
+ da=DataArrayDouble([(3,4),(5,6),(7,8)])
+ da.setName("ZeArr")
+ da0=da.deepCopy()
+ m=MEDCouplingUMesh.Build1DMeshFromCoords(da0)
+ m.checkConsistencyLight()
+ self.assertEqual(da0.getHiddenCppPointer(),m.getCoords().getHiddenCppPointer())
+ self.assertTrue(da.isEqual(da0,1e-12))
+ self.assertEqual(m.getName(),da.getName())
+ self.assertEqual(m.getMeshDimension(),1)
+ self.assertTrue(isinstance(m,MEDCouplingUMesh))
+ m1=MEDCoupling1SGTUMesh(m)
+ m1.checkConsistencyLight()
+ self.assertTrue(m1.getNodalConnectivity().isEqual(DataArrayInt([0,1,1,2])))
+ #
+ da0.setName("")
+ m2=MEDCouplingUMesh.Build1DMeshFromCoords(da0)
+ m2.checkConsistencyLight()
+ self.assertEqual(da0.getHiddenCppPointer(),m2.getCoords().getHiddenCppPointer())
+ self.assertEqual(m2.getName(),"Mesh")
+ pass
pass
%newobject MEDCoupling::MEDCouplingUMesh::buildPartOrthogonalField;
%newobject MEDCoupling::MEDCouplingUMesh::keepCellIdsByType;
%newobject MEDCoupling::MEDCouplingUMesh::Build0DMeshFromCoords;
+%newobject MEDCoupling::MEDCouplingUMesh::Build1DMeshFromCoords;
%newobject MEDCoupling::MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells;
%newobject MEDCoupling::MEDCouplingUMesh::findAndCorrectBadOriented3DCells;
%newobject MEDCoupling::MEDCouplingUMesh::convertIntoSingleGeoTypeMesh;
return self->cellIterator();
}
+ static MEDCouplingUMesh *Build1DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::Build1DMeshFromCoords(da));
+ return ret.retn();
+ }
+
PyObject *getAllGeoTypesSorted() const throw(INTERP_KERNEL::Exception)
{
std::vector<INTERP_KERNEL::NormalizedCellType> result=self->getAllGeoTypesSorted();