Professional Documents
Culture Documents
LECTURE 32
Root node
Indegree = 3 Outdegree = 2
G
Graph
Digraph
Tree
Binary Tree
C B C B G F E D E
Left subtree
Right subtree
nL = nR
Balanced binary tree
nL nR
Unbalanced binary tree
S=AUBUC S
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
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
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
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
10
A CSG Example
Create the CSG model of the following solid S.
y x z b B d c d S
AU*B-*C
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