@@ -434,6 +434,7 @@ void CopySubsetIndicesToSides(
434434}
435435
436436// NEW GROUP: Quality Util
437+ template <class elem_t >
437438void AssignSubsetsByAspectRatio (
438439 Mesh* msh,
439440 int numHistoSecs,
@@ -451,30 +452,32 @@ void AssignSubsetsByAspectRatio (
451452 Selector& sel = msh->selector ();
452453 SubsetHandler& sh = msh->subset_handler ();
453454
455+ int firstSubset = sh.num_subsets ();
456+ if (eraseOldSubsets){
457+ sh.clear ();
458+ firstSubset = 0 ;
459+ }
460+
461+
454462 AInt aHistoSecs;
455- g.attach_to_faces (aHistoSecs);
456- Grid::FaceAttachmentAccessor< AInt> aaHistoSec (g, aHistoSecs);
463+ g.attach_to < elem_t > (aHistoSecs);
464+ Grid::AttachmentAccessor< elem_t , AInt> aaHistoSec (g, aHistoSecs);
457465
458466 std::vector<int > histo;
459467
460- FaceIterator facesBegin = sel.faces_begin ();
461- FaceIterator facesEnd = sel.faces_end ();
462- size_t numFaces = sel.num <Face>();
463- if (numFaces == 0 ){
464- facesBegin = g.faces_begin ();
465- facesEnd = g.faces_end ();
466- numFaces = g.num <Face>();
468+ typedef typename Grid::traits<elem_t >::iterator iter_t ;
469+ iter_t elemsBegin = sel.begin <elem_t >();
470+ iter_t elemsEnd = sel.end <elem_t >();
471+ size_t numElems = sel.num <elem_t >();
472+ if (numElems == 0 ){
473+ elemsBegin = g.begin <elem_t >();
474+ elemsEnd = g.end <elem_t >();
475+ numElems = g.num <elem_t >();
467476 }
468477
469- GetFaceAspectRatioHistogram (histo, facesBegin, facesEnd,
470- numHistoSecs, msh->position_accessor (),
471- &aaHistoSec);
472-
473- int firstSubset = sh.num_subsets ();
474- if (eraseOldSubsets){
475- sh.clear ();
476- firstSubset = 0 ;
477- }
478+ GetAspectRatioHistogram (histo, elemsBegin, elemsEnd,
479+ numHistoSecs, msh->position_accessor (),
480+ &aaHistoSec);
478481
479482 const number stepSize = 1 . / (number) numHistoSecs;
480483 StringStreamTable t;
@@ -487,17 +490,20 @@ void AssignSubsetsByAspectRatio (
487490 t (1 , i) << histo[i];
488491 }
489492
490- for (FaceIterator iface = facesBegin; iface != facesEnd ; ++iface )
491- sh.assign_subset (*iface , aaHistoSec[*iface ]);
493+ for (iter_t ielem = elemsBegin; ielem != elemsEnd ; ++ielem )
494+ sh.assign_subset (*ielem , aaHistoSec[*ielem ]);
492495
493496 AssignSubsetColorsBlueToGreen (sh, firstSubset, numHistoSecs);
494497
495- g.detach_from_faces (aHistoSecs);
498+ g.detach_from < elem_t > (aHistoSecs);
496499
497- UG_LOG (" Face Aspect Ratio Histogram (" << numFaces << " faces ):\n\n " );
500+ UG_LOG (" Aspect Ratio Histogram (" << numElems << " elements ):\n\n " );
498501 UG_LOG (t.to_string () << std::endl);
499502}
500503
504+ template void AssignSubsetsByAspectRatio <Face> (Mesh*, int , bool );
505+ template void AssignSubsetsByAspectRatio <Volume> (Mesh*, int , bool );
506+
501507
502508template <int dim, class elem_t >
503509void AssignSubsetsFromRaster_IMPL (Mesh* obj, const char * rasterFileName)
0 commit comments