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: Wed, 21 Oct 2015 16:04:30 +0530
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:dI0UcB1mbN4fkqZlsmDT+DRfVm0co7zxezQtwd8ZsegfL/ad9pjvdHbS+e9qxAeQG96LtrQc0aGN6+jJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09fr2zQd6PyZztnLvqs7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cY6Loc8dVdW/D6Y7ggVu4fSy83Nng8osztrxjKCwWVoWANV30f1RtODQ+C5x7zWtL9szDxq/FmixWdaMb5RLRxVTW55LpwUzfpjj0GPng36jL5kMt12a1GpgmhplRw3pbIacnBO+d4ZaPccs4CWWMQdslUXi1FRIi7at1cXKI6Ie9Eotyl9BM1phykCFz0CQ==

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








Archive powered by MHonArc 2.6.18.

Top of Page