void CopyGridLevel(MultiGrid& srcMG, Grid& destGrid, ISubsetHandler& srcSH, ISubsetHandler& destSH, int lvl, TAPos aPos) { Grid::VertexAttachmentAccessor<TAPos> aaPos(destGrid, aPos); Grid::VertexAttachmentAccessor<TAPos> aaSrcPos(srcMG, aPos); GridObjectCollection goc = srcMG.get_grid_objects(); AVertex aNewVrt; srcMG.attach_to_vertices(aNewVrt); Grid::VertexAttachmentAccessor<AVertex> aaNewVrt(srcMG, aNewVrt); for(int si = destSH.num_subsets(); si < srcSH.num_subsets(); ++si) { destSH.subset_info(si) = srcSH.subset_info(si); } for(VertexIterator vrtIter = goc.begin<Vertex>(lvl); vrtIter != goc.end<Vertex>(lvl); ++vrtIter) { Vertex* srcVrt = *vrtIter; Vertex* destVrt = *destGrid.create_by_cloning(srcVrt); aaNewVrt[srcVrt] = destVrt; aaPos[destVrt] = aaSrcPos[srcVrt]; destSH.assign_subset(destVrt, srcSH.get_subset_index(srcVrt)); } CopyGridLevelElements<Edge>(srcMG, destGrid, srcSH, destSH, lvl, aNewVrt); CopyGridLevelElements<Face>(srcMG, destGrid, srcSH, destSH, lvl, aNewVrt); CopyGridLevelElements<Volume>(srcMG, destGrid, srcSH, destSH, lvl, aNewVrt); srcMG.detach_from_vertices(aNewVrt); }
void CopyGridLevelElements(MultiGrid& srcMG, Grid& destGrid, ISubsetHandler& srcSH, ISubsetHandler& destSH, int lvl, AVertex& aNewVrt) { Grid::VertexAttachmentAccessor<AVertex> aaNewVrt(srcMG, aNewVrt); GridObjectCollection goc = srcMG.get_grid_objects(); CustomVertexGroup vrts; typedef typename Grid::traits<TElem>::iterator iter_t; for(iter_t eIter = goc.begin<TElem>(lvl); eIter != goc.end<TElem>(lvl); ++eIter) { TElem* e = *eIter; vrts.resize(e->num_vertices()); for(size_t iv = 0; iv < e->num_vertices(); ++iv) { vrts.set_vertex(iv, aaNewVrt[e->vertex(iv)]); } TElem* ne = *destGrid.create_by_cloning(e, vrts); destSH.assign_subset(ne, srcSH.get_subset_index(e)); } }