Documente Academic
Documente Profesional
Documente Cultură
- +
A Root node A
B C B C
G F E D G F E D
Leaf nodes
Graph Digraph
CSG Data Structure
Cyclic Graph: If a graph contains a cycle it is called cyclic otherwise it
is acyclic. Cycles are some times called loops or rings.
The digraph shown below is cyclic as it has two cycles.
Indegree: In a digraph, number of arrows entering a node
Outdegree: number of arrows going out of a node
Indegree = 3
B B C
Outdegree = 2
G F E D
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
B C B C
G F E D G F E D
C D
B C
B E
G F E D
nL = nR nL ≠ nR
Balanced binary tree Unbalanced binary tree
Inverted Binary Tree for CSG Model
Inverted Binary Tree: If the direction of each connector
(arrow) is 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
A DD
S=AUBUC
B C
S
A CUD D
AUB
B C
Primitives =4
Operations=3
A B C D
Nodes=2n-1=7
A B C D
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 c)Postorder
1 2 3
2 3 1 3 1 2
3 8 10
11
Preorder
Traversal
4 7 12 13
5 6 14 15
Tree Traversal
Reverse Preorder: We have the following recursive algorithm
Algorithm
15
1. Traverse the right subtree in rp/o
2. Traverse the left subtree in rp/o
3. Visit the root 14 7
13 8 6
5
Reverse Preorder
Traversal
12 9 4 3
11 10 2 1
Tree Traversal
Inorder: We have the following recursive algorithm
Algorithm
8
1. Traverse the left subtree in inorder
2. Visit the root
3. Traverse the right subtree 6 10
4 7 9
12
Inorder
Traversal
2 5 11 14
1 3 13 15
Tree Traversal
Reverse Inorder: We have the following recursive algorithm
Algorithm
8
1. Traverse the right subtree
2. Visit the root
3. Traverse the left subtree 10 6
in reverse inorder
12 9 7
4
Reverse Inorder
Traversal
14 11 5 2
15 13 3 1
Tree Traversal
Postorder: We have the following recursive algorithm
Algorithm
15
1. Traverse the left subtree
in postorder
2. Traverse the right subtree
7 14
3. Visit the root
5 6 8
13
Postorder Traversal
3 4 9 12
1 2 10 11
Tree Traversal
Reverse Postorder: We have the following recursive algorithm
Algorithm
1
1. Visit the root
2. Traverse the right subtree in
reverse postorder
9 2
3. Traverse the left subtree in
reverse postorder
11 10 8
3
Reverse Postorder
Traversal
13 12 7 4
15 14 6 5
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 Y
L
R
P H X
B D Z
X
Y Y
Z BLOCK CYLINDER
WEDGE SPHERE
H P R
X X
D Z
Z B
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 because the point is shared between three solid
faces.
P P
P
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 steps 2 to 6 for each t-face of B.
A CSG Example
Create the CSG model of the following solid S.
y d S
x
c d AU*B-*C
b B
z
A c + -
a AU*B C
Geometry of the primitives
BLOCK A: 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) A B
BLOCK B:
CYLINDER C: R = R, H = d , PC ( x, y, z ) = PC (d + a / 2, d ,−c / 2)
E M(E,B) M(E,A)
A U* ∩* -*
Classify E on A M(E,A)
E out A E on S
E out B M(E,B) E E on B
B E in A E on S E on S
E on S U*
Combine Null ∩* Classify Combine
E on S -*