Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Create a correct arrangement with lines processed with linear_least_squares_fitting_2 function

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Create a correct arrangement with lines processed with linear_least_squares_fitting_2 function


Chronological Thread 
  • From: DamienDous <>
  • To:
  • Subject: Re: [cgal-discuss] Create a correct arrangement with lines processed with linear_least_squares_fitting_2 function
  • Date: Fri, 4 Dec 2015 03:27:50 -0800 (PST)
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=SoftFail ; spf=None
  • Ironport-phdr: 9a23:hZa5EBSLLbSDgXLfw3IT8zGafdpsv+yvbD5Q0YIujvd0So/mwa6/YB2N2/xhgRfzUJnB7Loc0qyN4/6mATRIyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/niabqo9X6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO9MxGlldhq5lhf44dqsrtY4q3wD86FpyshbTK+vf7gkVacKS3M9ImUt7YvqswPCRE2B/DwHQ2AOm11JBQbCqxr1V5O0virhvfdmw3qnO9brR+U0RSi69PUsDwT5jT8OcT8/6mDezMJqy7lKpQqo4B15zYmTa46cML9yf7jWYMgBFldHRdtbAixdHpunPcxIFPsEJe8ero/nplJIowH5HhipHOqoyzlGgTj90qQ+luggCgrbxxdzItQVrX6BrMnpLLxAFqeu3azQxHPCaelX0HHz8s/TYxU5qLaNW7x3NsHewE1qGwLehUiLst/YOSiI3LENr3SD9LgnEvm+jnYu7QB3uDmmgMk2zZLYg5ocjVHC+yI+y4k8IZi0SVVwfMW/Q6ZWrDyQYotqXts5ESYvozc/0rRAuJihfSFMxo5g3A/ac/XAco6G5VXoW++VZDt5n3l4Y6nsuxHn+kepzqjwV9K/zU1RhitDiNjF8H4XhDLJ7c3SZvJ4/0qn9TGSzEiH5uhBIE0y06bzMJgo2r0xkNwdqxKQTWfNhEzqgfrOJQ0f8e+y5rG/bw==

Hi Efi,

I'm using Visual Studio 2013 on Windows 8.1. Other thing : my CGAL library
uses Core Library. The errors I get are (sorry but my visual is in french
and I don't manage to change the langage, I think I have to reinstall visual
studio to modify the langage in english) :

1> main.cpp
1>C:\Code\trunk\external\CGAL\include\CGAL/IO/io.h(143): warning C4996:
'sscanf': This function or variable may be unsafe. Consider using sscanf_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\stdio.h(304) : voir la déclaration de 'sscanf'
1>C:\Code\trunk\external\CGAL\include\CGAL/eigen_2.h(89): error C2665:
'sqrt' : aucune des 3 surcharges n'a pu convertir tous les types d'arguments
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(521): peut être 'double sqrt(double)'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1135): ou 'float sqrt(float) throw()'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1251): ou 'long double sqrt(long double)
throw()'
1> lors de la tentative de mise en correspondance de la liste des
arguments '(FT)'
1>
C:\Code\trunk\external\CGAL\include\CGAL/linear_least_squares_fitting_points_2.h(85)
 :
voir la référence à l'instanciation de la fonction modèle 'void
CGAL::internal::eigen_symmetric_2<K>(const CORE::Expr
*,std::pair<Vector,Vector> &,std::pair<FT,FT> &)' en cours de compilation
1> with
1> [
1> K=CGAL::Simple_cartesian<CORE::Expr>
1> ]
1>
C:\Code\trunk\external\CGAL\include\CGAL/linear_least_squares_fitting_2.h(51) 
:
voir la référence à l'instanciation de la fonction modèle 'CORE::Expr
CGAL::internal::linear_least_squares_fitting_2<InputIterator,Kernel>(InputIterator,InputIterator,CGAL::Line_2<Kernel_>
&,CGAL::Point_2<Kernel_> &,const CGAL::Point_2<Kernel_> *,const K &,const
CGAL::Dimension_tag<0> &)' en cours de compilation
1> with
1> [
1>
InputIterator=std::_Vector_iterator<std::_Vector_val&lt;std::_Simple_types&lt;CGAL::Point_2&lt;CGAL::Simple_cartesian&lt;CORE::Expr>>>>>
1> , Kernel=CGAL::Simple_cartesian<CORE::Expr>
1> , Kernel_=CGAL::Simple_cartesian<CORE::Expr>
1> , K=CGAL::Simple_cartesian<CORE::Expr>
1> ]
1>
C:\Code\trunk\external\CGAL\include\CGAL/linear_least_squares_fitting_2.h(86) 
:
voir la référence à l'instanciation de la fonction modèle 'CORE::Expr
CGAL::linear_least_squares_fitting_2<InputIterator,CGAL::Simple_cartesian&lt;CORE::Expr>,Tag>(InputIterator,InputIterator,CGAL::Line_2<Kernel_>
&,CGAL::Point_2<Kernel_> &,const Tag &,const Kernel &)' en cours de
compilation
1> with
1> [
1>
InputIterator=std::_Vector_iterator<std::_Vector_val&lt;std::_Simple_types&lt;CGAL::Point_2&lt;CGAL::Simple_cartesian&lt;CORE::Expr>>>>>
1> , Tag=CGAL::Dimension_tag<0>
1> , Kernel_=CGAL::Simple_cartesian<CORE::Expr>
1> , Kernel=CGAL::Simple_cartesian<CORE::Expr>
1> ]
1> src\main.cpp(52) : voir la référence à l'instanciation de la
fonction modèle 'CORE::Expr
CGAL::linear_least_squares_fitting_2<std::_Vector_iterator&lt;std::_Vector_val&lt;std::_Simple_types&lt;CGAL::Point_2&lt;Kernel_>>>>,CGAL::Line_2<Kernel_>,CGAL::Dimension_tag<0>>(InputIterator,InputIterator,Line
&,const Tag &)' en cours de compilation
1> with
1> [
1> Kernel_=CGAL::Simple_cartesian<CORE::Expr>
1> ,
InputIterator=std::_Vector_iterator<std::_Vector_val&lt;std::_Simple_types&lt;CGAL::Point_2&lt;CGAL::Simple_cartesian&lt;CORE::Expr>>>>>
1> , Line=CGAL::Line_2<CGAL::Simple_cartesian&lt;CORE::Expr>>
1> , Tag=CGAL::Dimension_tag<0>
1> ]
1>C:\Code\trunk\external\CGAL\include\CGAL/eigen_2.h(90): error C2665:
'sqrt' : aucune des 3 surcharges n'a pu convertir tous les types d'arguments
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(521): peut être 'double sqrt(double)'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1135): ou 'float sqrt(float) throw()'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1251): ou 'long double sqrt(long double)
throw()'
1> lors de la tentative de mise en correspondance de la liste des
arguments '(FT)'
1>C:\Code\trunk\external\CGAL\include\CGAL/eigen_2.h(104): error C2665:
'sqrt' : aucune des 3 surcharges n'a pu convertir tous les types d'arguments
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(521): peut être 'double sqrt(double)'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1135): ou 'float sqrt(float) throw()'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1251): ou 'long double sqrt(long double)
throw()'
1> lors de la tentative de mise en correspondance de la liste des
arguments '(FT)'
1>C:\Code\trunk\external\CGAL\include\CGAL/eigen_2.h(104): error C2440:
'<function-style-cast>' : impossible de convertir de 'CORE::Expr' en
'Vector'
1> Aucun constructeur n'a pu prendre le type de source, ou la
résolution de la surcharge du constructeur était ambiguë
1>C:\Code\trunk\external\CGAL\include\CGAL/eigen_2.h(105): error C2665:
'sqrt' : aucune des 3 surcharges n'a pu convertir tous les types d'arguments
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(521): peut être 'double sqrt(double)'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1135): ou 'float sqrt(float) throw()'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1251): ou 'long double sqrt(long double)
throw()'
1> lors de la tentative de mise en correspondance de la liste des
arguments '(FT)'
1>C:\Code\trunk\external\CGAL\include\CGAL/eigen_2.h(105): error C2440:
'<function-style-cast>' : impossible de convertir de 'CORE::Expr' en
'Vector'
1> Aucun constructeur n'a pu prendre le type de source, ou la
résolution de la surcharge du constructeur était ambiguë
1>C:\Code\trunk\external\CGAL\include\CGAL/eigen_2.h(111): error C2665:
'sqrt' : aucune des 3 surcharges n'a pu convertir tous les types d'arguments
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(521): peut être 'double sqrt(double)'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1135): ou 'float sqrt(float) throw()'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1251): ou 'long double sqrt(long double)
throw()'
1> lors de la tentative de mise en correspondance de la liste des
arguments '(FT)'
1>C:\Code\trunk\external\CGAL\include\CGAL/eigen_2.h(111): error C2440:
'<function-style-cast>' : impossible de convertir de 'CORE::Expr' en
'Vector'
1> Aucun constructeur n'a pu prendre le type de source, ou la
résolution de la surcharge du constructeur était ambiguë
1>C:\Code\trunk\external\CGAL\include\CGAL/eigen_2.h(112): error C2665:
'sqrt' : aucune des 3 surcharges n'a pu convertir tous les types d'arguments
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(521): peut être 'double sqrt(double)'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1135): ou 'float sqrt(float) throw()'
1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\math.h(1251): ou 'long double sqrt(long double)
throw()'
1> lors de la tentative de mise en correspondance de la liste des
arguments '(FT)'
1>C:\Code\trunk\external\CGAL\include\CGAL/eigen_2.h(112): error C2440:
'<function-style-cast>' : impossible de convertir de 'CORE::Expr' en
'Vector'
1> Aucun constructeur n'a pu prendre le type de source, ou la
résolution de la surcharge du constructeur était ambiguë
1>
1>ÉCHEC de la build.

About my code, I'm sorry if it look not nice for you but I think there is a
problem between our two systems because it look nice for me (I attach a
print of my code visualized on my explorer). Maybe I can use tag on Nabble
to easily embed my code but I don't really know how to use Nabble.

In any case, thank you for your help and the time you are taking to solve my
problem.

Damien



<http://cgal-discuss.949826.n4.nabble.com/file/n4661445/Capture.png>
Efi Fogel wrote
> I have no problems compiling the code.
> Which platform are you using ?
> What errors are you getting.
>
> PS, if you expect other people to look at the code, make it look nice.
>
> ____ _ ____ _
> /_____/_) o /__________ __ //
> (____ ( ( ( (_/ (_/-(-'_(/
> _/
>
>
>
> On Thu, Dec 3, 2015 at 2:52 PM, DamienDous &lt;

> damien.d@

> &gt; wrote:
>
>> Hi Efi,
>>
>> I attach the file containing the code.
>>
>> Thank you for your help.
>>
>> Damien
>> Efi Fogel wrote
>> > On Thu, Dec 3, 2015 at 1:22 PM, DamienDous &lt;
>>
>> > damien.d@
>>
>> > &gt; wrote:
>> >
>> >> Hi Efi,
>> >>
>> >> Thank you for your answer!
>> >>
>> >> I tried the example using
>> >> Exact_predicates_exact_constructions_kernel_with_sqrt and I have a
>> >> compilation error. It seems that the function
>> >> linear_least_squares_fitting_2
>> >> doesn't take this Kernel. Am I using it in the good way?
>> >>
>> >
>> > I don't know.
>> > I was able to compile something.
>> > Attach the code, and I'll try it myself.
>> >
>> >>
>> >> I also tried to convert the lines from Epick to Epeck using the
>> mechanism
>> >> provided in the Algebraic Foundation package but as new user in CGAL
>> I'm
>> >> kind of lost. I tried to use fraction decomposition in order to
>> decompose
>> >> lines coefficients with Epick kernel and then recompose the
>> coefficients
>> >> with Epeck Kernel but that didn't work. Is that the good way to
>> convert
>> >> the
>> >> lines from one Kernel to another?
>> >>
>> >> Damien
>> >>
>> >>
>> >>
>> >> Efi Fogel wrote
>> >> > Hi Damien,
>> >> >
>> >> > Use the Exact_predicates_exact_constructions_kernel_with_sqrt kernel
>> >> or,
>> >> > when exactness can be compromised in favor of using a kernel that is
>> >> more
>> >> > efficient for constructing the arrangement, convert the lines from
>> one
>> >> > representation to the other using the mechanism provided in the
>> >> Algebraic
>> >> > Foundation package.
>> >> >
>> >> > Please paste pretty code. (Not only not nicely indented, but also it
>> >> seems
>> >> > that the '<' and '>' tags go converted by Nabble to &lt; and &gt;
>> and,
>> >> in
>> >> > addition, the ssl header inclusion is missing.)
>> >> >
>> >> > Efi
>> >> >
>> >> > ____ _ ____ _
>> >> > /_____/_) o /__________ __ //
>> >> > (____ ( ( ( (_/ (_/-(-'_(/
>> >> > _/
>> >> >
>> >> >
>> >> >
>> >> > On Tue, Dec 1, 2015 at 7:58 PM, DamienDous &lt;
>> >>
>> >> > damien.d@
>> >>
>> >> > &gt; wrote:
>> >> >
>> >> >> Hi,
>> >> >>
>> >> >> I need to create an arrangement with lines fitted by
>> >> >> linear_least_squares_fitting_2 function.
>> >> >>
>> >> >> I have a problem when I fit lines on points by using
>> >> >> linear_least_squares_fitting_2 function and after put the obtained
>> >> lines
>> >> >> in
>> >> >> an arrangement using an
>> Exact_predicates_exact_constructions_kernel.
>> >> The
>> >> >> face number processed is incorrect.
>> >> >>
>> >> >> The following example fit three lines intersecting at the same
>> point
>> >> >> using
>> >> >> Line_2 with Exact_predicates_inexact_constructions_kernel (the
>> >> >> linear_least_squares_fitting_2 can't take line with
>> >> >> Exact_predicates_exact_constructions_kernel because the function
>> >> >> processes
>> >> >> square root). To put the obtained lines in an arrangement using
>> >> >> Exact_predicates_exact_constructions_kernel , I convert the lines
>> in
>> >> >> Segment_2 with Exact_predicates_exact_constructions_kernel and I
>> >> >> understand
>> >> >> that the problem come from this transformation but I don't know how
>> to
>> >> >> use
>> >> >> linear_least_squares_fitting_2 function and then put the result in
>> an
>> >> >> arrangement using Exact_predicates_exact_constructions_kernel.
>> >> >>
>> >> >> Also, I tried to use an arrangement with
>> >> >> Exact_predicates_inexact_constructions_kernel but that doesn't work
>> >> given
>> >> >> that the precision problem.
>> >> >>
>> >> >>
>> >> >> Here is my code :
>> >> >>
>> >> >> #include &lt;CGAL/Arrangement_2.h&gt;
>> >> >> #include &lt;CGAL/Arr_segment_traits_2.h&gt;
>> >> >> #include &lt;CGAL/Arr_linear_traits_2.h&gt;
>> >> >> #include &lt;CGAL/Exact_predicates_exact_constructions_kernel.h&gt;
>> >> >> #include
>> &lt;CGAL/Exact_predicates_inexact_constructions_kernel.h&gt;
>> >> >> #include &lt;CGAL/Arr_extended_dcel.h&gt;
>> >> >>
>> >> >> typedef CGAL::Exact_predicates_inexact_constructions_kernel
>> >> >> Kernel1;
>> >> >> typedef CGAL::Exact_predicates_exact_constructions_kernel
>> >> >> Kernel2;
>> >> >> typedef CGAL::Arr_linear_traits_2
>> >> >
>> >
> <Kernel2>
>> >> >> Traits;
>> >> >> typedef CGAL::Arr_face_extended_dcel&lt;Traits, bool&gt;
>> >> >> Dcel_2;
>> >> >> typedef CGAL::Arrangement_2&lt;Traits, Dcel_2&gt;
>> >> >> Arrangement;
>> >> >>
>> >> >>
>> >> >> int main()
>> >> >> {
>> >> >> // Initialize segments distance and segments number of
>> points
>> >> >> double distance = 1;
>> >> >> size_t nbPoints = 100;
>> >> >>
>> >> >> // Fill the three points vectors representing the three
>> lines
>> >> >>
>> >> >>
>> std::vector&lt;std::vector&amp;lt;CGAL::Point_2&amp;lt;Kernel1&gt;>>
>> >> >> lines_points;
>> >> >> lines_points.resize(3);
>> >> >> double x = 0;
>> >> >> for (size_t i = 0; i < nbPoints; i++, x += distance /
>> >> nbPoints)
>> >> {
>> >> >> lines_points.at(0).push_back(CGAL::Point_2
>> >> >
>> >
> <Kernel1>
>> >> > (distance
>> >> >> - x, x));
>> >> >> lines_points.at(1).push_back(CGAL::Point_2
>> >> >
>> >
> <Kernel1>
>> >> > (x,
>> >> >> x));
>> >> >> lines_points.at(2).push_back(CGAL::Point_2
>> >> >
>> >
> <Kernel1>
>> >> > (x,
>> >> >> distance / 2));
>> >> >> }
>> >> >>
>> >> >> // Fit for each points vector a line using
>> >> >> linear_least_squares_fitting_2
>> >> >> // and transform this line in segment with
>> >> >> Exact_predicates_exact_constructions_kernel
>> >> >> CGAL::Line_2
>> >> >
>> >
> <Kernel1>
>> >> > line;
>> >> >> std::vector&lt;CGAL::Segment_2&amp;lt;Kernel2&gt;>
>> >> >> segments(lines_points.size());
>> >> >> for (size_t i = 0; i < lines_points.size(); i++) {
>> >> >>
>> CGAL::linear_least_squares_fitting_2(lines_points.at
>> >> >> (i).begin(),
>> >> >> lines_points.at(i).end(), line, CGAL::Dimension_tag<0>());
>> >> >> segments.at(i) =
>> >> >> CGAL::Segment_2
>> >> >
>> >
> <Kernel2>
>> >> > (CGAL::Point_2
>> >> >
>> >
> <Kernel2>
>> >> > (0,
>> >> >> -line.c() / line.b()),
>> >> >> CGAL::Point_2
>> >> >
>> >
> <Kernel2>
>> >> > (distance, -(distance *
>> >> >> line.a() + line.c()) /
>> >> >> line.b()));
>> >> >> }
>> >> >>
>> >> >> // Put the processed segment in an arrangement
>> >> >> Arrangement arr;
>> >> >> CGAL::insert(arr, segments.begin(), segments.end());
>> >> >>
>> >> >> // Print the number of bounded face
>> >> >> std::cout << arr.number_of_faces() -
>> >> >> arr.number_of_unbounded_faces() <<
>> >> >> std::endl;
>> >> >>
>> >> >> // Print the bounded face of the arrangement
>> >> >> Arrangement::Ccb_halfedge_const_circulator curr;
>> >> >> for (Arrangement::Face_const_handle fit =
>> arr.faces_begin();
>> >> fit
>> >> >> !=
>> >> >> arr.faces_end(); ++fit) {
>> >> >> if (!fit->is_unbounded()) {
>> >> >> curr = fit->outer_ccb();
>> >> >> do {
>> >> >> std::cout <<
>> curr->source()->point()
>> >> <<
>> >> "
>> >> >> - ";
>> >> >> } while (++curr != fit->outer_ccb());
>> >> >> }
>> >> >> }
>> >> >> }
>> >> >>
>> >> >>
>> >> >>
>> >> >> Is there a Kernel that provide against this problem?
>> >> >>
>> >> >> Thank you very much.
>> >> >> Regards.
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://cgal-discuss.949826.n4.nabble.com/Create-a-correct-arrangement-with-lines-processed-with-linear-least-squares-fitting-2-function-tp4661426.html
>> >> >> Sent from the cgal-discuss mailing list archive at Nabble.com.
>> >> >>
>> >> >> --
>> >> >> You are currently subscribed to cgal-discuss.
>> >> >> To unsubscribe or access the archives, go to
>> >> >> https://sympa.inria.fr/sympa/info/cgal-discuss
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >> > --
>> >> > You are currently subscribed to cgal-discuss.
>> >> > To unsubscribe or access the archives, go to
>> >> > https://sympa.inria.fr/sympa/info/cgal-discuss
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://cgal-discuss.949826.n4.nabble.com/Create-a-correct-arrangement-with-lines-processed-with-linear-least-squares-fitting-2-function-tp4661426p4661435.html
>> >> Sent from the cgal-discuss mailing list archive at Nabble.com.
>> >>
>> >> --
>> >> You are currently subscribed to cgal-discuss.
>> >> To unsubscribe or access the archives, go to
>> >> https://sympa.inria.fr/sympa/info/cgal-discuss
>> >>
>> >>
>> >>
>> >
>> > --
>> > You are currently subscribed to cgal-discuss.
>> > To unsubscribe or access the archives, go to
>> > https://sympa.inria.fr/sympa/info/cgal-discuss
>>
>> main.cpp
>> &lt;http://cgal-discuss.949826.n4.nabble.com/file/n4661437/main.cpp&gt;
>>
>>
>>
>> --
>> View this message in context:
>> http://cgal-discuss.949826.n4.nabble.com/Create-a-correct-arrangement-with-lines-processed-with-linear-least-squares-fitting-2-function-tp4661426p4661437.html
>> Sent from the cgal-discuss mailing list archive at Nabble.com.
>>
>> --
>> You are currently subscribed to cgal-discuss.
>> To unsubscribe or access the archives, go to
>> https://sympa.inria.fr/sympa/info/cgal-discuss
>>
>>
>>
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss





--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Create-a-correct-arrangement-with-lines-processed-with-linear-least-squares-fitting-2-function-tp4661426p4661445.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.18.

Top of Page