本文整理汇总了C++中PointList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ PointList::size方法的具体用法?C++ PointList::size怎么用?C++ PointList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointList
的用法示例。
在下文中一共展示了PointList::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy_block
bool copy_block(Tile* tiles, const Block* block) {
const p2i& p = block->position;
int xp = (p.x - START_X + SQUARE_SIZE / 2) / SQUARE_SIZE;
int yp = (p.y - START_Y + SQUARE_SIZE / 2) / SQUARE_SIZE;
if (is_block_available(tiles, xp, yp)) {
for (int i = 0; i < 4; ++i) {
int cx = xp + MARK_STEPS[i * 2];
int cy = yp + MARK_STEPS[i * 2 + 1];
uint32_t idx = get_tiles_index(cx, cy);
Tile& t = tiles[idx];
t.state.set(BIT_MARKED);
t.color = block->colors[i];
PointList list;
check(tiles, cx, cy, -1, list, true);
list.add(cx, cy);
if (list.size() > 2) {
//LOG << "connected";
t.state.set(BIT_COHERENT);
for (size_t j = 0; j < list.size(); ++j) {
const p2i& p = list.get(j);
//LOG << j << " = " << p.x << " " << p.y;
set_state(tiles, p.x, p.y, BIT_COHERENT);
}
}
}
determineEdges(tiles);
return true;
}
else {
//LOG << "Block is not available";
}
return false;
}
示例2: isIntersectsPointPolygon
bool CollisionManager::isIntersectsPointPolygon(ICollisionHull* point, ICollisionHull* polygon)
{
PointCollisionHull* pointCH = dynamic_cast<PointCollisionHull*>(point);
PoligonCollisionHull* poligonCH = dynamic_cast<PoligonCollisionHull*>(polygon);
Vector3 position = pointCH->getPosition();
PointList points = poligonCH->getPoints();
int i0, i1;
float A, B, C, D;
Vector3 P0, P1;
for(int i = 0; i < points.size(); i++)
{
i0 = i;
i1 = (i == (points.size() - 1)) ? 0 : i + 1;
P0 = points[i0];
P1 = points[i1];
A = P0._y - P1._y;
B = P1._x - P0._x;
C = (P0._x * P1._y) - (P1._x * P0._y);
D = (A * position._x) + (B * position._y) + C;
if(D > 0)
{
return false;
}
}
return true;
}
示例3: computePlanes
void computePlanes(const PointList& front, const PointList& back, Polytope::PlaneList& planeList)
{
for(unsigned int i=0;i<front.size();++i)
{
unsigned int i_1 = (i+1)%front.size(); // do the mod to wrap the index round back to the start.
if (!(front[i].first & front[i_1].first))
{
planeList.push_back(Plane(front[i].second,front[i_1].second,back[i].second));
}
}
}
示例4: UpdatePoints
void ColoredPolygon::UpdatePoints(const PointList &points)
{
_dots.resize(points.size());
for (uint i = 0; i < points.size(); ++i)
{
_dots[i].pos = points[i];
}
CalcWidthAndHeight();
GenerateTriangles();
_dotUnderCursor.clear();
_selectedDots.clear();
InitCorners();
}
示例5: writeSQL
void writeSQL(Site_2 site, PointList polygon, char* outdir)
{
std::cout << "INSERT INTO " << outdir << " (geom, id) VALUES (";
std::cout << "'POLYGON ((";
for (int i = 0; i < polygon.size(); i++) {
Point_2 p = polygon.at(i);
std::cout << p.x() << " " << p.y();
if (i < polygon.size() - 1) {
std::cout << ", ";
}
}
std::cout << "))', " << site.id() << ");" << std::endl;
}
示例6: handleDual
void handleDual(Hyperbola_segment_2 hs, std::vector<PointList>& polylines)
{
std::cerr << "hyperbola segment" << std::endl; //hs.draw(str);
PointList p;
hs.generate_points(p);
std::cerr << "# hyperbola points: " << p.size() << std::endl;
PointList points;
points.insert(points.end(), p.begin(), p.end());
polylines.push_back(points);
for (unsigned int i = 0; i < p.size() - 1; i++) {
Segment_2 seg(p[i], p[i+1]);
// doing nothing here
}
}
示例7: draw_hand_trace
void draw_hand_trace(sf::RenderWindow& window,
const PointList& pointList,
const sf::Color& color,
const float depthScale)
{
if (pointList.size() < 2) { return; }
const float thickness = 4;
auto it = pointList.begin();
astra::Vector2i previousPoint = *it;
while (it != pointList.end())
{
const astra::Vector2i currentPoint = *it;
++it;
const sf::Vector2f p1((previousPoint.x + .5f) * depthScale,
(previousPoint.y + .5f) * depthScale);
const sf::Vector2f p2((currentPoint.x + .5f) * depthScale,
(currentPoint.y + .5f) * depthScale);
previousPoint = currentPoint;
window.draw(sfLine(p1, p2, color, thickness));
}
}
示例8:
void Dataset<D, ELEM_TYPE>::load(const PointList& newPoints)
{
// Pre-allocate memory in one sys call
m_points.reserve(m_points.size() + newPoints.size());
// Append given points to end of current point list
m_points.insert(m_points.end(), newPoints.begin(), newPoints.end());
}
示例9: CalcWidthAndHeight
ColoredPolygon::ColoredPolygon(const PointList &points)
{
_dots.resize(points.size());
for (uint i = 0; i < points.size(); ++i)
{
_dots[i].pos = points[i];
}
CalcWidthAndHeight();
GenerateTriangles();
_mouseDown = false;
_dotUnderCursor.clear();
_selectedDots.clear();
_debugDraw = false;
InitCorners();
_color = 0xFFFFFFFF;
}
示例10:
BucketKDTreeNode<D, ELEM_TYPE>::BucketKDTreeNode(
BucketKDTreeNode<D, ELEM_TYPE>* parent,
const PointList& points)
: m_parent(parent), m_totalPoints(points.size()),
m_isLeaf(true), m_points(points),
m_leftChild(NULL), m_rightChild(NULL),
m_cuttingDimension(0), m_cuttingValue(0)
{
}
示例11: copyPointListToVertexList
void copyPointListToVertexList(const PointList& in,VertexList& out)
{
out.reserve(in.size());
for(PointList::const_iterator itr=in.begin();
itr!=in.end();
++itr)
{
out.push_back(itr->second);
}
}
示例12: computePolytopeVolume
// compute the volume between the front and back polygons of the occluder/hole.
float computePolytopeVolume(const PointList& front, const PointList& back)
{
float volume = 0.0f;
Vec3 frontStart = front[0].second;
Vec3 backStart = back[0].second;
for(unsigned int i=1;i<front.size()-1;++i)
{
volume += computeVolume(frontStart, front[i].second, front[i+1].second,
backStart, back[i].second, back[i+1].second);
}
return volume;
}
示例13: clip
// clip the convex hull 'in' to plane to generate a clipped convex hull 'out'
// return true if points remain after clipping.
unsigned int clip(const Plane& plane,const PointList& in, PointList& out,unsigned int planeMask)
{
std::vector<float> distance;
distance.reserve(in.size());
for(PointList::const_iterator itr=in.begin();
itr!=in.end();
++itr)
{
distance.push_back(plane.distance(itr->second));
}
out.clear();
for(unsigned int i=0;i<in.size();++i)
{
unsigned int i_1 = (i+1)%in.size(); // do the mod to wrap the index round back to the start.
if (distance[i]>=0.0f)
{
out.push_back(in[i]);
if (distance[i_1]<0.0f)
{
unsigned int mask = (in[i].first & in[i_1].first) | planeMask;
float r = distance[i_1]/(distance[i_1]-distance[i]);
out.push_back(Point(mask,in[i].second*r+in[i_1].second*(1.0f-r)));
}
}
else if (distance[i_1]>0.0f)
{
unsigned int mask = (in[i].first & in[i_1].first) | planeMask;
float r = distance[i_1]/(distance[i_1]-distance[i]);
out.push_back(Point(mask,in[i].second*r+in[i_1].second*(1.0f-r)));
}
}
return out.size();
}
示例14: writeWKT
void writeWKT(Site_2 site, PointList polygon, char* outdir)
{
// open an output file for storing the WKT
std::stringstream s;
s << outdir << "/" << site.id() << ".wkt";
std::string polygonFileName = s.str();
std::cerr << "filename: " << polygonFileName << std::endl;
std::ofstream file;
file.open(polygonFileName.c_str());
// write WKT file
file << "POLYGON ((";
for (int i = 0; i < polygon.size(); i++) {
Point_2 p = polygon.at(i);
file << p.x() << " " << p.y();
if (i < polygon.size() - 1) {
file << ", ";
}
}
file << "))";
file.close();
}
示例15: fastFilterPointList
boost::optional<Point> fastFilterPointList(
const PointList& pointList,
std::vector<Point>& newPointList) const
{
assert(!pointList.empty());
newPointList.reserve(pointList.size() - 1);
std::copy(
++pointList.begin(),
pointList.end(),
std::back_inserter(newPointList)
);
return boost::optional<Point>(pointList.front());
} // fastFilterFunctorList