views:

48

answers:

1

Using the Python bindings for CGAL, I can't work out how create a hexahedron, nor how to calculate its intersection with another hexahedron.

I have 8 input points, which are the corners of the hexahedron:

a hexahedron - a shape with six faces, eight corners

My code does this:

P = Polyhedron_3()
bottom = P.make_tetrahedron(p[0],p[1],p[2],p[3])
top = P.make_tetrahedron(p[4],p[5],p[6],p[7])
left = P.make_tetrahedron(p[0],p[1],p[5],p[4])
right = P.make_tetrahedron(p[3],p[2],p[6],p[7])
front = P.make_tetrahedron(p[4],p[7],p[3],p[0])
back = P.make_tetrahedron(p[1],p[2],p[6],p[5])

but when I count the points in the resulting polyhedron there are 24 - each face is unjoined with its neighbours.

How can I build a solid hexahedron using Python CGAL?

And, finally, having successfully constructed two such polyhedron, how do I calculate their intersection?

+1  A: 

You're going to want to create an initial tetrahedron, then use split_edge three times and moving the newly created vertices to where they are supposed to be. Then use another combination of split_facet and split_edge to "mold" the hexahedron into place.

See Section 25.3.7 of CGAL Documentation to see this being done in explicit detail for a special case hexahedron with vertices [0,0,0],[1,0,0],[0,1,0],[0,0,1],[1,1,0],[1,0,1],[0,1,1], and [1,1,1], without (I believe) any loss of generality.

Justin L.