Subject: CGAL users discussion list
List archive
- From: Marc Mörig <>
- To:
- Subject: Re: [cgal-discuss] Bug in Circular_kernel_2
- Date: Mon, 12 Nov 2012 16:28:59 +0100
I have attached some code plus an input file. Place both in the same directory.
On 11/12/2012 04:05 PM, Sebastien Loriot (GeometryFactory) wrote:
Hi Marc,
would you have a small but complete example showing the problem?
Sebastien.
--
Marc Mörig Email:
Institut für Simulation und Graphik Phone: +49 391 67-52858
Otto-von-Guericke Universität Magdeburg Office: G29-227
//****************************************************************************** #include <CGAL/Exact_predicates_exact_constructions_kernel.h> #include <CGAL/Circular_kernel_2.h> #include <CGAL/Exact_circular_kernel_2.h> #include <CGAL/Algebraic_kernel_for_circles_2_2.h> #include <CGAL/Arr_circular_line_arc_traits_2.h> #include <CGAL/Cartesian_converter.h> #include <CGAL/Arrangement_2.h> #include <CGAL/Simple_cartesian.h> #include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <ctime> //***************************************************************************** template <class Segment,class Circle, class SegmentOutputIterator,class CircleOutputIterator> std::pair<SegmentOutputIterator,CircleOutputIterator> read_curves(std::string filename, SegmentOutputIterator segments, CircleOutputIterator circles){ typedef typename CGAL::Kernel_traits<Segment>::Kernel Kernel; typedef typename Kernel::Point_2 Point; std::ifstream strm(filename.c_str()); if(!strm){ std::cerr << "Could not open '" << filename << "' for reading." << std::endl; exit(1); } else std::cout << "reading " << filename << std::endl; std::string line; std::stringstream linestrm; //skip 14 header lines for(int i=0;i<14;i++) std::getline(strm,line); std::getline(strm,line); linestrm.str(line); while(!strm.fail() && !strm.eof()){ double a,b,c,d; char lend; size_t pos = line.find_last_of("cl"); if(pos == std::string::npos){ std::cerr << "'l' or 'c' expected" << std::endl; exit(1); } if(line[pos] == 'c'){ linestrm >> a >> b >> c >> lend; if(lend != 'c'){ std::cerr << "'c' expected" << std::endl; exit(1); } *circles = Circle(Point(a,b),c*c); ++circles; }else if(line[pos] == 'l'){ linestrm >> a >> b >> c >> d >> lend; if(lend != 'l'){ std::cerr << "'l' expected" << std::endl; exit(1); } *segments = Segment(Point(a,b),Point(c,d)); ++segments; } std::getline(strm,line); linestrm.str(line); } return std::make_pair(segments,circles); } //****************************************************************************** template<class Traits,class CircleForwardIterator,class SegmentForwardIterator> inline void curve_arrangement_t(CircleForwardIterator cbegin, CircleForwardIterator cend, SegmentForwardIterator sbegin, SegmentForwardIterator send){ typedef typename std::iterator_traits<SegmentForwardIterator>::value_type Segment; typedef typename CGAL::Kernel_traits<Segment>::Kernel Kernel; typedef typename Traits::Kernel ExactKernel; typedef typename Traits::Curve_2 Curve; typedef CGAL::Cartesian_converter<Kernel,ExactKernel> Converter; typedef typename CGAL::Arrangement_2<Traits> Arrangement; Converter convert; std::vector<Curve> curves; curves.reserve(std::distance(cbegin,cend)+std::distance(sbegin,send)); for(SegmentForwardIterator s = sbegin;s!=send;++s) curves.push_back(convert(*s)); for(CircleForwardIterator c = cbegin;c!=cend;++c) curves.push_back(convert(*c)); Arrangement arr; //create by sweep insert(arr, curves.begin(), curves.end()); // //create incremental // typename std::vector<Curve>::const_iterator it=curves.begin(); // for(;it!=curves.end();++it){ // CGAL::insert(arr,*it); // } } //****************************************************************************** template<class CircleForwardIterator,class SegmentForwardIterator> inline void linearcarr(CircleForwardIterator cbegin, CircleForwardIterator cend, SegmentForwardIterator sbegin, SegmentForwardIterator send){ typedef CGAL::Exact_predicates_exact_constructions_kernel Linear_k; typedef Linear_k::FT NT; typedef CGAL::Algebraic_kernel_for_circles_2_2<NT> Algebraic_k; typedef CGAL::Circular_kernel_2<Linear_k,Algebraic_k> Circular_k; typedef CGAL::Arr_circular_line_arc_traits_2<Circular_k> Traits; curve_arrangement_t<Traits>(cbegin,cend,sbegin,send); } //****************************************************************************** int main(int /*argc*/, char* /*argv*/[]){ typedef CGAL::Simple_cartesian<double> Kernel; typedef Kernel::Segment_2 Segment; typedef Kernel::Circle_2 Circle; std::vector<Segment> segs; std::vector<Circle> circs; read_curves<Segment,Circle>("curves_rand_1000_000.eps", std::back_inserter(segs), std::back_inserter(circs)); linearcarr(circs.begin(),circs.end(),segs.begin(),segs.end()); return 0; } //******************************************************************************
Attachment:
curves_rand_1000_000.eps
Description: image/eps
- [cgal-discuss] Bug in Circular_kernel_2, Marc Mörig, 11/09/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Philipp Moeller, 11/09/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Andreas Fabri, 11/09/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Marc Mörig, 11/12/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Sebastien Loriot (GeometryFactory), 11/12/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Marc Mörig, 11/12/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Bhudev Kumar, 11/12/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Sebastien Loriot (GeometryFactory), 11/13/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Marc Mörig, 11/12/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Sebastien Loriot (GeometryFactory), 11/12/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Marc Mörig, 11/12/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Andreas Fabri, 11/09/2012
- Re: [cgal-discuss] Bug in Circular_kernel_2, Philipp Moeller, 11/09/2012
Archive powered by MHonArc 2.6.18.