IV-99 London Solving Geometric Constraints

Embed Size (px)

Citation preview

  • 8/2/2019 IV-99 London Solving Geometric Constraints

    1/6

    Solving Geometric Constraintsby a Graph-Constructive Approach

    Samy Ait-Aoudia, Brahim Hamid, Adel Moussaoui, Toufik SaadiINI - Institut National de formation en InformatiqueBP 68M - Oued Smar 16270 ALGIERS ALGERIA

    Tel : 213 2 51 60 33Fax : 213 2 51 61 56 Telex : 64531

    E-mail : [email protected] , [email protected]

    Abstract A geometric constraint solver is a major component of recent CAD systems. Graph constructive solvers arestemming from graph theory. In this paper, we describe a2D constraint-based modeller that uses a graphconstructive approach to solve systems of geometricconstraints. The graph-based approach provides means

    for developing sound and efficient algorithms. We present a linear algorithm that solves a large subset of the ruleand compass constructive problems. Methods for handling over- and under-constrained schemes are alsogiven.

    Key Words: Computer aided design, constraints solving,geometric constraints, graph-based solver, over- and under-constrained schemes.

    1. Introduction

    In CAD (Computer Aided Design), geometricmodelling by constraints enables users to describe shapesby specifying a rough sketch and adding to it geometricconstraints. The constraint solver derives automaticallythe geometric elements that are to be found. Typical

    constraints are : distance between two geometric elements(two points, a point and a line, two parallel lines), anglebetween two lines, tangency between a line and a circle orbetween two circles

    Many resolution methods have been proposed forsolving systems of geometric constraints. We classify theresolution methods in four broad categories : numerical,symbolic, rule-oriented and graph-constructive solvers.

    Numerical methods (Newton-Raphsons iteration,homotopy, gaussian elimination and so on) are O(n 3) orworse (see [1,2,3,4]). Most numerical methods have

    difficulties for handling over- and under-constrainedschemes.

    Symbolic methods (Grbner bases, elimination withresultants) are typically exponential in time and space (see[5,6]). They can be used only for small systems.According to Lazard [7], computing the Grbner bases of an irreducible system of degree two in ten unknowns is ahopeless case.

    Rule-based solvers rely on the predicates formulation(see [8,9,10,11]). Although they provide a qualitativestudy of geometric constraints, the "huge" amount of computations needed (exhaustive searching andmatching) make them inappropriate for real worldapplications.

    Graph-constructive solvers are stemming from graphtheory. They are based on an analysis of the structure of the constraint graph. The graph constructive approachprovides means for developing sound and efficientalgorithms (see [12,13,14]). Owen [15], Fudos andHoffman [16], Lamure and Michelucci [17] givequadratic algorithms for solving constrained schemes.

    In this paper, we describe a 2D constraint-basedmodeller that uses a graph constructive approach to solvesystems of geometric constraints. We present a linear

    algorithm that solves a large subset of the rule andcompass constructive problems. We also give efficientmethods for isolating over- and under-constrainedschemes.

    This paper is organised as follows. The graphrepresentation of the constraint problem is explained insection 2. We present in section 3, the core algorithm thathandles structurally well-constrained problems. The phasefor isolating over- and under-constrained schemes isgiven in section 4. We describe in section 5, ourconstraint-based modeller. Section 6 gives conclusions.

  • 8/2/2019 IV-99 London Solving Geometric Constraints

    2/6

    2. Constraints and graphs

    2.1 Graph representation

    Geometric modelling by constraints enables users todescribe geometric elements such as points, lines, circles,line segments and circular arcs by a set of requiredrelationships of distance, angle, incidence, tangency,parallelism and perpendicularity. With some pre-processing, the geometric elements are reduced to pointsand lines, and the constraints to those of distance andangle (see [18]).

    We use an undirected graph G=(V,E) where |V|=nand |E|=m to represent the constraint problem. Thegeometric elements are represented by the graph nodesand the constraints are the graph edges. The edges arelabelled with the values of the distance and angledimensions.

    Example 1 :A dimensioning scheme defining a constraint

    problem is shown in figure 1. It involves six points andsix lines. The constraints are six point-point distances,three line-line angles, twelve point-line implicit distancesthat are zero. The corresponding constraint graph isshown in figure 2. The unlabeled edges correspond to theimplicit point-line distances.

    A

    B

    C

    D

    E

    F

    d1 d2

    d3

    d4d5

    d6

    Figure 1. A constraint problem.

    A

    B

    C

    D

    E

    F

    AB BC

    CD

    DEEF

    AF

    d1 d2

    d3

    d4d5

    d6

    Figure 2. The corresponding constraint graph.

    2.2 Graph structure analysis

    Let us now give some definitions concerning thestructural properties of the constraint graph.

    Definition 1A constraint graph G=(V,E) where |V|=n and|E|=m is structurally well-constrained if and only if m=2*n-3 and m 2*n-3 for any inducedsubgraph G=(V,E) where |V|=n and |E|=m(see [ 19 ]).

    Definition 2A constraint graph G=(V,E) contains a structurallyover-constrained part if there is an inducedsubgraph G=(V,E) having more than 2*n-3edges.

    Definition 3A constraint graph G=(V,E) is structurally under-constrained if is not over-constrained and thenumber of edges is less than 2*n-3.

    Note that a constraint graph can have over- andunder-constrained parts. An example is shown in figure 3.

    Figure 3. Over- and under-constrained parts.

    The graph constructive approach uses only thestructure of the constraint graph and forgets numericalinformations. A constraint graph can be structurally well-constrained but numerically under constrained. Thedimensioned scheme shown in figure 4 (left) isnumerically under-constrained (the edges are labelledwith distance arguments). Its corresponding constraintgraph shown in figure 4 (right) is structurally well-constrained.

    A B

    C

    1

    0

    D

    1

    1

    1

    D

    A B

    C

    Figure 4. An under-constrained problem (left),and its associated constraint graph (right).

    Nonetheless, with the graph constructive approach,such cases will be detected during the construction phase.

  • 8/2/2019 IV-99 London Solving Geometric Constraints

    3/6

    3. Solving the constraints

    3.1. Basic clusters formation

    The first phase of the algorithm is the formation of what we call "basic clusters". A cluster is a rigidgeometric structure whose elements are known relativelyto each other. A basic cluster is obtained by the algorithmgiven below. The nodes (geometric elements) and theedges (geometric constraints) are initially unmarked.

    Algorithm :1. Pick an unmarked edge (constraint) ;

    Mark the edge ;Pin the two geometric elements related by theconstraint being marked ;Mark the two geometric elements to belong to anew basic cluster BCi(the two geometric elements are now known).

    2. Repeat the following :if there is a geometric element with two

    unmarked constraints related to knownelements

    then mark the two constraints ;mark the geometric element to belong to thebasic cluster Bci ;place this element by a constructive step (thisgeometric element is now known).

    The placement steps correspond to standardisedgeometric construction steps (place a point at givendistances from two points, place a line at prescribed anglefrom another line through a point, ). When placing ageometric element, our solver uses some rules to choosethe "best" solution. We assume that the constraintproblem has been specified by a user-prepared sketch.The distance and angle arguments are signed quantities.The solution, automatically chosen, is the one thatpreserves the topological order given by the sketch. If these rules fail, the solutions are browsed and the user

    selects one of them.To form all the basic clusters steps 1 and 2 arerepeated until no unmarked edge can be found. The goalis to systematically visit all the edges of the constraintgraph.. Step 2 uses a recursive procedure to form a basiccluster. During this step, we check the unmarked edgesrelated to known elements of the basic cluster beingconsidered to see if two of them lead to a same node. If sothis node is added to the basic cluster and the edgesmarked. The first phase can be computed in linear timeusing a simple variation of depth first search. Each clusteris placed in a local co-ordinate system. Note that ageometric element can belong to several basic clusters.

    Example 2 :To illustrate the process, consider the constraint

    graph of figure 2. Three basic clusters are found C1, C2and C3 (see figure 5). The geometric elements B, D and Fbelong each to two clusters : the point B to (C1,C3), thepoint D to (C2,C3) and the points F to (C1,C2).

    A

    B

    C

    D

    E

    F

    AB BC

    CD

    DEEF

    AF

    d1 d2

    d3

    d4d5

    d6

    C1

    C2

    C3

    Figure 5. Clusters of the graph.

    3.2. The skeleton of the constraint graph.

    The second phase of the algorithm is to construct theskeleton of the constraint graph. The skeleton is a graphGs=(Vs,Es) which is obtained by the algorithm givenbelow.

    Algorithm :1. The nodes Vs of the skeleton are the nodes of the

    constraint graph that belong to several basicclusters (these nodes are marked with at least twobasic clusters names).

    2. The edges Es of the skeleton are obtained asfollows :Es=;For each basic cluster CiDo pick the nodes {N1,N2, ,Nj} of Ci that

    belong to Vs;triangulate the set {N1,N2, ,Nj} by doing:

    Add* edge (N1,N2) to Es;For k=3 to jDo Add* edges (Nk,Nk-1) and

    (Nk,Nk-2) to Es;

    If an added edge (s,t) to Es is not a member of theinitial set of constraints then we insert a "virtual"

  • 8/2/2019 IV-99 London Solving Geometric Constraints

    4/6

    constraint whose value is easily determined because thenodes s and t belong to a rigid structure (a basic cluster).

    The graph skeleton (of problems solved by ouralgorithm) is a basic cluster. All its nodes are placed inthe plane. The skeleton can be empty if the constraintgraph consist of only one basic cluster (the finalconfiguration is then directly obtained).

    Example 3 :To better illustrate this phase, consider the constraint

    graph of figure 2. His skeleton is given in figure 6. All theedges of this skeleton are virtual constraints.

    B

    DF

    Figure 6. Skeleton of the previous constraintgraph .

    Example 4 :Another constraint graph (the basic clusters are alreadyformed) and its corresponding skeleton are shown infigure 7.

    (a)

    (b)

    Figure 7. A constraint graph (a), and itscorresponding skeleton (b).

    3.3. Final computation phase

    Once the nodes of the skeleton are placed(computed), each cluster is positioned relatively to theskeleton by computing the three required parameters (twotransitional and one rotational). Note that each basic

    cluster share with the skeleton at least two nodes. Thefinal scheme is then obtained.

    Example 5 :After placing the skeleton of the constraint graph

    given in figure 2, the three found basic clusters C1, C2and C3 are positioned (rotated and translated) relatively tothis skeleton (see figure 8).

    B

    DFC1

    C2

    C3

    Skeleton

    FD

    D

    B B

    F

    Figure 8. Placing the clusters.

    4. Handling over- and under-constrainedschemes

    When designing, the first time, the sketch of a

    dimensioning scheme, the user often, over-constrains andunder-constrains some geometric elements. Giving thefollowing message "your constraint graph is over- orunder-constrained" to the user when the graph containsmore than 100 nodes is not sufficient. The "lazy" user(not only him) wants a message like "the point P 99 is over-constrained and the line L 24 is under constrained" so hecan easily remove or add geometric constraints.

    Detecting over- and under-constrained geometries ina constraint graph is an important part of a "good"constraint-based modeller.

    By adding some extra checking to the algorithm of

    section 3.1, we can detect the extra-constraints in thesame time bound. The extra-constraints are the constraintswe shall remove so that the constraint graph will be wellconstrained. Before marking a constraint in step 1, we testif the two geometric elements related by this constraintbelong to a same basic cluster. If so, the consideredconstraint is necessarily an extra-constraint (a basiccluster is a rigid geometric structure, so if we add anotherconstraint between two of its nodes it become over-constrained). This constraint is removed and is notconsidered further.

  • 8/2/2019 IV-99 London Solving Geometric Constraints

    5/6

    Example 6 :Consider the constraint graph given in figure 9 (left).

    We can have the marking shown in figure 9 (right). Thecrossed out edges belong to a basic cluster. The unmarkededge AC is the extra-constraint (the nodes A and Calready belong to a basic cluster). Note that this markingis not unique.

    D

    A B

    C D

    A B

    CFigure 9. An over-constrained scheme.

    Detecting under constrained schemes is a two steps

    process. First, we test the number of "links" between thebasic clusters and the skeleton graph (we assume that theconstraint graph is connected). A basic cluster B that islinked to the skeleton by one node N can move relativelyto this skeleton. We must add a constraint, that do notinvolve the node N, between the cluster B and anothercluster of the constraint graph so that the cluster B will be"firmly" attached (see example 7). In the second step, weform the basic clusters BCSi of the skeleton (if theskeleton is under-constrained we will have more than onebasic cluster) and construct the meta-skeleton (skeleton of the initial skeleton). We then apply the first step to theBCSi and the meta-skeleton (see example 8).

    Example 7 :Consider the constraint-graph of figure 10. The basic

    clusters are : C1, C2, C3 and C4. In this example theskeleton is well-constrained.

    C1 C2

    C3

    A

    B C

    C4Figure 10. An under-constrained scheme.

    The cluster C3 is linked to the skeleton by one node(the node C). We must add a constraint, that do notinvolve the node C, between the cluster C3 and anothercluster (C1, C2 or C4) so that the entire configuration willbe well constrained.

    Example 8 :Consider the skeleton graph given in figure 11.

    A

    B

    C

    D

    EFigure 11. An under-constrained skeleton

    This skeleton is under-constrained. The meta-skeleton is reduced to the node C. A constraint (that doesnot involve the node C) must be added between the twobasic clusters of the skeleton so that it becomes wellconstrained.

    5. A 2D constraint based modeller

    We have implemented an experimental 2Dconstrained based modeller in C++ on an IBM PCcompatible machine (CPU Pentium, 200 MHz and 32 Moof RAM). The user creates points, lines, circles andspecify constraints in an interactive way. The user canhave directly the final solution (if there is one) of theconstraint problem. He can also follow the resolutionprocess step by step (clusters formation, visualisation of the skeleton). When the solver detect over- or under-constrained schemes, a message is delivered to the user

    showing him what he must do (adding or removingconstraints between specified geometries).For all configurations we have tested, our algorithm

    is faster than those of Owen[15] and Fudos [16]A screen dump of a scheme solved by our algorithm

    is given in figure 12. This scheme involves seventeencircles, five points and four lines. The constraints arethirty one circle-circle distances, three line-circledistances and two point-circle distances that are zero, twopoint-point distances, three line-line angles, eight point-line implicit distances that are zero.

    6. Conclusion

    We have described and implemented a linearalgorithm that solves a system of geometric constraintsusing a graph constructive approach. The class of configurations solved is a large subset of the rule andcompass constructive problems. Over- and under-constrained schemes are also handled by this algorithm.

    Our current interest is to extent the scope of thesolver while keeping the same time bound for the corealgorithm.

  • 8/2/2019 IV-99 London Solving Geometric Constraints

    6/6

    Figure 12. A screen dump of a constrained scheme

    References

    [1] D. Serrano. Automatic Dimensioning in Design for Manufacturing. Symposium on Solid Modeling Foundationsand CAD/CAM Applications, 1991, pp. 379-386.

    [2] E.L. Allgower and K. Georg. Continuation and path following . Acta Numerica , pages 1-64, 1993.

    [3] A. Perez and D. Serrano. Constraint base analysis tools for design. Second Symposium on Solid Modeling Foundationsand CAD/CAM Applications, Montreal Canada. May 93.pp. 281-290.

    [4] H. Lamure and D. Michelucci. Solving constraints byhomotopy. Symposium on Solid Modeling Foundations andCAD/CAM Applications. May 95. pp. 263-269.

    [5] K. Kondo. Algebraic method for manipulation of dimensional relationships in geometric models. ComputerAided Design, 24 (3), pp. 141-147, March 1992.

    [6] R. Anderl and R. Mendgen. Parametric design and itsimpact on solid modeling applications . Symposium on SolidModeling and CAD/CAM Applic. May 95. pp. 1-12.

    [7] D. Lazard. Systems of algebraic equations : algorithms and complexity. Rapport interne LITP 92.20, Mars 92.

    [8] G. Sunde. Specification of shape by dimensions and other geometric constraints. Geometric modeling for CADapplications, pp. 199-213. North-Holland, IFIP, 1988.

    [9] H. Suzuki, H. Ando and F. Kimura. Variation of geometriesbased on a geometric-reasoning method. Computer andGraphics, 14(2), pp. 211-224. 1990.

    [10] P. Schreck. Modlisation dune figure gomtrique adapteaux problmes de constructions. Actes des journesGROPLAN91, France 1991.

    [11] A. Verroust, F. Schonek and D. Roller. Rule-oriented method for parametrized computer-aided design. ComputerAided Design, 24 (3), pp. 531-540, Oct. 1992.

    [12] S. Ait-Aoudia, R. Jegou and D. Michelucci. Reduction of constraint systems . In Proceedings of Compugraphics,(Alvor, Portugal), pp. 83-92, 1993.

    [13] W. Bouma, I. Fudos, C.M. Hoffman, J. Cai, R. Paige. Ageometric constraint solver. Computer Aided Design, Vol.27, No.6, June 1995, 487-501.

    [14] I. Fudos. Constraint solving for computer aided design.Ph.D. Thesis, Dept. of Computer Science, PurdueUniversity, Aug. 1995.

    [15] J.C. Owen. Algebraic Solution for Geometry from Dimensional Constraints. Symposium on Solid ModelingFoundations and CAD/CAM Applications, 1991, pp. 397-407.

    [16] I. Fudos, C.M. Hoffman. A Graph-Constructive approachto Solving Systems of Geometric Constraints. ACM Trans.on Graphics, Vol. 16, No. 2, April 1997, 179-216.

    [17] H. Lamure and D. Michelucci.Qualitative study of

    geometric constraints. Geometric Constraint Solving andapplications, B. Brderlin and D. Roller editors, Springer-Verlag, 1998.

    [18] I. Fudos. Editable representation for 2D geometric design.Masters thesis, Dept. of Computer Science, PurdueUniversity, Dec. 1993.

    [19] G. Laman. On graphs and rigidity of plane skeletalstructures. Journal of Engineering Mathematics, vol. 4, num.4, pp. 331-340, Oct. 1970.