本文整理汇总了C++中cgal::Timer::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::stop方法的具体用法?C++ Timer::stop怎么用?C++ Timer::stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cgal::Timer
的用法示例。
在下文中一共展示了Timer::stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
CGAL::Timer timer;
// first param is dimension
// second param is number of points
int dimension = 4;
int n = 100;
int m = 100;
if (argc > 1 && std::string(argv[1])== std::string("-h")) {
std::cout<<"usage: "<<argv[0]<<" [dim] [#points] [max coords]\n";
return 1;
}
if (argc > 1) dimension = atoi(argv[1]);
if (argc > 2) n = atoi(argv[2]);
if (argc > 3) m = atoi(argv[2]);
Delaunay_d T(dimension);
std::list<Point_d> L;
random_points_in_range(n,dimension,-m,m,L);
timer.start();
int i=0;
std::list<Point_d>::iterator it;
for(it = L.begin(); it!=L.end(); ++it) {
T.insert(*it); i++;
if (i%10==0)
std::cout << i << " points inserted" << std::endl;
}
timer.stop();
std::cout << "used time for inserts " << timer.time() << std::endl;
std::cout << "entering check" << std::endl;
timer.reset();
timer.start();
T.is_valid();
timer.stop();
std::cout << "used time for sanity check " << timer.time() << std::endl;
std::cout << "entering nearest neighbor location" << std::endl;
L.clear();
random_points_in_range(n/10,dimension,-m,m,L);
timer.reset();
timer.start();
i = 0;
for(it = L.begin(); it!=L.end(); ++it) {
T.nearest_neighbor(*it); i++;
if (i%10==0) std::cout << i << " points located" << std::endl;
}
timer.stop();
std::cout << "used time for location " << timer.time() << std::endl;
T.print_statistics();
std::cout << "done" << std::endl;
return 0;
}
示例2: main
int main() {
const unsigned int N = 50;
CGAL::Timer timer;
timer.start();
std::vector<Point_3> points, queries;
Point_3 p;
std::ifstream point_stream("points.xyz");
while(point_stream >> p){
points.push_back(p);
}
My_point_property_map ppmap(points);
Distance tr_dist(ppmap);
std::ifstream query_stream("queries.xyz");
while(query_stream >> p ){
queries.push_back(p);
}
timer.stop();
std::cerr << "reading points took " << timer.time() << " sec." << std::endl;
timer.reset();
timer.start();
Tree tree( boost::counting_iterator<std::size_t>(0),
boost::counting_iterator<std::size_t>(points.size()),
Splitter(),
Traits(ppmap));
tree.build();
timer.stop();
std::cerr << "tree construction took " << timer.time() << " sec." << std::endl;
// Initialize the search structure, and search all N points
double d = 0;
timer.reset();
timer.start();
for(int i = 0; i < queries.size(); i++){
K_neighbor_search search(tree, queries[i], 50, 0, true, tr_dist);
// report the N nearest neighbors and their distance
// This should sort all N points by increasing distance from origin
for(K_neighbor_search::iterator it = search.begin(); it != search.end(); ++it){
//std::cout << it->first << std::endl;
d += get(ppmap,it->first).x();
}
}
timer.stop();
std::cerr << d << std::endl;
std::cerr << queries.size() << " queries in " << timer.time() << " sec." << std::endl;
return 0;
}
示例3: time_insertion_and_check
void time_insertion_and_check(pp_int V, int n, int d,
CGAL::Convex_hull_d<R>& C, std::string s, bool check=true)
{
typedef typename CGAL::Convex_hull_d<R>::chull_has_local_non_convexity
chull_has_local_non_convexity;
typedef typename CGAL::Convex_hull_d<R>::chull_has_double_coverage
chull_has_double_coverage;
typedef typename CGAL::Convex_hull_d<R>::
chull_has_center_on_wrong_side_of_hull_facet
chull_has_center_on_wrong_side_of_hull_facet;
std::cout << " timing of " << s << std::endl;
std::vector< CGAL::Point_d<R> > P(n); int i;
for(i=0; i<n; ++i)
P[i] = CGAL::Point_d<R>(d,V[i],V[i]+d,1);
timer.reset(); timer.start(); // float ti = used_time();
for(i=0; i<n; ++i) {
C.insert(P[i]);
if (i%10==0) std::cout << i << " points inserted" << std::endl;
}
timer.stop();
double t = timer.time(); timer.reset(); // float t = used_time(ti);
(*p_table_file) << s << "\t" << d << " " << n << " "
<< C.number_of_vertices() << " " << C.number_of_facets()
<< "\t" << t;
C.print_statistics();
std::cout << "used time for inserts " << t << std::endl;
C.clear(d);
timer.start(); // ti = used_time();
C.initialize(P.begin(),P.end());
timer.stop(); t = timer.time(); timer.reset();
// t = used_time(ti);
C.print_statistics();
std::cout << "used time for inserts " << t << std::endl;
if (check) {
timer.start();
std::cout << "entering check" << std::endl;
try { C.is_valid(true); }
catch ( chull_has_local_non_convexity )
{ std::cerr << "local non-convexity determined\n"; }
catch ( chull_has_double_coverage )
{ std::cerr << "double coverage determined\n"; }
catch ( chull_has_center_on_wrong_side_of_hull_facet )
{ std::cerr << "facet center problem determined\n"; }
// t = used_time(ti);
timer.stop(); t = timer.time();
(*p_table_file) << "\t" << t <<std::endl;
std::cout<<"used time for sanity check "<< t <<std::endl<<std::endl;
} else {
(*p_table_file) << "\t" << "no"<<std::endl;
std::cout<<"no check"<<std::endl;
}
p_table_file->flush();
}
示例4: done
void
insert_constraints_using_spatial_sort(SDG& sdg)
{
typedef typename Points_container::const_iterator Points_iterator;
typedef std::vector<Points_iterator> Indices;
typedef std::vector<typename SDG::Vertex_handle> Vertices;
Sort_traits_2<K, Points_iterator> sort_traits;
Indices indices;
indices.reserve(points.size());
for(Points_iterator it = points.begin(); it != points.end(); ++it) {
indices.push_back(it);
}
std::random_shuffle(indices.begin(), indices.end());
CGAL::spatial_sort(indices.begin(), indices.end(),
sort_traits);
std::cerr << "Inserting " << points.size() << " points...";
CGAL::Timer timer;
timer.start();
Vertices vertices;
vertices.resize(points.size());
typename SDG::Vertex_handle hint;
for(typename Indices::const_iterator
pt_it_it = indices.begin(), end = indices.end();
pt_it_it != end; ++pt_it_it) {
typename SDG::Vertex_handle vh = sdg.insert(**pt_it_it, hint);
hint = vh;
vertices[*pt_it_it - points.begin()] = vh;
}
timer.stop();
std::cerr << " done (" << timer.time() << "s)\n";
std::cerr << "Inserting " << constraints.size() << " constraints...";
timer.reset();
timer.start();
for(typename Constraints_container::const_iterator
cit = constraints.begin(), end = constraints.end();
cit != end; ++cit) {
const typename SDG::Vertex_handle& v1 = vertices[cit->first];
const typename SDG::Vertex_handle& v2 = vertices[cit->second];
if(v1 != v2)
sdg.insert(v1, v2);
}
timer.stop();
std::cerr << " done (" << timer.time() << "s)\n";
}
示例5: tr
template < class Traits > double test_sort(unsigned int degree, unsigned int n)
{
typedef CGAL::Kinetic::Sort < Traits > Sort;
Traits tr(0, 10000);
Sort sort(tr);
CGAL::Random r;
for (unsigned int i = 0; i < n; ++i) {
std::vector < double >cf;
for (unsigned int j = 0; j < degree + 1; ++j) {
cf.push_back(r.get_double());
}
typename Traits::Kinetic_kernel::Motion_function fn(cf.begin(),
cf.end());
typename Traits::Kinetic_kernel::Point_1 pt(fn);
tr.active_points_1_table_handle()->insert(pt);
}
CGAL::Timer timer;
timer.start();
int ne = 0;
while (tr.simulator_handle()->next_event_time() !=
tr.simulator_handle()->end_time()) {
tr.simulator_handle()->set_current_event_number(tr.
simulator_handle()->
current_event_number()
+ 1);
++ne;
if (ne == 1000)
break;
}
timer.stop();
return timer.time() / static_cast < double >(ne);
}
示例6: main
int main( int argc, char **argv) {
if ( argc != 3) {
cerr << "Usage: " << argv[0] << " <infile1> <infile2>" << endl;
cerr << " Minkowsky sum of two 3d polyhedra in OFF format."
<< endl;
cerr << " Output in OFF to stdout." << endl;
exit(1);
}
Polyhedron P1;
Polyhedron P2;
read( argv[1], P1);
read( argv[2], P2);
CGAL::Timer t;
t.start();
vector<Point> points;
Add_points add;
fold( P1.vertices_begin(), P1.vertices_end(),
P2.vertices_begin(), P2.vertices_end(),
back_inserter( points),
add);
Polyhedron P3;
convex_hull_3( points.begin(), points.end(), P3);
t.stop();
std::cout << "Runtime Minkowski Sum: " << t.time() << std::endl;
// cout << P3;
return 0;
}
示例7: main
int main (int argc, char *argv[]) {
// Cube
std::list<Plane> planes;
planes.push_back(Plane(1, 0, 0, -1));
planes.push_back(Plane(-1, 0, 0, -1));
planes.push_back(Plane(0, 1, 0, -1));
planes.push_back(Plane(0, -1, 0, -1));
planes.push_back(Plane(0, 0, 1, -1));
planes.push_back(Plane(0, 0, -1, -1));
std::vector<Point> points;
int N, steps;
// Number of points
if (argc > 1) {
N = atoi(argv[1]);
} else {
N = 50;
}
// Number of steps
if (argc > 2) {
steps = atoi(argv[2]);
} else {
steps = 10;
}
CGAL::Random_points_in_sphere_3<Point> g;
for (int i = 0; i < N; i++) {
Point p = *g++;
points.push_back(p);
}
std::ofstream bos("before_lloyd.xyz");
std::copy(points.begin(), points.end(),
std::ostream_iterator<Point>(bos, "\n"));
// Apply Lloyd algorithm: will generate points
// uniformly sampled inside a cube.
for (int i = 0; i < steps; i++) {
std::cout << "iteration " << i + 1 << std::endl;
CGAL::Timer timer;
timer.start();
lloyd_algorithm(planes.begin(),
planes.end(),
points);
timer.stop();
std::cout << "Execution time : " << timer.time() << "s\n";
}
std::ofstream aos("after_lloyd.xyz");
std::copy(points.begin(), points.end(),
std::ostream_iterator<Point>(aos, "\n"));
return 0;
}
示例8: main
int main (int argc, char *argv[])
{
// Get the name of the input file from the command line, or use the default
// fan_grids.dat file if no command-line parameters are given.
const char * filename = (argc > 1) ? argv[1] : "fan_grids.dat";
// Open the input file.
std::ifstream in_file (filename);
if (! in_file.is_open()) {
std::cerr << "Failed to open " << filename << " ..." << std::endl;
return (1);
}
// Read the segments from the file.
// The input file format should be (all coordinate values are integers):
// <n> // number of segments.
// <sx_1> <sy_1> <tx_1> <ty_1> // source and target of segment #1.
// <sx_2> <sy_2> <tx_2> <ty_2> // source and target of segment #2.
// : : : :
// <sx_n> <sy_n> <tx_n> <ty_n> // source and target of segment #n.
std::list<Segment_2> segments;
unsigned int n;
in_file >> n;
unsigned int i;
for (i = 0; i < n; ++i) {
int sx, sy, tx, ty;
in_file >> sx >> sy >> tx >> ty;
segments.push_back (Segment_2 (Point_2 (Number_type(sx), Number_type(sy)),
Point_2 (Number_type(tx), Number_type(ty))));
}
in_file.close();
// Construct the arrangement by aggregately inserting all segments.
Arrangement_2 arr;
CGAL::Timer timer;
std::cout << "Performing aggregated insertion of "
<< n << " segments." << std::endl;
timer.start();
insert (arr, segments.begin(), segments.end());
timer.stop();
// Print the arrangement dimensions.
std::cout << "V = " << arr.number_of_vertices()
<< ", E = " << arr.number_of_edges()
<< ", F = " << arr.number_of_faces() << std::endl;
std::cout << "Construction took " << timer.time()
<< " seconds." << std::endl;
return 0;
}
示例9: test_speed_for_query
void test_speed_for_query(const Tree& tree,
const Query_type query_type,
const char *query_name,
const double duration)
{
typedef typename K::Ray_3 Ray;
typedef typename K::Line_3 Line;
typedef typename K::Point_3 Point;
typedef typename K::Vector_3 Vector;
typedef typename K::Segment_3 Segment;
CGAL::Timer timer;
unsigned int nb = 0;
timer.start();
while(timer.time() < duration)
{
switch(query_type)
{
case RAY_QUERY:
{
Point source = random_point_in<K>(tree.bbox());
Vector vec = random_vector<K>();
Ray ray(source, vec);
tree.do_intersect(ray);
break;
}
case SEGMENT_QUERY:
{
Point a = random_point_in<K>(tree.bbox());
Point b = random_point_in<K>(tree.bbox());
tree.do_intersect(Segment(a,b));
break;
}
break;
case LINE_QUERY:
{
Point a = random_point_in<K>(tree.bbox());
Point b = random_point_in<K>(tree.bbox());
tree.do_intersect(Line(a,b));
break;
}
}
nb++;
}
unsigned int speed = (unsigned int)(nb / timer.time());
std::cout.precision(10);
std::cout.width(15);
std::cout << speed << " intersections/s with " << query_name << std::endl;
timer.stop();
}
示例10: build_skeleton
void build_skeleton(const char* fname)
{
typedef typename Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Straight_skeleton_builder_traits_2<Kernel> SsBuilderTraits;
typedef CGAL::Straight_skeleton_2<Kernel> Ss;
typedef CGAL::Straight_skeleton_builder_2<SsBuilderTraits,Ss> SsBuilder;
Polygon_2 pgn;
std::ifstream input(fname);
FT x,y;
while(input)
{
input >> x;
if (!input) break;
input >> y;
if (!input) break;
pgn.push_back( Point_2( typename Kernel::FT(x), typename Kernel::FT(y) ) );
}
input.close();
std::cout << "Polygon has " << pgn.size() << " points\n";
if(!pgn.is_counterclockwise_oriented()) {
std::cerr << "Polygon is not CCW Oriented" << std::endl;
}
if(!pgn.is_simple()) {
std::cerr << "Polygon is not simple" << std::endl;
}
CGAL::Timer time;
time.start();
SsBuilder ssb;
ssb.enter_contour(pgn.vertices_begin(), pgn.vertices_end());
boost::shared_ptr<Ss> straight_ske = ssb.construct_skeleton();
time.stop();
std::cout << "Time spent to build skeleton " << time.time() << "\n";
if(!straight_ske->is_valid()) {
std::cerr << "Straight skeleton is not valid" << std::endl;
}
std::cerr.precision(60);
print_straight_skeleton(*straight_ske);
}
示例11:
void
run_benchmark(SDG& sdg)
{
load_cin_file(std::cin, sdg);
CGAL::Timer timer;
timer.start();
if(! sdg.is_valid(true, 1) ){
std::cerr << "invalid data structure" << std::endl;
} else {
std::cerr << "valid data structure" << std::endl;
}
timer.stop();
std::cerr << "Data structure checking time = " << timer.time() << "s\n";
}
示例12: main
int main()
{
Polygon_2 poly ;
poly.push_back( Point(-1,-1) ) ;
poly.push_back( Point(0,-12) ) ;
poly.push_back( Point(1,-1) ) ;
poly.push_back( Point(12,0) ) ;
poly.push_back( Point(1,1) ) ;
poly.push_back( Point(0,12) ) ;
poly.push_back( Point(-1,1) ) ;
poly.push_back( Point(-12,0) ) ;
SsPtr ss = CGAL::create_interior_straight_skeleton_2(poly);
double offset = 1 ;
{
CGAL::Timer time; time.start();
PolygonPtrVector outer_polygons =
CGAL::create_exterior_skeleton_and_offset_polygons_2(offset, poly);
time.stop();
std:: cout << outer_polygons.size() << " built in " << time.time() << "\n";
}
{
CGAL::Timer time; time.start();
PolygonPtrVector outer_polygons =
CGAL::create_offset_polygons_2<Polygon_2>(offset,
*CGAL::create_exterior_straight_skeleton_2( offset, poly));
time.stop();
std:: cout << outer_polygons.size() << " built in " << time.time() << "\n";
}
return 0;
}
示例13: main
int main(int argc, const char *argv[])
{
CavConfig cfg;
const char *run_control_file = "cavity_volumes_fin.inp";
if (argc > 1)
run_control_file = argv[1];
if (!cfg.init(run_control_file)) {
std::cerr << "Error while initializing from run control file : " << run_control_file << std::endl;
return 2;
}
cfg.out_inf << "Run control file : " << run_control_file << std::endl;
CGAL::Timer t;
int processed_cnt = 0;
cfg.out_inf << std::endl;
t.start();
while (cfg.next_timestep()) {
const Array_double_3 &a = cfg.atoms.back();
cfg.out_inf << "Number of input atoms : " << cfg.atoms.size() << std::endl;
cfg.out_inf << "MD info : " << cfg.ts_info << std::endl;
cfg.out_inf << "Box : [ " << cfg.box[0] << ", " << cfg.box[1] << ", " << cfg.box[2] << " ]" << std::endl;
cfg.out_inf << "Last atom : " << a[0] << " " << a[1] << " " << a[2] << std::endl;
if (!process_conf(cfg)) {
cfg.out_inf << "process_conf() error. Exiting..." << std::endl;
return 1;
}
processed_cnt++;
}
t.stop();
// save accumulated per-atom surfaces
if (cfg.out_asf.is_open()) {
long double total_surf = std::accumulate(cfg.atom_confs_surf.begin(), cfg.atom_confs_surf.end(), 0.0L);
cfg.out_asf << total_surf << std::endl; // first line is total exposed surface of all atoms in all confs
cfg.out_asf << cfg.atom_confs_surf.size() << std::endl; // second line is the number of atoms
for (size_t i = 0; i < cfg.atom_confs_surf.size(); i++)
cfg.out_asf << cfg.atom_confs_surf[i] << std::endl;
}
cfg.out_inf << "Processed " << processed_cnt << " (of " << cfg.traj_ts_cnt() << ") configurations." << std::endl;
cfg.out_inf << "Time: " << t.time() << " sec." << std::endl;
return 0;
}
示例14: meshRemoveIntersectedTriangles
TrianglesList meshRemoveIntersectedTriangles(TrianglesList &triangles)
{
CGAL::Timer timer;
timer.start();
TrianglesList result;
//Collision boxes
std::vector<BoxInt> boxes;
std::list<Triangle>::iterator triangleIter;
for(triangleIter = triangles.begin(); triangleIter != triangles.end(); ++triangleIter)
{
//Triangle t = *triangleIter;
TriangleVisitedInfoMC *tvi = new TriangleVisitedInfoMC;
tvi->triangle = &(*triangleIter); //Use the pointer, it should not change into the container, since there aren't new added elements
tvi->intersected = false;
boxes.push_back( BoxInt( (*triangleIter).bbox(), tvi ));
}
//Do intersection
CGAL::box_self_intersection_d( boxes.begin(), boxes.end(), reportSelfIntersectionCallback);
//cycle on boxes and build result and delete tvi
std::vector<BoxInt>::iterator vectorBoxesIter;
for(vectorBoxesIter = boxes.begin(); vectorBoxesIter != boxes.end(); ++vectorBoxesIter)
{
BoxInt boxInt = *vectorBoxesIter;
TriangleVisitedInfoMC *tviHandled = boxInt.handle();
if ((!(tviHandled->intersected)) && (!(tviHandled->triangle->is_degenerate())))
{
Triangle t = *(tviHandled->triangle);
result.push_back(t);
}
delete tviHandled;
}
timer.stop();
std::cout << "Total meshRemoveIntersectedTriangles time: " << timer.time() << std::endl;
return result;
}
示例15: main
int main()
{
int i, loops=10000000;
CGAL::Timer t;
double dt;
#if 0
// Those timings were made on my laptop, which is now not mine anymore,
// so I need to make them again to be able to make useful comparisons...
// Maybe automazing the process would be useful to test on different
// platforms...
// mp / mp1 / mp2 / mp3
// Cartesian : 3.44 / 2.71 / 2.67 / 3.5
// PointC2 : 2.27 / 2.26 / 2.17 / 2.78
// Advanced kernel : 2.25 / 2.26 / 2.17 / 2.78
// SimpleCartesian : 1.23 (1.21) (= without the wrapper classes)
// Homogeneous : 4.46 (3.47)
dt = t.time(); t.start();
for (i=0; i<loops; i++)
Point2 C = CGAL::midpoint(A,B);
#else
// Cartesian : 4.13 / 3.68 / 3.63 / 4.65
// PointC2 : 3.29 / 3.29 / 3.16 / 3.5
// Advanced kernel : 3.29 / 3.29 / 3.16 / 3.51
// SimpleCartesian : 1.32 (1.21)
// Homogeneous : 5.23 (4.22)
Point2 C;
dt = t.time(); t.start();
for (i=0; i<loops; i++)
C = CGAL::midpoint(A,B);
#endif
t.stop();
std::cout << "time = " << t.time()-dt << std::endl;
return 0;
}