本文整理汇总了C++中Point2D类的典型用法代码示例。如果您正苦于以下问题:C++ Point2D类的具体用法?C++ Point2D怎么用?C++ Point2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Point2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void operator()(const Point2D& p) {
GNode n = g.createNode(0);
g.addNode(n);
nodes[p.x() * height + p.y()] = n;
}
示例2: switch
bool mitk::PlanarDoubleEllipse::SetControlPoint(unsigned int index, const Point2D& point, bool createIfDoesNotExist)
{
switch (index)
{
case 0:
{
Point2D centerPoint = this->GetControlPoint(0);
Vector2D vector = point - centerPoint;
Superclass::SetControlPoint(0, point, createIfDoesNotExist);
Superclass::SetControlPoint(1, this->GetControlPoint(1) + vector, createIfDoesNotExist);
Superclass::SetControlPoint(2, this->GetControlPoint(2) + vector, createIfDoesNotExist);
Superclass::SetControlPoint(3, this->GetControlPoint(3) + vector, createIfDoesNotExist);
break;
}
case 1:
{
Vector2D vector = point - this->GetControlPoint(1);
Superclass::SetControlPoint(1, point, createIfDoesNotExist);
Point2D centerPoint = this->GetControlPoint(0);
Vector2D outerMajorVector = point - centerPoint;
Vector2D outerMinorVector;
outerMinorVector[0] = outerMajorVector[1];
outerMinorVector[1] = -outerMajorVector[0];
if (!m_ConstrainCircle)
{
outerMinorVector.Normalize();
outerMinorVector *= centerPoint.EuclideanDistanceTo(this->GetControlPoint(2));
}
Superclass::SetControlPoint(2, centerPoint + outerMinorVector, createIfDoesNotExist);
Vector2D innerMajorVector = outerMajorVector;
if (!m_ConstrainThickness)
{
innerMajorVector.Normalize();
innerMajorVector *= centerPoint.EuclideanDistanceTo(this->GetControlPoint(3) - vector);
}
Superclass::SetControlPoint(3, centerPoint - innerMajorVector, createIfDoesNotExist);
break;
}
case 2:
{
m_ConstrainCircle = false;
Superclass::SetControlPoint(2, point, createIfDoesNotExist);
break;
}
case 3:
{
m_ConstrainThickness = false;
Superclass::SetControlPoint(3, point, createIfDoesNotExist);
break;
}
default:
return false;
}
return true;
}
示例3: copy
bool StudentLocalization::stepFindExactEyes(const IntensityImage &image, FeatureMap &features) const {
int temp = 0;
ImageIO::saveIntensityImage(image, ImageIO::getDebugFileName("input.png"));
IntensityImageStudent copy(image);
double** d_kern = new double*[3];
for (int y = 0; y < 3; y++) {
d_kern[y] = new double[3];
}
d_kern[0][0] = 0;
d_kern[0][1] = 1;
d_kern[0][2] = 0;
d_kern[1][0] = 1;
d_kern[1][1] = 0;
d_kern[1][2] = 1;
d_kern[2][0] = 0;
d_kern[2][1] = 1;
d_kern[2][2] = 0;
StudentKernel dilation = StudentKernel(d_kern, 3, 3, 0);
Feature top = features.getFeature(Feature::FEATURE_HEAD_TOP);
Feature bottom = features.getFeature(Feature::FEATURE_CHIN);
Feature nose_bottom = features.getFeature(Feature::FEATURE_NOSE_BOTTOM);
Feature headsideleft = features.getFeature(Feature::FEATURE_HEAD_LEFT_SIDE);
Feature headsideright = features.getFeature(Feature::FEATURE_HEAD_RIGHT_SIDE);
const int nose_to_top = nose_bottom.getY() - top.getY();
#if UNNECESSARY_CODE
#endif
Point2D<double> headsidelp = headsideleft.getPoints()[0];
headsidelp.setY(top.getY() + (nose_to_top*3/5));
headsidelp.setX((headsidelp.getX()));
Point2D<double> headsiderp = headsideright.getPoints()[0];
headsiderp.setY(nose_bottom.getY() - (nose_to_top*1/5));
headsiderp.setX((headsiderp.getX() + 3));
IntensityImageStudent eyes = ImageUtils::subimage(&image, headsidelp, headsiderp);
IntensityImageStudent eyes_dilated = dilation.dilate(&eyes);
StudentHistogram histo{eyes_dilated.getWidth()};
int zero_points[2] = { 0, histo.get_length() * 1 / 7 };
int lowest_found[2] = { eyes_dilated.getHeight(), eyes_dilated.getHeight() };
int left_out = 0, left_out_x = 0,
right_out = 0, right_out_x = 0,
left_in = 0, left_in_x = 0,
right_in = 0, right_in_x = 0;
for (int x = 0; x < histo.get_length(); x++){
temp = 0;
for (int y = 0; y < eyes_dilated.getHeight(); y++){
temp += eyes_dilated.getPixel(x, y) > 127 ? 0 : 1;
}
histo.set_value(x, temp);
if (x < histo.get_length() * 3 / 10 && temp <= lowest_found[0]){
lowest_found[0] = temp;
zero_points[0] = x;
}
if (x > histo.get_length() * 7 / 10 && temp < lowest_found[1]){
lowest_found[1] = temp;
zero_points[1] = x;
}
}
headsidelp.setX(headsidelp.getX() + zero_points[0]);
headsiderp.setX(headsiderp.getX() - (histo.get_length() - zero_points[1]));
headsidelp.setY(top.getY() + (nose_to_top * 2/ 5));
headsiderp.setY(nose_bottom.getY());
IntensityImageStudent eyes2(ImageUtils::subimage(&image, headsidelp, headsiderp));
IntensityImageStudent eyes_copy2(dilation.dilate(&eyes2));
histo.cut_to_size(zero_points[0], zero_points[1]);
for (int x = 0; x < histo.get_length(); x++){
if (x < histo.get_length() * 2 / 9){
left_out_x = histo.get_value(x) > left_out ? x : left_out_x;
left_out = histo.get_value(x) > left_out ? histo.get_value(x) : left_out;
}
else if (x < histo.get_length() * 4 / 9 && x > histo.get_length() * 2 / 9){
left_in_x = histo.get_value(x) > left_in ? x : left_in_x;
left_in = histo.get_value(x) > left_in ? histo.get_value(x) : left_in;
}
else if (x > histo.get_length() * 7 / 9){
right_out_x = histo.get_value(x) > right_out ? x : right_out_x;
right_out = histo.get_value(x) > right_out ? histo.get_value(x) : right_out;
}
else if (x > histo.get_length() * 5 / 9){
right_in_x = histo.get_value(x) > right_in ? x : right_in_x;
right_in = histo.get_value(x) > right_in ? histo.get_value(x) : right_in;
}
}
//.........这里部分代码省略.........
示例4: Move
void Entity::Move(Point2D new_path)
{
m_position.SetX(m_position.GetX()+new_path.GetX());
m_position.SetY(m_position.GetY()+new_path.GetY());
}
示例5:
Eigen::Vector3d
Line2D::getLine(Point2D &p1, Point2D &p2) {
return this->getLine(p1.getPoint()(0), p1.getPoint()(1), p2.getPoint()(0), p2.getPoint()(1));
}
示例6: test12D
void test12D() {
Point2D pt(1.0, 2.0);
Transform2D trans;
trans.TransformPoint(pt);
CHECK_INVARIANT(abs(pt.x - 1.0) < 1.e-8, "");
CHECK_INVARIANT(abs(pt.y - 2.0) < 1.e-8, "");
Point2D ref1(randNum(), randNum());
Point2D ref2(randNum(), randNum());
std::cout << "ref1: " << ref1 << " ref2: " << ref2 << "\n";
Point2D pt1(randNum(), randNum());
Point2D pt2(randNum(), randNum());
Point2D pt1o = pt1;
Point2D pt2o = pt2;
std::cout << "pt1: " << pt1 << " pt2: " << pt2 << "\n";
Transform2D t2d;
t2d.SetTransform(ref1, ref2, pt1, pt2);
t2d.TransformPoint(pt1);
t2d.TransformPoint(pt2);
// make sure pt1 overlaps ref1
Point2D dif1 = pt1 - ref1;
CHECK_INVARIANT(abs(dif1.x) < 1.e-8, "");
CHECK_INVARIANT(abs(dif1.y) < 1.e-8, "");
// now check that the angle between the two vectors (ref2 - ref1) and
// (pt2 - pt1) is zero
Point2D rvec = ref2 - ref1;
Point2D pvec = pt2 - pt1;
rvec.normalize();
pvec.normalize();
double pdot = rvec.dotProduct(pvec);
CHECK_INVARIANT(abs(pdot - 1.0) < 1.e-8, "");
// compute the reverse transform and make sure we are basically getting the
// identity
Transform2D tdi;
tdi.SetTransform(pt1o, pt2o, pt1, pt2);
tdi.TransformPoint(pt1);
tdi.TransformPoint(pt2);
CHECK_INVARIANT(ptEq(pt1, pt1o), "");
CHECK_INVARIANT(ptEq(pt2, pt2o), "");
// the following product should result in an identity matrix
tdi *= t2d;
tdi.TransformPoint(pt1);
tdi.TransformPoint(pt2);
CHECK_INVARIANT(ptEq(pt1, pt1o), "");
CHECK_INVARIANT(ptEq(pt2, pt2o), "");
Point2D npt1(1.0, 0.0);
Point2D npt2(5.0, 0.0);
Point2D opt1 = npt1;
Point2D opt2(1.0, 4.0);
Transform2D ntd;
ntd.SetTransform(npt1, M_PI / 2);
ntd.TransformPoint(npt1);
ntd.TransformPoint(npt2);
CHECK_INVARIANT(ptEq(npt1, opt1), "");
CHECK_INVARIANT(ptEq(npt2, opt2), "");
}
示例7: myV
void AbstractPolygon::checkConvexity()
{
Vertices const & myV(this->vertexes);
auto mysize=this->size();
// We consider segments and triangles as convex
if (mysize <= 3) {
this->isconvex=true;
return;
}
//! Since we are dealing with floating points it is better to have
// a small number so that |a| < smallNumber means for us a==0
double smallNumber(1000*std::numeric_limits<double>::min());
Point2D p;
Point2D v;
Point2D u;
double res(0.0);
double newres(0.0);
//! C++11 sintax. decltype(expr) returns the type of the expression
for ( decltype(mysize) i=0; i < mysize; ++i)
{
p = myV[i];
// ! next point
Point2D tmp = myV[(i+1) % myV.size()];
v = tmp - p;
//! next next point
u = myV[(i+2) % myV.size()];
if (i == 0) // in first loop direction is unknown, so save it in res
res = u.x() * v.y() - u.y() * v.x() + v.x() * p.y() - v.y() * p.x();
else{
newres = u.x() * v.y() - u.y() * v.x() + v.x() * p.y() - v.y() * p.x();
if (std::abs(res)<smallNumber){
// The two edges are aligned, skip test and update res
res=newres;
}
else if ( std::abs(newres)>= smallNumber &&
(newres > 0 && res < 0) || (newres < 0 && res > 0) ){
this->isconvex=false;
return;
}
}
}// end for
this->isconvex=true;
return;
}
示例8: belongsTo
bool AbstractTreeDrawing::belongsTo(const Point2D<double>& p1, const Point2D<double>& p2) const
{
return (p1.getX() >= p2.getX() - settings_->pointArea && p1.getX() <= p2.getX() + settings_->pointArea
&& p1.getY() >= p2.getY() - settings_->pointArea && p1.getY() <= p2.getY() + settings_->pointArea);
}
示例9: if
mitk::InteractionEvent::Pointer mitk::EventFactory::CreateEvent(PropertyList::Pointer list)
{
//
std::string eventClass, eventVariant;
list->GetStringProperty(InteractionEventConst::xmlParameterEventClass().c_str(), eventClass);
list->GetStringProperty(InteractionEventConst::xmlParameterEventVariant().c_str(), eventVariant);
// Query all possible attributes, if they are not present, set their default values.
// Position Events & Key Events
std::string strModifiers;
InteractionEvent::ModifierKeys modifiers = InteractionEvent::NoKey;
std::string strEventButton;
InteractionEvent::MouseButtons eventButton = InteractionEvent::NoButton;
std::string strButtonState;
InteractionEvent::MouseButtons buttonState = InteractionEvent::NoButton;
std::string strKey;
std::string key;
std::string strWheelDelta;
int wheelDelta;
std::string strSignalName = "";
Point2D pos;
pos.Fill(0);
std::string strPos;
// Position on screen
if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyPositionOnScreen().c_str(), strPos))
{
// split comma separated string
int commaPos;
commaPos = strPos.find_first_of(',');
pos[0] = static_cast<mitk::ScalarType>(std::atof(strPos.substr(0, commaPos).c_str()));
pos[1] = static_cast<mitk::ScalarType>(std::atof(strPos.substr(commaPos + 1, strPos.length()).c_str()));
}
std::string strWorld;
Point3D worldPos;
worldPos.Fill(0);
// Position in world coordinates
if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyPositionInWorld().c_str(), strWorld))
{
const std::vector<std::string> coords = split(strWorld, ',');
int i = 0;
for (std::vector<std::string>::const_iterator it = coords.cbegin(); it != coords.cend(); ++it, ++i)
{
worldPos[i] = atof((*it).c_str());
}
}
// Parse modifier information
if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyModifier().c_str(), strModifiers))
{
std::vector<std::string> mods = split(strModifiers, ',');
for (std::vector<std::string>::iterator it = mods.begin(); it != mods.end(); ++it)
{
std::transform((*it).cbegin(), (*it).cend(), (*it).begin(), ::toupper);
if (*it == "CTRL")
{
modifiers = modifiers | InteractionEvent::ControlKey;
}
else if (*it == "ALT")
{
modifiers = modifiers | InteractionEvent::AltKey;
}
else if (*it == "SHIFT")
{
modifiers = modifiers | InteractionEvent::ShiftKey;
}
else
{
MITK_WARN << "mitkEventFactory: Invalid event modifier in config file :" << (*it);
}
}
}
// Set EventButton
if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyEventButton().c_str(), strEventButton))
{
std::transform(strEventButton.cbegin(), strEventButton.cend(), strEventButton.begin(), ::toupper);
if (strEventButton == "MIDDLEMOUSEBUTTON")
{
eventButton = InteractionEvent::MiddleMouseButton;
}
else if (strEventButton == "LEFTMOUSEBUTTON")
{
eventButton = InteractionEvent::LeftMouseButton;
}
else if (strEventButton == "RIGHTMOUSEBUTTON")
{
eventButton = InteractionEvent::RightMouseButton;
}
else
{
MITK_WARN << "mitkEventFactory: Invalid event button in config file: " << strEventButton;
}
}
// Parse ButtonStates
if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyButtonState().c_str(), strButtonState))
//.........这里部分代码省略.........
示例10: while
vector<QPoint>
BlurredSegment::getPrintedPoints(){
Point2D d = lastLeftPointAdded;
Point2D f = lastRightPointAdded;
vector<QPoint> vectResult;
double apvh = (double)convexhull->getAPV().height();
double aphl = (double)convexhull->getAPH().large();
vector<Point2D>::iterator iterPoints;
iterPoints = vectorPixel.begin();
int Ymin=0, Ymax=0, Xmax=0, Xmin=0;
bool first = true;
while(iterPoints!=vectorPixel.end()){
Point2D ps = *iterPoints;
if(first){
first= false;
Ymax=ps.getY();
Ymin=ps.getY();
Xmax=ps.getX();
Xmin=ps.getX();
}else{
if(Ymin>ps.getY())
Ymin=ps.getY();
if(Ymax<ps.getY())
Ymax=ps.getY();
if(Xmin>ps.getX())
Xmin=ps.getX();
if(Xmax<ps.getX())
Xmax=ps.getX();
}
iterPoints++;
}
// P5-------- P6//
// P3-------- P4//
if ( apvh < aphl ){
Line lVerti= convexhull->getAPV().getEdge();
Point2DinCV p = convexhull->getAPV().getVertex();
Point2D p1 = lVerti.getBegin();
Point2D p2 = lVerti.getEnd();
double a = tan(getDirection());
double b = -(double)(p1.getX())*a +p1.getY();
double p3 [2] = {Xmax, a*(double)(Xmax)+b};
double p4 [2] = {Xmin, a*(double)(Xmin)+b};
double b2 = -(double)p.getX()*a +(double)p.getY();
double p5[2] = {Xmin, a*(double)(Xmin)+b2};
double p6[2] = {Xmax, a*(double)(Xmax)+b2};
vector<QPoint> droiteSup = PointSet::tracerSegment(QPoint(p3[0],p3[1]),
QPoint(p4[0],p4[1]));
vector<QPoint> droiteInf = PointSet::tracerSegment(QPoint(p5[0],p5[1]),
QPoint(p6[0],p6[1]));
PointSet::fusionVector(vectResult, droiteSup);
PointSet::fusionVector(vectResult, droiteInf);
// cout << "\n" << styleLineXFIG
// << "\n" << (int) p4[0]*RESOLUTION << " " << (int) p4[1]*RESOLUTION << " "
// <<(int) p3[0]*RESOLUTION << " " <<(int) p3[1]*RESOLUTION << " "
// <<(int) p6[0]*RESOLUTION << " " << (int)p6[1]*RESOLUTION << " "
// <<(int) p5[0]*RESOLUTION << " " << (int)p5[1]*RESOLUTION << " "
// <<(int) p4[0]*RESOLUTION << " " << (int) p4[1]*RESOLUTION << endl;
}else{
Line lVerti= convexhull->getAPH().getEdge();
Point2DinCV p = convexhull->getAPH().getVertex();
Point2D p1 = lVerti.getBegin();
Point2D p2 = lVerti.getEnd();
double a = tan(getDirection());
double b = -(double)(p1.getX())*a +p1.getY();
double p3 [2] = {(((double)Ymax)-b)/a,Ymax};
double p4 [2] = {(((double)Ymin)-b)/a,Ymin};
double b2 = -(double)p.getX()*a +(double)p.getY();
double p5[2] = {(((double)Ymin)-b2)/a, Ymin};
double p6[2] = {(((double)Ymax)-b2)/a, Ymax};
if((p2.getX() - p1.getX())==0){
p3[0] = p2.getX();
p3[1] = Ymax;
p4[0] = p2.getX();
p4[1] = Ymin;
p5[0] = p.getX();
p5[1] = Ymin;
p6[0] = p.getX();
//.........这里部分代码省略.........
示例11: XWinManaged
// ######################################################################
void CenterSurroundHistogramSegmenter::drawCurrentCSbelief
(Point2D<int> pt, Rectangle grC, Rectangle grS)
{
uint width = itsImage.getWidth();
uint height = itsImage.getHeight();
if(itsWin.is_invalid())
itsWin.reset(new XWinManaged(Dims(2*width, height), 0, 0, "CSHse"));
else itsWin->setDims(Dims(2*width, height));
uint gwidth = width/GRID_SIZE;
uint gheight = height/GRID_SIZE;
// display the window
Image<PixRGB<byte> > disp(2*width, height, ZEROS);
inplacePaste(disp, itsImage, Point2D<int>(0,0));
if(pt.isValid())
{
drawCross(disp, pt, PixRGB<byte>(255,0,0), 10, 1);
}
if(grC.isValid())
{
drawRect(disp, grC*GRID_SIZE, PixRGB<byte>(255,0,0), 1);
drawRect(disp, grS*GRID_SIZE, PixRGB<byte>(0,255,0), 1);
}
float mVal = 32;
float bVal = 255 - mVal;
Image<byte> dImaR, dImaG, dImaB;
getComponents(itsImage, dImaR, dImaG, dImaB);
inplaceNormalize(dImaR, byte(0), byte(mVal));
inplaceNormalize(dImaG, byte(0), byte(mVal));
inplaceNormalize(dImaB, byte(0), byte(mVal));
Image<PixRGB<byte> > dIma = makeRGB(dImaR,dImaG,dImaB);
// Image<float> dImaCf = itsGridCenterBelief;
// inplaceNormalize(dImaCf, 0.0F, bVal);
// Image<byte> dImaCb(dImaCf);
// Image<PixRGB<byte> > dImaC = makeRGB(dImaCb,dImaCb,dImaCb);
// Image<float> dImaSf = itsGridSurroundBelief;
// inplaceNormalize(dImaSf, 0.0F, bVal);
// Image<byte> dImaSb(dImaSf);
// Image<PixRGB<byte> > dImaS = makeRGB(dImaSb,dImaSb,dImaSb);
// Image<PixRGB<byte> > tdImaC(dIma+zoomXY(dImaC,GRID_SIZE));
// Image<PixRGB<byte> > tdImaS(dIma+zoomXY(dImaS,GRID_SIZE));
// inplacePaste (disp, tdImaC, Point2D<int>(width,0));
// inplacePaste (disp, tdImaS, Point2D<int>(2*width,0));
Image<float> dImaCSf =
clampedDiff((itsGridCenterBelief - itsGridSurroundBelief),
Image<float>(gwidth,gheight,ZEROS));
inplaceNormalize(dImaCSf, 0.0F, bVal);
Image<byte> dImaCSb(dImaCSf);
Image<PixRGB<byte> > dImaCS = makeRGB(dImaCSb,dImaCSb,dImaCSb);
Image<PixRGB<byte> > tdImaCS(dIma+zoomXY(dImaCS,GRID_SIZE));
inplacePaste (disp, tdImaCS, Point2D<int>(width,0));
Point2D<int> noff (width,0);
drawCross(disp, pt+noff, PixRGB<byte>(255,0,0), 10, 1);
if(itsCSrectangle.isValid())
{
drawRect(disp, itsCSrectangle*GRID_SIZE, PixRGB<byte>(255,0,0), 1);
drawRect(disp, (itsCSrectangle*GRID_SIZE)+noff, PixRGB<byte>(255,0,0), 1);
}
itsWin->drawImage(disp,0,0);
Raster::waitForKey();
}
示例12: operator
bool operator()(const Point2D& p, const Point2D& q)
{
return (p.getX() < q.getX());
}
示例13: isJumpBetween
bool JumpDistanceSegmentation::isJumpBetween(const Point2D* p1, const Point2D* p2)
{
const Point2D diff = *p1 - *p2;
return diff.norm() > m_jumpDistance;
}
示例14: getBackingScaleFactor
char* StagePreview::savePreviewImage(sf::RenderWindow *window,
BerryBotsEngine *engine, unsigned int &targetWidth,
unsigned int &targetHeight) {
Stage *stage = engine->getStage();
double backingScale = getBackingScaleFactor();
unsigned int viewWidth = stage->getWidth() + (2 * STAGE_MARGIN);
unsigned int viewHeight = stage->getHeight() + (2 * STAGE_MARGIN);
unsigned int screenWidth = backingScale * MAX_PREVIEW_WIDTH;
unsigned int screenHeight = backingScale * MAX_PREVIEW_HEIGHT;
double windowScale =
std::min(backingScale, std::min(((double) screenWidth) / viewWidth,
((double) screenHeight) / viewHeight));
targetWidth = round(windowScale * viewWidth);
targetHeight = round(windowScale * viewHeight);
#ifdef __WXGTK__
// Since setSize() doesn't work reliably, we create it inline on Linux.
window = new sf::RenderWindow(
sf::VideoMode(targetWidth, targetHeight), "Preview",
sf::Style::None,
sf::ContextSettings(0, 0, (isAaDisabled() ? 0 : 4), 2, 0));
window->setVisible(false);
#else
window->setSize(sf::Vector2u(targetWidth, targetHeight));
#endif
Team **teams = new Team*[1];
teams[0] = new Team;
strcpy(teams[0]->name, "PreviewTeam");
teams[0]->numRectangles = 0;
teams[0]->numLines = 0;
teams[0]->numCircles = 0;
teams[0]->numTexts = 0;
Ship **ships = new Ship*[1];
Ship *ship = new Ship;
ShipProperties *properties = new ShipProperties;
properties->shipR = properties->shipG = properties->shipB = 255;
properties->laserR = properties->laserB = 0;
properties->laserG = 255;
properties->thrusterR = 255;
properties->thrusterG = properties->thrusterB = 0;
strcpy(properties->name, "PreviewShip");
ship->properties = properties;
ship->thrusterAngle = ship->thrusterForce = 0;
Point2D *start = stage->getStart();
ship->x = start->getX();
ship->y = start->getY();
ship->alive = true;
ship->showName = ship->energyEnabled = false;
ships[0] = ship;
teams[0]->numTexts = 0;
stage->setTeamsAndShips(teams, 1, ships, 1);
previewGfxManager_->initBbGfx(window, backingScale, viewHeight, stage, teams,
1, ships, 1);
previewGfxManager_->initViews(window, viewWidth, viewHeight);
GfxEventHandler *gfxHandler = new GfxEventHandler();
window->clear();
previewGfxManager_->drawGame(window, stage, ships, 1, 0, gfxHandler, false,
false, 0);
std::stringstream filenameStream;
filenameStream << (rand() % 10000000) << ".png";
char *filename = fileManager_->getFilePath(getTmpDir().c_str(),
filenameStream.str().c_str());
char *absFilename = fileManager_->getAbsFilePath(filename);
delete filename;
sf::Image previewImage = window->capture();
fileManager_->createDirectoryIfNecessary(getTmpDir().c_str());
previewImage.saveToFile(absFilename);
#ifdef __WXGTK__
delete window;
#endif
previewGfxManager_->destroyBbGfx();
delete gfxHandler;
delete properties;
delete teams[0];
delete teams;
return absFilename;
}
示例15: floor
int Hash2D::getHashKey(const Point2D& a)
{
int x = floor(a.getPx()/cellwidth);
int y = floor(a.getPy()/cellwidth);
return y*cols + x;
}