Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Get corners of a Kd_tree_rectangle as Point_d

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Get corners of a Kd_tree_rectangle as Point_d


Chronological Thread 
  • From: Frédérik Paradis <>
  • To:
  • Subject: Re: [cgal-discuss] Get corners of a Kd_tree_rectangle as Point_d
  • Date: Tue, 19 Apr 2016 09:27:49 -0400
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=None ; spf=None
  • Ironport-phdr: 9a23:CgvqDBUkyoMzRneFRrUU1lwK3mLV8LGtZVwlr6E/grcLSJyIuqrYZxCOt8tkgFKBZ4jH8fUM07OQ6PCwHzJcqsjZ+Fk5M7VyFDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5K6zPF5LIiIzvjqbpq82VPVkD2mL1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu2pN5k+VqFSWTQ6L3gutoqsrgjGVQLJ530GU2xQnAAPGBnA9Bi9X5H/tWzxueN5nSWbJsbrVqtnZDK58q0+SAP0kDxVcHki4WTPg4pxirhaqVSvvVtk0ovMacaUMvR5OajSdNdfSWtaVdtKTH99Bda3YIILSuYAJu1FtJLVpl0UrBL4CxP/Kvnoz2pmnP76XLc70KwZGBvP0A07V4YAqH3OpY2oZI8PVvypxbbBiz7KOaAFkQzh4ZTFJ0hy6cqHWqh9JJLc

Never use min and max as variables some versions of MSVC will not compile.
You could have checked that .homogeneous(d) are different for all
the coordinates before doing the product.
BTW, github storage is not so restricted so you can add some comments
in your code ;)

I updated it with comments and refactoring.

The advantage of this method is that you don't need to loop over
all the points of the rectangle.

So what you're suggesting is that I do similarly as in the gist I sent you but instead of walking along the list of points, I just take the coordinates of type FT returned by the Kd_rectangle class? I cannot use the CommonFactor concept as it results in compilation error when using Quotient<double>.

Thank you.

Frédérik
 

2016-04-19 2:46 GMT-04:00 Sebastien Loriot (GeometryFactory) <>:
On 04/18/2016 02:53 PM, Frédérik Paradis wrote:
Hi,

Thank you for your answer. So, before your answer, I reimplemented the
features I needed from Point_container. The instantiation of the
Iso_box_d looks like that:
https://gist.github.com/freud14/88f014742122dc82b9a5a1b87feda5cc Do you
see anything wrong with that approach?


Never use min and max as variables some versions of MSVC will not compile.
You could have checked that .homogeneous(d) are different for all
the coordinates before doing the product.
BTW, github storage is not so restricted so you can add some comments
in your code ;)

Also, I looked at the FractionTraits and it seems that the number type
must be of model ExplicitInteroperable which is not always the case
when, for instance, the kernel is CGAL::Homogeneous_d<double>. Please
correct me if I am wrong.


The advantage of this method is that you don't need to loop over
all the points of the rectangle.
IIRC the denominator will be 1 in that case.

Sebastien.

Thank you.

Frédérik


2016-04-18 3:50 GMT-04:00 Sebastien Loriot (GeometryFactory)
< <mailto:>>:


    Looking at how things are implemented, in the Homogeneous case I think
    you have no other choice than decomposing each Cartesian coordinate
    to find a common RT factor.
    If I have to do it, I would use a functor/function specialized in the
    Homogeneous case.

    For the specialization you can use the nested Kernel_tag for the Kernel
    you are using that is either CGAL::Homogeneous_tag or
    CGAL::Cartesian_tag.

    For the decomposition, you can use Fraction_traits [1] that provides
    a Decompose functor [2].

    HTH

    Sebastien.

    [1]
    http://doc.cgal.org/latest/Algebraic_foundations/classCGAL_1_1Fraction__traits.html

    [2]
    http://doc.cgal.org/latest/Algebraic_foundations/classFractionTraits___1_1Decompose.html


    On 04/16/2016 12:28 AM, Frédérik Paradis wrote:

        HI,

        I am using the class Point_containter to generate and split the
        bounding
        box of a point set. I would like to get the bounding box as an
        Iso_box_d. However, the Point_container class only offers a method
        bounding_box which return a Kd_tree_rectangle. The only way to
        retrieve
        the coordinates of the corners of the rectangle seems to be the
        methods
        min_coord and max_coord which both returns the cartesian
        coordinate for
        the dimension i with the type FT.

        The problem arises when I'm using the Homogeneous_d kernel with
        whatever
        ring type because the ring type and the field type are not the
        same and
        thus trigger a compilation error.

        Here is my current code:

                std::vector<FT> min;
                std::vector<FT> max;
                const Kd_tree_rectangle<FT, D>& kdbox =
        container.bounding_box();
                for(int i = 0; i < d; i++) {
                  min.push_back(kdbox.min_coord(i));
                  max.push_back(kdbox.max_coord(i));
                }
                bbox = Iso_box_d(Point_d(d, min.begin(), min.end()),
                                  Point_d(d, max.begin(), max.end()));

        Is there any way to make it work with Point_container or will I
        have to
        compute the corners by iterating over all points?

        Thank you.

        Frédérik



    --
    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






Archive powered by MHonArc 2.6.18.

Top of Page