本文整理汇总了C++中PointVector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ PointVector::push_back方法的具体用法?C++ PointVector::push_back怎么用?C++ PointVector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointVector
的用法示例。
在下文中一共展示了PointVector::push_back方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Resample
void Resample(PointVector& points, size_t n)
{
double I = PathLength(points) / (n - 1); // interval length
double D = 0.0;
PointVector newpoints;
newpoints.push_back(points[0]);
for (size_t i = 1; i < points.size(); ++i)
{
double d = Distance(points[i - 1], points[i]);
if ((D + d) >= I)
{
double qx = points[i - 1]->X + ((I - D) / d) * (points[i]->X - points[i - 1]->X);
double qy = points[i - 1]->Y + ((I - D) / d) * (points[i]->Y - points[i - 1]->Y);
PointPtr q(new Point(qx, qy));
newpoints.push_back(q);
points.insert(points.begin()+i,q);
D = 0.0;
}
else D += d;
}
// somtimes we fall a rounding-error short of adding the last point, so add it if so
if (newpoints.size() == n - 1)
{
newpoints.push_back(points[points.size() - 1]);
}
points.clear();
points.insert(points.begin(), newpoints.begin(), newpoints.end());
}
示例2: getTrackTriangleStripPoints
PointVector Track::getTrackTriangleStripPoints() const
{
PointVector vStripPoints;
if(m_vPathPoints.size() < 2)
{
return vStripPoints;
}
// First 2 points
NMVector2f v = getNormalizedPerpendicularVector(m_vPathPoints[1] - m_vPathPoints[0]) * m_fTrackWidth;
vStripPoints.push_back(m_vPathPoints[0] + v);
vStripPoints.push_back(m_vPathPoints[0] - v);
// All points in the middle
for(NLib::NSize_t i = 1; i < m_vPathPoints.size() - 1; ++i)
{
NMVector2f v1 = m_vPathPoints[i] - m_vPathPoints[i - 1];
NMVector2f v2 = m_vPathPoints[i + 1] - m_vPathPoints[i];
NMVector2f n = getNormalizedPerpendicularVector(v1 + v2) * m_fTrackWidth;
vStripPoints.push_back(m_vPathPoints[i] + n);
vStripPoints.push_back(m_vPathPoints[i] - n);
}
// Last 2 points
NLib::NSize_t uLastIndex = m_vPathPoints.size() - 1;
v = getNormalizedPerpendicularVector(m_vPathPoints[uLastIndex] - m_vPathPoints[uLastIndex - 1]) * m_fTrackWidth;
vStripPoints.push_back(m_vPathPoints[uLastIndex] + v);
vStripPoints.push_back(m_vPathPoints[uLastIndex] - v);
return vStripPoints;
}
示例3: mouseMove
void MouseMovementManager::mouseMove(QPointF const & pnt)
{
PointVector path = mPath.back();
mPath.pop_back();
path.push_back(pnt);
mPath.push_back(path);
recountCentre();
}
示例4: leaveFromZone
PointVector Space::leaveFromZone(const PointVector& vec, const Point& splitPoint, unsigned int d)
{
PointVector result;
PointVector::const_iterator iter = vec.begin();
PointVector::const_iterator endIter = vec.end();
for(;iter!=endIter;++iter)
{
if(iter->distanceXTo(splitPoint)<=d)
result.push_back(*iter);
}
return result;
}
示例5: TranslateToOrigin
void TranslateToOrigin(PointVector& points)
{
PointPtr c = Centroid(points);
PointVector newpoints;
for (size_t i = 0; i < points.size(); ++i)
{
double qx = points[i]->X - c->X;
double qy = points[i]->Y - c->Y;
newpoints.push_back(PointPtr(new Point(qx, qy)));
}
points.clear();
points.insert(points.begin(), newpoints.begin(), newpoints.end());
}
示例6: ScaleToSquare
void ScaleToSquare(PointVector& points, double size)
{
RectanglePtr B = BoundingBox(points);
PointVector newpoints;
for (size_t i = 0; i < points.size(); ++i)
{
double qx = points[i]->X * (size / B->Width);
double qy = points[i]->Y * (size / B->Height);
newpoints.push_back(PointPtr(new Point(qx, qy)));
}
points.clear();
points.insert(points.begin(), newpoints.begin(), newpoints.end());
}
示例7: fourier_broken
void fourier_broken(T &m, feature_t* buf) {
int dftCount = FDLENGTH;
typename ImageFactory<T>::view_type *tmp = simple_image_copy(m);
// get contour points for each CC
ImageList* ccs = cc_analysis(*tmp);
PointVector p;
for(ImageList::iterator cc_it = ccs->begin(); cc_it != ccs->end();
cc_it++) {
Cc* cc = static_cast<Cc*>(*cc_it);
Point orig = cc->origin();
PointVector* cc_p = contour_pavlidis(*cc);
for(PointVector::iterator p_it = cc_p->begin();
p_it != cc_p->end(); p_it++) {
p.push_back(*p_it + orig);
}
delete *cc_it;
delete cc_p;
}
delete ccs;
delete tmp->data();
delete tmp;
if (p.size() == 0) {
for (int k = 0; k < dftCount; k++)
buf[k] = 0.0;
return;
}
else if (p.size() == 1) {
buf[0] = 1.0;
for (int k = 1; k < dftCount; k++)
buf[k] = 0.0;
return;
}
// calculate convex hull and interpolate points
PointVector* hullPoints = convex_hull_from_points(&p);
FloatPointVector* interpolatedHullPoints =
interpolatePolygonPoints(hullPoints);
FloatVector* distances = minimumContourHullDistances(interpolatedHullPoints, &p);
floatFourierDescriptorBrokenA(interpolatedHullPoints, &p, distances, dftCount, buf);
delete hullPoints;
delete interpolatedHullPoints;
delete distances;
}
示例8: RotateBy
void RotateBy(PointVector& points, double theta)
{
PointPtr c = Centroid(points);
double cosine = cos(theta);
double sine = sin(theta);
PointVector newpoints;
for (size_t i = 0; i < points.size(); ++i)
{
double qx = (points[i]->X - c->X) * cosine - (points[i]->Y - c->Y) * sine + c->X;
double qy = (points[i]->X - c->X) * sine + (points[i]->Y - c->Y) * cosine + c->Y;
newpoints.push_back(PointPtr(new Point(qx, qy)));
}
points.clear();
points.insert(points.begin(), newpoints.begin(), newpoints.end());
}
示例9: eliminate_triangle
int FilteredProcess::eliminate_triangle(const Triangle &triangle)
{
if (points_.size() != 2 * get_sensor_cnt())
return -1;
PointVector valid;
for (auto p : points_)
if (!triangle.is_inside(p))
valid.push_back(p);
if (valid.size() != get_sensor_cnt())
return -1;
points_ = valid;
return 0;
}
示例10: TP
void auxdata::DrcPoly::motionDraw(const layprop::DrawProperties&, CtmQueue& transtack,
SGBitSet* plst) const
{
CTM trans = transtack.front();
PointVector* ptlist = DEBUG_NEW PointVector;
ptlist->reserve(_psize);
for (unsigned i = 0; i < _psize; i++)
{
ptlist->push_back( TP(_pdata[2*i], _pdata[2*i+1]) * trans);
}
glBegin(GL_LINE_LOOP);
for (unsigned i = 0; i < _psize; i++)
{
glVertex2i((*ptlist)[i].x(), (*ptlist)[i].y());
}
glEnd();
ptlist->clear();
delete ptlist;
}
示例11: PointVector_from_python
inline PointVector* PointVector_from_python(PyObject* py) {
PyObject* seq = PySequence_Fast(py, "Argument must be an iterable of Points");
if (seq == NULL)
return 0;
int size = PySequence_Fast_GET_SIZE(seq);
PointVector* cpp = new PointVector();
try {
cpp->reserve(size);
for (int i = 0; i < size; ++i) {
PyObject* point = PySequence_Fast_GET_ITEM(seq, i);
Point p = coerce_Point(point);
cpp->push_back(p);
}
} catch (std::exception e) {
delete cpp;
Py_DECREF(seq);
PyErr_SetString(PyExc_RuntimeError, e.what());
return 0;
}
Py_DECREF(seq);
return cpp;
}
示例12: WhiteoutHelper
bool Whiteout::WhiteoutHelper(
bool viral,
Mask& mask,
unsigned int& depth,
PointVector& pv,
Point p)
{
// Perform the additional check. Note this is a virtual function.
if (AdditionalCheck(p))
{
// The check says this point is invalid.
return false;
}
// Get the point.
uint8_t* data = Point::GetDataByPoint(m_src, p);
if (data == 0)
{
// The point is outside the image.
return false;
}
// This will be on the stack. Bad, but no avoiding this.
Point point(0, 0);
// If any colour component is less that half intensity, it is considered a
// "dark" cell, and we will "white" it out.
if (data[0] < 0x7f || data[1] < 0x7f || data[2] < 0x7f)
{
// Maximum stack depth.
depth++;
if (depth > 100)
{
pv.push_back(p);
return false;
}
// Whiteout this cell.
data[0] = mask.GetBlue();
data[1] = mask.GetGreen();
data[2] = mask.GetRed();
// Point found callback (virtual).
PointFound(p);
if (viral)
{
// To the right.
point = Point(p.GetX()+1, p.GetY());
WhiteoutHelper(viral, mask, depth, pv, point);
// To the bottom.
point = Point(p.GetX(), p.GetY()+1);
WhiteoutHelper(viral, mask, depth, pv, point);
// To the left.
point = Point(p.GetX()-1, p.GetY());
WhiteoutHelper(viral, mask, depth, pv, point);
// To the top.
point = Point(p.GetX(), p.GetY()-1);
WhiteoutHelper(viral, mask, depth, pv, point);
}
return true;
}
return false;
}