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: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] polyhedron clipping using a plane
  • Date: Thu, 22 Oct 2015 08:42:26 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:+O7oRBS+Fpv+pZFxrGhrwDpUmdpsv+yvbD5Q0YIujvd0So/mwa65ZR2N2/xhgRfzUJnB7Loc0qyN4/2mATdLuM7c+Fk5M7VyFDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5K6zPF5LIiIzvjqbpq8CVO14D3WLgKZpJbzyI7izp/vEMhoVjLqtjgjDomVBvP9ps+GVzOFiIlAz97MrjtLRq8iBXpu5zv5UYCfayLOwFS6dFBmEmL3wt/5+s8gLSSBOGoHoaSGQf1BRSRBPU6QnzGZb3vCy9veV03GyWPNb9UKsvCgiluqxkQRuthCYcPCMi60nWjNZxheRVukGPvRt6lsTvbYucL+Z/c6WVWdQARG1dFoZ+WitED5+mfqUGBPYGJ/cZ5cGpvF8Jtxq5GU+pAMvgzzZJgjn92qhsgLdpKh3PwAF1R4FGi3/TttigbKo=
  • Organization: GeometryFactory

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









Archive powered by MHonArc 2.6.18.

Top of Page