Esempio n. 1
0
UVsurface*
SWEEP_DISK::build_revolve(
   CWpt_list&   apts,
   CWvec&       n,
   CWpt_list&   spts,
   MULTI_CMDptr cmd
   )
{
   static bool debug = Config::get_var_bool("DEBUG_BUILD_REVOLVE");

   // Editing or Creating
   bool is_editing = !(_surfs.empty());

   Bcurve* bcurve = Bcurve::get_curve(_boundary.edges());
   if (!bcurve) {
      err_adv(debug, "SWEEP_DISK::build_revolve: can't find curve");
      return nullptr;
   }
   if (!bcurve->is_control()) {
      err_adv(debug, "SWEEP_DISK::build_revolve: error: non-control curve");
      return nullptr;
   }

   Map1D3D* axis = new Wpt_listMap(apts, new WptMap(apts[0]), new WptMap(apts[1]), n);

   // XXX - Zachary: add SWEEP_CMD here:

   // Create/Edit the surface of revolution
   UVsurface* ret = nullptr;
   Panel* p = dynamic_cast<Panel*>(Bsurface::get_surface(_enclosed_faces));
   assert(p);
   if (is_editing) {
      assert(!_surfs.empty());
      ret = dynamic_cast<UVsurface*>(_surfs[0]);
      assert(ret);

      TubeMap* tmap = dynamic_cast<TubeMap*>(ret->map());
      assert(tmap);

      // reshape the axis
      Wpt_listMap* m = dynamic_cast<Wpt_listMap*>(tmap->axis());
      assert(m);
      WPT_LIST_RESHAPE_CMDptr a_cmd = make_shared<WPT_LIST_RESHAPE_CMD>(m,apts);
      if (a_cmd->doit())
         cmd->add(a_cmd);

      // reshape the top curve
      double s = spts.back()[2]/spts.front()[2];
      Wtransf M = tmap->axis()->F(1) * Wtransf::scaling(0,s,s) * tmap->axis()->Finv(0);
      WPT_LIST_RESHAPE_CMDptr c1_cmd = make_shared<WPT_LIST_RESHAPE_CMD>(((Wpt_listMap*)tmap->c1()), M*((Wpt_listMap*)tmap->c0())->get_wpts());
      if (c1_cmd->doit())
         cmd->add(c1_cmd);

      // reshape the profile
      cmd->add(make_shared<TUBE_MAP_RESHAPE_CMD>(tmap,spts));

      // change the record
      vector<Panel*>::iterator it = std::find(panels.begin(), panels.end(), p);
      assert(it != panels.end());
      int loc = it - panels.begin();
      profiles[loc] = _profile;

   } else {
      // for recording purposes
      Bpoint_list points;
      Bcurve_list curves;
      Bsurface_list surfs;

      ret =
         UVsurface::build_revolve(bcurve, axis, spts, _enclosed_faces, points, curves, surfs, cmd);
      if (ret) {
         //FLOOR::realign(ret->cur_mesh(), cmd);

         panels.push_back(p);
         bpoints.push_back(points);
         bcurves.push_back(curves);
         bsurfaces.push_back(surfs);
         profiles.push_back(_profile);
      }
   }

   WORLD::add_command(cmd);

   return ret;
}
Esempio n. 2
0
UVsurface*
SWEEP_DISK::build_revolve(
   CWpt_list&   apts,
   CWvec&       n,
   CWpt_list&   spts,
   MULTI_CMDptr cmd
   )
{
   static bool debug = Config::get_var_bool("DEBUG_BUILD_REVOLVE");

   // Editing or Creating
   bool is_editing = !(_surfs.empty());

   Bcurve* bcurve = Bcurve::get_curve(_boundary.edges());
   if (!bcurve) {
      err_adv(debug, "SWEEP_DISK::build_revolve: can't find curve");
      return 0;
   }
   if (!bcurve->is_control()) {
      err_adv(debug, "SWEEP_DISK::build_revolve: error: non-control curve");
      return 0;
   }

   Map1D3D* axis = new Wpt_listMap(apts, new WptMap(apts[0]), new WptMap(apts[1]), n);

   // XXX - Zachary: add SWEEP_CMD here:

   // Create/Edit the surface of revolution
   UVsurface* ret = NULL;
   Panel* p = Panel::upcast(Bsurface::get_surface(_enclosed_faces));
   assert(p);
   if (is_editing) {
      assert(!_surfs.empty());
      ret = UVsurface::upcast(_surfs[0]);
      assert(ret);

      TubeMap* tmap = TubeMap::upcast(ret->map());
      assert(tmap);

      // reshape the axis
      Wpt_listMap* m = Wpt_listMap::upcast(tmap->axis());
      assert(m);
      WPT_LIST_RESHAPE_CMDptr a_cmd = new WPT_LIST_RESHAPE_CMD(m,apts);
      if (a_cmd->doit())
         cmd->add(a_cmd);

      // reshape the top curve
      double s = spts.last()[2]/spts.first()[2];
      Wtransf M = tmap->axis()->F(1) * Wtransf::scaling(0,s,s) * tmap->axis()->Finv(0);
      WPT_LIST_RESHAPE_CMDptr c1_cmd = new WPT_LIST_RESHAPE_CMD(((Wpt_listMap*)tmap->c1()), M*((Wpt_listMap*)tmap->c0())->get_wpts());
      if (c1_cmd->doit())
         cmd->add(c1_cmd);

      // reshape the profile
      cmd->add(new TUBE_MAP_RESHAPE_CMD(tmap,spts));   

      // change the record
      int loc = panels.get_index(p);
      assert(loc >= 0);
      profiles[loc] = _profile;

   } else {
      // for recording purposes
      Bpoint_list points;
      Bcurve_list curves;
      Bsurface_list surfs;

      ret =
         UVsurface::build_revolve(bcurve, axis, spts, _enclosed_faces, points, curves, surfs, cmd);
      if (ret) {
         //FLOOR::realign(ret->cur_mesh(), cmd);

         panels += p;
         bpoints += points;
         bcurves += curves;
         bsurfaces += surfs;
         profiles += _profile;
      }
   }

   WORLD::add_command(cmd);

   return ret;
}