l32_solidmcsg

Upload: kannanviknesh

Post on 04-Jun-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 L32_solidmcsg

    1/11

    Solid Modeling Techniques

    Constructive Solid Geometry(CSG)

    AML710 CAD 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 basicelements or shapes that can be combined in a certainorder following a set of rules ( Boolean operations) tocreate the object.

    Primitives themselves are considered valid CSGmodels. Each primitives is bounded by closed andorientable surfaces.

    CSG model is fundamentally and topologically differentfrom a B-rep model in that it does not store faces, edgesand vertices explicitly. Instead it evaluates themwhenever needed by algorithms.

    CSG representation is of considerable importance formanufacturing

  • 8/13/2019 L32_solidmcsg

    2/11

    Primitive based Vs Half-space basedCSG 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 CSGscheme.

    Half space Based CSG :This scheme uses unboundedhalf spaces (non r-sets). Bounded solid primitives areconsidered composite half spaces and the boundariesof these are the surfaces of the component half spaces.

    Primitive based CSGHalf space based CSG

    - +

    Data Structure of CSG

    Like in B-rep, the database storestopology and geometry.

    The validity checking in CSG schemeoccurs indirectly. The each primitive thatis combined using a Boolean operations(r-sets) to build the CSG model ischecked for its validity.

    The common data structures used forCSG are graphs and trees

  • 8/13/2019 L32_solidmcsg

    3/11

    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 pathis called a cycle

    A

    B C

    DEFG

    A

    B C

    DEFG

    Graph Digraph

    Root node

    Leaf nodes

    CSG Data Structure

    Cyclic Graph: If a graph contains a cycle it is called cyclicotherwise 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 pathis called a cycle

    A

    B C

    DEFG

    Graph Digraph

    Indegree = 3

    Outdegree = 2

    B

  • 8/13/2019 L32_solidmcsg

    4/11

    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 othernodes has an indegree of one.

    Binary Tree: In a tree if the descendent of each node arein order (from left to right) and each node except the leafnode has two decedents (left and right), then the tree iscalled a binary tree.

    A

    B C

    DEFG

    Tree Binary Tree

    A

    B C

    DEFG

    Binary Tree and Subtree

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

    A

    B C

    DEFG

    Left subtree Right subtree

    C

    A

    E

    F

    D

    B

    G

    Unbalanced binary treeBalanced binary tree

    RL nn = RL nn

  • 8/13/2019 L32_solidmcsg

    5/11

    Inverted Binary Tree for CSG Model

    Inverted Binary Tree: If the direction of each connector

    (arrow) are reversed then we get an inverted binary treewherein each node has one outdegree except the rootnode.

    Root node: A node with outdegree = 0. Any node that doesnot have descendent.

    Leaf node: Any node that does not have a predecessor orindegree = 0.

    Interior node: Any node with outdegree > 0 is an interiornode.

    A

    B C

    DEFGInverted Binary Tree

    Inverted Binary Tree as CSG TreeCSG Tree: The inverted binary tree is very convenient to represent the

    CSG operations. Here each of the leaf nodes is a valid solidprimitive. The intermediate nodes are the transition states of thesolid modeling (r-set) operations. The root node is the resulting solidfrom the set operations. Here n primitives require (n-1) Booleanoperations to complete the construction of the object.

    A

    B

    D

    C

    A

    B

    D

    C

    A B DC

    S=AUBUC

    AUB CUD

    DCBA

    S

    D

    CSG Tree

    Primitives =4

    Operations=3

    Nodes=2n-1=7

  • 8/13/2019 L32_solidmcsg

    6/11

    Tree Traversal

    Tree Traversal: Visiting the nodes in sequential or orderly

    and efficient way. Many of the sorting and searchingalgorithms 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 typesdepending on the order in which the root node is visited

    a) Preorder b) Inorder c)Postorder

    1

    32

    Preorder

    2

    31

    Inorder

    3

    21

    Postorder

    Tree TraversalPreorder: We have the following recursive algorithm

    Algorithm

    1. Visit the root

    2. Traverse the left subtree in preorder

    3. Traverse the right subtree

    1

    2 9

    111083

    Preorder

    Traversal

    74

    65

    1312

    1514

  • 8/13/2019 L32_solidmcsg

    7/11

    Tree TraversalReverse Preorder: We have the following recursive algorithm

    Algorithm

    1. Traverse the right subtree

    2. Traverse the left subtree in preorder

    3. Visit the root

    15

    14 7

    56813

    Reverse PreorderTraversal

    912

    1011

    34

    12

    Tree TraversalInorder: We have the following recursive algorithm

    Algorithm

    1. Traverse the left subtree in preorder

    2. Visit the root

    3. Traverse the right subtree

    8

    6 10

    12974

    Inorder

    Traversal

    52

    31

    1411

    1513

  • 8/13/2019 L32_solidmcsg

    8/11

    Tree TraversalReverse Inorder: We have the following recursive algorithm

    Algorithm

    1. Traverse the right subtree

    2. Visit the root

    3. Traverse the left subtreein preorder

    8

    10 6

    47912

    Reverse InorderTraversal

    1114

    1315

    25

    13

    Tree TraversalPostorder: We have the following recursive algorithm

    Algorithm

    1. Traverse the left subtreein preorder

    2. Traverse the right subtree

    3. Visit the root

    15

    7 14

    13865

    Postorder Traversal

    43

    21

    129

    1110

  • 8/13/2019 L32_solidmcsg

    9/11

    Tree TraversalReverse Postorder: We have the following recursive algorithm

    Algorithm

    1. Visit the root

    2. Traverse the right subtree

    3. Traverse the left subtree inpreorder

    1

    9 2

    381011

    Reverse PostorderTraversal

    1213

    1415

    47

    56

    Basic Elements

    Primitives: Bounded solid primitives are the basic building blocks ofCSG. These (parametric) solids have two sets of geometric data:

    1. Configuration Parameters (size information)

    2. Rigid motion Parameters (orientation information)

    X

    Y

    Z

    L

    R

    Y

    X

    Z

    R

    Z

    BH

    DX

    Y

    P

    Y

    X

    Z B

    H

    D

    P

    SPHEREWEDGE

    CYLINDERBLOCK

  • 8/13/2019 L32_solidmcsg

    10/11

    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 arenot based on any equation or law. They are based onthe set theory and the closure property. Theseoperations are considered higher-level operations thanEuler operations.

    Some implementations of solid modelers provide derivedtypes of operations like ASSEMBLE and GLUE

    Main algorithms in CSG Operations1. Edge / Solid intersection algorithm

    2. Computing set membership classification

    a) Divide and conquer: It is like ray tracing. Instead of a ray an edge isused 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 faceneighborhood

    Edge neighborhood occurs when the point lies on the solid edge

    When a point is a vertex, vertex neighborhood occurs. This is acomplex case becouse the point is shared between three solid

    faces.

    P PP

  • 8/13/2019 L32_solidmcsg

    11/11

    Summary of a CSG algorithmThe 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 thenthis 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 thatbelong 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 fromintersecting 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 ofA.

    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.

    AU*B-*C

    AU*B C

    BA

    S

    Geometry of the primitives

    BLOCK A:

    BLOCK B:

    CYLINDER C:

    -+

    )2/,,2/(),,(,,

    ),0,0(),,(,,,

    ),0,(),,(,,,

    cdadPzyxPdHRR

    cPzyxPczbydx

    cdPzyxPczdydax

    CC

    BBLLL

    AALLL

    +===

    ====

    ====

    AE

    E on A

    E out B

    E on SNull

    E on S

    U*

    *-*

    BE E on B

    E out A

    E in A

    E on S

    E on S E on S

    U* * -*M(E,A)

    M(E,B)

    M(E,B) M(E,A)

    Classify Combine

    Classify

    Combine

    a

    B

    A

    cb

    c

    d

    dx

    z

    y