Beispiel #1
0
void smoothMesh(SurfaceMesh &mesh, int maxIter, bool preserveRidges, bool verbose){
    double maxMinAngle = 15;
    double minMaxAngle = 165;
    double minAngle, maxAngle;
    int nSmall, nLarge;
    int nIter = 1;

    if(verbose){
        std::tie(minAngle, maxAngle, nSmall, nLarge) = getMinMaxAngles(mesh, maxMinAngle, minMaxAngle);
        std::cout << "Initial Quality: Min Angle = " << minAngle << ", "
                  << "Max Angle = " << maxAngle << ", "
                  << "# smaller-than-" << maxMinAngle << " = " << nSmall << ", "
                  << "# larger-than-" << minMaxAngle << " = " << nLarge << std::endl;
    }

    for (int nIter = 1; nIter <= maxIter; ++nIter){
        for(auto vertex : mesh.get_level_id<1>()){
            if((*vertex).selected == true){
                surfacemesh_detail::weightedVertexSmooth(mesh, vertex, RINGS);
            }
            //barycenterVertexSmooth(mesh, vertex);
        }

        std::vector<SurfaceMesh::SimplexID<2> > edgesToFlip;
        // Get set of good, non-interfering edges to flip according to the
        // Angle based criteria.
        surfacemesh_detail::selectFlipEdges(mesh, preserveRidges, surfacemesh_detail::checkFlipAngle,
                            std::back_inserter(edgesToFlip));
        for(auto edgeID : edgesToFlip){
            surfacemesh_detail::edgeFlip(mesh, edgeID);
        }
        init_orientation(mesh);
        check_orientation(mesh);

        // Mark for flipping by edge valence.
        // edgesToFlip.clear();
        // selectFlipEdges(mesh, preserveRidges, checkFlipValence,
        //                    std::back_inserter(edgesToFlip));
        // for(auto edgeID : edgesToFlip){
        //     edgeFlip(mesh, edgeID);
        // }
        // init_orientation(mesh);
        // check_orientation(mesh);

        if (verbose){
            std::tie(minAngle, maxAngle, nSmall, nLarge) = getMinMaxAngles(mesh, maxMinAngle, minMaxAngle);
            std::cout << "Iteration " << nIter << ":" << std::endl;
            std::cout << "Min Angle = " << minAngle << ", "
                      << "Max Angle = " << maxAngle << ", "
                      << "# smaller-than-" << maxMinAngle << " = " << nSmall << ", "
                      << "# larger-than-" << minMaxAngle << " = " << nLarge << std::endl;
        }
    }
}
Beispiel #2
0
int		cmd_left(t_server *s, t_client *c,
			 char *cmd, e_client_type type)
{
  (void)type;
  (void)s;
  (void)cmd;
  void	(*orientation[4])(t_client *);

  if (c->state == CHILD)
    return (ERROR);
  init_orientation(orientation);
  if (c->orientation == 1)
    orientation[(c->orientation + 2)](c);
  else
    orientation[(c->orientation - 2) % 4](c);
  cmd_ppo(s, c, NULL, GUI);
  send_data(c->fd, "ok");
  return (SUCCESS);
}
Beispiel #3
0
int main()
{
  if(chdir(PKGDATADIR) != 0)
  {
    printf("data directory %s not found.", PKGDATADIR);
  }

  init();

  init_camera();
  init_board(&board);
  init_striker(&striker);
  init_chips();
  init_orientation(&striker);
  init_instructions();
  init_speed_text();
  init_main_menu();
  init_scores();
  init_game_over_state();

  move_to_main_menu();

  while(!quit)
  {
    frame_start();

    while(!quit && accumulator >= elapsed_time)
    {
      handle_events();
      update();
      render();
      accumulator -= elapsed_time;
    }
  }

  close();
}