The Boundary of a Shape and Its Classification

A unified algebraic foundation for shape computation is presented wherein the description of a shape is explored as a sum of disjoint segments and theresult of shape computation is expressed in terms of a classification of the boundaries of these segments. Shapes are considered as collections of spatial elements of limited but nonzero measure, independently of dimensionality or shape type. A spatial element is itself specified by two shapes: a carrier and a boundary. The carrier is a shape in which the element is embedded and is of the same type as the element. The boundary represents the form of the element and is a shape of a different type. A particular kind of spatial element or shape is a segment that has no nonempty proper subshape, the boundary of which is a subshape of the boundary of the segment. It is shown that a shape is the sum of a unique finite set of disjoint segments with disjoint boundaries. Then, the shape is said to be maximal and the boundary of a maximal shape is the sum of the boundaries of its maximal segments. Boundary segments of a shape can be classified with respect to another shape as to be inside or outside the other shape, or shared in the same way or shared oppositely between the two shapes. From this classification, the boundary of a shape resulting from a shape operation on two shapes is determined by summing appropriate classes of segments. In a similar way, shape relations between two shapes are shown to depend on the distribution of the boundary segments of each shape into these classes.

another shape, we will say that the given shape is 'part' of the other shape.Disjoint shapes have no parts in common -that is, an empty product -and a shape x can always be partitioned relative to any other shape y into disjoint shapes: x = (x -y) + x ⋅ y.Stiny (1991;1992) has examined specific models of shape algebras, namely, U, V and weighted algebras W defined for linear shapes in a Euclidean geometry.We consider shape algebras in which shapes are collections of spatial elements of limited but nonzero measure.We say that a shape is of the same type as its elements.For example, line shapes are collections of finite lines; plane shapes are collections of finite planes; solids are collections of finite volumes; curved shapes of a given type are collections of finite curves of the same type.A shape from a cartesian product of shapes has the 'compound' type of its constituent shape types.The element type acts as a filter for distinguishing categories of shapes.Additionally, an element is specified by its 'form', which is described by a shape.For example, the form of a finite line is defined by its pair of (end) points, the form of a finite rectilinear plane is defined by one or more polygonal line shapes and so on.The shape that describes the form of an element is necessarily of a different type, typically, that of a shape of a lower dimensional type.A spatial element is thus specified by two shapes: a carrier, c(x), and a boundary, b(x).The carrier is a shape in which the element is embedded and is of the same type as the element.The boundary represents the form of the element and is a shape of a different type.In principle, this model of shape algebra is independent of any underlying geometry.Particular models of shape algebras can be realized by mapping shapes to geometries in a specified way. Figure 1 illustrates a line shape, exemplar carriers and boundaries (sets of points) of its finite lines.The mathematical treatment of shapes given in this paper relies on the following definition for a segment.A spatial element or shape is a segment if it has no nonempty proper subshape the boundary of which is a subshape of the boundary of the segment.That is, x is a segment if and only if there is no shape y ≠ 0, y ≠ x, such that y ≤ x and b(y) ≤ b(x).A segment is thus a shape with a 'minimal' boundary with respect to the shape.Figure 2 illustrates this definition for plane segments.For any shape x that is not a segment, one can always find a shape y with y ≠ 0, y ≠ x, y ≤ x and b(y) ≤ b(x).Suppose y and x -y are sums of disjoint segments: y = y 1 + … + y n' and x -y = z 1 + … + z n'' .From y ⋅ (x -y) = 0, y i ⋅ z j = 0 for all i ≤ n' and j ≤ n''.Thus, x = y + (x -y) = y 1 + … + y n' + z 1 + … + z n'' = x 1 + … + x n with n = n' + n" and all x i (y i and z i-n' ) are pair-wise disjoint.By similar arguments, both y and x -y can be written as a sum of disjoint segments.This induction is finite because both y and x -y are parts of x, neither are equal to x, and the boundary of x is bounded (a boundary is a shape and any shape is bounded).For any shape algebra Σ, let Σ seg denote its shapes that are segments.Let connectives ∧ and ∨ denote logical and and or respectively.Consequently: (1) Every shape is the sum of a finite set of disjoint segments.
Since the x i 's are disjoint, x = x 1 ⊕ … ⊕ x n .This identity motivates the following definition.A set {x 1 , …, x n } of disjoint segments x i constitutes a representation for shape x if the x i 's satisfy (1).x and {x 1 , …, x n } are two alternative views of the same shape, one algebraic and the other representational.Every segment can be identified with a carrier, indeed, indefinitely many carriers (although it is convenient to define carriers uniquely, especially for computer implementations.)In principle, carrier shapes possess structurally and topologically interesting properties for shapes.For example, a line segment is carried by every line in which that segment can be embedded, a plane segment is carried by every plane in which that segment can be embedded and so on.For segment x, let c(x) denote any of its carriers.Then, c(x) minimally satisfies the following conditions: c(0) = 0 and x ≤ c(x).Carriers for segments can always be specified so that for any segment y, x ≤ y ⇔ c(x) ≤ c(y).Two segments are coequal (i.e., collinear, coplanar, cohyperplanar, etc.) if there is a carrier that carries both shapes.Note that all carriers of a segment are coequal.Carriers can always be specified so that for coequal segments, c(x ⋅ y) ≤ c(x) ⋅ c(y).Carriers extend to shapes in which case c(x) is the sum of the carriers of its segments.A shape is coequal if all its segments are coequal.A segment is necessarily coequal.Carriers for shapes can be specified so that c(x ⋅ y) ≤ c(x) ⋅ c(y).Note that for shapes x and y with representation {x 1 , …, x n } and {y 1 , …, y n' } respectively, the subshape relation can be expressed in terms of the segment carriers:

!
x " y # $x i (% y j ,c( x i ) " c( y j )) .In this fashion we can impose a topology on the carriers of a shape by requiring that c(c(x)) = c(x) for each x.
In practice, carriers are specified by equations.In this paper, we will regard the carrier of any segment as specified and identified, uniquely, by its equation.The equation of a carrier can be used to define coincidence of a shape with a carrier if the former satisfies the equation of the latter.The carriers of segments act as a filter in our process of distinguishing categories of shapes.In this model of shape algebra, pictorial equivalence does not imply shape equality.Figure 3 shows a curve segment s that is embedded in two different (curved) carriers given by equations g(x, y) = 0 and h(x, y) = 0.Although the curve segment s of type g is pictorially identical to the curve segment s of type h, the two are not the same shape.Pictorial equivalence assumes a pictorial scale and resolution at which equivalence is assessed.Equality between shapes requires that their carriers have identical equations and their boundaries are identical.In other words, the embedding character of a shape is integral to its identity.It is this embedding character of a shape rather than its point set equivalence that distinguishes the approach in this paper from conventional geometrical modeling.For linear shapes defined on a Euclidean geometry, this distinction between pictorial equivalence and shape equality does not arise since for any linear segment its carriers can be carried by a single largest carrier.The algebraic approach applies to linear as well as curved segments on condition that carriers are selected in such a way that pictorially identical segments always have the same carrier.This applies to all carriers that are equationally defined, because two curves with equationally defined carriers can never have more than a finite number of intersection points (within a finite area), and thus can never be pictorially identical (at the right level of detail).Otherwise, pictorial equivalence can only be assessed through approximation and it is generally considered only for a subset of potential carriers, e.g., NURBS.

Boundary and neighborhoods of a segment
The boundary defines the 'outline' or 'form' of a shape.For computational purposes, we need to know which part of the shape lies inside the boundary and which lies outside.For this we specify certain provisions on shapes to make this notion precise.To this end, we introduce the notion of a neighborhood of a segment as a shape within the proximity of the segment.A neighborhood of a segment is a shape such that the segment is a part of the boundary of the shape; notationally, Δ(x) is a (shape) neighborhood of x whenever x ≤ b(Δ(x)).By definition, Δ(0) = 0.The neighborhood of a segment is of a higher dimensional type than the segment, but the boundary of the neighborhood is of the same type as the segment.For instance, for point segments the neighborhoods are line shapes, for line segments these are plane shapes, for plane segments these are volumes and so on.The neighborhood of a line segment is illustrated in Figure 4.A neighborhood signifies a 'side' of the segment with respect to the neighborhood shape.On the other hand, a segment has indefinitely many neighborhoods.However: (2) No three neighborhoods of a segment can be both mutually disjoint and coequal.
In other words, each segment has two sides defined by a pair of mutually disjoint coequal neighborhoods.We extend this notion of neighborhood to a collection of segments that make up the boundary of a segment to be the composition of coequal neighborhoods of the individual segments.See Figure 5. Again, there cannot be three mutually disjoint coequal neighborhoods.The boundary (and by extension, any subshape of it) divides its coequal neighborhoods into two categories, one which is 'inside' the segment, and the other 'outside'.That is, (3) For any subshape of the boundary of a segment, there are two neighborhoods coequal with the segment, one contained in the segment and the other disjoint from it.Figure 6 illustrates this provision for a line shape to be a subshape of the boundary of a plane segment.Neighborhoods Δ 1 (l) and Δ 2 (l) are necessarily disjoint, since !" 1 (l ) # x $ " 2 (l ) % x = 0 & " 1 (l ) % " 2 (l ) = 0. We note that every shape is a neighborhood of its boundary.We can now state the condition that suffices for a shape to be a subshape of the boundary of a segment: (4) Any subshape of the boundary of a segment is also a subshape of the boundary of any other segment that contains the given segment provided there is a neighborhood coequal and disjoint from the latter segment.By comparing a neighborhood of a segment with any shape coequal with this neighborhood it follows that: (5) A segment and each of its neighborhoods can always be partitioned, with respect to any other shape coequal to the neighborhood, into two shapes and corresponding neighborhoods one contained in the second shape and the other disjoint from it.
(6) The boundary of a coequal shape equals the symmetric difference of the boundaries of the segments in its representation.Conversely, suppose there is a neighborhood Δ(l) ≤ y -x.Since l ≤ b(x), x is a neighborhood of l, and (y -x) • x = 0. Hence, it follows from (4) that l ≤ b(y -x), or y -x is a neighborhood of l.Suppose l ≤ b(y).Then, there is a neighborhood Δ*(l) with Δ*(l) • y = 0. Hence, Δ*(l) • (y -x) = 0. Since x ≤ y, Δ*(l) • x = 0 which violates provision (2).Therefore, !l / " b( y).Since this holds for an arbitrary l such that l ≤ b(x), l • b(y) = 0 for all such l.This establishes the necessary and sufficient condition for a shape to be a part of the boundary of a segment.
(7) Any subshape of the boundary of a segment is not a part of the boundary of any other shape that contains the segment if and only if there is a neighborhood, of the subshape, that is a subshape of the difference of the shape and the segment.
Define a partitioning on l and Δ 1 (l) with respect to x as follows: Define a partitioning on l and Δ(l) with respect to x as follows: Define a partitioning on l and Δ(l) with respect to y as follows: See Figure 9. From an implementation stand point, this result indicates that one never need inspect beyond the boundary of individual segments in order to obtain the boundary of a shape resulting from a shape arithmetical operation.A variation of this result is the start point for Earl's (1997) examination of shape boundaries and their properties.
(ii) x and y are not disjoint.There is a set {u 1 , …, u n } of disjoint segments such that x + y = u 1 + … + u n .Let u i and u j , i < j, be two segments such that b(u i ) • b(u j ) ≠ 0. From the above argument, u i + u j must be a segment.Thus, {u 1 , …, u i-1 , u i+1 , …, u j-1 , u j+1 , …, u n , u i + u j } is a set of disjoint segments that represents x + y.This process can be repeated replacing in the representation of x + y any two segments s and t, with b(s) • b(t) ≠ 0 by the sum s + t.This results in a representation of x + y by a set {v for all i ≠ j.However, this contradicts the fact that x is a segment.Hence, the representation of x + y must consist of a single segment, which equals x + y.We have established the conditions under which two coequal segments combine to form a segment under sum.
(9) The sum of two coequal segments is a segment if and only if either the segments are not disjoint or their boundaries are not disjoint.We are ready to describe a shape as the sum of a unique set of disjoint segments with disjoint boundaries.We first show that such a set exists.Consider any shape x {x 1 , …, x n } represented by disjoint segments with x = x 1 + … + x n .If b(x i ) • b(x j ) = 0 for all i ≠ j, then this set exists.Otherwise, any two segments x i and x j (i < j) By induction, this results in a set {y 1 , …, y n' } of disjoint segments with disjoint boundaries such that x = y 1 + … + y n' .Secondly, assume there are two representations for x by sets of disjoint segments with disjoint boundaries, {x 1 , …, x n } and {y 1 , …, y n' }.Then, at least one segment y i is different from all segments x j and we can write y i = y i • x 1 + … + y i • x n = z 1 + … + z n'' (with z 1 equal to the first y i • x j that is different from 0, and so on).z 1 , …, z n'' are disjoint segments with not all disjoint boundaries (otherwise, y i is not a segment).Suppose b(z k ) • b(z l ) ≠ 0. Consider a segment l ≤ b(z k ) • b(z l ).Then, given that z k • z l = 0, there exist two coequal disjoint neighborhoods Δ 1 (l) and Δ 2 (l) with Δ 1 (l) ≤ z k and Δ 1 (l) • z l = 0, and, Δ 2 (l) ≤ z l and Δ 2 (l) 0 and Δ 2 (l) ≤ z l ≤ x l' , and similarly for x k' .Thus, l ≤ b(x k' ) • b(x l' ), which contradicts our assumption.Whence, the following proposition which forms the basis of the maximal segment representation of shapes (Krishnamurti, 1992a).
(10) Every shape is the sum of a unique finite set of disjoint segments with disjoint boundaries.

Boundary shapes
Previously, we defined a segment as a shape with a minimal boundary.As such this definition does not lend itself to easy computer implementation.Instead, we now provide a semi-constructive definition of a segment using the notion of a simple boundary, that is, a 'minimal' boundary shape as a part of the boundary shape, however, not relative to the defined shape.A shape l is a boundary shape whenever there is a shape x such that l = b(x).The boundary shape l defines the shape x and this is expressed as x = Γ(l).Γ may be viewed as a 'constructor' function.Note that the empty boundary shape defines only the empty shape; Γ(0) = 0.A boundary shape x is a simple boundary if and only if there is no boundary shape y, y ≠ 0 and y ≠ x, that is a subshape of x.It immediately follows that a simple boundary x defines a segment Γ(x).However, the boundary shape of a segment is not always a simple boundary.Figure 11 illustrates this for planar segments.On the other hand, the boundary of a coequal shape can always be described as composed of a finite set of disjoint simple boundaries.We show that the boundary of any segment can be decomposed into disjoint simple boundaries.
Consider a simple boundary y that is a subshape of the boundary x defining the segment Γ(x).From the arguments above, we can conclude that either Γ(x) • Γ(y) = 0 or Γ(x) ≤ Γ(y).If the latter, we say that y is an outer boundary; otherwise, y is an inner boundary.Figure 12 illustrates the classification into inner and outer boundaries of a set of nonintersecting simple line shape boundaries.A simple boundary y that is a part of the boundary of a segment x is an outer boundary for x if x ≤ Γ(y), and an inner boundary for x, otherwise.A segment has a single outer boundary, and either zero or more inner boundaries.Figure 13 illustrates this with planar segments and shapes.

Figure 13. Outer and inner boundaries for planar shapes: (a) a segment with a single outer boundary; (b) a segment with a single outer and multiple (two) inner boundaries; (c) a shape (with two segments) with two outer and a single inner boundary; (d) a shape with four outer boundaries.
There is at least one outer boundary for a segment, which we can show by the following reasoning.There is a set of disjoint simple boundaries, {s 1 , …, s n }, such that b(x) = s 1 + … + s n .If none of the shapes s 1 , …, s n is an outer boundary, then Γ(s i ) • x = 0 for all i ≤ n.
A canonical representation of a shape constitutes a unique representation of the shape as a set of segments and a unique representation of each segment as a set of simple boundaries.Denote the unique outer boundary of x as s 0 .Consider the shape s = b(x) -s 0 .By (11), there is a finite set {s 1 , …, s n-1 } of disjoint simple boundaries such that b(x) = s 0 + s = s 0 + s 1 + … + s n-1 .Consider the set {Γ(s 1 ), …, Γ(s n-1 )} of segments defined by s 1 , …, s n-1 .If the segments are all disjoint, it then follows from (10) that this decomposition into simple boundaries is unique.
Note that this proposition holds only for segments.As Figure 14 shows, the boundary of a shape can be interpreted in two ways each as a set of disjoint simple boundaries.The set of simple boundaries representing the boundary of a segment defines a set of segments that relate in a unique way to the original segment.Let x be a segment with b(x) = s 0 + s 1 + … + s n-1 .Suppose s 0 is the outer boundary for x and s 1 , …, s n-1 are the inner boundaries for x.We have x ≤ Γ(s 0 ) and x • Γ(s i ) = 0 for all 1 ≤ i ≤ n-1, or, x ≤ Γ(s 0 ) -(Γ(s 1 ) + … + Γ(s n-1 )).Conversely, consider the shape y = Γ(s 0 ) -(Γ(s 1 ) + … + Γ(s n-1 )) -x.We have y • x = 0.If y ≠ 0, then, there is a segment l ≤ b(y) ≤ b(x) and two coequal disjoint neighborhoods Δ 1 (l) and Δ 2 (l) with Δ 1 (l) ≤ y, Δ 2 (l) ≤ x, Δ 1 (l) • x = 0, and Δ 2 (l) • y = 0. Given x ≤ Γ(s 0 ) -(Γ(s 1 ) + … + Γ(s n-1 )), we have Δ 2 (l) ≤ x ≤ Γ(s 0 ) and Δ 1 (l) ≤ y ≤ Γ(s 0 ), such that 0 s l !/ .In a similar fashion, , which contradicts the assumption.Thus, y must be the empty shape and x = Γ(s 0 ) -(Γ(s 1 ) + … + Γ(s n-1 )).Hence, we have the following specification for a segment: (14) Each segment is the shape difference of the shape defined by its simple outer boundary and the shape resulting from the sum of the shapes defined by its simple inner boundaries.

Maximal shapes
A segment x i in the representation of a shape x {x 1 , …, x n } is maximal if and only if it is disjoint with all other segments x j , i ≠ j, in the representation and its boundary is represented as a set of simple boundaries each of which is a maximal shape.A shape x {x 1 , …, x n } is maximal if and only if each of its segments is maximal.A shape of distinct points is always maximal.From ( 10) and ( 13) we posit that the maximal segment representation is canonical.A canonical representation offers certain computational advantages, in particular, a shape x {x 1 , …, x n } is a subshape of a maximal shape y {y 1 , …, y n' } if and only if each segment x i is part of a maximal segment y j .Moreover, (15) The boundary of a maximal shape is the sum (and symmetric difference) of the boundaries of its maximal segments.
The difference between propositions (6) and ( 15) is that the latter applies to any shape not just coequal shapes.The proof is straightforward.It is important to note that for Figure 14, the interpretation that is consonant with the definitions of maximal shape and segment is the shape consisting of two maximal segments each defined by a single outer boundary (namely, Figure 14a).

Comparing boundaries
As the preceding development indicates, in computing the result of a shape arithmetical operation, it is important to know which subshapes of the boundary of both shapes contribute to the boundary of the resulting shape.We can do this by classifying the boundary of each shape with respect to the other.In this sense, boundary segments can be considered to be inside or outside the other shape, or shared between shapes.We examine each category separately.

Shared segments
A boundary segment is deemed shared between two shapes if it is a subshape of the boundaries of both shapes.Let s(x, y) denote the shape formed by the shared boundary segments of shapes x and y.Then But this implies that l has three coequal disjoint neighborhoods which is impossible and hence, m(x, y) • n(x, y) = 0.In short, (16) The same-shared and oppositely-shared boundary segments partition the shared boundary segments.
which is not immediately intuitive from the appearance of the formulae.Figure 16 illustrates the same-shared and oppositely-shared boundary segments for two shapes.In the sequel, we use the letters S, M and N to denote the shapes formed by the shared, sameshared and oppositely-shared boundary segments when the context of the shapes can be assumed.That is, S ≈ s(x, y) = s(y, x); M ≈ m(x, y) = m(y, x); and N ≈ n(x, y) = n(y, x).

Inner and outer segments
We next examine boundary segments that are not shared between two shapes.A boundary segment of a shape is said to be inner relative to another shape if the segment is not shared and it has a neighborhood that is a subshape of the second shape.Let i(x, y) denote the inner boundary segments of x relative to y.Then, Then there is a neighborhood Δ(l) ≤ x.By (5) we can partition l and Δ(l) with respect to y as follows: Therefore, l -m must be a subshape of the boundary of y, which contradicts the assumption that l -m ≤ i(x, y).Thus, A boundary segment of a shape is said to be outer relative to another shape if the segment is not shared and it has a neighborhood that is disjoint from the second shape.Let o(x, y) denote the outer boundary segments of x relative to y.Then, As before, consider a boundary segment l ≤ b(x).Then !"#(l ) : #(l ) $ x and we can partition l and Δ(l) with respect to y as follows: that is, m must be a subshape of the boundary of y which contradicts the assumption that m   The inner and outer segments are pairwise disjoint.Assume i(x, y) • o(x, y) ≠ 0. That is, there is a segment l ≤ i(x, y) • o(x, y), l ≠ 0. From l ≤ i(x, y), there is a neighborhood Δ 1 (l) with Δ 1 (l) ≤ y, and from l ≤ o(x, y) there is a neighborhood Δ 2 (l) with Δ 2 (l) • y = 0. Given Δ 1 (l) ≤ y and Δ 2 (l) • y = 0, it follows that l must be a boundary segment of y.However, l is a boundary segment of x and, thus, l is a subshape of S. By definition i(x, y) • S = 0 and S • o(x, y) = 0, we conclude that i(x, y) • o(x, y) = 0. Let the symbols I x ≈ i(x, y) and O x ≈ o(x, y) denote the inner and outer boundary segments when the context of the shapes are known.Consider the sum S + I x + O x .(17) The boundary of any shape is the sum of its shared, inner and outer segments with respect to any other shape.Moreover, these segments are mutually disjoint.b

Shape operations
Previously, in (8), the boundary of the shape resulting from a shape operation is described as a subshape of the sum of the boundaries of two shapes.In this section we refine this result and show that this boundary equals the sum of the shapes from appropriate classes of boundary segments.Table 1 summarizes the inclusion of the classes of boundary segments for each of the shape arithmetical operations.
Table 1.Classified boundary segments that make up the shape resulting from a shape operation.
The proofs below rely on the construction of two neighborhoods, termed left(l) and right(l), for a boundary segment l of the shape x classified with respect to coequal shape y.We employ the following notation.For any boundary segment l of x, left(l) denotes a neighborhood of l such that left(l) ≤ x and either left(l) ≤ y or the product of left(l) • y = 0. Similarly, right(l) denotes a neighborhood of l such that right(l) • x = 0 and either right(l) ≤ y or right(l) • y = 0. From the previous discussion these neighborhoods must exist if l is deemed inner, outer, same-shared or oppositely-shared with respect to y.In the proofs below we let l denote an arbitrary boundary segment of x such that it is deemed inner, outer, same-shared or oppositely-shared with respect to y.Consider b(x + y).left(l) is a subshape of x + y.Thus, l is a boundary segment of x + y if and only if right(l) is not a subshape of x + y, and therefore if right(l) • y = 0.This is the case if l is deemed outer or same-shared with respect to y (as illustrated in Figure 19).Remark.There is a more direct proof: The proof is similar for an arbitrary boundary segment of y with respect to

Shape Relations
The relation between two coequal shapes depends on the distribution of the boundary segments of each shape into the four classes.In particular, it depends on whether or not each of the classes contains one or more segments.The particular dependencies are stated below.
The four basic shape relations -contain, overlap, discontiguous and share_boundary -are defined in Table 2.
Table 2.The basic shape relations. x Table 3 summarizes the dependencies between the shape relations and conditions on the classified boundary segments.The necessity for a particular class of boundary segments to be nonempty is indicated by the symbol . Figure 21 graphically illustrates that each of the conjunctions (i through vii) is necessary as a sufficient condition for two shapes to overlap.

Concluding remarks
We have shown that shape operations defined over a Boolean ring -independent of its underlying shape type -can be preprocessed in a unified way by classifying the boundary of a shape with respect to another by splitting the boundary segments so that each split segment can be identified as inner, outer, shared in the same way or shared oppositely with respect to the other shape.Summing appropriate classes of segments provides the boundary of the resulting shape.The same classification process can be used to define relations between pairs of shapes.This is illustrated by the algorithms (Figure 22) which reflect Table 1 and Table 3. (The conventions and the form of the pseudo-code for the algorithms are due to Cormen et al, 1990.)CLASSIFY returns the split boundary segments of two shapes classified against each other.The appropriate segments are combined by CONSTRUCT which constructs the shape according to a given boundary.CLASSIFY and CONSTRUCT are geometry dependent.For different geometrical realisations, different algorithms for CLASSIFY and CONSTRUCT would need to be designed.For shape algebras U n , we employ the following representational mapping shown in Table 4.A shape is a finite composition of segments under sum (and maximally under symmetric difference).
A shape is embedded in another shape in U n if each segment in the first shape is embedded in a coequal segment in the second shape.
A main distinction between the work presented here and conventional geometrical modeling is that the latter is based on a point-set representation of shapes.This representation may satisfy a regularised algebra derived from a Boolean algebra with 'fixes' that account for valid physical interpretations of point-sets resulting from a shape operation (Mäntyla, 1988;Hoffman, 1989).Alternatively, operations may not be closed within one dimensionality and, instead, be defined across dimensionalities (Gursoz et al, 1991) In the latter case, shapes cannot be defined to share boundary.It is possible, however, to construct isomorphisms between shapes defined in terms of structured parts as in this paper to regularised point-set representations of spatial objects to provide conventional valid physical interpretations of shapes and also to validate the neighborhood provisions (2) and (3) (see Stouffs, 1994, for these constructions and Henle, 1979, for relevant point-set topology conditions).Further, conventional geometrical modeling makes a distinction between manifold and nonmanifold spatial objects, which is neither considered nor required in the formulation presented in this paper.This distinction arises from continuity and differentiable properties of subspaces of Euclidean spaces (Spivak, 1965), and so are relevant for point-set based formulations.Moreover, the boundary computations described in Table 1 and Table 3 are  In practice, rules are specified so that (a -b) = 0 in which case the boundary of v can be directly obtained by classifying u against a representation of the change invoked by the shape rule.

Figure 1 .
Figure 1.A line shape with its segments, exemplar carriers and boundary.

Figure 2 .
Figure 2. Exemplar plane segments and their boundary shape.

Figure 3 .
Figure 3. Two unequal curved segments that are pictorially the same.

Figure 4 .
Figure 4.A line segment x and possible neighborhoods Δ(x).Notice that x ≤ b(Δ(x)).Notice that x is coincident with its neighborhood shape.

Figure 5 .
Figure 5.A shape x, its boundary b(x) and two possible neighborhoods Δ(b(x)) coequal to x.

Figure 6 .
Figure 6.A subshape l of the boundary b(x) of a segment x and two neighborhoods Δ 1 (l) and Δ 2 (l) coequal to x.

Figure 7
Figure 7 illustrates this proposition for a pair of plane segments.

Figure 7 .
Figure 7. Two plane segments x and y and subshape l of the boundary of x, with the three possible partitions of l and x with respect to y: (i) m = 0, (ii) m ≠ 0 ∧ m ≠ l, (iii) m = l.
It follows that: (8) For any arithmetic operation on shapes the boundary of the resulting shape is a part of the sum of the boundaries of the two shapes.For a shape operation *, b(x * y) ≤ b(x) + b(y).

Figure 9 .
Figure 9. Two shapes x and y, the sum of their boundaries and the boundaries under the operations of sum, product, difference and symmetric difference.

Figure 10
Figure10illustrates these conditions for reducing a pair of volume segments to a single volume segment.Note that segments that are not coequal cannot combine to form a single segment.

Figure 10 .
Figure 10.The sum of two segments is a segment if the segments are not disjoint (cases a, b); or if their boundaries are not disjoint (case c); and is not a segment otherwise (cases d, e, f).

Figure 11 .
Figure 11.Examples of segments (a) with a simple boundary; and (b, c) without a simple boundary.

Figure 12 .
Figure 12.Inner and outer boundaries among a set of non-intersecting, simple boundaries.Outer boundaries are drawn solid, inner boundaries dashed.

Figure 14 .
Figure 14.Two different interpretations for the boundary of a plane shape.Both interpretations result in two simple boundaries: (a) two outer boundaries and (b) one outer and one inner boundary.
, s(x, y) = b(x) • b(y) = s(y, x). Figure 15 illustrates the shared boundary segments for two volume shapes.Shared boundary segments can be further classified.

Figure 15 .
Figure 15.Two shapes x and y and their shared boundary segments.

Figure 16 .
Figure 16.The same-shared and oppositely-shared boundary segments of two shapes x and y.
Figure 17 and Figure 18 respectively illustrate the inner and outer boundary segments of two volume shapes.

Figure 17 .
Figure 17.The boundary segments of two shapes x and y that are deemed inner with respect to the other.

Figure 18 .
Figure 18.The boundary segments of two shapes x and y that are deemed outer with respect to the other.

Figure 19 .
Figure 19.Inner and outer neighborhoods of a boundary segment l of x with respect to shapes x and y.Only if l is deemed outer or same-shared with respect to y, is l also a boundary segment of x + y.

Figure 20 .
Figure 20.Inner and outer neighborhoods of a boundary segment l of x with respect to shapes x and y.Only if l is deemed inner or same-shared with respect to y, then l is also a boundary segment of x + y.
(b(x • y) • (b(x) + b(y)) -S) + b(x • y) • S = (b(x • y) -S) + b(x • y) • S = b(x • y) Next consider b(x -y).right(l) • x = 0 implies that right(l) • (x -y) = 0. Thus l is a boundary segment of x -y if and only if left(l) is a subshape of x -y, and therefore if left(l) • y = 0.This is the case if l is deemed outer or oppositely-shared with respect to y.An illustration can be constructed from Figure 19 with " ![l same -shared " left(l ) # y \ right(l ) $ y = 0]" replaced by " ![l oppositely -shared " left(l ) # y = 0 \ right(l ) $ y]".The proof is similar, but opposite, for an arbitrary boundary segment of y with respect to x.That is, b(x -y) = O x + I y + N.Finally consider b(x ⊕ y).Since left(l) is a subshape of y, if left(l) • y = 0, then left(l) must be a subshape of x ⊕ y.Since right(l) • x = 0, only if right(l) • y = 0 is right(l) • (x ⊕ y) = 0.In this case, l is deemed outer with respect to y. Similarly if both left(l) and right(l) are parts of y, and therefore l is deemed inner with respect to y, then l is a subset of the boundary of x ⊕ y.A similar illustration to Figure19can be constructed by replacing " !

Figure 21 .
Figure 21.Examples showing that each of the conjunctions i through vii is necessary as a (sufficient) condition for two shapes to overlap.The heavy-shaded area represents the overlapping region.

Figure 22 .
Figure 22.Algorithms for shape arithmetic and relations.∪ denotes the merge operation on collections of segments.
independent of the dimensionality, type and genus of the shapes involved.Lastly, the basic equation of a shape grammar interpreter isv = u -+ b if a ≤ u, which implies that v = u -(a -b) + (b -a).If we were to classify u against both (a -b) and (b -a) then b(v) = O u + I (a -b) + O (b -a) + M (b -a) -N (b -a) , O u are the segments of u outer relative to (a -b).
contain overlapA shape x contains a shape y if and only if y is a subshape of x and, therefore, if and only if the difference of y with respect to x equals 0. Since b(y -x) consists of the boundary segments in I x + O y + N, y -x = 0 if and only if these three classes are empty.Two shapes x and y are disjoint (possibly with non-disjoint boundaries) if and only if x • y = 0. Since b(x • y) consists of the boundary segments in I x + I y + M, x • y = 0 if and only if these three classes equal 0. For disjoint shapes x and y to share boundary, the class of oppositelyshared boundary segments has to be nonempty.For x and y to be discontiguous, that is, disjoint with disjoint boundaries, the class of oppositely-shared boundary segments has to be empty; it follows, naturally, that the boundary segments of each are outer with respect to the other shape.
Two shapes x and y have a shape in common if and only if x • y ≠ 0. If the difference of shape with respect to the other is nonempty, then neither contains the other.Thus x and y overlap, without containment, if and only if (x • y