Analysis of Boundary Representation Model Rectification by Guoling Shen B.S. in Naval Architecture and Marine Engineering (1988) Huazhong University of Science and Technology, China M.S. in Naval Architecture and Marine Engineering (1997) M.S. in Mechanical Engineering (1997) Massachusetts Institute of Technology Submitted to the Department of Ocean Engineering in partial fulfillment of the requirements for the degree of Doctor of Philosophy at the MASSACHUSETTS INSTITUTE OF TECHNOLOGY June 2000 @ Massachusetts Institute of Technology 2000. All rights reserved. A u th or ................................ .................................. .......... Department of Ocean Engineering February 9, 2000 C ertified by ........................................................................ Nicholas M. Patrikalakis Kawasaki Professor of Engineering Thesis Supervisor .......................................... Accepted by . . MASSACHUSETTS INSTITUTE OF TECHNOLOGY Nicholas M. Patrikalakis Chairman, Graduate Program Committee Department of Ocean Engineering NOV 2 9 2000 LIBRARIES ENG Analysis of Boundary Representation Model Rectification by Guoling Shen Submitted to the Department of Ocean Engineering on February 9, 2000, in partial fulfillment of the requirements for the degree of Doctor of Philosophy , Abstract One major disadvantage of boundary representation (B-rep) is its inability to guarantee model validity. This thesis addresses issues on model validity verification and defect rectification. We first study validity of ideal B-rep models. In particular, we derive a complete set of conditions for validity of representational nodes of a general B-rep data structure and prove their sufficiency. A representational node defines a valid topological boundary entity if it satisfies the corresponding conditions and all its lower level nodes are valid. We then analyze the model rectification problem, and propose a rectify-by-reconstruction approach which searches for the global optimal solution. Such a reconstruction method rebuilds a valid boundary which is topologically equivalent to a given B-rep model and has the minimum geometric change. It is also shown that the boundary reconstruction problem is NP-hard. Based on this, a boundary reconstruction methodology is proposed which aims to build a valid boundary in the neighborhood of the original model and duplicate its topological structure as much as possible. Finally, we use interval model representation in boundary reconstruction. An interval model is defined as a collection of boxes, and is regarded as an approximation of the intended exact model. We also define the concept of approximate equality relation between an interval model and its intended exact model, and derive sufficient conditions for such approximate equality. Such a relation imposes constraints on geometric and topological properties of interval models. Techniques needed in interval model construction are also developed. An example illustrates some of the issues discussed in this thesis. Thesis Supervisor: Nicholas M. Patrikalakis Title: Kawasaki Professor of Engineering Acknowledgments Funding for this work was obtained in part from NSF grant DMI-9215411, ONR grant N00014-96-1-0857 and from the Kawasaki chair endowment at MIT. I thank my advisor, Prof. N. M. Patrikalakis, for guiding me through the labyrinth of scientific research, and Prof. T. Sakkalis, whose help greatly improved the mathematical rigor of this work. Most of the ideas presented in this thesis were developed from our (exhausting but very productive) discussions in Athens last spring. I would also like to thank other members of my thesis committee, Prof. D. C. Gossard, Prof. J. Peraire, and Dr. X. Ye, for their constructive comments. Dr. X. Ye also provided the example used in this thesis. Thanks also go to Prof. A. Clement, Prof. T. J. Peters, Prof. A. Russell and Prof. F.-E. Wolter for useful discussions and comments, to Dr. W. Cho and Mr. G. Yu for their assistance in the early phases of the CAD model rectification project, and to Mr. F. Baker for maintaining a reliable hardware environment. I also thank all Design Laboratory members, former and present, for making the laboratory a pleasant working place. I want to take this chance to thank all my friends, especially Liangwu, Qinghua, Yining, Dan, Yujing, Wenjie, Xiaopeng, and Pimjai, for always being there for me. I thank my family for their love and support. Especially, I thank my wife, Zheng, for her love, and for sharing her dream with me. Contents Abstract 2 Acknowledgments 3 Contents 4 List of Figures 7 1 Introduction 9 1.1 M otivation and Objectives . . . . . . . . . . . . . . . . . . . . . . . . 9 1.2 CAD M odel Defects. . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.3 Thesis Organization. 14 2 Literature Review 16 2.1 Manifold B-Rep Model Validity . . . . . . . . . . . . . . 16 2.2 CAD Model Rectification..... . . . . . . . . . . . . . . 18 2.2.1 Polyhedral models . . . . . . . . . . . . . . . . . . 19 2.2.2 Surface models . . . . . . . . . . . . . . . . . . . . 21 Robust Geometric Representation . . . . . . . . . . . . . . 23 2.3 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . Representational Validity of Boundary Representation Models 26 3.1 Mathematical Preliminaries . . . . . . . . . . . . . . . . . . . . . . . 26 3.2 Solids and their Boundaries . . . . . . . . . . . . . . . . . . . . . . . 29 3.3 Representational Validity Conditions 3.3.1 D ata structure . . . . . . . . . . . . . . . . . . 35 . . . . . . . . . . . . . . . . . . . . . . . . . . 35 4 3.3.2 Sufficient conditions for node validity . . . . . . . . . . . . . . 36 3.3.3 Proof of validity . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4 Analysis of Manifold Boundary Representation Model Rectification 41 5 4.1 Problem Statem ent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 4.2 Problem Com plexity . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 4.2.1 Face reconstruction problem . . . . . . . . . . . . . . . . . . . 45 4.2.2 Boundary reconstruction problem . . . . . . . . . . . . . . . . 57 Topological and Geometric Properties of Interval Solid Models 61 5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 5.2 Covering Manifolds with Boxes . . . . . . . . . . . . . . . 62 5.3 Construction of Interval Solids . . . . . . . . . . . . . . . . 68 6 Manifold Boundary Representation Model Rectification 77 6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 6.2 Surface Intersection and Box Construction . . . . . . . . . . . . . . . 78 6.2.1 Surface intersection . . . . . . . . . . . . . . . . . . . . . . . . 78 6.2.2 Control of box size . . . . . . . . . . . . . . . . . . . . . . . . 79 6.2.3 Structure of intersection boxes . . . . . . . . . . . . . . . . . . 81 6.2.4 Data reduction . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Model Reconstruction Methodology . . . . . . . . . . . . . . . . . . . 87 6.3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 6.3.2 Intersection-induced graph . . . . . . . . . . . . . . . . . . . . 89 6.3.3 Face reconstruction . . . . . . . . . . . . . . . . . . . . . . . . 89 6.3.4 Shell reconstruction . . . . . . . . . . . . . . . . . . . . . . . . 94 Exam ple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 6.3 6.4 7 Conclusions and Recommendations 100 7.1 Conclusions . . . . . . . . . . . . . . . . . 100 7.2 Recommendations . . . . . . . . . . . . . . 101 5 A Short review of NP-completeness 105 B Boxes on an interval B-spline surface 107 References 111 6 List of Figures 1-1 Gaps created by adding a sweeping solid . . . 13 1-2 An example of failure in data exchange [36] . 14 2-1 Domain and range of a representation scheme 17 3-1 Two valid solids . . . . . . . . . . . . . . . . . . . . . . 29 3-2 Two invalid solids . . . . . . . . . . . . . . . . . . . . . 30 3-3 Three valid faces . . . . . . . . . . . . . . . . . . . . . 33 3-4 Two invalid faces . . . . . . . . . . . . . . . . . . . . . 34 3-5 Graph representation of the data structure . . . . . . . 36 4-1 Flow1 . . . 46 4-2 Two homeomorphic graphs with different geometric embeddings . . . 47 4-3 Curve segments from surface intersections . . . . . . . . . . . . . . . 48 4-4 Initial rectification of an edge on a face . . . . . . . . . . . . . . . . . 49 4-5 Creation of e' by vertex perturbation . . . . . . . . . . . . . . . . . . 50 4-6 Trimming of dangling curve segments (a) and gap filling (b) . . . 51 4-7 Minimization of edge geometric change . . . . . . . . . . . . . . . . . 55 4-8 An instance of the restricted FR problem . . . . . . . . . . . . . . . . 56 4-9 Illustration of the proof of Theorem 4.2.2 . . . . . . . . . . . . . . . . 60 5-1 An example of interval solid . . . . . . . . . . . . . . . . . . . . . . . 65 5-2 2D version of condition C2 and C3 . . . . . . . . . . . . . . . . . . . 66 5-3 Influence of box sizes on approximate equality . . . . . . . . . . . . . 69 5-4 Boxes of an interval model . . . . . . . . . . . . . . . . . . . . . . . . 70 chart of an id1II n roormcfr1 7 nrc+rm 5-5 Exceptions to C 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 5-6 Illustration of Remark 5.3.1 73 5-7 Construction of 2D boxes satisfying the conditions in Remark 5.3.1 74 5-8 Construction of 3D boxes satisfying the conditions in Remark 5.3.1 76 6-1 Examples of special surface intersection cases . . . . . . . . . . . . . 79 6-2 Flow chart of box curve and box point identification . . . . . . . . . . 83 6-3 Refinement of box curves formed by clusters . . . . . . . . . . . . . . 85 6-4 Ordering of boxes in box curves of Example 2 86 6-5 Close-up of one box point in the parameter domain of Example 2 . . 86 6-6 Reconstruction of a vertex . . . . . . . . . . . . . . . . . . . . . . . . 90 6-7 Gap closing in loop reconstruction . . . . . . . . . . . . . . . . . . . . 91 6-8 Loop m odification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 6-9 Definition of the rotation index of a simple closed box curve . . . . 94 6-10 Hole filling in shell reconstruction . . . . . . . . . . . . . . . . . . . . 96 6-11 Part of a shaver handle . . . . . . . . . . . . . . . . . . . . . . . . . . 97 6-12 An invalid face with the resolution 10~ 6m . . . . 98 4 98 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13 The face in Figure 6-12 becomes valid at the resolution 2 x 107-1 m. . Interval model as an internal model representation . . . . . . . . . . . 104 8 Chapter 1 Introduction 1.1 Motivation and Objectives Model representation schemes enable man-machine and machine-machine communication on product design and manufacturing. With semantic rules set by representation schemes, models can be realized as physical artifacts. The success of such communication and realization, however, heavily relies on representational validity of models. That is, a model created using a specific modeling scheme should express design intent unambiguously, and such intent can be faithfully interpreted by applying the same semantic rules without consulting the designer. A model is regarded as invalid if it corresponds to a model description which is not a mathematical abstraction of any of the objects in the world under consideration [53]. Such a model is neither interpretable nor manufacturable, and thus, represents a nonsense object. Constructive Solid Geometry (CSG) and Boundary Representation (B-rep) are the two representation schemes currently adopted by most solid modeling systems, see Mdntyld [45] and Hoffmann [29] for detailed descriptions of these two representation methods. Both have great expressive power, capable of describing almost all man-made solids. CSG defines solids using primitive solids and operations such as regularized Boolean operations and transformations. A CSG model is generally represented as a CSG tree whose leaves are primitive solids and internal nodes are regularized Boolean operations and transformations. The solid is defined at the root 9 of the tree. Because primitives and operations are all well-defined, a CSG model is always valid if the tree is syntactically correct. B-rep defines a solid by describing its boundary collectively. It uses topological boundary entities such as vertex, edge, loop, face, shell and region in a hierarchical way. A higher level entity is defined by various lower level entities related by a certain structure, and at the top of this structure is the solid. Such a structure is often represented by a graph providing explicit information on adjacency and incidence relations of boundary entities. It also contains geometric information such as equations for points, curves and surfaces, each of which is associated to an appropriate topological entity as its underlying geometry. Unlike CSG models, validity of B-rep models is not self-guaranteed. Indeed, "the fundamental problem with the Brep database structure is the inability of the representation itself to guarantee object validity" [41]. Nevertheless, a B-rep model has the advantage of being an evaluated model. Boundary information necessary for important applications such as model rendering, analysis, and manufacturing, is readily available. Invalid models may fail under certain modeling operations, generate useless results in analysis programs, and produce defective products when used to compute control data to drive a manufacturing system. Model validity is becoming a prominent problem in data exchange as different CAD systems coexist even in one design or manufacturing unit. Model validity verification and rectification (or informally correction) of invalid models, therefore, are very important problems in both modeling theory and CAD/CAM/CAE practice. In the early years of solid modeling, validity verification was mostly done by the user, and was error-prone [53]. Model rectification was also done manually by experienced operators. The entire model verification and rectification process was laborious. As the complexity of models grows enormously, it becomes impossible for a human being to visualize defects and consistently repair them, and thus automated, or semi-automated with limited user assistance, model validity verification and defect rectification methods are needed in the solid modeling community, in order to design and manufacture defect-free products. 10 In this thesis, we focus on various aspects of the model verification and rectification problem. In particular, given a model, we try to answer the question "Is this model valid? If not, could it be fixed, and how?". 1.2 CAD Model Defects Defects are those representational entities which violate semantic rules of modeling schemes. For a manifold B-rep model, mathematically, it is invalid if it does not describe a 2-manifold without boundary, and thus, represents a nonsense object in the modeling space. At the representational level, there are two types of defects, topological errors and inconsistencies between topological and geometric specification. Topological errors refer to features in the incidence and adjacency graph which violate the manifoldness condition. For instance, if a face has no adjacent face through one of its edges, obviously, an arbitrary point on that edge does not have a 2-manifold neighborhood. Inconsistencies between topological and geometric specification refer to situations where a topological relation is inconsistent with the geometries of the topological entities involved in the relation. For instance, two faces sharing a common edge may be represented by two trimmed surface patches which do not meet properly at the geometry of the edge. Visually, defects appear as gaps, dangling entities, inappropriate intersections, internal walls and inconsistent orientations. Gaps often exist along common edges between two faces. Such gaps may be extremely small and invisible in rendering, but may have disastrous effects on analysis and manufacturing applications. Models could also, but rarely, have considerable holes due to reasons such as missing patches. Inappropriate intersections are those intersections in the interior of a face. Internal walls subdivide solids into multiple regions, and are not allowed in a manifold B-rep model. Dangling entities could be dangling patches, edges, or isolated points, none of which define legitimate solids. Inconsistent orientations make the definition of interior and exterior unclear. 11 The causes of defects exist throughout the entire life cycle of a CAD model, especially during model creation and data exchange. One major cause is pathological behaviors of certain geometric algorithms. For example, intersection curves are generally approximated by lower degree curves. In Figure 1-1, a model is bounded by a set of B-spline surfaces. Later, a solid created by sweeping a planar shape along one of the edges is added. Since the edge is an intersection curve of high degree, the sweeping path is a B-spline curve approximating the edge and is not identical to the original edge. Therefore, there exists a gap between the boundary of the sweeping solid and the boundary of the original one1 . Even if an algorithm is correctly designed, poor implementation could still produce defects. For example, if the regularized union is not correctly implemented, it may leave an internal wall when applied to two cubes contacting each other at faces. Another major cause of defects is the precision limitation of the computer [30]. The computer can only represent a discrete domain of floating point numbers. Numbers unrepresentable in this domain are rounded to their closest floating point numbers. This causes computational errors, and such errors could accumulate to a fairly significant amount. In addition, CAD data will be shared by other systems or applications through data exchange. Since every system has its own proprietary data structure and internal accuracy/resolution for competitive purposes, useful information may be lost during the transmission. Therefore, a model valid in its native system may become invalid elsewhere. An invalid model may fail under certain modeling operations. A typical example is the potential failure of point classification algorithms. A very fundamental query needed in Boolean operations is whether a point is inside or outside a solid. If the solid boundary has gaps, a ray casting algorithm will make a wrong decision if a selected ray shoots right through a gap. Modeling operations which rely on such decisions, thus, may fail to perform properly, or even lead to system error, if they are unable to handle contradictions or ambiguities induced by wrong decisions. Downstream 'Although the size of the gap can be reduced by increasing the approximation precision, such actions will create B-spline surfaces with very long knot vectors, which will affect the performance and robustness of downstream applications. In general, current solid modeling systems balance the approximation precision and the complexity of resulting models. 12 /sweeping path gap approximate sweeping path after Boolean union original model Figure 1-1: Gaps created by adding a sweeping solid applications are also vulnerable to defects. A finite element analysis program may return useless results if the input mesh is created using a CAD model with gaps. Without proper post-processing, NC data computed from such models will leave defects such as under-cuts in finished products. In rapid prototyping, an internal wall will cause uneven material shrinkage at the location and subsequent warping and loss of part accuracy [12]. A model with inconsistent orientation will visually have black faces during rendering. Defects may be further exaggerated through data exchange. A model may become completely unrecognizable in the receiving system, and cost tremendous man-power and financial resources to fix. See a very good example in Figure 1-2, where the left image is the model in the native system and the right is in the receiving system. Such failures of data exchange are due to different tolerances used in the sending and the receiving systems and/or that the model representation used in the sending system does not contain topological information, see [36]. A recent report to NIST [16] indicates that the interoperability problem of CAD data costs the US automobile industry and its part sub-contractors over one billion dollars a year, including investment in avoiding such problems before data exchange and fixing problematic data afterwards and profit loss due to delay in design and production. Although much can be accomplished via proper widespread use of the STEP standard [65] in reducing the magnitude of the interoperability problem, many of data exchange problems and data quality problems categorized in the NIST report 13 Figure 1-2: An example of failure in data exchange [36] are directly or indirectly related to model validity. 1.3 Thesis Organization Chapter 2 provides the necessary background of this thesis. It contains a brief introduction of solid modeling theory, especially on model validity. It also provides a literature review of recent research on model verification and rectification, especially on triangulated models. Another approach to the model validity problem, currently explored by many, is the development of robust geometric representations as replacements of traditional representations using floating point specification. Interval geometric representation, which will be used in this work, is introduced briefly. Chapter 3 provides mathematical fundamentals of ideal boundary models and studies validity of ideal B-rep models. It defines solid modeling concepts such as solid, shell, face, loop, edge, and vertex, as well as loop and face orientations. It then derives conditions for manifold B-rep model validity and proves their sufficiency. Such conditions are useful in developing model verification and rectification methods. Chapter 4 analyzes the nature of the boundary rectification problem, and proposes a rectify-by-reconstruction approach. It also proves that the boundary reconstruction problem, which searches for a global consistent and optimal boundary model on the underlying surfaces of a given model, is NP-hard. Chapter 5 further develops the concept of interval solid model introduced by Hu 14 et al [33, 34]. In particular, it defines the concept of approximate equality relation between an interval solid model and the intended ideal model, and derives sufficient conditions for such approximate equality. Chapter 6 presents a model rectification methodology based on our study of the problem in Chapters 4 and 5. This method builds a valid model in the neighborhood of the object described by a traditional boundary representation model with floating point specification. It converts an erroneous model into an interval solid model, guaranteed to be gap-free. The chapter also provides necessary techniques for constructing interval solid models, such as box size control, data reduction, and ordering boxes. An example illustrates our methodology for robust conversion. Chapter 7 concludes the thesis with a summary of contributions and recommendations of future research. In particular, we propose the use interval model representation as an internal representation at the core of solid modeling systems, and explain how this representation will benefit the development of robust application algorithms. Appendix A provides a brief introduction to the theory of NP-completeness, needed in Chapter 4. Appendix B derives the recursive formulae for evaluating an interval point on an interval B-spline curve or surface using de Boor's algorithm, and the approximate relation between the size of such a point and its parameter resolution, all needed in Chapters 5 and 6. 15 Chapter 2 Literature Review 2.1 Manifold B-Rep Model Validity Fundamental concepts and definitions of solid modeling can be found in Requicha [53], Mintyli [45], Hoffmann [29], Braid [14], and the literature cited therein. A historical overview of solid modeling developments can be found in Braid [13] and Voelcker and Requicha [66]. This section provides a brief summary of prior research work on model validity, especially of manifold B-rep models. A solid modeler is designed to model a set of mathematical solids, which form the modeling space M of the modeler. Each element in M is an abstraction of a real solid. A modeler consists of representations and a representation scheme. A representation is a finite symbol structure constructed from an alphabet according to syntactical rules. All syntactically correct representations form the representation space R. A representation scheme is defined as a relation s : M -+ R, whose domain D C M and whose range V C R. A valid representation is a representation in V, see Figure 2-1, Requicha [53] and Mintyli [45]. Manifold B-rep describes real solids whose mathematical abstractions are r-sets with 2-manifold boundary [53, 45]. An r-set is a bounded, regular and semianalytic subset in E 3 . Almost all man-made solids can be represented by such mathematical descriptions. B-rep uses a collection of 2-dimensional entities, called faces, properly connected and consistently oriented, to define solid boundaries. Each face is bounded 16 S Figure 2-1: Domain and range of a representation scheme by loops and is embedded on a surface. Each loop is a string of edges, properly connected and consistently oriented to form a simple closed curve with orientation. Each edge is a simple open or closed curve, and embedded on a curve and bounded by two vertices. In addition, a shell is defined as a collection of faces whose union is a connected 2-manifold without boundary. See Figure 3-5 for the diagram of such a hierarchical structure. Adjacency and incidence relations of these topological entities are referred to as "topology" or topological structure, and their underlying geometries as "geometry" or geometric representation. A B-rep model is valid if its faces form a 2-manifold without boundary. Specifically, a B-rep model is valid if the following conditions are satisfied [44]: 1. Faces may intersect only at common edges or vertices. 2. Each edge is shared by exactly two faces. 3. Faces around each vertex can be arranged in a cyclical sequence such that each consecutive pair share an edge incident to the vertex. Similar conditions were also presented in terms of a simplicial complex methodology in Hoffmann [29]. The above conditions for validity require topological integrity, meaning that it is possible to assign each topological entity a well-behaved geometry such that the overall geometry is a 2-manifold without boundary [44], and geometric integrity, meaning that geometric representation conforms to all topological relations presented in the topological structure [15]. Orientations of faces must obey Moebius' Rule [22, 44], that is, each edge is traversed exactly once in each direction. 17 Topological integrity can be assured by using Euler operators as primitive modeling operators. Euler operators were introduced by Baumgart [9] in his work on computer vision, and were extensively studied by many others [21, 14, 15, 46, 44], see also Braid [13] for historical notes on Euler operators. The theoretical basis is the well-known Euler-Poincar6 formula, which holds for polyhedra in E 3 . A limited set of Euler operators is enough to construct any polyhedron. For convenience, often an augmented set of Euler operators is chosen. Higher level modeling operations, such as sweeping, chamfering, and set operations, are developed along with geometric specification and computation algorithms. In Braid et al [15], a topological structure is called admissible if certain conditions are satisfied, mainly the Euler-Poincar6 formula. Admissibility does not imply validity because the Euler-Poincare formula is necessary but not sufficient, meaning that a polyhedral model satisfying this formula may not be a 2-manifold [14, 15, 29]. Mdntyld [44] further proved that any topological polyhedron constructed using Euler operators is topologically valid. For models created using a modeling kernel whose operations are not based on Euler operators, topological structures could be invalid even if the Euler-Poincare formula is satisfied. Geometric integrity can be verified by two tests, see [15] for polyhedral models. Local test verifies if underlying curves of edges and coordinates of vertices are consistent with surfaces. Global test checks if there are any surface intersections in the interiors of faces. 2.2 CAD Model Rectification This section reviews model rectification techniques, mainly on polyhedral models and surface models. Very little research on curved B-rep model verification and rectification has been published. Some commercial software is now marketed including model verification and rectification tools. Without access to their proprietary techniques, their review is superficial. Based on descriptions of product features [37, 36, 38], such software tools detect and rectify local defects. Global consistency is left to the user 18 or processed in an iterative manner. 2.2.1 Polyhedral models Polyhedral models use linear geometries as underlying geometries of boundary entities. Though limited in expressive power, they are widely used to approximate curved objects in model rendering, finite element analysis, and manufacturing such as rapid prototyping. A special class of polyhedral models is triangulated models such as STL models in rapid prototyping. Despite of its many drawbacks, STL file format [1] is the de facto industry standard for solid freeform fabrication as a method for rapid prototyping. An STL model contains a collection of unordered triangles with no topological information. Each triangle is represented by three points as its vertices and a normal vector indicating orientation. Therefore, the boundary of a solid is defined by consistently oriented and properly connected triangles. Defects in STL models are gaps, inappropriate intersections, dangling triangles, overlapping triangles, and inconsistent orientations [12, 43]. Bohn and Wozny [12] proposed an algorithm which detects and repairs gaps in STL models. It first identifies lamina edges. A lamina edge on a triangle is an edge which has no adjacent triangle, or more than one adjacent triangles, or one adjacent triangle with inconsistent orientation. The algorithm then strings lamina edges into a directed graph, and separates the graph into a collection of simple closed curves. Complicated situations where such separations are ambiguous are resolved using topological and geometric heuristic rules, such as the assumption that a model only represents one solid. These simple closed curves bound holes. Additional triangles are added to close holes. Mdkeli and Dolenc [43] developed methods for efficiently repairing STL defects, including gaps, overlapping or duplicate triangles, and intersecting triangles. The algorithm first detects adjacency relations among triangles. Before a triangle is inserted into a specially designed data structure, each of its vertices is compared with the vertices of triangles already in the data structure, and merged with the closest 19 one, if the distance is within a given tolerance. Neighboring relations are then detected. Edges without matching edges from other triangles are classified as erroneous edges. Gaps bounded by such edges will be triangulated. Degenerated triangles and exact duplicates are deleted at this stage. The orientation of a triangle is determined by the number of intersections between the model and a ray emitted from one of the vertices in the direction of the normal vector. Intersections are checked within one connected component and between different components. The above algorithms succeed in the majority of candidate models. However, as local methods, global consistency is not guaranteed. Unwanted features may be added during gap-filling. In addition, triangles added to fill in gaps are often ill-shaped and inappropriate for some analysis and manufacturing programs. Barequet and Sharir [8] developed a global gap-closing algorithm for polyhedral models, using a partial curve matching technique. In their method, gap boundaries are discretized. Each match between any two parts of gap boundaries is given a score based on the closeness of their discrete points. They have shown that finding a consistent set of partial curve matches with maximum score, a subproblem of their repairing process, is NP-hard. Barequet and Kumar [7] developed a model repairing system using the algorithm in [8], but with a modified score which is the normalized gap area between two matched parts of gap boundaries. Visualization tools were also provided to enable the user to override unwanted modifications. The system was improved by Barequet et al [6] in terms of efficiency, and extended to models with regular arrangement of entire NURBS surface patches. However, this extension does not handle trimmed patches with intersection curve boundaries and real B-rep models involving non-regular arrangement of surface patches. A different type of global algorithm is based on spatial subdivision. Murali and Funkhouser [51] developed an algorithm which handles defects such as intersecting and overlapping polygons and mis-oriented polygons. The algorithm follows three steps: spatial subdivision, solid region identification, and model output. It first subdivides R 3 into convex cells using planes on which polygons sit. A cell adjacency graph is then constructed. Each node is a convex cell, and each arc is a link between two cells 20 sharing a polygon. Whether a cell is a part of the intended solid is determined by its solidity value, ranging from -1 to 1. The solidity value of a cell is computed based on how much area of the cell boundary is covered by original polygons as well as solidity values of neighboring cells. Boundary polygons of cells with positive solidity values are then output as the resulting solid boundary. A major advantage of this algorithm is that it always outputs a valid solid. One limitation of this algorithm is that it may mishandle missing polygons and add cells which do not belong to the model. 2.2.2 Surface models Surface models are also boundary models. Solid boundaries are defined by surface patches with no topological information. As patches often mismatch for reasonably complex models, validity is difficult to achieve and maintain. Hamann and Jean [27] developed an interactive surface correction technique intended as a preprocess for a grid generation system. The method projects local Coons patch approximants, each of which interpolates four boundary curves specified by the user, to the original surfaces and creates artificial points at the gaps where no projected points exist, using a bivariate scattered data approximation technique. The artificial points, together with the projections, will later be approximated by a bicubic B-spline surface. Adjacency between patches is determined by the distance between their boundary curves. Go and G1 continuity can be enforced by simply adjusting control points of neighboring patches. The method is a geometric approach with a few topological constraints. It may created non-manifold features due to missing patches and surface intersections. Trimmed patches may impose some difficulties on boundary specification for Coons patch approximation. Continuity will change if a specified boundary curve is located inside a surface patch. In addition, subdivision of surfaces into quadrilateral patches burdens the user. Although user interference is unavoidable as the authors believe, it should be minimized. Hu and Sun [35] developed an algorithm which closes numerical gaps between two trimmed patches by moving one surface towards one of the trimming curves of the other surface. This method corrects gaps up to a certain accuracy, and gaps 21 will reappear when higher accuracies are used in application programs. Moreover, it perturbs the control points of a surface so that one specific trimming curve on the surface is close to a target curve in the space. Since this method changes surfaces, it may not be suitable for surfaces specifically designed to meet functionality and performance requirements. A better approach to surface model rectification first involves construction of the topological structure. This not only rectifies an invalid model, but also converts surface models into B-rep models [59]. Evensen and Dokken [23] developed an adjacency analyzer for transferring geometries between different CAD systems. The adjacency analyzer reconstructs the topological structure of a model whose original topological structure is either modified or completely lost during data exchange. The underlying algorithm uses a geometric resolution to find possible common intervals between two curves. The adjacency test of surfaces examines the closeness of boundary curves of any two surfaces in a surface model using the given resolution. Surfaces with their boundary curves sharing common intervals are tagged as adjacent. As the authors pointed out, the analyzer is unable to handle trimmed surfaces, two surfaces intersecting in their interiors, and overlapping surfaces. More importantly, the algorithm only constructs local topology, i.e. incidence and adjacency relations among surface patches, without verifying global topology. Sheng and Meier [59] developed a topology analyzer for generating topological structures for surface models. The algorithm first discretizes boundary curves of surface patches, and then identifies matching pairs of boundary curves if any two curves fall inside small neighborhoods of each other. The matching polygonal curves are merged and the two corresponding patches are considered adjacent. This is, indeed, very similar to the algorithm developed by Barequet and Sharir [8], but without consideration of global topological correctness and geometric optimality. 22 2.3 Robust Geometric Representation Another direction towards robust solid modeling, currently investigated by many, is to develop robust geometric representations in the floating point environment. Such a representation is often based on a certain arithmetic system whose numbers are representable on the computer and operations are closed. Floating point representation has a discrete domain of numbers, and round-off is unavoidable [30]. The goal of robust geometric representations is to maintain consistency of topological decisions based on geometric computations, so that models could achieve topological correctness and geometric consistency at least at a certain level of credibility. Two typical classes of representations are of great interest: integer-based and error-bounded. Integer-based representations use integer numbers. Pure integer representations use a certain data structure to store an integer. Values and coefficients for the geometric representation are all integers. If the result of a computation procedure requires more bits, the data structure may have a mechanism for dynamically growing storage size. As uncontrolled growths may lead to system failure, in general, such a result is replaced by an approximant. For example, an intersection point between two lines, is approximated by the closest point in the grid of representable integer points. Rational arithmetic represents all numbers as fractions with both numerator and denominator stored as integers. At present, rational arithmetic is inefficient when used in geometric computations, and thus, is infrequently used for geometric modeling. It may be used in situations where exact evaluations are crucial. In so-called lazy arithmetic, evaluations are performed using error-bounded methods, and switched to rational arithmetic when approaching degeneracies. See [47, 24, 39, 40, 10, 3] for references on integer, rational and lazy arithmetic and their applications in geometric and solid modeling. In the following, we review a typical error-bounded representation, interval geometric representation,since it will play a key role in our approach to the model verification and rectification problem. In interval arithmetic [49, 4], a number is a closed interval in R, and algebraic operations are well-defined and closed. If input values to a computation procedure 23 are known to be intervals, interval evaluation returns intervals containing the exact result. By using rounded interval arithmetic, even round-off errors can be captured, and enclosures of exact results are computationally preserved [2]. However, both interval and rounded interval arithmetic are conservative, meaning that width growth may be unnecessarily larger than actual error propagation. Therefore, width control is a very important issue in algorithms using interval arithmetic. Interval geometric representation uses interval numbers for parameters and coefficients, and in general, represents a 3D region in space. An interval geometry also represents a family of geometries of the indicated dimensionality. For instance, an interval curve may refer to its induced region in the setting of point-set theory, or to a family of curves when its dimensionality is of primary interest. Interval polynomials were used in numerical analysis since the 1960's [49]. Interval B6zier curves, whose control points are rectangular boxes and represented as interval vectorsi, were first studied and applied by Sederberg and Farouki [57] in curve approximation. Interval explicit B-spline surfaces were studied by Tuohy and Patrikalakis [63, 64] and applied in approximation problems. Tuohy et al [62] extended the concept to interval parametric B-spline surfaces and applied it in surface approximation. Shen and Patrikalakis [58] studied the numerical and geometric properties of interval B-splines. Hu et al [33, 34] first proposed an interval solid modeling method. It uses interval points, curves and surfaces as underlying geometries for vertices, edges and surfaces. A graph-based data structure incorporating special features of interval geometries was also developed to represent both manifold and non-manifold objects. Algorithms of Boolean operations are based on robust interval curve and surface intersection algorithms [32, 31]. These rely on the Interval Projected Polyhedron (IPP) algorithm for robustly solving a system of m nonlinear polynomial equations in n unknowns within an n-dimensional rectangular box, see Sherbrooke and Patrikalakis [60] and Abrams et al [2]. However, topological properties of interval solid models were not studied in the above references. Topological issues are very important. As an interval solid model defines a family of boundaries, topological invariance of members is crucial 'An interval vector is a 3-tuple whose components are interval numbers. 24 for retrieving correct boundary information from the interval model. We study such issues in detail in Chapter 5. 25 Chapter 3 Representational Validity of Boundary Representation Models 3.1 Mathematical Preliminaries A real solid is a material object that occupies a region in 3-space. An abstract solid, therefore, must unambiguously describe the region occupied by the solid, so that it is possible to classify whether a point is inside the region of the solid [54]. Another important characteristic of a real solid is its physical realizability, which refers to the possibility of rebuilding it [52]. On the other hand, this realizability should not be limited by current manufacturing technology. A widely accepted definition of solid was given by Requicha [53]: "a solid, denoted as r-set, is a subset of R 3 that is bounded 1 , closed 2 , regular3 and semianalytic4 . This definition captures mathematical characteristics of most real solids of interest, such as mechanical parts. However, this definition allows non-manifold features, such as the contacting edge between two cubes, a feature which is non-manufacturable (see 1A set in R 3 is bounded if for every pair of points in this set, the distance is less than some number [50]. 2 See the definition in this section. 3 A set in R 3 is regular if it equals the closure of its interior [53]. 4 A set is semianalytic if it can be expressed as a finite Boolean combination of sets of the form {(x, y, z) I F(x, y, z) <; 0}, where the Fi are analytic [53]. 26 Figure 3-2(b)). It is for that reason that many prefer a solid to be a topological manifold [451. In the following we state some definitions pertinent for this discussion. For a reference see [18, 20, 48]. Let p E R' and let r > 0. The open ball B(p, r) of radius r centered at p is defined as the set of points x C R" whose distance from p is less than r. Such an open ball is also called a neighborhood of p. An open halfspace Rn+ is defined as Rn+ = {(x1, X2 , - - -, xn) E R" ;> 01 for some i, 1 < i < n. A subset A of R" is open if for every point a E A there exists an r > 0 so that B(a, r) C A. A subset A of R" is called closed if its complement -,A is open. A k-simplex o-T=conv(T) is the convex hull of an affinely independent set T C R", TI = k + 1, where |TI denotes the number of elements of T. k is called the dimension of the simplex aT. A simplicial complex K is a finite collection of simplices that satisfy the following: 1. if uT E K then c-u E K, VU CT, and 2. if u, o-v E K, then -unv = O-u n a-v. The underlying space of K is [K] = UCEK U-, with the induced topology from R". A subcomplex of K is a simplicial complex L C K. Definition 3.1.1 Let A C Rn. The interior Int(A) of A consists of all points a E A such that A contains a neighborhood of a. The closure A is defined as A = ,int(-,A). The boundary of A is Bd(A) = A-Int(A). A shall be called compact if it is bounded and closed. Definition 3.1.2 Let A 1 , A 2 be subsets of R', R', respectively, and let g : A 1 -+ A 2 be a map. We say that g is continuous, if for every point b E A 2 and r > 0, the inverse image of B(b, r) n A 2 is equal to C n A 1 , where C is an open set in Rn. In addition, we say that g is a homeomorphism if g is 1-1, onto and g and g continuous. In that case we say that A 1 and A 2 are homeomorphic. 27 1 are both Definition 3.1.3 Let M, N be subsets of R'. We say that M is a n-manifold (without boundary) if every point p C M has a neighborhood homeomorphic to R . On the other hand, we say that N is a n-manifold with boundary if every q E N has a neighborhood homeomorphic to either Rn or Rn+. In this case, the boundary ON of N is defined as the set of points x E N that have a neighborhood homeomorphic to Rn+, and the interior Int(N) as the set of points x e N that have a neighborhood homeomorphic to R'. In view of the above, we define an open disk A = Int(M), where M C R3 is a 2-manifold (with boundary) homeomorphic to the unit closed disk D ={x C R2I|xjj < 1}. A half open disk Ah is a bounded subset of R 3 homeomorphic to {x = (xI, x 2 ) c R 2 1 1xII < 1, and x 2 > 0}. Definition 3.1.4 Let M be an n-manifold, with or without boundary. If there exists a simplicial complex K whose underlying space [K] is homeomorphic to M, then M is said to be a triangulated n-manifold, and K is called a triangulation of M. Remark 3.1.1 If N is a n-manifold with boundary, then its boundary ON is an (n - 1) manifold without boundary. For a proof see [26], p. 59. Definition 3.1.5 A curve c C Rn is the image of a continuous map g : [0, 1] -+ R". It is called simple if g is 1-1 over (0,1). c is closed if g(0) = g(1). We also say that c has a self-intersection if g(to) = g(ti), with to # t1 and at least one of the to, t1 is in the interior of [0,1]. Definition 3.1.6 A (parametrized)surface E is the image of a continuous map (D D c R2 -+ R3 . We can write <b(u, v) = (x(u, v), y (u, v), z(u, v)). If (D is differentiable, we call E a differentiable surface. In that case we say that E is smooth at a point (uo, vo) if the vector 2 x '- # 0. We also call E an almost smooth (AS) surface if E is smooth for all points in D, except at a set of points 28 of measure zero. Finally, we say that E has a self-intersection if there exist points (u 1 , v1) # (u 2,v 2 ) E D, with at least one of these points in the interior of D, so that ((ui, v1) = (2, 3.2 V2). Solids and their Boundaries In view of the above and [53, 45], we may now define: Definition 3.2.1 Let S C R 3 . S shall be called a solid if it is a compact and connected 3-manifold with boundary, so that: 1. Its boundary 0S is a 2-manifold without boundary, and 2. OS C U> Rj, where {Rj} are AS surfaces. Figures 3-1 and 3-2 illustrate several valid and invalid solids. Figure 3-1: Two valid solids Obviously, for a solid S we have OS = S - int(S). In addition, thanks to a result from geometric topology, we note that a solid is a triangulable manifold with boundary, and thus it is orientable [48]. Roughly speaking, the latter means that we know precisely its interior as well as its exterior. Notice, also, that the boundary of a solid may not be connected if the solid has cavities. Definition 3.2.2 Let S be a solid. A shell C of S is a connected component of 0 9S [44]. For such a C, we define the inner (outer) part of C, C'(C ), as the interior of the unique bounded (unbounded) connected component of R 3 29 - C, respectively. (b) (a) Figure 3-2: Two invalid solids Notice that since C is a 2-manifold without boundary sitting in R 3, it is orientable, and thus R 3 - C has precisely two connected components, one bounded and one unbounded. Remark 3.2.1 Let S be a solid. Then, there exists a unique shell Ce, called external shell, so that every other shell of S is contained in its inner part CeI. Proof: Let U be the unique unbounded connected component of R 3 - S. Let now Ce be a shell of S with the property that some point p E Ce has a neighborhood that does not meet any other shell of S and intersects U. Since Ce is orientable, we see that every point of Ce has the above property. We now claim that this shell of S is the only one with this property; for otherwise, S would not have been connected. Finally, if C is another shell of S it obviously lies in the inner part of Ce, since the outer part of Ce is precisely U. All shells of S, except Ce shall be called internal. Note from the above remark that k S = UeI - C1 C i=i1 where Ci are the internal shells of S. 30 (3.1) We next define the so-called faces of a solid, in order to achieve a boundary representation of solids. Face can be defined in an analogous way to a solid, see Mintyli [44]. The following definition gives a clear description of face topology. Definition 3.2.3 A face f of a solid S is a non void subset of OS having the following properties: 1. f is a subset of one, and only one, AS surface. 2. The interiorInt(f) in OS is a connected 2-manifold, and 3. f is homeomorphic to a (topological) sphere E minus a finite number of mutually disjoint (nondegenerate) open disks Ai C E, i = 0,1 i # j, OAi n azj .. , k, k > 0, so that for is either empty or a single point. The requirement that a face is embedded in one surface is representational rather than mathematical. This also makes an abstract face close to a natural face, which in general is bounded by natural edges manifested by tangential discontinuities. It is also accepted in solid modeling practice that a face has no handles. Indeed, this is the case as definition 3.2.3(3) shows. Notice that a face is path-connected, and the connectedness of its interior excludes two neighboring faces to be taken as one face. See also Mintyli [45]. The following remark comes directly from definition 3.2.3 and is useful for face representation. Remark 3.2.2 Let f be a face of a solid S, and k > 0 be as in definition 3.2.3(3). Then, " f is homeomorphic to F, where F is the closed unit disk D = Do minus k mutually disjoint (nondegenerate) open disks Di, so that Di C D, for all 1 < i < k, and aDi n Dj is either empty or a single point, for i # j,0 i, j < k, and * The interior of any simple closed curve c - U _%&Di in F, is a subset of Uk_ 1 Di. 31 Proof: Indeed, a sphere E minus the open disk A0 is (homeomorphic to) the disk D. Further exclusion of the remaining open disks Ai, 1 < i < k results in the description of F in the first bullet. To prove the second assertion let us suppose that C 1 , C2 are two different connected components of F. Then, we may pick a simple closed curve c E Bd(C 1 ) so that its interior is just C1 . This, however, is a contradiction to the second bullet. We define the boundary of between f f as Bd(f) = f- Int(f). Once a homeomorphism and F has been established, it is easy to see what the boundary of Indeed, let g : f - f is. F be a homeomorphism of f and F. Then Bd(f) = g- 1 (OD) U U {g-1(0Di)} (3.2) . The following remark describes the topology of Bd(f). Remark 3.2.3 Let x C Bd(f), and let Ai be an open disk so that x C OAi. Then, we may choose r > 0 so that Fl. ci = B(x, r) n aA is a simple curve. Moreover, if x E DAj, j : i, then ci n c = {x}. F2. f n B(x, r) is equal to precisely m half open disks D'(f) if and only if x C nT 1OAi. In addition, A' = Ai n B(x, r) is a half open disk, for each i. Moreover, UL'i, {D'(f) U A} = E n B(x, r). Proof: Fl. Let x C Bd(f). Then, x belongs to the boundary of some open disk Ai. Since that boundary is an 1-manifold without boundary, that is, a simple closed curve, we may pick an r > 0 so that ci = B(x, r) n Oa. is a simple curve. Now, if x E &aj, j : i, Definition 3.2.3(3) says that Oaj n &a2 = {x}. Thus, ci n cj = {x}. F2. Let x E n', 1 OAi. Then if r is as above, Ex(r) = E n B(x, r) is a closed disk. From F1 we see that each ci intersects Bd(E(r)) at precisely two points, say al, a2. Since each Ai is a 2-manifold with boundary the simple closed curve ai, we see that A' = Ai n B(x, r) is an open half disk, whose boundary contains a>,a?. 32 Since ci n cj = {x}, we observe that the ci's divide the disk EZ(r) into precisely 2m connected regions R, R?, each one of them being a closed disk, whose boundary contain the points a., a., and a?, a!+, respectively. The proof is now complete. * Definition 3.2.4 Let f, F,g be as above. A loop of f is one of the simple closed curves g- 1 (DD) and g-'(Di). We may now define the notions of external/internal loops of a face above. We define the external loop of other loops Li of f f, Le to be Le = f. Let f, F be as g- 1 (OD). We shall call all internal. Even though the definition of external/internal loops of a face is not unique, we may use that notion to 'reconstruct' a face from its boundary loops. To achieve the latter, we will have to define the notion of a region bounded by a loop in f. First define Re = g-'(D), and R. = g- 1 (Di). Then, we have k f = Re - U (3.3) Int(Ri). i=1 Notice the similarity of the above formula, with formula (3.1). Figures 3-3 and 3-4 illustrate several valid and invalid faces. (a) (b) (c) Figure 3-3: Three valid faces We may now expand the above discussion of the notion of the 'region bounded by loops' so that we can use it in the next section. Let E : <D : [0, 1] x [0, 1] be an AS surface and let cj, j R3 = 1, -- -, m be simple closed curves that belong to E, with the property that Cr n ci is either empty or a single point. We also assume that in a neighborhood Nj of each cj, 4) is 1-1. Let also E as well as the cj's come with 33 (a) (b) Figure 3-4: Two invalid faces a specific orientation. Then, it is possible to define the region bounded by the closed curves c3 , R'. To do that, we consider the curves l = -1 (cj). Then, since D is 1 -1 over Nj, each l is a simple closed curve. The given orientation(s) on E and cj induce-via 4 and each l. 1 -an orientation on [0, 1] x [0, 1] We can then agree that each of the above oriented closed curves define a region in [0,1] x [0,1]. For each lj we define the region bounded by l, R(l) as the subset of [0, 1] x [0, 1] that lies to the left of l as one is walking on the positive side of [0, 1] x [0, 1], along lj with respect to its orientation. Finally, we define RE= R* = nj4(R(lj)), 0 otherwise if Bd(R*) = Ujcj and R* is connected (3.4) Now, a loop can be decomposed into edges. Definition 3.2.5 An edge e of a face f is a subset of Bd(f) such that 1. It is also a subset of a loop, and 2. It is homeomorphic to either a simple closed curve or to an open simple curve. On the other hand, edges are bounded by vertices: Definition 3.2.6 A vertex v of an edge e is " A component of Bd(e), if Bd(e) # 0; " An arbitrarypoint in Bd(e) if Bd(e) 34 = 0. In general, the underlying geometry of an edge is the intersection curve of the two underlying surfaces of the two faces sharing this edge, and a vertex is the intersection of three or more surfaces. We next give the definition of boundary representation: Definition 3.2.7 A boundary representation of a solid S is a collection of faces fi, 1 < i < n, such that 1. U -f=OS, and 2. For any i 0 j, fi n fj = Bd(fi) n Bd(fj). Representational Validity Conditions 3.3 3.3.1 Data structure A typical data structure for B-rep model has a graph structure as shown in Figure 3-5. B-rep data structures can be found in Baumgart [9], Mantyli [45], Weiler [67] and others. Description of the nodes is given below: 1. A vertex node is the representation of a vertex. It has a pointer to a node containing Cartesian coordinates. 2. An edge node is the representation of an edge. It has two ordered pointers to two vertex nodes, and a pointer to a node containing the geometric representation of a curve, including a binary field specifying the orientation of the edge with respect to the orientation of the curve. 3. A loop node is the representation of a loop. It has a collection of pointers, each of which points to an edge node and has a binary field specifying the orientation of the edge in the loop with respect to the orientation of the edge. 4. A face node is the representation of a face. It has a collection of pointers, each of which points to a loop node and has a binary field specifying the orientation of the loop in the face with respect to the orientation of the loop. It also has 35 a pointer to a node containing the geometric representation of an AS surface (see Defintion 3.1.6), including a binary field specifying the orientation of the face with respect to the orientation of the AS surface. 5. A shell node is the representation of a shell. It has a collection of pointers to face nodes. Model Shell Surface -- Face -. -- Loop Curve Point Edge -- Vertex Figure 3-5: Graph representation of the data structure The data structure is an adaptation of the STEP file structure [65], and is able to hold non-manifold features, as we assume a given representation could be topologically incorrect. 3.3.2 Sufficient conditions for node validity Representational validity verification, for a certain data structure like the one in section 3.3.1, is a process of verifying that each node in an instance of the data structure is a valid representation of the corresponding topological entity. The following suffi36 cient conditions are compiled from priory work such as [45, 29, 44, 15, 22, 65], and the discussion in Section 3.1 and 3.2. C 3.3.1 Vertex node validity A vertex node is a valid representation of a vertex if it is assigned with the coordinates specifying the position of the vertex in R3 . C 3.3.2 Edge node validity An edge node is a valid representation of an edge if 1. Its two vertex nodes represent points on the underlying curve of the edge. 2. There exists a path on the curve, connecting these two points in the given orientation. 3. The curve does not self-intersect in the interior of the path. C 3.3.3 Loop node validity A loop node represents a valid loop if 1. The directed graph constructed by taking vertices as nodes and oriented edges as directed arcs, is a simple directed cycle. 2. Any two adjacent edges intersect only at their common vertices. Any two nonadjacent edges do not intersect. C 3.3.4 Face node validity A face node represents a valid face if 1. All its loop nodes represent loops on the surface. 2. The surface does not self-intersect in the interior of the region bounded by the loops, see equation (3.3). 3. The region bounded by the loops satisfies Remark 3.2.2. C 3.3.5 Shell node validity A shell node represents a valid shell C if 1. Each face of C has exactly one adjacent face, which also belongs to C, through each of its edges. 37 2. Each vertex v E C has a finite number of incident faces fi E C and (nondegen- erate) edges e E C, 1 < i < m. These incident faces and edges can be arranged in the form of f, - el - f2- - - - - fm - em - fm+ edge of fi and fi+1, for i = 1,. -, = fi, and ei is a common iM. 3. Any two adjacent faces only intersect at their common vertices and/or edges. Any two non-adjacent faces do not intersect. 4. Faces are consistently oriented. C 3.3.6 Model node validity A model node represents a valid B-rep model if 1. There exists exactly one external shell. 2. Each of the inner shells is properly oriented such that the region it bounds is in the region bounded by the external shell. 3. None of the inner shells is in the region bounded by another inner shell. 4. Shells do not intersect. 3.3.3 Proof of validity In this section we will show that whenever the conditions of section 3.3.2 are satisfied, then we indeed get a valid solid. More precisely, we will prove that when conditions C3.3.1 through C3.3.5 are satisfied the result will be a shell. In addition, we will also prove that once we have shells and C3.3.6 is satisfied, then we will get a solid. Our approach is primarily based on the fact that a face f that comes from a face node can be given a triangulation Tf. This is easily seen from Remark 3.2.2. Furthermore, using C3.3.5.1, given any two faces fi and f2, we can always pick triangulations Tf, and Tf2 of fl, f2 such that T, n Tf2 is a triangulation of fi n f2 = Bd(f 1 ) n Bd(f 2 ). Now let C be a shell that comes from a shell node. To this end, we will show that C is a compact oriented triangulable 2-manifold without boundary. 38 To achieve that, let a be a point of C. Then, there exists a face f so that a E f. If a E Int(f), then a has a neighborhood Na homeomorphic to R2 . Since any two faces do not intersect at their interiors, Na is also a neighborhood of a in C. Now let a belong to fi, i = 1, 2,. - -, m, m > 2. In that case we see that a E OBd(fi), for all i. For simplicity, we may always take a to be a vertex of C. Let el, e 2 , - --, em edges of C so that along with the faces fi, ---, f m satisfy C3.3.5.2 in the said order. Since we have a finite number of distinct edges ei coming through the common vertex a, and each ei satisfies C3.3.5.2, we may pick a 6 > 0 small enough so that if B = B(a, 6) " F2 of Remark 3.2.3 is true for r = 6 and for each fi. " The ci = B n ei are mutually distinct non-closed simple curves, and each ci is a subset of Bd(fi) n Bd(fi+1 ), and " ci =- {a}, for i # j. From the second bullet above we see that OB n ei is precisely one point; we call it ai. Let Ni j 1,.-. = Bn fi. , ki. Since From F2 we see that Ni is a collection of ki half open disks Da(fi), fi is incident to ei_ 1 and ei, ci_ 1 and ci belong to one, and only one, of the above disks, say Dl(fi). Call the unique simple oriented curve that is part of the boundary of Dl(fi) and connects ai_ 1 and ai, without going through a, 'y_. Now let F U {"' 1}, where am+l = a 1 . Then, since the disks D3(fi) and the interior of faces are mutually disjoint, respectively, we see that F is a simple curve that belongs to OB, and thus it is unknotted. We claim that the union of all the above collections Ni, N = U~L 1{UNi} is an open disk. Indeed, we first note that the boundary of each half open disk Dl(fi) is simply the (simple) closed curve ci_ 1 U 7_1 U ci. Now, the set D'(fi) U Dl(f 2 ) is a closed disk since is the result of gluing together the two disks D (fi) and D'(f 2 ) along their common boundary c1 . Simple induction shows that m 19= J Dl(fi) i=1 is a closed disk with boundary F. Obviously, Int(D) = N. This proves the claim. 39 The above shows that C is a 2-manifold without boundary. Since C consists of a finite number of faces, each of them being a bounded subset of R3 , C is also compact. In addition, condition C3.3.5.4 shows that C is orientable. Finally, since each face f of C is given a triangulation Tf that agrees with the triangulation of each of its adjacent faces, C is triangulable. We have thus showed the following: Theorem 3.3.1 Let C be a shell that comes from a shell node satisfying conditions C3.3.1 through C3.3.5. Then C is a compact oriented triangulable 2-manifold with0 out boundary. Corollary 3.3.2 Let S be a solid that comes from a model node satisfying C3.3.6. Then S is a valid solid. Proof: Let Ce be the unique external shell of S. Using the above theorem we see that Ce is orientable. We give Ce an orientation so that the region it bounds is its inner part C. Notice that each of the inner shells of S is given the proper orientation according to C3.3.6.2. Since the various shells of S do not intersect and each one of them is a compact manifold without boundary, then S is a 3-manifold with boundary its different shells. To finish the proof, it remains to show that S is connected. Let Ci be the inner shells of S, i= 1, - , k. Notice from C3.3.6.3 and Eq.(3.1) that k S =C - CU (3.5) i=1 Observe that CeI is connected. Since the internal shells Ci of S are disjoint and the interior of one does not contain any other, then S must be connected. 40 0 Chapter 4 Analysis of Manifold Boundary Representation Model Rectification 4.1 Problem Statement Defects must be identified before being rectified. Based on this principle, two approaches, local and global, may be explored for the development of rectification methods. A local rectification method traverses through a model, identifies defects using the sufficient conditions derived in Chapter 3, and rectifies defects using the same sufficient conditions, or some heuristic rules and/or user assistance if ambiguities arise. Such an approach is the same as other rectification methods [12, 43, 36] except that conditions for identifying and rectifying defects may have some differences. However, a local method does not guarantee a global optimal solution. In addition, rectification of local defects may have unpredictable cascading effects on other topological and geometric entities in the model, and some defects may not be rectified without searching further. A global rectification method, on the other hand, identifies all defects once for all. It then rectifies defects such that the resulting model is not only valid but also optimal based on some user-defined criteria. The difficulty of developing such a method lies in the fact that a priory identification of all defects, done independently of rectification, is simply impossible. As the definition of a boundary 41 is bottom-up in a model representation, the validity verification should proceed in the same manner. Higher level entities cannot be verified if lower level entities have not been rectified. Part of the reason why it is so difficult to implement an identifyand-rectify approach is the necessity to maintain the consistency between topological and geometric specification. It is not difficult to identify a defect, but it is hard to decide what is right or wrong, whenever there are inconsistencies between topological and geometric specification. The ultimate goal of model rectification is to find the model intended by the designer but misrepresented. However, without user assistance, any solution resulting from the erroneous model is only an educated guess. It comes down to the question "What do we trust about a model that contains defects?" This is the most fundamental question we must answer before we can move any further. For example, if a B-rep model has correct topological information, while there are no appropriate geometry embedded in the underlying surfaces, what is the intended boundary? Should the topological information be modified to accommodate the geometry, or should the geometry (surfaces) be perturbed to have a boundary consistent with the topological information? To answer such questions, we need to classify the information in a boundary representation: those initialized or selected by the designer and those induced by the system. In a solid modeling system, the only entities the designer can directly manipulate are the underlying surfaces. All others, topological information and individual topological and geometric entities, are computed by the system. For this reason, we opt to believe that surfaces are the basic information to be used in a rectification method. Another reason for such a hypothesis is that surfaces are specifically designed to fulfill certain performance requirements and functionalities, and therefore, should not be subjected to any modification without the designer's permission. In addition to the above, another piece of information which can be used in the rectification process is the genus of the intended solid boundary. Genus captures the designer's intent and can be computed using the well-known Euler's formula [14]. In this context, model rectification becomes a model reconstruction problem. An 42 algorithm for model rectification searches for the intended boundary in the union of all the surfaces, and rebuilds all necessary topological and geometric entities. However, there may exist many potential solid boundaries, or none at all, resulting from the surfaces. Without additional information, it would be difficult to make a choice. Since an erroneous model in a neutral format (e.g. STEP[65]) is computed with reasonable precision in its native system, the information in the model could help clarify such ambiguities, although it should be used with caution. Roughly speaking, a desirable solution is a model which describes a boundary somewhere "near" the object described by the original model, both topologically and geometrically. A typical data structure for B-rep models consists of topological structure and geometric representation. For a simplified version, see Figure 3-5. The topological structure, shaded in Figure 3-5, is a graph which describes adjacency and incidence relations' (represented by arcs) between topological entities (represented by nodes). In typical implementations more detailed topological relations are explicitly stored than those implied in Figure 3-5 (e.g. adjacency relations between a face and all its neighboring faces). The geometric representation includes points, curve and surface equations, which are associated with appropriate topological entities. A model, thus, is an instance of the data structure, and is valid if it describes a solid boundary. Let m, be a model with topological structure G(m") 2 . G(m0 ) is valid if it is possible to assign each topological entity a geometry whose interior is a manifold, such that the overall geometry bounds a solid. That is, if G(m0 ) is valid, there exists a nonempty set M = {mI m is a valid model and has topological structure G(m,)}. (4.1) For simplicity, in the following analysis, we assume that models have only one shell. 'Two topological entities of different dimensionalities have an incidence relation if one is a proper subset of the other. Two topological entities of same dimensionality have an adjacency relation if their intersection is a lower dimensional entity that has an incidence relation with each of them. 2 We denote models and face nodes by lowercase letters, and the point-sets they represent by uppercase letters. For example, model mo represents solid M,. The topological structure of a node is denoted by G(node). 43 It will be clear at the end of this chapter that the same result applies to models with multiple shells. With this assumption, for any m 1, M 2 C M, M1 is homeomorphic to M 2 , because they have the same genus. Therefore, in case that the geometric representation of m0 is inconsistent with G(m0 ), if a reconstructed model m" has topological structure G(m), mn is topologically equivalent to the design intent. If G(m) is different from G(m0 ), the topological equivalence between m" and m, can be imposed by requiring that the genus of OM, is equal to that of OM, where model m E M. We simply denote this by g(mn) = g(m,), because both genuses can be computed by applying the Euler's formula to G(mn) and G(m,), respectively. Geometrically, two objects are close to each other if each one is in a neighborhood of the other. Some form of distance function could be used as a measure for this purpose, either the maximum distance or a well-defined average distance. An alternative, arguably more suitable for boundary rectification, is the boundary area change before and after rectification, because both the rectified and the original models use the same set of underlying surfaces. A correspondence can be established between a rectified face and an old face if they both have the same underlying surface, and the area difference between them measures the geometric change. No matter what measure is used, it should approach zero as the erroneous model becomes the exact model. Let 0 be a function which evaluates the geometric difference between 1M, and OMs, and E be a user-specified tolerance for the geometric change. Let Mi, G(m 0 ) be as above. An ideal boundary reconstruction algorithm should follow the following procedure (see Figure 4-1): 1. Find a new model mn, such that mn has topological structure G(mn) 0 (M ,OMn) and E. 2. If there exist a number of such new models, select the one with the minimal # value. 3. Otherwise, find a new model mn, such that G(mn) is different from G(mo) but g(inn)= g(mo), and 0(&Mo, Mn) < E. 44 4. If there exist a number of such new models, select the one with the minimal topological structure change, e.g. the difference of the total numbers of arcs and nodes in G(ms) and G(m,) is minimal. 5. Otherwise, find a new model m, with #(OM 0, OM,) < 6. If there exist more than one such new boundaries, select the one with the minimal topological change (i.e. minimal genus change); otherwise, no new model is reconstructed. In the next section, we study the following subproblem which is essential to this reconstruction process: Boundary reconstruction (BR) problem: Given a B-rep model m, whose geometric representation is inconsistent with its topological structure, reconstruct a new model m, using only the information in m, such that: (1) g(mn) = g(mo) and (2) #(&Mo, 4.2 OM,) is minimal. Problem Complexity 4.2.1 Face reconstruction problem Before moving onto the boundary reconstruction (BR) problem, we first study a lower-dimensional problem which not only gives us insight on the nature of such reconstruction problems, but also plays a crucial role in understanding the complexity of the BR problem. A face node in a B-rep model represented in a certain format such as STEP [65] is likely to have inconsistent geometric features such as edges whose underlying curves are not on the underlying surface of the face. Topological errors such as open loops make a clear definition of the face geometry even more elusive. Similar to boundary reconstruction, face reconstruction builds a new face node node fo, f, from an erroneous face using only the information in the given model, such that valid but also close to the object described by fo fn is not only in both topology and geometry. We formulate the face reconstruction problem as an analog to the BR problem. 45 mo with topological structure G(mo) construct mn s. t. G(mn)~G(mo) and y return the one with minimal geometric Mn exist? change N construct mn s.t. g (mn)= g (mo) and $ ( Mo, abln) <E y Mn exist? return the one with minimal topological structure change N construct mn with$(QMo, aMn)<F, y Mn exist? return the one with minimal genus change N return Figure 4-1: Flow chart of an ideal global reconstruction algorithm 46 A valid face is homeomorphic to a closed disk minus k mutually disjoint open disks, and has no handles. See Chapter 3. If f, is valid, G(f 0 ) is a planar graph consists of simple cycles. Any two of these cycles may share at most one common nodes. Two graphs are homeomorphic if both can be obtained from the same graph by a sequence of subdivisions of arcs [281. However, two homeomorphic graphs may have different geometric embeddings, and thus define two faces which are not homeomorphic. See Figure 4-2. In order to capture the design intent topologically, the component containing the outer loop in G(fs) also needs to be homeomorphic to that in G(f 0 ), in addition to that G(f.) is homeomorphic to G(f 0 ), so that the above situation is prevented. In this case we say that G(fs) is homeomorphic to G(f 0 ) in the strong sense. In the following problem statement, of is a function evaluating the geometric change before and after rectification. Figure 4-2: Two homeomorphic graphs with different geometric embeddings Face reconstruction (FR) problem: Given a face node f0, whose geometric representation is inconsistent with its topological structure, in a B-rep model m, reconstruct a valid face node fn, using only the information in m0 , such that G(fn) is homeomorphic to G(f 0 ) in the strong sense and of(Fn, F) is minimal. In the following, we first study how an invalid face node could be rectified, and then formulate the face reconstruction problem mathematically and prove its NPhardness. Face boundary reconstruction Let R be the underlying surface of face node f,, and {Ri}1<i<N be surfaces in ino such that Ci = R n Ri ,0 0. Surface intersections could be very complex. Here, for simplicity, we assume that surfaces do not overlap. In addition, we also exclude 47 isolated intersection points, since such a point does not bound a finite region on R, and therefore, is not used to form the face boundary. However, if an intersection point between two surfaces is on an intersection curve, it may be used as a vertex in the face boundary. See Figure 4-3(a), where the intersection point of R and R 4 is on C1. CC3 " C2 (a) (b) Figure 4-3: Curve segments from surface intersections Furthermore, Ci's may intersect each other. Each Ci is subdivided by intersection points into curve segments, each of which is either an open curve bounded by two intersection points or a simple closed curve. Those intersection points, indeed, are intersections of three or more surfaces. Denote the collection of curve segments on all Ci's by {Sij}. See Figure 4-3(b), where broken lines are curve segments and solid dots are intersection points. In the figure, because the underlying surface is finite, its boundary curves are also used in creating curve segments. Notice that {Sij} subdivide R into patches whose interiors are disjoint and intersection-free. The face geometry must be either one of these patches or the union of some patches. Therefore, the face boundary consists of curve segments from {Si}. In the following description, for simplicity, we use a lowercase symbol to denote an edge or a vertex as a point-set. Whenever the corresponding representational node is referred, the word node is used before the notation. For example, node e represents 48 edge e. For models and faces, the same notation scheme as in the previous section is used, i.e. lowercase symbols for nodes and uppercase symbols for point-sets. Let node ei, be an edge node in f0, also shared by face node fi having Ri as its underlying surface. Then, to maintain geometric consistency of the adjacency relation between these two faces, ei, must be a subset of Ci. This is rarely true as the underlying curve given in node ei, is often an approximation of the exact intersection curve Ci. As a matter of fact, as illustrated in Figure 4-4, e k may be pathologically defined by a space curve (the broken line) and two points (the two circles) which may not be on the curve as they are supposed to be. Because the adjacency relation is symbolic and thus exact, the initial rectification of node ei, can be done by using Ci as the underlying curve and discarding the one given in the original model. Consequently, the vertices must be on Ci. They also need to be close to their original erroneous positions in order to reflect the design intent. Reasonable replacements of the original vertices v 1 , vi 2 , for instance, could be the projections Vo1 , Vi2 of v 1 , vi 2 onto Ci. See Figure 4-4, where the new vertices are solid dots. Therefore, such a rectified edge, denoted by e' vf, vo is a subset of Ci, bounded by and oriented in the same way as eik provided that the given underlying curve in node eik and Ci are not far apart. given underlying curve of node 8k Figure 4-4: Initial rectification of an edge on a face However, as a face should be bounded by curve segments from {Sj}, a rectified 49 edge should consist of such curve segments. Edge e'% is not guaranteed to be so. See Figure 4-5(a). Further rectification of ei, selects some curve segments on Ci such that their union is a simple open or closed curve and an optimal approximation of e'k. The union defines a new edge e', whose corresponding node has the same symbolic information as node eik, i.e. the same embedding surfaces, the same parent faces, and the same orientation, but has a consistent geometric representation while node e-k does not. Edge e'' can be obtained by perturbing vertices v', v' of e' to the closest intersection points on Ci. This vertex perturbation is also necessary in order to achieve geometric consistency at a vertex. A vertex is involved in various incidence and adjacency relations between its incident faces and edges, and therefore, needs to be positioned at the intersection point of those underlying surfaces. C2 C C0 M Co (a) (b) Figure 4-5: Creation of e'' by vertex perturbation The collection of such rectified edges, however, may not form a valid face boundary, as there may exist open loops and/or dangling curve segments. For example, in Figure 4-6(a), a dangling curve segment S1 2 and a gap between e' and e' exist. The final act of face reconstruction, is to trim away dangling curve segments and fill gaps with curve segments from {Sij}, so that the selected curve segments form a valid face boundary. See Figure 4-6(b). This trimming and gap-filling process should create a 50 face boundary which satisfies the topological and geometric requirements stated in the problem statement. C1 C2 C3 C4 C8 Cs C9 C6 C7 C10 (a) @9 (b) Figure 4-6: Trimming of dangling curve segments (a) and gap filling (b) Assume that in the final reconstructed face boundary, the selected curve segments from C, are S, = {Si3 ,}1 I;Li. A new edge e' is created by stringing curve segments in Si. The process starts with an arbitrary curve segment Sij E Si, and searches for its adjacent curve segments in Si. If, at one endpoint, exactly one adjacent curve segment Sii2 is found, then, Si2 is selected and the search marches on at the other 51 endpoint of Sij,; otherwise, the process terminates and resumes at the other endpoint of Sij. Notice that there may be more than one new edges created from Si. For example, in Figure 4-6, curve segments S72, S74 on C 7 are selected in the final face boundary, creating two new edges e' and e'. In summary, an edge ei, in the original model, shared by faces f0 and rectified by projecting its vertices onto Ci = f n Ri, fi, is first which is the exact underlying curve of node ei,. This produces e'k, and achieves a consistent adjacency relation between f0 and fi but may not do so at the vertices. Edge e'k is then rectified by perturbing its vertices to their closest intersection points on Ci, such that the resulting edge e' consists of curve segments in {SJg}. Notice that node e' has the same symbolic information as node ei, and could be geometrically consistent with all adjacency and incidence relations in which it is involved, if other topological entities are appropriately constructed. Typically, the geometric change between e'' and ek is minimal. Since such edges may not form a valid face boundary, additional curve segments from {Sij} are added to fill gaps and dangling curve segments are trimmed away. In the rectified face boundary, a new edge e" consists of curve segments from C. Problem formulation and proof of NP-hardness To mathematically formulate the FR problem, especially to quantify face geometric change, we classify new edges into two categories: 1. A new edge e belongs to the first category if it has a corresponding edge esk in the original model, i.e. e' is considered to be the rectified ei,. Such a new edge node has the same symbolic information as node eik and a geometry which is an optimal approximation of that of node eik. Because eik is not well defined, the geometric change between e' and ei, is measured by comparing e' and e'k, which is not only well defined but also symbolically the same as and geometrically close to eik. We define (,e e, ,) #e : (Ci x Ci) length((en U e') - (e, 52 n 7, where R e,, ', e'k _ C2 . (4.2) For example, in Figure 4-5, if e' = e'', meaning that during the trimming-and- filling stage the edge is unchanged, then 0e(e~, where elk ~V fvj (4.3) denotes the length of a curve segment. If there exist more than one new edges on C, which could belong to the first category, the one with the minimal e value is designated as the new edge in the first category, i.e. there is at most one corresponding new edge in the new boundary for each edge in the original model. In addition, el n e'l - 0, so that a new edge whose geometry is far away from e' will not be taken as the corresponding new edge of esk. This could happen, for example, when two new edges eC, 1 , e, 2 have the same symbolic information as eik but Ct,n ik ne' k :A0,% 0 e 0, =, , In Figure 4-6(b), all the new edges, except en , belong to the first category. 2. All other new edges belong to the second category. These edges are generally added to close gaps. Let a new edge be on curve C = R n R. It is possible that the face on Rj is not adjacent to fo in the original model, and therefore, the new edge on C does not have a corresponding old edge. Because the edges in the original face node carry the design intent, geometric changes to them should be minimized, i.e. E he for the new edges of the first category should be minimal. If there exist more than one choices of new face boundary having the minimum, the one with the shortest total length of the edges of the second category should be chosen, because any drastic change is not trustworthy. Figure 4-7(a) shows the curve segments and initially rectified edges. Notice that the original face node has an inconsistent geometric representation. It can be seen in Figure 453 7(b) that if all four edges represented by thick lines are selected in the final boundary, T e is the minimum. There exist five such loops. Figure 4-7(c) shows the final face boundary which has the shortest gap-closing edge eg, and Figure 4-7(d) shows the other four. We now formulate the face reconstruction problem as a search problem: Face reconstruction (FR) problem: Let f0 be a face node, whose geometric representation is inconsistent with its topological structure, in a B-rep model, and {Sij} be as above. Search for a subcollection {Sij,}11<i<N,1<1<Li (4-4) of {Sjj}, where Li is the number of curve segments selected on Ci, such that 1. {Sij,} bounds a face F,. 2. G(fs) is homeomorphic to G(f 0 ) in the strong sense. 3. Z #be(e's, e') is minimal for the new edges of the first category. 4. If condition (3) is satisfied, then, the total length of the edges of the second category is also minimal. Intuitively, this problem can be converted to a graph problem as {Sjj} forms a geometric embedding on R of a graph. This graph, Gf = (Vf, Ef), has curve segments in {Sj} as arcs in Ef and intersection points as nodes in Vf. The solution to the FR problem is then a subgraph satisfying the properties in the problem statement. The face reconstruction process is a process of searching for such a subgraph. A straightforward implementation of this process is to search all possible subgraphs and find the one satisfying conditions 1 to 4 above. Such an exhaustive search, however, may need exponential time in terms of the number of arcs in Ef. In the following, we prove that the FR problem is NP-hard by proving a restricted problem is NP-hard. See also Appendix A for some further comments on NP-hard problems. But first, we introduce a known NP-hard problem [25]: 54 (a) (b) (c) (d) Figure 4-7: Minimization of edge geometric change 55 Rural Postman Problem:3 Let graph G = (V, E). Each e E E has length 1(e) E Zo. Let E' C E. Find the circuit in G that includes each arc in E' and that has the shortest total length. Theorem 4.2.1 The FR problem is NP-hard. Proof: The basic idea of the proof is to consider the following instance of the restricted FR problem: The topological structure of f0 represents a closed disk, and there is only one curve segment on each Ci (see Figure 4-8). The boundary of F, is then a simple closed curve. The solution to the problem must be a circuit in graph Gf if condition (2) is to be satisfied. Figure 4-8: An instance of the restricted FR problem For each edge ejk of F, we construct e'el, as above. Because there is only one curve segment Si on each Ci, e' = Si provided that e' is not far different from ik segmen Si1. If Sil is in the reconstructed face boundary, then e" = e' Ne(e, e' = Si, and therefore, ) is minimal, due to the way e'' is constructed. If it is not in the face 3 Here we give the Rural Postman search problem because the FR problem is also a search problem. In [25], the Rural Postman decision problem is given. 56 boundary, then #e(e, S1 el) = is maximal, because e' = 0. Let {Si I there exists e' = S, 0 < i < N.} (4.5) Then, if all the curve segments in S1 are selected, E 0e for the edges of the first category reaches its minimum. This means that a valid face boundary which includes all the curve segments in S1, will be selected over any choice which does not. The corresponding instance of the Rural Postman problem is as follows: Graph Gf with 1(e) = length(Sai) for each i, and E' = S1. We prove that it can be reduced to the restricted FR problem at least in the abstract setting of graph theory '. It can be observed that the solution to the restricted FR problem answers the Rural Postman problem; if the solution exists for the restricted FR problem and contains all the curve segments in S1, it is the circuit with the shortest length and including all the arcs in E', and therefore, the solution to the Rural Postman problem; if the solution does not exist or it exists but does not contain all the edges in S1, no solution exists for the Rural Postman problem. 4.2.2 Boundary reconstruction problem Now we formulate the BR problem and prove that it is also NP-hard. Let m0 be the given B-rep model. The underlying surfaces, {Ri}1<i<N, are subdivided by surface intersections into a collection of patches (4-6) {Pi} }i<N,1<j<Ni, 1 where Ni is the number of patches on surface Ri. For a face node f, F, may not be well defined. Because the embedding information is symbolic and thus exact, the initial rectification of F can be done by trimming the underlying surface R. of using projections of the loops in fi fi onto Ri. Denote such a face by F'. As in face 4 Theoretically, it is possible to develop a linear algorithm to draw a planar graph on the plane. See [11, 17]. This establishes the argument that an abstract graph search problem could be converted to an instance of the geometric problem (FR problem). 57 reconstruction, F' is further rectified by selecting patches from {Pi}1ij N, to form a new geometry which is an optimal approximation of Fj'. Denote this new face by F". The difference between Fj' and Fj" can be measured by function of : (Ri x R.) -± R, where #f (F, Fj") = area((F'U F") - (F' n F")), Fj, F' C R . (4.7) Such rectified faces may not form a valid solid boundary due to the possible existence of dangling patches and holes. Therefore, a trimming-and-filling process follows. Similar to face reconstruction, in the new solid boundary, a new face F" belongs to the first category if it has a corresponding old face, and to the second category if it does not. For the faces of the first category, E #f (Fi, Fj') should be minimized. If there exist more than one valid boundaries having the minimum T Of, the one with the minimal total area of the faces of the second category should be chosen. The boundary reconstruction problem can also be formulated as a search problem: Boundary Reconstruction (BR) problem: Let m, be a B-rep model whose geometric representation is inconsistent with its topological structure, and {fPi} be as above. Search for a subcollection {Pijk }1 iN,1 k Kj, (4.8) of {Pij}, where Ki is the number of patches selected on surface Ri, such that 1. {Pij,} bounds a solid M,. 2. g(mn) = g(m 0 ), where m, is the new model representing M". 3. E Of(FiL, Fj') is minimal for the faces of the first category. 4. If condition (3) is satisfied, then, the total area of the faces of the second category is also minimal. We now prove that the BR problem is NP-hard: 58 Theorem 4.2.2 The BR problem is NP-hard. Proof: We prove the theorem by converting the restricted FR problem to the BR problem. Assume that in an instance of the restricted FR problem, the face node f0 has a plane as its underlying surface. Sweep the face along the normal direction to a parallel plane. The sweeping solid of F, should be homeomorphic to a closed ball. The instance of the BR problem is a patch collection {Pi} = {patches generated from curve segments} U{patches from the two planes}, (4.9) and a model m, with its topological structure representing a sphere and {Fj'} generated from {e'k }. See Figure 4-9 for an example. This conversion can be executed in polynomial time. If a subcollection of {S 3 } is the solution to the restricted FR problem, then the patches generated from the curve segments in the subcollection, with additional patches from the two planes, is the solution to the BR problem. Conversely, if a subcollection of the patches is the solution to the BR problem, it must be bounded by two patches from the two planes and patches whose generating curve segments indeed form the solution to the restricted FR problem. 0 For models with multiple shells, the same result holds, because the boundary reconstruction problem of models with one shell is a special case of that of models with multiple shells. The BR problem is, in certain ways, similar to the gap boundary matching problem studied by Barequet and Sharir [8] which is also shown to be a NP-hard (global search) problem. However, they are quite different in nature as the former reconstructs a boundary from a set of surfaces and involves complex topological constraints, whereas the latter matches boundaries of a set of surface patches. Theoretically, of course, all NP-complete problems are equivalent, but their specifics can vary significantly. 59 geometric description sweeping f2 fi topological structure FR problem Vi :e2 ei BR problem Figure 4-9: Illustration of the proof of Theorem 4.2.2 60 f3 e3- Chapter 5 Topological and Geometric Properties of Interval Solid Models 5.1 Introduction In the previous chapter, we demonstrate that the boundary reconstruction problem of a B-rep model is NP-hard. However, even with the existence of polynomial algorithms, building ideal boundary models still remains beyond the reach of current computing technology, because most geometries in solid modeling can not be represented exactly due to the precision limitation of the computer [30, 29]. In addition, pathological behaviors of geometric algorithms (particularly, geometric approximations) introduce significant computational errors. Together with round-off errors in numerical computations, such errors make topological decisions inconsistent, especially when geometric degeneracies occur. In boundary model representations, these errors leave gaps along edges and thus create inconsistencies between topological and geometric specification. One solution widely adopted by CAD/CAM practice is the use of tolerances. However, a tolerance often only represents accuracy of geometric computations. Moreover, semantics of geometric tolerancing and its influence on validity and topological properties of models have not been fully studied. Research efforts have been mainly directed to develop new arithmetic systems in 61 which numbers are representable in floating point environment and operations are closed. Essentially, these are approximation methods. Instead of exact geometries, approximations with certain guaranteed properties on numerical reliability and stability, are constructed. Typical examples are integer and rational arithmetic (viewed here as approximations of real arithmetic), and interval and lazy arithmetic. See [47, 24, 39, 40, 55, 56, 33, 34, 10, 3] for some detailed descriptions. As an efficient and powerful extension of traditional floating point representation, interval arithmetic and interval geometric representation not only increase numerical stability but also assist in achieving model validity by defining gap-free boundaries. Hu et al [33, 34] introduced a method for robust solid modeling using interval arithmetic, and developed a data structure and Boolean operations for manifold and nonmanifold interval boundary models. The required curve and surface intersection algorithms using interval arithmetic were presented in [32, 31]. However, topological issues involved in interval solid modeling were not studied in these papers [33, 34, 32, 31]. As an interval boundary model defines a family of infinitely many boundaries, maintaining topological invariance of such boundaries is, by no means, a trivial problem. This chapter addresses such topological issues. Although the results presented here are primarily useful in boundary model reconstruction, they are also relevant in Boolean operations and boundary evaluation of interval models. The chapter is organized as follows: Section 5.2 studies the topology of the union of a collection of boxes which covers the boundary of an ideal solid M. In particular, conditions on boxes are derived, so that the interval model constructed using such boxes defines an ideal solid that is homeomorphic to M. Section 5.3 explains how such a collection of boxes can be constructed using interval surface intersection algorithms. 5.2 Covering Manifolds with Boxes Throughout this chapter, a box b refers to a rectangular (closed) box in R 3 , whose edges are parallel to the axes. A box defines a region in R 3 , and can be represented by an interval vector. The size of a box is the maximum length of its edges. Operations 62 on boxes using rounded interval arithmetic [2] preserve enclosure, meaning that the computed boxes always contain exact boxes under the same operations. In this section, we present some results concerning the topology of a finite union of boxes. In particular, we shall be interested in the topology of a manifold when covered with boxes. The motivation behind this is our way of constructing interval models (see Section 5.3). We assume that the reader is familiar with the basic notions of topology [50]. Most of the terminology used here can be found in Chapter 3. Let B be a finite collection of boxes, and let A C R 3 . We define B = U{bjb E B} and AB - A U B. We begin with a general result. Let B be as above so that the following is satisfied: A. Let bi, bj E B. Whenever bi n bj # 0, then bij = bi n bj is a box. Then we have, Proposition 5.2.1 Let the collection B satisfy condition A. Then, B is a compact 3-manifold with boundary. Proof: Without loss of generality, we may assume that B is minimal in the sense that B 0 U{b b E B, b 0 3}, for any 3 E B. Now notice that B is a compact subset of R 3 , since it is the union of a finite number of compact boxes. Moreover, we see that UbiE{Int(bZ)} belongs to the interior of B. We first observe that the boundary of B, Bd(B) = B -Int(B), is non-empty since B is compact. Evidently, the boundary of B consists of pieces from the boundaries of boxes. In fact, the boundary of every box b contains a piece of Bd(B). For, if q E Bd(b) belongs to the interior of B, then q is in the interior of some box bj. Therefore, since B is minimal, not all points of Bd(b) are interior points of B. Let then p E Bd(B). Then, there exists a box b with p E Bd(b). If b is the only box that contains p, there is nothing to show. If p belongs to more than one elements of B, then condition A guarantees that p has a 3D neighborhood homeomorphic to a half space. Finally, notice that the boundary of B consists of pieces of planar surfaces. U 63 Recall from Chapter 3 that an ideal solid M is a (non-empty) connected compact subset of R 3 which is a 3-manifold with boundary OM. Moreover, OM consists of finitely many components, each of which is a subset of the union of finitely many almost smooth (AS) surfaces Ri. The following is an immediate application of the previous result. Corollary 5.2.1 In case where B is connected, then B is an ideal solid. Now let V C R 3 be a compact connected orientable 2-manifold without boundary, and B as above. Suppose that, in addition to condition A, B satisfies the following: B1. V c B, that is, B covers V, and B2. b n V 0 0, for every b E B. Recall that VB = V U B = B. It is easy to see that VB is path connected. Indeed, let u, v c VB. Then, u E b, and v E b2 , for some bl, b2 E B. Pick points ui c b, n V and v, E b2 n V. Since bi, b2 and V are (path) connected, there is a path in VB that joins u and v. Thus, the above corollary gives us: Corollary 5.2.2 For B and VB as above, VB is an ideal solid. Since V is connected and orientable, its complement has precisely two connected components, Vr, Vo; we may assume that V is interior to V, while VO lies in its exterior. An argument similar to the one used in the proof of Proposition 5.2.1 shows that Remark 5.2.1 VIP is an ideal solid. Evidently, the above construction can be applied to ideal solids as well. Indeed, if M is an ideal solid, and B satisfies conditions A, B1 and B2 when V is replaced by aM, then the above result shows that MB = M U B is an ideal solid. In that case we shall call MB the interval solid generated by M and B. Figure 5-1(c) shows a 2D example of such an MB. We shall see in the next section that such a solid can be constructed using interval surface intersection algorithms [32, 31]. 64 (a) ideal solid M (b) boxes B (c) interval solid MB Figure 5-1: An example of interval solid 65 Consider now S = V U V. Then, obviously, S is a compact connected 3-manifold whose boundary is precisely V, i.e. S is a solid. In the sequel, we shall show that under some generic conditions on B, S and Vil are homeomorphic. The conditions are the following (see Figure 5-2): C1. {Int(bz), bi E B} is a cover of V. C2. Each member b of B intersects V generically; in particular, b n V is a (closed) disk that separates b into two (closed) balls, BI and B-, and C3. Whenever b n bj 0, then bij = bi n bj is a box that satisfies C2, for bi, bj E B. V V Condition C3 Condition C2 Figure 5-2: 2D version of condition C2 and C3 Notice that the conditions C1 and C3 are similar in nature to B1 and A. Condition C2, on the other hand, says that every b intersects V nicely. Moreover, observe that it is reasonable to expect that there is such a cover B of V that satisfies the above conditions. To this end we will show that S is homeomorphic to V 3 . First we have: Lemma 5.2.3 If b E B, then S U b is homeomorphic to S. Proof: Consider the disk D = b n V. From C2 we see that D separates b into two balls B+ and B-. Since S, V are orientable and V is a compact 2-manifold without boundary sitting in R 3 , we may assume that B' is exterior to S while B- lies in its 66 interior. We may now find a homeomorphism satisfied: f (x) = x for x E0B1 g(x)= - f : Bb -+ b so that the following is Int(D). Finally, if g : S -+ S U b is defined by: (5.1) if xcS-Bx f(x) if x E Bb then, g is easily seen to be a homeomorphism. We call this process of placing b onto S, gluing b on S along the closed disk D =Vnb= S n b. On the other hand, we call the reverse process ungluing b from S U b. As a result of this process we get back the original set S. Let S be a finite collection of boxes of the form [xI, x 2 ] and let the half space Z = x [X 3 , x 4 ] x [0, X5 ], xj C R, {(x, y, z) z < 0}. Then, the proof of Proposition 5.2.1 indicates that Z8 is a connected 3-manifold with boundary. In fact, it is easy to see that Z- is homeomorphic to Z, and its boundary OZ' is homeomorphic to R 2 . This shows that when a box b is removed (unglued) from Z-, the topology of the resulting manifold remains unchanged outside a neighborhood N of b, and its topology inside Nb is still homeomorphic to the topology of Z8 n Nb. We are now in a position to show the following: Lemma 5.2.4 S is homeomorphic to VjB. Proof: The proof will be by induction on the number of elements of B. Lemma 5.2.3 provides the first step in the induction procedure. Let us then consider a subcollection B1 of B having more than one elements, and let Si = SUB 1 . Take an element b1 E B1. When b1 is removed (unglued) from S1, the topology of Si remains unchanged outside a neighborhood N1 of bi. By invoking the above discussion, we see that when b1 is removed (unglued) from S1, the topology of the resulting manifold remains the same inside N 1 . Thus, S U B 1 is homeomorphic to S U B 2 , where B2 = B1 - {b 1 }. By induction, that means that S is homeomorphic to S U B 1 . M Now we are ready to state the main result of this section. Let M be a compact connected 3-manifold with boundary, and let B be a finite collection of boxes in R 3 that satisfies conditions C1-C3, when V is replaced by OM. Then we have: 67 Theorem 5.2.5 Let M, B be as above. Recall that MB = M U B. Then, MB is a 3-manifold with boundary that is homeomorphic to M. In fact, M' is an ideal solid. Proof: Since M is compact, its boundary OM consists of finitely many components, say C 1 , C 2 , - -, Ck. If b is in B, notice from C2 that b intersects only one component of OM. Then, for 1 < i < k, define B to be the collection of boxes that intersect Ci. In that case Lemma 5.2.4 shows that M U Bi is homeomorphic to M, for each i. Finally, using induction on the number of components of OM, Lemma 5.2.4 and Remark 5.2.1, we complete the proof. N Corollary 5.2.6 If M is an ideal solid and B satisfies conditions C1 through C3, then M' and M - B are interval solids that are homeomorphic to M. Observe that in Corollary 5.2.6 condition C1 is very natural in order for M1 to be an interval solid. The fact that B has to satisfy C2 says that for every connected component Ci of OM, every member of Bi has to be in an open neighborhood Ni of Ci, and these Ni's are mutually disjoint. The latter puts a constraint on how big the boxes can be. In fact, we may confine each member of Bi to be in a tubular neighborhood T of C. Condition C3 puts some constraints on the structure of B. In the next section we shall show how such a collection can be constructed by using interval surface intersection (ISI) algorithms (e.g. [31]) with sufficiently tight resolution. We close this section with the following definition which is motivated by the above results: Definition 5.2.1 Let M be a solid, and B be a finite collection of boxes. We say that the interval solid MB is approximately equal to M if MB, as well as M - B, are homeomorphic to M and the size of each b G B is small. Figure 5-1 gives an example of an M' which is approximately equal to M. 5.3 Construction of Interval Solids The aim of this section is the construction of interval solids approximately equal to an ideal solid using methods of interval arithmetic. 68 The size of a box, in general, has little influence on approximate equality. The example in Figure 5-3(a) illustrates that no matter how small the sizes are, approximate equality may not be achievable; on the other hand, Figure 5-3(b) shows that the sizes could be fairly large while still maintaining approximate equality. As discussed in the previous section, it is the structure of boxes that determines the property of approximate equality. However, boxes constructed by evaluating surfaces and computing their intersections using interval arithmetic, have certain properties which guarantee that a sufficiently tight resolution E exists such that the conditions C1-C3 are all satisfied if the box sizes are no larger than E. (a) (b) Figure 5-3: Influence of box sizes on approximate equality Appendix B shows that boxes evaluated on a B-spline surface have centers on the exact surface and piecewise monotonous sizes. In the following, we illustrate that interval models constructed using an ISI algorithm have, in general, the property of approximate equality. In an interval model generated from an ideal solid M, we call boxes that cover only the interiors of ideal faces face boxes, i.e. face boxes do not intersect ideal edges and vertices. A face box can be constructed by evaluating an interval point in the interior of a region bounded by a collection of rectangles in the parameter domain of the underlying surface. These rectangles are solutions of surface intersections using an ISI algorithm, and their union contains the pre-images of ideal edges and vertices in the parameter domain. See Figure 5-4 for an example. As an intersection curve computed by an ISI algorithm is an ordered list of boxes, the intersection of two 69 such curves is a cluster of boxes whose union contains the exact intersection point. If this point happens to be an ideal vertex, the boxes in the cluster are called vertex boxes. Boxes between two clusters of vertex boxes on an intersection curve, are called edge boxes. Notice that an edge box only covers a piece of an ideal edge but none of ideal vertices. See also Figure 5-4 for examples of edge box and vertex box. Because boxes computed using an ISI algorithm always contain exact surface intersections, such a collection of boxes is guaranteed to cover the exact boundary OM so that C1 is satisfied. edge box ideal edge vertex box face box ideal vertex U Figure 5-4: Boxes of an interval model Now note that the topology of R" remains the same when one replaces "open balls" with "open boxes". Since OM is a 2-manifold without boundary, for each point p E OM, there exists a box b that contains p so that Int(b) n OM is an open disk, as well as b n &M is a closed disk. Let b be a face box, because its center is a point in OM, b n OM is a closed disk for sufficiently small box size. If b is an edge box, it is an intersection box of two surfaces. Assume that the exact solution for one intersection point is {u, v} and {s, t} in the parameter domains. Due to the use of rounded interval arithmetic, the interval solution is ([u, uu], [v', vu]) and ([si, su], [t', tu]) such that u C (ul, uu), v C (v', vu), s C (si, su) and t C (t', tu). Therefore, the interior of b also contains at least one point in OM. When the box size is sufficiently small, C2 is satisfied. For a vertex box, the same argument holds. 70 In general, C3 is satisfied. Exceptions happen when boxes intersect 1) at the positions of the global minimum self-distance; 2) due to the variation of box size. See Figure 5-5(a); 3) due to small geometric features. See Figure 5-5(b); 4) at a lower dimensional entity. At a given resolution, indeed, case 1 and 2 will be detected by an ISI algorithm as surface intersections. As the resolution increases, in both cases overlapping boxes will eventually become disjoint. For example, if the maximum box size is less than d/x/f, where d is the minimum self-distance, case 1 will never happen1 . Case 4 can be eliminated by slightly reducing or increasing the size of one box while maintaining its relations with other boxes. For case 3, we have the following remark: Remark 5.3.1 If bi n V = 0 in C3, then, Lemma 5.2.4 holds if there exists a subcollection Bk such that 1) Bk = U{b~b E Bk} is a closed ball satisfying C2; 2) Bk n bij is also a closed ball, and 3) Bk n bi and Bk n bj satisfy C3. This is because bi, bj and Bk can be replaced by closed balls satisfying C3. For example, in Figure 5-6, bi, bj and bk can be replace by b = bi - bkl, b' = bj - bkl and b'k = bk U bk2, where bkl and bk2 are two boxes satisfying the following conditons: (1) bij C bkl C bk2, and (2) bkl n V = 0, bk2 n V = 0. In the following, we study how to construct 2D boxes satisfying the conditions in Remark 5.3.1, and then extend the result to 3D. The following discussion serves as an explanation of the existence of such a box collection, rather than a computation method. Let bi, b2 be two boxes evaluated on the same B-spline curve C and (binb2 )nC = Denote the half-widths of a 2D box by (X, 0. Ey). See the example in Figure 5-7. Assume that Ey1 < Ey2, and ey of boxes between b1 and b2 varies monotonously. Observe that if the curve segment c'1 2 , where c1 , c2 are the centers, is above line 1 : y = cy2-(Ey1+Ey2) then, boxes covering cc 2 forms a closed ball satisfying the conditions in Remark 5.3.1. A sufficient condition for this to happen is that the minimum radius of curvature of C, 'This is because the circumscribed spheres of any two boxes do not intersect due to the minimum self-distance. 71 real intersection intersection due to width variation (a) (b) Figure 5-5: Exceptions to C3 72 bj bk2 bi jb - - bi - bk T V bj bi TF I - bk Figure 5-6: Illustration of Remark 5.3.1 73 R., is no less than the radius r of the circle which passes through c1 , c2 and intersects line I at point p with the condition that p is the intersection point with the larger x-coordinate, where p is the intersection point of line 1 and the right edge of b1 . See Figure 5-7(a). If p does not exist as shown in Figure 5-7(b), the circle should pass through c1 , c2 and tangent to line 1. Y IEx2 y2 C2 ( C.2, Cy2 ) , ) C1(O,0) _K' EyiI Vz + line I d xi x L-yl 1 - (a) y Ex2 Ey2 C2 (Cx2,Cy2) Ci(0, 0) Erx I, Exi y, line 1 (b) Figure 5-7: Construction of 2D boxes satisfying the conditions in Remark 5.3.1 Without loss of generality, assume that c1 is the origin. Then, r depends on the 74 position of c2 and the half-widths, i.e. r = V)(Cx2, 7Cy2,7 ExI, E, (5.2) Ex2, y2), with such that b1 n b2 Cx2 E [0, ExI + Ex2, Cy2 E [0, Ei + Ey2], 0. Let Et be the resolution in the parameter domain of curve C. The half-widths of boxes are bounded in [e , Eu] and computed using Eq. (B.9) in Appendix B with E = [E' , E&], 'Et. where the bounds can be The overall maximum radius is thus Rmax = max(V)(Cx2, Cy2, ExI,7 EY1i, Ex2, Ey2)),7 Cx2 E [0, 2Eu] , Cy2 E [0, 2,u]), ExI Ex2 C [E , E", Ey,1 Ey2 E [E , u".. (5.3) Thus, the conditions in Remark 5.3.1 will be satisfied if Rmax Rr,. (5.4) Extension of the above discussion to 3D is straightforward. Let bl, b2 be two boxes with centers c1 , c2 and half-widths (Exl, El, Ez), (Ex2, 8 y2, Ez2). Assume that Ez < Ez2 The minimum radius of curvature of the surface must be no less than the radius of a sphere which passes through c1 , c2 and intersects plane p z = Cz2 - (Ezi + &z2) with the condition that the intersection circle between the sphere and p is tangent to plane x= Exl and plane Y = 8 y1 and is located inside {(x, y)Ix < ExI, Y < Eyl}. See Figure 5-8. In general, the resolution is so small that Eq. (5.4) is always satisfied. 75 Z Y sphere intersection circle plane p Figure 5-8: Construction of 3D boxes satisfying the conditions in Remark 5.3.1 In summary, for a sufficiently tight resolution, boxes constructed using an ISI algorithm form an interval solid which is approximately equal to the exact ideal solid. 76 Chapter 6 Manifold Boundary Representation Model Rectification 6.1 Introduction CAD model rectification plays a crucial role in the success of CAD/CAM/CAE applications such as data exchange, analysis and manufacturing. In general, the problem has been approached by local identify-and-rectify methods, which do not guarantee global consistency and optimality. Based on previous chapters, in this chapter, we develop a boundary reconstruction methodology. The objective is to reconstruct a B-rep model from a given B-rep model represented in a certain format (e.g. STEP [65]) using interval arithmetic. The chapter is organized as follows: Section 6.2 discusses issues on surface intersection and box construction, needed for interval model construction. Section 6.3 presents our methodology for manifold B-rep model reconstruction. Section 6.4 gives an example which demonstrates some of the issues discussed in this thesis. 77 6.2 Surface Intersection and Box Construction 6.2.1 Surface intersection Surface intersection plays a central role in boundary evaluation. Most methods are approximation methods, i.e. approximate, rather than exact, solutions are computed for most cases. In this work, we use interval curve and surface intersection algorithms developed by Hu et al [32, 31]. These algorithms use the Interval Projected-Polyhedron (IPP) algorithm [60, 2] to solve nonlinear polynomial equation systems, and guarantee that the resulting solutions contain the exact intersection. See [32, 31] for the detailed description of these algorithms as applied to curve and surface intersection problems. However, general surface intersection algorithms could be extremely difficult, consuming tremendous computing resources in time and memory. Although the methods in [32, 31] are theoretically rigorous and promising, their practical use is often daunted by geometric degeneracies, notably tangential and higher order contacts. Due to the nature of the subdivision method used in the IPP algorithm, these algorithms could be very slow when two surfaces are tangential or nearly tangential along their intersection. Specialized methods for computing tangential intersection were also developed in [32, 31] which speed up the process. In principle, the tangential intersection algorithm should be executed first, and then, the transversal intersection algorithm should be applied to regions free of tangential intersection. If two surfaces are nearly tangential along their intersection, at certain level of computation accuracy, such tangential intersection may become transversal. In such cases, if the tangential surface intersection algorithm returns no solution, the transversal intersection algorithm still needs to be executed to compute the intersection, which will certainly be extremely slow. Such geometric degeneracies are ubiquitous in models. In fact, they are often present in models as they represent specific design intent. To facilitate surface intersection computation, some heuristic rules are used. It is observed that in B-rep models created by boundary evaluation of Constructive Solid Geometry (CSG) models, the underlying surfaces of two neighboring faces often match 78 exactly at their boundary curves (see the top figure in Figure 6-1); one surface may tangentially intersect the other at one of its boundary curves (see the bottom figure in Figure 6-1); in some cases, two underlying surfaces could be identical. Therefore, it is efficient to identify these situations first. If two surfaces match exactly along their boundary curves, the identical curve is regarded as the intersection. If a boundary curve of one surface overlaps another surface, the overlapping segment of that curve is taken as the intersection. Figure 6-1: Examples of special surface intersection cases 6.2.2 Control of box size In an interval model, boxes are constructed by evaluating points on surfaces using interval arithmetic. In general, parameter values are also intervals. They are either solutions of interval curve and surface intersection algorithms, or a set of interval points covering the interior of a face in the parameter domain of the underlying surface. Note that in order to cover the entire exact boundary of a solid, evaluation 79 using interval parameter values is necessary, for otherwise, it would be difficult to do so with a finite number of boxes. However, as it is always the case, interval evaluation introduces additional error propagation. For instance, suppose that an interval Bspline curve [57, 58] is uniformly parametrized. Intuitively, an interval box evaluated at an interval parameter value covering one-tenth of the parameter domain should, in general, cover a similar fraction of the curve. This is, however, frequently not true. For a function y = f (x1, x 2 , ... , Xn), its interval evaluation [Y'] = f ([X1i, is much larger than its range [Y] = { f(xI, x 2 , - -, Xn) for reasons rooted in interval arithmetic, see [49, 4]. I [X2 ], ... , [Xv]) xi E [Xi], 1 < i < n}, In this section, we give an explanation for such unusual interval growth, and also provide a formula to compute an accuracy so that the box size is of a given order. Let an interval Bezier curve [57] of degree d have control points [R]I = Ri + ho[I], where ho has a constant value h0 in all its three components, and its parameter domain be [t 0 , ti]. Then, from Eq.(B.17) in Appendix B, the x-component of the half-width of an evaluated point at [t] ho + t1 t + E[I] is in the order of = - to (h o + Rx) (6.1) where Rx is the average of the absolute values of the x-coordinates of Ri's. The formula for the y, z-components can be obtained by replacing Rx with RY, RZ, respectively. For a given order h of half-width, the required parameter resolution (t1 - to)(h - ho) 2d(ho + Rmax) where Rmax = ( max{RX, RY, Rz}. For an interval B6zier surface of degrees (dy, d,), we apply de Boor's algorithm in one direction first and then in the other. The xcomponent of the half-width is h ~ho + 2d+ wUe a- (ho + Rx) 2d me 1 - (6.3) vo where ~ means "in the order of", and [uo, u1] x [vo, v1] is the parameter domain. 80 Similar formulae hold for the y and z components of the half-width. Assuming that t -= , for a given order h of half-width, we have At = h 2(du + dv)(ho + Rmax) (6.4) From these equations, it is observed that the sizes of boxes depend on the coordinates and sizes of control points, as well as the sizes of parameter rectangles. Small parameter resolutions do not necessarily mean small box sizes. If the coordinate values of control points are extremely large compared to the size of a surface, the evaluated point could be as large as the surface itself, even though the parameter resolution is fairly small. Example 1 A Bezier curve of degree 1 has the following control points: {100, 0, 0}, {100.0001, 0, 0}. For the evaluated point at [t] = [0.5, 0.5001], its width in the x-direction is 0.04. If the size of the box is to be in order of 10-6, [t] should have width 2.49999875 x 10-1, and the evaluated width in the x-direction is 1.000000395 x 10-6, i.e. for this line segment, Eq.(6.1) is almost exact. Also, notice that from Eq.(6.1) and (6.3), the half-width can be reduced by translating the curve close to the origin so that the coordinate values of control points are small, and later moving the evaluated point back. Using this method, at [t] = [0.5, 0.5001], the width is 1.0001 x 10-8. And for the order of 106, [t]'s width is only 0.005. 6.2.3 Structure of intersection boxes Boxes constructed by evaluating surface intersection solutions are sometimes unordered (e.g. from direct application of the IPP algorithm [31]). Every box defines a volume in 3D space, and therefore, surface intersections have no regular meanings as either intersection curves or points. However, in order to reconstruct edges and vertices, such classification of intersections is necessary, and therefore, intersection boxes 81 must be put into a certain structure so that the topology of surface intersections can be identified. Notice that boxes are generated to contain the exact intersection. A box is called a curve box if it only contains points from an exact intersection curve, and is called a point box if it contains an exact intersection point. All curve boxes covering one exact intersection curve form a box curve, and all point boxes containing one exact intersection point form a box point. However, because the exact intersection is unknown, whether a box is a point box or a curve box cannot be determined using the above definitions. The following algorithm identifies point boxes and curve boxes by marching through boxes. A box could be a point box if it has more than two disjoint neighbors (in this case, a branch box). A box could be a curve box if it has exactly two disjoint neighbors or one neighbor (in this case, an end box of an intersection curve). Boxes constructed using interval surface intersection methods, in general, are extremely dense, meaning one box could have many neighboring boxes. Simply marching by neighborhood relations is unlikely to always lead to specific conclusions. As a cluster of boxes looks like one single point when viewed from far away, we select an arbitrary box as a seed, and merge with all its neighbors into a cluster. The collection of boxes then becomes a collection of clusters, each of which contains a subcollection of boxes. The identification of box curves and box points is then done on these clusters. Figure 6-2 is the flow chart of this algorithm. A cluster is a branch point if it has more than one unmarched neighboring clusters whose union has at least two components. Curves represented by clusters are then refined by sorting boxes in each cluster in order. This is done by finding where a box curve enters and where it leaves the enveloping box of a cluster. For a cluster in the middle of a box curve, because it has exactly two neighbors, the box curve enters the cluster where it intersects the last cluster, and leaves the cluster where it intersects the next cluster. See Figure 6-3 and the following description of the curve refinement algorithm. Here, {ci} is the ordered clusters, and vi is the enveloping box of ci. 1. Intersect vo and v, to obtain v. 82 clusters {c), curves (C), points (P) Y (c} empty? return (C},{P} N find a cluster c with two neighbors ci and c2 I c into the current rtput curve, and set ci as c I find the neighbors of c put c into the current curve, and 1 0 number of set the only put c into the current curve neighbors neighbor as c >1 t merge the neighbors N branch point? Y put c into (P) I I I N c2 marched? set c2 as c y put the current curve into I (C} I Figure 6-2: Flow chart of box curve and box point identification 83 F 2. Find the collection of boxes in co, each of which touches at least one face of vo and intersect v. 3. Set a target point p: (a) If boxes in the collection touch vo only on its left face along the x-direction, set px equal to the x-coordinate of the left face. (b) If boxes in the collection touch vo only on its right face along the xdirection, set px equal to the x-coordinate of the right face. (c) Do the same to the y, z-coordinates. (d) If there is no box touching either face in one direction, or if there are boxes touching both faces, the corresponding coordinate is set to be the average of the coordinates of the centers of all the boxes in the collection. 4. Find the box bend E cO which is closest to p and intersects v. 5. Find the box bstart C co which is farthest from p. 6. Start from bstart. Find among its neighbors the closest box to bend, and move onto that box until the process reaches bend. 7. For the remaining boxes in co, insert each box into the position next to its closest box already in the sorted box list. 8. Move to c1 . 9. Find bstart in ci using the same method of finding bend in the previous steps. 10. Find bend by intersecting v, and v2 and using the same method as before. 11. Sort boxes in ci in the same manner. 12. Repeat the process until reaching the last cluster. 13. Find bstart as before, and find bend in a similar way as finding bstart for the first cluster. Sort boxes in the cluster. 84 Ci bend target Ci+1 bstart target Ci-1 Figure 6-3: Refinement of box curves formed by clusters Box points also need to be refined, because they may have more boxes than what are needed due to additional cluster merging. Intuitively, the enveloping box of a box point can be shrunk in all directions. Whenever a box comes out of this shrinking box, and if it intersects only one edge, it is then added to that edge. Example 2 The intersection between two orthogonal cylindrical surfaces consists of two box points and four box curves. Figure 6-4 shows the four box curves with box ordering represented by the color spectrum. Figure 6-5 shows a close-up of the pre-image of a box point in the parameter domain. Point boxes are in red, and curve boxes in blue. Notice that overlapping boxes may touch at their boundaries or be aligned along one parameter direction due to the nature of the subdivision method used in solving nonlinear equation systems [60, 31, 2]. 6.2.4 Data reduction Boxes constructed by surface intersection and evaluation tend to be extremely dense. The number of boxes often exceeds what one would intuitively expect. One major reason is the nature of the subdivision method used in solving nonlinear polynomial equation systems. The IPP algorithm [60, 31, 2] first converts a set of m polynomial equations into an m + 1 dimensional Bezier surface, and then projects the control polygon onto m ordinate (2-dimensional) planes. On each plane, the IPP algorithm computes the intersection between the convex hull of the projected control points 85 7 _ Figure 6-4: Ordering of boxes in box curves of Example 2 Figure 6-5: Close-up of one box point in the parameter domain of Example 2 86 . . 11 - and the horizontal axis, and discards those parameter intervals which do not contain solutions. This process goes on until the remaining parameter intervals, which may contain the solutions, reach a given threshold. For surface intersection, this subdivision process proceeds on four ordinate planes independently [31]. Different combinations of solutions obtained on these planes are considered as different solutions to the problem. Another major reason is that for a given box size, the required parameter resolution for evaluation may be extremely small. For practical purposes, data reduction needs to be performed for memory efficiency. One method is to merge solutions in the parameter domains first, and then evaluate with an appropriate parameter resolution. As mentioned above, a specific solution of one parameter may appear many times in different solutions. In the parameter domain of one surface, any two parameter boxes are compared in one parameter direction first, and merged if they are almost identical in that direction. This may increase the box size in the other direction. Then, the same is done along the other parameter direction. For dense boxes due to tight parameter resolutions, notice that for any two neighboring parameter boxes, the distance between their centers is in the order of the parameter resolution. Because the center of a 2d parameter box is mapped to the center of the evaluated box, in the above case, the centers of the two 3d boxes are extremely close, and therefore, the boxes are almost identical. That is, although the box sizes are fairly large, the deviation of the centers is very small. Merging such boxes, therefore, only slightly increases box sizes. Other data reduction methods may be also developed based on interval curve approximation, Tuohy et al [62]. 6.3 6.3.1 Model Reconstruction Methodology Overview In Chapter 4, we argued that in order to achieve global consistency and optimality of both topology and geometry, CAD model rectification should be approached 87 as a boundary reconstruction problem. It has also been shown that the boundary reconstruction problem is NP-hard. Despite the theoretical difficulty of solving the problem, practical methods to solve the problem even in some sub-optimal way need to be developed, because the problem is important in modeling theory and practice. One approach to solving NP-hard problems is to improve straightforward exhaustive search. For optimization problems, often a less ambitious objective is sought. Instead of searching for a global optimal solution, polynomial algorithms are developed to search for a "relatively good" one, using some heuristic rules suitable for the problem at hand. Detailed description of dealing with NP-hard problems can be found in Garey and Johnson [25]. As boundary rectification is an engineering problem, the solution must faithfully reflect design intent carried in inaccurate and/or erroneous models. However, such intent is implicitly represented and thus it is frequently unclear if drastic errors exist. A valid model, even if it is the optimal solution, if it is far different from the given model in both geometry and topology, may be less reliable and desirable than the original erroneous model. This is simply because for the latter, the user may be fully aware of the existence of defects, while for the former, validity is assumed. Therefore, searching for the intended model should be within the neighborhood of the object described by the given model, and changes to the topological structure should be avoided as much as possible. Also, for some complex topological features, it may be better to resort to user assistance. A rectification log is also needed to record all changes, especially topological structure changes and geometric changes beyond given tolerances. The methodology proposed in the following sections consists of three main steps: 1) construction of a graph induced by surface intersections for each surface, 2) face reconstruction, and 3) shell reconstruction. The methodology follows very closely the proof of NP-hardness of the boundary reconstruction problem in Chapter 4. It mainly focuses on capturing miniature numerical gaps and fills them with appropriate boxes. 88 6.3.2 Intersection-induced graph Edges of a B-rep model are embedded on intersection curves of the underlying surfaces. On each of the surfaces, curves form a geometric embedding of a graph with their intersections as nodes and the curve segments as arcs. As discussed in Chapter 4, face boundaries must consist of arcs in this graph in order to achieve geometric consistency of all topological relations (incidence and adjacency) in which the face is involved. In the proposed boundary reconstruction method, an intersection curve is an ordered list of boxes. Therefore, the geometric embedding of an arc in the graph is a box curve, and that of a node is a (unordered) cluster of boxes. Whenever a new intersection curve is computed, the two graphs on the intersection surfaces need to be updated. The new curve is intersected with the geometries of all arcs and nodes in both graphs, and is subdivided into a list of box points and box curves, which are then inserted into both graphs to create new nodes and arcs. 6.3.3 Face reconstruction Let R be the underlying surface of face f0 in model M 0 , and Gf be the intersectioninduced graph. As in model creation, boundary reconstruction proceeds in a bottomup manner. An edge e" involved in a certain adjacency relation between fo and another face f'o must be embedded in the intersection curve C of R and R 1 . The reconstruction of e starts with its vertices vr, v0. The corresponding new vertices v', v' are two nodes in Gf. Each of these nodes must have at least one incident arc constructed from C, i.e. the new vertices are on the intersection curve. In addition, each selected node should be the closest to the original position of the corresponding old vertex among all such nodes to minimize the geometric change in boundary reconstruction. See Figure 6-6 for illustration, where the dotted lines are arcs of Gf. The reconstruction of eo is to find a path between the two selected nodes in Gf. Again, the selected arcs must be constructed from the intersection curve C. If there 89 . - - -- - 7- Figure 6-6: Reconstruction of a vertex exist multiple pathes, the one with the minimum deviation from the original geometry of e' should be selected. This often happens when C contains self-intersections or is closed, e.g. a circle. With the edge orientation given in e', it shall be clear which part of C belongs to an edge, unless the underlying curve of e' in M' is far different from C. New edge e" thus is oriented in the same way as e'. For a loop 10, new edges form a subgraph Ge in Gf, which may not be a simple closed curve. Though an arbitrary graph could be very complicated, the proposed method intends to resolve miniature features such as small dangling arcs and gaps. It first identifies two types of nodes in Ge: free node that has exactly one incident arc, and branch node that has more than two incident arcs. Dangling arcs are then identified by marching from a free node until another free node or a branch node is reached, and then trimmed away if the geometric change due to such actions is within a given tolerance. Large pieces of dangling arcs indicates the existence of gaps. Let v 1i, v 2 be two ends of a gap. The shortest path between v 1 , v 2 is then searched in G1 , where G, = Gf - (Ge - {v 1 , v2 }) 1 . See Figure 6-7 for illustration. Finding the shortest path between two nodes in a graph is a polynomial problem. Algorithms can be found in many textbooks on graph theory, such as [19]. Edges in the newly constructed loop 1" are oriented in the same way as their corresponding old edges are in 1'. Consistency can be verified by marching through these edges. 'Here, the difference between graph G(V, E) and its subgraph G1 (VI, E1 ) is another subgraph 90 (b) (a) (C) Figure 6-7: Gap closing in loop reconstruction A face may have more than one loops. Loops reconstructed individually need to be modified so that together they define a valid face boundary. The modification process includes eliminating intersections between loops, verifying relative locations of loops, and orienting loops consistently. To retain the design intent of the face topology, the resulting loops should also be homeomorphic to the original face topological structure in the strong sense (see Chapter 4), provided that the latter is a graph consisting of simple cycles sharing at most one common node pairwise. Any two loops share at most one common vertex. Assume two loops in and ln share more than two vertices. We show how to solve cases of two common vertices. Cases involving more than two common vertices may follow the same approach. Let v1 , v2 be two common vertices of lI and In. Let P be the shorter path between vI, v 2 in li, and P2 be that in li. Also assume that the corresponding original loops I' and 10 are topologically correct. The following is a brief description of the algorithm. Also see Figure 6-8. 1. If both i and i are inner loops, (a) If P is outside in, and P2 is outside i, i. If l and l do not have common vertices, A. Delete v1 and v2 and their incident arcs in ln, i.e. in <-in-{viv 2 }consisting of nodes V - VI and arcs connecting these nodes. 91 B. Fill the gap in graph Gf - I' - 12. C. If the gap can not be filled, try the same in I. ii. If I' and I' share one common vertex, A. Delete vi and its incident arcs in l, i.e. 1i <- 1 -{v1}. B. Fill the gap in graph Gf lI - - l. C. If the gap can not be filled, try the same in l, or by deleting v 2. iii. If lP and l' share one common edge, delete P 1 , P 2 and merge ln, l. (b) If P is) s inside in I, switch P and P2 and do the same as 2f is and insideP2 P2 is inside i12sw Step 1(a). (c) If P is inside 1i while P2 is outside i, 2. If one, say l, delete P 1 , P2 and merge In, In is the outer loop, (a) If in is inside ln, do the same as Step 1(a). (b) If one part of 1i is outside l1, delete P 1 , P2 and merge in and I. In Step 1(a) of the above algorithm, if in and ln can not be modified in accordance with the topological structure of i' and l, topological changes are then necessary. For example, if Step 1(a)i fails, we may try Step 1(a)ii by ignoring the topological structure. For two loops sharing an common edge, if the feature exists in the original topological structure, the two loops should be merged by trimming the edge; otherwise, the edge should be deleted from one of the loops and the induced hole needs to be closed as above. Whether a part or an entire loop lI is inside another loop lI can be verified by checking a box of lI which does not intersect lI. The ray casting algorithm should be applied to the pre-images in the parameter domain of the underlying surface. Let Rb be a horizontal or vertical ray from a box b. Compute the intersections between Rb and boxes in In. The intersections are intervals, representing coordinate values in the direction of the ray. Merge all intervals which intersect. The number of remaining intervals is then the number of intersections. 92 The same algorithm is also used to n n 112 . . V2 step i V1...... n 11 i Pi P2 ..... i n 12 step ii n ' V2 - 12 V2 step iii vi......... 11 Step 1(a) vi n P2. vi .... ... n :i Pi 12 No Pi V2 V2 Step 1(b) 1 i n: 12: P2 P1 P2 -p. ii Step 1(c),2(b) Figure 6-8: Loop modification 93 '12 verify the relative locations of the loops. All inner loops must be inside the outer loop, and no inner loop is inside another inner loop. The orientation of a loop can be determined by computing the rotation index [20] of its pre-image in the parameter domain. Select an arbitrary point c inside a loop. Let {ci} be centers of boxes in the loop. Then, the rotation index is 1 r = 21 1 L(x, c 2 - c), (6.5) where Z denotes the positive angle between two vectors, and x is the unit vector along a fixed axis, see Figure 6-9. This number should be close to ±1 if box sizes are small. A loop is positively oriented if r e 1, and is negatively oriented if r _ -1. The outer loop must be positively oriented, and all inner loops must be negatively oriented. Figure 6-9: Definition of the rotation index of a simple closed box curve 6.3.4 Shell reconstruction A shell consisting of faces reconstructed individually may have dangling patches, internal walls and holes, and may be inconsistently oriented. Similar to algorithms for STL model rectification, shell reconstruction identifies those edges shared by only one or more than two faces, and string them together to form simple closed curves. Such a simple closed curve may bounds a hole if each of its edges have exactly one 94 incident face, and bounds an internal wall if each of its edges has more than two incident faces. If it consists of two connected pieces, one having edges with one incident face and the other having edges with three incident faces, then, the closed curve bounds a piece of dangling patch. More complex situations similar to what were studied in Bohn et al [12] could happen. Heuristic rules could help in such situations, but user assistance is frequently needed in resolving certain ambiguities. Here, we only deal with the above mentioned three situations, and leave other cases to user resolution. Dangling patches with very small sizes shall be trimmed away first. The boundary of an internal wall actually bounds three connected pieces, each of which is an open shell. The one inside the shell formed by the other two is the internal wall and shall be deleted. Whether an open shell is inside a closed shell can be verified by a raycasting algorithm in a similar manner as in loop reconstruction. In the following, we present a method for filling holes using surface patches constructed from the underlying surfaces by surface intersections. Let {ej} be the edges in a hole boundary and already sorted in order. The method fills the hole progressively by attaching new patches to the boundary and computing the new hole boundary. This is a trialand-error process. It tests all possible combinations of patches until one is found to fill the hole. In the selection of patches, those with small sizes are preferable so as to minimize the geometric change. For an edge e in {e}, a patch shall be selected first if it is embedded on the same surface as the face sharing e. This patch can then be merged to the face, so that no new face is introduced and the change to the topological structure is minimized. See Figure 6-10 and the following description: 1. Start with eo. Find a patch of small size and incident to eo. Denote the new patch by fl. 2. Let ei be the current edge, vi be the common vertex of ei_ 1 and ej, and e' be the edge on fi' incident to vi. 3. Find a patch of small size and incident to ej and e. 95 4. If no such patches exist, go back to edge ei_ 1 and select a different patch as fj- 1. It may be necessary to search further back. 5. Repeat Step 2 to 4 until the process reaches eo again. 6. Update the hole boundary {e }. 7. If {ei} is not empty, repeat Step 1-6. initial hole boundary new hole boundary ei Figure 6-10: Hole filling in shell reconstruction Shells constructed individually may share vertices, edges and/or faces. Such features should be detected and eliminated. Similar actions to those of loop modification should be taken to achieve topological validity and retain design intent. For instance, if two shells share one common face and the face is in the original topological structure, then, it should be deleted and the two shells should be merged, because the face is very likely an internal wall left by improperly implemented regularized Boolean operations. However, if it is a face introduced to fill a hole, it should be trimmed away, together with all of its adjacent faces, and the induced hole must be closed. 6.4 Example The model shown in Figure 6-11 is one part of a shaver handle, and created using a commercial CAD system. The size of the model is roughly 0.04mxO.06mxO.14m. The underlying surfaces of the model consist of 16 integral and rational B-spline surfaces, 3 cylindrical surfaces and 5 planes. The global uncertainty measure is given by the 96 designer as 10- 6m. The model has V = 40 vertices, E = 62 edges, F = 24 faces, no inner loop, and one shell. The topological structure satisfies the sufficient conditions presented in Chapter 3. Therefore, from the Euler-Poincar6 formula V - E + F = 2(1 - G), we can deduce that the model has genus G = 0 and that it is homeomorphic to a sphere. Figure 6-11: Part of a shaver handle We convert this model into an interval solid model. Because edges in the original model are reasonably computed, initial conversion of each face is performed by growing the width of underlying curves of its edges by a given resolution. If such growth gives a valid face, the conversion of the face is finished, unless adjacency relations with neighboring faces are violated. For the latter cases, the reconstruction process using the proposed methodology is then performed. The experiment starts with the resolution 10- 6m, given in the original STEP file. Eight faces have edges not on their underlying surfaces. Figure 6-12 shows one face with 2 edges partially on the underlying surface and one edge not overlapping the surface at all. Further computation reveals that the original face becomes valid at the resolution 2 x 10-4m. Figure 6-13 shows the valid face boundary. Overall, the model becomes valid at the resolution 5 x 10- 4m 97 Figure 6-12: An invalid face with the resolution 10- 6m Figure 6-13: The face in Figure 6-12 becomes valid at the resolution 2 x 10-4m. 98 We now test whether it is possible to reconstruct an interval model at the given resolution 10- 6 m, i.e. when all the surfaces in the model become interval surfaces with width 10- 6 m. For the face in Figure 6-12, because its underlying surface, now an interval surface, does not intersect one of the surfaces on which its adjacent faces are embedded, no valid face boundary can be constructed from surface intersections. If we further grow the width of all the surfaces to 10~5 m, the face can then be reconstructed. The remaining seven invalid faces can be rectified at various resolutions, and an interval model can be constructed at the resolution 5 x 10- 5m. 99 Chapter 7 Conclusions and Recommendations 7.1 Conclusions CAD model validity has long been recognized as an important problem. Prior research work concentrated on theory and algorithms for creating valid models. This thesis, on the other hand, addresses model validity verification and defect rectification problems, i.e. validity and rectification of existing models. Analyzing validity of models cannot be done without precise understanding of model validity. On this aspect, we derived sufficient conditions on topological boundary entities of ideal B-rep models which guarantee model validity. Similar conditions have partially appeared in previous literature, or in a loose mathematical setting. We compiled a complete set of such conditions and proved their sufficiency in guaranteeing model validity. We first defined topological entities, vertex, edge, loop, face and shell, as well as other concepts such as loop and face orientations. In particular, the definition of face provides a more clear description of face topology. Then, sufficient conditions, which apply to a typical data structure of B-rep, were derived. It is guaranteed that if a representational entity satisfies the corresponding conditions and its lower dimensional entities are valid, then it defines a valid topological entity. Although these conditions may not directly lead to a computational method for model validity verification, their usefulness is evident in our approach to the model rectification problem. 100 Most of current model rectification techniques use local methods. A local method traverses through the representational entities of a model, identifies individual defects using certain conditions, and then rectifies them. It does not guarantee a global consistent and optimal solution. In this work, we propose a new rectify-by-reconstruction approach. Such a method uses the underlying surfaces of an erroneous model, and rebuilds a valid boundary which is topologically equivalent and geometrically closest to the object described by the original model. However, we have also shown that solving such a problem is NP-hard. This not only reveals the difficulty of the problem, but also provides constructive suggestions on algorithm development. As is standard practice in solving NP-hard problems, especially optimization problems, an approximation methodology was then developed. Instead of searching for the global optimal solution, the proposed method attempts to build a valid boundary in the neighborhood of the original model, and duplicates the topological structure as much as possible. Heuristic rules are used for clarifying topological ambiguities. As floating point representation in general leaves miniature gaps, we used interval geometric representation in boundary reconstruction. We further developed the concept of interval solid model introduced in Hu et al [33, 34]. In particular, we defined the concept of approximate equality relation between an interval solid model and its intended exact model, and proved sufficient conditions for approximate equality. We also explained how an interval solid model can be constructed using interval curve and surface intersection algorithms, so that it is approximately equal to its intended exact model. Techniques needed in interval model construction, such as box size control, data reduction and ordering boxes, were also developed 7.2 Recommendations Further research work should focus on developing practical rectification algorithms. Such development should involve extensive testing and analysis of real models, so that a set of more complete and sophisticated heuristic rules could be constructed. It is expected that such an algorithm would be time-consuming, especially when computing 101 surface intersections with high accuracy. Therefore, more efficient surface intersection methods are desirable. One promising direction is to use an interval marching method for the initial value problem, such as the one developed by Lohner [42], to compute surface intersection. Such a method is likely to be more efficient than current techniques and produce a smaller number of boxes enclosing the intersection. In addition, boxes would be ordered, which is advantageous in modeling and processing. Other than developing new more efficient intersection algorithms, improving conditions of input surfaces may also reduce running time. For instance, a NURBS surface may have many more control points than needed. When computing intersections, such a surface is subdivided into many B zier patches, and thus slows down the computation. Simplifying the complexity of such surfaces, therefore, is beneficial. Similarly, surfaces with small sizes, which often serve solely as gap-stitching patches and do not represent design intent, may be merged appropriately with adjacent surfaces. To reduce the number of boxes, a data reduction method with high compression power may be developed using interval curve approximation techniques as in [62]. In model representation methods and data exchange standards, tangential and higher order contact of two adjacent faces or edges may also be symbolically recorded and transmitted, because such information not only helps surface intersection computation, but also retains design intent. Additional topological information, such as the genus of each shell of a model, may also be included to enable the verification of the correctness of the topological structure of a model. Further research needs to be performed to extend the formulation found in this thesis relating to homeomorphism of objects to the more general concept of "ambient isotopy with compact support" as the basis for topological equivalence of two objects [5]. Such more general concept is motivated by the topological distinction between a torus and a knotted torus which, although homeomorphic, have different embeddings in 3D space [61]. Effort should also be directed towards applications of interval models. An interval model defines a family of models. Because most application programs operate on one single model, an interval model needs to be converted to a certain format acceptable to a specific application. However, as interval model representation contains more 102 information than conventional B-rep, it may be possible to develop robust conversion algorithms, so that output models could have certain desirable geometric and/or topological properties. From this point of view, interval model representation may serve as an internal representation. See Figure 7-1 for the structure of a proposed model rectification system. Possible downstream applications could include boundary triangulation for rendering, analysis and rapid prototyping, tool path generation for manufacturing, and model conversion for data exchange. Finally, longer term research on realizing exact B-rep models bounded by general arbitrary degree curves and surfaces with rational, algebraic and transcendental coefficients is also recommended. Such models if developed and adopted would be expected to be intrinsically valid and not require rectification. Computational power increase expected in state-of-the-art hardware may make the very complex necessary computations possible for practical applications. 103 Data exchange Conventional B-Rep models I PROPOSED I SYSTEM interval models Interval models Conventional B-Rep models with tolerance Model rendering, FEM analysis, rapid prototyping, Data exchange manufacturing Figure 7-1: Interval model as an internal model representation 104 Appendix A Short review of NP-completeness This appendix provides a brief introduction to the theory of NP-completeness. For details, see [25]. A decision problem is a problem whose answer is yes or no. A problem is said to belong to the class P if it can be solved by a polynomial time DTM program. DTM is the abbreviation for deterministic one-tape Turing machine, a simplified computing model. If the problem can be solved by a polynomial time NDTM program, it belongs to the class NP. NDTM, non-deterministic one-tape Turing machine, has the exact same structure as DTM, except that it has a guessing module. A NDTM program has two distinct stages: guessing and checking. For example, the traveling salesman problem is given as: Traveling salesman problem: Given a finite set of cities, a distance between each pair of cities, and a bound B, is there a tour of all the cities such that the total distance of the tour is no larger than B? A NDTM program first guesses a tour of all the cities, and then verifies in polynomial time if the length of this guessed tour is less than the given threshold. If at least one guessed tour is accepted, the answer to the problem is yes. Therefore, the traveling salesman problem is in class NP. It is observed that class(P)Cclass(NP). It is also an unproven conjecture that P#NP. For a problem in NP, there exists a polynomial p such that the problem can be solved by a deterministic algorithm having time complexity O(2P(n)), where n is the length of the input string. A decision problem H is NP-complete if lI ENP and, 105 for all other decision problems H' ENP, there is a polynomial transformation from H' to H. A polynomial transformation is a mapping f such that 1. There exists a polynomial DTM program which computes f. 2. For any instance x of the problem, x is accepted if and only if f(x) is accepted. Therefore, NP-complete problems are the "hardest" problems in NP. The NP-completeness proof of a decision problem consists of the following four steps: 1. Show that H ENP, i.e. H can be solved by a NDTM program. 2. Select a known NP-complete problem H'. 3. Construct a transformation 4. Prove that f is f from H' to H. a polynomial transformation. The NP-completeness can also be proven by restriction, that is, a problem is NPcomplete if it contains a known NP-complete problem as a special case. The concept of NP-hardness applies to problems outside class NP, e.g. search problems. Informally, a search problem is NP-hard if it is at least as hard as some NP-complete problem. For example, the search for the shortest tour of all the cites is as hard as the traveling salesman decision problem, because the solution to the search problem certainly answers the decision problem. 106 Appendix B Boxes on an interval B-spline surface Evaluation of a B-spline surface P(u, v) at a certain point (uo, vo) in the parameter domain using interval arithmetic creates a box guaranteed to containing P(uo, vo). In the following, we study the location and size of such boxes. For detailed description of interval arithmetic and interval B-splines, see [49, 57, 58]. An interval number [X] represents an interval [X1, Xu], where X' and XU are the lower and upper bounds. The center of [X] is X, w([X]) = Xu - X1. Thus, [X] = = (X + Xu), and the width is Xc + 1w([X])[I], where [I] = [-1, 1]. Let [D4] be the control points of a B-spline function, {ti} be the knot vector. Let [t] = t + E[I] be an interval parameter, where E is the half-width of [t]. The recursive formula of de Boor's algorithm is [Dq] = (1 - [a])[Dq_-1f + [al][D- 1], (B.1) where [D_-| = [D--1= D_ + h_-[I], (B.2) D 4 + hi-[I], (B.3) 107 with [Do] = [Di], h' = 'w([D ]), and [a ] = t -t ti+k-j - . ti (B.4) By plugging [t] in the formula, we have (1 - ce)Di-i [Dj] + a4D4- ((1 - a )hi-+ + cqh + | + |D_-1|) At±+ (hi-1 + hi_-i)Ati) [I], (B.5) where a = At = t - t(B.6) ~- ti(B6 Z ti+k-j ti+k-j - ti .(B.7) Therefore, [Df] can be represented as Di + hi [I] with Dq h (I - oz )D_~' =(1 - ac )hq_-q- a|Dj-1, (B.8) + (|Dj-'| + |Dj-±|)Atj + (hi-1 + hji_- 1 )At.(B.9) Denote the function value as [P([t])]. Then, the center of [t] maps to the center of [P([t])]. Note that Eq. (B.9) is a polynomial function of t in each span of the parameter domain, and therefore, the width of [P([t])] varies piecewise monotonously. If a knot ti E [t], [P([t])] = [P([t1 ])] U [P([t2])] where [t 1 ] = [t] n [ti_ 1 ,ti] and [t 2 ] = [t] n [tj, ti+1 ]. In summary, a box evaluated on a surface has its center on the exact surface. The size in each axis direction varies piecewise monotonously. Furthermore, let [P](t) be an interval Bezier function of order k. We now derive an approximate relation between E and the half-width h of an evaluated value at [t]. We assume that hi = ho for all i's, i.e. the half-width of control points is uniform. 108 For j 1, we have h' (1 = where Dy - a)ho + aho + (IDil + Di 1 )At + 2hoAt (B.10) ho + 2hoAt + 2DiAt, 0.5(IDjI + Di_ 1 1). Note that for Bezier functions, ac, AtP are the same for all i's and j's. Therefore, the subscript and superscript are dropped. Assume that the recursive relation of half-width is hq ~ ho + 2jhoAt + 2jDAt, where - (B.11) means "in the order of", and D is the average of IDiI's. We prove this by induction. Let Eq.(B.11) be true for j - 1, i.e. hj-I, hj~1 ~ ho + 2(j - 1)hoAt + 2(j - 1)DAt. (B.12) With - Dj_-1 =( (1 - a)Dj_- + Dj-, - a)Dj-2 + aDj_, (B.13) (B.14) and therefore, IDj-' +| Dj_-1 - (1 - a)(Dj-2 + Dj-2)|+ a(Dj-2 + D_~)~ 2D, (B.15) we have h ho + 2jhoAt + 2jDAt + O(,At 2 ) For At < 1, we prove Eq.(B.11). (B.16) Now, let the parameter domain be [to, ti] and 109 T = ti - to, the half-width of an evaluated value is h ~ ho + where d A:- 2dc (ho + D), T 1. 110 (B.17) Bibliography [1] 3D Systems, Inc. Stereolithography Interface Specification, June 1988. [2] S. L. Abrams, W. Cho, C.-Y. Hu, T. Maekawa, N. M. Patrikalakis, E. C. Sherbrooke, and X. Ye. Efficient and reliable methods for rounded interval arithmetic. Computer Aided Design, 30(8):657-665, 1998. [3] A. Agrawal. A General Approach to the Design of Robust Algorithms for Geometric Modeling. PhD thesis, Computer Science Department, University of Southern California, Los Angeles, CA, May 1995. [4] G. Alefeld and J. Herzberger. Introduction to Interval Computations. Academic Press, New York, 1983. [5] L.-E. of Andersson, topological T. J. form for Peters, and curvilinear N. F. geometric Stewart. objects. Equivalence pre-print, <http://www.eng2.uconn.edu/ tpeters/Peters.html>. [6] G. Barequet, C. A. Duncan, and S. Kumar. RSVP: A geometric toolkit for controlled repair of solid models. IEEE Transactionson Visualization and Computer Graphics, 4(2):162-177, 1998. [7] G. Barequet and S. Kumar. Repairing CAD models. In R. Yagel and H. Hagen, editors, Proceedings of IEEE Visualization Conference, pages 363-370, Phoenix, Arizona, 1997. [8] G. Barequet and M. Sharir. Filling gaps in the boundary of a polyhedron. Computer Aided Geometric Design, 12(2):207-229, March 1995. 111 [9] B. Baumgart. A polyhedron representation for computer vision. In Proceedings of National Computer Conference, pages 589-596, Montvale, NJ, 1975. AFIPS Press. [10] M. Benouamer, D. Michelucci, and B. Peroche. Error-free boundary evaluation based on a lazy rational arithmetic: A detailed implementation. Computer Aided Design, 26(6):403-415, June 1993. [11] N. L. Biggs and A. T. White. PermutationGroups and CombinatorialStructures. Cambridge University Press, Cambridge, England, 1979. [12] J. H. Bohn and M. J. Wozny. A topology-based approach for shell-closure. In P. R. Wilson, M. J. Wozny, and M. J. Pratt, editors, Geometric Modeling for Product Realization, pages 297-318. Elsevier Science Publishers BV, 1993. [13] C. Braid. Boundary Modeling. In L. Piegl, editor, Fundamental Development of Computer-Aided Geometric Modeling, pages 165-184. Academic Press, San Diego, CA, 1993. [14] I. C. Braid. Notes on a geometric modeller. CAD Group Document 101, Computer Laboratory, University of Cambridge, England, June 1979. [15] I. C. Braid, R. C. Hillyard, and I. A. Stroud. Stepwise construction of polyhedra in geometric modeling. In K. W. Brodlie, editor, Mathematical Methods in Computer Graphics and Design, pages 123-141, Academic Press, London, 1980. [16] S. B. Brunnermeier and S. A. Martin. the U.S. Automotive Supply Chain. Interoperability Cost Analysis of Final Report, RTI Project Number 7007-03, Research Triangle Institute, Research Triangle Park, NC, 1999. <http://www.rti.org/publications>. [17] N. Chiba, T. Yamanouchi, and T. Nishizeki. Linear algorithms for convex drawings of planar graphs. In J. A. Bondy and U. S. R. Murty, editors, Progress in Graph Theory, pages 153-173. Academic Press, Toronto, 1984. 112 [18] F. Croom. Basic Concepts of Algebraic Topology. Springer-Verlag, New York, 1978. [19] N. Deo. Graph Theory with Applications to Engineering and Computer Science. Prentice-Hall, Englewood Cliffs, NJ, 1974. [20] P. M. do Carmo. Differential Geometry of Curves and Surfaces. Prentice-Hall, Inc., Englewood Cliffs, New Jersey, 1976. [21] C. Eastman, J. Lividini, and D. Stoker. A database for designing large physical systems. In Proceedings of National Computer Conference, pages 603-611, Montvale, NJ, 1975. AFIPS Press. [22] C. Eastman and K. Weiler. Geometric modeling using Euler operators. In Proceedings of the First Annual Conference on Computer Graphics in CAD/CAM Systems, pages 248-259, May 1979. [23] P. Evensen and T. Dokken. Experiences using adjacency analysis for building topology structures. In W. Strasser and H.-P. Seidel, editors, Theory and Practice of Geometric Modeling, pages 419-432. Springer-Verlag, Berlin, 1989. [24] S. Fortune. Polyhedral modeling with multiprecision integer arithmetic. Computer Aided Design, 29(2):123-133, 1997. [25] M. R. Garey and D. S. Johnson. Computer and Intractability: A Guide to the Theory of NP- completeness. W. H. Freeman and Company, San Francisco, 1979. [26] V. Guillemin and A. Pollack. Differential Topology. Prentice-Hall, Englewood Cliffs, NJ, 1974. [27] B. Hamann and B. A. Jean. Interactive surface correction based on a local approximation scheme. Computer Aided Geometric Design, 13(4):351-368, June 1996. [28] F. Harary. Graph Theory. Addison-Wesley, Reading, MA, 1969. 113 [29] C. M. Hoffmann. Geometric and Solid Modeling: An Introduction. Morgan Kaufmann Publishers, Inc., San Mateo, California, 1989. [30] C. M. Hoffmann. The problems of accuracy and robustness in geometric computation. Computer, 22(3):31-41, March 1989. [31] C.-Y. Hu, T. Maekawa, N. M. Patrikalakis, and X. Ye. Robust interval algorithm for surface intersections. Computer Aided Design, 29(9):617-627, September 1997. [32] C.-Y. Hu, T. Maekawa, E. C. Sherbrooke, and N. M. Patrikalakis. Robust interval algorithm for curve intersections. Computer Aided Design, 28(6/7):495-506, June/July 1996. [33] C.-Y. Hu, N. M. Patrikalakis, and X. Ye. Robust interval solid modeling: Part I, Representations. Computer Aided Design, 28(10):807-817, October 1996. [34] C.-Y. Hu, N. M. Patrikalakis, and X. Ye. Robust interval solid modeling: Part II, Boundary evaluation. Computer Aided Design, 28(10):819-830, October 1996. [35] Y. Hu and T. Sun. Moving a B-spline surface to a curve - a trimmed surface matching algorithm. Computer Aided Design, 29(6):449-455, 1997. [36] International TechneGroup Inc. Case studies and articles. Inc. Case studies and articles. <http://www.cadfix.com/>. [37] International TechneGroup <http://www.cadiq.com/>. [38] Theorem Solution Inc. Product information. <http://www.theorem.co.uk/>. [39] J. Keyser, S. Krishnan, and D. Manocha. Efficient and accurate b-rep generation of low degree sculptured solids using exact arithmetic: I-representations. Computer Aided Geometric Design, 16(9):841-859, October 1999. 114 [40] J. Keyser, S. Krishnan, and D. Manocha. Efficient and accurate b-rep generation of low degree sculptured solids using exact arithmetic: II-computation. Computer Aided Geometric Design, 16(9):861-882, October 1999. [41] D. E. LaCourse. Handbook of Solid Modeling. McGraw-Hill Inc., New York, 1995. [42] R. Lohner. Enclosing the solutions of ordinary initial and boundary value problems. In Kaucher et al., editor, Computer Arithmetic, Scientific Computation and ProgrammingLanguages, pages 255-286. B. G. Teubner, Stuttgart, 1987. [43] I. Mikels and A. Dolenc. Some efficient procedures for correcting triangulated models. In Proceedings of Solid Freeform FabricationSymposium, pages 126-134. University of Texas at Austin, 1993. [44] M. Mintyli. A note on the modeling space of Euler operators. Computer Vision, Graphics and Image Processing, 26(1):45-60, 1984. [45] M. Mintyld. An Introduction to Solid Modeling. Computer Science Press, Rockville, Maryland, 1988. [46] M. Mdntyli and R. Sulonen. GWB - A solid modeller with Euler operators. IEEE Computer Graphics and Applications, 2(7):17-32, September 1982. [47] V. Milenkovic. Robust polygon modelling. Computer Aided Design, 25(9):546566, September 1993. [48] E. E. Moise. Geometric Topology in Dimensions 2 and 3. Springer-Verlag, New York, 1977. [49] R. E. Moore. Interval Analysis. Prentice-Hall, Englewood Cliffs, NJ, 1966. [50] J. R. Munkres. Topology: a First Course. Prentice-Hall, Englewood Cliffs, NJ, 1975. 115 [51] T. M. Murali and T. A. Funkhouser. Consistent solid and boundary representations from arbitrary polygonal data. In A. Van Dam, editor, Proceedings of 1997 Symposium on Interactive 3D Graphics,pages 155-162, Providence, Rhode Island, 1997. New York, ACM Press. [52] A. A. G. Requicha. Mathematical models of rigid solid objects. Technical Report 28, University of Rochester, November 1977. [53] A. A. G. Requicha. Representations of solid objects - theory, methods and systems. ACM Computing Surveys, 12(4):437-464, December 1980. [54] A. A. G. Requicha and H. B. Voelcker. Constructive Solid Geometry. Technical Report TM 25, Production Automation Project, University of Rochester, Rochester, NY, November 1977. [55] D. Salesin, J. Stolfi, and L. Guibas. Epsilon geometry: Building robust algorithms from imprecise calculations. In ACM Annual Symposium on Computational Geometry, pages 208-217, Saarbruecken, Germany, 1989. ACM Press. [56] D. H. Salesin. Epsilon geometry: Building robust algorithms from imprecise computations. PhD thesis, Stanford University, March 1991. [57] T. W. Sederberg and R. T. Farouki. Approximation by interval Bezier curves. IEEE Computer Graphics and Applications, 12(5):87-95, September 1992. [58] G. Shen and N. M. Patrikalakis. Numerical and geometric properties of interval B-splines. InternationalJournal of Shape Modeling, 4(1 and 2):35-62, March and June 1998. [59] X. Sheng and R. Meier. Generating topological structures for surface models. IEEE Computer Graphics and Applications, 15(6):35-41, November 1995. [60] E. C. Sherbrooke and N. M. Patrikalakis. Computation of the solutions of nonlinear polynomial systems. Computer Aided Geometric Design, 10(5):379-405, October 1993. 116 [61] N. F. Stewart. Sufficient condition for correct topological form in tolerance specification. Computer Aided Design, 25(1):39-48, 1993. [62] S. T. Tuohy, T. Maekawa, G. Shen, and N. M. Patrikalakis. Approximation of measured data with interval B-splines. Computer Aided Design, 29(11):791-799, November 1997. [63] S. T. Tuohy and N. M. Patrikalakis. Representation of geophysical maps with uncertainty. In N. M. Thalmann and D. Thalmann, editors, Communicating with Virtual Worlds, Proceedings of CG International '93, Lausanne, Switzerland, pages 179-192. Springer, Tokyo, June 1993. [64] S. T. Tuohy and N. M. Patrikalakis. Nonlinear data representation for ocean exploration and visualization. Journal of Visualization and Computer Animation, 7(3):125-139, July-September 1996. [65] U. S. Product Data Association. ANS US PRO/IPO-200-042-1994: Part 42 - Integrated Geometric Resources: Geometric and Topological Representation, 1994. [66] H. B. Voelcker and A. G. Requicha. Research in Solid Modeling at the University of Rochester: 1972-1987. In L. Piegl, editor, Fundamental Development of Computer-Aided Geometric Modeling, pages 203-254. Academic Press, San Diego, CA, 1993. [67] K. Weiler. Edge-based data structures for solid modeling in curved surface environments. IEEE Computer Graphics and Applications, 5(1):21-40, January 1985. 117