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


C++ Lines类代码示例

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


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

示例1: catch

void
Parser::cat(const string& name)
{
    DirectoryPrx dir = _dirs.front();
    NodeDesc d;
    try
    {
        d = dir->find(name);
    }
    catch(const NoSuchName&)
    {
        cout << "`" << name << "': no such file" << endl;
        return;
    }
    if(d.type == DirType)
    {
        cout << "`" << name << "': not a file" << endl;
        return;
    }
    FilePrx f = FilePrx::uncheckedCast(d.proxy);
    Lines l = f->read();
    for(Lines::const_iterator i = l.begin(); i != l.end(); ++i)
    {
        cout << *i << endl;
    }
}
开发者ID:BlackHoleJet,项目名称:freeze,代码行数:26,代码来源:Parser.cpp

示例2: splitLines

void Context::splitLines()
{
    for (auto line = lines.begin(); line != lines.end(); ++line)
    {
        auto &text = line->text;
        auto p = text.find('\n');
        if (p == text.npos)
            continue;

        size_t old_pos = 0;
        Lines ls;
        while (1)
        {
            ls.push_back(Line{text.substr(old_pos, p - old_pos), line->n_indents});
            p++;
            old_pos = p;
            p = text.find('\n', p);
            if (p == text.npos)
            {
                ls.push_back(Line{ text.substr(old_pos), line->n_indents });
                break;
            }
        }
        lines.insert(line, ls.begin(), ls.end());
        line = lines.erase(line);
        line--;
    }
}
开发者ID:cppan,项目名称:cppan,代码行数:28,代码来源:context.cpp

示例3: save

void FileHelper::save(std::ostream& stream, Lines& lines)
{
    for (Lines::iterator i=lines.begin(); i != lines.end(); ++i)
    {
        stream << (*i).c_str() << std::endl;
    }
}
开发者ID:shenglonglinapple,项目名称:slin_code,代码行数:7,代码来源:FileHelper.cpp

示例4: GetFeatureEdge

void vavImage::GetFeatureEdge(Lines& lines)
{
	return;
	for (Lines::iterator it = lines.begin(); it != lines.end(); ++it)
	{
		Line& li = *it;
		if (li.size() == 3)
		{
			li.erase(li.begin() + 1);
		}
		else if (li.size() > 3)
		{
			Vector2 lastmove = li[1] - li[0];
			for (int i = 2; i < li.size() - 1; ++i)
			{
				Vector2 move = li[i + 1] - li[i];
				if (move == lastmove)
				{
					li[i - 1].x = -999;
				}
				lastmove = move;
			}
			for (int i = 1; i < li.size(); ++i)
			{
				if (li[i].x == -999)
				{
					li.erase(li.begin() + i);
					i--;
				}
			}
		}
	}
}
开发者ID:maleiwhat,项目名称:vectorizing-project,代码行数:33,代码来源:vavImage.cpp

示例5: main

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    Lines window;
    window.show();
    return app.exec();
}
开发者ID:Foxy1987,项目名称:Qt5,代码行数:7,代码来源:main.cpp

示例6: main

int main ()
{
  using namespace Graph_lib;  // our graphics facilities are in Graph_lib namespace

  constexpr Point pt{100,100};    // to become top left corner of window

  Simple_window win {pt, 600, 400,"ch13.5_LineStile"};  // make a simple window, {top_left, width, hight, title}

  const int x_size = win.x_max();
  const int y_size = win.y_max();
  const int x_grid = 80;
  const int y_grid = 40;

  Lines grid;
  for (int x=x_grid; x<x_size; x+=x_grid)
    grid.add(Point{x,0},Point{x,y_size}); // vertical line
  for (int y=y_grid; y<y_size; y+=y_grid)
    grid.add(Point{0,y},Point{x_size,y});  // horizontal line

  grid.set_color(Color::red); // set color (chould affect both lines
  //grid.set_style(Line_style{Line_style::dot,2});
  //grid.set_style(Line_style::dashdot);
  grid.set_style(Line_style{Line_style::dashdot,2});

  win.attach(grid);

  win.wait_for_button();  // display!

}
开发者ID:tol60,项目名称:STROUSTRUP_C11,代码行数:29,代码来源:ch13.5_LineStile.C

示例7: listRecursive

static void
listRecursive(const DirectoryPrx& dir, int depth = 0)
{
    string indent(++depth, '\t');

    NodeSeq contents = dir->list();

    for(NodeSeq::const_iterator i = contents.begin(); i != contents.end(); ++i)
    {
        DirectoryPrx dir = DirectoryPrx::checkedCast(*i);
        FilePrx file = FilePrx::uncheckedCast(*i);
        cout << indent << (*i)->name() << (dir ? " (directory):" : " (file):") << endl;
        if(dir)
        {
            listRecursive(dir, depth);
        }
        else
        {
            Lines text = file->read();
            for(Lines::const_iterator j = text.begin(); j != text.end(); ++j)
            {
                cout << indent << "\t" << *j << endl;
            }
        }
    }
}
开发者ID:2008hatake,项目名称:zeroc-ice,代码行数:26,代码来源:Client.cpp

示例8:

BoundingBox::BoundingBox(const Lines &lines)
{
    Points points;
    for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line) {
        points.push_back(line->a);
        points.push_back(line->b);
    }
    *this = BoundingBox(points);
}
开发者ID:2bright,项目名称:Slic3r,代码行数:9,代码来源:BoundingBox.cpp

示例9: to_lines

inline Lines to_lines(const Polygon &poly) 
{
    Lines lines;
    lines.reserve(poly.points.size());
    for (Points::const_iterator it = poly.points.begin(); it != poly.points.end()-1; ++it)
        lines.push_back(Line(*it, *(it + 1)));
    lines.push_back(Line(poly.points.back(), poly.points.front()));
    return lines;
}
开发者ID:jiripech,项目名称:Slic3r,代码行数:9,代码来源:Polygon.hpp

示例10: GetRGBTranslateColorShade

void Starfield::draw() const {
    const RgbColor slowColor   = GetRGBTranslateColorShade(kStarColor, MEDIUM);
    const RgbColor mediumColor = GetRGBTranslateColorShade(kStarColor, LIGHT);
    const RgbColor fastColor   = GetRGBTranslateColorShade(kStarColor, LIGHTER);

    switch (g.ship.get() ? g.ship->presenceState : kNormalPresence) {
        default:
            if (!_warp_stars) {
                Points points;
                // we're not warping in any way
                for (const scrollStarType* star : range(_stars, _stars + kScrollStarNum)) {
                    if (star->speed != kNoStar) {
                        const RgbColor* color = &slowColor;
                        if (star->speed == kMediumStarSpeed) {
                            color = &mediumColor;
                        } else if (star->speed == kFastStarSpeed) {
                            color = &fastColor;
                        }

                        points.draw(star->location, *color);
                    }
                }
                break;
            }

        case kWarpInPresence:
        case kWarpOutPresence:
        case kWarpingPresence: {
            Lines lines;
            for (const scrollStarType* star : range(_stars, _stars + kScrollStarNum)) {
                if (star->speed != kNoStar) {
                    const RgbColor* color = &slowColor;
                    if (star->speed == kMediumStarSpeed) {
                        color = &mediumColor;
                    } else if (star->speed == kFastStarSpeed) {
                        color = &fastColor;
                    }

                    if (star->age > 1) {
                        lines.draw(star->location, star->oldLocation, *color);
                    }
                }
            }
            break;
        }
    }

    Points points;
    for (const scrollStarType* star : range(_stars + kSparkStarOffset, _stars + kAllStarNum)) {
        if ((star->speed != kNoStar) && (star->age > 0)) {
            const RgbColor color =
                    GetRGBTranslateColorShade(star->hue, (star->age >> kSparkAgeToShadeShift) + 1);
            points.draw(star->location, color);
        }
    }
}
开发者ID:arescentral,项目名称:antares,代码行数:56,代码来源:starfield.cpp

示例11:

Lines
Polygon::lines() const
{
    Lines lines;
    for (int i = 0; i < this->points.size()-1; i++) {
        lines.push_back(Line(this->points[i], this->points[i+1]));
    }
    lines.push_back(Line(this->points.back(), this->points.front()));
    return lines;
}
开发者ID:4ZM,项目名称:Slic3r,代码行数:10,代码来源:Polygon.cpp

示例12:

Lines
Polyline::lines() const
{
    Lines lines;
    lines.reserve(this->points.size() - 1);
    for (Points::const_iterator it = this->points.begin(); it != this->points.end()-1; ++it) {
        lines.push_back(Line(*it, *(it + 1)));
    }
    return lines;
}
开发者ID:JoeyKramer1,项目名称:Slic3r,代码行数:10,代码来源:Polyline.cpp

示例13:

Lines
ExPolygonCollection::lines() const
{
    Lines lines;
    for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) {
        Lines ex_lines = it->lines();
        lines.insert(lines.end(), ex_lines.begin(), ex_lines.end());
    }
    return lines;
}
开发者ID:bjmckenz,项目名称:Slic3r,代码行数:10,代码来源:ExPolygonCollection.cpp

示例14:

double
MultiPoint::length() const
{
    Lines lines = this->lines();
    double len = 0;
    for (Lines::iterator it = lines.begin(); it != lines.end(); ++it) {
        len += it->length();
    }
    return len;
}
开发者ID:TonyK68,项目名称:Slic3r,代码行数:10,代码来源:MultiPoint.cpp

示例15: scale_

std::string
Wipe::wipe(GCode &gcodegen, bool toolchange)
{
    std::string gcode;
    
    /*  Reduce feedrate a bit; travel speed is often too high to move on existing material.
        Too fast = ripping of existing material; too slow = short wipe path, thus more blob.  */
    double wipe_speed = gcodegen.writer.config.travel_speed.value * 0.8;
    
    // get the retraction length
    double length = toolchange
        ? gcodegen.writer.extruder()->retract_length_toolchange()
        : gcodegen.writer.extruder()->retract_length();
    
    if (length > 0) {
        /*  Calculate how long we need to travel in order to consume the required
            amount of retraction. In other words, how far do we move in XY at wipe_speed
            for the time needed to consume retract_length at retract_speed?  */
        double wipe_dist = scale_(length / gcodegen.writer.extruder()->retract_speed() * wipe_speed);
    
        /*  Take the stored wipe path and replace first point with the current actual position
            (they might be different, for example, in case of loop clipping).  */
        Polyline wipe_path;
        wipe_path.append(gcodegen.last_pos());
        wipe_path.append(
            this->path.points.begin() + 1,
            this->path.points.end()
        );
        
        wipe_path.clip_end(wipe_path.length() - wipe_dist);
    
        // subdivide the retraction in segments
        double retracted = 0;
        Lines lines = wipe_path.lines();
        for (Lines::const_iterator line = lines.begin(); line != lines.end(); ++line) {
            double segment_length = line->length();
            /*  Reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one
                due to rounding (TODO: test and/or better math for this)  */
            double dE = length * (segment_length / wipe_dist) * 0.95;
            gcode += gcodegen.writer.set_speed(wipe_speed*60);
            gcode += gcodegen.writer.extrude_to_xy(
                gcodegen.point_to_gcode(line->b),
                -dE,
                (std::string)"wipe and retract" + (gcodegen.enable_cooling_markers ? ";_WIPE" : "")
            );
            retracted += dE;
        }
        gcodegen.writer.extruder()->retracted += retracted;
        
        // prevent wiping again on same path
        this->reset_path();
    }
    
    return gcode;
}
开发者ID:BradNagel,项目名称:Slic3r,代码行数:55,代码来源:GCode.cpp


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