Solid Modeling Ron Goldman Department of Computer Science Rice University
Solids Definition 1. A model which has a well defined inside and outside. 2. For each point, we can in principle determine whether the point is inside, outside, or on the solid. Purpose 1. Model More Complicated Shapes 2. Interference Checking 3. Mass Properties Calculations Volume Moments of Inertia 4. Finite Element Analysis Stress 5. Manufacturing (CAD/CAM) Numerical Control
Representations 1. Constructive Solid Geometry (CSG) 2. Boundary Representation (B-REP) 3. Octree
1. Constructive Solid Geometry
Constructive Solid Geometry (CSG) Data Structure = Binary Tree Nodes = Boolean Operations Union, Intersection, Difference Nodes = Transformations To Position and Scale Objects Leaves = Primitives Blocks and Wedges Natural Quadrics -- Spheres, Cylinders, Cones Other Quadrics -- Ellipsoids, Paraboloids, Hyperboloids Torus -- for blending quadrics (piping) Extruded Solids -- Solid Cylinders and Cones Swept Solids -- Solids of Revolution Deformed Solids
Ray Tracing CSG Trees Algorithm For each Pixel, Construct a Line from the Eye through the Pixel. If the Solid is a Primitive Compute all the intersections of the Line with the Primitive. Display the closest intersection. Otherwise if the Solid is a CSG tree Recursively find all the intervals in which the line intersects the Left and Right subtrees. Combine these intervals using the Boolean operation at the root. Display the closest intersection.
Ray Tracing CSG-Trees (continued) Transformation Nodes If the node is a transformation T, then Compute the inverse transformation T 1 Apply T 1 to the line L Intersect T 1 (L) with the Solid below the node Remarks 1. Initially, there is no need to perform T on the intersection points because we are computing parameter values, not points! 2. Transformation nodes permit use of canonical primitives in canonical positions. May simplify intersection computations.
Volume Computations Volume (Riemann Sum) Same Algorithm as Display, but Use parallel rays (Eye at Infinity). Think of each ray as a beam with length and width Δx,Δy. Multiply each intersection interval by Δx,Δy. Add the results of all the intervals and all the rays.
Volume Computation Ray Tracing Volume Algorithm Initialize Volume = 0 For Each Pixel Construct a Line through the Pixel perpendicular to the Plane of the Pixel. (Eye at Infinity) If the Solid is a Primitive Compute all the intersections of the Line with the Primitive Vol = Vol + Length(I k )ΔxΔy. k Otherwise if the Solid is a CSG Tree Recursively find all the intervals in which the Line intersects the Left and Right subtrees. Combine these intervals using the Boolean operation at the root Vol = Vol + Length(I k )ΔxΔy. k
Alternative Volume Computation Monte Carlo Algorithm Construct a Bounding Box around the Solid. Select points at random inside the Bounding Box. {Random Number Generator} For each point, determine whether it is inside or outside the Solid. If the Solid is a Primitive, perform a parity check. {Ray Casting} Otherwise if the Solid is a CSG tree Recursively determine whether the point is inside or outside the Left and Right subtrees. Combine these results using the Boolean operation at the root Vol(Solid) Vol(Box) Vol(Solid) # Points inside Solid # Points selected # Points inside Solid # Points selected Vol(Box)
Constructive Solid Geometry Advantages Compact representation Natural user interface Robust data structure Parametrized objects Parametrized primitives Canonical primitives in canonical positions Easy analysis -- Ray Casting Rendering Mass Properties Inside/Outside
Constructive Solid Geometry (continued) Disadvantages No adjacency information for NC etc. Difficult to distinguish the part from the scrap No direct access to vertices and edges Difficult for designer to select specific part of object No tweaking of the model Not easy to perform FEM Representation not unique Hard to extract important features for manufacturing Holes, Slots,...
2. Boundary Representation
Boundary Representation (B Rep) Data Structures=Boundary File Topology (Binary Information) Connectivity Vertices, Edges, Faces Geometry (Floating Point Data) Position, Orientation, and Size Points, Curves, Surfaces Analysis Algorithm=Ray Casting Intersect with surface boundaries No special techniques here
Topology and Geometry Topology Geometry Vertex Point Edge Curve Face Surface
Topology Vertices, Edges, Faces For solids bounded by 2-manifolds Each edge connects 2 vertices Each edge lies on two faces Each face is defined by a set of non-intersecting loops Connectivity information explicit E V E F Other pointers as required for 9 possible adjacency relations Winged-edge data structure Speed vs. Storage Answers questions of the form: Is A on or adjacent to B Pointers to Geometry V P E C F S
Winged Edge Topology Rationale Fast Retrieval of Topological Information Supports All Queries Easy to Maintain Medium size Data Structure Edge Data -- Oriented Edge 2 Vertices -- First and Second, Previous and Next (orientation) 2 Faces -- L and R 4 Edges -- P R, N R and P L, N L Vertex Data Point (Geometry) 1 Edge Face Data Surface (Geometry) 1 Edge
Winged Edge Data Structure N L N N R L Face P L E P R Face P R
Winged Edge Topology (continued) Queries Find all edges surrounding a face Find all faces adjacent to a face Find all vertices on a face Find all edges on a vertex M Faces with Holes Problem -- not supported by winged edge structure Solution -- auxiliary edges connecting hole bdy to outer bdy Auxiliary edges have same face on both sides!
Euler s Formula Formula (for solids bounded by 2-manifolds) V E + F H = 2(C G) V = vertices E = edges F = faces H = holes in the faces C = connected components G = holes in the solid = genus Examples Platonic Solids (LHS=2) Torus (LHS=0)
Intersection Algorithm Algorithm Intersect each surface (face) of A with each surface (face) of B to form new curves on A and B. {Difficult Computations} Intersect each new curve with existing edges on the old faces to form new vertices and edges on A and B. Insert new faces, edges, and vertices into topology of A and B. {Update Topological Data Structures} Combine the boundary topologies based on the particular Boolean operation. Boundaries (A B) = ( A A inb ) ( B B ina ) (A B) = A inb B ina (A B) = ( A A inb ) B ina (B A) = ( A inb ) ( B B ina )
Intersections Examples Cut a cylindrical corner from a box. Remarks Maintaining correct boundary files is time consuming. Maintaining correct boundary files is susceptible to numerical errors. Computing correct and accurate intersections is difficult.
Boundary Representation Advantages Adjacency information for NC etc. Simple to find connected components using topological structure Distinguish part from scrap NC tool path verification Representation is unique Verification of model correctness using Euler s formula Tweaking of vertices and edges Easy to extract important features for manufacturing Holes, Slots,... Disadvantages Large data base Slow computation of B-Rep evaluation from CSG input Hard to maintain robust models for curved surfaces Disagreement between geometry and topology Tangencies particularly difficult to handle
3. Octrees
Octrees Tree Data Structure (Divide and Conquer) Divide a cube into 8 octants Label each octant: E = empty, F = full, P = partially full Recursively subdivide the P nodes until their descendent are E, F, or a lowest level of resolution (cutoff depth) is reached Observations Number of nodes proportional to Surface Area Subdivision occurs mostly to capture the boundary
Algorithms Ray Casting Intersect Line with all F voxels and accept nearest hit Boolean Operations Apply Boolean operation to corresponding nodes in octree Union If either node is F, place F in result Otherwise if both nodes are E, place E in the result Otherwise, mark node as P and recursively inspect the children Intersection If either node is E, place E in the result Otherwise if both nodes are F, place F in the result Otherwise, mark node as P and recursively inspect the children If all children marked E (F), then change P to E (F)
Octrees Advantages Fast Volume/Mass Properties Calculations -- sum the voxels Fast Boolean operations -- simple interference checking Fast scaling and 900 rotations around axes Fast Mesh Generation? Much more compact representation than spatial enumeration Accuracy as desired Disadvantages Difficult to perform arbitrary affine transformations Coordinate dependent model High accuracy requires high storage
Summary CSG B REP Octree Accuracy Good Good Mediocre Domain Large Small Large Uniqueness No Yes Yes Validity Easy Hard Easy Closure Yes No Yes Compactness Good Bad Mediocre
Problems 1. Converting between different representations CSG to B REP (Boundary Evaluation) B REP to CSG (Hard) 2. Extracting information from a particular representation Connected Components Adjacent Patches 3. Robust Intersections Surface Surface Ray Casting 4. Blends and Offsets 5. Tolerances 6. Features for Manufacturing