本文整理汇总了C++中Segments::dump方法的典型用法代码示例。如果您正苦于以下问题:C++ Segments::dump方法的具体用法?C++ Segments::dump怎么用?C++ Segments::dump使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segments
的用法示例。
在下文中一共展示了Segments::dump方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
// profiler
Profiler profiler;
profiler.start((char*)"main");
// random generate 1d vector
// assign maximum size =>
const int max = 100;
vector<double> main_1d_points(max);
srand(time(NULL));
for (int i = 0; i < max; i++) {
main_1d_points[i] = rand() % 100;
};
// transform to Points, then sorting
Points main_points;
main_points.parse_1d_points_from(main_1d_points);
main_points.sort_by_y();
main_points.dump();
Points center;
center.create_center_from(main_points);
center.dump();
// create a set of points
Point a, b, c, d, e, f, g, h;
a.set_point( 0, 0);
b.set_point( 5, 0);
c.set_point( 5, 5);
d.set_point( 0, 5);
e.set_point(-5, 5);
f.set_point(-5, 0);
g.set_point(-5, -5);
h.set_point( 0, -5);
// form each segment
Segment ab, bc, cd, de, ef, fg, gh, ha;
ab.set_segment(&a, &b);
bc.set_segment(&b, &c);
cd.set_segment(&c, &d);
de.set_segment(&d, &e);
ef.set_segment(&e, &f);
fg.set_segment(&f, &g);
gh.set_segment(&g, &h);
ha.set_segment(&h, &a);
// try segment copy
Segment copy_test;
copy_test.copy(ab);
printf("copy segment:\n");
copy_test.dump();
copy_test.free();
// form a set of segments
Segments all;
all.append(&ab);
all.append(&bc);
all.append(&cd);
all.append(&de);
all.append(&ef);
all.append(&fg);
all.append(&gh);
all.append(&ha);
all.dump();
// set the set of segments to a polygon
// and test polygon function
Polygon polygon1;
polygon1.set_polygon(&all);
polygon1.dump();
printf("(%d) segments in this polygon\n", polygon1.get_segment_number());
printf("center point of this polygon is (%f, %f)\n",
polygon1.get_center().get_gx(),
polygon1.get_center().get_gy());
// set the set of segments to another polygon
// yet, they reference the same segments set
printf("\nthis is polygon2\n");
Polygon polygon2;
polygon2.set_polygon(&all);
polygon2.dump();
// try polygon copy
printf("\nthis is polygon3\n");
Polygon polygon3;
polygon3.copy(polygon2);
polygon3.dump();
// append the polygons into a set of polygons
Polygons polygons;
polygons.append(&polygon1);
polygons.append(&polygon3);
// set segment function and loop all polygons set
ktSetSegmentFunction(grow_45_degree);
ktLoopSegment(&polygons);
//.........这里部分代码省略.........