mirror of https://github.com/CGAL/cgal
Benchmarks -> benchmark
This commit is contained in:
parent
5030f1e929
commit
3fbda51a5e
|
|
@ -1231,6 +1231,10 @@ Circular_kernel_2/Benchmarks/parser/Report.pdf -text svneol=unset#application/pd
|
|||
Circular_kernel_2/Benchmarks/readme.doc -text svneol=unset#application/msword
|
||||
Circular_kernel_2/Benchmarks/readme.pdf -text svneol=unset#application/pdf
|
||||
Circular_kernel_2/Benchmarks/readme.sxw -text
|
||||
Circular_kernel_2/benchmark/parser/Report.pdf -text svneol=unset#application/pdf
|
||||
Circular_kernel_2/benchmark/readme.doc -text svneol=unset#application/msword
|
||||
Circular_kernel_2/benchmark/readme.pdf -text svneol=unset#application/pdf
|
||||
Circular_kernel_2/benchmark/readme.sxw -text
|
||||
Circular_kernel_2/changes -text
|
||||
Circular_kernel_2/demo/Circular_kernel_2/Qt3/README -text
|
||||
Circular_kernel_2/demo/Circular_kernel_2/Qt3/help/get_arc.jpeg -text svneol=unset#image/jpeg
|
||||
|
|
|
|||
|
|
@ -0,0 +1,124 @@
|
|||
#include <CGAL/Random.h>
|
||||
#include <CGAL/IO/Dxf_variant_reader.h>
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_dfx(ArcContainer& arcs,char* Dfxfile){
|
||||
|
||||
typedef typename CK::Circular_arc_2 Circular_arc_2;
|
||||
typedef typename CK::Line_arc_2 Line_arc_2;
|
||||
std::ifstream fin;
|
||||
|
||||
fin.open (Dfxfile);
|
||||
CGAL::variant_load<CK, Circular_arc_2, Line_arc_2>(fin, std::back_inserter(arcs));
|
||||
fin.close();
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_grid(ArcContainer& ac){
|
||||
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
int x = 5;
|
||||
int y = 5;
|
||||
int r = 5;
|
||||
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j <20; j++){
|
||||
ac.push_back( Circle_2( Point_2(x + j*r, y + i*r), r*r));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_grid2(ArcContainer& ac){
|
||||
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
int x = 10;
|
||||
int y = 10;
|
||||
int r = 10;
|
||||
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j < 20; j++){
|
||||
ac.push_back(Circle_2( Point_2(x + j*r, y + i*r), r*r));
|
||||
}
|
||||
}
|
||||
|
||||
x += r;
|
||||
y += r;
|
||||
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j < 20; j++){
|
||||
ac.push_back( Circle_2( Point_2(x + j*r, y + i*r), r*r));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_random(ArcContainter& arcs)
|
||||
{
|
||||
std::ofstream fout("random.inp");
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
CGAL::Random generatorOfgenerator;
|
||||
int random_seed = generatorOfgenerator.get_int(0, 123456);
|
||||
std::cout << "random_seed = " << random_seed << std::endl;
|
||||
CGAL::Random theRandom(random_seed);
|
||||
|
||||
double random_max = 10;
|
||||
double random_min = -10;
|
||||
|
||||
for(int i = 0; i < 100 ; i++){
|
||||
double x = theRandom.get_double(random_min,random_max);
|
||||
double y = theRandom.get_double(random_min,random_max);
|
||||
double r = theRandom.get_double(0.1,random_max);
|
||||
fout << x << " " << y << " " << r << " " ;
|
||||
arcs.push_back( Circle_2( Point_2(x,y), r*r));
|
||||
}
|
||||
|
||||
fout.close();
|
||||
std::cout << arcs.size() << std::endl;
|
||||
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_file(ArcContainter& arcs){
|
||||
double x,y, r;
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
std::ifstream fin("random.inp");
|
||||
for(int i = 0; i < 100 ; i++){
|
||||
fin >> x >> y >> r ;
|
||||
arcs.push_back( Circle_2( Point_2(x,y), r*r));
|
||||
}
|
||||
|
||||
fin.close();
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_rotation(ArcContainter& ac){
|
||||
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
int x = 10;
|
||||
int y = 10;
|
||||
int r = 10;
|
||||
int R =0;
|
||||
|
||||
for(int k = 0; k < 5; k++){
|
||||
for(int i = 0; i < 5; i++){
|
||||
for(int j = 0; j < 5; j++){
|
||||
R = (r+k)*(r+k);
|
||||
ac.push_back( Circle_2( Point_2(x + i*r, y + j*r),R));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,466 @@
|
|||
#ifndef ECG_BENCH_H
|
||||
#define ECG_BENCH_H
|
||||
|
||||
#include <CGAL/Interval_nt.h>
|
||||
#include <CGAL/Memory_sizer.h>
|
||||
|
||||
#include <string>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "Input_data.h"
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
|
||||
|
||||
class Bench
|
||||
{
|
||||
private:
|
||||
|
||||
int numof_f_fails;
|
||||
std::ofstream htmlout,texout;
|
||||
struct rusage before,after;
|
||||
struct timeval utime,stime;
|
||||
bool firsttime;
|
||||
int vert[5],hedg[5];
|
||||
int i;
|
||||
CGAL::Memory_sizer mem_sizer;
|
||||
char* Dxffile;
|
||||
bool ONLY_DXF;
|
||||
typedef std::list<char *> DxfFileNames;
|
||||
bool Dxf_Horizontal;
|
||||
double MemBefore,MemAfter;
|
||||
public:
|
||||
Bench(DxfFileNames df,char * fhtml="benchmarks.html", char* ftex="benchmarks.tex"):
|
||||
htmlout(fhtml,std::ios::app),
|
||||
texout(ftex,std::ios::app)
|
||||
{
|
||||
i=0;
|
||||
numof_f_fails= CGAL::Interval_nt<>::number_of_failures() ;
|
||||
ONLY_DXF = false;
|
||||
Dxf_Horizontal =true;
|
||||
std::cout << ".:Starting Bench Suite:." << std::endl;
|
||||
std::cout << ".:Starting Bench Suite:." << std::endl;
|
||||
|
||||
htmlout<<"<table border = \"3\">"<<std::endl;
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td>";
|
||||
texout << "\\documentclass[1pt]{article}"<<std::endl
|
||||
<<"\\usepackage{amsmath}"<<std::endl
|
||||
<<"\\usepackage{rotating}"<<std::endl
|
||||
<<"\\begin{document}"<<std::endl
|
||||
<<"\\newsavebox{\\foo}"<<std::endl
|
||||
<<"\\savebox{\\foo}"<<std::endl
|
||||
<<"{\\parbox{5cm}{"<<std::endl
|
||||
<<"\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline $Kernel$ ";
|
||||
for (DxfFileNames::const_iterator it=df.begin();
|
||||
it != df.end(); ++it) {
|
||||
std::cout<<*it<<std::endl;
|
||||
htmlout<<"<td>"<<*it<<"</td>";
|
||||
texout <<"& \\multicolumn{4}{c|}{\\begin{verbatim}"<< *it<<"\\end{verbatim}}";
|
||||
};
|
||||
htmlout << "</tr>"
|
||||
<<std::endl;
|
||||
texout <<"\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Bench( char *fhtml="benchmarks.html", char* ftex="benchmarks.tex",char* Dxffilename="",const bool only_dxf=false):
|
||||
htmlout(fhtml,std::ios::app),
|
||||
texout(ftex,std::ios::app){
|
||||
i=0;
|
||||
numof_f_fails=CGAL::Interval_nt<>::number_of_failures();
|
||||
Dxffile=Dxffilename;
|
||||
ONLY_DXF = only_dxf;
|
||||
|
||||
std::cout << ".:Starting Bench Suite:." << std::endl;
|
||||
|
||||
htmlout<<"Dxf file is : "<< Dxffile << std::endl;
|
||||
|
||||
htmlout<<"<table border = \"3\">"<<std::endl;
|
||||
|
||||
if(!ONLY_DXF){
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>grid I(400 Circle_2)</td><td>grid II(800 Circle_2)</td><td>random double (100 Circle)</td><td> rotation (125 Circle_2) </td></tr>"
|
||||
<<std::endl;
|
||||
|
||||
texout << "\\documentclass[12pt]{article}"<<std::endl
|
||||
<<"\\usepackage{amsmath}"<<std::endl
|
||||
<<"\\usepackage{rotating}"<<std::endl
|
||||
<<"\\begin{document}"<<std::endl
|
||||
<<"\\newsavebox{\\foo}"<<std::endl
|
||||
<<"\\savebox{\\foo}"<<std::endl
|
||||
<<"{\\parbox{5cm}{"<<std::endl
|
||||
<<"\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline Kernel &\\multicolumn{4}{c|}{ grid I}&\\multicolumn{4}{c|}{grid II }&\\multicolumn{4}{c|}{random double} &\\multicolumn{4}{c|}{ rotation }\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
|
||||
else {
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>Dxf input is: "<< Dxffile <<"</td></tr>"
|
||||
<<std::endl;
|
||||
|
||||
texout << "\\documentclass[12pt]{article}"<<std::endl
|
||||
<<"\\usepackage{amsmath}"<<std::endl
|
||||
<<"\\begin{document}"<<std::endl
|
||||
<<"\\begin{tabular}{|c|c|c|} \\hline $Kernel$ & & \\multicolumn{4}{c|}{Dxf input is:"<< Dxffile <<"} \\\\ \\hline"<<std::endl;
|
||||
}
|
||||
firsttime = true;
|
||||
|
||||
}
|
||||
void infotable(){
|
||||
if(!Dxf_Horizontal){
|
||||
if(!ONLY_DXF){
|
||||
texout<< "\\hline\\hline & \\multicolumn{4}{c|}{ grid I}&\\multicolumn{4}{c|}{grid II }&\\multicolumn{4}{c|}{random double} &\\multicolumn{4}{c|}{ rotation }\\\\ \\hline" << std::endl
|
||||
<< "vertices" ;
|
||||
for (int k=1; k < 6 ;k++) {
|
||||
texout << " &\\multicolumn{4}{c|}{"<< vert[k]<<"}";
|
||||
}
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
texout<<"halfedges";
|
||||
|
||||
for (int l=1; l < 6 ;l++){
|
||||
texout << " &\\multicolumn{4}{c|}{"<< hedg[l]<<"}";
|
||||
}
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
|
||||
else {
|
||||
texout<< "\\hline\\hline &\\multicolumn{4}{c|}{Dxf input is:"<< Dxffile <<"} \\\\ \\hline" << std::endl
|
||||
<< "vertices" ;
|
||||
texout << " &\\multicolumn{4}{c|}{"<< vert[4]<<"}";
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
texout<<"halfedges";
|
||||
texout <<" &\\multicolumn{4}{c|}{"<< hedg[4]<<"}";
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
texout<< "\\hline\\hline "<< std::endl
|
||||
<< "vertices" ;
|
||||
for (int k=0; k < 3 ;k++) {
|
||||
texout << " &\\multicolumn{4}{c|}{"<< vert[k]<<"}";
|
||||
}
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
texout<<"halfedges";
|
||||
|
||||
for (int l=0; l < 3 ;l++){
|
||||
texout <<" &\\multicolumn{4}{c|}{"<< hedg[l]<<"}";
|
||||
}
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
~Bench(){
|
||||
std::cout<<"destructor"<<std::endl;
|
||||
htmlout <<"</table>"<<std::endl;
|
||||
infotable();
|
||||
texout << "\\end{tabular}" << std::endl
|
||||
<<"}"<< std::endl
|
||||
<<"}"<< std::endl
|
||||
<<"\\begin{turn}{-90}\\usebox{\\foo}\\end{turn}"<< std::endl
|
||||
<<"\\end{document}"<<std::endl;
|
||||
}
|
||||
private:
|
||||
void open_cell(){
|
||||
htmlout <<"<td>";
|
||||
texout<<" ";
|
||||
}
|
||||
|
||||
void close_cell(){
|
||||
htmlout <<"</td>";
|
||||
texout <<" ";
|
||||
}
|
||||
void open_row(){
|
||||
htmlout <<"<tr>";
|
||||
texout <<"";
|
||||
}
|
||||
|
||||
void close_row(){
|
||||
htmlout <<"</tr>"<< std::endl;
|
||||
texout <<"\\\\ \\hline"<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
void empty_cell(){
|
||||
this->open_cell();
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td><td>MemBefore</td><td>MemAfter</td>" << std::endl
|
||||
<< "<tr><td>"
|
||||
<<"-"<<"</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td></tr>"
|
||||
<< "</table></td>" ;
|
||||
texout<<"& -& -&-& -";
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
void start(void){
|
||||
getrusage(RUSAGE_SELF,&before);
|
||||
}
|
||||
|
||||
void stop(void){
|
||||
getrusage(RUSAGE_SELF,&after);
|
||||
}
|
||||
|
||||
void summarize(int vertices,int hedges){
|
||||
int temp;
|
||||
temp=CGAL::Interval_nt<>::number_of_failures();
|
||||
numof_f_fails = temp - numof_f_fails;
|
||||
std::cout << " numbers_of_filter_fails : " << numof_f_fails << std::endl;
|
||||
|
||||
timersub(&(after.ru_utime),&(before.ru_utime),&utime);
|
||||
timersub(&(after.ru_stime),&(before.ru_stime),&stime);
|
||||
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td><td>MemBefore</td><td>MemAfter</td>" << std::endl
|
||||
<< "<tr><td>"
|
||||
<<utime.tv_sec<<"."<< std::setw(6) << std::setfill('0')<< utime.tv_usec <<"</td><td>"
|
||||
<< numof_f_fails << "</td><td>"
|
||||
<< vertices << "</td><td>"
|
||||
<< hedges<<"</td><td>"
|
||||
<< MemBefore << "</td><td>"
|
||||
<< MemAfter<< "</td></tr>"
|
||||
<< "</table></td>";
|
||||
|
||||
texout << " & " <<utime.tv_sec<<"."<< std::setw(6) << std::setfill('0')
|
||||
<< utime.tv_usec;
|
||||
texout << "&"<< numof_f_fails;
|
||||
texout << "&"<< MemBefore;
|
||||
texout << "&"<<MemAfter;
|
||||
std::cout << " vertices : " << vertices << std::endl
|
||||
<< " halfedges : " << hedges << std::endl
|
||||
<< " Time (sec): " << utime.tv_sec << std::endl
|
||||
<< " (usec): " << std::setw(6) << std::setfill('0')
|
||||
<< utime.tv_usec << std::endl;
|
||||
numof_f_fails = CGAL::Interval_nt<>::number_of_failures();
|
||||
}
|
||||
|
||||
void fail(void){
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td><td>MemBefore</td><td>MemAfter</td>"<<std::endl
|
||||
<< "<tr><td>"
|
||||
<<"fail"<<"</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td></tr>"
|
||||
<< "</table></td>" ;
|
||||
texout << "& fail & fail & fail & fail";
|
||||
std::cout << " :: Abort:: "<< std::endl;
|
||||
}
|
||||
|
||||
template <class Traits,class ArcContainer>
|
||||
void arrangement(const ArcContainer & ac){
|
||||
bool fail=false;
|
||||
typedef typename CGAL::Arrangement_2<Traits> Pmwx;
|
||||
typedef typename CGAL::Arr_naive_point_location<Pmwx> Point_location;
|
||||
|
||||
std::cout << "memory size before construction" << mem_sizer.virtual_size() << std::endl;
|
||||
std::cout << "memory resident size before insert()" << mem_sizer.resident_size () << std::endl;
|
||||
MemBefore = mem_sizer.virtual_size ()/1000;
|
||||
Pmwx _pm;
|
||||
Point_location _pl(_pm);
|
||||
|
||||
try{
|
||||
this->start();
|
||||
insert(_pm,ac.begin(),ac.end(),boost::false_type());
|
||||
this->stop();
|
||||
}
|
||||
catch (...) {
|
||||
this->fail();
|
||||
fail=true;
|
||||
}
|
||||
vert[i]=(int)_pm.number_of_vertices();
|
||||
hedg[i]=(int)_pm.number_of_halfedges();
|
||||
|
||||
if (!fail){this->summarize(_pm.number_of_vertices(),_pm.number_of_halfedges());}
|
||||
|
||||
MemAfter = mem_sizer.virtual_size ()/1000;
|
||||
std::cout << "memory size after insert()" << mem_sizer.virtual_size () << std::endl;
|
||||
std::cout << "memory resident size after insert()" << mem_sizer.resident_size () << std::endl;
|
||||
_pm.clear();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void grid(){
|
||||
i=1;
|
||||
ArcContainer ac;
|
||||
_bench_input_grid<CK,ArcContainer>(ac);
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void grid2(){
|
||||
i=2;
|
||||
ArcContainer ac;
|
||||
_bench_input_grid2<CK,ArcContainer>(ac);
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void random(){
|
||||
i=3;
|
||||
ArcContainer ac;
|
||||
if (firsttime){
|
||||
_bench_input_random<CK,ArcContainer>(ac);
|
||||
std::cout << "Input from random generator!"<<std::endl;
|
||||
}
|
||||
else{
|
||||
_bench_input_file<CK,ArcContainer>(ac);
|
||||
std::cout << "Input from file!"<<std::endl;
|
||||
}
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
this->close_cell();
|
||||
firsttime = false;
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void dfx(char* Dfxfile){
|
||||
if(!Dxf_Horizontal){
|
||||
i=4;
|
||||
}
|
||||
ArcContainer arc;
|
||||
_bench_input_dfx<CK,ArcContainer>(arc,Dfxfile);
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(arc);
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void rotation(){
|
||||
i=5;
|
||||
bool fail=false;
|
||||
ArcContainer arc;
|
||||
try{
|
||||
_bench_input_rotation<CK,ArcContainer>(arc);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->fail();
|
||||
fail=true;
|
||||
std::cout << "failed before input";
|
||||
}
|
||||
|
||||
if (!fail){
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(arc);
|
||||
this->close_cell();
|
||||
this->close_row();
|
||||
}
|
||||
}
|
||||
public:
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute(char* dxffile){
|
||||
if(!ONLY_DXF){
|
||||
this->grid<CK,Traits,ArcContainer>();
|
||||
this->grid2<CK,Traits,ArcContainer>();
|
||||
this->random<CK,Traits,ArcContainer>();
|
||||
this->dfx<CK,Traits,ArcContainer>(dxffile);
|
||||
this->rotation<CK,Traits,ArcContainer>();
|
||||
}
|
||||
else{
|
||||
this->dfx<CK,Traits,ArcContainer>(dxffile);
|
||||
this->close_row();
|
||||
}
|
||||
}
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void ComputeArrayDxf(DxfFileNames df){
|
||||
i=0;
|
||||
for ( DxfFileNames::const_iterator it=df.begin();
|
||||
it != df.end(); ++it) {
|
||||
std::cout<<*it<<std::endl;
|
||||
this->dfx<CK,Traits,ArcContainer>(*it);
|
||||
i++;
|
||||
};
|
||||
this->close_row();
|
||||
}
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute_no_dxf(){
|
||||
if(!ONLY_DXF){
|
||||
this->grid<CK,Traits,ArcContainer>();
|
||||
this->grid2<CK,Traits,ArcContainer>();
|
||||
this->random<CK,Traits,ArcContainer>();
|
||||
this->empty_cell();
|
||||
this->rotation<CK,Traits,ArcContainer>();
|
||||
}
|
||||
}
|
||||
|
||||
void empty_row(){
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->close_row();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute_dxf(char* dxffile){
|
||||
this->dfx<CK,Traits,ArcContainer>(dxffile);
|
||||
this->close_row();
|
||||
}
|
||||
|
||||
void kernel(char* kernel){
|
||||
this->open_row();
|
||||
this->open_cell();
|
||||
htmlout << kernel;
|
||||
texout << kernel ;
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
|
||||
void newDxfFilename(char* Dxffilename=""){
|
||||
char* newDxf = Dxffilename;
|
||||
if(!Dxf_Horizontal){
|
||||
if(!ONLY_DXF){
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>grid I</td><td>grid II</td><td>random double</td><td>Dxf input is: "<< newDxf <<"</td><td> rotation </td></tr>"
|
||||
<<std::endl;
|
||||
infotable();
|
||||
texout <<"\\end{tabular}"<<std::endl<<"\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline Kernel &\\multicolumn{4}{c|}{ grid I}&\\multicolumn{4}{c|}{grid II }&\\multicolumn{4}{c|}{random double} & \\multicolumn{4}{c|}{Dxf input is:"<< newDxf<<" }&\\multicolumn{4}{c|}{ rotation }\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
else{
|
||||
infotable();
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>Dxf input is: "<< newDxf <<"</td> </tr>"
|
||||
<<std::endl;
|
||||
texout <<"\\end{tabular}"<<std::endl<<"\\begin{tabular}{|c|c|c|c|c|} \\hline $Kernel$ &\\multicolumn{4}{c|}{Dxf input is:"<< newDxf <<"} \\\\ \\hline"<<std::endl;
|
||||
}
|
||||
Dxffile=Dxffilename;
|
||||
|
||||
}
|
||||
htmlout <<"</table>"<<std::endl;
|
||||
infotable();
|
||||
texout << "\\end{tabular}" << std::endl;
|
||||
texout <<"\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline $Kernel$ ";
|
||||
}
|
||||
void newDxfArray(DxfFileNames df){
|
||||
htmlout <<"</table>"<<std::endl;
|
||||
infotable();
|
||||
texout << "\\end{tabular}" << std::endl;
|
||||
texout <<"\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline $Kernel$ ";
|
||||
htmlout<<"<table border = \"3\">"<<std::endl;
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td>";
|
||||
for (DxfFileNames::const_iterator it=df.begin();
|
||||
it != df.end(); ++it) {
|
||||
std::cout<<*it<<std::endl;
|
||||
htmlout<<"<td>"<<*it<<"</td>";
|
||||
texout <<"& \\multicolumn{4}{c|}{\\begin{verbatim}"<< *it<<"\\end{verbatim}}";
|
||||
};
|
||||
htmlout << "</tr>"
|
||||
<<std::endl;
|
||||
texout <<"\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
};
|
||||
#endif //#define ECG_BENCH_H
|
||||
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
#define CGAL_CAST_INT
|
||||
|
||||
#define CIRCULAR_KERNEL_2
|
||||
#define LAZY_CURVED_KERNEL_2
|
||||
//#define CIRCULAR_KERNEL_2_FILTERED_HEXAGON
|
||||
//#define LAZY_CURVED_KERNEL_2_FILTERED_HEXAGON
|
||||
// #define CIRCULAR_KERNEL_2_FILTERED_BBOX
|
||||
//#define LAZY_CURVED_KERNEL_2_FILTERED_BBOX
|
||||
|
||||
#define CGAL_CAST_INT
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Handle_for.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
#include <CGAL/MP_Float.h>
|
||||
|
||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
||||
|
||||
#include <CGAL/intersections.h>
|
||||
|
||||
#include <CGAL/Circular_kernel_2.h>
|
||||
#include <CGAL/Circular_arc_traits.h>
|
||||
#include <CGAL/Circular_arc_traits_tracer.h>
|
||||
|
||||
#include <CGAL/Lazy_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Filtered_hexagon_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Filtered_bbox_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_naive_point_location.h>
|
||||
#include <CGAL/Variant_traits.h>
|
||||
|
||||
|
||||
#include <CGAL/Random.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "benchmark.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{ typedef std::list<char*> Dxffilenames;
|
||||
Dxffilenames dxffilenames;
|
||||
char* Dxffilename[]={"myFirst.dxf","minimask0.dxf","minimask1.dxf","mask0.dxf","mask1.dxf","smallpainttrack.dxf","mask0_25.dxf","mask0_5.dxf","cad_l2.dxf","cad_l1.dxf","CIOnZDraw.dxf","che_mod1.dxf","elekonta.dxf","painttrack.dxf","netlist_signal_1.dxf","51.dxf"};
|
||||
char* Htmlfilename;
|
||||
char* Texfilename;
|
||||
int i;
|
||||
i=0;
|
||||
|
||||
|
||||
Htmlfilename="benchmarks.html";
|
||||
Texfilename="benchmarks.tex";
|
||||
|
||||
|
||||
for(int n = 0; n < 3; n++){
|
||||
dxffilenames.push_back(Dxffilename[n]);
|
||||
};
|
||||
|
||||
|
||||
Bench bench(dxffilenames,Htmlfilename,Texfilename);
|
||||
|
||||
|
||||
for(i=1;i<6;i++){
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Circular_Kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef CIRCULAR_KERNEL_2
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT1;
|
||||
typedef CGAL::Cartesian<NT1> Linear_k1;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT1> Algebraic_k1;
|
||||
typedef CGAL::Circular_kernel_2<Linear_k1, Algebraic_k1> CircularKernel;
|
||||
|
||||
typedef CircularKernel::Circular_arc_2 Circular_arc_2;
|
||||
typedef CircularKernel::Line_arc_2 Line_arc_2;
|
||||
typedef CGAL::Variant_traits<CircularKernel,Line_arc_2,Circular_arc_2> CircularK_Variant_Traits;
|
||||
|
||||
typedef boost::variant< Circular_arc_2, Line_arc_2 > CircularKVarArc;
|
||||
typedef std::vector<CircularKVarArc> CircularKVarArcContainer;
|
||||
|
||||
bench.kernel("CK VarTraits");
|
||||
|
||||
bench.ComputeArrayDxf<CircularKernel,CircularK_Variant_Traits,CircularKVarArcContainer>(dxffilenames);
|
||||
|
||||
//bench.Compute_dxf<CircularKernel,CircularK_Variant_Traits,CircularKVarArcContainer>(Dxffilename[i]);
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Lazy_curved_Kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef LAZY_CURVED_KERNEL_2
|
||||
// typedef CGAL::Quotient<CGAL::MP_Float> NT2;
|
||||
typedef CGAL::Gmpq NT2;
|
||||
typedef CGAL::Cartesian<NT2> Linear_k2;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT2> Algebraic_k2;
|
||||
typedef CGAL::Circular_kernel_2 <Linear_k2, Algebraic_k2> CK2_;
|
||||
|
||||
|
||||
typedef CGAL::Interval_nt_advanced NT3;
|
||||
typedef CGAL::Cartesian<NT3> Linear_k3;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT3> Algebraic_k3;
|
||||
typedef CGAL::Circular_kernel_2 <Linear_k3,Algebraic_k3> CK3_;
|
||||
|
||||
|
||||
typedef CGAL::Lazy_circular_kernel_2<CK2_,CK3_> LazyCurvedK;
|
||||
|
||||
|
||||
|
||||
typedef LazyCurvedK::Circular_arc_2 Circular_arc_3;
|
||||
typedef LazyCurvedK::Line_arc_2 Line_arc_3;
|
||||
typedef boost::variant<Circular_arc_3,Line_arc_3 > LazyVarArc;
|
||||
typedef std::vector<LazyVarArc> LazyVarContainer;
|
||||
typedef CGAL::Variant_traits<LazyCurvedK,Line_arc_3,Circular_arc_3> LazyCurvedK_Variant_Traits;
|
||||
|
||||
bench.kernel("LazyK. VarTraits");
|
||||
|
||||
bench.ComputeArrayDxf<LazyCurvedK,LazyCurvedK_Variant_Traits,LazyVarContainer>(dxffilenames);
|
||||
//bench.Compute_dxf<LazyCurvedK,LazyCurvedK_Variant_Traits,LazyVarContainer>(Dxffilename[i]);
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Filtered_hexagone_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef CIRCULAR_KERNEL_2_FILTERED_HEXAGON
|
||||
|
||||
typedef CGAL::Filtered_hexagon_circular_kernel_2<CircularKernel> CircularKernelHexagon;
|
||||
|
||||
typedef CircularKernelHexagon::Circular_arc_2 Circular_arc_4;
|
||||
typedef CircularKernelHexagon::Line_arc_2 Line_arc_4;
|
||||
typedef boost::variant< Circular_arc_4, Line_arc_4 > CircularKernHexVarArc;
|
||||
typedef std::vector<CircularKernHexVarArc> CircularKernHexVarArcContainer;
|
||||
typedef CGAL::Variant_traits<CircularKernelHexagon,Circular_arc_4,Line_arc_4> CircularKernHex_Variant_Traits;
|
||||
|
||||
bench.kernel("CK Hex VarTraits");
|
||||
|
||||
// bench.Compute<CircularKernelHexagon,CircularKernHex_Variant_Traits,CircularKernHexVarArcContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<CircularKernelHexagon,CircularKernHex_Variant_Traits,CircularKernHexVarArcContainer>();
|
||||
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Filtered_hexagone_Lazy_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef LAZY_CURVED_KERNEL_2_FILTERED_HEXAGON
|
||||
|
||||
typedef CGAL::Filtered_hexagon_curved_kernel<LazyCurvedK> LazyKernelHexagon;
|
||||
|
||||
typedef LazyKernelHexagon::Circular_arc_2 Circular_arc_5;
|
||||
typedef LazyKernelHexagon::Line_arc_2 Line_arc_5;
|
||||
typedef boost::variant<Circular_arc_5,Line_arc_5 > HxLazyVarArc;
|
||||
typedef std::vector<HxLazyVarArc> HxLazyVarContainer;
|
||||
typedef CGAL::Variant_traits<LazyKernelHexagon,Line_arc_5,Circular_arc_5> HxLazyVariantTraits;
|
||||
|
||||
bench.kernel("LazyK Hex VarTraits") ;
|
||||
|
||||
//bench.Compute<LazyKernelHexagon,HxLazyVariantTraits,HxLazyVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<LazyKernelHexagon,HxLazyVariantTraits,HxLazyVarContainer>();
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_filtered_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef CIRCULAR_KERNEL_2_FILTERED_BBOX
|
||||
|
||||
typedef CGAL::Filtered_bbox_circular_kernel_2<CircularKernel> BBCircularKernel ;
|
||||
|
||||
typedef BBCircularKernel::Circular_arc_2 Circular_arc_6;
|
||||
typedef BBCircularKernel::Line_arc_2 Line_arc_6;
|
||||
typedef boost::variant<Circular_arc_6,Line_arc_6 > BBCircVarArc;
|
||||
typedef std::vector<BBCircVarArc> BBCircVarContainer;
|
||||
typedef CGAL::Variant_traits<BBCircularKernel,Line_arc_6,Circular_arc_6> BBCircVariantTraits;
|
||||
|
||||
bench.kernel("CK BBox VarTraits") ;
|
||||
|
||||
bench.Compute<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>(Dxffilename[i]);
|
||||
// bench.Compute_no_dxf<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>();
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_hexagone_Lazy_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef LAZY_CURVED_KERNEL_2_FILTERED_BBOX
|
||||
|
||||
typedef CGAL::Filtered_bbox_curved_kernel<LazyCurvedK> BBLazyCurvedK;
|
||||
|
||||
typedef BBLazyCurvedK::Circular_arc_2 Circular_arc_7;
|
||||
typedef BBLazyCurvedK::Line_arc_2 Line_arc_7;
|
||||
typedef boost::variant<Circular_arc_7,Line_arc_7 > BBLazyVarArc;
|
||||
typedef std::vector< BBLazyVarArc> BBLazyVarContainer;
|
||||
typedef CGAL::Variant_traits<BBLazyCurvedK,Line_arc_7,Circular_arc_7> BBLazyVariantTraits;
|
||||
|
||||
bench.kernel("LLazyK BBox VarTraits") ;
|
||||
|
||||
bench.Compute<BBLazyCurvedK, BBLazyVariantTraits, BBLazyVarContainer>(Dxffilename[i]);
|
||||
//bench.Compute_no_dxf<BBLazyCurvedK, BBLazyVariantTraits, BBLazyVarContainer>();
|
||||
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_filtered_Filtered_hexagone_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Filtered_bbox_curved_kernel<CircularKernelHexagon> BBCircKHexagon ;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<BBCircKHexagon> BBCircKHexagonCATraits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<BBCircKHexagon> Traits0_7;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_7> BBCircKHexagonCATraits;
|
||||
#endif
|
||||
typedef BBCircKHexagon::Circular_arc_2 BBCircKHexagonArc;
|
||||
typedef std::vector<BBCircKHexagon> BBCircKHexagonArcCont;
|
||||
bench.kernel("BBox Circular kernel filtered Hexagon CircArcTraits");
|
||||
|
||||
bench.Compute_no_dxf<BBCircKHexagon,BBCircKHexagonCATraits, BBCircKHexagonArcCont>();
|
||||
|
||||
typedef BBCircularKernelHexagon::Circular_arc_2 Circular_arc_8;
|
||||
typedef BBCircularKernelHexagon::Line_arc_2 Line_arc_8;
|
||||
typedef boost::variant<Circular_arc_8,Line_arc_8 > BBCircularKernelHexagonVarArc;
|
||||
typedef std::vector<BBCircularKernelHexagonVarArc> BBCircularKernelHexagonVarContainer;
|
||||
typedef CGAL::Variant_traits<BBCircularKernelHexagon,Line_arc_8,Circular_arc_8> BBCircularKernelHexagonVariantTraits;
|
||||
|
||||
bench.kernel("BBox Circular kernel filtered Hexagon VarTraits") ;
|
||||
|
||||
//bench.Compute<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<BBCircularKernelHexagon,BBCircularKernelHexagonVariantTraits,BBCircularKernelHexagonVarContainer>();*/
|
||||
/*--------------------------------------------------------------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------------------------------------------------------------*/
|
||||
dxffilenames.erase(dxffilenames.begin(),dxffilenames.end());
|
||||
if (i<5){
|
||||
for(int n = 3*(i+1)-3; n < 3*(i+1); n++){
|
||||
dxffilenames.push_back(Dxffilename[n]);
|
||||
};
|
||||
bench.newDxfArray(dxffilenames);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
#include <CGAL/Random.h>
|
||||
#include <CGAL/IO/Dxf_variant_reader.h>
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_dfx(ArcContainer& arcs,char* Dfxfile){
|
||||
|
||||
typedef typename CK::Circular_arc_2 Circular_arc_2;
|
||||
typedef typename CK::Line_arc_2 Line_arc_2;
|
||||
std::ifstream fin;
|
||||
|
||||
fin.open (Dfxfile);
|
||||
CGAL::variant_load<CK, Circular_arc_2, Line_arc_2>(fin, std::back_inserter(arcs));
|
||||
fin.close();
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_grid(ArcContainer& ac){
|
||||
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
int x = 5;
|
||||
int y = 5;
|
||||
int r = 5;
|
||||
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j <20; j++){
|
||||
ac.push_back(typename CK::Circular_arc_2 ( Circle_2( Point_2(x + j*r, y + i*r), r*r)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_grid2(ArcContainer& ac){
|
||||
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
int x = 10;
|
||||
int y = 10;
|
||||
int r = 10;
|
||||
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j < 20; j++){
|
||||
ac.push_back(typename CK::Circular_arc_2 ( Circle_2( Point_2(x + j*r, y + i*r), r*r) ));
|
||||
}
|
||||
}
|
||||
|
||||
x += r;
|
||||
y += r;
|
||||
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j < 20; j++){
|
||||
ac.push_back(typename CK::Circular_arc_2 ( Circle_2( Point_2(x + j*r, y + i*r), r*r)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_random(ArcContainter& arcs)
|
||||
{
|
||||
std::ofstream fout("random.inp");
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
CGAL::Random generatorOfgenerator;
|
||||
int random_seed = generatorOfgenerator.get_int(0, 123456);
|
||||
std::cout << "random_seed = " << random_seed << std::endl;
|
||||
CGAL::Random theRandom(random_seed);
|
||||
|
||||
double random_max = 10;
|
||||
double random_min = -10;
|
||||
|
||||
for(int i = 0; i < 100 ; i++){
|
||||
double x = theRandom.get_double(random_min,random_max);
|
||||
double y = theRandom.get_double(random_min,random_max);
|
||||
double r = theRandom.get_double(0.1,random_max);
|
||||
fout << x << " " << y << " " << r << " " ;
|
||||
arcs.push_back(typename CK::Circular_arc_2 ( Circle_2( Point_2(x,y), r*r) ));
|
||||
}
|
||||
|
||||
fout.close();
|
||||
std::cout << arcs.size() << std::endl;
|
||||
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_file(ArcContainter& arcs){
|
||||
double x,y, r;
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
std::ifstream fin("random.inp");
|
||||
for(int i = 0; i < 100 ; i++){
|
||||
fin >> x >> y >> r ;
|
||||
arcs.push_back(typename CK::Circular_arc_2 ( Circle_2( Point_2(x,y), r*r)));
|
||||
}
|
||||
|
||||
fin.close();
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_rotation(ArcContainter& ac){
|
||||
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
int x = 10;
|
||||
int y = 10;
|
||||
int r = 10;
|
||||
int R =0;
|
||||
|
||||
for(int k = 0; k < 5; k++){
|
||||
for(int i = 0; i < 5; i++){
|
||||
for(int j = 0; j < 5; j++){
|
||||
R = (r+k)*(r+k);
|
||||
ac.push_back(typename CK::Circular_arc_2 ( Circle_2( Point_2(x + i*r, y + j*r),R) ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
The usage is:
|
||||
./example ${alpha} ${beta}
|
||||
|
||||
where alpha:
|
||||
1: means to bench the BBox(CK) with Vartraits
|
||||
2: means to bench the Lazy(CK) with Vartraits
|
||||
3: means to bench the CK with Vartraits
|
||||
4: means to bench the Bbox(Lazy(CK)) with Vartraits
|
||||
5: means to bench the BBox(CK) with Circulartraits
|
||||
6: means to bench the Lazy(CK) with Circulartraits
|
||||
7: means to bench the CK(CK) with Circulartraits
|
||||
8: means to bench the Bbox(Lazy(CK)) Circulartraits
|
||||
(le 0 est interne)
|
||||
|
||||
beta:
|
||||
0: Compute the arrangement of DXF/51.dxf with the kernel ${alpha}
|
||||
1: Compute the arrangement of DXF/cad_l1.dxf with the kernel ${alpha}
|
||||
2: Compute the arrangement of DXF/cad_l2.dxf
|
||||
3: Compute the arrangement of DXF/che_mod1.dxf
|
||||
4: Compute the arrangement of DXF/CIOnZDraw.dxf
|
||||
5: Compute the arrangement of DXF/mask1.dxf
|
||||
6: Compute the arrangement of DXF/elekonta.dxf
|
||||
7: Compute the arrangement of DXF/netlist_signal_1.dxf
|
||||
8: Compute the arrangement of DXF/painttrack.dxf
|
||||
9: Compute the arrangement of ${Scenario1}
|
||||
a: Compute the arrangement of ${Scenario2}
|
||||
b: Compute the arrangement of ${Scenario3}
|
||||
c: Compute the arrangement of ${Scenario4}
|
||||
d: Compute the arrangement of ${Scenario5}
|
||||
|
||||
${Scenario1}:
|
||||
- Circles with center in [0,10]x[0,10],
|
||||
- 0.5 of distance between each circle
|
||||
- unitary radius
|
||||
|
||||
${Scenario2}:
|
||||
- Circles with center in [0,0.2]x[0,0.2],
|
||||
- 0.01 of distance between each circle
|
||||
- unitary radius
|
||||
|
||||
${Scenario3}:
|
||||
Only one circle
|
||||
|
||||
${Scenario4}
|
||||
100 Random Circles with
|
||||
- Center in [0,1]x[0,1]
|
||||
- Radius in [0,1]
|
||||
|
||||
${Scenario5}
|
||||
Lattice, like:
|
||||
o o o o o o o o o o o o o o o o
|
||||
o o o o o o o o o o o o o o o
|
||||
o o o o o o o o o o o o o o o o
|
||||
o o o o o o o o o o o o o o o
|
||||
o o o o o o o o o o o o o o o o
|
||||
o o o o o o o o o o o o o o o
|
||||
with no intersection.
|
||||
|
||||
The output:
|
||||
|
||||
In std::cout :
|
||||
The number of elements to compute the arrangement
|
||||
The number of circles and polygons (wich the side may be circular arcs)
|
||||
The time needed to compute it,
|
||||
The number of Vertices, Edges and Faces of the arrangement
|
||||
|
||||
In std::cerr :
|
||||
Only the time needed to compute it. (it is useful to benchmark a lot of cases and redirect it on a .txt)
|
||||
|
||||
ATTENTION:
|
||||
1) dont use ./example a b
|
||||
with 5 <= a <= 8 and 0 <= b <= 8, we cannot use the Circulartraits to handle the files
|
||||
2) The files have to be put on a folder name DXF where the program is located
|
||||
|
||||
Compile with -DCGAL_INTERSECTION_MAP_FOR_SUPPORTING_CIRCLES if you want to benchmark with
|
||||
the same kernel, but with an additional map for supporting circles.
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
#include <CGAL/Random.h>
|
||||
#include <CGAL/IO/Dxf_variant_reader.h>
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_dfx(ArcContainer& arcs,char* Dfxfile){
|
||||
std::ifstream fin;
|
||||
fin.open (Dfxfile);
|
||||
typedef typename CK::Circular_arc_2 Circular_arc_2;
|
||||
typedef typename CK::Line_arc_2 Line_arc_2;
|
||||
CGAL::variant_load<CK, Circular_arc_2, Line_arc_2>(fin, std::back_inserter(arcs));
|
||||
fin.close();
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_grid(ArcContainer& ac){
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
int x = 5;
|
||||
int y = 5;
|
||||
int r = 5;
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j <20; j++){
|
||||
ac.push_back( Circle_2( Point_2(x + j*r, y + i*r), r*r));
|
||||
}
|
||||
}
|
||||
// CGAL::Random theRandom(77147);
|
||||
// double random_max = 15;
|
||||
// double random_min = -16;
|
||||
// for(int i = 0; i < 100 ; i++){
|
||||
// double x1, y1, x2, y2 = 0.0;
|
||||
// do{
|
||||
// x1 = theRandom.get_double(random_min,random_max);
|
||||
// y1 = theRandom.get_double(random_min,random_max);
|
||||
// x2 = theRandom.get_double(random_min,random_max);
|
||||
// y2 = theRandom.get_double(random_min,random_max);
|
||||
// }while ((x1 == x2) && (y1 == y2));
|
||||
// ac.push_back( Line_arc_2( Point_2(x1,y1), Point_2(x2, y2)));
|
||||
// }
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_grid2(ArcContainer& ac)
|
||||
{
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
int x = 10;
|
||||
int y = 10;
|
||||
int r = 10;
|
||||
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j < 20; j++){
|
||||
ac.push_back(Circle_2( Point_2(x + j*r, y + i*r), r*r));
|
||||
}
|
||||
}
|
||||
|
||||
x += r;
|
||||
y += r;
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j < 20; j++){
|
||||
ac.push_back( Circle_2( Point_2(x + j*r, y + i*r), r*r));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_random(ArcContainter& arcs)
|
||||
{
|
||||
std::ofstream fout("random.inp");
|
||||
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
|
||||
CGAL::Random generatorOfgenerator;
|
||||
int random_seed = generatorOfgenerator.get_int(0, 123456);
|
||||
std::cout << "random_seed = " << random_seed << std::endl;
|
||||
|
||||
CGAL::Random theRandom(random_seed);
|
||||
// CGAL::Random theRandom(77147);
|
||||
double random_max = 10;
|
||||
double random_min = -10;
|
||||
|
||||
for(int i = 0; i < 100 ; i++){
|
||||
double x = theRandom.get_double(random_min,random_max);
|
||||
double y = theRandom.get_double(random_min,random_max);
|
||||
double r = theRandom.get_double(0.1,random_max);
|
||||
fout << x << " " << y << " " << r << " " ;
|
||||
arcs.push_back( Circle_2( Point_2(x,y), r*r));
|
||||
}
|
||||
fout.close();
|
||||
// for(int i = 0; i < 20 ; i++){
|
||||
// double x1, y1, x2, y2 = 0.0;
|
||||
// do{
|
||||
// x1 = theRandom.get_double(random_min,random_max);
|
||||
// y1 = theRandom.get_double(random_min,random_max);
|
||||
// x2 = theRandom.get_double(random_min,random_max);
|
||||
// y2 = theRandom.get_double(random_min,random_max);
|
||||
// }while ((x1 == x2) && (y1 == y2));
|
||||
// arcs.push_back( Line_arc_2( Point_2(x1,y1), Point_2(x2, y2)));
|
||||
// }
|
||||
//
|
||||
std::cout << arcs.size() << std::endl;
|
||||
|
||||
}
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_file(ArcContainter& arcs)
|
||||
{ double x,y, r;
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
std::ifstream fin("random.inp");
|
||||
for(int i = 0; i < 100 ; i++){
|
||||
// fin >> x >> y >> r ;
|
||||
fin >> x >> y >> r ;
|
||||
arcs.push_back( Circle_2( Point_2(x,y), r*r));
|
||||
}
|
||||
fin.close();
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_rotation(ArcContainter& ac)
|
||||
{
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
int x = 10;
|
||||
int y = 10;
|
||||
int r = 10;
|
||||
int R =0;
|
||||
for(int k = 0; k < 5; k++){
|
||||
for(int i = 0; i < 5; i++){
|
||||
for(int j = 0; j < 5; j++){
|
||||
R = (r+k)*(r+k);
|
||||
ac.push_back( Circle_2( Point_2(x + i*r, y + j*r),R));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
template <class T>
|
||||
bool from_string(T &t,
|
||||
const std::string &s,
|
||||
std::ios_base & (*f)(std::ios_base&))
|
||||
{
|
||||
std::istringstream iss(s);
|
||||
return !(iss>>f>>t).fail();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
std::string to_string(T t, std::ios_base & (*f)(std::ios_base&)=std::dec)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << f << t;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,379 @@
|
|||
#ifndef ECG_BENCH_H
|
||||
#define ECG_BENCH_H
|
||||
|
||||
#include <CGAL/Interval_nt.h>
|
||||
#include <CGAL/Memory_sizer.h>
|
||||
|
||||
#include <string>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "Input_data.h"
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
class Bench
|
||||
{
|
||||
int numof_f_fails;
|
||||
std::ofstream htmlout,texout;
|
||||
struct rusage before,after;
|
||||
struct timeval utime,stime;
|
||||
bool firsttime;
|
||||
char *description;
|
||||
int vert[4],hedg[4];
|
||||
int i;
|
||||
CGAL::Memory_sizer mem_sizer;
|
||||
char* Dxffile;
|
||||
bool ONLY_DXF;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Bench( char *fhtml="benchmarks.html", char* ftex="benchmarks.tex",char* Dxffilename="",const bool only_dxf=false):
|
||||
htmlout(fhtml,std::ios::app),
|
||||
texout(ftex,std::ios::app)
|
||||
{ i=0;
|
||||
numof_f_fails= 0;
|
||||
Dxffile=Dxffilename;
|
||||
ONLY_DXF = only_dxf;
|
||||
|
||||
description = "Arrangement ";
|
||||
|
||||
std::cout << ".:Starting Bench Suite:." << std::endl;
|
||||
std::cout << "bencmarking : " << description << std::endl;
|
||||
|
||||
htmlout<<"Dxf file is : "<< Dxffile << std::endl;
|
||||
htmlout<<"<table border = \"3\">"<<std::endl;
|
||||
|
||||
if(!ONLY_DXF){
|
||||
htmlout<< "<tr bgcolor=\"gray\" ><td>Kernel</td><td>grid I(400 Circle_2)</td><td>grid II(800 Circle_2)</td><td>random double (100 Circle)</td><td>Dxf input. Dxf file is : "<< Dxffile <<"</td><td> rotation (125 Circle_2) </td></tr>"
|
||||
<<std::endl;
|
||||
|
||||
texout << "\\documentclass[12pt]{article}"<<std::endl
|
||||
<<"\\usepackage{amsmath}"<<std::endl
|
||||
<<"\\begin{document}"<<std::endl
|
||||
<<"\\begin{tabular}{|c|c|c|c|c|c|} \\hline $Kernel$ & grid I&grid II &random double & Dxf input. Dxf file is : "<< Dxffile <<" & rotation \\\\ \\hline"<<std::endl;
|
||||
}
|
||||
else
|
||||
{htmlout<< "<tr bgcolor=\"gray\" ><td>Kernel</td><td>Dxf input. Dxf file is : "<< Dxffile <<"</td></tr>"
|
||||
<<std::endl;
|
||||
|
||||
texout << "\\documentclass[12pt]{article}"<<std::endl
|
||||
<<"\\usepackage{amsmath}"<<std::endl
|
||||
<<"\\begin{document}"<<std::endl
|
||||
<<"\\begin{tabular}{|c|c|c|c|c|c|} \\hline $Kernel$ & & Dxf input. Dxf file is : "<< Dxffile <<" \\\\ \\hline"<<std::endl;
|
||||
}
|
||||
firsttime = true;
|
||||
}
|
||||
|
||||
~Bench()
|
||||
{
|
||||
htmlout <<"</table>"<<std::endl;
|
||||
texout << "\\end{tabular}" << std::endl
|
||||
<<"\\end{document}"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
void open_cell()
|
||||
{
|
||||
htmlout <<"<td>";
|
||||
texout<<" ";
|
||||
}
|
||||
void close_cell()
|
||||
{
|
||||
htmlout <<"</td>";
|
||||
texout <<" ";
|
||||
}
|
||||
void open_row()
|
||||
{
|
||||
htmlout <<"<tr>";
|
||||
texout <<"";
|
||||
}
|
||||
void close_row()
|
||||
{
|
||||
htmlout <<"</tr>"<< std::endl;
|
||||
texout <<"\\\\ \\hline"<< std::endl;
|
||||
}
|
||||
|
||||
void kernel(char* kernel)
|
||||
{ this->open_row();
|
||||
this->open_cell();
|
||||
htmlout << kernel;
|
||||
texout << kernel ;
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
void empty_cell()
|
||||
{
|
||||
this->open_cell();
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td>" << std::endl
|
||||
<< "<tr><td>"
|
||||
<<"-"<<"</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td></tr>"
|
||||
<< "</table></td>" ;
|
||||
texout<<"& -";
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
void infotable(){
|
||||
|
||||
texout<< "\\hline\\hline & grid I&grid II &random double & Dxf input. Dxf file is : "<< Dxffile <<" & rotation \\\\ \\hline" << std::endl
|
||||
<< "vertices" ;
|
||||
for (int k=1; k < 6 ;k++)
|
||||
{
|
||||
texout << " & "<< vert[k];
|
||||
}
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
texout<<"halfedges";
|
||||
for (int l=1; l < 6 ;l++)
|
||||
{
|
||||
texout <<" & "<< hedg[l];
|
||||
}
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
|
||||
void newDxfFilename(char* Dxffilename="")
|
||||
{Dxffile=Dxffilename;
|
||||
if(!ONLY_DXF){
|
||||
htmlout<< "<tr bgcolor=\"gray\" ><td>Kernel</td><td>grid I</td><td>grid II</td><td>random double</td><td>Dxf input. Dxf file is : "<< Dxffile <<"</td><td> rotation </td></tr>"
|
||||
<<std::endl;
|
||||
}
|
||||
else{
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>Dxf input. Dxf file is : "<< Dxffile <<"</td> </tr>"
|
||||
<<std::endl;
|
||||
|
||||
texout <<"\\begin{tabular}{|c|c|c|c|c|c|} \\hline $Kernel$ & Dxf input. Dxf file is : "<< Dxffile <<" \\\\ \\hline"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void start(void) {
|
||||
getrusage(RUSAGE_SELF,&before);
|
||||
|
||||
}
|
||||
void stop(void) {getrusage(RUSAGE_SELF,&after);}
|
||||
|
||||
void summarize(int vertices,int hedges)
|
||||
{
|
||||
int temp;
|
||||
temp=CGAL::Interval_nt<>::number_of_failures();
|
||||
numof_f_fails = temp - numof_f_fails;
|
||||
|
||||
std::cout << " numbers_of_filter_fails : " << numof_f_fails << std::endl;
|
||||
timersub(&(after.ru_utime),&(before.ru_utime),&utime);
|
||||
timersub(&(after.ru_stime),&(before.ru_stime),&stime);
|
||||
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td>" << std::endl
|
||||
<< "<tr><td>"
|
||||
<<utime.tv_sec<<"."<<utime.tv_usec <<"</td><td>"
|
||||
<< numof_f_fails << "</td><td>"
|
||||
<< vertices << "</td><td>"
|
||||
<< hedges<< "</td></tr>"
|
||||
<< "</table></td>";
|
||||
|
||||
texout << " & " <<utime.tv_sec<<"."<<utime.tv_usec;
|
||||
|
||||
//It's necessery to make output of number of filter fails here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
std::cout << " vertices : " << vertices << std::endl
|
||||
<< " halfedges : " << hedges << std::endl
|
||||
<< " Time (sec): " << utime.tv_sec << std::endl
|
||||
<< " (usec): " << std::setw(6) << std::setfill('0')
|
||||
<< utime.tv_usec << std::endl;
|
||||
numof_f_fails = CGAL::Interval_nt<>::number_of_failures();
|
||||
}
|
||||
|
||||
void fail(void)
|
||||
{
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td>" << std::endl
|
||||
<< "<tr><td>"
|
||||
<<"fail"<<"</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td></tr>"
|
||||
<< "</table></td>" ;
|
||||
texout << "&" <<"fail";
|
||||
std::cout << " :: Abort:: "<< std::endl;
|
||||
}
|
||||
|
||||
template <class Traits,class ArcContainer>
|
||||
void arrangement(const ArcContainer & ac){
|
||||
bool fail=false;
|
||||
typedef typename CGAL::Arrangement_2<Traits> Pmwx;
|
||||
typedef typename CGAL::Arr_naive_point_location<Pmwx> Point_location;
|
||||
std::cout << "memory size before construction" << mem_sizer.virtual_size() << std::endl;
|
||||
std::cout << "memory resident size before insert()" << mem_sizer.resident_size () << std::endl;
|
||||
Pmwx _pm;
|
||||
Point_location _pl(_pm);
|
||||
|
||||
std::cout << "Construction complited"<<std::endl;
|
||||
try{
|
||||
this->start();
|
||||
|
||||
insert(_pm,ac.begin(),ac.end(),boost::false_type());
|
||||
|
||||
this->stop();
|
||||
}
|
||||
catch (...) {
|
||||
this->fail();
|
||||
fail=true;
|
||||
}
|
||||
vert[i]=(int)_pm.number_of_vertices();
|
||||
hedg[i]=(int)_pm.number_of_halfedges();
|
||||
|
||||
|
||||
//_pl.~Point_location();
|
||||
// _pm.~Pmwx();
|
||||
if (!fail){this->summarize(_pm.number_of_vertices(),_pm.number_of_halfedges());}
|
||||
|
||||
|
||||
std::cout << "memory size after insert()" << mem_sizer.virtual_size () << std::endl;
|
||||
std::cout << "memory resident size after insert()" << mem_sizer.resident_size () << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void grid(){
|
||||
|
||||
i=1;
|
||||
|
||||
ArcContainer ac;
|
||||
|
||||
_bench_input_grid<CK,ArcContainer>(ac);
|
||||
|
||||
this->open_cell();
|
||||
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void grid2(){
|
||||
i=2;
|
||||
|
||||
ArcContainer ac;
|
||||
|
||||
_bench_input_grid2<CK,ArcContainer>(ac);
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
this->close_cell();
|
||||
}
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void random()
|
||||
{
|
||||
i=3;
|
||||
|
||||
ArcContainer ac;
|
||||
if (firsttime)
|
||||
{
|
||||
_bench_input_random<CK,ArcContainer>(ac);
|
||||
std::cout << "Input from random generator!"<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
_bench_input_file<CK,ArcContainer>(ac);
|
||||
std::cout << "Input from file!"<<std::endl;
|
||||
}
|
||||
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
this->close_cell();
|
||||
firsttime = false;
|
||||
}
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void dfx(char* Dfxfile){
|
||||
i=4;
|
||||
|
||||
ArcContainer arc;
|
||||
_bench_input_dfx<CK,ArcContainer>(arc,Dfxfile);
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(arc);
|
||||
|
||||
this->close_cell();
|
||||
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void rotation(){
|
||||
i=5;
|
||||
|
||||
ArcContainer arc;
|
||||
try{
|
||||
|
||||
_bench_input_rotation<CK,ArcContainer>(arc);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "failed before input";
|
||||
}
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(arc);
|
||||
|
||||
this->close_cell();
|
||||
|
||||
this->close_row();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute(char* dxffile)
|
||||
{
|
||||
this->grid<CK,Traits,ArcContainer>();
|
||||
|
||||
this->grid2<CK,Traits,ArcContainer>();
|
||||
|
||||
this->random<CK,Traits,ArcContainer>();
|
||||
// this->empty_cell();
|
||||
// this->empty_cell();
|
||||
// this->empty_cell();
|
||||
|
||||
this->dfx<CK,Traits,ArcContainer>(dxffile);
|
||||
|
||||
this->rotation<CK,Traits,ArcContainer>();
|
||||
//this->empty_cell();
|
||||
//this->close_row();
|
||||
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute_no_dxf()
|
||||
{
|
||||
this->grid<CK,Traits,ArcContainer>();
|
||||
|
||||
|
||||
this->grid2<CK,Traits,ArcContainer>();
|
||||
|
||||
this->random<CK,Traits,ArcContainer>();
|
||||
this->empty_cell();
|
||||
// this->empty_cell();
|
||||
// this->empty_cell();
|
||||
// this->empty_cell();
|
||||
// this->empty_cell();
|
||||
// this->close_row();
|
||||
this->rotation<CK,Traits,ArcContainer>();
|
||||
}
|
||||
|
||||
void empty_row()
|
||||
{ this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->close_row();
|
||||
|
||||
}
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute_dxf(char* dxffile)
|
||||
{
|
||||
this->dfx<CK,Traits,ArcContainer>(dxffile);
|
||||
this->close_row();
|
||||
}
|
||||
};
|
||||
|
||||
#endif //#define ECG_BENCH_H
|
||||
|
||||
|
|
@ -0,0 +1,463 @@
|
|||
#define CGAL_CAST_INT
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include<CGAL/Handle_for.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
#include <CGAL/MP_Float.h>
|
||||
|
||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
||||
|
||||
#include <CGAL/intersections.h>
|
||||
|
||||
#include <CGAL/Circular_kernel_2.h>
|
||||
#include <CGAL/Circular_arc_traits.h>
|
||||
#include <CGAL/Circular_arc_traits_tracer.h>
|
||||
|
||||
#include <CGAL/Lazy_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Filtered_hexagon_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Filtered_bbox_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_naive_point_location.h>
|
||||
#include <CGAL/Variant_traits.h>
|
||||
|
||||
|
||||
#include <CGAL/Random.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "benchmark.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char* Dxffilename[15]/*={"myFirst.dxf","minimask0.dxf","minimask1.dxf","mask0.dxf","smallpainttrack.dxf","mask0_25.dxf","mask0_5.dxf","cad_l2.dxf","cad_l1.dxf","CIOnZDraw.dxf","che_mod1.dxf","elekonta.dxf","painttrack.dxf","netlist_signal_1.dxf","51.dxf"}*/;
|
||||
char* Htmlfilename;
|
||||
char* Texfilename;
|
||||
char exten[4];
|
||||
int i;
|
||||
i=0;
|
||||
|
||||
|
||||
if (argv[1] != NULL)
|
||||
{
|
||||
int len =strlen(argv[1]);
|
||||
for (int j=0; j < 3 ; j++)
|
||||
{
|
||||
exten[j]=argv[1][len - 3 + j];
|
||||
}
|
||||
if (strncmp(exten,"dxf",3) !=0)
|
||||
{
|
||||
std::cout<< "File is not correct (*.dxf is needed)." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
Dxffilename[i] = argv[1];
|
||||
std::cout<< "File "<< Dxffilename[i] << " is correct."<<std::endl;
|
||||
}
|
||||
if (argc >2 and argv[2] != NULL)
|
||||
{
|
||||
int len =strlen(argv[2]);
|
||||
for (int j=0; j < 4 ; j++)
|
||||
{
|
||||
exten[j]=argv[2][len - 4 + j];
|
||||
}
|
||||
if (strncmp(exten,"html",4) !=0)
|
||||
{
|
||||
std::cout<< "File "<< argv[2] << " is not correct (*.html is needed)." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
std::cout<< "File "<< argv[2] << " is correct." <<std::endl;
|
||||
}
|
||||
if (argv[3] != NULL)
|
||||
{
|
||||
int len =strlen(argv[3]);
|
||||
for (int j=0; j < 3 ; j++)
|
||||
{
|
||||
exten[j]=argv[3][len - 3 + j];
|
||||
}
|
||||
if (strncmp(exten,"tex",3) !=0)
|
||||
{
|
||||
std::cout<< "File "<< argv[3] << " is not correct (*.tex is needed)."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
std::cout<< "File "<< argv[3] << " is correct." <<std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Htmlfilename="benchmarks.html";
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.html file is :" << Htmlfilename<< std::endl;
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Dxffilename[i]="myFirst.dxf";
|
||||
//Dxffilename[]={"myFirst.dxf","minimask0.dxf","minimask1.dxf","mask0.dxf"};
|
||||
Htmlfilename="benchmarks.html";
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.dxf file is :" << Dxffilename[i]<< std::endl;
|
||||
std::cout<< "Default *.html file is :" << Htmlfilename<< std::endl;
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
|
||||
// std::ifstream fin;
|
||||
// fin.open (Dxffilename[i]);
|
||||
// if (!fin.is_open())
|
||||
// {
|
||||
// cout<<"file "<< Dxffilename[i] << " is not found"<<std::endl;
|
||||
// fin.close();
|
||||
// return 0;
|
||||
//
|
||||
// }
|
||||
// fin.close();
|
||||
|
||||
|
||||
Bench bench(Htmlfilename,Texfilename,Dxffilename[i]);
|
||||
|
||||
for(i=0;i<15;i++){
|
||||
|
||||
std::ifstream fin;
|
||||
fin.open (Dxffilename[i]);
|
||||
if (!fin.is_open())
|
||||
{
|
||||
std::cout<<"file "<< Dxffilename[i] << " is not found"<<std::endl;
|
||||
fin.close();
|
||||
return 0;
|
||||
|
||||
}
|
||||
fin.close();
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Place for tests!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
// typedef CGAL::Lazy_exact_nt<CGAL::Quotient<CGAL::MP_Float> > NT4;
|
||||
// typedef CGAL::Cartesian<NT4> Linear_k4;
|
||||
// typedef CGAL::Algebraic_kernel_2_2<NT4> Algebraic_k4;
|
||||
// typedef CGAL::Curved_kernel<Linear_k4,Algebraic_k4> CK4;
|
||||
//
|
||||
// #ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
// typedef CGAL::Circular_arc_traits<CK4> CircularK_CA_Traits;
|
||||
// #else
|
||||
// typedef CGAL::Circular_arc_traits<CK4> Traits0;
|
||||
// typedef CGAL::Circular_arc_traits_tracer<Traits0> CircularK_CA_Traits;
|
||||
// #endif
|
||||
//
|
||||
// typedef CK4::Circular_arc_2 CircularKArc;
|
||||
// typedef std::vector<CircularKArc> CircularKArcContainer;
|
||||
// bench.kernel("Circular kernel Circular arc traits");
|
||||
//
|
||||
// typedef CircularK_CA_Traits::Curve_2 Conic_arc_2;
|
||||
// typedef CGAL::Arrangement_2<CircularK_CA_Traits> Pmwx;
|
||||
// typedef CGAL::Arr_naive_point_location<Pmwx> Point_location;
|
||||
//
|
||||
// typedef CircularK_CA_Traits::X_monotone_curve_2 X_monotone_curve_2;
|
||||
// typedef CK4::Point_2 Point_2;
|
||||
// typedef CK4::Circle_2 Circle_2;
|
||||
// typedef CK4::Circular_arc_2 Circular_arc_2;
|
||||
//
|
||||
//
|
||||
// CGAL::Random generatorOfgenerator;
|
||||
// int random_seed = generatorOfgenerator.get_int(0, 123456);
|
||||
// std::cout << "random_seed = " << random_seed << std::endl;
|
||||
// CGAL::Random theRandom(random_seed);
|
||||
// int random_max = 128;
|
||||
// int random_min = -128;
|
||||
// CircularKArcContainer ac;
|
||||
// int x;
|
||||
// int y;
|
||||
// int r;
|
||||
// for(int i = 0; i < 20; i++){
|
||||
// x = theRandom.get_int(random_min,random_max);
|
||||
// y = theRandom.get_int(random_min,random_max);
|
||||
// r = theRandom.get_int(1,random_max);
|
||||
// ac.push_back( Circle_2( Point_2(x,y), r*r));
|
||||
// }
|
||||
//
|
||||
// // Pmwx _pm;
|
||||
// // Point_location _pl(_pm);
|
||||
// // try{
|
||||
// // bench.start();
|
||||
// // for (typename ArcContainer::const_iterator it=ac.begin();
|
||||
// // it != ac.end(); ++it) {
|
||||
// // //insert(_pm,_pl,*it);
|
||||
// // insert(_pm,*it,_pl);
|
||||
// // };
|
||||
// // bench.stop();
|
||||
// // bench.summarize(_pm.number_of_vertices(),_pm.number_of_halfedges());
|
||||
// // }
|
||||
// // catch (...) {
|
||||
// // bench.fail();
|
||||
// // }
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Circular_Kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT1;
|
||||
//typedef CGAL::Lazy_exact_nt<CGAL::Quotient<CGAL::MP_Float> > NT1;
|
||||
typedef CGAL::Cartesian<NT1> Linear_k1;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT1> Algebraic_k1;
|
||||
typedef CGAL::Circular_kernel_2<Linear_k1, Algebraic_k1> CircularKernel;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<CircularKernel> CircularK_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<CircularKernel> Traits0;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0> CircularK_CA_Traits;
|
||||
#endif
|
||||
|
||||
typedef CircularKernel::Circular_arc_2 CircularKArc;
|
||||
typedef std::vector<CircularKArc> CircularKArcContainer;
|
||||
bench.kernel("Circular kernel Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<CircularKernel,CircularK_CA_Traits,CircularKArcContainer>();
|
||||
|
||||
|
||||
typedef CircularKernel::Circular_arc_2 Circular_arc_2;
|
||||
typedef CircularKernel::Line_arc_2 Line_arc_2;
|
||||
typedef CGAL::Variant_traits<CircularKernel,Line_arc_2,Circular_arc_2> CircularK_Variant_Traits;
|
||||
|
||||
typedef boost::variant< Circular_arc_2, Line_arc_2 > CircularKVarArc;
|
||||
typedef std::vector<CircularKVarArc> CircularKVarArcContainer;
|
||||
|
||||
bench.kernel("Circular kernel Variant traits");
|
||||
|
||||
bench.Compute<CircularKernel,CircularK_Variant_Traits,CircularKVarArcContainer>(Dxffilename[i]);
|
||||
// bench.Compute_dxf<CircularKernel,CircularK_Variant_Traits,CircularKVarArcContainer>(Dxffilename[i]);
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Lazy_curved_Kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT2;
|
||||
// typedef CGAL::Lazy_exact_nt<CGAL::Quotient<CGAL::MP_Float> > NT2;
|
||||
typedef CGAL::Cartesian<NT2> Linear_k2;
|
||||
typedef CGAL::Algebraic_kernel_2_2<NT2> Algebraic_k2;
|
||||
typedef CGAL::Curved_kernel<Linear_k2, Algebraic_k2> CK2_;
|
||||
|
||||
//typedef CGAL::Interval_nt<> NT2;
|
||||
typedef CGAL::Interval_nt_advanced NT3;
|
||||
typedef CGAL::Cartesian<NT3> Linear_k3;
|
||||
typedef CGAL::Algebraic_kernel_2_2<NT3> Algebraic_k3;
|
||||
typedef CGAL::Curved_kernel<Linear_k3,Algebraic_k3> CK3_;
|
||||
|
||||
|
||||
typedef CGAL::Lazy_curved_kernel<CK2_,CK3_> LazyCurvedK;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<LazyCurvedK> LazyCurvedK_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<LazyCurved_k> Traits0_2;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_2> LazyCurved_kTraits;
|
||||
#endif
|
||||
|
||||
typedef LazyCurvedK::Circular_arc_2 LazyArc;
|
||||
typedef std::vector<LazyArc> LazyArcContainer;
|
||||
|
||||
bench.kernel("Lazy curved kernel Circular arc traits") ;
|
||||
|
||||
bench.Compute_no_dxf<LazyCurvedK,LazyCurvedK_CA_Traits,LazyArcContainer>();
|
||||
|
||||
|
||||
typedef LazyCurvedK::Circular_arc_2 Circular_arc_3;
|
||||
typedef LazyCurvedK::Line_arc_2 Line_arc_3;
|
||||
typedef boost::variant<Circular_arc_3,Line_arc_3 > LazyVarArc;
|
||||
typedef std::vector<LazyVarArc> LazyVarContainer;
|
||||
typedef CGAL::Variant_traits<LazyCurvedK,Line_arc_3,Circular_arc_3> LazyCurvedK_Variant_Traits;
|
||||
|
||||
bench.kernel("Lazy curved kernel Variant traits");
|
||||
|
||||
bench.Compute<LazyCurvedK,LazyCurvedK_Variant_Traits,LazyVarContainer>(Dxffilename[i]);
|
||||
//bench.Compute_dxf<LazyCurvedK,LazyCurvedK_Variant_Traits,LazyVarContainer>(Dxffilename[i]);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Filtered_hexagone_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
typedef CGAL::Filtered_hexagon_curved_kernel<CircularKernel> CircularKernelHexagon;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<CircularKernelHexagon> CircularKernHex_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<CircularKernelHexagon> Traits0_3;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_3> CircularKernHex_CA_Traits;
|
||||
#endif
|
||||
|
||||
typedef CircularKernelHexagon::Circular_arc_2 CircularKernHexArc;
|
||||
typedef std::vector<CircularKernHexArc> CircularKernHexArcContainer;
|
||||
bench.kernel("Circular kernel filtered hexagon Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<CircularKernelHexagon,CircularKernHex_CA_Traits,CircularKernHexArcContainer>();
|
||||
|
||||
|
||||
typedef CircularKernelHexagon::Circular_arc_2 Circular_arc_4;
|
||||
typedef CircularKernelHexagon::Line_arc_2 Line_arc_4;
|
||||
typedef boost::variant< Circular_arc_4, Line_arc_4 > CircularKernHexVarArc;
|
||||
typedef std::vector<CircularKernHexVarArc> CircularKernHexVarArcContainer;
|
||||
typedef CGAL::Variant_traits<CircularKernelHexagon,Circular_arc_4,Line_arc_4> CircularKernHex_Variant_Traits;
|
||||
|
||||
bench.kernel("Circular kernel filtered hexagon Variants traits");
|
||||
|
||||
//bench.Compute<CircularKernelHexagon,CircularKernHex_Variant_Traits,CircularKernHexVarArcContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<CircularKernelHexagon,CircularKernHex_Variant_Traits,CircularKernHexVarArcContainer>();
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Filtered_hexagone_Lazy_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Filtered_hexagon_curved_kernel<LazyCurvedK> LazyKernelHexagon;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<LazyKernelHexagon> LazyKernelHexagon_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<LazyKernelHexagon> Traits0_4;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_4> LazyKernelHexagon_CA_Traits;
|
||||
#endif
|
||||
typedef LazyKernelHexagon::Circular_arc_2 LazyKernelHexagonArc;
|
||||
typedef std::vector<LazyKernelHexagonArc> LazyKernelHexagonArcContainer;
|
||||
bench.kernel("Lazy curved kernel filtered hexagon Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<LazyKernelHexagon,LazyKernelHexagon_CA_Traits, LazyKernelHexagonArcContainer>();
|
||||
|
||||
typedef LazyKernelHexagon::Circular_arc_2 Circular_arc_5;
|
||||
typedef LazyKernelHexagon::Line_arc_2 Line_arc_5;
|
||||
typedef boost::variant<Circular_arc_5,Line_arc_5 > HxLazyVarArc;
|
||||
typedef std::vector<HxLazyVarArc> HxLazyVarContainer;
|
||||
typedef CGAL::Variant_traits<LazyKernelHexagon,Line_arc_5,Circular_arc_5> HxLazyVariantTraits;
|
||||
|
||||
bench.kernel("Lazy curved kernel filtered hexagon Variants traits") ;
|
||||
|
||||
//bench.Compute<LazyKernelHexagon,HxLazyVariantTraits,HxLazyVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<LazyKernelHexagon,HxLazyVariantTraits,HxLazyVarContainer>();
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_filtered_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Filtered_bbox_curved_kernel<CircularKernel> BBCircularKernel ;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<BBCircularKernel> BBCircularKernel_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<BBCircularKernel> Traits0_5;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_5> BBCircularKernel_CA_Traits;
|
||||
#endif
|
||||
typedef BBCircularKernel::Circular_arc_2 BBCircularKernelArc;
|
||||
typedef std::vector<BBCircularKernelArc> BBCircularKernelArcContainer;
|
||||
bench.kernel("Circular kernel filtered bbox Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<BBCircularKernel,BBCircularKernel_CA_Traits, BBCircularKernelArcContainer>();
|
||||
|
||||
typedef BBCircularKernel::Circular_arc_2 Circular_arc_6;
|
||||
typedef BBCircularKernel::Line_arc_2 Line_arc_6;
|
||||
typedef boost::variant<Circular_arc_6,Line_arc_6 > BBCircVarArc;
|
||||
typedef std::vector<BBCircVarArc> BBCircVarContainer;
|
||||
typedef CGAL::Variant_traits<BBCircularKernel,Line_arc_6,Circular_arc_6> BBCircVariantTraits;
|
||||
|
||||
bench.kernel("Circular kernel filtered bbox Variants traits") ;
|
||||
|
||||
// bench.Compute<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>();
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_hexagone_Lazy_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Filtered_bbox_curved_kernel<LazyCurvedK> BBLazyCurvedK;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<BBLazyCurvedK> BBLazyCurvedK_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<BBLazyCurvedK> Traits0_6;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_6> BBLazyCurvedK_CA_Traits;
|
||||
#endif
|
||||
typedef BBLazyCurvedK::Circular_arc_2 BBLazyCurvedKArc;
|
||||
typedef std::vector<BBLazyCurvedKArc> BBLazyCurvedKArcContainer;
|
||||
bench.kernel("Lazy curved kernel filtered bbox Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<BBLazyCurvedK,BBLazyCurvedK_CA_Traits,BBLazyCurvedKArcContainer>();
|
||||
|
||||
|
||||
typedef BBLazyCurvedK::Circular_arc_2 Circular_arc_7;
|
||||
typedef BBLazyCurvedK::Line_arc_2 Line_arc_7;
|
||||
typedef boost::variant<Circular_arc_7,Line_arc_7 > BBLazyVarArc;
|
||||
typedef std::vector< BBLazyVarArc> BBLazyVarContainer;
|
||||
typedef CGAL::Variant_traits<BBLazyCurvedK,Line_arc_7,Circular_arc_7> BBLazyVariantTraits;
|
||||
|
||||
bench.kernel("Lazy curved kernel filtered bbox Variants traits") ;
|
||||
|
||||
//bench.Compute<BBLazyCurvedK, BBLazyVariantTraits, BBLazyVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<BBLazyCurvedK, BBLazyVariantTraits, BBLazyVarContainer>();
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_filtered_Filtered_hexagone_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Filtered_bbox_curved_kernel<CircularKernelHexagon> BBCircKHexagon ;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<BBCircKHexagon> BBCircKHexagonCATraits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<BBCircKHexagon> Traits0_7;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_7> BBCircKHexagonCATraits;
|
||||
#endif
|
||||
typedef BBCircKHexagon::Circular_arc_2 BBCircKHexagonArc;
|
||||
typedef std::vector<BBCircKHexagon> BBCircKHexagonArcCont;
|
||||
bench.kernel("BBox Circular kernel filtered bbox Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<BBCircKHexagon,BBCircKHexagonCATraits, BBCircKHexagonArcCont>();
|
||||
|
||||
typedef BBCircularKernelHexagon::Circular_arc_2 Circular_arc_8;
|
||||
typedef BBCircularKernelHexagon::Line_arc_2 Line_arc_8;
|
||||
typedef boost::variant<Circular_arc_8,Line_arc_8 > BBCircularKernelHexagonVarArc;
|
||||
typedef std::vector<BBCircularKernelHexagonVarArc> BBCircularKernelHexagonVarContainer;
|
||||
typedef CGAL::Variant_traits<BBCircularKernelHexagon,Line_arc_8,Circular_arc_8> BBCircularKernelHexagonVariantTraits;
|
||||
|
||||
bench.kernel("BBox Circular kernel filtered bbox Variants traits") ;
|
||||
|
||||
//bench.Compute<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<BBCircularKernelHexagon,BBCircularKernelHexagonVariantTraits,BBCircularKernelHexagonVarContainer>();*/
|
||||
/*--------------------------------------------------------------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------------------------------------------------------------*/
|
||||
if (i+1<15)
|
||||
{
|
||||
if (strcmp(Dxffilename[i+1],""))
|
||||
{
|
||||
bench.newDxfFilename(Dxffilename[i+1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "that's all" << Dxffilename[i+1] << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bench.infotable();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
#include <CGAL/basic.h>
|
||||
|
||||
#include <CGAL/point_generators_2.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/MP_Float.h>
|
||||
|
||||
#include <CGAL/Algebraic_kernel_2_2.h>
|
||||
|
||||
#include <CGAL/intersections.h>
|
||||
|
||||
#include <CGAL/Circular_kernel.h>
|
||||
#include <CGAL/Circular_arc_traits.h>
|
||||
#include <CGAL/Circular_arc_traits_tracer.h>
|
||||
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_naive_point_location.h>
|
||||
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/CORE_algebraic_number_traits.h>
|
||||
#include <CGAL/Arr_conic_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
|
||||
|
||||
#include <CGAL/Random.h>
|
||||
#include "benchmark.h"
|
||||
|
||||
#include <fstream>
|
||||
#include "IntStr.h"
|
||||
int main(int argc, char* argv[])
|
||||
{ char* Dxffilename;
|
||||
char* Htmlfilename;
|
||||
char* Texfilename;
|
||||
char exten[4];
|
||||
|
||||
|
||||
|
||||
if (argv[1] != NULL)
|
||||
{
|
||||
int len =strlen(argv[1]);
|
||||
for (int j=0; j < 3 ; j++)
|
||||
{
|
||||
exten[j]=argv[1][len - 3 + j];
|
||||
}
|
||||
if (strncmp(exten,"dxf",3) !=0)
|
||||
{
|
||||
std::cout<< "File is not correct (*.dxf is needed)." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
Dxffilename = argv[1];
|
||||
std::cout<< "File "<< Dxffilename << " is correct."<<std::endl;
|
||||
}
|
||||
if (argc >2 and argv[2] != NULL)
|
||||
{
|
||||
int len =strlen(argv[2]);
|
||||
for (int j=0; j < 4 ; j++)
|
||||
{
|
||||
exten[j]=argv[2][len - 4 + j];
|
||||
}
|
||||
if (strncmp(exten,"html",4) !=0)
|
||||
{
|
||||
std::cout<< "File "<< argv[2] << " is not correct (*.html is needed)." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
std::cout<< "File "<< argv[2] << " is correct." <<std::endl;
|
||||
}
|
||||
if (argv[3] != NULL)
|
||||
{
|
||||
int len =strlen(argv[3]);
|
||||
for (int j=0; j < 3 ; j++)
|
||||
{
|
||||
exten[j]=argv[3][len - 3 + j];
|
||||
}
|
||||
if (strncmp(exten,"tex",3) !=0)
|
||||
{
|
||||
std::cout<< "File "<< argv[3] << " is not correct (*.tex is needed)."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
std::cout<< "File "<< argv[3] << " is correct." <<std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Htmlfilename="benchmarks.html";
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.html file is :" << Htmlfilename<< std::endl;
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Dxffilename="cad_l2.dxf";
|
||||
Htmlfilename="benchmarks.html";
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.dxf file is :" << Dxffilename<< std::endl;
|
||||
std::cout<< "Default *.html file is :" << Htmlfilename<< std::endl;
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
|
||||
std::ifstream fin;
|
||||
fin.open (Dxffilename);
|
||||
if (!fin.is_open())
|
||||
{
|
||||
cout<<"file "<< Dxffilename << " is not found"<<std::endl;
|
||||
fin.close();
|
||||
return 0;
|
||||
|
||||
}
|
||||
fin.close();
|
||||
Bench bench(Htmlfilename,Texfilename,Dxffilename);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Arrangement_traits!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
|
||||
typedef Nt_traits::Rational Rational;
|
||||
typedef Nt_traits::Algebraic Algebraic;
|
||||
typedef CGAL::Cartesian<Rational> Rat_kernel;
|
||||
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
|
||||
typedef CGAL::Arr_conic_traits_2<Rat_kernel,
|
||||
Alg_kernel,
|
||||
Nt_traits> Traits_2;
|
||||
|
||||
typedef Traits_2::Curve_2 Conic_arc_2;
|
||||
typedef Traits_2::Polygon_2 Polygon;
|
||||
bench.kernel("Arrangement_traits");
|
||||
|
||||
typedef std::vector<Conic_arc_2> ArcContainer;
|
||||
|
||||
bench.Compute_no_dxf<Rat_kernel,Traits_2,ArcContainer>();
|
||||
|
||||
|
||||
bench.infotable();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,388 @@
|
|||
#ifndef ECG_BENCH_H
|
||||
#define ECG_BENCH_H
|
||||
|
||||
#include <CGAL/Interval_nt.h>
|
||||
#include <CGAL/Memory_sizer.h>
|
||||
|
||||
#include <string>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "Input_data.h"
|
||||
#include <boost/variant.hpp>
|
||||
#include <exception>
|
||||
|
||||
|
||||
|
||||
class Bench
|
||||
{
|
||||
private:
|
||||
|
||||
int numof_f_fails;
|
||||
std::ofstream htmlout,texout;
|
||||
struct rusage before,after;
|
||||
struct timeval utime,stime;
|
||||
bool firsttime;
|
||||
int vert[4],hedg[4];
|
||||
int i;
|
||||
typedef std::size_t size_type;
|
||||
CGAL::Memory_sizer mem_sizer;
|
||||
std::string Dxffile;
|
||||
bool ONLY_DXF;
|
||||
double MemBefore,MemAfter;
|
||||
|
||||
public:
|
||||
|
||||
Bench(const bool only_dxf=false, const char *fhtml="benchmarks.html", const char* ftex="benchmarks.tex",const char* Dxffilename=""):
|
||||
htmlout(fhtml,std::ios::app),
|
||||
texout(ftex,std::ios::app){
|
||||
i=0;
|
||||
numof_f_fails= 0;
|
||||
Dxffile=Dxffilename;
|
||||
ONLY_DXF = only_dxf;
|
||||
|
||||
std::cout << ".:Starting Bench Suite:." << std::endl;
|
||||
|
||||
htmlout<<"Dxf file is : "<< Dxffile << std::endl;
|
||||
|
||||
htmlout<<"<table border = \"3\">"<<std::endl;
|
||||
|
||||
if(!ONLY_DXF){
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>grid I(400 Circle_2)</td><td>grid II(800 Circle_2)</td><td>random double (100 Circle)</td><td> rotation (125 Circle_2) </td></tr>"
|
||||
<<std::endl;
|
||||
|
||||
texout << "\\documentclass[12pt]{article}"<<std::endl
|
||||
<<"\\usepackage{amsmath}"<<std::endl
|
||||
<<"\\usepackage{rotating}"<<std::endl
|
||||
<<"\\begin{document}"<<std::endl
|
||||
<<"\\newsavebox{\\foo}"<<std::endl
|
||||
<<"\\savebox{\\foo}"<<std::endl
|
||||
<<"{\\parbox{5cm}{"<<std::endl
|
||||
<<"\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline Kernel &\\multicolumn{4}{c|}{ grid I}&\\multicolumn{4}{c|}{grid II }&\\multicolumn{4}{c|}{random double} &\\multicolumn{4}{c|}{ rotation }\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
|
||||
else {
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>Dxf input is: "<< Dxffile <<"</td></tr>"
|
||||
<<std::endl;
|
||||
|
||||
texout << "\\documentclass[12pt]{article}"<<std::endl
|
||||
<<"\\usepackage{amsmath}"<<std::endl
|
||||
<<"\\begin{document}"<<std::endl
|
||||
<<"\\begin{tabular}{|c|c|c|} \\hline $Kernel$ & & \\multicolumn{4}{c|}{Dxf input is:"<< Dxffile <<"} \\\\ \\hline"<<std::endl;
|
||||
}
|
||||
firsttime = true;
|
||||
|
||||
}
|
||||
|
||||
void infotable(){
|
||||
|
||||
if(!ONLY_DXF){
|
||||
texout<< "\\hline\\hline & \\multicolumn{4}{c|}{ grid I}&\\multicolumn{4}{c|}{grid II }&\\multicolumn{4}{c|}{random double} &\\multicolumn{4}{c|}{ rotation }\\\\ \\hline" << std::endl
|
||||
<< "vertices" ;
|
||||
for (int k=1; k < 6 ;k++) {
|
||||
texout << " &\\multicolumn{4}{c|}{"<< vert[k]<<"}";
|
||||
}
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
texout<<"halfedges";
|
||||
|
||||
for (int l=1; l < 6 ;l++){
|
||||
texout << " &\\multicolumn{4}{c|}{"<< hedg[l]<<"}";
|
||||
}
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
|
||||
else {
|
||||
texout<< "\\hline\\hline &\\multicolumn{4}{c|}{Dxf input is:"<< Dxffile <<"} \\\\ \\hline" << std::endl
|
||||
<< "vertices" ;
|
||||
texout << " &\\multicolumn{4}{c|}{"<< vert[4]<<"}";
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
texout<<"halfedges";
|
||||
texout <<" &\\multicolumn{4}{c|}{"<< hedg[4]<<"}";
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
~Bench(){
|
||||
std::cout<<"destructor"<<std::endl;
|
||||
htmlout <<"</table>"<<std::endl;
|
||||
infotable();
|
||||
|
||||
texout << "\\end{tabular}" << std::endl
|
||||
<<"}"<< std::endl
|
||||
<<"}"<< std::endl
|
||||
<<"\\begin{turn}{-90}\\usebox{\\foo}\\end{turn}"<< std::endl
|
||||
<<"\\end{document}"<<std::endl;
|
||||
}
|
||||
private:
|
||||
void open_cell(){
|
||||
htmlout <<"<td>";
|
||||
texout<<" ";
|
||||
}
|
||||
|
||||
void close_cell(){
|
||||
htmlout <<"</td>";
|
||||
texout <<" ";
|
||||
}
|
||||
void open_row(){
|
||||
htmlout <<"<tr>";
|
||||
texout <<"";
|
||||
}
|
||||
|
||||
void close_row(){
|
||||
htmlout <<"</tr>"<< std::endl;
|
||||
texout <<"\\\\ \\hline"<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
void empty_cell(){
|
||||
this->open_cell();
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td><td>MemBefore</td><td>MemAfter</td>" << std::endl
|
||||
<< "<tr><td>"
|
||||
<<"-"<<"</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td></tr>"
|
||||
<< "</table></td>" ;
|
||||
texout<<"& -& -&-& -";
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
void start(void){
|
||||
getrusage(RUSAGE_SELF,&before);
|
||||
}
|
||||
|
||||
void stop(void){
|
||||
getrusage(RUSAGE_SELF,&after);
|
||||
}
|
||||
|
||||
void summarize(int vertices,int hedges){
|
||||
int temp;
|
||||
// temp=CGAL::Interval_nt<>::number_of_failures();
|
||||
numof_f_fails = temp - numof_f_fails;
|
||||
std::cout << " numbers_of_filter_fails : " << numof_f_fails << std::endl;
|
||||
|
||||
timersub(&(after.ru_utime),&(before.ru_utime),&utime);
|
||||
timersub(&(after.ru_stime),&(before.ru_stime),&stime);
|
||||
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td><td>MemBefore</td><td>MemAfter</td>" << std::endl
|
||||
<< "<tr><td>"
|
||||
<<utime.tv_sec<<"."<< std::setw(6) << std::setfill('0')<< utime.tv_usec <<"</td><td>"
|
||||
<< numof_f_fails << "</td><td>"
|
||||
<< vertices << "</td><td>"
|
||||
<< hedges<<"</td><td>"
|
||||
<< MemBefore << "</td><td>"
|
||||
<< MemAfter<< "</td></tr>"
|
||||
<< "</table></td>";
|
||||
|
||||
texout << " & " <<utime.tv_sec<<"."<< std::setw(6) << std::setfill('0')
|
||||
<< utime.tv_usec;
|
||||
texout << "&"<< numof_f_fails;
|
||||
texout << "&"<< MemBefore;
|
||||
texout << "&"<<MemAfter;
|
||||
std::cout << " vertices : " << vertices << std::endl
|
||||
<< " halfedges : " << hedges << std::endl
|
||||
<< " Time (sec): " << utime.tv_sec << std::endl
|
||||
<< " (usec): " << std::setw(6) << std::setfill('0')
|
||||
<< utime.tv_usec << std::endl;
|
||||
// numof_f_fails = CGAL::Interval_nt<>::number_of_failures();
|
||||
}
|
||||
|
||||
void fail(void){
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td><td>MemBefore</td><td>MemAfter</td>"<<std::endl
|
||||
<< "<tr><td>"
|
||||
<<"fail"<<"</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td></tr>"
|
||||
<< "</table></td>" ;
|
||||
texout << "& fail & fail & fail & fail";
|
||||
std::cout << " :: Abort:: "<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
template <class Traits,class ArcContainer>
|
||||
void arrangement(const ArcContainer & ac){
|
||||
bool fail=false;
|
||||
typedef typename CGAL::Arrangement_2<Traits> Pmwx;
|
||||
typedef typename CGAL::Arr_naive_point_location<Pmwx> Point_location;
|
||||
|
||||
std::cout << "memory size before construction" << mem_sizer.virtual_size() << std::endl;
|
||||
std::cout << "memory resident size before insert()" << mem_sizer.resident_size () << std::endl;
|
||||
MemBefore = mem_sizer.virtual_size ()/1000000;
|
||||
Pmwx _pm;
|
||||
Point_location _pl(_pm);
|
||||
try{
|
||||
this->start();
|
||||
insert(_pm,ac.begin(),ac.end(),boost::false_type());
|
||||
this->stop();
|
||||
} catch (std::exception &e) {
|
||||
this->fail();
|
||||
std::cout << "Exception:" << std::endl << e.what() << std::endl;
|
||||
fail=true;
|
||||
} catch(...) {
|
||||
this->fail();
|
||||
fail=true;
|
||||
}
|
||||
vert[i]=(int)_pm.number_of_vertices();
|
||||
hedg[i]=(int)_pm.number_of_halfedges();
|
||||
|
||||
if (!fail){this->summarize(_pm.number_of_vertices(),_pm.number_of_halfedges());}
|
||||
|
||||
|
||||
MemAfter = mem_sizer.virtual_size ()/1000000;
|
||||
std::cout << "memory size after insert()" << mem_sizer.virtual_size () << std::endl;
|
||||
std::cout << "memory resident size after insert()" << mem_sizer.resident_size () << std::endl;
|
||||
_pm.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void grid(){
|
||||
i=1;
|
||||
ArcContainer ac;
|
||||
_bench_input_grid<CK,ArcContainer>(ac);
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void grid2(){
|
||||
i=2;
|
||||
ArcContainer ac;
|
||||
_bench_input_grid2<CK,ArcContainer>(ac);
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void random(){
|
||||
i=3;
|
||||
ArcContainer ac;
|
||||
if (firsttime){
|
||||
_bench_input_random<CK,ArcContainer>(ac);
|
||||
std::cout << "Input from random generator!"<<std::endl;
|
||||
}
|
||||
else{
|
||||
_bench_input_file<CK,ArcContainer>(ac);
|
||||
std::cout << "Input from file!"<<std::endl;
|
||||
}
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
this->close_cell();
|
||||
firsttime = false;
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void dfx(const char* Dfxfile){
|
||||
i=4;
|
||||
|
||||
ArcContainer arc;
|
||||
_bench_input_dfx<CK,ArcContainer>(arc,Dfxfile);
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(arc);
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void rotation(){
|
||||
i=5;
|
||||
bool fail=false;
|
||||
ArcContainer arc;
|
||||
try{
|
||||
_bench_input_rotation<CK,ArcContainer>(arc);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->fail();
|
||||
fail=true;
|
||||
std::cout << "failed before input";
|
||||
}
|
||||
|
||||
if (!fail){
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(arc);
|
||||
this->close_cell();
|
||||
this->close_row();
|
||||
}
|
||||
}
|
||||
public:
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute(const char* dxffile){
|
||||
if(!ONLY_DXF){
|
||||
this->grid<CK,Traits,ArcContainer>();
|
||||
this->grid2<CK,Traits,ArcContainer>();
|
||||
this->random<CK,Traits,ArcContainer>();
|
||||
this->dfx<CK,Traits,ArcContainer>(dxffile);
|
||||
this->rotation<CK,Traits,ArcContainer>();
|
||||
}
|
||||
else{
|
||||
this->dfx<CK,Traits,ArcContainer>(dxffile);
|
||||
this->close_row();
|
||||
}
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute_no_dxf(){
|
||||
if(!ONLY_DXF){
|
||||
this->grid<CK,Traits,ArcContainer>();
|
||||
this->grid2<CK,Traits,ArcContainer>();
|
||||
this->random<CK,Traits,ArcContainer>();
|
||||
//this->empty_cell();
|
||||
this->rotation<CK,Traits,ArcContainer>();
|
||||
}
|
||||
}
|
||||
|
||||
void empty_row(){
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->close_row();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute_dxf(const char* dxffile){
|
||||
this->dfx<CK,Traits,ArcContainer>(dxffile);
|
||||
this->close_row();
|
||||
}
|
||||
|
||||
void kernel(const char* kernel){
|
||||
this->open_row();
|
||||
this->open_cell();
|
||||
htmlout << kernel;
|
||||
texout << kernel ;
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
|
||||
void newDxfFilename(const char* Dxffilename=""){
|
||||
const char* newDxf = Dxffilename;
|
||||
|
||||
if(!ONLY_DXF){
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>grid I</td><td>grid II</td><td>random double</td><td>Dxf input is: "<< newDxf <<"</td><td> rotation </td></tr>"
|
||||
<<std::endl;
|
||||
infotable();
|
||||
texout <<"\\end{tabular}"<<std::endl<<"\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \\hline Kernel &\\multicolumn{4}{c|}{ grid I}&\\multicolumn{4}{c|}{grid II }&\\multicolumn{4}{c|}{random double} & \\multicolumn{4}{c|}{Dxf input is:"<< newDxf<<" }&\\multicolumn{4}{c|}{ rotation }\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
else{
|
||||
infotable();
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>Dxf input is: "<< newDxf <<"</td> </tr>"
|
||||
<<std::endl;
|
||||
texout <<"\\end{tabular}"<<std::endl<<"\\begin{tabular}{|c|c|c|c|c|} \\hline $Kernel$ &\\multicolumn{4}{c|}{Dxf input is:"<< newDxf <<"} \\\\ \\hline"<<std::endl;
|
||||
}
|
||||
Dxffile=Dxffilename;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //#define ECG_BENCH_H
|
||||
|
||||
|
|
@ -0,0 +1,269 @@
|
|||
//#define CGAL_INTERSECTION_MAP_FOR_SUPPORTING_CIRCLES
|
||||
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Handle_for.h>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
#include <CGAL/MP_Float.h>
|
||||
#include <CGAL/Gmpz.h>
|
||||
#include <CGAL/Gmpq.h>
|
||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
||||
#include <CGAL/intersections.h>
|
||||
#include <CGAL/Circular_kernel_2.h>
|
||||
#include <CGAL/Arr_circular_arc_traits_2.h>
|
||||
#include <CGAL/Lazy_circular_kernel_2.h>
|
||||
#include <CGAL/Filtered_bbox_circular_kernel_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_naive_point_location.h>
|
||||
#include <CGAL/Arr_circular_line_arc_traits_2.h>
|
||||
#include <CGAL/Timer.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <CGAL/IO/Dxf_variant_reader.h>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
// CIRCULAR KERNEL TYPEDEFS
|
||||
//typedef CGAL::MP_Float RT;
|
||||
//typedef CGAL::Quotient<RT> NT1;
|
||||
typedef CGAL::Gmpz RT;
|
||||
typedef CGAL::Gmpq NT1;
|
||||
typedef CGAL::Cartesian<NT1> Linear_k1;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT1> Algebraic_k1;
|
||||
typedef CGAL::Circular_kernel_2<Linear_k1, Algebraic_k1> CircularKernel;
|
||||
typedef CGAL::Arr_circular_arc_traits_2<CircularKernel> CircularK_CA_Traits;
|
||||
typedef CircularKernel::Circular_arc_2 CircularKArc;
|
||||
typedef std::vector<CircularKArc> CircularKArcContainer;
|
||||
typedef CircularKernel::Circular_arc_2 Circular_arc_2;
|
||||
typedef CircularKernel::Line_arc_2 Line_arc_2;
|
||||
typedef CGAL::Arr_circular_line_arc_traits_2<CircularKernel> CircularK_Variant_Traits;
|
||||
typedef boost::variant< Circular_arc_2, Line_arc_2 > CircularKVarArc;
|
||||
typedef std::vector<CircularKVarArc> CircularKVarArcContainer;
|
||||
|
||||
// LAZY KERNEL TYPEDEFS
|
||||
typedef CGAL::Interval_nt_advanced NT3;
|
||||
typedef CGAL::Cartesian<NT3> Linear_k3;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT3> Algebraic_k3;
|
||||
typedef CGAL::Circular_kernel_2 <Linear_k3,Algebraic_k3> CK3_;
|
||||
typedef CGAL::Lazy_circular_kernel_2<CircularKernel,CK3_> LazyCurvedK;
|
||||
typedef CGAL::Arr_circular_arc_traits_2<LazyCurvedK> LazyCurvedK_CA_Traits;
|
||||
typedef LazyCurvedK::Circular_arc_2 LazyArc;
|
||||
typedef std::vector<LazyArc> LazyArcContainer;
|
||||
typedef LazyCurvedK::Circular_arc_2 Circular_arc_3;
|
||||
typedef LazyCurvedK::Line_arc_2 Line_arc_3;
|
||||
typedef boost::variant<Circular_arc_3,Line_arc_3 > LazyVarArc;
|
||||
typedef std::vector<LazyVarArc> LazyVarContainer;
|
||||
//~ typedef CGAL::Arr_circular_line_arc_traits_2<LazyCurvedK,Line_arc_3,Circular_arc_3> LazyCurvedK_Variant_Traits;
|
||||
typedef CGAL::Arr_circular_line_arc_traits_2<LazyCurvedK> LazyCurvedK_Variant_Traits;
|
||||
|
||||
// BBOX TYPEDEFS
|
||||
typedef CGAL::Filtered_bbox_circular_kernel_2<CircularKernel>
|
||||
BBCircularKernel ;
|
||||
typedef CGAL::Arr_circular_arc_traits_2<BBCircularKernel>
|
||||
BBCircularKernel_CA_Traits;
|
||||
typedef BBCircularKernel::Circular_arc_2
|
||||
BBCircularKernelArc;
|
||||
typedef std::vector<BBCircularKernelArc>
|
||||
BBCircularKernelArcContainer;
|
||||
typedef BBCircularKernel::Circular_arc_2
|
||||
Circular_arc_6;
|
||||
typedef BBCircularKernel::Line_arc_2
|
||||
Line_arc_6;
|
||||
typedef boost::variant<Circular_arc_6,Line_arc_6 >
|
||||
BBCircVarArc;
|
||||
typedef std::vector<BBCircVarArc>
|
||||
BBCircVarContainer;
|
||||
typedef CGAL::Arr_circular_line_arc_traits_2<BBCircularKernel> BBCircVariantTraits;
|
||||
|
||||
// BBOX(LAZY)
|
||||
typedef CGAL::Filtered_bbox_circular_kernel_2<LazyCurvedK>
|
||||
BBLazyKernel ;
|
||||
typedef CGAL::Arr_circular_arc_traits_2<BBLazyKernel>
|
||||
BBLazyKernel_CA_Traits;
|
||||
typedef BBLazyKernel::Circular_arc_2
|
||||
BBLazyKernelArc;
|
||||
typedef std::vector<BBLazyKernelArc>
|
||||
BBLazyKernelArcContainer;
|
||||
typedef BBLazyKernel::Circular_arc_2
|
||||
Circular_arc_lazybb;
|
||||
typedef BBLazyKernel::Line_arc_2
|
||||
Line_arc_lazybb;
|
||||
typedef boost::variant<Circular_arc_lazybb,Line_arc_lazybb >
|
||||
BBLazyVarArc;
|
||||
typedef std::vector<BBLazyVarArc>
|
||||
BBLazyVarContainer;
|
||||
typedef CGAL::Arr_circular_line_arc_traits_2<BBLazyKernel> BBLazyVariantTraits;
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void do_main(const char *s) {
|
||||
|
||||
// TYPEDEFS
|
||||
typedef typename CK::Circular_arc_2 C2;
|
||||
typedef typename CK::Line_arc_2 L2;
|
||||
typedef typename CGAL::Arrangement_2<Traits> Pmwx;
|
||||
typedef typename CGAL::Arr_naive_point_location<Pmwx> Point_location;
|
||||
|
||||
// LOADING CURVES
|
||||
ArcContainer ac;
|
||||
std::ifstream fin;
|
||||
fin.open (s);
|
||||
CGAL::variant_load<CK, C2, L2>(
|
||||
fin, std::back_inserter(ac));
|
||||
fin.close();
|
||||
|
||||
std::cout << "Size:" << ac.size() << std::endl;
|
||||
|
||||
// BENCHMARKING
|
||||
Pmwx _pm;
|
||||
Point_location _pl(_pm);
|
||||
struct rusage before, after;
|
||||
struct timeval utime, stime;
|
||||
getrusage(RUSAGE_SELF,&before);
|
||||
insert(_pm,ac.begin(),ac.end(),boost::false_type());
|
||||
getrusage(RUSAGE_SELF,&after);
|
||||
timersub(&(after.ru_utime),&(before.ru_utime),&utime);
|
||||
timersub(&(after.ru_stime),&(before.ru_stime),&stime);
|
||||
std::cout<<"Time="<< utime.tv_sec<<"."<< std::setw(6) <<
|
||||
std::setfill('0')<< utime.tv_usec <<std::endl;
|
||||
|
||||
std::cerr << utime.tv_sec << "." << std::setw(6) <<
|
||||
std::setfill('0')<< utime.tv_usec << std::endl;
|
||||
|
||||
std::cout << "The arrangement size:" << std::endl
|
||||
<< " V = " << _pm.number_of_vertices()
|
||||
<< ", E = " << _pm.number_of_edges()
|
||||
<< ", F = " << _pm.number_of_faces() << std::endl;
|
||||
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void do_main(int k) {
|
||||
|
||||
// TYPEDEFS
|
||||
typedef typename CK::Circular_arc_2 C2;
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::FT FT;
|
||||
typedef typename CGAL::Arrangement_2<Traits> Pmwx;
|
||||
typedef typename CGAL::Arr_naive_point_location<Pmwx> Point_location;
|
||||
|
||||
// LOADING CURVES
|
||||
ArcContainer ac;
|
||||
|
||||
double cx, cy;
|
||||
const FT rft(1.0);
|
||||
|
||||
// DENSE
|
||||
if(k == 0) {
|
||||
for(cx = 0.0; cx <= 10.0; cx += 0.5) {
|
||||
for(cy = 0.0; cy <= 10.0; cy += 0.5) {
|
||||
ac.push_back(typename CK::Circular_arc_2 ( typename CK::Circle_2(Point_2(cx,cy),rft) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VERY DENSE
|
||||
if(k == 1) {
|
||||
for(cx = 0.0; cx <= 0.2; cx += 0.01) {
|
||||
for(cy = 0.0; cy <= 0.2; cy += 0.01) {
|
||||
ac.push_back(typename CK::Circular_arc_2 ( typename CK::Circle_2(Point_2(cx,cy),rft) ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ONE CIRCLE
|
||||
if(k == 2) {
|
||||
ac.push_back(typename CK::Circular_arc_2 ( typename CK::Circle_2(Point_2(0,0),5) ));
|
||||
}
|
||||
|
||||
// RANDOM CASE
|
||||
if(k == 3) {
|
||||
CGAL::Random generatorOfgenerator;
|
||||
int random_seed = generatorOfgenerator.get_int(0, 123456);
|
||||
CGAL::Random theRandom(random_seed);
|
||||
for(int i=0; i<100; i++) {
|
||||
double x = theRandom.get_double(0.0,1.0);
|
||||
double y = theRandom.get_double(0.0,1.0);
|
||||
double r = theRandom.get_double(0.00001,1.0);
|
||||
ac.push_back(typename CK::Circular_arc_2 ( typename CK::Circle_2(Point_2(x,y),FT(r)) ));
|
||||
}
|
||||
}
|
||||
|
||||
// SPARSE
|
||||
if(k == 4) {
|
||||
double h = (std::sqrt(3.0)+0.01);
|
||||
for(cx = 0.0; cx <= 40.4; cx += 2.01) {
|
||||
for(cy = h; cy <= h*20; cy += h*2) {
|
||||
ac.push_back(typename CK::Circular_arc_2 ( typename CK::Circle_2(Point_2(cx+1.0,cy),rft) ));
|
||||
}
|
||||
for(cy = 0.0; cy <= h*20.0; cy += h*2) {
|
||||
ac.push_back(typename CK::Circular_arc_2 ( typename CK::Circle_2(Point_2(cx,cy),rft)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Size:" << ac.size() << std::endl;
|
||||
|
||||
// BENCHMARKING
|
||||
Pmwx _pm;
|
||||
Point_location _pl(_pm);
|
||||
struct rusage before, after;
|
||||
struct timeval utime, stime;
|
||||
getrusage(RUSAGE_SELF,&before);
|
||||
insert(_pm,ac.begin(),ac.end(),boost::false_type());
|
||||
getrusage(RUSAGE_SELF,&after);
|
||||
timersub(&(after.ru_utime),&(before.ru_utime),&utime);
|
||||
timersub(&(after.ru_stime),&(before.ru_stime),&stime);
|
||||
std::cout<<"Time="<< utime.tv_sec<<"."<< std::setw(6) <<
|
||||
std::setfill('0')<< utime.tv_usec << std::endl;
|
||||
|
||||
std::cerr << utime.tv_sec << "." << std::setw(6) <<
|
||||
std::setfill('0')<< utime.tv_usec << std::endl;
|
||||
|
||||
std::cout << "The arrangement size:" << std::endl
|
||||
<< " V = " << _pm.number_of_vertices()
|
||||
<< ", E = " << _pm.number_of_edges()
|
||||
<< ", F = " << _pm.number_of_faces() << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
|
||||
const char* dxf_filename[] = { "DXF/51.dxf",
|
||||
"DXF/cad_l1.dxf",
|
||||
"DXF/cad_l2.dxf",
|
||||
"DXF/che_mod1.dxf",
|
||||
"DXF/CIOnZDraw.dxf",
|
||||
"DXF/mask1.dxf",
|
||||
"DXF/elekonta.dxf",
|
||||
"DXF/netlist_signal_1.dxf",
|
||||
"DXF/painttrack.dxf" };
|
||||
if(argc == 3) {
|
||||
int i = argv[1][0]-'0';
|
||||
int j = argv[2][0]-'0';
|
||||
if((j >= 0 && j < 9)) {
|
||||
if(i == 1) do_main<BBCircularKernel,BBCircVariantTraits, BBCircVarContainer>(dxf_filename[j]);
|
||||
if(i == 2) do_main<LazyCurvedK,LazyCurvedK_Variant_Traits, LazyVarContainer>(dxf_filename[j]);
|
||||
if(i == 3) do_main<CircularKernel,CircularK_Variant_Traits, CircularKVarArcContainer>(dxf_filename[j]);
|
||||
if(i == 4) do_main<BBLazyKernel,BBLazyVariantTraits, BBLazyVarContainer>(dxf_filename[j]);
|
||||
if((i >= 5) || (i <= 0)) std::cout << "INVALID PARAMETERS" << std::endl;
|
||||
} else {
|
||||
int k = -1;
|
||||
if(j == 9) k = 0;
|
||||
if(j == ('a'-'0')) k = 1;
|
||||
if(j == ('b'-'0')) k = 2;
|
||||
if(j == ('c'-'0')) k = 3;
|
||||
if(j == ('d'-'0')) k = 4;
|
||||
if(i == 1) do_main<BBCircularKernel,BBCircVariantTraits, BBCircVarContainer>(k);
|
||||
if(i == 2) do_main<LazyCurvedK,LazyCurvedK_Variant_Traits, LazyVarContainer>(k);
|
||||
if(i == 3) do_main<CircularKernel,CircularK_Variant_Traits, CircularKVarArcContainer>(k);
|
||||
if(i == 4) do_main<BBLazyKernel,BBLazyVariantTraits, BBLazyVarContainer>(k);
|
||||
if(i == 5) do_main<BBCircularKernel,BBCircularKernel_CA_Traits, BBCircularKernelArcContainer>(k);
|
||||
if(i == 6) do_main<LazyCurvedK,LazyCurvedK_CA_Traits, LazyArcContainer>(k);
|
||||
if(i == 7) do_main<CircularKernel,CircularK_CA_Traits, CircularKArcContainer>(k);
|
||||
if(i == 8) do_main<BBLazyKernel,BBLazyKernel_CA_Traits, BBLazyKernelArcContainer>(k);
|
||||
}
|
||||
} else std::cout << "INVALID PARAMETERS" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,437 @@
|
|||
#define CGAL_CAST_INT
|
||||
#define CIRCULAR_KERNEL_2
|
||||
#define LAZY_CURVED_KERNEL_2
|
||||
#define CIRCULAR_KERNEL_2_FILTERED_HEXAGON
|
||||
#define LAZY_CURVED_KERNEL_2_FILTERED_HEXAGON
|
||||
#define CIRCULAR_KERNEL_2_FILTERED_BBOX
|
||||
#define LAZY_CURVED_KERNEL_2_FILTERED_BBOX
|
||||
|
||||
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Handle_for.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
#include <CGAL/MP_Float.h>
|
||||
|
||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
||||
|
||||
#include <CGAL/intersections.h>
|
||||
|
||||
#include <CGAL/Circular_kernel_2.h>
|
||||
#include <CGAL/Arr_circular_arc_traits_2.h>
|
||||
//#include <CGAL/Circular_arc_traits_tracer.h>
|
||||
|
||||
#include <CGAL/Lazy_circular_kernel_2.h>
|
||||
|
||||
#ifdef CIRCULAR_KERNEL_2_FILTERED_HEXAGON
|
||||
#include <CGAL/Filtered_hexagon_circular_kernel_2.h>
|
||||
#endif
|
||||
|
||||
#include <CGAL/Filtered_bbox_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_naive_point_location.h>
|
||||
#include <CGAL/Arr_circular_line_arc_traits_2.h>
|
||||
|
||||
|
||||
#include <CGAL/Random.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "benchmark.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{ //char* Dxffilename[]={"myFirst.dxf","cad_l1.dxf"};
|
||||
const char* Dxffilename[]={"myFirst.dxf","minimask0.dxf","minimask1.dxf","mask0.dxf","mask1.dxf","smallpainttrack.dxf","mask0_25.dxf","mask0_5.dxf","cad_l2.dxf","cad_l1.dxf","CIOnZDraw.dxf","che_mod1.dxf","elekonta.dxf","painttrack.dxf","netlist_signal_1.dxf","51.dxf"};
|
||||
std::string Htmlfilename;
|
||||
std::string Texfilename;
|
||||
char exten[4];
|
||||
int i;
|
||||
i=0;
|
||||
|
||||
|
||||
if (argv[1] != NULL)
|
||||
{
|
||||
int len =strlen(argv[1]);
|
||||
for (int j=0; j < 3 ; j++)
|
||||
{
|
||||
exten[j]=argv[1][len - 3 + j];
|
||||
}
|
||||
if (strncmp(exten,"dxf",3) !=0)
|
||||
{
|
||||
std::cout<< "File is not correct (*.dxf is needed)." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
Dxffilename[i] = argv[1];
|
||||
std::cout<< "File "<< Dxffilename[i] << " is correct."<<std::endl;
|
||||
}
|
||||
if (argc >2 and argv[2] != NULL)
|
||||
{
|
||||
int len =strlen(argv[2]);
|
||||
for (int j=0; j < 4 ; j++)
|
||||
{
|
||||
exten[j]=argv[2][len - 4 + j];
|
||||
}
|
||||
if (strncmp(exten,"html",4) !=0)
|
||||
{
|
||||
std::cout<< "File "<< argv[2] << " is not correct (*.html is needed)." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
std::cout<< "File "<< argv[2] << " is correct." <<std::endl;
|
||||
}
|
||||
if (argv[3] != NULL)
|
||||
{
|
||||
int len =strlen(argv[3]);
|
||||
for (int j=0; j < 3 ; j++)
|
||||
{
|
||||
exten[j]=argv[3][len - 3 + j];
|
||||
}
|
||||
if (strncmp(exten,"tex",3) !=0)
|
||||
{
|
||||
std::cout<< "File "<< argv[3] << " is not correct (*.tex is needed)."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
std::cout<< "File "<< argv[3] << " is correct." <<std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Htmlfilename="benchmarks.html";
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.html file is :" << Htmlfilename<< std::endl;
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Dxffilename[i]="myFirst.dxf";
|
||||
//Dxffilename[i]="cad_l1.dxf";
|
||||
Htmlfilename="benchmarks.html";
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.dxf file is :" << Dxffilename[i]<< std::endl;
|
||||
std::cout<< "Default *.html file is :" << Htmlfilename<< std::endl;
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Bench bench(Htmlfilename,Texfilename,Dxffilename[i],true); // If you want to do benchmarks only with dxf files, you supose to use this defenition
|
||||
|
||||
Bench bench; //If you want create table with all datasets you supose to use this.
|
||||
|
||||
|
||||
|
||||
// for(i=0;i<2;i++){
|
||||
//
|
||||
// std::ifstream fin;
|
||||
// fin.open (Dxffilename[i]);
|
||||
// if (!fin.is_open())
|
||||
// {
|
||||
// std::cout<<"file "<< Dxffilename[i] << " is not found"<<std::endl;
|
||||
// fin.close();
|
||||
// return 0;
|
||||
//
|
||||
// }
|
||||
// fin.close();
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Circular_Kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef CIRCULAR_KERNEL_2
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT1;
|
||||
typedef CGAL::Cartesian<NT1> Linear_k1;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT1> Algebraic_k1;
|
||||
typedef CGAL::Circular_kernel_2<Linear_k1, Algebraic_k1> CircularKernel;
|
||||
|
||||
// #ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Arr_circular_arc_traits_2<CircularKernel> CircularK_CA_Traits;
|
||||
// #else
|
||||
// typedef CGAL::Circular_arc_traits<CircularKernel> Traits0;
|
||||
// typedef CGAL::Circular_arc_traits_tracer<Traits0> CircularK_CA_Traits;
|
||||
// #endif
|
||||
|
||||
typedef CircularKernel::Circular_arc_2 CircularKArc;
|
||||
typedef std::vector<CircularKArc> CircularKArcContainer;
|
||||
bench.kernel("CkCircArc");
|
||||
|
||||
bench.Compute_no_dxf<CircularKernel,CircularK_CA_Traits,CircularKArcContainer>();
|
||||
|
||||
|
||||
typedef CircularKernel::Circular_arc_2 Circular_arc_2;
|
||||
typedef CircularKernel::Line_arc_2 Line_arc_2;
|
||||
typedef CGAL::Arr_circular_line_arc_traits_2<CircularKernel> CircularK_Variant_Traits;
|
||||
|
||||
typedef boost::variant< Circular_arc_2, Line_arc_2 > CircularKVarArc;
|
||||
typedef std::vector<CircularKVarArc> CircularKVarArcContainer;
|
||||
|
||||
bench.kernel("CKVar");
|
||||
|
||||
//bench.Compute<CircularKernel,CircularK_Variant_Traits,CircularKVarArcContainer>(Dxffilename[i]);
|
||||
|
||||
//bench.Compute_dxf<CircularKernel,CircularK_Variant_Traits,CircularKVarArcContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<CircularKernel,CircularK_Variant_Traits,CircularKVarArcContainer>();
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Lazy_curved_Kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef LAZY_CURVED_KERNEL_2
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT2;
|
||||
typedef CGAL::Cartesian<NT2> Linear_k2;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT2> Algebraic_k2;
|
||||
typedef CGAL::Circular_kernel_2 <Linear_k2, Algebraic_k2> CK2_;
|
||||
|
||||
|
||||
typedef CGAL::Interval_nt_advanced NT3;
|
||||
typedef CGAL::Cartesian<NT3> Linear_k3;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT3> Algebraic_k3;
|
||||
typedef CGAL::Circular_kernel_2 <Linear_k3,Algebraic_k3> CK3_;
|
||||
|
||||
|
||||
typedef CGAL::Lazy_circular_kernel_2<CK2_,CK3_> LazyCurvedK;
|
||||
|
||||
// #ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Arr_circular_arc_traits_2<LazyCurvedK> LazyCurvedK_CA_Traits;
|
||||
// #else
|
||||
// typedef CGAL::Circular_arc_traits<LazyCurved_k> Traits0_2;
|
||||
// typedef CGAL::Circular_arc_traits_tracer<Traits0_2> LazyCurved_kTraits;
|
||||
// #endif
|
||||
|
||||
typedef LazyCurvedK::Circular_arc_2 LazyArc;
|
||||
typedef std::vector<LazyArc> LazyArcContainer;
|
||||
|
||||
bench.kernel("LazyCircArc") ;
|
||||
|
||||
bench.Compute_no_dxf<LazyCurvedK,LazyCurvedK_CA_Traits,LazyArcContainer>();
|
||||
|
||||
|
||||
typedef LazyCurvedK::Circular_arc_2 Circular_arc_3;
|
||||
typedef LazyCurvedK::Line_arc_2 Line_arc_3;
|
||||
typedef boost::variant<Circular_arc_3,Line_arc_3 > LazyVarArc;
|
||||
typedef std::vector<LazyVarArc> LazyVarContainer;
|
||||
typedef CGAL::Arr_circular_line_arc_traits_2<LazyCurvedK> LazyCurvedK_Variant_Traits;
|
||||
|
||||
bench.kernel("LazyKVar");
|
||||
|
||||
//bench.Compute<LazyCurvedK,LazyCurvedK_Variant_Traits,LazyVarContainer>(Dxffilename[i]);
|
||||
//bench.Compute_dxf<LazyCurvedK,LazyCurvedK_Variant_Traits,LazyVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<LazyCurvedK,LazyCurvedK_Variant_Traits,LazyVarContainer>();
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Filtered_hexagone_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef CIRCULAR_KERNEL_2_FILTERED_HEXAGON
|
||||
|
||||
typedef CGAL::Filtered_hexagon_circular_kernel_2<CircularKernel> CircularKernelHexagon;
|
||||
|
||||
// #ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Arr_circular_arc_traits_2<CircularKernelHexagon> CircularKernHex_CA_Traits;
|
||||
// #else
|
||||
// typedef CGAL::Circular_arc_traits<CircularKernelHexagon> Traits0_3;
|
||||
// typedef CGAL::Circular_arc_traits_tracer<Traits0_3> CircularKernHex_CA_Traits;
|
||||
// #endif
|
||||
|
||||
typedef CircularKernelHexagon::Circular_arc_2 CircularKernHexArc;
|
||||
typedef std::vector<CircularKernHexArc> CircularKernHexArcContainer;
|
||||
bench.kernel("CK Hex CircArcTraits");
|
||||
|
||||
bench.Compute_no_dxf<CircularKernelHexagon,CircularKernHex_CA_Traits,CircularKernHexArcContainer>();
|
||||
|
||||
|
||||
typedef CircularKernelHexagon::Circular_arc_2 Circular_arc_4;
|
||||
typedef CircularKernelHexagon::Line_arc_2 Line_arc_4;
|
||||
typedef boost::variant< Circular_arc_4, Line_arc_4 > CircularKernHexVarArc;
|
||||
typedef std::vector<CircularKernHexVarArc> CircularKernHexVarArcContainer;
|
||||
typedef CGAL::Arr_circular_line_arc_traits_2<CircularKernelHexagon> CircularKernHex_Variant_Traits;
|
||||
|
||||
bench.kernel("CK Hex VarTraits");
|
||||
|
||||
// bench.Compute<CircularKernelHexagon,CircularKernHex_Variant_Traits,CircularKernHexVarArcContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<CircularKernelHexagon,CircularKernHex_Variant_Traits,CircularKernHexVarArcContainer>();
|
||||
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Filtered_hexagone_Lazy_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef LAZY_CURVED_KERNEL_2_FILTERED_HEXAGON
|
||||
|
||||
|
||||
typedef CGAL::Filtered_hexagon_circular_kernel_2<LazyCurvedK> LazyKernelHexagon;
|
||||
|
||||
// #ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Arr_circular_arc_traits_2<LazyKernelHexagon> LazyKernelHexagon_CA_Traits;
|
||||
// #else
|
||||
// typedef CGAL::Circular_arc_traits<LazyKernelHexagon> Traits0_4;
|
||||
// typedef CGAL::Circular_arc_traits_tracer<Traits0_4> LazyKernelHexagon_CA_Traits;
|
||||
// #endif
|
||||
|
||||
typedef LazyKernelHexagon::Circular_arc_2 LazyKernelHexagonArc;
|
||||
typedef std::vector<LazyKernelHexagonArc> LazyKernelHexagonArcContainer;
|
||||
bench.kernel("LazyK Hex CircArcTraits");
|
||||
|
||||
bench.Compute_no_dxf<LazyKernelHexagon,LazyKernelHexagon_CA_Traits, LazyKernelHexagonArcContainer>();
|
||||
|
||||
typedef LazyKernelHexagon::Circular_arc_2 Circular_arc_5;
|
||||
typedef LazyKernelHexagon::Line_arc_2 Line_arc_5;
|
||||
typedef boost::variant<Circular_arc_5,Line_arc_5 > HxLazyVarArc;
|
||||
typedef std::vector<HxLazyVarArc> HxLazyVarContainer;
|
||||
typedef CGAL::Arr_circular_line_arc_traits_2<LazyKernelHexagon> HxLazyVariantTraits;
|
||||
|
||||
bench.kernel("LazyK Hex VarTraits") ;
|
||||
|
||||
//bench.Compute<LazyKernelHexagon,HxLazyVariantTraits,HxLazyVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<LazyKernelHexagon,HxLazyVariantTraits,HxLazyVarContainer>();
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_filtered_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef CIRCULAR_KERNEL_2_FILTERED_BBOX
|
||||
|
||||
typedef CGAL::Filtered_bbox_circular_kernel_2<CircularKernel> BBCircularKernel ;
|
||||
|
||||
// #ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Arr_circular_arc_traits_2<BBCircularKernel> BBCircularKernel_CA_Traits;
|
||||
// #else
|
||||
// typedef CGAL::Circular_arc_traits<BBCircularKernel> Traits0_5;
|
||||
// typedef CGAL::Circular_arc_traits_tracer<Traits0_5> BBCircularKernel_CA_Traits;
|
||||
// #endif
|
||||
typedef BBCircularKernel::Circular_arc_2 BBCircularKernelArc;
|
||||
typedef std::vector<BBCircularKernelArc> BBCircularKernelArcContainer;
|
||||
bench.kernel("CK BBox CircArcTraits");
|
||||
|
||||
bench.Compute_no_dxf<BBCircularKernel,BBCircularKernel_CA_Traits, BBCircularKernelArcContainer>();
|
||||
|
||||
typedef BBCircularKernel::Circular_arc_2 Circular_arc_6;
|
||||
typedef BBCircularKernel::Line_arc_2 Line_arc_6;
|
||||
typedef boost::variant<Circular_arc_6,Line_arc_6 > BBCircVarArc;
|
||||
typedef std::vector<BBCircVarArc> BBCircVarContainer;
|
||||
typedef CGAL::Arr_circular_line_arc_traits_2<BBCircularKernel> BBCircVariantTraits;
|
||||
|
||||
bench.kernel("CK BBox VarTraits") ;
|
||||
|
||||
// bench.Compute<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>();
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_hexagone_Lazy_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef LAZY_CURVED_KERNEL_2_FILTERED_BBOX
|
||||
|
||||
typedef CGAL::Filtered_bbox_circular_kernel_2<LazyCurvedK> BBLazyCurvedK;
|
||||
|
||||
// #ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Arr_circular_arc_traits_2<BBLazyCurvedK> BBLazyCurvedK_CA_Traits;
|
||||
// #else
|
||||
// typedef CGAL::Circular_arc_traits<BBLazyCurvedK> Traits0_6;
|
||||
// typedef CGAL::Circular_arc_traits_tracer<Traits0_6> BBLazyCurvedK_CA_Traits;
|
||||
// #endif
|
||||
|
||||
typedef BBLazyCurvedK::Circular_arc_2 BBLazyCurvedKArc;
|
||||
typedef std::vector<BBLazyCurvedKArc> BBLazyCurvedKArcContainer;
|
||||
bench.kernel("LLazyK BBox CircArcTraits");
|
||||
|
||||
bench.Compute_no_dxf<BBLazyCurvedK,BBLazyCurvedK_CA_Traits,BBLazyCurvedKArcContainer>();
|
||||
|
||||
|
||||
typedef BBLazyCurvedK::Circular_arc_2 Circular_arc_7;
|
||||
typedef BBLazyCurvedK::Line_arc_2 Line_arc_7;
|
||||
typedef boost::variant<Circular_arc_7,Line_arc_7 > BBLazyVarArc;
|
||||
typedef std::vector< BBLazyVarArc> BBLazyVarContainer;
|
||||
typedef CGAL::Arr_circular_line_arc_traits_2<BBLazyCurvedK> BBLazyVariantTraits;
|
||||
|
||||
bench.kernel("LLazyK BBox VarTraits") ;
|
||||
|
||||
//bench.Compute<BBLazyCurvedK, BBLazyVariantTraits, BBLazyVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<BBLazyCurvedK, BBLazyVariantTraits, BBLazyVarContainer>();
|
||||
|
||||
#endif
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_filtered_Filtered_hexagone_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Filtered_bbox_curved_kernel<CircularKernelHexagon> BBCircKHexagon ;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<BBCircKHexagon> BBCircKHexagonCATraits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<BBCircKHexagon> Traits0_7;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_7> BBCircKHexagonCATraits;
|
||||
#endif
|
||||
typedef BBCircKHexagon::Circular_arc_2 BBCircKHexagonArc;
|
||||
typedef std::vector<BBCircKHexagon> BBCircKHexagonArcCont;
|
||||
bench.kernel("BBox Circular kernel filtered Hexagon CircArcTraits");
|
||||
|
||||
bench.Compute_no_dxf<BBCircKHexagon,BBCircKHexagonCATraits, BBCircKHexagonArcCont>();
|
||||
|
||||
typedef BBCircularKernelHexagon::Circular_arc_2 Circular_arc_8;
|
||||
typedef BBCircularKernelHexagon::Line_arc_2 Line_arc_8;
|
||||
typedef boost::variant<Circular_arc_8,Line_arc_8 > BBCircularKernelHexagonVarArc;
|
||||
typedef std::vector<BBCircularKernelHexagonVarArc> BBCircularKernelHexagonVarContainer;
|
||||
typedef CGAL::Variant_traits<BBCircularKernelHexagon,Line_arc_8,Circular_arc_8> BBCircularKernelHexagonVariantTraits;
|
||||
|
||||
bench.kernel("BBox Circular kernel filtered Hexagon VarTraits") ;
|
||||
|
||||
//bench.Compute<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<BBCircularKernelHexagon,BBCircularKernelHexagonVariantTraits,BBCircularKernelHexagonVarContainer>();*/
|
||||
/*--------------------------------------------------------------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------------------------------------------------------------*/
|
||||
// if (i+1<2)
|
||||
// {
|
||||
// try{
|
||||
// if (strcmp(Dxffilename[i+1],""))
|
||||
// {
|
||||
// try{
|
||||
// fin.open (Dxffilename[i]);
|
||||
// }
|
||||
// catch(...){
|
||||
// std::cout<<"error"<<std::endl;
|
||||
// }
|
||||
// if (!fin.is_open())
|
||||
// {
|
||||
// std::cout<<"file "<< Dxffilename[i] << " is not found"<<std::endl;
|
||||
// std::cout << "that's all" << std::endl;
|
||||
// fin.close();
|
||||
// break;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// bench.newDxfFilename(Dxffilename[i+1]);
|
||||
// }
|
||||
// fin.close();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::cout << "that's all" << std::endl;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// catch(...){std::cout << "error" << std::endl;}
|
||||
// }
|
||||
// }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
|
||||
#include <CGAL/basic.h>
|
||||
#include<CGAL/Handle_for.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
#include <CGAL/MP_Float.h>
|
||||
|
||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
||||
|
||||
#include <CGAL/intersections.h>
|
||||
|
||||
#include <CGAL/Circular_kernel_2.h>
|
||||
#include <CGAL/Circular_arc_traits.h>
|
||||
#include <CGAL/Circular_arc_traits_tracer.h>
|
||||
|
||||
#include <CGAL/Lazy_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Filtered_hexagon_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Filtered_bbox_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_naive_point_location.h>
|
||||
#include <CGAL/Variant_traits.h>
|
||||
|
||||
|
||||
#include "IntStr.h"
|
||||
#include "benchmark_parser.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
template <typename K,class ArcContainer>
|
||||
struct Breader : public Benchmark_visitor {
|
||||
typedef typename CGAL::Quotient<CGAL::MP_Float> NT1;
|
||||
typedef typename K::Point_2 Point_2;
|
||||
typedef typename K::Circle_2 Circle_2;
|
||||
typedef std::list<Circle_2> Circles;
|
||||
typedef std::list<Point_2> Points;
|
||||
typedef std::list<NT1> Numbers;
|
||||
typedef std::list<std::pair<Point_2, double> > Polygon;
|
||||
typedef std::list<Polygon> Polygons;
|
||||
Points points;
|
||||
Numbers numbers;
|
||||
Circles circles;
|
||||
Polygons polygons;
|
||||
int x_;
|
||||
int y_;
|
||||
Breader() {}
|
||||
virtual void token_not_handled( std::string s) {}
|
||||
virtual void accept_benchmark_name( std::string s) {
|
||||
Benchmark_visitor::accept_benchmark_name(s);
|
||||
std::cerr << "name '" << s << "', ";
|
||||
}
|
||||
|
||||
virtual void accept_classification( std::string problem,
|
||||
std::string geom,
|
||||
std::string clas,
|
||||
std::string family,
|
||||
std::string instance,
|
||||
std::string release) {
|
||||
|
||||
if ((problem != "Arrangement") && (problem != "CSG")
|
||||
&& (problem != " "))
|
||||
error_handler
|
||||
( "classification error");
|
||||
|
||||
if ((geom != "Lines") && (geom != "Circles") && (geom != "Conics")
|
||||
&& (geom != "Cubics") && (geom != "Quartics")
|
||||
&& (geom != "ArbitraryDegreeCurves") && ( geom != "Quadrics")
|
||||
&& (geom != "Tori") && (geom != "Planes") && (geom != " "))
|
||||
error_handler ( "classification error" );
|
||||
|
||||
if ((clas != "FullCurves") && (clas != "Ellipses")
|
||||
&& (clas != "BoundedArcs") && (clas != "UnboundedArcs")
|
||||
&& (clas != "FullSurfaces") && (clas != "BoundedPatches")
|
||||
&& (clas != "UnboundedPatches") && (clas != " "))
|
||||
error_handler ( "classification error" );
|
||||
}
|
||||
virtual void begin_circle_2() {
|
||||
|
||||
std::cerr << "circle begin" << std::endl;
|
||||
x_=0;
|
||||
y_=0;
|
||||
}
|
||||
|
||||
virtual void end_circle_2() {
|
||||
|
||||
std::cerr << "circle end" << std::endl;
|
||||
//Circle_2 cyrc = typename K::Construct_circle_2()(Point_2(x_,y_), integer*integer);
|
||||
NT1 r= numbers.back();
|
||||
Circle_2 circ = typename K::Construct_circle_2()(points.back(), r*r);
|
||||
circles.push_back(circ);
|
||||
}
|
||||
|
||||
virtual void accept_point_2( std::string x, std::string y) {
|
||||
|
||||
std::cerr << "accept_point_2 :"<<x << " ; "<< y << std::endl;
|
||||
|
||||
NT1 qx,qy;
|
||||
from_string(qx,x);
|
||||
from_string(qy,y);
|
||||
points.push_back(typename K::Construct_point_2()(qx,qy));
|
||||
std::cerr << "accept_point_2 :"<<qx << " ; "<< qy << std::endl;
|
||||
}
|
||||
virtual void accept_rational( std::string num, std::string denom) {
|
||||
|
||||
|
||||
CGAL::MP_Float _num,_denom;
|
||||
from_string(_num,num);
|
||||
from_string(_denom,denom);
|
||||
NT1 x(_num,_denom);
|
||||
std::cerr << "accept rat:"<<x<< std::endl;
|
||||
numbers.push_back(x);
|
||||
}
|
||||
|
||||
virtual void accept_point_2( std::string x_num, std::string x_denom,
|
||||
std::string y_num, std::string y_denom) {
|
||||
|
||||
|
||||
CGAL::MP_Float num,denom;
|
||||
from_string(num,x_num);
|
||||
from_string(denom,x_denom);
|
||||
NT1 x(num,denom);
|
||||
from_string(num,y_num);
|
||||
from_string(denom,y_denom);
|
||||
NT1 y(num,denom);
|
||||
std::cerr << "accept_point_2(rational) :"<< x<<","<< y<< std::endl;
|
||||
tnh( "Point_2(x_num, x_denom, y_num, y_denom)");
|
||||
points.push_back(typename K::Construct_point_2()(x,y));
|
||||
}
|
||||
virtual void accept_integer( std::string s) {
|
||||
|
||||
NT1 n;
|
||||
from_string(n,s);
|
||||
std::cerr <<"accept_integer!!!!"<<n <<std::endl;
|
||||
numbers.push_back(n);
|
||||
|
||||
}
|
||||
virtual void begin_line_segment_2() {
|
||||
std::cerr <<"Begin_line_segment_2"<<std::endl; }
|
||||
|
||||
virtual void end_line_segment_2() {
|
||||
std::cerr <<"end_line_segment_2"<<std::endl;
|
||||
Polygon p1;
|
||||
Polygon p2;
|
||||
typename Points::iterator pit = points.end();
|
||||
p2.push_back(std::make_pair(*pit, 0));
|
||||
pit--;
|
||||
p1.push_back(std::make_pair(*pit, 0));
|
||||
polygons.push_back(p1);
|
||||
polygons.push_back(p2);
|
||||
}
|
||||
virtual void begin_CircularArc_2(){
|
||||
std::cerr <<"begin_Circular_arc_2"<<std::endl;
|
||||
}
|
||||
|
||||
virtual void end_CircularArc_2(){
|
||||
std::cerr <<"end_Circular_arc_2"<<std::endl;
|
||||
}
|
||||
virtual void begin_LineArc_2(){
|
||||
tnh("begin_line_arc_2");
|
||||
std::cerr <<"begin_line_arc_2"<<std::endl;
|
||||
}
|
||||
|
||||
virtual void end_LineArc_2(){
|
||||
tnh("end_line_arc_2");
|
||||
std::cerr <<"end_line_arc_2"<<std::endl;
|
||||
}
|
||||
virtual void begin_CircularPoint_2(){
|
||||
tnh("begin_circular_arc_poin");
|
||||
std::cerr <<"begin_circular_arc_poin"<<std::endl;
|
||||
}
|
||||
|
||||
virtual void end_CircularPoint_2(){
|
||||
tnh("end_circular_arc_poin");
|
||||
std::cerr <<"end_circular_arc_poin"<<std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
////
|
||||
int str_to_int(const char* ch){
|
||||
int i;
|
||||
sscanf(ch,"%i",&i);
|
||||
return i;
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] ) {
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT1;
|
||||
typedef CGAL::Cartesian<NT1> Linear_k1;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT1> Algebraic_k1;
|
||||
typedef CGAL::Circular_kernel_2<Linear_k1, Algebraic_k1> CK;
|
||||
typedef CK::Circular_arc_2 Circular_arc_2;
|
||||
typedef CK::Line_arc_2 Line_arc_2;
|
||||
typedef CGAL::Variant_traits<CK,Line_arc_2,Circular_arc_2> CircularK_Variant_Traits;
|
||||
typedef boost::variant< Circular_arc_2, Line_arc_2 > CircularKVarArc;
|
||||
typedef std::vector<CircularKVarArc> CircularKVarArcContainer;
|
||||
CircularKVarArcContainer arc;
|
||||
typedef CGAL::Arrangement_2<CircularK_Variant_Traits> Pmwx;
|
||||
typedef CGAL::Arr_naive_point_location<Pmwx> Point_location;
|
||||
Pmwx _pm;
|
||||
Point_location _pl(_pm);
|
||||
typedef CK::Circle_2 Circle_2;
|
||||
typedef std::list<Circle_2> Circles;
|
||||
|
||||
int exit_status = 0;
|
||||
if ( argc < 2) {
|
||||
return 0;
|
||||
} else {
|
||||
for ( int i = 1; i < argc; ++i) {
|
||||
Breader<CK,CircularKVarArcContainer> check;
|
||||
std::cerr << "File '" << argv[i] << "', "<<std::endl;
|
||||
if ( benchmark_parse_file( argv[i], &check)) {
|
||||
std::cerr<<check.circles.size()<<std::endl;
|
||||
std::cerr<<check.polygons.size()<<std::endl;
|
||||
} else {
|
||||
std::cerr << "is malformed." << std::endl;
|
||||
exit_status = 1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return exit_status;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
It's not finished reader off .bff it uses extendet version of
|
||||
parser. I hope it will be usefull for yours future works. By using
|
||||
this source you can easyly create yours own.
|
||||
|
||||
missing
|
||||
Circular-arc
|
||||
Line-arc
|
||||
Circular-arc-point
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
#include <fstream>
|
||||
#include "dxf_converter.h"
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
|
||||
Dxf_converter converter;
|
||||
char* Benchfilename;
|
||||
char exten[4];
|
||||
|
||||
|
||||
if (argv[1] != NULL)
|
||||
{
|
||||
int len =strlen(argv[1]);
|
||||
for (int j=0; j < 3 ; j++)
|
||||
{
|
||||
exten[j]=argv[1][len - 3 + j];
|
||||
}
|
||||
if (strncmp(exten,"dxf",3))
|
||||
{
|
||||
std::cout<< "File is not correct (*.dxf is needed)." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
std::cout<< "File "<< argv[1] << " is correct."<<std::endl;
|
||||
}
|
||||
if (argc >2 and argv[2] != NULL)
|
||||
{
|
||||
int len =strlen(argv[2]);
|
||||
for (int j=0; j < 4 ; j++)
|
||||
{
|
||||
exten[j]=argv[2][len - 4 + j];
|
||||
}
|
||||
if (strncmp(exten,"arr",4) !=0)
|
||||
{
|
||||
std::cout<< "File "<< argv[2] << " is not correct (*.arr is needed)." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
std::cout<< "File "<< argv[2] << " is correct." <<std::endl;
|
||||
strcpy(Benchfilename,argv[2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{strcpy(Benchfilename,"");
|
||||
int len= strlen(argv[1]);
|
||||
strncat(Benchfilename,argv[1],len-4);
|
||||
strcat(Benchfilename,".arr");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
cout<<"file "<< argv[1]<< " is not found"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::cout<<Benchfilename<<std::endl;
|
||||
|
||||
std::ifstream fintest;
|
||||
fintest.open(argv[1]);
|
||||
if (!fintest.is_open())
|
||||
{
|
||||
cout<<"file "<<argv[1] << " is not found"<<std::endl;
|
||||
fintest.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::ifstream fin(argv[1]);
|
||||
std::ofstream fout(Benchfilename);
|
||||
// std::ofstream fout("test.arr");
|
||||
fout<< "FileFormat(\"AcsBenchmark\",0,1)"<<std::endl;
|
||||
fout<<"BenchmarkName(\""<<Benchfilename<<"\")"<<std::endl;
|
||||
fout<<"Classification(\"Arrangement\",\" Line\",\" BoundedArcs\",\"Rnd\",\"1\",\"Jan-2006\")"<<std::endl;
|
||||
fout<<"Classification(\"Arrangement\",\" Circles\",\" FullCurves\",\"Rnd\",\"1\",\"Jan-2006\")"<<std::endl;
|
||||
fout<<"Classification(\"Arrangement\",\" Conics\",\" FullCurves\",\"Rnd\",\"1\",\"Jan-2006\")"<<std::endl;
|
||||
fout<<"Classification(\"Arrangement\",\" Conics\",\" BoundedArcs\",\"Rnd\",\"1\",\"Jan-2006\")"<<std::endl;
|
||||
fout <<std::endl;
|
||||
converter(fin,fout);
|
||||
std::cout<<"convertation-finished"<<std::endl;
|
||||
fin.close();
|
||||
fout.close();
|
||||
std::cout<<"files closing-finished"<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -0,0 +1,293 @@
|
|||
#include <CGAL/basic.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <boost/variant.hpp>
|
||||
#include <CGAL/intersections.h>
|
||||
#include <CGAL/MP_Float.h>
|
||||
#include <CGAL/Circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
#include <CGAL/MP_Float.h>
|
||||
#include <CGAL/Gmpq.h>
|
||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
||||
|
||||
using namespace std;
|
||||
class Dxf_converter {
|
||||
//typedef std::pair<double, double> Point_2;
|
||||
/*
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT1;
|
||||
typedef CGAL::Cartesian<NT1> Linear_k1;
|
||||
typedef CGAL::Algebraic_kernel_2_2<NT1> Algebraic_k1;
|
||||
typedef CGAL::Curved_kernel<Linear_k1, Algebraic_k1> CircularKernel;*/
|
||||
// typedef double type;
|
||||
// typedef CGAL::Cartesian<type> NT1;
|
||||
//typedef CGAL::Quotient<CGAL::MP_Float> NT1;
|
||||
typedef CGAL::Gmpq NT1;
|
||||
// typedef CGAL::Quotient<NT1> NT1;
|
||||
typedef CGAL::Cartesian<NT1> Linear_k1;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT1> Algebraic_k1;
|
||||
typedef CGAL::Circular_kernel_2<Linear_k1, Algebraic_k1> CK;
|
||||
typedef CK::Circular_arc_point_2 Circular_arc_point_2;
|
||||
typedef CK::Line_2 Line_2;
|
||||
typedef CK::Point_2 Point_2;
|
||||
typedef CK::Circle_2 Circle_2;
|
||||
typedef std::list<std::pair<Point_2, double> > Polygon;
|
||||
typedef std::list<Polygon> Polygons;
|
||||
typedef CK::Intersect_2 Intersect_2;
|
||||
typedef CK::FT FT;
|
||||
private:
|
||||
|
||||
void
|
||||
header(std::istream& is)
|
||||
{
|
||||
int n;
|
||||
double xmin, ymin;
|
||||
double xmax, ymax;
|
||||
is >> n;
|
||||
assert(n == 9);
|
||||
char c;
|
||||
is >> c;
|
||||
assert(c == '$');
|
||||
std::string str;
|
||||
is >> str;
|
||||
if(str == std::string("EXTMIN")){
|
||||
is >> n;
|
||||
assert(n == 10);
|
||||
is >> xmin;
|
||||
is >> n;
|
||||
assert(n == 20);
|
||||
is >> ymin;
|
||||
}
|
||||
is >> n;
|
||||
assert(n == 9);
|
||||
is >> c;
|
||||
assert(c == '$');
|
||||
is >> str;
|
||||
if(str == "EXTMAX"){
|
||||
is >> n;
|
||||
assert(n == 10);
|
||||
is >> xmax;
|
||||
is >> n;
|
||||
assert(n == 20);
|
||||
is >> ymax;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
skip_header(std::istream& is)
|
||||
{
|
||||
int n;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
std::string str;
|
||||
is >> str;
|
||||
assert(str == "SECTION");
|
||||
is >> n;
|
||||
assert(n == 2);
|
||||
is >> str;
|
||||
if(str == "HEADER"){
|
||||
header(is);
|
||||
}
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
is >> str;
|
||||
assert(str == "ENDSEC");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
read_circle(std::istream& is,std::ostream& os)
|
||||
{
|
||||
int n;
|
||||
double cx, cy, r;
|
||||
std::string str;
|
||||
is >> n;
|
||||
assert(n == 8);
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
|
||||
is >> n;
|
||||
assert(n == 10);
|
||||
is >> cx;
|
||||
is >> n;
|
||||
assert(n == 20);
|
||||
is >> cy;
|
||||
is >> n;
|
||||
assert(n == 40);
|
||||
is >> r;
|
||||
NT1 x(cx),y(cy),gr(r);
|
||||
os<<"Circle_2 ("<<"Point_2("<<"Rational(" <<x.numerator()<< ", "<<x.denominator()<<")"<< ", "<<"Rational(" <<y.numerator()<< ", "<<y.denominator()<<")""),"<<"Rational(" <<gr.numerator()<< ", "<<gr.denominator()<<")"<<")"<<std::endl;
|
||||
// circ = typename K::Construct_circle_2()(Point_2(cx,cy), r*r);
|
||||
}
|
||||
|
||||
void
|
||||
write_polygon(Polygons polygons,std::ostream& os){
|
||||
|
||||
|
||||
Point_2 first_point;
|
||||
Point_2 ps;
|
||||
Point_2 pt ;
|
||||
Point_2 center;
|
||||
FT bulge;
|
||||
for( Polygons::iterator it = polygons.begin(); it != polygons.end(); it++){
|
||||
Polygon::iterator pit = it->begin();
|
||||
first_point = pit->first;
|
||||
while(true){
|
||||
ps = pit->first;
|
||||
bulge = pit->second;
|
||||
pit++;
|
||||
if(pit ==it->end()){
|
||||
break;
|
||||
}
|
||||
pt = pit->first;
|
||||
if(bulge == FT(0)){
|
||||
if(ps != pt){
|
||||
os<<"Line_arc_2("<<"Point_2("<<"Rational(" <<ps.x().numerator()<< ", "<<ps.x().denominator()<<"), "<<"Rational(" <<ps.y().numerator()<< ", "<<ps.y().denominator()<<")),"<<"Point_2("<<"Rational(" <<pt.x().numerator()<< ", "<<pt.x().denominator()<<"), "<<"Rational(" <<pt.y().numerator()<< ", "<<pt.y().denominator()<<")))"<<std::endl;
|
||||
}
|
||||
} else {
|
||||
os<<"Circular_arc_2( Point_2( Rational(" <<ps.x().numerator()<< ", "<<ps.x().denominator()<<")"<< ", "<<"Rational(" <<ps.y().numerator()<< ", "<<ps.y().denominator()<<")),"<<"Point_2("<<"Rational(" <<pt.x().numerator()<< ", "<<pt.x().denominator()<<"), "<<"Rational(" <<pt.y().numerator()<< ", "<<pt.y().denominator()<<")),"<<"Rational(" <<bulge.numerator()<< ", "<<bulge.denominator()<<"))"<<std::endl;
|
||||
// const FT sqr_bulge = CGAL::square(bulge);
|
||||
// const FT common = (FT(1) - sqr_bulge) / (FT(4)*bulge);
|
||||
// const FT x_coord = ((ps.x() + pt.x())/FT(2)) + common*(ps.y() - pt.y());
|
||||
// const FT y_coord = ((ps.y() + pt.y())/FT(2)) + common*(pt.x() - ps.x());
|
||||
// const FT sqr_rad = CGAL::squared_distance(ps, pt) * (FT(1)/sqr_bulge + FT(2) + sqr_bulge) / FT(16);
|
||||
// Circular_arc_point_2 cps = ps;
|
||||
// Circular_arc_point_2 cpt = pt;
|
||||
// os << "Circular_arc_2("<<"Circle_2 ("<<"Point_2("<< x_coord<<","<<y_coord <<"),"<<sqr_rad <<"),"<< "Point_2("<< cps.x()<<","<<cps.y() <<"),"<<"Point_2("<< cpt.x()<<","<<cpt.y() <<"))"<<std::endl;
|
||||
|
||||
//Circular_arc_2 arc = Circular_arc_2(Circle_2(Point_2(x_coord, y_coord), sqr_rad), cps, cpt);
|
||||
// os<<"Circular_arc_2("<<"Circle_2 ("<<"Point_2("<<"Rational(" <<x_coord.numerator()<< ", "<<x_coord.denominator()<<")"<< ", "<<"Rational(" <<y_coord.numerator()<< ", "<<y_coord.denominator()<<")""),"<<"Rational(" <<sqr_rad.numerator()<< ", "<<sqr_rad.denominator()<<")"<<"),"<<"Point_2("<<"Rational(" <<cps.x().numerator()<< ", "<<cps.x().denominator()<<"), "<<"Rational(" <<cps.y().numerator()<< ", "<<cps.y().denominator()<<")),"<<"Point_2("<<"Rational(" <<cpt.x().numerator()<< ", "<<cpt.x().denominator()<<"), "<<"Rational(" <<cpt.y().numerator()<< ", "<<cpt.y().denominator()<<")))"<<std::endl;
|
||||
}
|
||||
}
|
||||
if(bulge == FT(0)){
|
||||
if(ps != first_point){
|
||||
os<<"Line_arc_2("<<"Point_2("<<"Rational(" <<ps.x().numerator()<< ", "<<ps.x().denominator()<<"), "<<"Rational(" <<ps.y().numerator()<< ", "<<ps.y().denominator()<<")),"<<"Point_2("<<"Rational(" <<first_point.x().numerator()<< ", "<<first_point.x().denominator()<<"), "<<"Rational(" <<first_point.y().numerator()<< ", "<<first_point.y().denominator()<<")))"<<std::endl;
|
||||
}
|
||||
} else {
|
||||
pt = first_point;
|
||||
os<<"Circular_arc_2( Point_2( Rational(" <<ps.x().numerator()<< ", "<<ps.x().denominator()<<")"<< ", "<<"Rational(" <<ps.y().numerator()<< ", "<<ps.y().denominator()<<")),"<<"Point_2("<<"Rational(" <<pt.x().numerator()<< ", "<<pt.x().denominator()<<"), "<<"Rational(" <<pt.y().numerator()<< ", "<<pt.y().denominator()<<")),"<<"Rational(" <<bulge.numerator()<< ", "<<bulge.denominator()<<"))"<<std::endl;
|
||||
// const FT sqr_bulge = CGAL::square(bulge);
|
||||
// const FT common = (FT(1) - sqr_bulge) / (FT(4)*bulge);
|
||||
// const FT x_coord = ((ps.x() + pt.x())/FT(2)) + common*(ps.y() - pt.y());
|
||||
// const FT y_coord = ((ps.y() + pt.y())/FT(2)) + common*(pt.x() - ps.x());
|
||||
// const FT sqr_rad = CGAL::squared_distance(ps, pt) * (FT(1)/sqr_bulge + FT(2) + sqr_bulge) / FT(16);
|
||||
// Circular_arc_point_2 cps = ps;
|
||||
// Circular_arc_point_2 cpt = pt;
|
||||
/* os << "Circular_arc_2("<<"Circle_2 ("<<"Point_2("<< x_coord<<","<<y_coord <<"),"<<sqr_rad <<"),"<< "Point_2("<< cps.x()<<","<<cps.y() <<"),"<<"Point_2("<< cpt.x()<<","<<cpt.y() <<"))"<<std::endl;*/
|
||||
// os<<"Circular_arc_2("<<"Circle_2 ("<<"Point_2("<<"Rational(" <<x_coord.numerator()<< ", "<<x_coord.denominator()<<")"<< ", "<<"Rational(" <<y_coord.numerator()<< ", "<<y_coord.denominator()<<")""),"<<"Rational(" <<sqr_rad.numerator()<< ", "<<sqr_rad.denominator()<<")"<<"),"<<"Point_2("<<"Rational(" <<cps.x().numerator()<< ", "<<cps.x().denominator()<<"), "<<"Rational(" <<cps.y().numerator()<< ", "<<cps.y().denominator()<<")),"<<"Point_2("<<"Rational(" <<cpt.x().numerator()<< ", "<<cpt.x().denominator()<<"), "<<"Rational(" <<cpt.y().numerator()<< ", "<<cpt.y().denominator()<<")))"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
read_polygon(std::istream& is,Polygon& poly)
|
||||
{
|
||||
Polygons polygons;
|
||||
int n;
|
||||
int i;
|
||||
double x, y, len;
|
||||
std::string str;
|
||||
i=0;
|
||||
do {
|
||||
is >> n;
|
||||
if(n != 0){
|
||||
int m;
|
||||
is >> m;
|
||||
}
|
||||
} while(n != 0);
|
||||
|
||||
do {
|
||||
is >> str;
|
||||
if(str == "VERTEX"){
|
||||
is >> n;
|
||||
assert(n == 8);
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
is >> n;
|
||||
assert(n == 10);
|
||||
is >> x;
|
||||
is >> n;
|
||||
assert(n == 20);
|
||||
is >> y;
|
||||
is >> n;
|
||||
len = 0;
|
||||
if(n == 42){
|
||||
is >> len;
|
||||
} else {
|
||||
assert(n == 0);
|
||||
}
|
||||
//std::cout<<"Polygon"<<x<<y<<len<<std::endl;
|
||||
poly.push_back(std::make_pair(CK::Construct_point_2()(x,y), len));
|
||||
i++;
|
||||
}
|
||||
|
||||
} while (str != "SEQEND");
|
||||
is >> n;
|
||||
assert(n == 8);
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
std::cout<<i<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
read_entities(std::istream& is,std::ostream& os)
|
||||
{Polygons poly;
|
||||
int n;
|
||||
//double x, y;
|
||||
std::string str;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
is >> str;
|
||||
assert(str == "SECTION");
|
||||
is >> n;
|
||||
is >> str;
|
||||
assert(str == "ENTITIES");
|
||||
do {
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
is >> str;
|
||||
if(str == "POLYLINE"){
|
||||
Polygon p;
|
||||
poly.push_back(p);
|
||||
std::cout<< "it's polyline" <<std::endl;
|
||||
read_polygon(is, poly.back());
|
||||
} else if(str == "CIRCLE"){
|
||||
read_circle(is,os);
|
||||
} else if(str == "ENDSEC"){
|
||||
|
||||
} else {
|
||||
std::cerr << "unknown entity" << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
} while(str != "ENDSEC");
|
||||
std::cout<< "it's endsec" <<std::endl;
|
||||
is >> n;
|
||||
assert(n == 0);
|
||||
is >> str;
|
||||
assert(str == "EOF");
|
||||
std::cout << "read_entities - finished"<<std::endl;
|
||||
write_polygon(poly,os);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void operator()(std::istream& is,std::ostream& os)
|
||||
{
|
||||
skip_header(is);
|
||||
read_entities(is,os);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1 @@
|
|||
This is converter from dxf file format to bff. I was using dxf_reader for creating this stuff.
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
#include <CGAL/Random.h>
|
||||
#include <CGAL/IO/Dxf_variant_reader.h>
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_dfx(ArcContainer& arcs,char* Dfxfile){
|
||||
std::ifstream fin;
|
||||
fin.open (Dfxfile);
|
||||
typedef typename CK::Circular_arc_2 Circular_arc_2;
|
||||
typedef typename CK::Line_arc_2 Line_arc_2;
|
||||
CGAL::variant_load<CK, Circular_arc_2, Line_arc_2>(fin, std::back_inserter(arcs));
|
||||
fin.close();
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_grid(ArcContainer& ac){
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
int x = 5;
|
||||
int y = 5;
|
||||
int r = 5;
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j <20; j++){
|
||||
ac.push_back( Circle_2( Point_2(x + j*r, y + i*r), r*r));
|
||||
}
|
||||
}
|
||||
// CGAL::Random theRandom(77147);
|
||||
// double random_max = 15;
|
||||
// double random_min = -16;
|
||||
// for(int i = 0; i < 100 ; i++){
|
||||
// double x1, y1, x2, y2 = 0.0;
|
||||
// do{
|
||||
// x1 = theRandom.get_double(random_min,random_max);
|
||||
// y1 = theRandom.get_double(random_min,random_max);
|
||||
// x2 = theRandom.get_double(random_min,random_max);
|
||||
// y2 = theRandom.get_double(random_min,random_max);
|
||||
// }while ((x1 == x2) && (y1 == y2));
|
||||
// ac.push_back( Line_arc_2( Point_2(x1,y1), Point_2(x2, y2)));
|
||||
// }
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainer>
|
||||
void _bench_input_grid2(ArcContainer& ac)
|
||||
{
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
int x = 10;
|
||||
int y = 10;
|
||||
int r = 10;
|
||||
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j < 20; j++){
|
||||
ac.push_back(Circle_2( Point_2(x + j*r, y + i*r), r*r));
|
||||
}
|
||||
}
|
||||
|
||||
x += r;
|
||||
y += r;
|
||||
for(int i = 0; i < 20; i++){
|
||||
for(int j = 0; j < 20; j++){
|
||||
ac.push_back( Circle_2( Point_2(x + j*r, y + i*r), r*r));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_random(ArcContainter& arcs)
|
||||
{
|
||||
std::ofstream fout("random.inp");
|
||||
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
|
||||
CGAL::Random generatorOfgenerator;
|
||||
int random_seed = generatorOfgenerator.get_int(0, 123456);
|
||||
std::cout << "random_seed = " << random_seed << std::endl;
|
||||
|
||||
CGAL::Random theRandom(random_seed);
|
||||
// CGAL::Random theRandom(77147);
|
||||
double random_max = 10;
|
||||
double random_min = -10;
|
||||
|
||||
for(int i = 0; i < 100 ; i++){
|
||||
double x = theRandom.get_double(random_min,random_max);
|
||||
double y = theRandom.get_double(random_min,random_max);
|
||||
double r = theRandom.get_double(0.1,random_max);
|
||||
fout << x << " " << y << " " << r << " " ;
|
||||
arcs.push_back( Circle_2( Point_2(x,y), r*r));
|
||||
}
|
||||
fout.close();
|
||||
// for(int i = 0; i < 20 ; i++){
|
||||
// double x1, y1, x2, y2 = 0.0;
|
||||
// do{
|
||||
// x1 = theRandom.get_double(random_min,random_max);
|
||||
// y1 = theRandom.get_double(random_min,random_max);
|
||||
// x2 = theRandom.get_double(random_min,random_max);
|
||||
// y2 = theRandom.get_double(random_min,random_max);
|
||||
// }while ((x1 == x2) && (y1 == y2));
|
||||
// arcs.push_back( Line_arc_2( Point_2(x1,y1), Point_2(x2, y2)));
|
||||
// }
|
||||
//
|
||||
std::cout << arcs.size() << std::endl;
|
||||
|
||||
}
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_file(ArcContainter& arcs)
|
||||
{ double x,y, r;
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
|
||||
std::ifstream fin("random.inp");
|
||||
for(int i = 0; i < 100 ; i++){
|
||||
// fin >> x >> y >> r ;
|
||||
fin >> x >> y >> r ;
|
||||
arcs.push_back( Circle_2( Point_2(x,y), r*r));
|
||||
}
|
||||
fin.close();
|
||||
}
|
||||
|
||||
template <class CK,class ArcContainter>
|
||||
void _bench_input_rotation(ArcContainter& ac)
|
||||
{
|
||||
typedef typename CK::Point_2 Point_2;
|
||||
typedef typename CK::Circle_2 Circle_2;
|
||||
int x = 10;
|
||||
int y = 10;
|
||||
int r = 10;
|
||||
int R =0;
|
||||
for(int k = 0; k < 5; k++){
|
||||
for(int i = 0; i < 5; i++){
|
||||
for(int j = 0; j < 5; j++){
|
||||
R = (r+k)*(r+k);
|
||||
ac.push_back( Circle_2( Point_2(x + i*r, y + j*r),R));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,382 @@
|
|||
#ifndef ECG_BENCH_H
|
||||
#define ECG_BENCH_H
|
||||
|
||||
#include <CGAL/Interval_nt.h>
|
||||
#include <CGAL/Memory_sizer.h>
|
||||
|
||||
#include <string>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "Input_data.h"
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
class Bench
|
||||
{
|
||||
int numof_f_fails;
|
||||
std::ofstream htmlout,texout;
|
||||
struct rusage before,after;
|
||||
struct timeval utime,stime;
|
||||
bool firsttime;
|
||||
char *description;
|
||||
int vert[4],hedg[4];
|
||||
int i;
|
||||
CGAL::Memory_sizer mem_sizer;
|
||||
char* Dxffile;
|
||||
bool ONLY_DXF;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Bench( char *fhtml="benchmarks.html", char* ftex="benchmarks.tex",char* Dxffilename="",const bool only_dxf=false):
|
||||
htmlout(fhtml,std::ios::app),
|
||||
texout(ftex,std::ios::app)
|
||||
{ i=0;
|
||||
numof_f_fails= 0;
|
||||
Dxffile=Dxffilename;
|
||||
ONLY_DXF = only_dxf;
|
||||
|
||||
description = "Arrangement ";
|
||||
|
||||
std::cout << ".:Starting Bench Suite:." << std::endl;
|
||||
std::cout << "bencmarking : " << description << std::endl;
|
||||
|
||||
htmlout<<"Dxf file is : "<< Dxffile << std::endl;
|
||||
htmlout<<"<table border = \"3\">"<<std::endl;
|
||||
|
||||
if(!ONLY_DXF){
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>grid I(400 Circle_2)</td><td>grid II(800 Circle_2)</td><td>random double (100 Circle)</td><td>Dxf input. Dxf file is : "<< Dxffile <<"</td><td> rotation (125 Circle_2) </td></tr>"
|
||||
<<std::endl;
|
||||
|
||||
texout << "\\documentclass[12pt]{article}"<<std::endl
|
||||
<<"\\usepackage{amsmath}"<<std::endl
|
||||
<<"\\begin{document}"<<std::endl
|
||||
<<"\\begin{tabular}{|c|c|c|c|c|c|} \\hline $Kernel$ & grid I&grid II &random double & Dxf input. Dxf file is : "<< Dxffile <<" & rotation \\\\ \\hline"<<std::endl;
|
||||
}
|
||||
else
|
||||
{htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>Dxf input. Dxf file is : "<< Dxffile <<"</td></tr>"
|
||||
<<std::endl;
|
||||
|
||||
texout << "\\documentclass[12pt]{article}"<<std::endl
|
||||
<<"\\usepackage{amsmath}"<<std::endl
|
||||
<<"\\begin{document}"<<std::endl
|
||||
<<"\\begin{tabular}{|c|c|c|c|c|c|} \\hline $Kernel$ & & Dxf input. Dxf file is : "<< Dxffile <<" \\\\ \\hline"<<std::endl;
|
||||
}
|
||||
firsttime = true;
|
||||
}
|
||||
|
||||
~Bench()
|
||||
{
|
||||
htmlout <<"</table>"<<std::endl;
|
||||
texout << "\\end{tabular}" << std::endl
|
||||
<<"\\end{document}"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
void open_cell()
|
||||
{
|
||||
htmlout <<"<td>";
|
||||
texout<<" ";
|
||||
}
|
||||
void close_cell()
|
||||
{
|
||||
htmlout <<"</td>";
|
||||
texout <<" ";
|
||||
}
|
||||
void open_row()
|
||||
{
|
||||
htmlout <<"<tr>";
|
||||
texout <<"";
|
||||
}
|
||||
void close_row()
|
||||
{
|
||||
htmlout <<"</tr>"<< std::endl;
|
||||
texout <<"\\\\ \\hline"<< std::endl;
|
||||
}
|
||||
|
||||
void kernel(char* kernel)
|
||||
{ this->open_row();
|
||||
this->open_cell();
|
||||
htmlout << kernel;
|
||||
texout << kernel ;
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
void empty_cell()
|
||||
{
|
||||
this->open_cell();
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td>" << std::endl
|
||||
<< "<tr><td>"
|
||||
<<"-"<<"</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td><td>"
|
||||
<<"-"<< "</td></tr>"
|
||||
<< "</table></td>" ;
|
||||
texout<<"& -";
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
void infotable(){
|
||||
|
||||
texout<< "\\hline\\hline & grid I&grid II &random double & Dxf input. Dxf file is : "<< Dxffile <<" & rotation \\\\ \\hline" << std::endl
|
||||
<< "vertices" ;
|
||||
for (int k=1; k < 6 ;k++)
|
||||
{
|
||||
texout << " & "<< vert[k];
|
||||
}
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
texout<<"halfedges";
|
||||
for (int l=1; l < 6 ;l++)
|
||||
{
|
||||
texout <<" & "<< hedg[l];
|
||||
}
|
||||
texout<<"\\\\ \\hline"<<std::endl;
|
||||
}
|
||||
|
||||
void newDxfFilename(char* Dxffilename="")
|
||||
{Dxffile=Dxffilename;
|
||||
if(!ONLY_DXF){
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>grid I</td><td>grid II</td><td>random double</td><td>Dxf input. Dxf file is : "<< Dxffile <<"</td><td> rotation </td></tr>"
|
||||
<<std::endl;
|
||||
}
|
||||
else{
|
||||
htmlout<< "<tr bgcolor=\"gray\"><td>Kernel</td><td>Dxf input. Dxf file is : "<< Dxffile <<"</td> </tr>"
|
||||
<<std::endl;
|
||||
|
||||
texout <<"\\begin{tabular}{|c|c|c|c|c|c|} \\hline $Kernel$ & Dxf input. Dxf file is : "<< Dxffile <<" \\\\ \\hline"<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void start(void) {
|
||||
getrusage(RUSAGE_SELF,&before);
|
||||
|
||||
}
|
||||
void stop(void) {getrusage(RUSAGE_SELF,&after);}
|
||||
|
||||
void summarize(int vertices,int hedges)
|
||||
{
|
||||
int temp;
|
||||
temp=CGAL::Interval_nt<>::number_of_failures();
|
||||
numof_f_fails = temp - numof_f_fails;
|
||||
|
||||
std::cout << " numbers_of_filter_fails : " << numof_f_fails << std::endl;
|
||||
timersub(&(after.ru_utime),&(before.ru_utime),&utime);
|
||||
timersub(&(after.ru_stime),&(before.ru_stime),&stime);
|
||||
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td>" << std::endl
|
||||
<< "<tr><td>"
|
||||
<<utime.tv_sec<<"."<< std::setw(6) << std::setfill('0')
|
||||
<< utime.tv_usec <<"</td><td>"
|
||||
<< numof_f_fails << "</td><td>"
|
||||
<< vertices << "</td><td>"
|
||||
<< hedges<< "</td></tr>"
|
||||
<< "</table></td>";
|
||||
|
||||
texout << " & " <<utime.tv_sec<<"."<< std::setw(6) << std::setfill('0')
|
||||
<< utime.tv_usec;
|
||||
|
||||
//It's necessery to make output of number of filter fails here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
std::cout << " vertices : " << vertices << std::endl
|
||||
<< " halfedges : " << hedges << std::endl
|
||||
<< " Time (sec): " << utime.tv_sec << std::endl
|
||||
<< " (usec): " << std::setw(6) << std::setfill('0')
|
||||
<< utime.tv_usec << std::endl;
|
||||
numof_f_fails = CGAL::Interval_nt<>::number_of_failures();
|
||||
}
|
||||
|
||||
void fail(void)
|
||||
{
|
||||
htmlout << "<table border=\"1\"><tr><td>User time</td><td>Num. of fails</td><td>vertices</td><td>halfedges</td>" <<std::endl
|
||||
<< "<tr><td>"
|
||||
<<"fail"<<"</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td><td>"
|
||||
<<"fail"<< "</td></tr>"
|
||||
<< "</table></td>" ;
|
||||
texout << "&" <<"fail";
|
||||
std::cout << " :: Abort:: "<< std::endl;
|
||||
}
|
||||
|
||||
template <class Traits,class ArcContainer>
|
||||
void arrangement(const ArcContainer & ac){
|
||||
bool fail=false;
|
||||
typedef typename CGAL::Arrangement_2<Traits> Pmwx;
|
||||
typedef typename CGAL::Arr_naive_point_location<Pmwx> Point_location;
|
||||
std::cout << "memory size before construction" << mem_sizer.virtual_size() << std::endl;
|
||||
std::cout << "memory resident size before insert()" << mem_sizer.resident_size () << std::endl;
|
||||
Pmwx _pm;
|
||||
Point_location _pl(_pm);
|
||||
|
||||
std::cout << "Construction complited"<<std::endl;
|
||||
try{
|
||||
this->start();
|
||||
for (typename ArcContainer::const_iterator it=ac.begin();
|
||||
it != ac.end(); ++it) {
|
||||
insert(_pm,*it,_pl,boost::false_type());
|
||||
};
|
||||
this->stop();
|
||||
}
|
||||
catch (...) {
|
||||
this->fail();
|
||||
fail=true;
|
||||
}
|
||||
vert[i]=(int)_pm.number_of_vertices();
|
||||
hedg[i]=(int)_pm.number_of_halfedges();
|
||||
|
||||
|
||||
//_pl.~Point_location();
|
||||
// _pm.~Pmwx();<Traits, class Dcel,Point_location>
|
||||
if (!fail){this->summarize(_pm.number_of_vertices(),_pm.number_of_halfedges());}
|
||||
|
||||
_pm.clear();
|
||||
std::cout << "memory size after insert()" << mem_sizer.virtual_size () << std::endl;
|
||||
std::cout << "memory resident size after insert()" << mem_sizer.resident_size () << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void grid(){
|
||||
|
||||
i=1;
|
||||
|
||||
ArcContainer ac;
|
||||
|
||||
_bench_input_grid<CK,ArcContainer>(ac);
|
||||
|
||||
this->open_cell();
|
||||
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
|
||||
this->close_cell();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void grid2(){
|
||||
i=2;
|
||||
|
||||
ArcContainer ac;
|
||||
|
||||
_bench_input_grid2<CK,ArcContainer>(ac);
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
this->close_cell();
|
||||
}
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void random()
|
||||
{
|
||||
i=3;
|
||||
|
||||
ArcContainer ac;
|
||||
if (firsttime)
|
||||
{
|
||||
_bench_input_random<CK,ArcContainer>(ac);
|
||||
std::cout << "Input from random generator!"<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
_bench_input_file<CK,ArcContainer>(ac);
|
||||
std::cout << "Input from file!"<<std::endl;
|
||||
}
|
||||
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(ac);
|
||||
this->close_cell();
|
||||
firsttime = false;
|
||||
}
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void dfx(char* Dfxfile){
|
||||
i=4;
|
||||
|
||||
ArcContainer arc;
|
||||
_bench_input_dfx<CK,ArcContainer>(arc,Dfxfile);
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(arc);
|
||||
|
||||
this->close_cell();
|
||||
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void rotation(){
|
||||
i=5;
|
||||
|
||||
ArcContainer arc;
|
||||
try{
|
||||
|
||||
_bench_input_rotation<CK,ArcContainer>(arc);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "failed before input";
|
||||
}
|
||||
this->open_cell();
|
||||
this->arrangement<Traits,ArcContainer>(arc);
|
||||
|
||||
this->close_cell();
|
||||
|
||||
this->close_row();
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute(char* dxffile)
|
||||
{
|
||||
// this->grid<CK,Traits,ArcContainer>();
|
||||
//
|
||||
// this->grid2<CK,Traits,ArcContainer>();
|
||||
//
|
||||
// this->random<CK,Traits,ArcContainer>();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
|
||||
this->dfx<CK,Traits,ArcContainer>(dxffile);
|
||||
|
||||
// this->rotation<CK,Traits,ArcContainer>();
|
||||
this->empty_cell();
|
||||
this->close_row();
|
||||
|
||||
}
|
||||
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute_no_dxf()
|
||||
{
|
||||
this->grid<CK,Traits,ArcContainer>();
|
||||
|
||||
|
||||
this->grid2<CK,Traits,ArcContainer>();
|
||||
|
||||
this->random<CK,Traits,ArcContainer>();
|
||||
this->empty_cell();
|
||||
// this->empty_cell();
|
||||
// this->empty_cell();
|
||||
// this->empty_cell();
|
||||
// this->empty_cell();
|
||||
// this->close_row();
|
||||
this->rotation<CK,Traits,ArcContainer>();
|
||||
}
|
||||
|
||||
void empty_row()
|
||||
{ this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->empty_cell();
|
||||
this->close_row();
|
||||
|
||||
}
|
||||
template <class CK,class Traits,class ArcContainer>
|
||||
void Compute_dxf(char* dxffile)
|
||||
{
|
||||
this->dfx<CK,Traits,ArcContainer>(dxffile);
|
||||
this->close_row();
|
||||
}
|
||||
};
|
||||
|
||||
#endif //#define ECG_BENCH_H
|
||||
|
||||
|
|
@ -0,0 +1,391 @@
|
|||
#define CGAL_CAST_INT
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Handle_for.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
#include <CGAL/MP_Float.h>
|
||||
|
||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
||||
|
||||
#include <CGAL/intersections.h>
|
||||
|
||||
#include <CGAL/Circular_kernel_2.h>
|
||||
#include <CGAL/Circular_arc_traits.h>
|
||||
#include <CGAL/Circular_arc_traits_tracer.h>
|
||||
|
||||
#include <CGAL/Lazy_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Filtered_hexagon_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Filtered_bbox_circular_kernel_2.h>
|
||||
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_naive_point_location.h>
|
||||
#include <CGAL/Variant_traits.h>
|
||||
|
||||
|
||||
#include <CGAL/Random.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "benchmark.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char* Dxffilename[]={"myFirst.dxf","minimask0.dxf","minimask1.dxf","mask0.dxf","smallpainttrack.dxf","mask0_25.dxf","mask0_5.dxf","mask1.dxf","cad_l2.dxf","cad_l1.dxf"/*,"CIOnZDraw.dxf","che_mod1.dxf","elekonta.dxf","painttrack.dxf","netlist_signal_1.dxf","51.dxf"*/};
|
||||
char* Htmlfilename;
|
||||
char* Texfilename;
|
||||
char exten[4];
|
||||
int i;
|
||||
i=0;
|
||||
|
||||
|
||||
if (argv[1] != NULL)
|
||||
{
|
||||
int len =strlen(argv[1]);
|
||||
for (int j=0; j < 3 ; j++)
|
||||
{
|
||||
exten[j]=argv[1][len - 3 + j];
|
||||
}
|
||||
if (strncmp(exten,"dxf",3) !=0)
|
||||
{
|
||||
std::cout<< "File is not correct (*.dxf is needed)." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
Dxffilename[i] = argv[1];
|
||||
std::cout<< "File "<< Dxffilename[i] << " is correct."<<std::endl;
|
||||
}
|
||||
if (argc >2 and argv[2] != NULL)
|
||||
{
|
||||
int len =strlen(argv[2]);
|
||||
for (int j=0; j < 4 ; j++)
|
||||
{
|
||||
exten[j]=argv[2][len - 4 + j];
|
||||
}
|
||||
if (strncmp(exten,"html",4) !=0)
|
||||
{
|
||||
std::cout<< "File "<< argv[2] << " is not correct (*.html is needed)." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
std::cout<< "File "<< argv[2] << " is correct." <<std::endl;
|
||||
}
|
||||
if (argv[3] != NULL)
|
||||
{
|
||||
int len =strlen(argv[3]);
|
||||
for (int j=0; j < 3 ; j++)
|
||||
{
|
||||
exten[j]=argv[3][len - 3 + j];
|
||||
}
|
||||
if (strncmp(exten,"tex",3) !=0)
|
||||
{
|
||||
std::cout<< "File "<< argv[3] << " is not correct (*.tex is needed)."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
std::cout<< "File "<< argv[3] << " is correct." <<std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Htmlfilename="benchmarks.html";
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.html file is :" << Htmlfilename<< std::endl;
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Dxffilename[i]="myFirst.dxf";
|
||||
//Dxffilename[i]="CIOnZDraw.dxf";
|
||||
|
||||
//Dxffilename[]={"myFirst.dxf","minimask0.dxf","minimask1.dxf","mask0.dxf"};
|
||||
// Dxffilename[]={/*"myFirst.dxf","minimask0.dxf","minimask1.dxf","mask0.dxf","smallpainttrack.dxf","mask0_25.dxf","mask0_5.dxf","cad_l2.dxf","cad_l1.dxf",*/"CIOnZDraw.dxf","che_mod1.dxf","elekonta.dxf","painttrack.dxf","netlist_signal_1.dxf","51.dxf"};
|
||||
Htmlfilename="benchmarks.html";
|
||||
Texfilename="benchmarks.tex";
|
||||
std::cout<< "Default *.dxf file is :" << Dxffilename[i]<< std::endl;
|
||||
std::cout<< "Default *.html file is :" << Htmlfilename<< std::endl;
|
||||
std::cout<< "Default *.tex file is :" << Texfilename<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Bench bench(Htmlfilename,Texfilename,Dxffilename[i],true);
|
||||
|
||||
for(i=0;i<15;i++){
|
||||
|
||||
std::ifstream fin;
|
||||
fin.open (Dxffilename[i]);
|
||||
if (!fin.is_open())
|
||||
{
|
||||
std::cout<<"file "<< Dxffilename[i] << " is not found"<<std::endl;
|
||||
fin.close();
|
||||
return 0;
|
||||
|
||||
}
|
||||
fin.close();
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Circular_Kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT1;
|
||||
typedef CGAL::Cartesian<NT1> Linear_k1;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT1> Algebraic_k1;
|
||||
typedef CGAL::Circular_kernel_2<Linear_k1, Algebraic_k1> CircularKernel;
|
||||
/*
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<CircularKernel> CircularK_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<CircularKernel> Traits0;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0> CircularK_CA_Traits;
|
||||
#endif
|
||||
|
||||
typedef CircularKernel::Circular_arc_2 CircularKArc;
|
||||
typedef std::vector<CircularKArc> CircularKArcContainer;
|
||||
bench.kernel("Circular kernel Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<CircularKernel,CircularK_CA_Traits,CircularKArcContainer>();*/
|
||||
|
||||
|
||||
typedef CircularKernel::Circular_arc_2 Circular_arc_2;
|
||||
typedef CircularKernel::Line_arc_2 Line_arc_2;
|
||||
typedef CGAL::Variant_traits<CircularKernel,Line_arc_2,Circular_arc_2> CircularK_Variant_Traits;
|
||||
|
||||
typedef boost::variant< Circular_arc_2, Line_arc_2 > CircularKVarArc;
|
||||
typedef std::vector<CircularKVarArc> CircularKVarArcContainer;
|
||||
|
||||
bench.kernel("Circular kernel Variant traits");
|
||||
|
||||
// bench.Compute<CircularKernel,CircularK_Variant_Traits,CircularKVarArcContainer>(Dxffilename[i]);
|
||||
bench.Compute_dxf<CircularKernel,CircularK_Variant_Traits,CircularKVarArcContainer>(Dxffilename[i]);
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Lazy_curved_Kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT2;
|
||||
typedef CGAL::Cartesian<NT2> Linear_k2;
|
||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT2> Algebraic_k2;
|
||||
typedef CGAL::Circular_kernel_2<Linear_k2, Algebraic_k2> CK2_;
|
||||
|
||||
//typedef CGAL::Interval_nt<> NT2;
|
||||
typedef CGAL::Interval_nt_advanced NT3;
|
||||
typedef CGAL::Cartesian<NT3> Linear_k3;
|
||||
typedef CGAL::Algebraic_kernel_2_2<NT3> Algebraic_k3;
|
||||
typedef CGAL::Curved_kernel<Linear_k3,Algebraic_k3> CK3_;
|
||||
|
||||
|
||||
typedef CGAL::Lazy_circular_kernel_2<CK2_,CK3_> LazyCurvedK;
|
||||
|
||||
// #ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
// typedef CGAL::Circular_arc_traits<LazyCurvedK> LazyCurvedK_CA_Traits;
|
||||
// #else
|
||||
// typedef CGAL::Circular_arc_traits<LazyCurved_k> Traits0_2;
|
||||
// typedef CGAL::Circular_arc_traits_tracer<Traits0_2> LazyCurved_kTraits;
|
||||
// #endif
|
||||
//
|
||||
// typedef LazyCurvedK::Circular_arc_2 LazyArc;
|
||||
// typedef std::vector<LazyArc> LazyArcContainer;
|
||||
//
|
||||
// bench.kernel("Lazy curved kernel Circular arc traits") ;
|
||||
//
|
||||
// bench.Compute_no_dxf<LazyCurvedK,LazyCurvedK_CA_Traits,LazyArcContainer>();
|
||||
|
||||
|
||||
typedef LazyCurvedK::Circular_arc_2 Circular_arc_3;
|
||||
typedef LazyCurvedK::Line_arc_2 Line_arc_3;
|
||||
typedef boost::variant<Circular_arc_3,Line_arc_3 > LazyVarArc;
|
||||
typedef std::vector<LazyVarArc> LazyVarContainer;
|
||||
typedef CGAL::Variant_traits<LazyCurvedK,Line_arc_3,Circular_arc_3> LazyCurvedK_Variant_Traits;
|
||||
|
||||
bench.kernel("Lazy curved kernel Variant traits");
|
||||
|
||||
// bench.Compute<LazyCurvedK,LazyCurvedK_Variant_Traits,LazyVarContainer>(Dxffilename[i]);
|
||||
// bench.Compute_dxf<LazyCurvedK,LazyCurvedK_Variant_Traits,LazyVarContainer>(Dxffilename[i]);
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Filtered_hexagone_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
asdashhhhhhhhhhhhfhjhdghdf
|
||||
typedef CGAL::Filtered_hexagon_curved_kernel<CircularKernel> CircularKernelHexagon;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<CircularKernelHexagon> CircularKernHex_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<CircularKernelHexagon> Traits0_3;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_3> CircularKernHex_CA_Traits;
|
||||
#endif
|
||||
|
||||
typedef CircularKernelHexagon::Circular_arc_2 CircularKernHexArc;
|
||||
typedef std::vector<CircularKernHexArc> CircularKernHexArcContainer;
|
||||
bench.kernel("Circular kernel filtered hexagon Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<CircularKernelHexagon,CircularKernHex_CA_Traits,CircularKernHexArcContainer>();
|
||||
|
||||
|
||||
typedef CircularKernelHexagon::Circular_arc_2 Circular_arc_4;
|
||||
typedef CircularKernelHexagon::Line_arc_2 Line_arc_4;
|
||||
typedef boost::variant< Circular_arc_4, Line_arc_4 > CircularKernHexVarArc;
|
||||
typedef std::vector<CircularKernHexVarArc> CircularKernHexVarArcContainer;
|
||||
typedef CGAL::Variant_traits<CircularKernelHexagon,Circular_arc_4,Line_arc_4> CircularKernHex_Variant_Traits;
|
||||
|
||||
bench.kernel("Circular kernel filtered hexagon Variants traits");
|
||||
|
||||
bench.Compute<CircularKernelHexagon,CircularKernHex_Variant_Traits,CircularKernHexVarArcContainer>(Dxffilename[i]);
|
||||
// bench.Compute_no_dxf<CircularKernelHexagon,CircularKernHex_Variant_Traits,CircularKernHexVarArcContainer>();
|
||||
|
||||
|
||||
*/
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!Filtered_hexagone_Lazy_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Filtered_hexagon_curved_kernel<LazyCurvedK> LazyKernelHexagon;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<LazyKernelHexagon> LazyKernelHexagon_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<LazyKernelHexagon> Traits0_4;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_4> LazyKernelHexagon_CA_Traits;
|
||||
#endif
|
||||
typedef LazyKernelHexagon::Circular_arc_2 LazyKernelHexagonArc;
|
||||
typedef std::vector<LazyKernelHexagonArc> LazyKernelHexagonArcContainer;
|
||||
bench.kernel("Lazy curved kernel filtered hexagon Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<LazyKernelHexagon,LazyKernelHexagon_CA_Traits, LazyKernelHexagonArcContainer>();
|
||||
|
||||
typedef LazyKernelHexagon::Circular_arc_2 Circular_arc_5;
|
||||
typedef LazyKernelHexagon::Line_arc_2 Line_arc_5;
|
||||
typedef boost::variant<Circular_arc_5,Line_arc_5 > HxLazyVarArc;
|
||||
typedef std::vector<HxLazyVarArc> HxLazyVarContainer;
|
||||
typedef CGAL::Variant_traits<LazyKernelHexagon,Line_arc_5,Circular_arc_5> HxLazyVariantTraits;
|
||||
|
||||
bench.kernel("Lazy curved kernel filtered hexagon Variants traits") ;
|
||||
|
||||
bench.Compute<LazyKernelHexagon,HxLazyVariantTraits,HxLazyVarContainer>(Dxffilename[i]);
|
||||
//bench.Compute_no_dxf<LazyKernelHexagon,HxLazyVariantTraits,HxLazyVarContainer>();
|
||||
*/
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_filtered_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Filtered_bbox_curved_kernel<CircularKernel> BBCircularKernel ;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<BBCircularKernel> BBCircularKernel_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<BBCircularKernel> Traits0_5;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_5> BBCircularKernel_CA_Traits;
|
||||
#endif
|
||||
typedef BBCircularKernel::Circular_arc_2 BBCircularKernelArc;
|
||||
typedef std::vector<BBCircularKernelArc> BBCircularKernelArcContainer;
|
||||
bench.kernel("Circular kernel filtered bbox Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<BBCircularKernel,BBCircularKernel_CA_Traits, BBCircularKernelArcContainer>();
|
||||
|
||||
typedef BBCircularKernel::Circular_arc_2 Circular_arc_6;
|
||||
typedef BBCircularKernel::Line_arc_2 Line_arc_6;
|
||||
typedef boost::variant<Circular_arc_6,Line_arc_6 > BBCircVarArc;
|
||||
typedef std::vector<BBCircVarArc> BBCircVarContainer;
|
||||
typedef CGAL::Variant_traits<BBCircularKernel,Line_arc_6,Circular_arc_6> BBCircVariantTraits;
|
||||
|
||||
bench.kernel("Circular kernel filtered bbox Variants traits") ;
|
||||
|
||||
bench.Compute<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>(Dxffilename[i]);
|
||||
// bench.Compute_no_dxf<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>();
|
||||
*/
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_hexagone_Lazy_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Filtered_bbox_curved_kernel<LazyCurvedK> BBLazyCurvedK;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<BBLazyCurvedK> BBLazyCurvedK_CA_Traits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<BBLazyCurvedK> Traits0_6;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_6> BBLazyCurvedK_CA_Traits;
|
||||
#endif
|
||||
typedef BBLazyCurvedK::Circular_arc_2 BBLazyCurvedKArc;
|
||||
typedef std::vector<BBLazyCurvedKArc> BBLazyCurvedKArcContainer;
|
||||
bench.kernel("Lazy curved kernel filtered bbox Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<BBLazyCurvedK,BBLazyCurvedK_CA_Traits,BBLazyCurvedKArcContainer>();
|
||||
|
||||
|
||||
typedef BBLazyCurvedK::Circular_arc_2 Circular_arc_7;
|
||||
typedef BBLazyCurvedK::Line_arc_2 Line_arc_7;
|
||||
typedef boost::variant<Circular_arc_7,Line_arc_7 > BBLazyVarArc;
|
||||
typedef std::vector< BBLazyVarArc> BBLazyVarContainer;
|
||||
typedef CGAL::Variant_traits<BBLazyCurvedK,Line_arc_7,Circular_arc_7> BBLazyVariantTraits;
|
||||
|
||||
bench.kernel("Lazy curved kernel filtered bbox Variants traits") ;
|
||||
|
||||
bench.Compute<BBLazyCurvedK, BBLazyVariantTraits, BBLazyVarContainer>(Dxffilename[i]);
|
||||
//bench.Compute_no_dxf<BBLazyCurvedK, BBLazyVariantTraits, BBLazyVarContainer>();
|
||||
*/
|
||||
/*-------------------------------------------------------------------------------------------------------------------------
|
||||
!!!!!!!!!!!bbox_filtered_Filtered_hexagone_Circular_kernel!!!!!!!!!!!!!!!!!!
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
typedef CGAL::Filtered_bbox_curved_kernel<CircularKernelHexagon> BBCircKHexagon ;
|
||||
|
||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
||||
typedef CGAL::Circular_arc_traits<BBCircKHexagon> BBCircKHexagonCATraits;
|
||||
#else
|
||||
typedef CGAL::Circular_arc_traits<BBCircKHexagon> Traits0_7;
|
||||
typedef CGAL::Circular_arc_traits_tracer<Traits0_7> BBCircKHexagonCATraits;
|
||||
#endif
|
||||
typedef BBCircKHexagon::Circular_arc_2 BBCircKHexagonArc;
|
||||
typedef std::vector<BBCircKHexagon> BBCircKHexagonArcCont;
|
||||
bench.kernel("BBox Circular kernel filtered bbox Circular arc traits");
|
||||
|
||||
bench.Compute_no_dxf<BBCircKHexagon,BBCircKHexagonCATraits, BBCircKHexagonArcCont>();
|
||||
|
||||
typedef BBCircularKernelHexagon::Circular_arc_2 Circular_arc_8;
|
||||
typedef BBCircularKernelHexagon::Line_arc_2 Line_arc_8;
|
||||
typedef boost::variant<Circular_arc_8,Line_arc_8 > BBCircularKernelHexagonVarArc;
|
||||
typedef std::vector<BBCircularKernelHexagonVarArc> BBCircularKernelHexagonVarContainer;
|
||||
typedef CGAL::Variant_traits<BBCircularKernelHexagon,Line_arc_8,Circular_arc_8> BBCircularKernelHexagonVariantTraits;
|
||||
|
||||
bench.kernel("BBox Circular kernel filtered bbox Variants traits") ;
|
||||
|
||||
//bench.Compute<BBCircularKernel,BBCircVariantTraits,BBCircVarContainer>(Dxffilename[i]);
|
||||
bench.Compute_no_dxf<BBCircularKernelHexagon,BBCircularKernelHexagonVariantTraits,BBCircularKernelHexagonVarContainer>();*/
|
||||
/*--------------------------------------------------------------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------------------------------------------------------------*/
|
||||
if (i+1<15)
|
||||
{
|
||||
if (strcmp(Dxffilename[i+1],""))
|
||||
{
|
||||
bench.newDxfFilename(Dxffilename[i+1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "that's all" << Dxffilename[i+1] << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bench.infotable();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
|
@ -0,0 +1,215 @@
|
|||
\documentclass[10pt]{article}
|
||||
\usepackage{amsmath}
|
||||
|
||||
|
||||
\begin{document}
|
||||
\section{Inroduction}
|
||||
[ ... ]
|
||||
\section{Objects types for Extension of Parser}
|
||||
|
||||
We describe objects which we want to put in an extended version of Benchmark file format in the following table. The first column lists the nonterminal symbol. The second column lists grammar rules where several alternative choices are listed below each other. The third column gives a description of the object.
|
||||
|
||||
\begin{tabular}{|c|c|c|} \hline Type & syntax & description \\ \hline
|
||||
\hline\hline
|
||||
Circle\_2 & Circle\_2 (Point\_2,Rational) & Squered radius can be rational\\
|
||||
\hline
|
||||
CircularPoint\_2 & CircularPoint\_2(Point\_2) &\\
|
||||
& CircularPoint\_2(AlgebraicReal,&\\
|
||||
& AlgebraicReal) &\\
|
||||
\hline
|
||||
CircularArc\_2 & CircularArc\_2(Circle\_2) & Constructs an arc from a full circle. \\
|
||||
&CircularArc\_2(Circle\_2, &Circular\_arc\_2(Circle\_2 c,\\
|
||||
&CircularPoint\_2, &CircularPoint p1, \\
|
||||
&CircularPoint\_2) &CircularPoint p2);Constructthe\\
|
||||
& &linesegment supported by c, thatis \\
|
||||
& &oriented counterclockwise, whose \\
|
||||
& &source is p1 and whose target is p2.\\
|
||||
& &Precondition: p1 and p2 lie on c.\\
|
||||
&CircularArc\_2(Point\_2, &Circular\_arc\_2(begin, end, bulge).\\
|
||||
&Point\_2, &\\
|
||||
&Rational) &\\
|
||||
\hline
|
||||
LineArc\_2 & LineArc\_2(LineSegment) &\\
|
||||
& LineArc\_2(CircularPoint, &\\
|
||||
& CircularPoint) &\\
|
||||
& LineArc\_2(Point\_2, &\\
|
||||
& Point\_2), &\\
|
||||
|
||||
\hline
|
||||
\end{tabular}
|
||||
|
||||
\section{Extention of the Parser}
|
||||
In following we describe necessary changes to add our new tokens and rules to the parser. First, we describe new Benchmark Visitor functions. Second, we explain how to make changes in Parser source to make possible parsing our new objects.
|
||||
\subsection{New Benchmark Visitors functions}
|
||||
|
||||
In the following table are listed functions that do not exist in the Benchmark\_visitor class and must be added . The statements in curly braces \{...\} are function calls to the visitor. There are always a pair of functions that enclose the parsing parameters.
|
||||
\\
|
||||
\begin{tabular}{|c|c|} \hline Object & grammar rule with visitor function \\ \hline
|
||||
\hline\hline
|
||||
Circle\_2 &Circle\_2\{begin\_circle\_2();\}\\
|
||||
&(Point\_2,Rational)\\
|
||||
&\{end\_circle\_2();\}\\
|
||||
\hline
|
||||
CircularPoint\_2 &CircularPoint\_2\{begin\_CircularPoint\_2();\}\\
|
||||
&(Point\_2)\\
|
||||
&\{end\_circular\_CircularPoint\_2();\}\\
|
||||
&CircularPoint\_2\{begin\_CircularPoint\_2();\}\\
|
||||
&(AlgebraicReal,AlgebraicReal)\\
|
||||
&\{end\_circular\_CircularPoint\_2();\}\\
|
||||
|
||||
\hline
|
||||
|
||||
CircularArc\_2 & CircularArc\_2 \{begin\_CircularArc\_2();\}\\
|
||||
&(Circle\_2)\\
|
||||
&\{end\_CircularArc\_2();\}\\
|
||||
& CircularArc\_2 \{begin\_CircularArc\_2();\}\\
|
||||
&(Circle\_2,CircularPoint\_2,CircularPoint\_2)\\
|
||||
&\{end\_CircularArc\_2();\}\\
|
||||
& CircularArc\_2\{begin\_CircularArc\_2();\}\\
|
||||
&(Point\_2,Point\_2,Rational)\\
|
||||
&\{end\_CircularArc\_2();\}\\
|
||||
|
||||
\hline
|
||||
|
||||
LineArc\_2 &LineArc\_2\{begin\_LineArc\_2();\}\\
|
||||
&(LineSegment)\\
|
||||
&\{end\_LineArc\_2();\}\\\
|
||||
&LineArc\_2\{begin\_LineArc\_2();\}\\
|
||||
&(CircularPoint\_2,CircularPoint\_2)\\
|
||||
&\{end\_LineArc\_2();\}\\
|
||||
&LineArc\_2\{begin\_LineArc\_2();\}\\
|
||||
&(Point\_2,Point\_2)\\
|
||||
&\{end\_LineArc\_2();\}\\
|
||||
\hline
|
||||
\end{tabular}
|
||||
|
||||
\subsection{Extending of Parser by new types}
|
||||
Here we describe how to add new tokens and rules to the parser.
|
||||
\subsubsection{Extend the Scanner in benchmark\_lexer.l}
|
||||
First thing that is needed to extend parser is to put new tokens in section with Token in coments. It is looks like this:
|
||||
|
||||
\begin{verbatim}
|
||||
/* Tokens */
|
||||
/* --------- */
|
||||
"FileFormat" { return FileFormat;}
|
||||
"BenchmarkName" { return BenchmarkName; }
|
||||
.......
|
||||
\end{verbatim}
|
||||
|
||||
In the end of this section add these lines:
|
||||
|
||||
\begin{verbatim}
|
||||
"CircularArc_2" { return CircularArc_2;}
|
||||
"LineArc_2" { return LineArc_2;}
|
||||
"CircularPoint_2" {return CircularPoint_2;}
|
||||
\end{verbatim}
|
||||
|
||||
The left string is representation in file format, the right word is its indentifier in the program code.
|
||||
\subsubsection{Extended the Parser in benchmark\_parser.y}
|
||||
In a section with words Structure tokens in coments, which looks like this:
|
||||
|
||||
\begin{verbatim}
|
||||
/* Structure tokens */
|
||||
/* ---------------- */
|
||||
%token FileFormat
|
||||
%token BenchmarkName
|
||||
%token Classification
|
||||
....
|
||||
\end{verbatim}
|
||||
add anywhere new lines with new tokens:
|
||||
\begin{verbatim}
|
||||
%token CircularArc_2
|
||||
%token LineArc_2
|
||||
%token CircularPoint_2
|
||||
|
||||
\end{verbatim}
|
||||
|
||||
Now go to Grammar section and add new rules. In the and of stmt block add new lines with rules:
|
||||
|
||||
\begin{verbatim}
|
||||
| CircularPoint_2 {visitor->begin_CircularPoint_2();}
|
||||
'(' circular_arc_point ')'
|
||||
{visitor->end_CircularPoint_2();}
|
||||
| LineArc_2 {visitor->begin_LineArc_2();}
|
||||
'(' line_arc_2 ')'
|
||||
{visitor->end_LineArc_2();}
|
||||
| CircularArc_2 {visitor->begin_CircularArc_2();}
|
||||
'('circular_arc_2 ')'
|
||||
{ visitor->end_CircularArc_2();}
|
||||
\end{verbatim}
|
||||
|
||||
And after stmt block add new lines with definition for circular\_arc\_point ; line\_arc\_2 ; circular\_arc\_2 :
|
||||
|
||||
\begin{verbatim}
|
||||
circular_arc_point:
|
||||
error_rules{}
|
||||
| point_2
|
||||
| AlgebraicReal, AlgebraicReal
|
||||
;
|
||||
line_arc_2:
|
||||
error_rules {}
|
||||
| LineSegment
|
||||
| point_2 ',' point_2
|
||||
| CircularPoint_2 '(' circular_arc_point ')'
|
||||
',' CircularPoint_2 '(' circular_arc_point ')'
|
||||
;
|
||||
circular_arc_2:
|
||||
error_rules {}
|
||||
| Circle_2 '(' circle ')'
|
||||
| Circle_2 '(' circle ')' ',' CircularPoint_2 '(' circular_arc_point ')'
|
||||
',' CircularPoint_2 '(' circular_arc_point ')'
|
||||
| point_2 ',' point_2 ',' rational
|
||||
;
|
||||
\end{verbatim}
|
||||
|
||||
For add new rule for circle\_2 (Point\_2, Rational) change in stmt block this lines :
|
||||
|
||||
\begin{verbatim}
|
||||
| Circle_2 { visitor->begin_circle_2(); }
|
||||
'(' point_2 ',' INTEGER { visitor->accept_integer( $6); } ')'
|
||||
{ visitor->end_circle_2(); }
|
||||
\end{verbatim}
|
||||
|
||||
By this :
|
||||
|
||||
\begin{verbatim}
|
||||
| Circle_2 { visitor->begin_circle_2(); }
|
||||
'(' circle_2 ')' { visitor->end_circle_2(); }
|
||||
\end{verbatim}
|
||||
|
||||
And add after stmt block this lines:
|
||||
|
||||
\begin{verbatim}
|
||||
circle_2:
|
||||
error_rules {}
|
||||
| point_2 ',' rational
|
||||
| point_2 ',' INTEGER { visitor->accept_integer($3); }
|
||||
\end{verbatim}
|
||||
|
||||
\subsection{extend the Visitor in benchmark\_visitor.h}
|
||||
All what is needed for extending the Visitor is to add new virtual functions. It can be easyly made by addition
|
||||
of these lines in end of definition of benchmark\_visitor class :
|
||||
|
||||
\begin{verbatim}
|
||||
virtual void begin_CircularArc_2(){
|
||||
tnh("begin_CircularArc_2");
|
||||
}
|
||||
virtual void end_CircularArc_2(){
|
||||
tnh("end_CircularArc_2");
|
||||
}
|
||||
virtual void begin_LineArc_2(){
|
||||
tnh("begin_LineArc_2");
|
||||
}
|
||||
virtual void end_LineArc_2(){
|
||||
tnh("end_LineArc_2");
|
||||
}
|
||||
virtual void begin_CircularPoint_2(){
|
||||
tnh("begin_CircularPoint_2");
|
||||
}
|
||||
virtual void end_CircularPoint_2(){
|
||||
tnh("end_CircularPoint_2");
|
||||
}
|
||||
\end{verbatim}
|
||||
|
||||
Congratulation! Now you have extended vertion of Parser of Benchmark File format.
|
||||
\end{document}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,412 @@
|
|||
/**************************************************************************
|
||||
// Copyright (c) 2004 Max-Planck-Institut Saarbruecken (Germany)
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of BenchmarkParser; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with BenchmarkParser.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner
|
||||
**************************************************************************/
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
|
||||
/* Use C++ std::string as semantic value to communicate with lexer */
|
||||
#define YYSTYPE std::string
|
||||
#include <benchmark_parser.tab.h> // gets definitions from syntax parser
|
||||
|
||||
// Public lexer interface, check with decl. in benchmark_parser.h
|
||||
// --------------------------------------------------------------
|
||||
|
||||
// Current input stream and associated values.
|
||||
std::istream* benchmark_in = & std::cin;
|
||||
int benchmark_linenumber = 1;
|
||||
std::string benchmark_filename( "<cin>");
|
||||
|
||||
// Initialize lexer to scan from input stream with name and linenumber.
|
||||
// The caller is responsible for the lifetime of 'in' that must live
|
||||
// during the scan.
|
||||
void benchmark_init_lexer(
|
||||
std::istream& in, std::string name, int linenumber = 1);
|
||||
|
||||
// Reset lexer to clean state.
|
||||
void benchmark_reset_lexer();
|
||||
|
||||
// Writes a trace of the current include file nesting to the 'out' stream.
|
||||
// Appends the 'fill' string after each file listed.
|
||||
void benchmark_include_file_trace( std::ostream& out, std::string fill);
|
||||
|
||||
|
||||
// Private lexer interface, all static to keep it local
|
||||
// ----------------------------------------------------
|
||||
|
||||
// Stack of input streams: the item stored in the stack.
|
||||
struct Include_stack_item {
|
||||
std::istream* in; // input stream
|
||||
int linenumber; // linenumber in file for error messages
|
||||
std::string filename; // filename (or similar string)
|
||||
YY_BUFFER_STATE buffer; // Opaque pointer to flex-buffer struct.
|
||||
Include_stack_item() {}
|
||||
Include_stack_item( std::istream* i, int ln, std::string name,
|
||||
YY_BUFFER_STATE buf)
|
||||
: in(i), linenumber(ln), filename(name), buffer(buf) {}
|
||||
};
|
||||
|
||||
// Stack of input streams is a std::list
|
||||
typedef std::list<Include_stack_item> Include_stack;
|
||||
|
||||
// We have one static global variable for the stack and some static functions.
|
||||
// The include stack is except for the trace() debug function not
|
||||
// accessible from other files (is not polluting namespaces) since
|
||||
// the Include() function and the <<EOF>> condition are all handled here.
|
||||
// The function implementations are at the end of this file.
|
||||
static Include_stack include_stack;
|
||||
|
||||
// Push current state on include_stack, initializes lexer with new file
|
||||
// input stream, name, and linenumber.
|
||||
static void open_include_stream(
|
||||
std::istream *in, std::string name, int linenumber = 1);
|
||||
|
||||
// Shortcut for open file with name and then call open_include_stream.
|
||||
// Returns false if the file could not be opened successfully.
|
||||
static bool open_include_file( std::string name, int linenumber = 1);
|
||||
|
||||
// Closes current input stream. Initializes lexer with new file input stream,
|
||||
// name, and linenumber, from the include_stack's top. Pop's an element from
|
||||
// the include_stack. Returns false if include_stack was empty.
|
||||
static bool close_include_stream();
|
||||
|
||||
|
||||
// Make the lexer read from benchmark_in instead of yyin
|
||||
#define YY_INPUT(buf,result,max_size) { \
|
||||
benchmark_in->read( buf, max_size); \
|
||||
result = benchmark_in->gcount(); \
|
||||
}
|
||||
|
||||
// Count newlines in the string s
|
||||
static void count_newlines( const char* s) {
|
||||
while ( *s) {
|
||||
if ( *s == '\n')
|
||||
++benchmark_linenumber;
|
||||
++s;
|
||||
}
|
||||
}
|
||||
|
||||
static int comment_nesting = 0; // counts nesting depth of () in Comments
|
||||
|
||||
#define YY_BREAK /* a do nothing */
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
Parsing Modes:
|
||||
-- INITIAL: main mode for sequence of tokens
|
||||
-- IncludeMode: parses lciInclude filename,
|
||||
-- CommentMode: Comment(...) parsing of nested parantheses
|
||||
# comments and strings are correctly ignored
|
||||
-------------------------------------------------------------------- */
|
||||
%}
|
||||
|
||||
%x IncludeMode
|
||||
%x CommentMode
|
||||
|
||||
space [\t \r]*
|
||||
newline [\n]
|
||||
spcnl [\t \n\r]*
|
||||
integer [+-]?[0-9]+
|
||||
/* An fnumber consists of up to three parts:
|
||||
* 1) a sign [+-]
|
||||
* 2) a mantissa (digits [0-9] with at most one dot in between)
|
||||
* 3) an exponent [eE]{integer}
|
||||
*
|
||||
* Part 1) is optional.
|
||||
* Part 2) must contain at least one digit,
|
||||
* but may have leading or trailing dot
|
||||
* Part 3) is optional iff the mantissa contains a dot
|
||||
* (so that fnumbers and integers remain distinguishable).
|
||||
*/
|
||||
fnumber [+-]?(([0-9]+[.][0-9]*|[.][0-9]+)([eE]{integer})?|[0-9]+[eE]{integer})
|
||||
idfier [a-zA-Z][a-zA-Z0-9_]*
|
||||
minus_infty MINUS_INFTY
|
||||
plus_infty PLUS_INFTY
|
||||
filename [^ \t\n\r\\\{\}\[\]()]+
|
||||
void VOID
|
||||
counterclockwise COUNTERCLOCKWISE
|
||||
clockwise CLOCKWISE
|
||||
|
||||
%%
|
||||
/* Tokens */
|
||||
/* --------- */
|
||||
"FileFormat" { return FileFormat;}
|
||||
"BenchmarkName" { return BenchmarkName; }
|
||||
"Classification" { return Classification; }
|
||||
"List" { return List; }
|
||||
"Rational" { return Rational; }
|
||||
"Polynomial_1" { return Polynomial_1; }
|
||||
"Point_2" { return Point_2; }
|
||||
"AlgebraicReal" { return AlgebraicReal; }
|
||||
|
||||
|
||||
"ConicPoint_2" { return ConicPoint_2; }
|
||||
"Conic_2" { return Conic_2; }
|
||||
|
||||
|
||||
"ConicArc_2" { return ConicArc_2; }
|
||||
"Circle_2" { return Circle_2; }
|
||||
"LineSegment_2" { return LineSegment_2; }
|
||||
"Cubic_2" { return Cubic_2; }
|
||||
"CircularArc_2" { return CircularArc_2;}
|
||||
"LineArc_2" { return LineArc_2;}
|
||||
"CircularPoint_2" {return CircularPoint_2;}
|
||||
"Quadric_3" { return Quadric_3; }
|
||||
|
||||
|
||||
/* Integer numbers and float numbers */
|
||||
/* --------------------------------- */
|
||||
{integer} { yylval = std::string( yytext);
|
||||
return INTEGER;
|
||||
}
|
||||
{fnumber} { yylval = std::string( yytext);
|
||||
return FNUMBER;
|
||||
}
|
||||
{minus_infty} { yylval = std::string( yytext);
|
||||
return MINUS_INFTY;
|
||||
}
|
||||
{plus_infty} { yylval = std::string( yytext);
|
||||
return PLUS_INFTY;
|
||||
}
|
||||
{void} { yylval = std::string( yytext);
|
||||
return VOID;
|
||||
}
|
||||
{counterclockwise} { yylval = std::string( yytext);
|
||||
return COUNTERCLOCKWISE;
|
||||
}
|
||||
{clockwise} { yylval = std::string( yytext);
|
||||
return CLOCKWISE;
|
||||
}
|
||||
|
||||
|
||||
/* Non-recognized tokens are errors */
|
||||
/* -------------------------------- */
|
||||
{idfier} { yylval = std::string( yytext);
|
||||
return UNKNOWN_TOKEN;
|
||||
}
|
||||
|
||||
/* Handle include files */
|
||||
/* ------------------------- */
|
||||
"IncludeFile"{spcnl}[(]{spcnl} { BEGIN( IncludeMode);
|
||||
count_newlines( yytext);
|
||||
break;
|
||||
}
|
||||
<IncludeMode>{filename} { /* remove remaining chars before the ')' */
|
||||
int c = yyinput();
|
||||
while( c != EOF && c != ')') {
|
||||
if ( c == '\n')
|
||||
++benchmark_linenumber;
|
||||
c = yyinput();
|
||||
}
|
||||
BEGIN( INITIAL);
|
||||
if ( c == EOF) {
|
||||
yylval = std::string( "Reached EOF while"
|
||||
" parsing include filename '") +
|
||||
std::string( yytext) +
|
||||
std::string( "'.");
|
||||
return ERROR;
|
||||
}
|
||||
open_include_file( yytext);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Strings with quoted \" and \\ */
|
||||
/* ------------------------------ */
|
||||
<INITIAL,CommentMode>"\"" { int c = yyinput();
|
||||
yylval = std::string("");
|
||||
bool quoted_char = false;
|
||||
while (c != EOF && (c!='"' || quoted_char)){
|
||||
if ( c == '\n')
|
||||
++benchmark_linenumber;
|
||||
if ( ! quoted_char && c == '\\') {
|
||||
quoted_char = true;
|
||||
} else {
|
||||
quoted_char = false;
|
||||
yylval.push_back( char(c));
|
||||
}
|
||||
c = yyinput();
|
||||
}
|
||||
if ( c == EOF) {
|
||||
yylval = std::string( "Reached EOF while"
|
||||
" parsing string constant '") +
|
||||
yylval + std::string( "'.");
|
||||
BEGIN( INITIAL);
|
||||
return ERROR;
|
||||
}
|
||||
if ( YY_START == INITIAL) {
|
||||
return STRING;
|
||||
}
|
||||
yylval = std::string("");
|
||||
break;
|
||||
}
|
||||
|
||||
/* One line comment starting with # */
|
||||
/* -------------------------------- */
|
||||
<INITIAL,CommentMode>"#" { /* remove remaining chars before the '\n' */
|
||||
int c = yyinput();
|
||||
while( c != EOF && c != '\n') {
|
||||
c = yyinput();
|
||||
}
|
||||
if ( c == '\n')
|
||||
++benchmark_linenumber;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Nestable and multi-line Comment( ... ) */
|
||||
/* -------------------------------------- */
|
||||
"Comment"{spcnl}"("{spcnl} { BEGIN( CommentMode);
|
||||
comment_nesting = 1;
|
||||
count_newlines( yytext);
|
||||
break;
|
||||
}
|
||||
|
||||
<CommentMode>{newline} { ++benchmark_linenumber; break; }
|
||||
|
||||
<CommentMode>"(" { ++comment_nesting; break; }
|
||||
|
||||
<CommentMode>")" { if ( --comment_nesting == 0)
|
||||
BEGIN( INITIAL);
|
||||
break;
|
||||
}
|
||||
|
||||
<CommentMode><<EOF>> { yylval = std::string( "Reached EOF while "
|
||||
"parsing 'Comment(...)'.");
|
||||
BEGIN( INITIAL);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
<CommentMode>. { break; }
|
||||
|
||||
/* Count line numbers for good error messages */
|
||||
{newline} { ++benchmark_linenumber; break; }
|
||||
|
||||
/* Ignore white spaces */
|
||||
{space} { break; }
|
||||
|
||||
/* stop scanning at EOF, maybe continue with surrounding file */
|
||||
<<EOF>> { yyterminate(); }
|
||||
|
||||
/* single characters passed to the parser: */
|
||||
[(),] { return yytext[0]; }
|
||||
|
||||
/* all other single characters are errors */
|
||||
. { yylval = std::string( "Found illegal char '")
|
||||
+ std::string( yytext) + std::string("'.");
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
// implements the proper EOF behavior, pop's file from include stack
|
||||
extern "C" int yywrap() {
|
||||
if ( close_include_stream())
|
||||
return 0; // there was a file waiting on the stack, we continue scan
|
||||
return 1; // no file in the stack left, we stop scan
|
||||
}
|
||||
|
||||
// Push current state on include_stack, initializes lexer with new file
|
||||
// input stream, name, and linenumber.
|
||||
static void open_include_stream( std::istream *in, std::string name,
|
||||
int linenumber)
|
||||
{
|
||||
include_stack.push_front( Include_stack_item(
|
||||
benchmark_in, benchmark_linenumber, benchmark_filename,
|
||||
YY_CURRENT_BUFFER));
|
||||
benchmark_in = in;
|
||||
benchmark_linenumber = linenumber;
|
||||
benchmark_filename = name;
|
||||
yy_switch_to_buffer( yy_create_buffer( 0, YY_BUF_SIZE));
|
||||
}
|
||||
|
||||
// Shortcut for open file with name and then call open_include_stream.
|
||||
// Returns false if the file could not be opened successfully.
|
||||
static bool open_include_file( std::string name, int linenumber) {
|
||||
std::ifstream* in = new std::ifstream( name.c_str());
|
||||
if ( ! *in) {
|
||||
delete in;
|
||||
return false;
|
||||
}
|
||||
open_include_stream( in, name, linenumber);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Closes current input stream. Initializes lexer with new file input stream,
|
||||
// name, and linenumber, from the include_stack's top. Pop's an element from
|
||||
// the include_stack. Returns false if include_stack was empty.
|
||||
static bool close_include_stream() {
|
||||
if ( include_stack.empty())
|
||||
return false;
|
||||
delete benchmark_in; // closes the stream
|
||||
benchmark_in = include_stack.front().in;
|
||||
benchmark_linenumber = include_stack.front().linenumber;
|
||||
benchmark_filename = include_stack.front().filename;
|
||||
yy_delete_buffer( YY_CURRENT_BUFFER);
|
||||
yy_switch_to_buffer( include_stack.front().buffer);
|
||||
include_stack.pop_front();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Public interface of the lexer component
|
||||
// ---------------------------------------
|
||||
|
||||
// Initialize lexer to scan from input stream with name and linenumber.
|
||||
// The caller is responsible for the lifetime of 'in' that must last
|
||||
// during the scan.
|
||||
void benchmark_init_lexer(
|
||||
std::istream& in, std::string name, int linenumber)
|
||||
{
|
||||
benchmark_reset_lexer();
|
||||
benchmark_in = & in;
|
||||
benchmark_linenumber = linenumber;
|
||||
benchmark_filename = name;
|
||||
yy_switch_to_buffer( yy_create_buffer( 0, YY_BUF_SIZE));
|
||||
}
|
||||
|
||||
// reset lexer to clean state. Can be used to parse another file then.
|
||||
void benchmark_reset_lexer() {
|
||||
while( close_include_stream()) // close all pre-existing include files
|
||||
; // empty while body
|
||||
benchmark_in = & std::cin;
|
||||
benchmark_linenumber = 1;
|
||||
benchmark_filename = std::string("<cin>");
|
||||
yyrestart(0);
|
||||
BEGIN( INITIAL);
|
||||
};
|
||||
|
||||
// Writes a trace of the current include file nesting to the 'out' stream.
|
||||
void benchmark_include_file_trace( std::ostream& out, std::string fill) {
|
||||
std::size_t n = include_stack.size();
|
||||
for ( Include_stack::const_iterator i = include_stack.begin();
|
||||
i != include_stack.end(); ++i)
|
||||
{
|
||||
out << std::setw(3) << n-- << ": '" << i->filename << "' line "
|
||||
<< i->linenumber << fill << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// This summy function is only here to suppress a warning for
|
||||
// an unused yyunput function
|
||||
void benchmark_parser_dummy_no_warn_() {
|
||||
yyunput( 1, 0);
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,74 @@
|
|||
/**************************************************************************
|
||||
// Copyright (c) 2004 Max-Planck-Institut Saarbruecken (Germany)
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of BenchmarkParser; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with BenchmarkParser.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef BENCHMARK_PARSER_H
|
||||
#define BENCHMARK_PARSER_H
|
||||
|
||||
#include <string>
|
||||
#include <benchmark_visitor.h>
|
||||
|
||||
// Magic name and file version number
|
||||
// ----------------------------------
|
||||
// The name and the version number <major.minor> of the benchmark file format.
|
||||
// If the file has a different format name, it is rejected. If the
|
||||
// Major number in the file is higher than the major number listed
|
||||
// here then the file is also rejected. If the <major.minor> number
|
||||
// in the file is lower than the the number listed here, the parser
|
||||
// assumes backwards compatibility and continues parsing.
|
||||
const std::string BENCHMARK_FORMAT_NAME( "AcsBenchmark");
|
||||
const int BENCHMARK_FORMAT_MAJOR = 0;
|
||||
const int BENCHMARK_FORMAT_MINOR = 1;
|
||||
|
||||
|
||||
// Public interface of the parser component
|
||||
// ----------------------------------------
|
||||
|
||||
// Opens file 'name' and parses it. Uses visitor 'v' while parsing.
|
||||
// Returns false if something went wrong. See the visitor for details
|
||||
// of the error reporting.
|
||||
bool benchmark_parse_file( std::string name, Benchmark_visitor* v);
|
||||
|
||||
// Starts parsing from stream 'in' with the associated filename 'name'
|
||||
// (or analogous meaning for different streams) counting linenumbers
|
||||
// starting from 'n'. Uses visitor 'v' while parsing. Returns false if
|
||||
// something went wrong. See the visitor for details of the error reporting.
|
||||
bool benchmark_parse_stream( std::istream& in, std::string name,
|
||||
Benchmark_visitor* v, int n = 1);
|
||||
|
||||
|
||||
// Public interface of the lexer component
|
||||
// ---------------------------------------
|
||||
// Current input stream and associated values. READ ONLY! Do not modify them!
|
||||
// The lexer works with internal buffers and would not sync properly!
|
||||
extern int benchmark_linenumber;
|
||||
extern std::string benchmark_filename;
|
||||
|
||||
// Initialize lexer to scan from input stream with name and linenumber.
|
||||
// The caller is responsible for the lifetime of 'in' that must live
|
||||
// during the scan. Used by benchmark_parse_file and does not have to
|
||||
// be called separately.
|
||||
void benchmark_init_lexer(
|
||||
std::istream& in, std::string name, int linenumber = 1);
|
||||
|
||||
// Writes a trace of the current include file nesting to the 'out' stream.
|
||||
// Appends the 'fill' string after each file listed.
|
||||
void benchmark_include_file_trace( std::ostream& out, std::string fill);
|
||||
|
||||
|
||||
#endif // BENCHMARK_PARSER_H //
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/* A Bison parser, made by GNU Bison 1.875c. */
|
||||
|
||||
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, when this file is copied by Bison into a
|
||||
Bison output file, you may use that output file without restriction.
|
||||
This special exception was added by the Free Software Foundation
|
||||
in version 1.24 of Bison. */
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
INTEGER = 258,
|
||||
FNUMBER = 259,
|
||||
STRING = 260,
|
||||
ERROR = 261,
|
||||
UNKNOWN_TOKEN = 262,
|
||||
MINUS_INFTY = 263,
|
||||
PLUS_INFTY = 264,
|
||||
COUNTERCLOCKWISE = 265,
|
||||
CLOCKWISE = 266,
|
||||
VOID = 267,
|
||||
FileFormat = 268,
|
||||
BenchmarkName = 269,
|
||||
Classification = 270,
|
||||
List = 271,
|
||||
Rational = 272,
|
||||
Polynomial_1 = 273,
|
||||
Point_2 = 274,
|
||||
AlgebraicReal = 275,
|
||||
ConicPoint_2 = 276,
|
||||
LineSegment_2 = 277,
|
||||
Conic_2 = 278,
|
||||
CircularArc_2 = 279,
|
||||
LineArc_2 = 280,
|
||||
CircularPoint_2 = 281,
|
||||
ConicArc_2 = 282,
|
||||
Circle_2 = 283,
|
||||
Cubic_2 = 284,
|
||||
Quadric_3 = 285
|
||||
};
|
||||
#endif
|
||||
#define INTEGER 258
|
||||
#define FNUMBER 259
|
||||
#define STRING 260
|
||||
#define ERROR 261
|
||||
#define UNKNOWN_TOKEN 262
|
||||
#define MINUS_INFTY 263
|
||||
#define PLUS_INFTY 264
|
||||
#define COUNTERCLOCKWISE 265
|
||||
#define CLOCKWISE 266
|
||||
#define VOID 267
|
||||
#define FileFormat 268
|
||||
#define BenchmarkName 269
|
||||
#define Classification 270
|
||||
#define List 271
|
||||
#define Rational 272
|
||||
#define Polynomial_1 273
|
||||
#define Point_2 274
|
||||
#define AlgebraicReal 275
|
||||
#define ConicPoint_2 276
|
||||
#define LineSegment_2 277
|
||||
#define Conic_2 278
|
||||
#define CircularArc_2 279
|
||||
#define LineArc_2 280
|
||||
#define CircularPoint_2 281
|
||||
#define ConicArc_2 282
|
||||
#define Circle_2 283
|
||||
#define Cubic_2 284
|
||||
#define Quadric_3 285
|
||||
|
||||
|
||||
|
||||
|
||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||
typedef int YYSTYPE;
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,361 @@
|
|||
/**************************************************************************
|
||||
// Copyright (c) 2004 Max-Planck-Institut Saarbruecken (Germany)
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of BenchmarkParser; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with BenchmarkParser.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner
|
||||
// Franziska Ebert <febert@mpi-sb.mpg.de>
|
||||
**************************************************************************/
|
||||
|
||||
%{
|
||||
/* C/C++ declaration section */
|
||||
/* ========================= */
|
||||
//#include <cstdlib> /* for atoi */
|
||||
#include <string> /* for std::string */
|
||||
#include <fstream> /* for std::ifstream */
|
||||
#include <benchmark_parser.h>
|
||||
#include <benchmark_visitor.h>
|
||||
#include <iostream>
|
||||
static Benchmark_visitor* visitor; /* global visitor used during parsing */
|
||||
|
||||
/* declaration for flex parser call yylex */
|
||||
int yylex( void);
|
||||
|
||||
/* error function called for parse errors */
|
||||
void yyerror( char *s) { visitor->parse_error( std::string(s)); }
|
||||
|
||||
/* Use C++ std::string as semantic value to communicate with lexer */
|
||||
#define YYSTYPE std::string
|
||||
|
||||
// Public parser interface, check with decl. in benchmark_parser.h
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
// Opens file 'name' and parses it. Uses visitor 'v' while parsing.
|
||||
// Returns false if something went wrong. See the visitor for details.
|
||||
bool benchmark_parse_file( std::string name, Benchmark_visitor* v);
|
||||
|
||||
// Starts parsing from stream 'in' with the associated filename 'name'
|
||||
// (or analogous meaning for different streams) counting linenumbers
|
||||
// starting from 'n'. Uses visitor 'v' while parsing. Returns false if
|
||||
// something went wrong. See the visitor for details of the error reporting.
|
||||
bool benchmark_parse_stream( std::istream& in, std::string name,
|
||||
Benchmark_visitor* v, int n);
|
||||
|
||||
%}
|
||||
|
||||
/* Elementary data types */
|
||||
/* --------------------- */
|
||||
%token INTEGER
|
||||
%token FNUMBER
|
||||
%token STRING
|
||||
%token ERROR
|
||||
%token UNKNOWN_TOKEN
|
||||
%token MINUS_INFTY
|
||||
%token PLUS_INFTY
|
||||
%token COUNTERCLOCKWISE
|
||||
%token CLOCKWISE
|
||||
%token VOID
|
||||
|
||||
/* Structure tokens */
|
||||
/* ---------------- */
|
||||
%token FileFormat
|
||||
%token BenchmarkName
|
||||
%token Classification
|
||||
|
||||
%token List
|
||||
%token Rational
|
||||
%token Polynomial_1
|
||||
%token Point_2
|
||||
%token AlgebraicReal
|
||||
|
||||
|
||||
%token ConicPoint_2
|
||||
%token LineSegment_2
|
||||
%token Conic_2
|
||||
|
||||
%token CircularArc_2
|
||||
%token LineArc_2
|
||||
%token CircularPoint_2
|
||||
|
||||
%token ConicArc_2
|
||||
%token Circle_2
|
||||
%token Cubic_2
|
||||
|
||||
|
||||
%token Quadric_3
|
||||
|
||||
|
||||
%%
|
||||
/* Grammar */
|
||||
/* ======= */
|
||||
|
||||
input: /* an input is a potentially empty sequence of files */
|
||||
/* empty */
|
||||
| error { /* parse error restart here */ }
|
||||
| input file
|
||||
;
|
||||
|
||||
file: /* must start with unique header */
|
||||
file_format file_header_options file_classification file_body
|
||||
;
|
||||
|
||||
file_format: /* mandatory fileformat descriptor */
|
||||
error_rules {}
|
||||
| FileFormat '(' STRING ',' INTEGER ',' INTEGER ')'
|
||||
{ visitor->accept_file_format( $3,
|
||||
atoi( $5.c_str()), atoi( $7.c_str()),
|
||||
std::string("")); }
|
||||
| FileFormat '(' STRING ',' INTEGER ',' INTEGER ',' STRING ')'
|
||||
{ visitor->accept_file_format( $3,
|
||||
atoi( $5.c_str()), atoi( $7.c_str()),
|
||||
$9); }
|
||||
;
|
||||
|
||||
file_header_options: /* sequence of optional file header entries */
|
||||
/* empty */
|
||||
| file_header_options file_header_option
|
||||
;
|
||||
|
||||
file_header_option: /* single optional file header entry */
|
||||
BenchmarkName '(' STRING ')' { visitor->accept_benchmark_name( $3); }
|
||||
;
|
||||
|
||||
file_classification: /* */
|
||||
error_rules {}
|
||||
| classificat
|
||||
| file_classification classificat
|
||||
;
|
||||
|
||||
classificat: /* */
|
||||
Classification '(' STRING ',' STRING ',' STRING ',' STRING ','
|
||||
STRING ',' STRING ')'
|
||||
{ visitor->accept_classification( $3, $5, $7,
|
||||
$9, $11, $13); }
|
||||
;
|
||||
|
||||
file_body: /* sequence of statements (stmt) */
|
||||
/* empty */
|
||||
| file_body stmt
|
||||
;
|
||||
|
||||
stmt_sequence: /* comma separated sequence of statements (stmt) */
|
||||
/* empty */
|
||||
| stmt_sequence_non_empty
|
||||
;
|
||||
|
||||
stmt_sequence_non_empty: /* comma separated sequence of statements (stmt) */
|
||||
stmt
|
||||
| stmt_sequence_non_empty ',' stmt
|
||||
;
|
||||
|
||||
stmt:
|
||||
error { /* parse error restart here */ }
|
||||
error_rules {}
|
||||
| List { visitor->begin_list(); }
|
||||
'(' stmt_sequence ')' { visitor->end_list(); }
|
||||
| Circle_2 { visitor->begin_circle_2(); }
|
||||
'(' circle_2 ')' { visitor->end_circle_2(); }
|
||||
| Conic_2 conic_2
|
||||
| LineSegment_2 { visitor->begin_line_segment_2(); }
|
||||
'(' point_2 ',' point_2 ')'
|
||||
{ visitor->end_line_segment_2(); }
|
||||
| ConicArc_2 conic_arc_2
|
||||
|
||||
| Cubic_2 '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ','
|
||||
INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')'
|
||||
{ visitor->accept_cubic_2( $3, $5, $7, $9,
|
||||
$11, $13, $15,
|
||||
$17, $19, $21); }
|
||||
| Quadric_3 '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ','
|
||||
INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')'
|
||||
{ visitor->accept_quadric_3( $3, $5, $7, $9,
|
||||
$11, $13, $15,
|
||||
$17, $19, $21); }
|
||||
|
||||
| CircularPoint_2 {visitor->begin_CircularPoint_2();}
|
||||
'('circular_arc_point')'
|
||||
{visitor->end_CircularPoint_2();}
|
||||
| LineArc_2 {visitor->begin_LineArc_2();}
|
||||
'('line_arc_2')'
|
||||
{visitor->end_LineArc_2();}
|
||||
|CircularArc_2 { visitor->begin_CircularArc_2();}
|
||||
'('circular_arc_2 ')'
|
||||
{ visitor->end_CircularArc_2();}
|
||||
;
|
||||
circular_arc_point:
|
||||
circular_arc_point:
|
||||
error_rules{}
|
||||
| point_2
|
||||
| AlgebraicReal ',' AlgebraicReal
|
||||
;
|
||||
line_arc_2:
|
||||
error_rules {}
|
||||
| LineSegment_2
|
||||
| point_2 ',' point_2
|
||||
| CircularPoint_2 '(' circular_arc_point ')'
|
||||
',' CircularPoint_2 '(' circular_arc_point ')'
|
||||
;
|
||||
circular_arc_2:
|
||||
error_rules {}
|
||||
| Circle_2 '(' circle_2 ')'
|
||||
| Circle_2 '(' circle_2 ')' ',' CircularPoint_2 '(' circular_arc_point ')'
|
||||
',' CircularPoint_2 '(' circular_arc_point ')'
|
||||
| point_2 ',' point_2 ',' rational
|
||||
;
|
||||
circle_2:
|
||||
error_rules {}
|
||||
| point_2 ',' rational
|
||||
| point_2 ',' INTEGER { visitor->accept_integer($3); }
|
||||
|
||||
;
|
||||
conic_2: /* */
|
||||
error_rules {}
|
||||
|
||||
| '(' INTEGER ',' INTEGER ',' INTEGER ','
|
||||
INTEGER ',' INTEGER ',' INTEGER ')'
|
||||
{ visitor->accept_conic_2( $2, $4, $6,
|
||||
$8, $10, $12); }
|
||||
|
||||
|
||||
;
|
||||
conic_arc_2: /* */
|
||||
error_rules {}
|
||||
| '(' Conic_2 { visitor->begin_conic_arc_2(); }
|
||||
conic_2
|
||||
',' ConicPoint_2 conic_point_2
|
||||
',' ConicPoint_2 conic_point_2
|
||||
',' orientation { visitor->accept_orientation( $12); }
|
||||
')'
|
||||
{ visitor->end_conic_arc_2(); }
|
||||
|
||||
|
||||
| '(' ConicPoint_2 { visitor->begin_conic_arc_2(); }
|
||||
conic_point_2 ')'
|
||||
{ visitor->end_conic_arc_2(); }
|
||||
|
||||
;
|
||||
|
||||
integer_sequence1: /* comma separated integers */
|
||||
error_rules {}
|
||||
| INTEGER { visitor->accept_integer( $1); }
|
||||
| integer_sequence1 ',' INTEGER { visitor->accept_integer( $3); }
|
||||
;
|
||||
|
||||
|
||||
point_2: /* a 2d point */
|
||||
error_rules {}
|
||||
| Point_2 '(' INTEGER ',' INTEGER ')'
|
||||
{ visitor->accept_point_2( $3, $5); }
|
||||
| Point_2 '(' INTEGER ',' INTEGER ',' INTEGER ')'
|
||||
{ visitor->accept_point_2( $3, $5, $7); }
|
||||
| Point_2 '(' Rational '(' INTEGER ',' INTEGER ')' ','
|
||||
Rational '(' INTEGER ',' INTEGER ')' ')'
|
||||
{ visitor->accept_point_2( $5, $7,
|
||||
$12, $14); }
|
||||
;
|
||||
|
||||
conic_point_2: /* */
|
||||
error_rules {}
|
||||
| '(' Conic_2 { visitor->begin_conic_point_2();}
|
||||
conic_2
|
||||
',' algorint
|
||||
')' { visitor->end_conic_point_2(); }
|
||||
|
||||
;
|
||||
|
||||
algorint: /* */
|
||||
error_rules {}
|
||||
| algebraic_real ',' inti
|
||||
| infty ',' INTEGER { visitor->accept_infty( $1);
|
||||
visitor->accept_integer( $3); }
|
||||
;
|
||||
|
||||
|
||||
algebraic_real: /* */
|
||||
error_rules {}
|
||||
| AlgebraicReal { visitor->begin_algebraic_real(); }
|
||||
'(' Polynomial_1 { visitor->begin_polynomial_1(); }
|
||||
'(' integer_sequence1 ')'
|
||||
{ visitor->end_polynomial_1(); }
|
||||
|
||||
',' rational
|
||||
',' rational
|
||||
',' INTEGER { visitor->accept_integer($15); }
|
||||
')' { visitor->end_algebraic_real(); }
|
||||
;
|
||||
|
||||
rational: /* */
|
||||
error_rules {}
|
||||
| Rational '(' INTEGER ',' INTEGER ')'
|
||||
{ visitor->accept_rational( $3, $5); }
|
||||
;
|
||||
|
||||
inti: /* */
|
||||
INTEGER { visitor->accept_integer( $1); }
|
||||
| infty { visitor->accept_infty( $1); }
|
||||
;
|
||||
|
||||
infty: /* */
|
||||
MINUS_INFTY
|
||||
| PLUS_INFTY
|
||||
;
|
||||
|
||||
orientation: /* */
|
||||
COUNTERCLOCKWISE
|
||||
| CLOCKWISE
|
||||
| VOID
|
||||
;
|
||||
|
||||
double_val: /* a double value can be either an FNUMBER or an INTEGER */
|
||||
FNUMBER
|
||||
| INTEGER { visitor->accept_integer( $1); }
|
||||
;
|
||||
|
||||
error_rules:
|
||||
ERROR { visitor->parse_error( $1); }
|
||||
| UNKNOWN_TOKEN { visitor->unknown_token( $1); }
|
||||
;
|
||||
|
||||
/* End of Grammar */
|
||||
/* ============== */
|
||||
%%
|
||||
|
||||
// Opens file 'name' and parses it. Uses visitor 'v' while parsing.
|
||||
// Returns false if something went wrong. See the visitor for details.
|
||||
bool benchmark_parse_file( std::string name, Benchmark_visitor* v) {
|
||||
std::ifstream in( name.c_str());
|
||||
if ( ! in) {
|
||||
v->parse_error( std::string( "cannot open file '") + name +
|
||||
std::string( "'."));
|
||||
return false;
|
||||
}
|
||||
visitor = v;
|
||||
benchmark_init_lexer( in, name, 1);
|
||||
yyparse();
|
||||
return ! v->error();
|
||||
}
|
||||
|
||||
// Starts parsing from stream 'in' with the associated filename 'name'
|
||||
// (or analogous meaning for different streams) counting linenumbers
|
||||
// starting from 'n'. Uses visitor 'v' while parsing. Returns false if
|
||||
// something went wrong. See the visitor for details of the error reporting.
|
||||
bool benchmark_parse_stream( std::istream& in, std::string name,
|
||||
Benchmark_visitor* v, int n) {
|
||||
visitor = v;
|
||||
benchmark_init_lexer( in, name, n);
|
||||
yyparse();
|
||||
return ! v->error();
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/**************************************************************************
|
||||
// Copyright (c) 2004 Max-Planck-Institut Saarbruecken (Germany)
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of BenchmarkParser; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with BenchmarkParser.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner
|
||||
**************************************************************************/
|
||||
|
||||
#include <benchmark_visitor.h>
|
||||
#include <benchmark_parser.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
|
||||
void Benchmark_visitor::error_handler( std::string s) {
|
||||
std::ostringstream message;
|
||||
message << "ERROR: Benchmark_parser: " << benchmark_filename << " line "
|
||||
<< benchmark_linenumber << ": " << s;
|
||||
if ( ! m_error) {
|
||||
m_error = true;
|
||||
m_error_message = message.str();
|
||||
}
|
||||
if ( m_mode & PRINT_ERRORS) {
|
||||
std::cerr << message.str() << std::endl;
|
||||
}
|
||||
switch ( m_mode & 0x06) {
|
||||
case THROW_ERRORS:
|
||||
throw Benchmark_parser_exception( message.str());
|
||||
break;
|
||||
case EXIT_ERRORS:
|
||||
exit( 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Benchmark_visitor::parse_error( std::string s) {
|
||||
//error_handler( std::string("parse error: ") + s);
|
||||
error_handler( s);
|
||||
}
|
||||
|
||||
void Benchmark_visitor::unknown_token( std::string s) {
|
||||
error_handler( std::string("unknown token '") + s
|
||||
+ std::string("' found."));
|
||||
}
|
||||
|
||||
void Benchmark_visitor::token_not_handled( std::string s) {
|
||||
error_handler( std::string("known token '") + s
|
||||
+ std::string("' found but not handled by visitor."));
|
||||
}
|
||||
|
||||
void Benchmark_visitor::reset_header() {
|
||||
m_major = -1;
|
||||
m_minor = -1;
|
||||
m_format_options = std::string("");
|
||||
m_benchmark_name = std::string("");
|
||||
}
|
||||
|
||||
void Benchmark_visitor::accept_file_format(
|
||||
std::string s, int major, int minor, std::string options)
|
||||
{
|
||||
reset_header();
|
||||
if ( s != BENCHMARK_FORMAT_NAME) {
|
||||
error_handler( std::string( "wrong file format '") + s +
|
||||
std::string("', must be '") + BENCHMARK_FORMAT_NAME
|
||||
+ std::string("'."));
|
||||
return;
|
||||
}
|
||||
if ( major > BENCHMARK_FORMAT_MAJOR) {
|
||||
std::ostringstream message;
|
||||
message << "version major " << major << " is larger than "
|
||||
<< BENCHMARK_FORMAT_MAJOR << " what the parser understands.";
|
||||
error_handler( message.str());
|
||||
return;
|
||||
}
|
||||
m_major = major;
|
||||
m_minor = minor;
|
||||
// Options are comma separated. We add one left and one right to
|
||||
// have simple contains-an-option ",OPT," queries.
|
||||
m_format_options = std::string(",") + options + std::string(",");
|
||||
}
|
||||
|
||||
void Benchmark_visitor::accept_benchmark_name( std::string s) {
|
||||
m_benchmark_name = s;
|
||||
}
|
||||
|
||||
void Benchmark_visitor::accept_classification( std::string problem,
|
||||
std::string geom,
|
||||
std::string clas,
|
||||
std::string family,
|
||||
std::string instance,
|
||||
std::string release) {
|
||||
std::cout<<"inclassifi visitor" <<std::endl;
|
||||
error_handler ("classification not supported");
|
||||
}
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
/**************************************************************************
|
||||
// Copyright (c) 2004 Max-Planck-Institut Saarbruecken (Germany)
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of BenchmarkParser; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with BenchmarkParser.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Lutz Kettner
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef BENCHMARK_VISITOR_H
|
||||
#define BENCHMARK_VISITOR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
// Exception thrown by Benchmark_visitor if mode is THROW_ERRORS
|
||||
struct Benchmark_parser_exception {
|
||||
std::string message;
|
||||
Benchmark_parser_exception() {}
|
||||
Benchmark_parser_exception( std::string s) : message(s) {}
|
||||
};
|
||||
|
||||
// Visitor pattern for the benchmark parser
|
||||
class Benchmark_visitor {
|
||||
public:
|
||||
enum Error_mode { IGNORE_ERRORS = 0, PRINT_ERRORS = 1,
|
||||
THROW_ERRORS = 2, EXIT_ERRORS = 4 };
|
||||
protected:
|
||||
// error handling
|
||||
int m_mode; // Error_mode or'ed together
|
||||
bool m_error; // flags if an error has occured
|
||||
std::string m_error_message; // error message kept from last error
|
||||
virtual void error_handler( std::string s);
|
||||
|
||||
// information from the benchmark file already understood and parsed
|
||||
int m_major;
|
||||
int m_minor;
|
||||
std::string m_format_options;
|
||||
std::string m_benchmark_name;
|
||||
|
||||
public:
|
||||
Benchmark_visitor( int mode = PRINT_ERRORS )
|
||||
: m_mode(mode), m_error( false), m_error_message(""),
|
||||
m_major(-1), m_minor(-1) {}
|
||||
virtual ~Benchmark_visitor() {}
|
||||
|
||||
// error status and mode
|
||||
bool error() const { return m_error; }
|
||||
std::string error_message() const { return m_error_message; }
|
||||
void reset_error() {
|
||||
m_error = false;
|
||||
m_error_message = std::string( "");
|
||||
}
|
||||
|
||||
// information from the benchmark file already understood and parsed
|
||||
int version_major() const { return m_major; }
|
||||
int version_minor() const { return m_minor; }
|
||||
|
||||
virtual void reset_header();
|
||||
|
||||
// Options are comma separated. We have also a comma left and one right
|
||||
// to have simple contains-an-option ",OPT," queries.
|
||||
std::string format_options() const { return m_format_options; }
|
||||
std::string benchmark_name() const { return m_benchmark_name; }
|
||||
|
||||
// error handlers
|
||||
virtual void parse_error( std::string s);
|
||||
virtual void unknown_token( std::string s);
|
||||
virtual void token_not_handled( std::string s);
|
||||
void tnh( std::string s) { token_not_handled(s); } // shortcut
|
||||
|
||||
// file header entries
|
||||
virtual void accept_file_format( std::string s, int major, int minor,
|
||||
std::string options);
|
||||
virtual void accept_benchmark_name( std::string s);
|
||||
virtual void accept_classification( std::string problem,
|
||||
std::string geom,
|
||||
std::string clas,
|
||||
std::string family,
|
||||
std::string instance,
|
||||
std::string release);
|
||||
|
||||
// terminal nodes
|
||||
virtual void accept_infty( std::string s) { tnh( "Infty"); }
|
||||
virtual void accept_orientation( std::string s) { tnh( "Orientation"); }
|
||||
|
||||
virtual void accept_integer( std::string s) { tnh( "Integer"); }
|
||||
virtual void accept_rational( std::string num, std::string denom) {
|
||||
tnh( "Rational");
|
||||
}
|
||||
virtual void accept_fnumber( double d) { tnh( "Fnumber"); }
|
||||
virtual void accept_string( std::string s) { tnh( "String"); }
|
||||
virtual void accept_minus_infty (std::string s) { tnh("Minus_infty"); }
|
||||
virtual void accept_plus_infty (std::string s) { tnh("Plus_infty"); }
|
||||
virtual void accept_counter (std::string s) { tnh("Counterclockwise"); }
|
||||
virtual void accept_clockwise (std::string s) { tnh("Clockwise"); }
|
||||
virtual void accept_void (std::string s) { tnh("Void"); }
|
||||
|
||||
virtual void accept_point_2( std::string x, std::string y) {
|
||||
tnh( "Point_2(x,y)");
|
||||
}
|
||||
virtual void accept_point_2( std::string x, std::string y, std::string w) {
|
||||
tnh( "Point_2(x,y,w)");
|
||||
}
|
||||
virtual void accept_point_2( std::string x_num, std::string x_denom,
|
||||
std::string y_num, std::string y_denom) {
|
||||
tnh( "Point_2(x_num, x_denom, y_num, y_denom)");
|
||||
}
|
||||
|
||||
virtual void begin_algebraic_real() { tnh( "Begin_algebraic_real" ); }
|
||||
virtual void end_algebraic_real() { tnh( "End_algebraic_real" ); }
|
||||
|
||||
|
||||
virtual void begin_conic_point_2() {
|
||||
tnh( "Begin_conic_point_2" );
|
||||
}
|
||||
|
||||
virtual void end_conic_point_2() {
|
||||
tnh( "End_conic_point_2" );
|
||||
}
|
||||
|
||||
// non-terminal nodes
|
||||
virtual void begin_list() { tnh( "Begin_list"); }
|
||||
virtual void end_list() { tnh( "End_list"); }
|
||||
|
||||
virtual void begin_polynomial_1() { tnh( "Begin_polynomial_1"); }
|
||||
virtual void end_polynomial_1() { tnh( "End_polynomial_1"); }
|
||||
|
||||
virtual void begin_line_segment_2() { tnh( "Begin_line_segment_2"); }
|
||||
virtual void end_line_segment_2() { tnh( "End_line_segment_2"); }
|
||||
|
||||
virtual void accept_conic_2(std::string A, std::string B, std::string C,
|
||||
std::string D, std::string E, std::string F) {
|
||||
tnh("Conic_2");
|
||||
}
|
||||
|
||||
|
||||
virtual void begin_conic_arc_2() { tnh( "Begin_conic_arc_2" );}
|
||||
virtual void end_conic_arc_2() { tnh( "End_conic_arc_2" );}
|
||||
|
||||
virtual void begin_circle_2() { tnh("Begin_circle_2"); }
|
||||
virtual void end_circle_2() { tnh("End_circle_2"); }
|
||||
|
||||
virtual void accept_cubic_2(std::string A, std::string B, std::string C,
|
||||
std::string D, std::string E, std::string F,
|
||||
std::string G, std::string H, std::string K,
|
||||
std::string L) {
|
||||
tnh("Cubic_2");
|
||||
}
|
||||
|
||||
|
||||
virtual void accept_quadric_3(std::string A, std::string B, std::string C,
|
||||
std::string D, std::string E, std::string F,
|
||||
std::string G, std::string H, std::string K,
|
||||
std::string L) {
|
||||
tnh("Quadric_3");
|
||||
}
|
||||
virtual void begin_CircularArc_2(){
|
||||
tnh("begin_CircularArc_2");
|
||||
}
|
||||
virtual void end_CircularArc_2(){
|
||||
tnh("end_CircularArc_2");
|
||||
}
|
||||
virtual void begin_LineArc_2(){
|
||||
tnh("begin_LineArc_2");
|
||||
}
|
||||
virtual void end_LineArc_2(){
|
||||
tnh("end_LineArc_2");
|
||||
}
|
||||
virtual void begin_CircularPoint_2(){
|
||||
tnh("begin_CircularPoint_2");
|
||||
}
|
||||
virtual void end_CircularPoint_2(){
|
||||
tnh("end_CircularPoint_2");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // BENCHMARK_VISITOR_H //
|
||||
|
|
@ -0,0 +1 @@
|
|||
This source of extendet parser. By using report.tex. You can easily extend it in you own way.
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue