当前位置: 首页>>代码示例>>C++>>正文


C++ SearchPointVector::size方法代码示例

本文整理汇总了C++中SearchPointVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchPointVector::size方法的具体用法?C++ SearchPointVector::size怎么用?C++ SearchPointVector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchPointVector的用法示例。


在下文中一共展示了SearchPointVector::size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ApplyHandicap

ContestResult
OLCSISAT::CalculateResult(const ContestTraceVector &solution) const
{
  // build convex hull from solution
  SearchPointVector spv;
  for (unsigned i = 0; i < num_stages; ++i)
    spv.push_back(SearchPoint(solution[i].location));

  spv.PruneInterior();

  // now add leg distances making up the convex hull
  fixed G = fixed_zero;

  if (spv.size() > 1) {
    for (unsigned i = 0; i + 1 < spv.size(); ++i)
      G += spv[i].DistanceTo(spv[i + 1].GetLocation());

    // closing leg (end to start)
    G += spv[spv.size() - 1].DistanceTo(spv[0].GetLocation());
  }

  // R distance (start to end)
  const fixed R = solution[0].DistanceTo(solution[num_stages - 1].GetLocation());

  // V zigzag-free distance
  const fixed V = G - R;

  // S = total distance
  ContestResult result = ContestDijkstra::CalculateResult(solution);
  result.score = ApplyHandicap((V + 3 * result.distance) / 4000);
  return result;
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例2: apply_handicap

fixed
OLCSISAT::calc_score() const
{
  // build convex hull from solution
  SearchPointVector spv;
  for (unsigned i = 0; i < num_stages; ++i)
    spv.push_back(solution[i]);

  prune_interior(spv);

  // now add leg distances making up the convex hull
  fixed G = fixed_zero;

  if (spv.size() > 1) {
    for (unsigned i = 0; i + 1 < spv.size(); ++i)
      G += spv[i].distance(spv[i + 1].get_location());

    // closing leg (end to start)
    G += spv[spv.size() - 1].distance(spv[0].get_location());
  }

  // R distance (start to end)
  const fixed R = solution[0].distance(solution[num_stages - 1].get_location());

  // V zigzag-free distance
  const fixed V = G - R;

  // S = total distance
  const fixed S = calc_distance();

  return apply_handicap((V + fixed(3) * S) * fixed(0.00025));
}
开发者ID:Mrdini,项目名称:XCSoar,代码行数:32,代码来源:OLCSISAT.cpp

示例3: gs

bool 
is_convex(const SearchPointVector& spv)
{
  bool changed=false;
  GrahamScan gs(spv);
  size_t size_before = spv.size();
  SearchPointVector res;
  res = gs.prune_interior(&changed);
  return res.size() != size_before;
}
开发者ID:Plantain,项目名称:XCSoar,代码行数:10,代码来源:SearchPointVector.cpp

示例4: visible

bool
MapCanvas::prepare_polygon(const SearchPointVector &points)
{
  unsigned num_points = points.size();
  if (num_points < 3)
    return false;

  /* copy all SearchPointVector elements to geo_points */
  geo_points.GrowDiscard(num_points * 3);
  for (unsigned i = 0; i < num_points; ++i)
    geo_points[i] = points[i].get_location();

  /* clip them */
  num_raster_points = clip.ClipPolygon(geo_points.begin(),
                                       geo_points.begin(), num_points);
  if (num_raster_points < 3)
    /* it's completely outside the screen */
    return false;

  /* project all GeoPoints to screen coordinates */
  raster_points.GrowDiscard(num_raster_points);
  for (unsigned i = 0; i < num_raster_points; ++i)
    raster_points[i] = projection.GeoToScreen(geo_points[i]);

  return visible(raster_points.begin(), num_raster_points);
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:26,代码来源:MapCanvas.cpp

示例5:

void
StencilMapCanvas::DrawSearchPointVector(const SearchPointVector &points)
{
  size_t size = points.size();
  if (size < 3)
    return;

  /* copy all SearchPointVector elements to geo_points */
  geo_points.GrowDiscard(size * 3);
  for (unsigned i = 0; i < size; ++i)
    geo_points[i] = points[i].GetLocation();

  /* clip them */
  size = clip.ClipPolygon(geo_points.begin(), geo_points.begin(), size);
  if (size < 3)
    /* it's completely outside the screen */
    return;

  /* draw it all */
  RasterPoint screen[size];
  for (unsigned i = 0; i < size; ++i)
    screen[i] = proj.GeoToScreen(geo_points[i]);

  buffer.DrawPolygon(&screen[0], size);
  if (use_stencil)
    stencil.DrawPolygon(&screen[0], size);
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:27,代码来源:StencilMapCanvas.cpp

示例6: PartitionPoints

bool
GrahamScan::PruneInterior()
{
  SearchPointVector res;

  /* the result is usually one more than the input vector - is that a
   bug? */
  res.reserve(size + 1);

  if (size < 3) {
    std::copy(raw_points.begin(), raw_points.end(), std::back_inserter(res));
    return false;
    // nothing to do
  }

  PartitionPoints();
  BuildHull();

  for (unsigned i = 0; i + 1 < lower_hull.size(); i++)
    res.push_back(*lower_hull[i]);

  for (int i = upper_hull.size() - 1; i >= 0; i--)
    res.push_back(*upper_hull[i]);

  if (res.size() == size)
    return false;

  raw_vector.swap(res);
  return true;
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:30,代码来源:GrahamScan.cpp

示例7:

void 
MapDrawHelper::draw_search_point_vector(const SearchPointVector& points)
{
  size_t size = points.size();
  if (size < 3)
    return;

  /* copy all SearchPointVector elements to geo_points */
  geo_points.GrowDiscard(size * 3);
  for (unsigned i = 0; i < size; ++i)
    geo_points[i] = points[i].get_location();

  /* clip them */
  size = clip.ClipPolygon(geo_points.begin(), geo_points.begin(), size);
  if (size < 3)
    /* it's completely outside the screen */
    return;

  /* draw it all */
  RasterPoint screen[size];
  for (unsigned i = 0; i < size; ++i)
    screen[i] = m_proj.GeoToScreen(geo_points[i]);

  if (!MapCanvas::visible(m_canvas, screen, size))
    return;

  m_buffer.polygon(&screen[0], size);
  if (m_use_stencil)
    m_stencil.polygon(&screen[0], size);
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例8: nearest_point

FlatGeoPoint nearest_point(const SearchPointVector& spv, 
                            const FlatGeoPoint &p3,
                            const bool is_convex)
{
  // special case
  if (spv.empty()) {
    return p3; // really should be error
  } else if (spv.size()==1) {
    return spv[0].get_flatLocation();
  }

  if (is_convex) {
    /** \todo Strictly speaking it isn't correct to use this function
     */
    return nearest_point_convex(spv,p3);
  } else {
    return nearest_point_nonconvex(spv,p3);
  }
}
开发者ID:Plantain,项目名称:XCSoar,代码行数:19,代码来源:SearchPointVector.cpp

示例9: map_canvas

void 
MapDrawHelper::draw_search_point_vector(Canvas& the_canvas, 
                                        const SearchPointVector& points) 
{
  const size_t size = points.size();
  if (size<3) {
    return;
  }

  MapCanvas map_canvas(the_canvas, m_proj);
  POINT screen[size];
  map_canvas.project(points, screen);

  if (!map_canvas.visible(screen, size))
    return;

  the_canvas.polygon(&screen[0], size);
  if (m_use_stencil) {
    m_stencil.polygon(&screen[0], size);
  }
}
开发者ID:Plantain,项目名称:XCSoar,代码行数:21,代码来源:MapDrawHelper.cpp

示例10:

bool 
GrahamScan::prune_interior()
{
  SearchPointVector res;

  /* the result is usually one more than the input vector - is that a
     bug? */
  res.reserve(size + 1);

  if (size<3) {
    std::copy(raw_points.begin(), raw_points.end(),
              std::back_inserter(res));
    return false;
    // nothing to do
  }

  partition_points();
  build_hull();

  for ( unsigned i = 0 ; i+1 < lower_hull.size() ; i++ ) {
    res.push_back(*lower_hull[i]);
  }
  for ( int i = upper_hull.size()-1; i>=0 ; i-- ) {
    res.push_back(*upper_hull[i]);
  }

// if (!has_changed) {
//      *changed = !std::equal(res.begin(), res.end(), raw_vector.begin() );
//    }

  if (res.size() != size) {
    raw_vector.swap(res);
    return true;
  } else {
    return false;
  }
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:37,代码来源:GrahamScan.cpp

示例11: size

GrahamScan::GrahamScan(SearchPointVector& sps, const fixed sign_tolerance):
  raw_points(sps.begin(), sps.end()), raw_vector(sps), size(sps.size()),
  tolerance(sign_tolerance)
{
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:5,代码来源:GrahamScan.cpp


注:本文中的SearchPointVector::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。