Sunteți pe pagina 1din 11

LECTURE 32

## Computational Solid Geometry

Primitive based: It is based on the notion that a physical object can be divided into a set of primitives basic elements or shapes that can be combined in a certain order following a set of rules ( Boolean operations) to create the object. Primitives themselves are considered valid CSG models. Each primitives is bounded by closed and orientable surfaces. CSG model is fundamentally and topologically different from a B-rep model in that it does not store faces, edges and vertices explicitly. Instead it evaluates them whenever needed by algorithms. CSG representation is of considerable importance for manufacturing

## Primitive based Vs Half-space based CSG Schemes

There are two types of CSG schemes Primitive Based CSG: It is based on bounded valid solid primitives, r-sets. It is the most popular CSG scheme. Half space Based CSG :This scheme uses unbounded half spaces (non r-sets). Bounded solid primitives are considered composite half spaces and the boundaries of these are the surfaces of the component half spaces. +

## Data Structure of CSG

Like in B-rep, the database stores topology and geometry. The validity checking in CSG scheme occurs indirectly. The each primitive that is combined using a Boolean operations (r-sets) to build the CSG model is checked for its validity. The common data structures used for CSG are graphs and trees

## CSG Data Structure

Graph: A graph is defined as a set of nodes connected by a set of branches or lines. Path: Each node in a tree belongs to a path E.g. A to G Cycle: If starting and ending nodes are the same the path is called a cycle
A

Root node

## CSG Data Structure

Cyclic Graph: If a graph contains a cycle it is called cyclic otherwise it is acyclic. Path: Each node in a tree belongs to a path E.g. A to G Cycle: If starting and ending nodes are the same the path is called a cycle
A

Indegree = 3 Outdegree = 2
G

Graph

Digraph

## Tree and Binary Tree

Tree: A tree is an acyclic digraph in which a single node called root node has a zero indegree and every other nodes has an indegree of one. Binary Tree: In a tree if the descendent of each node are in order (from left to right) and each node except the leaf node has two decedents (left and right), then the tree is called a binary tree.
A A

Tree

Binary Tree

## Binary Tree and Subtree

Subtree: Any binary tree can be thought of as joining together of 2 subtrees. A left subtree and a right subtree rooted at two successor nodes
A A

C B C B G F E D E

Left subtree

Right subtree

nL = nR
Balanced binary tree

nL nR
Unbalanced binary tree

## Inverted Binary Tree for CSG Model

Inverted Binary Tree: If the direction of each connector (arrow) are reversed then we get an inverted binary tree wherein each node has one outdegree except the root node. Root node: A node with outdegree = 0. Any node that does not have descendent. Leaf node: Any node that does not have a predecessor or indegree = 0. Interior node: Any node with outdegree > 0 is an interior node.
A B C

## Inverted Binary Tree as CSG Tree

CSG Tree: The inverted binary tree is very convenient to represent the CSG operations. Here each of the leaf nodes is a valid solid primitive. The intermediate nodes are the transition states of the solid modeling (r-set) operations. The root node is the resulting solid from the set operations. Here n primitives require (n-1) Boolean operations to complete the construction of the object. A B D D C D C
D

S=AUBUC S

## Primitives =4 Operations=3 Nodes=2n-1=7

A B
A

AUB

CUD

B CSG Tree

Tree Traversal
Tree Traversal: Visiting the nodes in sequential or orderly and efficient way. Many of the sorting and searching algorithms need to do the tree traversal Traversal methods: Two broad methods are: 1. Depth first 2. Breadth first The depth first is further divided into the following types depending on the order in which the root node is visited a) Preorder b) Inorder
1 2

c)Postorder
3

Preorder

Inorder

Postorder

Tree Traversal
Preorder: We have the following recursive algorithm Algorithm 1. Visit the root 2. Traverse the left subtree in preorder 3. Traverse the right subtree
2 9 1

Preorder Traversal
4

10

11

12

13

14

15

Tree Traversal
Reverse Preorder: We have the following recursive algorithm Algorithm 1. Traverse the right subtree 2. Traverse the left subtree in preorder 3. Visit the root
14 7 15

## Reverse Preorder Traversal

12

13

11

10

Tree Traversal
Inorder: We have the following recursive algorithm Algorithm 1. Traverse the left subtree in preorder 2. Visit the root 3. Traverse the right subtree
6 10 8

Inorder Traversal
2

12

11

14

13

15

Tree Traversal
Reverse Inorder: We have the following recursive algorithm Algorithm 1. Traverse the right subtree 2. Visit the root 3. Traverse the left subtree in preorder
12 10 6 8

## Reverse Inorder Traversal

14

11

15

13

Tree Traversal
Postorder: We have the following recursive algorithm Algorithm 1. Traverse the left subtree in preorder 2. Traverse the right subtree 3. Visit the root
5 7 15

14

Postorder Traversal
3

13

12

10

11

Tree Traversal
Reverse Postorder: We have the following recursive algorithm Algorithm 1. Visit the root 2. Traverse the right subtree 3. Traverse the left subtree in preorder
11 9 2 1

## Reverse Postorder Traversal

13

10

12

15

14

Basic Elements
Primitives: Bounded solid primitives are the basic building blocks of CSG. These (parametric) solids have two sets of geometric data: 1. Configuration Parameters (size information) 2. Rigid motion Parameters (orientation information)
Y L P H X R Z X BLOCK WEDGE H Z P B D CYLINDER SPHERE X Z R X Y Y

B Y

Building Operations
The main building operations are regularised set operatoins like union (U*), intersection (*) and difference (-*). Hence the CSG models are known as set-theoretic, Boolean or combinatorial models. In contrast to Euler operations, the Boolean operations are not based on any equation or law. They are based on the set theory and the closure property. These operations are considered higher-level operations than Euler operations. Some implementations of solid modelers provide derived types of operations like ASSEMBLE and GLUE

## Main algorithms in CSG Operations

1. Edge / Solid intersection algorithm 2. Computing set membership classification a) Divide and conquer: It is like ray tracing. Instead of a ray an edge is used as a reference b) Neighborhood: It deals with in, on and out decisions When a point is in the interior of solid face then it is called face neighborhood Edge neighborhood occurs when the point lies on the solid edge When a point is a vertex, vertex neighborhood occurs. This is a complex case becouse the point is shared between three solid faces.
P

10

## Summary of a CSG algorithm

The following steps describe a general CSG algorithm based on divide and conquer approach:
1. Generate a sufficient number of t-faces, set of faces of participating primitives, say A and B. 2. Classify self edges of A w.r.t A including neighborhood. 3. Classify self edges of A w.r.t B using D & C paradigm. If A or B is not primitive then this step is followed recursively. 4. Combine the classifications in step 2 and 3 via Boolean operations. 5. Regularize the on segment that result from step 4 discarding the segments that belong to only one face of S. 6. Store the final on segments that result from step 5 as part of the boundary of S. Steps 2 to 6 is performed for each of t-edge of a given t-face of A. 7. Utilize the surface/surface intersection to find cross edges that result from intersecting faces of B (one at a time) with the same t-face mentioned in step 6. 8. Classify each cross edge w.r.t S by repeating steps 2 to 4 with the next self edge of A. 9. Repeat steps 5 and 6 for each cross edge 10. Repeat steps 2 to 9 for each t-face of A. 11. Repeat stpes 2 to 6 for each t-face of B.

A CSG Example
Create the CSG model of the following solid S.
y x z b B d c d S
AU*B-*C

## A c a Geometry of the primitives BLOCK A: BLOCK B:

AU*B

xL = a d , y L = d , z L = c, PA ( x, y , z ) = PA (d ,0,c ) xL = d , y L = b, z L = c, PB ( x, y, z ) = PB (0,0,c)
E

CYLINDER C: R = R, H = d , PC ( x, y , z ) = PC ( d + a / 2, d ,c / 2) A
M(E,B) M(E,A) M(E,A) M(E,B)

Classify

E on A

U* E on S

*
E on S E on S

-*

E out B
Combine

E on S
Null E on S

* -*

U*

E E on B

E out A E in A

Classify

Combine

11