Exemplo n.º 1
0
template <typename PointInT> void
pcl::OrganizedFastMesh<PointInT>::makeLeftCutMesh (std::vector<pcl::Vertices>& polygons)
{
  int last_column = input_->width - triangle_pixel_size_columns_;
  int last_row = input_->height - triangle_pixel_size_rows_;

  int i = 0, index_down = 0, index_right = 0, index_down_right = 0, idx = 0;
  int y_big_incr = triangle_pixel_size_rows_ * input_->width,
      x_big_incr = y_big_incr + triangle_pixel_size_columns_;
  // Reserve enough space
  polygons.resize (input_->width * input_->height * 2);

  // Go over the rows first
  for (int y = 0; y < last_row; y += triangle_pixel_size_rows_)
  {
    // Initialize a new row
    i = y * input_->width;
    index_right = i + triangle_pixel_size_columns_;
    index_down = i + y_big_incr;
    index_down_right = i + x_big_incr;

    // Go over the columns
    for (int x = 0; x < last_column; x += triangle_pixel_size_columns_,
                                     i += triangle_pixel_size_columns_,
                                     index_right += triangle_pixel_size_columns_,
                                     index_down += triangle_pixel_size_columns_,
                                     index_down_right += triangle_pixel_size_columns_)
    {
      if (isValidTriangle (i, index_down, index_right))
        if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_right))
          addTriangle (i, index_down, index_right, idx++, polygons);

      if (isValidTriangle (index_right, index_down, index_down_right))
        if (store_shadowed_faces_ || !isShadowedTriangle (index_right, index_down, index_down_right))
          addTriangle (index_right, index_down, index_down_right, idx++, polygons);
    }
  }
  polygons.resize (idx);
}
Exemplo n.º 2
0
void checkCombinations(unsigned long arr[], unsigned long resArr[], int start, int end, int r, int index)
{
    // termination condition
    if(index == r)
    {
        if(!isValidTriangle(resArr))
            count ++;
        return;
    }

    for(int i=start; i < end; i++)
    {
        resArr[index] = arr[i];
        checkCombinations(arr, resArr, i + 1,  end, 3, index + 1);
        
        // removing duplicates
        //while(arr[i] == arr[i+1])
        //     i++; 
    }
}
Exemplo n.º 3
0
template <typename PointInT> void
pcl::OrganizedFastMesh<PointInT>::makeAdaptiveCutMesh (std::vector<pcl::Vertices>& polygons)
{
  int last_column = input_->width - triangle_pixel_size_columns_;
  int last_row = input_->height - triangle_pixel_size_rows_;

  int i = 0, index_down = 0, index_right = 0, index_down_right = 0, idx = 0;
  int y_big_incr = triangle_pixel_size_rows_ * input_->width,
      x_big_incr = y_big_incr + triangle_pixel_size_columns_;
  // Reserve enough space
  polygons.resize (input_->width * input_->height * 2);

  // Go over the rows first
  for (int y = 0; y < last_row; y += triangle_pixel_size_rows_)
  {
    // Initialize a new row
    i = y * input_->width;
    index_right = i + triangle_pixel_size_columns_;
    index_down = i + y_big_incr;
    index_down_right = i + x_big_incr;

    // Go over the columns
    for (int x = 0; x < last_column; x += triangle_pixel_size_columns_,
                                     i += triangle_pixel_size_columns_,
                                     index_right += triangle_pixel_size_columns_,
                                     index_down += triangle_pixel_size_columns_,
                                     index_down_right += triangle_pixel_size_columns_)
    {
      const bool right_cut_upper = isValidTriangle (i, index_down_right, index_right);
      const bool right_cut_lower = isValidTriangle (i, index_down, index_down_right);
      const bool left_cut_upper = isValidTriangle (i, index_down, index_right);
      const bool left_cut_lower = isValidTriangle (index_right, index_down, index_down_right);

      if (right_cut_upper && right_cut_lower && left_cut_upper && left_cut_lower)
      {
        float dist_right_cut = fabsf (input_->points[index_down].z - input_->points[index_right].z);
        float dist_left_cut = fabsf (input_->points[i].z - input_->points[index_down_right].z);
        if (dist_right_cut >= dist_left_cut)
        {
          if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down_right, index_right))
            addTriangle (i, index_down_right, index_right, idx++, polygons);
          if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_down_right))
            addTriangle (i, index_down, index_down_right, idx++, polygons);
        }
        else
        {
          if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_right))
            addTriangle (i, index_down, index_right, idx++, polygons);
          if (store_shadowed_faces_ || !isShadowedTriangle (index_right, index_down, index_down_right))
            addTriangle (index_right, index_down, index_down_right, idx++, polygons);
        }
      }
      else
      {
        if (right_cut_upper)
          if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down_right, index_right))
            addTriangle (i, index_down_right, index_right, idx++, polygons);
        if (right_cut_lower)
          if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_down_right))
            addTriangle (i, index_down, index_down_right, idx++, polygons);
        if (left_cut_upper)
          if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_right))
            addTriangle (i, index_down, index_right, idx++, polygons);
        if (left_cut_lower)
          if (store_shadowed_faces_ || !isShadowedTriangle (index_right, index_down, index_down_right))
            addTriangle (index_right, index_down, index_down_right, idx++, polygons);
      }
    }
  }
  polygons.resize (idx);
}