Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] polyhedron clipping using a plane

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] polyhedron clipping using a plane


Chronological Thread 
  • From: gunshi gupta <>
  • To:
  • Subject: Re: [cgal-discuss] polyhedron clipping using a plane
  • Date: Mon, 26 Oct 2015 18:55:32 +0530
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:eSo9uxCm8wpe1SSdc1bXUyQJP3N1i/DPJgcQr6AfoPdwSP//r8bcNUDSrc9gkEXOFd2CrakU1qyP6uu9ACQp2tWojjMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3DwdpPOO9QteU1JTqkbnrsMCKKyxzxxODIppKZC2sqgvQssREyaBDEY0WjiXzn31TZu5NznlpL1/A1zz158O34YIxu38I46FppIZ9V77ndfE4UaBAF2ZhdHsk4dXi8xjFVwqGoHUGFX4HlwJBRAnD4ha9VZj4tm72t/F2xTKBbvDwVq0+DDS+879wGlivkzYCLzd/8WfNi8U2grgcuwOkvxU4wojaZ8aeO/N6O6/cZtgHXnESYsEEXCNIBsawbpAEEvEaFedetYj04VUU/jWkAgz5C/7p0T9JznDrxbEzm7AuDAfd3A0vAsoSuSX8o9D8NaNUWuewmvqbhQ7fZu9bjG+uoLPDdQos9KmB

Thanks Sebastien that should do it, i've gone through the function's code, and what it seems to be doing is that it first clips the bounding box of the polyhedron P1 using the plane into a polyhedron P2 and then using this as the clipping polyhedron, clips the original polyhedron P1 that we provided as input, is that correct?
Is there any way i could invert the plane, or add a couple of steps, to get the other polyhedron as well, that was created during the clipping, through this function?
For reference, Frederic here seems to mention such an inversion:
http://cgal-discuss.949826.n4.nabble.com/Trouble-cutting-polyhedron-using-a-plane-td951826.html#a4661276
Thankyou
Gunshi

On Thu, Oct 22, 2015 at 12:12 PM, Sebastien Loriot (GeometryFactory) <> wrote:
For information I've coded a way to clip a polyhedron by a plane
using some internal code. That is not the smartest way to do it
but it should work relatively well. A better version is on its
way but I need some time to finish it.


You need the include file internal/Polyhedron_plane_clipping_3.h
available here:
https://github.com/sloriot/cgal/raw/Operations_on_polyhedra-plane_clipping_with_corefinement-sloriot/Operations_on_polyhedra/include/CGAL/internal/Polyhedron_plane_clipping_3.h

And you can test it with the following program:
https://github.com/sloriot/cgal/raw/Operations_on_polyhedra-plane_clipping_with_corefinement-sloriot/Operations_on_polyhedra/examples/Operations_on_polyhedra/polyhedron_clipping.cpp

You can run the program without arguments if you have the file
elephant.off in data/ where the program is ran.

Sebastien.



On 10/21/2015 12:34 PM, gunshi gupta wrote:
Thanks Vinicius, this looks helpful.
I shall do so and revert back soon.
Gunshi.

On Tue, Oct 20, 2015 at 4:34 PM, Vinicius Azevedo
< <mailto:>> wrote:

    Hi Gunshi,

    You may want to look my old thread about polygon slicing:
    http://cgal-discuss.949826.n4.nabble.com/Slicing-splitting-cutting-polyhedral-meshes-td4660731.html
    The snippet that I provide at the end can work for some cases, but
    its not the optimal approach. I can help if you have more questions.

    Vinicius C. Azevedo.

    On Tue, Oct 20, 2015 at 7:51 AM, gunshi gupta
    < <mailto:>> wrote:

        I wanted to add:
        Or should I go about it using boolean operations on nef
        polyhedra, using the halfspaces I want as NOT of(halfspaces of
        the plane I have)?
        Thanks.

        On 20 Oct 2015 14:51, "gunshi gupta" <
        <mailto:>> wrote:

            Thank you for your response Sebastien.

            I now understand how the function works mostly, but i still
            have a couple of doubts.

            1)Initially in my program i have a cube with 6 plane
            equations for their faces. I can, after some calculations
            compute which half spaces of these planes i want. I then
            intend to introduce n cutting planes, one by one, and
            partition this cube into two polyhedrons, then partition the
            two polyhedrons created into more polyhedrons by the next
            cutting plane, and so on.

            I basically have a cube and n cutting planes, and i want to
            generate all the polyhedrons(guaranteed convex) that are
            generated between these 6+n planes when we see them in 3d space.
            The functions computes an intersection of half spaces, so
            that means an intersection of the negative sides of these
            hyperplanes right?
            But what if i know which half space i want to be used in the
            intersection? Is there any way to modify the plane_3
            variable to make that happen,or some other way,  since i
            guess its quite unlikely that i will get the polyhedrons i
            want with only the negative half spaces being taken into
            consideration, since i know my polyhedron will lie in the
            first octant.

            If it is possible, then i can just specify half spaces every
            time, for the polyhedron, and turn wise use both half spaces
            of the cutting plane to create the two polyhedrons i want
            each time.

            2) The last optional argument of the halfspace intersection
            method is to be supplied as a point that we are certain lies
            inside the polyhedron. This is supposed to greatly speed up
            computation.
            In my case i can only provide a point that lies ON the
            polyhedron (i have this point from some other part of the
            program),
            I know that internally the point-in-polygon test takes place
            calls :

            if( !plane.has_on_negative_side(p) )

            return false;

            so i guess it'll return false for my case, and i should not
            supply it, right?


            Thanks again!


            On Mon, Oct 19, 2015 at 12:22 PM, Sebastien Loriot
            (GeometryFactory) <
            <mailto:>> wrote:

                On 10/17/2015 05:58 PM, gunshi gupta wrote:

                    Hi,
                    I have a function written in MATLAB which is
                    clipping a convex
                    polyhedron, given an initial convex polyhedron and a
                    plane, and it
                    returns the new polyhedron that was formed as a
                    result of the clipping
                    (defined in terms of its faces and vertices).
                       This function has been implemented by using the
                    clipPolygon3D function
                    that MATLAB provides, internally, by clipping each
                    polygonal face of the
                    polyhedron and then doing the necessary computation
                    to combine the results.
                    link:
                    http://in.mathworks.com/matlabcentral/fileexchange/24484-geom3d/content/geom3d/geom3d/clipPolygon3dHP.m

                    Now i want to do the same in c++, and preferably
                    using CGAL.
                    So
                    1) i have searched and was not able to find a
                    function for polygon
                    clipping in CGAL, but i wanted to confirm if that is
                    right since CGAL
                    covers quite a wide range of algorithms.
                    2)i have also come across the function "void
                    CGAL::halfspace_intersection_3" from section 3D
                    convex hulls in CGAL
                    which seems to compute the intersection of a plane
                    and a convex hull.
                    link:
                    http://doc.cgal.org/latest/Convex_hull_3/group__PkgConvexHull3Functions.html#ga6118d2c46934c541669ab871f8e1fd24

                    It seems that if i am able to define a polyhedron as
                    a convex hull, then
                    from what i understand from the documentation (i
                    understand very
                    little), i should be able to do what i described
                    above(polyhedron
                    clipping) without having to implement polyhedron
                    clipping through
                    polygon clipping. Can someone help me with
                    this/verify if this is possible?
                    Thanks a lot!

                If the polyhedron is defined as a set of planes, you
                indeed can use
                this function.

                If you use a CGAL polyhedron with plane associated to
                faces, this is
                direct.

                See this example [1] (only the last line) to see how to
                associate
                a plane to each face.

                [1]
                http://doc.cgal.org/latest/Convex_hull_3/Convex_hull_3_2quickhull_3_8cpp-example.html

                Sebastien.

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