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


C++ Polygon::push_back方法代码示例

本文整理汇总了C++中clipperlib::Polygon::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon::push_back方法的具体用法?C++ Polygon::push_back怎么用?C++ Polygon::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clipperlib::Polygon的用法示例。


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

示例1: toClipperPolygon

		ClipperLib::Polygon Rectangle::toClipperPolygon() const
		{
			ClipperLib::Polygon ret;
			ret.push_back(topleft);
			ret.push_back(glm::vec2(topleft.x, bottomright.y));
			ret.push_back(bottomright);
			ret.push_back(glm::vec2(bottomright.x, topleft.y));
			return ret;
		}
开发者ID:kees2125,项目名称:netwerkgame-Remco-Kees,代码行数:9,代码来源:Rectangle.cpp

示例2: MakePolygonFromInts

void MakePolygonFromInts(int *ints, int size, ClipperLib::Polygon &p)
{
  p.clear();
  p.reserve(size / 2);
  for (int i = 0; i < size; i +=2)
    p.push_back(IntPoint(ints[i], ints[i+1]));
}
开发者ID:Alkaponj,项目名称:repsnapper,代码行数:7,代码来源:main.cpp

示例3:

void
Slic3rPolygon_to_ClipperPolygon(const Slic3r::Polygon &input, ClipperLib::Polygon &output)
{
    output.clear();
    for (Slic3r::Points::const_iterator pit = input.points.begin(); pit != input.points.end(); ++pit) {
        output.push_back(ClipperLib::IntPoint( (*pit).x, (*pit).y ));
    }
}
开发者ID:BabayDeLaKrus,项目名称:Slic3r,代码行数:8,代码来源:ClipperUtils.cpp

示例4: polygonFromQxClipper

void polygonFromQxClipper(const QPolygonF& qxPolygon,
                          ClipperLib::Polygon &clipperPolygon)
{
  clipperPolygon.clear();
  clipperPolygon.reserve(qxPolygon.size());
  foreach(const QPointF &point, qxPolygon)
  {
    clipperPolygon.push_back(ClipperLib::IntPoint(point.x()*ConversionFactor,
                                                  point.y()*ConversionFactor));
  }
开发者ID:lukeandrew,项目名称:QxClipper,代码行数:10,代码来源:qxclipper.cpp

示例5: ofPolyline_to_Polygon

//--------------------------------------------------------------
ClipperLib::Polygon ofxClipper::ofPolyline_to_Polygon(ofPolyline& polyline) {
	vector<ofPoint> verts = polyline.getVertices();
    vector<ofPoint>::iterator iter;
    ClipperLib::Polygon polygon;
    for(iter = verts.begin(); iter != verts.end(); iter++) {
        ClipperLib::IntPoint ip((*iter).x * clipperGlobalScale, 
                                (*iter).y * clipperGlobalScale);
        polygon.push_back(ip);
    }
    return polygon;
}
开发者ID:neumic,项目名称:ofxClipper,代码行数:12,代码来源:ofxClipper.cpp

示例6: fillPolygonLayer

void Slice::fillPolygonLayer(){
    //for every layer
    for(int j=0; j<this->pointLayer.size(); j++){
        Polygons layer;
        for(int k=0; k<this->pointLayer.at(j)->size(); k++){
            ClipperLib::Polygon p;
            for(int i=0; i<this->pointLayer.at(j)->at(k)->size(); i++){
                p.push_back(ClipperLib::IntPoint((int)(this->pointLayer.at(j)->at(k)->at(i).x()*1000),(int)(this->pointLayer.at(j)->at(k)->at(i).y()*1000)));
            }
            layer.push_back(p);
        }
        this->polygonLayer.append(layer);
    }
}
开发者ID:esoren,项目名称:YARRH,代码行数:14,代码来源:slice.cpp

示例7: main

int main(int argc, char* argv[]) {
	if (argc != 3) {
		cout<<"Usage: offset.exe <input.poly> <output.poly>\n\n  Input and output files should be different.\n  Only one ring poly files are accepted now without inner rings.\n  Default offset is 0.001 degree\n";
		return 0;

	}
	ifstream f(argv[1], ifstream::in);
	ofstream outfile(argv[2], ofstream::out);
	outfile.precision(9);
	string s;
	for (int i=0;i<3;i++) {
		getline(f, s);
		outfile<<s<<"\n";
	}
	ClipperLib::Polygons polygons;
	ClipperLib::Polygon polygon;
	while(!f.eof()) {
		f>>s;
		if (s == "END") {
			break;
		}
		double c1 = ::atof(s.c_str());
		f>>s;
		double c2 = ::atof(s.c_str());
		ClipperLib::IntPoint point(c1 * MUL, c2 * MUL);
		polygon.push_back(point);
	}
	polygons.push_back(polygon);
	double distance = 0.001 * MUL;

	ClipperLib::Polygons res_polygons;
	ClipperLib::OffsetPolygons (polygons, res_polygons, distance, ClipperLib::jtMiter);

	if (res_polygons.size() < 1) { cerr<<"Bad output of OffsetPolygons!\n";return 1;}
	ClipperLib::Polygon result = res_polygons.front();

	for (ClipperLib::Polygon::iterator it = result.begin(); it != result.end(); ++it) {
		ClipperLib::IntPoint point = *it;
		outfile << "   " << (point.X/MUL) << "   " << (point.Y/MUL) << " \n";
	}

	outfile<<s;
	while (!f.eof()) {
		getline(f, s);
		outfile<<s<<"\n";
	}

	return 0;
}
开发者ID:geosphere,项目名称:ua-convert,代码行数:49,代码来源:offset.cpp

示例8: makePolygons

void SlicerLayer::makePolygons(OptimizedVolume* ov, bool keepNoneClosed, bool extensiveStitching)
{
    for(unsigned int startSegment=0; startSegment < segmentList.size(); startSegment++)
    {
        if (segmentList[startSegment].addedToPolygon)
            continue;
        
        ClipperLib::Polygon poly;
        poly.push_back(segmentList[startSegment].start);
        
        unsigned int segmentIndex = startSegment;
        bool canClose;
        while(true)
        {
            canClose = false;
            segmentList[segmentIndex].addedToPolygon = true;
            Point p0 = segmentList[segmentIndex].end;
            poly.push_back(p0);
            int nextIndex = -1;
            OptimizedFace* face = &ov->faces[segmentList[segmentIndex].faceIndex];
            for(unsigned int i=0;i<3;i++)
            {
                if (face->touching[i] > -1 && faceToSegmentIndex.find(face->touching[i]) != faceToSegmentIndex.end())
                {
                    Point p1 = segmentList[faceToSegmentIndex[face->touching[i]]].start;
                    Point diff = p0 - p1;
                    if (shorterThen(diff, 10))
                    {
                        if (faceToSegmentIndex[face->touching[i]] == (int)startSegment)
                            canClose = true;
                        if (segmentList[faceToSegmentIndex[face->touching[i]]].addedToPolygon)
                            continue;
                        nextIndex = faceToSegmentIndex[face->touching[i]];
                    }
                }
            }
            if (nextIndex == -1)
                break;
            segmentIndex = nextIndex;
        }
        if (canClose)
            polygonList.add(poly);
        else
            openPolygonList.add(poly);
    }
    //Clear the segmentList to save memory, it is no longer needed after this point.
    segmentList.clear();

    //Connecting polygons that are not closed yet, as models are not always perfect manifold we need to join some stuff up to get proper polygons
    //First link up polygon ends that are within 2 microns.
    for(unsigned int i=0;i<openPolygonList.size();i++)
    {
        if (openPolygonList[i].size() < 1) continue;
        for(unsigned int j=0;j<openPolygonList.size();j++)
        {
            if (openPolygonList[j].size() < 1) continue;
            
            Point diff = openPolygonList[i][openPolygonList[i].size()-1] - openPolygonList[j][0];
            int64_t distSquared = vSize2(diff);

            if (distSquared < 2 * 2)
            {
                if (i == j)
                {
                    polygonList.add(openPolygonList[i]);
                    openPolygonList[i].clear();
                    break;
                }else{
                    for(unsigned int n=0; n<openPolygonList[j].size(); n++)
                        openPolygonList[i].push_back(openPolygonList[j][n]);

                    openPolygonList[j].clear();
                }
            }
        }
    }
    
    //Next link up all the missing ends, closing up the smallest gaps first. This is an inefficient implementation which can run in O(n*n*n) time.
    while(1)
    {
        int64_t bestScore = 10000 * 10000;
        unsigned int bestA = -1;
        unsigned int bestB = -1;
        bool reversed = false;
        for(unsigned int i=0;i<openPolygonList.size();i++)
        {
            if (openPolygonList[i].size() < 1) continue;
            for(unsigned int j=0;j<openPolygonList.size();j++)
            {
                if (openPolygonList[j].size() < 1) continue;
                
                Point diff = openPolygonList[i][openPolygonList[i].size()-1] - openPolygonList[j][0];
                int64_t distSquared = vSize2(diff);
                if (distSquared < bestScore)
                {
                    bestScore = distSquared;
                    bestA = i;
                    bestB = j;
                    reversed = false;
                }
//.........这里部分代码省略.........
开发者ID:ubaldino,项目名称:SawersPrinter3D,代码行数:101,代码来源:slicer.cpp


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