コード例 #1
0
ファイル: skin.C プロジェクト: ArnaudGastinel/jot-lib
static int
max_subdiv_edit_level(Bface_list all, Bface_list core=Bface_list())
{
   // what is the deepest subdiv level that is either:
   //   - controlled by a Bbase
   //   - has holes cut
   //   - has new surface regions attached

   err_adv(debug, "max_subdiv_edit_level:");
   if (all.empty()) {
      assert(core.empty());
      err_adv(debug, "  face list is empty");
      return 0;
   }
   assert(all.mesh() && all.contains_all(core));

   int R = 0;   // level at which deepest edits happened
   int k = 0;   // current level being examined
   while (!all.empty()) {
      k++;
      all = get_subdiv_faces(all,1);
      if (all.empty())
         break;

      // check for controllers
      if (!Bbase::find_owners(all).empty()) {
         err_adv(debug, "  controllers at level %d", k);
         R = k;
      }

      // check for holes at this level:
      if (all.has_any_secondary()) {
         all = all.primary_faces();
         err_adv(debug, "  hole at level %d", k);
         R = k; // holes exist at this level
      }

      // check for new regions
      if (core.empty())
         continue;
      core = get_subdiv_faces(core,1);
      Bface_list new_faces = core.two_ring_faces().primary_faces();
      // see if any of these new ones are actually new:
      new_faces.set_flags(1);
      all.clear_flags();
      new_faces = new_faces.filter(SimplexFlagFilter(1));
      if (!new_faces.empty()) {
         all.append(new_faces);
         err_adv(debug, "  new faces at level %d", k);
         R = k;  // new stuff exists at this level
      }
   }
   return R;
}