本文整理汇总了C++中SearchPointVector类的典型用法代码示例。如果您正苦于以下问题:C++ SearchPointVector类的具体用法?C++ SearchPointVector怎么用?C++ SearchPointVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SearchPointVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: project
void
project(SearchPointVector& spv, const TaskProjection& tp)
{
for (SearchPointVector::iterator i = spv.begin(); i!= spv.end(); ++i) {
i->project(tp);
}
}
示例2: 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;
}
示例3: 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));
}
示例4:
void
MapCanvas::Project(const Projection &projection,
const SearchPointVector &points, BulkPixelPoint *screen)
{
for (auto it = points.begin(); it != points.end(); ++it)
*screen++ = projection.GeoToScreen(it->GetLocation());
}
示例5:
void
MapCanvas::project(const Projection &projection,
const SearchPointVector &points, RasterPoint *screen)
{
for (auto it = points.begin(); it != points.end(); ++it)
*screen++ = projection.GeoToScreen(it->get_location());
}
示例6: write_spv
void write_spv (const SearchPointVector& spv)
{
for (auto v = spv.begin(); v != spv.end(); ++v) {
write_point(*v, v->get_flatLocation(), "spv");
}
printf("spv\n");
fflush(stdout);
}
示例7: FindClearingPair
AirspaceRoute::ClearingPair
AirspaceRoute::GetPairs(const SearchPointVector &spv,
const RoutePoint &start, const RoutePoint &dest) const
{
SearchPointVector::const_iterator i_closest = spv.NearestIndexConvex(start);
SearchPointVector::const_iterator i_furthest = spv.NearestIndexConvex(dest);
return FindClearingPair(spv, i_closest, i_furthest, start);
}
示例8: is_convex
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;
}
示例9: nearest_point_convex
static FlatGeoPoint
nearest_point_convex(const SearchPointVector& spv, const FlatGeoPoint &p3)
{
unsigned distance_min = 0-1;
SearchPointVector::const_iterator i_best = spv.end();
// find nearest point in vector
for (SearchPointVector::const_iterator i = spv.begin();
i!= spv.end(); ++i) {
unsigned d_this = p3.distance_sq_to(i->get_flatLocation());
if (d_this<distance_min) {
distance_min = d_this;
i_best = i;
}
}
FlatGeoPoint pc = i_best->get_flatLocation();
// find nearest point on this segment
FlatGeoPoint pa = segment_nearest_point(spv,i_best,p3);
if (!(pa == pc)) {
unsigned d_seg = pa.distance_sq_to(p3);
if (d_seg < distance_min) {
distance_min = d_seg;
pc = pa;
}
}
// find nearest point on previous segment
SearchPointVector::const_iterator i_prev;
if (i_best == spv.begin()) {
i_prev = spv.end()-1;
} else {
i_prev = i_best-1;
}
FlatGeoPoint pb = segment_nearest_point(spv,i_prev,p3);
if (!(pb == pc)) {
unsigned d_seg = pb.distance_sq_to(p3);
if (d_seg < distance_min) {
distance_min = d_seg;
pc = pb;
}
}
return pc;
}
示例10: segment_nearest_point
static FlatGeoPoint
segment_nearest_point(const SearchPointVector& spv,
const SearchPointVector::const_iterator i1,
const FlatGeoPoint &p3)
{
if (i1+1 == spv.end()) {
return nearest_point(i1->get_flatLocation(),
spv.begin()->get_flatLocation(),
p3);
} else {
return nearest_point(i1->get_flatLocation(),
(i1+1)->get_flatLocation(),
p3);
}
}
示例11:
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);
}
示例12: SegmentNearestPoint
gcc_pure
static FlatGeoPoint
SegmentNearestPoint(const SearchPointVector& spv,
const SearchPointVector::const_iterator i1,
const FlatGeoPoint &p3)
{
if (i1+1 == spv.end()) {
return NearestPoint(i1->GetFlatLocation(),
spv.begin()->GetFlatLocation(),
p3);
} else {
return NearestPoint(i1->GetFlatLocation(),
(i1 + 1)->GetFlatLocation(),
p3);
}
}
示例13:
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);
}
示例14: p
AirspaceRoute::ClearingPair
AirspaceRoute::GetBackupPairs(const SearchPointVector& spv,
const RoutePoint &_start,
const RoutePoint &intc) const
{
SearchPointVector::const_iterator start = spv.NearestIndexConvex(intc);
ClearingPair p(intc, intc);
SearchPointVector::const_iterator i_left = spv.NextCircular(start);
p.first = AFlatGeoPoint(i_left->GetFlatLocation(), _start.altitude); // @todo alt!
SearchPointVector::const_iterator i_right = spv.PreviousCircular(start);
p.second = AFlatGeoPoint(i_right->GetFlatLocation(), _start.altitude); // @todo alt!
return p;
}
示例15: 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);
}