• Aucun résultat trouvé

The CSG Representation

Dans le document Computer Graphics and Geometric Modeling (Page 183-187)

5.3 Representation Schemes

5.3.3 The CSG Representation

In constructive solid geometry (CSG) one represents objects in terms of a sequence of Boolean set operations and rigid motion operators starting with a given collection of primitive objects. One can express this representation pictorially as a binary tree.

For example, in Figure 5.11 the binary tree on the left is used to represent the union of three blocks, one of which has been translated by a vector v. Although the idea is simple enough, we must get a little technical in order to give a precise definition.

Let P be a set of r-sets in Rn. The elements of P will be called primitive objects.

Let O be a set of regularized binary set operators such as »*,«*,-*, . . . . Let M be a set of pairs (m,x) where m is a label for a rigid motion of Rn such as a translation, rotation, . . . , and x is data that defines a specific such motion. For example, if n =2, then (rotation,(p,p/2)) is a possible pair in M and represents the rotation of R2about pthrough an angle p/2. If (m,x) ŒM, then let m(x) denote the rigid motion defined by the pair (m,x).

Figure 5.10. A boundary representation graph.

Although one is free to choose any set of primitives or transformations for a csg-rep, generic halfspaces of one sort or another are usually used as primitives. Two common csg-reps used

(1) “arbitrary” (possibly unbounded) generic halfspaces as primitives, or (2) bounded generic halfspace combinations as primitives.

Primitives are often parameterized. For example, a primitive block is usually con-sidered to be situated at the origin and to be defined by the three parameters of length, width, and height. One then talks about instancinga primitive, where that term means

(1) assigning values to the configuration parameters, and then

(2) positioning the result of (1) via a rigid motion (which could also be viewed as assigning values to positional parameters).

Csg-reps can handle nonmanifold objects. Their exact domain of coverage depends on

(1) the primitives (actually the halfspaces which define them), (2) the motion operators that are available, and

(3) the set operators that are available.

It is interesting to note the results of an extensive survey of mechanical parts and what it takes to describe them which can be found in [SaRE76]. Fully 63% of all the parts could be handled with a CSG system based on only orthogonal block and cylinder primitives. A larger class of primitives provided a natural description of over 90% of the parts. This indicated that CSG is therefore a good fit for a CAD system in that sort of environment because most mechanical parts seemed to be relatively simple.

If one uses general operations and bounded primitives, then one gets a represen-tation that is

(1) unambiguous, (2) not unique, (3) very concise, and

(4) easy to create (at least for its domain of coverage).

One of the biggest advantages of a csg-rep over other representation schemes is that validity is pretty much built into the representation if one is a little careful about choosing primitives. For example, if one uses r-sets as primitives and arbitrary regu-larized set operations, then the algebraic properties of r-sets ensure that a represen-tation is always valid. This is not the case if operations are not general, for example, if the union operation is only allowed for quasi-disjoint objects. Also, in a CSG system based on general generic halfspaces, some trees may represent unbounded sets and hence not be valid. It is true however that, by in large, all syntactically correct CSG representations (trees) are also semantically correct.

Because of the tree structure of a CSG representation, one can often use a divide-and-conquer approach to algorithms: one first solves a problem for the primitive

objects and then uses recursion. See Algorithm 5.3.3.1. The point membership clas-sification function, which is discussed in Section 5.9, is an example of this.

One disadvantage with a CSG representation is that it is not easy to generate a display using it because one needs the boundary of an object for that. Getting a bound-ary representation for an object defined by CSG (a process referred to as boundbound-ary evaluation) is relatively hard. We look at this in more detail in Section 5.9. One problem in this context (especially for mechanical design) is how to define a “face” of an object. This certainly is no problem in the linear case, but it is for curved objects.

See Figure 5.12. What should the faces be in that figure? Some minimal characteris-tics of a face are:

(1) A face should be contained in the boundary of the solid.

(2) Topologically, a face should be a surface with boundary.

(3) If the solid was defined via regularized Boolean set operations from a collec-tion of halfspaces {Hi}, then each face should be contained in bHifor some i.

(4) Faces should be quasi-disjoint, that is, pairwise intersections of faces should either be empty or lie in their boundary.

answer function Solve (CSG-tree T) begin

answer ans1, ans2;

operation op;

if IsPrimitive (T)

then return (PrimitiveAnswerOf (T));

else begin

ans1: = Solve (LeftSubtree (T));

ans2: = Solve (RightSubtree (T));

op : = ValueAtRoot (T);

return (CombineAnswers (ans1,op,ans2));

end end;

Algorithm 5.3.3.1. A divide-and-conquer approach in CSG.

Figure 5.12. What are the faces of this solid?

Another issue when it comes to faces is how to represent them? We shall see in Section 5.9 that to represent a face Fwe can

(1) represent the halfspace in whose boundary the face Flies (for example, in the case of a cylinder, use its equation),

(2) represent the boundary edges of F(the boundary of a face is a list of edges), and

(3) maintain some neighborhood information for these bounding edges and orient the edges (for example, we can arrange it so that the inside of the face is to the right of the edge or we can store appropriate normal vectors for the edges).

This scheme works pretty well for simple surfaces but for more complicated surfaces one needs more.

Dans le document Computer Graphics and Geometric Modeling (Page 183-187)