If addPolyhedron is applied to a Polyhedron and a PolyhedralComplex it adds the Polyhedron to the PolyhedralComplex if they are in the same ambient space, if the Polyhedron is compatible with every generating Polyhedron of PC, but is not a face of one of them. If one of the first two conditions fails, there will be an error and no PolyhedralComplex will be returned. The pairs of incompatible polyhedra can be accessed with the function incompPolyhedra. If the last condition fails, then the Polyhedron is already in the PolyhedralComplex as a face of one of the poyhedra, so it does not have to be added. The conditions are checked in this order.
If addPolyhedron is applied to a List and a PolyhedralComplex, then the function adds the list Polyhedron by Polyhedron and stops if one of the three conditions fails for one of the polyhedra. There is again an error for the first two conditions. The pairs of incompatible polyhedra can again be retrieved using incompPolyhedra. Note that the may also contain PolyhedralComplexes. Then the function replaces it by its list of generating polyhedra.
If applied to a pair of PolyhedralComplexes it adds the generating polyhedra of the first PolyhedralComplex to the second PolyhedralComplex, again checking for the same conditions as above.
As an example, we make a PolyhedralComplex consisting of the following Polyhedron and try to add an adjacent cube.
i1 : P = convexHull matrix {{1,1,1,1,2,2,2,2},{0,0,1,1,0,0,1,1},{0,1,0,1,0,1,0,1}}; |
i2 : PC = polyhedralComplex P o2 = PC o2 : PolyhedralComplex |
i3 : P = hypercube 3; |
i4 : incompPolyhedra(P,PC) o4 = {(P, Polyhedron{...1...})} o4 : List |
This shows that the two polyhedra do not intersect in a common face, but if we divide P into three parts, we get a PolyhedralComplex.
i5 : P1 = convexHull matrix {{1,1,1,1,-1,-1,-1,-1},{0,0,1,1,0,0,1,1},{0,1,0,1,0,1,0,1}}; |
i6 : P2 = convexHull matrix {{1,1,1,1,-1,-1,-1,-1},{0,1,1,-1,0,1,1,-1},{0,0,-1,-1,0,0,-1,-1}}; |
i7 : P3 = convexHull matrix {{1,1,1,1,-1,-1,-1,-1},{0,0,-1,-1,0,0,-1,-1},{0,1,1,-1,0,1,1,-1}}; |
i8 : P == convexHull {P1,P2,P3} o8 = true |
i9 : PC = addPolyhedron({P1,P2,P3},PC) o9 = PC o9 : PolyhedralComplex |