From: ageay Date: Tue, 23 Jul 2013 16:02:36 +0000 (+0000) Subject: Target MEDReader X-Git-Tag: B4PolyhIntersect~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d6d39a558e1a732e06df29cc3cd26cbe99a5e784;p=modules%2Fmed.git Target MEDReader --- diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index 7d43b18a7..98fbbf48c 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -885,6 +885,12 @@ MEDMeshMultiLev::MEDMeshMultiLev(const std::vector& levs) throw(INTERP_KERNEL::Exception) { return new MEDUMeshMultiLev(m,levs); @@ -938,18 +944,88 @@ void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) throw(INT { if(!pflNodes || !pflNodes->isAllocated()) return ; - /*std::vector ngs(getNodeGridStructure()); + std::size_t sz(_parts.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr > a(sz); + std::vector< const DataArrayInt *> aa(sz); + for(std::size_t i=0;i m(_parts[i]); + if(pfl) + m=dynamic_cast(_parts[i]->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); + DataArrayInt *cellIds=0; + m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds); + MEDCouplingAutoRefCountObjectPtr cellIdsSafe(cellIds); + MEDCouplingAutoRefCountObjectPtr m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end())); + int tmp=-1; + a[i]=m2->getNodeIdsInUse(tmp); aa[i]=a[i]; + if(pfl) + _pfls[i]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end()); + else + _pfls[i]=cellIdsSafe; + } + _node_reduction=DataArrayInt::Aggregate(aa); + _node_reduction->sort(true); + _node_reduction=_node_reduction->buildUnique(); +} + +MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const throw(INTERP_KERNEL::Exception) +{ + return new MEDUMeshMultiLev(*this); +} + +MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts) +{ +} + +MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr& part):MEDMeshMultiLev(other) +{ + _parts.resize(1); + _parts[0]=part; +} + +//= + +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev() +{ +} + +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(gts,pfls,nbEntities) +{ +} + +void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception) +{ + if(!pflNodes || !pflNodes->isAllocated()) + return ; + std::vector ngs(getNodeGridStructure()); MEDCouplingAutoRefCountObjectPtr conn(MEDCouplingStructuredMesh::Build1GTNodalConnectivity(&ngs[0],&ngs[0]+ngs.size())); - MEDCouplingAutoRefCountObjectPtr m(MEDCoupling1SGTUMesh::New("",GMEDCouplingStructuredMesh::etGeoTypeGivenMeshDimension(ngs.size()))); + MEDCouplingAutoRefCountObjectPtr m(MEDCoupling1SGTUMesh::New("",MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(ngs.size()))); m->setNodalConnectivity(conn); + const DataArrayInt *pfl(_pfls[0]); + if(pfl) + { + m=dynamic_cast(m->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); + } DataArrayInt *cellIds=0; m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds); MEDCouplingAutoRefCountObjectPtr cellIdsSafe(cellIds); MEDCouplingAutoRefCountObjectPtr m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end())); int tmp=-1; - _node_reduction=m2->getNodeIdsInUse(tmp);*/ + _node_reduction=m2->getNodeIdsInUse(tmp); + if(pfl) + _pfls[0]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end()); + else + _pfls[0]=cellIdsSafe; } +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other) +{ +} + +//= + MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector& levs) throw(INTERP_KERNEL::Exception) { return new MEDCMeshMultiLev(m,levs); @@ -996,6 +1072,10 @@ MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector MEDCMeshMultiLev::getNodeGridStructure() const throw(INTERP_KERNEL::Exception) { std::vector ret(_coords.size()); @@ -1004,6 +1084,51 @@ std::vector MEDCMeshMultiLev::getNodeGridStructure() const throw(INTERP_KER return ret; } +MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const throw(INTERP_KERNEL::Exception) +{ + const DataArrayInt *pfl(_pfls[0]),*nr(_node_reduction); + MEDCouplingAutoRefCountObjectPtr nnr; + std::vector cgs,ngs(getNodeGridStructure()); + cgs.resize(ngs.size()); + std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus(),-1)); + if(pfl) + { + std::vector< std::pair > cellParts; + if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts)) + { + MEDCouplingAutoRefCountObjectPtr ret(new MEDCMeshMultiLev(*this)); + if(nr) + { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); } + ret->_nb_entities[0]=pfl->getNumberOfTuples(); + ret->_pfls[0]=0; + std::vector< MEDCouplingAutoRefCountObjectPtr > coords(_coords.size()); + for(std::size_t i=0;i<_coords.size();i++) + coords[i]=_coords[i]->selectByTupleId2(cellParts[i].first,cellParts[i].second+1,1); + ret->_coords=coords; + return ret.retn(); + } + else + { + MEDCouplingAutoRefCountObjectPtr m(MEDCouplingCMesh::New()); + for(std::size_t i=0;isetCoordsAt(i,_coords[i]); + MEDCouplingAutoRefCountObjectPtr m2(m->build1SGTUnstructured()); + MEDCouplingAutoRefCountObjectPtr m3=dynamic_cast(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); + MEDCouplingAutoRefCountObjectPtr ret(new MEDUMeshMultiLev(*this,m3)); + if(nr) + { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); } + return ret.retn(); + } + } + else + { + MEDCouplingAutoRefCountObjectPtr ret(new MEDCMeshMultiLev(*this)); + if(nr) + { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); } + return ret.retn(); + } +} + //= MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLinearMesh *m, const std::vector& levs) throw(INTERP_KERNEL::Exception) @@ -1047,33 +1172,61 @@ MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearM _structure=m->getMesh()->getNodeGridStructure(); } -std::vector MEDCurveLinearMeshMultiLev::getNodeGridStructure() const throw(INTERP_KERNEL::Exception) +MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords),_structure(other._structure) { - return _structure; } -//= - -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev() -{ -} - -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(gts,pfls,nbEntities) +std::vector MEDCurveLinearMeshMultiLev::getNodeGridStructure() const throw(INTERP_KERNEL::Exception) { + return _structure; } -void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception) +MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const throw(INTERP_KERNEL::Exception) { - if(!pflNodes || !pflNodes->isAllocated()) - return ; - std::vector ngs(getNodeGridStructure()); - MEDCouplingAutoRefCountObjectPtr conn(MEDCouplingStructuredMesh::Build1GTNodalConnectivity(&ngs[0],&ngs[0]+ngs.size())); - MEDCouplingAutoRefCountObjectPtr m(MEDCoupling1SGTUMesh::New("",MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(ngs.size()))); - m->setNodalConnectivity(conn); - DataArrayInt *cellIds=0; - m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds); - MEDCouplingAutoRefCountObjectPtr cellIdsSafe(cellIds); - MEDCouplingAutoRefCountObjectPtr m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end())); - int tmp=-1; - _node_reduction=m2->getNodeIdsInUse(tmp); + const DataArrayInt *pfl(_pfls[0]),*nr(_node_reduction); + MEDCouplingAutoRefCountObjectPtr nnr; + std::vector cgs,ngs(getNodeGridStructure()); + cgs.resize(ngs.size()); + std::transform(ngs.begin(),ngs.end(),cgs.begin(),std::bind2nd(std::plus(),-1)); + if(pfl) + { + std::vector< std::pair > cellParts,nodeParts; + if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts)) + { + nodeParts=cellParts; + std::vector st(ngs.size()); + for(std::size_t i=0;i p(MEDCouplingStructuredMesh::BuildExplicitIdsFrom(ngs,nodeParts)); + MEDCouplingAutoRefCountObjectPtr ret(new MEDCurveLinearMeshMultiLev(*this)); + if(nr) + { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); } + ret->_nb_entities[0]=pfl->getNumberOfTuples(); + ret->_pfls[0]=0; + ret->_coords=_coords->selectByTupleIdSafe(p->begin(),p->end()); + ret->_structure=st; + return ret.retn(); + } + else + { + MEDCouplingAutoRefCountObjectPtr m(MEDCouplingCurveLinearMesh::New()); + m->setCoords(_coords); m->setNodeGridStructure(&_structure[0],&_structure[0]+_structure.size()); + MEDCouplingAutoRefCountObjectPtr m2(m->build1SGTUnstructured()); + MEDCouplingAutoRefCountObjectPtr m3=dynamic_cast(m2->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); + MEDCouplingAutoRefCountObjectPtr ret(new MEDUMeshMultiLev(*this,m3)); + if(nr) + { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); } + return ret.retn(); + } + } + else + { + MEDCouplingAutoRefCountObjectPtr ret(new MEDCurveLinearMeshMultiLev(*this)); + if(nr) + { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); } + return ret.retn(); + } } diff --git a/src/MEDLoader/MEDFileFieldOverView.hxx b/src/MEDLoader/MEDFileFieldOverView.hxx index 6dca9aa9d..e8866b543 100644 --- a/src/MEDLoader/MEDFileFieldOverView.hxx +++ b/src/MEDLoader/MEDFileFieldOverView.hxx @@ -73,23 +73,30 @@ namespace ParaMEDMEM static MEDMeshMultiLev *NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode) throw(INTERP_KERNEL::Exception); void setNodeReduction(const DataArrayInt *nr); virtual void selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception) = 0; + virtual MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception) = 0; protected: MEDMeshMultiLev(); + MEDMeshMultiLev(const MEDMeshMultiLev& other); MEDMeshMultiLev(const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); - protected: + protected: std::vector< MEDCouplingAutoRefCountObjectPtr > _pfls; std::vector< INTERP_KERNEL::NormalizedCellType > _geo_types; std::vector _nb_entities; MEDCouplingAutoRefCountObjectPtr _node_reduction; }; - + + class MEDStructuredMeshMultiLev; + class MEDUMeshMultiLev : public MEDMeshMultiLev { public: static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector& levs) throw(INTERP_KERNEL::Exception); static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities) throw(INTERP_KERNEL::Exception); void selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception); + MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception); + MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr& part); private: + MEDUMeshMultiLev(const MEDUMeshMultiLev& other); MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& levs); MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); private: @@ -103,6 +110,7 @@ namespace ParaMEDMEM virtual std::vector getNodeGridStructure() const throw(INTERP_KERNEL::Exception) = 0; protected: MEDStructuredMeshMultiLev(); + MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other); MEDStructuredMeshMultiLev(const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); }; @@ -112,7 +120,9 @@ namespace ParaMEDMEM static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector& levs) throw(INTERP_KERNEL::Exception); static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities) throw(INTERP_KERNEL::Exception); std::vector getNodeGridStructure() const throw(INTERP_KERNEL::Exception); + MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception); private: + MEDCMeshMultiLev(const MEDCMeshMultiLev& other); MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector& levs); MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); private: @@ -125,7 +135,9 @@ namespace ParaMEDMEM static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector& levs) throw(INTERP_KERNEL::Exception); static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector& gts, const std::vector& pfls , const std::vector& nbEntities) throw(INTERP_KERNEL::Exception); std::vector getNodeGridStructure() const throw(INTERP_KERNEL::Exception); + MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception); private: + MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other); MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector& levs); MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); private: