mirror of https://github.com/CGAL/cgal
Simplify examples by reading data and not generating them randomly
This commit is contained in:
parent
90543eefab
commit
d4b7c2a030
|
|
@ -0,0 +1,50 @@
|
|||
-0.35075798630714417 -0.41687235236167908 -0.83856201171875
|
||||
0.71419811248779297 -0.18843579292297363 0.67410165071487427
|
||||
0.42867341637611389 0.027884410694241524 0.90302908420562744
|
||||
-0.62013190984725952 -0.34540200233459473 -0.70436769723892212
|
||||
-0.9326632022857666 0.29634016752243042 0.2057226151227951
|
||||
-0.40354812145233154 -0.89961040019989014 -0.16688345372676849
|
||||
0.03419160470366478 -0.48057779669761658 -0.87628531455993652
|
||||
0.23089799284934998 0.93538933992385864 0.26782989501953125
|
||||
0.85671085119247437 0.3628881573677063 0.36654967069625854
|
||||
-0.97818666696548462 -0.19104444980621338 0.081565350294113159
|
||||
0.47440874576568604 -0.5743638277053833 0.66711509227752686
|
||||
-0.056493125855922699 -0.86927080154418945 0.49109753966331482
|
||||
0.010806520469486713 0.013613199815154076 0.99984896183013916
|
||||
-0.71397566795349121 0.69716060161590576 -0.064852356910705566
|
||||
-0.27015089988708496 0.89724856615066528 -0.34923270344734192
|
||||
0.75348001718521118 -0.64979678392410278 0.10015973448753357
|
||||
-0.16720794141292572 0.51168584823608398 -0.84274494647979736
|
||||
-0.95293289422988892 -0.016512550413608551 0.3027312159538269
|
||||
0.69286113977432251 0.2687678337097168 0.66910934448242188
|
||||
0.7616615891456604 -0.64587092399597168 -0.052176054567098618
|
||||
0.92837363481521606 0.31181377172470093 0.20222419500350952
|
||||
0.47622725367546082 -0.82185006141662598 0.31268206238746643
|
||||
-0.20359978079795837 -0.50635278224945068 0.83794629573822021
|
||||
0.93060797452926636 0.36560913920402527 -0.017285611480474472
|
||||
-0.49206924438476563 -0.57476919889450073 -0.65384113788604736
|
||||
0.23404335975646973 0.1553766131401062 0.95973008871078491
|
||||
-0.65989810228347778 0.61365216970443726 -0.4335499107837677
|
||||
0.4939064085483551 -0.71372514963150024 -0.49664154648780823
|
||||
-0.49325522780418396 -0.80213826894760132 -0.33656129240989685
|
||||
0.11709120124578476 -0.2466987818479538 -0.96199238300323486
|
||||
-0.11803566664457321 0.16113057732582092 0.97984921932220459
|
||||
-0.70011669397354126 0.51104563474655151 -0.49866718053817749
|
||||
-0.062452834099531174 0.83341878652572632 -0.54910176992416382
|
||||
0.81961542367935181 -0.57244569063186646 0.023163642734289169
|
||||
-0.91654831171035767 0.14896728098392487 -0.37114411592483521
|
||||
-0.86025965213775635 -0.48420202732086182 0.15969254076480865
|
||||
-0.90642267465591431 -0.070597186684608459 0.41643005609512329
|
||||
-0.80410152673721313 -0.14624878764152527 0.57622218132019043
|
||||
0.27692857384681702 0.94953805208206177 0.1472686231136322
|
||||
0.4138990044593811 0.87840986251831055 0.23892201483249664
|
||||
0.80276262760162354 0.58548694849014282 0.11303627490997314
|
||||
0.07320818305015564 0.54400688409805298 -0.83588099479675293
|
||||
-0.77511709928512573 -0.61544054746627808 -0.14292106032371521
|
||||
0.88176971673965454 0.17292548716068268 -0.43883812427520752
|
||||
0.40121713280677795 -0.56469219923019409 -0.72121250629425049
|
||||
0.37540614604949951 -0.021287409588694572 0.92661595344543457
|
||||
0.91951727867126465 -0.39196351170539856 -0.029198687523603439
|
||||
-0.14655432105064392 -0.3981950581073761 -0.9055178165435791
|
||||
-0.67616212368011475 -0.22916138172149658 -0.70020699501037598
|
||||
-0.061372220516204834 0.92836838960647583 0.36655905842781067
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
-0.23387014772742987 0.51576417125761509 -0.94283433258533478 -0.23387014772742987 0.51576417125761509 -0.94283433258533478 -0.23387014772742987 0.51576417125761509 -0.94283433258533478
|
||||
-0.22177217062562704 0.6342452485114336 0.53645038604736328 0.48698166385293007 0.36138747073709965 0.8473226111382246 0.89880591165274382 -0.18703385163098574 0.36222409456968307
|
||||
0.80122884176671505 0.5579549316316843 -0.38984065130352974 -0.75229252129793167 -0.45774985756725073 -0.91460688132792711 0.84752658847719431 0.76262033171951771 0.96778011787682772
|
||||
-0.86271896027028561 -0.4205366550013423 -0.29304531868547201 -0.15778046473860741 0.31035543419420719 -0.76522185187786818 -0.98073739279061556 -0.85805401857942343 0.23671759944409132
|
||||
0.21695174276828766 0.52004669141024351 -0.41049789078533649 0.33822660800069571 -0.48476908728480339 -0.45631814934313297 -0.99325979873538017 -0.39482945576310158 0.68310892302542925
|
||||
0.64706522040069103 0.37597482278943062 0.83709257375448942 0.59178035520017147 -0.57171380333602428 -0.44549135770648718 0.02933723758906126 -0.79570241831243038 -0.079932044260203838
|
||||
-0.62750499602407217 0.29624816589057446 -0.3586333217099309 -0.97918341495096684 -0.96518470905721188 0.96828581392765045 -0.061115194112062454 0.48867659643292427 0.64704497344791889
|
||||
-0.93772094696760178 0.80566393863409758 -0.60725640039891005 -0.65731576643884182 -0.027184804901480675 -0.60858374927192926 -0.84231293667107821 -0.30525741167366505 0.76050507463514805
|
||||
0.44579031877219677 0.4484728816896677 -0.77035037335008383 -0.098480274900794029 -0.35220413748174906 0.0438017463311553 -0.99089097138494253 -0.44518457073718309 0.32719461154192686
|
||||
0.34583100397139788 0.64581762347370386 -0.387538967654109 0.75826548598706722 -0.77495390456169844 0.99434433691203594 -0.4828643761575222 0.63003566861152649 -0.54110724478960037
|
||||
|
|
@ -1,15 +1,10 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/box_intersection_d.h>
|
||||
#include <CGAL/point_generators_3.h>
|
||||
#include <CGAL/algorithm.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Simple_cartesian<float> Kernel;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
typedef CGAL::Random_points_on_sphere_3<Point_3> Points_on_sphere;
|
||||
|
||||
std::vector<Point_3> points;
|
||||
std::vector<Point_3*> boxes; // boxes are just pointers to points
|
||||
|
|
@ -44,17 +39,18 @@ void report( const Point_3* a, const Point_3* b) {
|
|||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
// create some random points on the sphere of radius 1.0
|
||||
Points_on_sphere generator( 1.0);
|
||||
points.reserve( 50);
|
||||
for ( int i = 0; i != 50; ++i) {
|
||||
points.push_back( *generator++);
|
||||
boxes.push_back( & points.back());
|
||||
}
|
||||
|
||||
// run the intersection algorithm and report proximity pairs
|
||||
CGAL::box_self_intersection_d( boxes.begin(), boxes.end(),
|
||||
report, Traits());
|
||||
return 0;
|
||||
int main(int argc, char*argv[]) {
|
||||
|
||||
std::ifstream in((argc>1)?argv[1]:"data/points.xyz");
|
||||
Point_3 p;
|
||||
while(in >> p){
|
||||
points.push_back(p);
|
||||
}
|
||||
for(std::size_t i = 0; i< points.size();++i) {
|
||||
boxes.push_back( &points[i]);
|
||||
}
|
||||
// run the intersection algorithm and report proximity pairs
|
||||
CGAL::box_self_intersection_d( boxes.begin(), boxes.end(),
|
||||
report, Traits());
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/intersections.h>
|
||||
#include <CGAL/point_generators_3.h>
|
||||
#include <CGAL/Bbox_3.h>
|
||||
#include <CGAL/box_intersection_d.h>
|
||||
#include <CGAL/function_objects.h>
|
||||
#include <CGAL/Join_input_iterator.h>
|
||||
#include <CGAL/algorithm.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
|
|
@ -15,34 +10,42 @@ typedef std::vector<Triangle_3> Triangles;
|
|||
typedef Triangles::iterator Iterator;
|
||||
typedef CGAL::Box_intersection_d::Box_with_handle_d<double,3,Iterator> Box;
|
||||
|
||||
Triangles triangles; // global vector of all triangles
|
||||
struct Report {
|
||||
Triangles* triangles;
|
||||
|
||||
// callback function that reports all truly intersecting triangles
|
||||
void report_inters( const Box& a, const Box& b) {
|
||||
std::cout << "Box " << (a.handle() - triangles.begin()) << " and "
|
||||
<< (b.handle() - triangles.begin()) << " intersect";
|
||||
Report(Triangles& triangles)
|
||||
: triangles(&triangles)
|
||||
{}
|
||||
|
||||
// callback functor that reports all truly intersecting triangles
|
||||
void operator()(const Box& a, const Box& b) const
|
||||
{
|
||||
std::cout << "Box " << (a.handle() - triangles->begin()) << " and "
|
||||
<< (b.handle() - triangles->begin()) << " intersect";
|
||||
if ( ! a.handle()->is_degenerate() && ! b.handle()->is_degenerate()
|
||||
&& CGAL::do_intersect( *(a.handle()), *(b.handle()))) {
|
||||
std::cout << ", and the triangles intersect also";
|
||||
std::cout << ", and the triangles intersect also";
|
||||
}
|
||||
std::cout << '.' << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
// Create 10 random triangles
|
||||
typedef CGAL::Random_points_in_cube_3<Point_3> Pts;
|
||||
typedef CGAL::Creator_uniform_3< Point_3, Triangle_3> Creator;
|
||||
typedef CGAL::Join_input_iterator_3<Pts,Pts,Pts,Creator> Triangle_gen;
|
||||
Pts points( 1); // in centered cube [-1,1)^3
|
||||
Triangle_gen triangle_gen( points, points, points);
|
||||
CGAL::cpp11::copy_n( triangle_gen, 10, std::back_inserter(triangles));
|
||||
|
||||
// Create the corresponding vector of bounding boxes
|
||||
std::vector<Box> boxes;
|
||||
for ( Iterator i = triangles.begin(); i != triangles.end(); ++i)
|
||||
boxes.push_back( Box( i->bbox(), i));
|
||||
|
||||
// Run the self intersection algorithm with all defaults
|
||||
CGAL::box_self_intersection_d( boxes.begin(), boxes.end(), report_inters);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char*argv[])
|
||||
{
|
||||
std::ifstream in((argc>1)?argv[1]:"data/triangles.xyz");
|
||||
Triangles triangles;
|
||||
Triangle_3 t;
|
||||
while(in >> t){
|
||||
triangles.push_back(t);
|
||||
}
|
||||
|
||||
// Create the corresponding vector of bounding boxes
|
||||
std::vector<Box> boxes;
|
||||
for ( Iterator i = triangles.begin(); i != triangles.end(); ++i)
|
||||
boxes.push_back( Box( i->bbox(), i));
|
||||
|
||||
// Run the self intersection algorithm with all defaults
|
||||
CGAL::box_self_intersection_d( boxes.begin(), boxes.end(), Report(triangles));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/intersections.h>
|
||||
#include <CGAL/point_generators_3.h>
|
||||
#include <CGAL/Bbox_3.h>
|
||||
#include <CGAL/box_intersection_d.h>
|
||||
#include <CGAL/function_objects.h>
|
||||
#include <CGAL/Join_input_iterator.h>
|
||||
#include <CGAL/algorithm.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
|
|
@ -15,40 +10,47 @@ typedef std::vector<Triangle_3> Triangles;
|
|||
typedef Triangles::iterator Iterator;
|
||||
typedef CGAL::Box_intersection_d::Box_with_handle_d<double,3,Iterator> Box;
|
||||
|
||||
Triangles triangles; // global vector of all triangles
|
||||
struct Report {
|
||||
Triangles* triangles;
|
||||
|
||||
// callback function that reports all truly intersecting triangles
|
||||
void report_inters( const Box* a, const Box* b) {
|
||||
std::cout << "Box " << (a->handle() - triangles.begin()) << " and "
|
||||
<< (b->handle() - triangles.begin()) << " intersect";
|
||||
Report(Triangles& triangles)
|
||||
: triangles(&triangles)
|
||||
{}
|
||||
|
||||
// callback functor that reports all truly intersecting triangles
|
||||
void operator()(const Box* a, const Box* b) const
|
||||
{
|
||||
std::cout << "Box " << (a->handle() - triangles->begin()) << " and "
|
||||
<< (b->handle() - triangles->begin()) << " intersect";
|
||||
if ( ! a->handle()->is_degenerate() && ! b->handle()->is_degenerate()
|
||||
&& CGAL::do_intersect( *(a->handle()), *(b->handle()))) {
|
||||
std::cout << ", and the triangles intersect also";
|
||||
std::cout << ", and the triangles intersect also";
|
||||
}
|
||||
std::cout << '.' << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
// Create 10 random triangles
|
||||
typedef CGAL::Random_points_in_cube_3<Point_3> Pts;
|
||||
typedef CGAL::Creator_uniform_3< Point_3, Triangle_3> Creator;
|
||||
typedef CGAL::Join_input_iterator_3<Pts,Pts,Pts,Creator> Triangle_gen;
|
||||
Pts points( 1); // in centered cube [-1,1)^3
|
||||
Triangle_gen triangle_gen( points, points, points);
|
||||
CGAL::cpp11::copy_n( triangle_gen, 10, std::back_inserter(triangles));
|
||||
|
||||
// Create the corresponding vector of bounding boxes
|
||||
std::vector<Box> boxes;
|
||||
for ( Iterator i = triangles.begin(); i != triangles.end(); ++i)
|
||||
boxes.push_back( Box( i->bbox(), i));
|
||||
|
||||
// Create the corresponding vector of pointers to bounding boxes
|
||||
std::vector<Box *> ptr;
|
||||
for ( std::vector<Box>::iterator i = boxes.begin(); i != boxes.end(); ++i)
|
||||
ptr.push_back( &*i);
|
||||
|
||||
// Run the self intersection algorithm with all defaults on the
|
||||
// indirect pointers to bounding boxes. Avoids copying the boxes.
|
||||
CGAL::box_self_intersection_d( ptr.begin(), ptr.end(), report_inters);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char*argv[])
|
||||
{
|
||||
std::ifstream in((argc>1)?argv[1]:"data/triangles.xyz");
|
||||
Triangles triangles;
|
||||
Triangle_3 t;
|
||||
while(in >> t){
|
||||
triangles.push_back(t);
|
||||
}
|
||||
// Create the corresponding vector of bounding boxes
|
||||
std::vector<Box> boxes;
|
||||
for ( Iterator i = triangles.begin(); i != triangles.end(); ++i)
|
||||
boxes.push_back( Box( i->bbox(), i));
|
||||
|
||||
// Create the corresponding vector of pointers to bounding boxes
|
||||
std::vector<Box *> ptr;
|
||||
for ( std::vector<Box>::iterator i = boxes.begin(); i != boxes.end(); ++i)
|
||||
ptr.push_back( &*i);
|
||||
|
||||
// Run the self intersection algorithm with all defaults on the
|
||||
// indirect pointers to bounding boxes. Avoids copying the boxes.
|
||||
CGAL::box_self_intersection_d( ptr.begin(), ptr.end(), Report(triangles));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue