llll. PPPPPPP(((( approximate hierarchy rule hierarchical subdivision ... 5555ZZZZZ. `````` 88888 aaa. AA. AA aaa. 111. QQQQ. 0. 000TTT. 88888 aaa. AA. AA.
Computing the Visibility Map on a Hierarchical Triangle-Based Terrain Model Leila De Floriani Paola Magillo Dipartimento di Informatica e Scienze dell'Informazione Universita di Genova, Viale Benedetto XV, 3, 16132 Genova (Italy) Tel.: +39-10-3538033, Fax: +39-10-3538028 Email: fde o, magillog @ disi.unige.it
Abstract Hierarchical terrain models describe a topographic surface at dierent levels of detail, providing a multiresolution representation as well as a data compression mechanism. In this paper, we consider the problem of computing the visibility map, with respect to a xed viewpoint, on a hierarchical triangle-based terrain model. This problem presents two aspects: the extraction of a visibility map at a given resolution, and the update of such map as the resolution increases. In particular, we focus on the dynamical update of the visibility map when the terrain resolution is increased by expanding a subset of faces into ner triangular tesselations. We propose a randomized algorithm for maintaining the visibility map under insertions and deletions of triangles (terrain faces). The expected space complexity of the algorithm is equal to O(n2 ) (i.e., worst-case optimal), and the expected update time for both inserting and deleting a randomly selected triangle is equal to O(n log n).
1
Introduction
Terrain models have a fundamental importance in geographic information systems, since they provide a description of topography in a form which can be represented and manipulated by a computer. A topographic surface can be mathematically modeled by a continuous bivariate function z = (x; y) de ned over a domain D. Since the surface of a natural terrain is too irregular to be expressed in an analitic form, in practice Digital Terrain Models (DTMs) are used, which are based on a nite set of elevation values measured on a terrain. In such models, the domain of the terrain is partitioned into a collection of regions, and in each region the terrain surface is approximated by an analytic expression. Usually, linear or bilinear interpolating functions are used. The tesselation of the domain into rectangular or triangular patches induces a classi cation of DTMs into Regular Square Grids (RSGs) and Triangulated Irregular Networks (TINs). Despite of its semplicity, the regurarity of the grid structure makes RSGs not suitable to describe terrain features. The irregular structure of TINs, on the contrary, can adapt to topography, thus giving a suitable approximation of a surface by using only a restricted amount of data. While RSGs and TINs are already in use in commercial packages for terrain representation, organizing terrain representations at dierent levels of detail into a hierarchical structure is a recent research issue. Hierarchical Terrain Models (HTMs) provide a data compression mechanism as well as a variable resolution method for representing a surface according to an accuracy-based criterion. A hierarchical organization allows an easy implementation of searching and other geometric operations, such as nding surface intersection, or zooming when visualizing the surface. Moreover, it makes real-time simulation and visualization possible for those applications in which describing less important areas with fewer details is a relevant issue. HTMs are based on a recursive decomposition of the terrain domain into a sequence of increasingly ner tesselations. In early HTMs, such as quadtrees [29] and quaternary triangulations [19], the domain 1
decomposition follows a prede ned regular geometrical pattern, with rectangles or equilateral triangles as basic elements. In ternary triangulations [11], the domain decomposition is driven by a xed topological pattern with variable geometry. Recently, HTMs in which the domain decomposition is driven by accuracy and not by geometry have been de ned. Such models provide a multiresolution description of the terrain in a strict sense, by explicitly encoding a sequence of surface descriptions at increasing resolution. Adaptive hierarchical triangulations [31, 32] and hierarchical Delaunay triangulations [13] rely on these concepts, combining the advantages of TINs with those of a hierarchical description. Describing a terrain through visibility information has a variety of applications, such as geomorphology, navigation, terrain exploration. Problems which can be solved based on visibility are, for instance, the computation of the minimum number of observation points needed to view a region, the computation of paths with speci ed visibility characteristics (e.g., hidden paths with respect to a prede ned set of observers, scenic paths from which large portions of the terrain can be viewed), the computation of optimal locations for television transmitters [6, 9]. Visibility problems on a terrain can be classi ed, according to the type of visibility information they compute, into point visibility problems, which are based on the computation of intervisibilities between pairs of points, line visibility problems, which are related to the computation of lines with speci ed visibility characteristics (like the horizon), and region visibility problems, which are based on the computation of areas of a terrain visible from a viewpoint. Algorithms for visibility computation operate on polyhedral models, i.e., planar-faced digital models. Essentially, polyhedral models used in practice have triangular faces (see [15] for a survey). Region visibility problems on a terrain are related to the problem of computing the visible surfaces in a three-dimensional scene, which has been extensively studied in the literature [10, 16, 21, 23, 24, 27, 33, 34]. Some algorithms have been developed speci cally for polyhedral terrains [1, 12, 26, 27], since they exploit the special characteristics of the 3D scene. In this paper, we address the problem of computing region visibility information on an HTM, and, in particular, on triangle-based models, that we generally call hierarchical TINs [13, 14, 31, 32]. There are two basic problems that we have to solve when computing the visibility region of a point on an HTM: 1. Compute the visibility region of a viewpoint V on a representation of terrain at a speci c degree " of precision; such representation will be a digital model of the terrain obtained from the given hierarchical description. 2. Given the visibility region of a viewpoint V at the degree " of precision, compute the visibility region of V at a degree "0 of precision such that "0 "; in this case, we need an algorithm which dynamically updates a visibility region of a point while increasing the degree of precision of the underlying description. Our aim has been to design an on-line fully dynamic algorithm for computing the visibility region of a viewpoint V , i.e., an algorithm which allows modi cation of the visibility region of V , while adding and/or deleting faces from the underlying terrain model. A semidynamic algorithm, which can be applied to the computation of the visibility region of a point, has been developed by Boissonnat and Dobrindt [3]. The algorithm computes the lower envelope of a set of triangles in space by incremental insertion of a triangle at a time. The algorithm uses a data structure, called the enriched in uence graph, developed for the design of geometric algorithms [8, 4, 5]. This technique provides bounds for the expected time and space complexity when averaging on all possible permutations of the input data. Solving the region visibility problem corresponds to computing the visible portion of each face of the terrain representation which reduces to the lower envelope of a set of semidisjoint triangles in 3D-space. Thus, one contribution of this work led us to the developement of a fully dynamic algorithm for computing and maintaining the visibility map on a hierarchical triangulated terrain model. We prove that our algorithm has an an expected worst-case time complexity equal to O(n log n) for random insertions or deletions. The reminder of this paper is organized as follows. In Section 2, we introduce the de nition of mathematical, digital and hierarchical terrain models. In Section 3, we de ne the visibility map, a structure which encodes region visibility information on a digital terrain model, and discuss the relation between 2
such map and the lower envelope of triangles in space. In Section 4, we introduce the dynamic algorithm for envelope computation, and in Section 5 we present a randomized analysis of its time and space complexity. In Section 6, we discuss the region visibility computation problem on hierarchical triangulated terrain models, at dierent resolutions, and show the application of the algorithm described in Section 5 in this context.
2
Terrain Models
A natural terrain can be described by a continuous function z = (x; y), de ned over a connected subset D of the x 0 y plane, called the domain of the terrain. Thus, a Mathematical Terrain Model (MTM), that we simply call a terrain, can be de ned as a pair M (D; ). In practice, a nite set S of data points are
selected, whose elevation values are given by sampling, and a discrete terrain representation is built based on such points. The concept of digital terrain model relies on this idea, thus providing an approximation of a natural terrain. Let 6 be a plane subdivision of a domain D, having the set of points f(x; y) j (x; y; z ) 2 Sg as its set of vertices, and let 8 be a family of bivariate continuous functions such that
every function i 2 8 is de ned on a region fi 2 6, for every (x; y; z ) 2 S with (x; y) 2 fi , i(x; y) = z (where fi denotes the closure of region fi ), and for every pair of adjacent regions fi and fj , i(x; y) = j (x; y) for all (x; y) 2 fi \ fj . The pair D (6; 8) de nes a Digital Terrain Model (DTM). Since a plane subdivision with n vertices is composed of O(n) edges and regions, the spatial complexity of a DTM with n vertices is a linear function of n. Polyhedral Terrain Models (PTMs) are DTMs characterized by a domain subdivision consisting of a straight-line plane graph and by linear interpolating functions. Visibility algorithms developed in the computational geometry literature, including horizon computation algorithms, operate on polyhedral terrain models (that we simply call polyhedral terrains), since they exploit the planarity of their faces. A special class of PTMs is that formed by Triangulated Irregular Networks (TINs), which are characterized by a triangular subdivision of the domain. Building a TIN reduces to the problem of computing a triangulation of the domain with vertices at the projections of the data points on the x0y plane. Often, a Delaunay triangulation is used as domain subdivision for a TIN because of its good behaviour in numerical interpolation. Given a set S of points in the plane, a triangulation 6 of S is a Delaunay triangulation if and only if the circumcircle of each triangle t of 6 does not contain any point of S inside. As shown in [28], among all possible triangulations, the Delaunay triangulation is the one that minimizes the roughness of the approximating surface. In many practical cases, a large number of elevation values is available for a topographic surface, often distributed on a regular grid. Building a DTM based on the whole set of data points would be too expensive in terms of storage space. Thus, a subset of the original dataset is selected, and an approximate DTM is built on them. A mechanism is required for selecting a suitable such subset S 0 , on which the model can be de ned. We call approximate a model that does not interpolate exactly all points of data set S , but only a subset S 0 . The approximation error at a point P (x; y; z ) 2 S 0S 0 is evaluated as the dierence between the interpolated and the measured elevation value: E (P ) =j z 0 i (x; y) j, where i(x; y) is the interpolated elevation value at point P .
For each subset of the domain D0 D (e.g., an edge, a region), we de ne the error on D0 as the maximum error of points in S 0 S 0 whose vertical projection belongs to D0 : E (D0 ) = maxfE (P ) j P (x; y; z ) 2 S 0 S 0 and (x; y) 2 D0 g.
3
'
ll ll P 88 PPPPll 8 8 PPl 8
$
ll ? ? ? l((l , H ( ( P P 8 8 , 88 888 PPPPP PPPPlPl , 8 8 8 , Pl P ? (PP(P((ll ?880 80 PPPl 88 0 Pl Figure 1: A hierarchical subdivision. The quantity E (6) = E (D) provides a measure of the accuracy of the digital terrain model: the model is said to approximate a terrain at level " of precision if and only if E (6) ". Organizing terrain representations at dierent levels of detail into a hierarchical structure is fundamental to produce a multiresolution description. For several application it is useful to re ne the terrain representation only where necessary and describe less important areas with fewer details. For this purpose, hierarchical terrain models have been developed. The concept of hierarchical terrain model is based on that of hierarchical subdivision. Intuitively, given a subdivision 6, a region f of 6 can be seen as an individual entity and re ned into a subdivision 6f , whose domain covers f . The re nement of f is performed by adding new vertices either inside f or on its sides. Recursive application of the re nement process leads to a hierarchy of subdivisions. More formally, let Q = f60 ; . . . ; 6m g be a collection of subdivisions. Q satis es the hierarchy rule if, for every j > 0, 6j has more than one region, and there exists exactly one i < j such that the domain of 6j is a region of 6i. A hierarchical subdivision H is a tree in which the subdivisions of satisfying the hierarchy rule are linked together. The nodes of H are the subdivisions 60; . . . ; 6m , and 60 is the root. The parent of a node 6j with j < i is the unique node 6i containing the region f which is the domain of 6j . Arc (6i ; 6j ) is labeled with region f . An example of hierarchical subdivision is shown in Figure 1. Each subdivision in the hierarchy, except for the root, contains more than one region, and is the re nement of a region belonging to some other subdivision in the hierarchy. A region f which is re ned in the hierarchy (i.e., which appears as label of some edge) is called a macroregion. Conversely, a region that is not a macroregion is called simple. The total number of regions in a hierarchical subdivision is linear in the number of simple regions [13]. A Hierarchical Terrain Model (HTM) is built on a hierarchy of subdivisions by associating with each subdivision 6i in the hierarchy a DTM (6i ; 8i). In a hierarchical subdivision, the re nement of a macroregion can split one of its edges into a chain of edges through insertion of new vertices. Inconsistent re nement of an internal edge e may have undesirable eects on the terrain model supported by H, because the continuity of the surfaces on adjacent patches could not be guaranteed. Two subdivisions 6i and 6j are said to be adjacent along a straight-line segment l if their domains intersect only along l. 6i and 6j are matching along l if they are adjacent along l and their boundary edges along l are pairwise coincident (see Figure 2). In order to ensure that two adjacent macroregions are always re ned by inserting the same vertices on their common edge, and that this property is maintained throughout the whole hierarchy, the following rule, called matching rule, must be satis ed:
for each pair of subdivisions 6i ; 6j 2 Q, adjacent along a straight-line segment l, either 6i and 6j 4
rr r r
r rr
((((1 1A ( ( ( ( ( (@( 00TT 1 a1 A T11 11AAaaA1A @@00 @@ 11 11aa88aAA1Q AA @@11 18188 QQQAA
((((1 1A ( ( ( ( ` ( (@( 55ZZ````` 1 a1 A @@55 ZZZ 11 11AAaaA1A AA1 AA @@ 11 11aa8a 8 Q @@11 81188 QQQAA (a)
(b)
Figure 2: (a) Two matching subdivisions; (b) Two non-matching subdivisions.
11AA 11 AA A 1 33 JJ 3 3 JJ 3 J 33
-
t
02 0022 00 22 @ 2 @@2
(a)
-
t
(c)
t
t
t
012 001212 00 1122 @ 2 @@2
r
r
r
11AA 11AA 1AA 1 1 A (b) 8 8Q8833 - @JJ@@BBB8Q8Q33 JJB 3 JBB33 -
(d)
Figure 3: Dierent schemes of domain decomposition: (a) Quadtree; (b) Quaternary triangulation; (c) Ternary triangulation. (d) Hierarchical Triangulated Irregular Network. are matching along l, or one of them (let it be 6j ) is matching with a subdivision 6h in the subtree rooted at and 6i. for every simple region f of some subdivision 6i 2 Q, the edges of f are never re ned further in the hierarchy. According to the re nement criterion, existing HTMs (see Figure 3) can be classi ed into quadtree-based and hierarchical triangulated models. In quadtree-based models, such as quadtree [7, 30, 35] and quaternay triangulations [2, 19], the hierarchical decomposition of the domain follows a prede ned regular geometrical pattern, with rectangles and equilateral rectangles, respectively, as basic elements. Hierarchical triangulated models, on the contrary, are based on a non-geometrically xed hierarchical decomposition, in which faces are arbitrary triangles. Ternary triangulations [11, 25] represent a rst attempt to produce an adaptive model, using a xed topological pattern with variable geometry, but they have the disadvantage of producing long and thin triangles, and thus a less ecient approximation of the surface. Irregularly triangle-based models seem to provide a more appropriate and exible description of topographic surfaces than quadtree-based models, because they can adapt to the changes in the roughness of the terrain and include surface-speci c points and lines, which characterize the surface independently from the data sampling. Hierarchical Triangulated Irregular Networks (HTINs) are hierarchical terrain models based on a hierarchy of triangulations, in which the recursive re nement process is driven by an accuracy-based criterion. Given a sequence "0 ; . . . "m of decreasing tolerance values, each level in the hierarchy represents the terrain surface at one of the prede ned values "i . The top level corresponds to the coarsest description, satisfying the largest tolerance "0 . Passing from a level i to level i +1, every triangle t is expanded in a ner subdivision by iteratively inserting points in its interior or on its sides, until the accuracy "i+1 is reached. The number of points in the re nement of a triangle (and, thus, the number of triangles in its expansion) is not prede ned. The rule used for selecting and inserting points in a triangle characterizes the dierent types of HTINs. In all cases, the criterion is based on an error evaluation, and ensures the matching rule to be satis ed. models
5
In an Adaptive Hierarchical Triangulation [31, 32], the re nement of a triangle t is performed by iteratively applying a splitting rule, based on the evaluation of four maximun-error points, related to the interior and to the three edges of t. Among these four points, the ones corresponding to an error greater than "i+1 are selected for insertion. In Hierarchical Delaunay Triangulations (HDTs) [13, 14], each element of the hierarchical structure is a Delaunay-based TIN. Notice that, while the subdivision inside every macrotriangle is locally a Delaunay triangulation, the global expanded subdivision of the whole domain generally is not. The expansion of a triangle t is performed by an iterative application of the Delaunay selector, which, at each step, updates the current Delaunay triangulation by inserting the point having the maximum error. To ensure matching between adjacent triangulations, rst edge re nement is performed, and only when precision "i+1 has been reached for every edge, points inside the triangle are examined.
3
Region Visibility Problems on a Terrain
Given a mathematical terrain model M (D; f ), we call a candidate point any point P (x; y; z ) belonging to or above the terrain, i.e., such that (x; y) 2 D and z f (x; y). In what follows, V is a xed candidate point, which we call observation point, or viewpoint. Region visibility on a terrain is related to the computation of the portion of terrain visible from V . This information is encoded as a partition of the domain D in two disjoint subsets: the visible region, containing all points (x; y) 2 D such that (x; y; (x; y)) is visible from V , and its complementary in D, called the invisible region. On a DTM D (6; 8), region visibility can be encoded as a map, called a visibility map, which partitions the domain D into maximal connected regions, each of which is labeled as invisible, if it is a subset of the invisible region, or with a face i of the model, if it is contained in the visible region and in region fi . A characterization of the visibility map of a polyhedral terrain can be given in terms of the lower envelope of a set of polygons in space. The lower envelope of a set of polygons in 3D de nes a partition of the x 0 y plane into maximal connected regions, each of which is labeled with a polygon in such a way that, if a region R is labeled with a polygon p, then p is the polygon with minimum heigth over R. The visibility map of a polyhedral terrain with respect to a viewpoint V is equal to the lower envelope of the set of polygons obtained by associating with each region Ri 2 6 a heigth function z = di(x; y) that, for every point (x; y) 2 Ri, provides the distance of (x; y; i(x; y)) from V . We remark the dierence between a visibility map, that is a partition of the terrain domain, and the visible image of a scene (possibly a polyhedral terrain), computed by algorithms for hidden surface removal [24]: this latter structure is a partition of the view plane, de ned as the collection of the visible portion of each object of the scene projected on the view plane. When the viewpoint is located inside the given scene, as in our case, the viewplane can be rede ned as a sphere centered at the viewpoint. The visibility map and the visible image of a terrain represent two dierent ways of encoding the same information. The worst-case space complexity of both structures is equal to O(n2) for a PTM with n vertices (in other words, the general quadratic upper bound to HSR [16, 33] applies also to the special case of a polyhedral terrain). Since the visible image and the visibility map of a terrain can be obtained one from the other in linear time, an algorithm for HSR can be used to solve a region visibility problem. Algorithm speci cally developed for computing the visibility map on a PTM (in particular, on a TIN) are also available in the computational geometry literature. The approach proposed by De Floriani et al. [12] is speci c for acyclic TINs (i.e., TINs in which triangles can be sorted in a consistent way according to their distance from the viewpoint), like the ones based on a Delaunay triangulation of the domain. The algorithm consists of two distinct phases: a preliminar sorting of the triangles by distance from V and a subsequent computation of the visible portions of each triangle. The sorting phase is performed by incrementally building a star-shaped polygon around V , starting from the triangle containing the vertical projection of V and growing outwards. The visibility determination phase processes the triangles according to their distance order: a current horizon, related to the part of terrain already visited, is maintained, and, at each step, the visible portions of the current triangle are determined by projecting the current horizon onto it. Since this approach requires every triangle to be processed in the proper order, it cannot be applied when the con guration of the terrain faces varies after 6
a re nement in the surface representation. Another approach to region visibility computation on a triangulated terrain is based on the determination of the lower envelope of triangles. The lower envelope of n triangles in 3D [17] has a O(n2 (n)) worst-case space complexity (where denotes the functional inverse of the Ackermann function) in the general case, and O(n2 ) for triangles without proper intersections, as in the case of a triangulated terrain. The lower envelope of triangles can be computed either with a divide-and-conquer algorithm, with optimal time complexity [18], or with an incremental one. A randomized semidynamic incremental algorithm, described in [3], presents an expected insertion time for the i-th triangle equal to O(i(i) log i) in the general case, and O(i log i) for disjoint triangles.
4
A Dynamic Incremental Algorithm for Computing the Lower Envelope
The algorithm we describe in this Section is a dynamic extension of the on-line incremental algorithm proposed in [3], in the simpli ed hypotheses that triangles are pairwise disjoint. It works with the general framework, proposed in [5], for the design of randomized dynamic incremental algorithms. The algorithm uses a data structure, that increases the eciency of locating the portion of the current lower envelope that will be modi ed by the insertion of the new triangle, when averaging on the insertion order of triangles. In addition, the data structure can perform the deletion of a triangle from the current set without rebuilding the entire structure, but updating only the part aected by the deletion.
4.1 Preliminary De nitions We denote with Env(T ) the labeled plane subdivision representing the lower envelope of a set T of triangles (as previously remarked, such subdivision can be considered as an alternative representation of the visibility map for a triangulated terrain). The algorithm does not calculate Env(T ) directly, but it calculates another plane subdivision, that is a re nement of Env(T ), with the advantage of having convex regions with a number of edges bounded by a constant value. Such subdivision is called the trapezoidal decomposition induced on the x 0 y plane by Env(T ), and denoted T rap(T ). We classify the vertices of Env(T ) in primary junctions, corresponding to projected triangle vertices, and T-junctions, corresponding to points where an edge of a triangle disappears under another triangle. T rap(T ) is obtained from Env(T ) by drawing a vertical line through each primary junction, until another edge is encountered in both directions, and drawing in the same way a half-line through each T-junction, in opposite direction with respect to the orientation of the \T". An example of trapezoidal decomposition is shown in Figure 4. Each region of T rap(T ) is a trapezoid, possibly degenerating in a triangle. Every trapezoid has at most two adjacent trapezoids along a vertical edge, while it has an arbitrary number of adjacent trapezoids along a transversal edge. Only adjacency links along vertical edges of trapezoids are maintained. Since T rap(T ) is a re nement of Env(T ), we can label each trapezoid tp, contained in a region R of Env(T ), with the triangle tj labelling R. For each vertex of Env(T ), at most two new vertex are added in T rap(T ), thus, the spatial complexity of the two subdivisions is the same, i.e., O(n2 ) for n disjoint triangles. Env(T ) can be obtained from T rap(T ) by merging vertically adjacent trapezoids labeled with the same triangle. We say that a trapezoid tpi of T rap(T ) is de ned by at most ve triangles tj ; tleft ; tright ; tup ; tdown 2 T (see Figure 5), where:
tj = label(tpi ); tup is the triangle containing the edge whose projection contains the upper edge of trapezoid tpi;
simmetrically tdown . if the left edge of tpi is a vertical line drawn through a primary junction P , then tleft is the triangle containing the vertex whose projection is P ; if the left edge of tpi is a vertical line drawn through a 7
s
c sc
s
00AA A AA 000 AA A 0 A A0 AA 00 AA 0011 00 A0011 0 0 1 0 0 1A 0 0 1 0 0 1 AAA 0 S 1 @@@1 1 SS 11 S1
s
sc c c s c sc sc s
Figure 4: The trapezoidal decomposition induced by the upper envelope of four triangles: Primary junctions are marked in black; T-junctions in white. T-junction Q, then tleft is the triangle containing the edge which disappears under another triangle at Q; simmetrically tright . A triangle t is said to be in con ict with a labeled trapezoid tpi if and only if t properly intersects the unbounded prism, which is the intersection between the locus of points (x; y; z ) with (x; y) 2 tpi and the upper half-space de ned by the plane containing triangle tj = label(tpi ). A labeled trapezoid belongs to T rap(T ) if and only if it is de ned by triangles in T and is not in con ct with any triangle in T . A trapezoid cannot be in con ict with any of the triangles de ning it. In the incremental algorithm, we say that a trapezoid tp is created (killed) by a triangle t (and thus t is the creator (killer) of tp) if tp appears (disappears) in (from) the trapezoidal decomposition when t is inserted.
4.2 The Enriched IDAG Let t1; . . . ; tn be a sequence of triangles inserted and not deleted, sorted by insertion time (ti inserted after ti01). Set T = ft1 ; . . . ; tng is called the current set. The In uence Direct Acyclic Graph (IDAG) stores the current trapezoidal decomposition, plus the \history" of its construction. Each node of the IDAG corresponds to a labeled trapezoid that appeared in the decomposition at some stage (i.e, when the current set was a subset Tk = ft1; . . . ; tk g of T , with k n). The root of the IDAG is a conventional unbounded trapezoid, covering the whole plane and representing the trapezoidal decomposition induced by the empty set of triangles. At a generic step, the leaves correspond to the trapezoids of the current decomposition. When a triangle t is added, leaves in con ict with t become internal nodes, and new leaves, whose labeled trapezoids are de ned by t, are created as their children. A con icting leaf l, whose associated trapezoid is tp, becomes parent of all new nodes whose trapezoid properly intersects tp. Every child is contained into the union of its parents. The number of children for each node is bounded by a constant value (13 in the general case, 10 when triangles do not intersect). With respect to the on-line algorithm by Boissonnat and Dobrindt, in our algorithm the IDAG is 8
@@ 11@@ 8888B BB 8@8@88 BB 888 t @@11AA t 1 tp 11 11 AA 11 PA PPPPPP 11 t AA@ A@ PPPPPP1 1 tj AA P PPPP @@ 1 A AA t 88 8 8 AA 888 A88 up
r
left
right
r
down
Figure 5: The ve triangles de ning a trapezoid tp. enriched by adding to each node the list of all triangles of the current set con icting with it (con ict list). This auxiliary structure is not necessary for insertions, but it is useful for deletions. If a node is a leaf, then its con ict list is empty. Every node in con ict with a triangle t has at least one parent in con ict with the same triangle t.
4.3 Insertion The insertion algorithm we describe in the following is essentially the same algorithm by Boissonnat and Dobrindt, with the simpli cation due to the fact that we are dealing with semi-disjoint triangles, and with the extra work represented by the update of con ict lists. The insertion of a new triangle t in the structure built for the current set T consists of a location step and of an update step.
Location step
We locate all the trapezoids of the current decomposition T rap(T ) that are in con ict with t (see Figure 6(a)). This is done by an IDAG traversal which starts at the root, and visits recursively, for each node, all the children in con ict with t and not yet visited, and nally collects the visited leaves. While traversing the IDAG, we add t to the con ict list of each visited node (this is correct, since only trapezoids in con ict with t are traversed). Update step We compute the new trapezoidal decomposition in the part of plane covered and in the one not covered by triangle t. Note that the part covered by t may consist of several connected components. { Cutting substep Each trapezoid tp, in con ict with t, is subdivided by drawing vertical lines from the projected vertices of t lying inside tp, and from the possible intersection points between projected edges of t and boundary edges of tp (see Figure 6(b)). In this way, the portion of tp not covered by t (if any) is split in at most ve parts; and the one covered by t in at most four (see Figure 7). For each new trapezoid, a leafnode is created and linked to the killed node representing tpi (see Figure 8(a)). The number of children per node in this phase is bounded by 9. The nodes created at this step (temporary nodes) are possibly not properly de ned trapezoids, which must be merged with other temporary nodes, thus leading to convergent paths in the IDAG. { External merge substep We examine pairs of vertically adjacent new trapezoids tp1 , tp2, not covered by t, created as children of dierent nodes: if the vertical edge between tp1 and tp2 does not contain a vertex of 9
@ @@C 11@ @1@1 @@ D @@ G 1 @ F 1 @ @@ 11 t E @@ 1 q
B
A
q
C1
C2 C3
@ @@ 11@ @@ D 1 @ C C G 1@ F G 11 G@ @@ G @ @@ E1 D 1 E @@ 1E E D q
B
q
1
A
q
2
C1
q
a
1
A
q
a
4
3
D4
5
A
4
2
1
q
3
2
5
3
q
E4
3
q
2
a
1
a
2
1
q
I
@@ H 1@ @ 11 @ @ @ G@1 F @ G 1 @@ 1 E1 D @ 11 L M N E @@ E
q
2
5
C2
B
1
q
4
C1
q
q
2
3
(b)
@@ H 1@ @ 11 @ @ G 1@C C @ F @ G 1 @ 1G G @ @@ E1 D @ 1 E E @@ E 1 a
5
2
C2
B
4
D4
1
(a) q
a
q
(c)
2
3
I
q
(d) C1
C2
@ H @@ 11@ @@11 @@ G @ G 1 F @@ 1 E1 @@ O P 1 E @ 1 q
B
A
q
2
D4
a
1
q
a
2
1
q
I
q
(e) Figure 6: Insertion of a new triangle t in the trapezoidal decomposition: (a) decomposition before the insertion of t; (b) cutting step inside each trapezoid; (c) decomposition after external merge; (d) decomposition after internal merge; (e) nal updated decomposition.
10
D4
rr r r r rr
rr
88 8 8 800 8 8 88 00 422 00 3 2 2 0 2 2 2 1 22 ZZ ZZ 22
888 8 888 8 8 2 A3
AA
A4 1
5
(a)
(b)
Figure 7: Subdivision of the portion not covered by t of a trapezoid in ve subparts (a); and subdivision of the portion covered by t in four subparts (b). root 8 8 0 @P@HPHPHPP 88 0 H A B !C D E F Ga rootH@PHPP 8!081 13C C@AcS c @QHQaHaHa 8 ! 8 0 8 ! !801 13 C CAS@ @QHa 88 0 @ HHPP A B C D E F G !!88!800 11 1133 CC CCAAS@cS@cc @@QQHaHHaaa ! C C C C C 8080H10H10H101H@AA@ @AA@ 8 1 3 C C A S @ccG G G G 0 8 1 33 CC CC AA SS@@ cc 880000 0110 11 HAAH@@H AA @@ 1 8 D D D D E E E E E C C H D P I E E O G G 1
2
3
4
5
1
2
3
(a)
4
1
2
3
1
2
4
5
3
4
1
2
4
(b)
1
2
1
2
Figure 8: The IDAG update corresponding to Figure 6. (a) IDAG after subdivision inside each trapezoid; (b) Final updated IDAG (after merge operations).
{
the lower envelope, we merge tp1 and tp2 together (see Figure 6(c)). This can be done in linear time in the number of killed trapezoids. Internal merge substep
We remove the the edges of T rap(T ) covered by t. For each triangle edge l, supporting an edge of T rap(T ) (partially) covered by t, we nd all the killed trapezoids whose upper transversal edge is supported by l, and all the trapezoids whose lower transversal edge is supported by l. We can nd such upper and lower lists of trapezoids (called transversal lists), by using the vertical adjacency links between con icting trapezoids, in linear time in the number of con icting trapezoids. The matching between the upper and lower lists, related to the same triangle edge l, can be found in time O(k log k), where k is the number of involved triangle edges (k is linear in the number of con icting trapezoids). We traverse each pair of matching lists, and extend the vertical lines corresponding to side edges of adjacent trapezoids above and below the line (see Figure 6(d)). In this phase the number of children covered by t of a node may increase, but it is still bounded by 5 (since the portion covered by t of the triangle labelling a trapezoid has at most 6 edges, its interior is decomposed in at most 5 parts). Finally, we perform vertical merges between vertically adjacent pairs of resulting trapezoids labeled by t, as described in the external merging step (see Figure 6(e)). The nal IDAG is shown in Figure 8(b). We remark that every new node is created with an empty con ict list (and in fact it is a leaf).
11
4.4 Deletion The IDAG stores the history of the incremental construction of the trapezoidal decomposition. When a triangle t is deleted, such history must be rebuilt as if t had never been inserted. History is rebuilt only where necessary, i.e., locally to the part of the plane, called critical region, where triangle t appeared on the lower envelope. The deletion of a triangle t consists of a location step, and an update step, in which the triangles originally inserted after t are inserted again, locally to the critical region.
Location step
As in the insertion algorithm, we visit the IDAG, starting at the root. During the visit, we look for three dierent types of nodes: { Nodes that were leaves when t was inserted, and have been killed by its insertion (killed nodes). These nodes form the initial critical region. { Among the descendants of killed nodes, we collect all the nodes de ned by t. These nodes (removed nodes) must disappear in the updated envelope. { Nodes not de ned by t, but with at least one removed parent (unhooked nodes). These nodes remain in the updated envelope, but their history must be (partially) rebuilt. { Unremoved parents of removed nodes not created by s (those of removed nodes created by s are killed nodes). These nodes are outside the proper critical region, and their removed children were created by internal merges with trapezoids inside the critical region. These nodes will gain new children during the subsequent update step. While visiting the IDAG, we also delete t from the con ict list of traversed nodes. Nodes forming the critical region (critical nodes, which are, initially, killed nodes found in the IDAG visit) are stored in a priority queue, with the insertion time of the new killer (the older con icting triangle after t) as key. Unremoved parents of removed nodes, which we call co-critical nodes, are also stored in a priority queue, with the insertion time of their killer as key. Unhooked nodes are stored in a dictionary, indexed on the creator triangle, and on some element which dierentiates unambiguously trapezoids created by a single triangle (e.g., the center point of the trapezoid). Reinsertion step All the creators of removed nodes are inserted again, one by one, according to their original insertion time. The reinsertion of a triangle t0 is local to critical and co-critical nodes. { To nd the next triangle t0 to be reinserted and critical nodes in con ict with it, pick from the priority queue of critical nodes all the nodes with minimum key. { To nd co-critical nodes with killer = t0 , pick from the priority queue of co-critical nodes the nodes with key = t0 . After reiserting t0 , the critical region is updated by removing nodes in con ict with t0 (just processed) and adding new nodes created by t0, whose trapezoid is in con ict with t0. The reinsertion process of a triangle t0 presents the following dierences from the normal insertion process:
Cutting step is performed in the usual way in critical nodes. In co-critical nodes, only temporary children corresponding to removed children are recreated. Special attention must be devoted to merge operations, which occur at the boundary of the critical region, i.e., between a temporary child tp1 of a critical node and a temporary child tp2 of a non-critical node. In the original IDAG construction, tp2 was merged with a temporary child tp10 of a removed node, thus creating a removed or unhooked node tp3 (see Figure 9). If tp3 is a removed node, then the parent of tp2 is a co-critical node, tp2 is re-created, and the merge operation is performed in the usual way. If tp3 is unhooked, the operation is more complicated: 12
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 AA 1 t1 A A 1 A 1 1 1 1 1 1 1 1 11 11 11 11 11 11 1 11 111111 @11 11 1 1 t14 1 1 @1 @ 1 11 11 11 11 11 11 @ 1 1 1 1 1 1 1 H1 H 1 1 11 11 11 11 11 11 11 11 11H1H1H t2 11 1 11 11 11 11 11 11 11 11 11 11 11 11 H11 H1 1 1 1 1 1t31 1 1 1 1 1 1 1 11 11 H11 H 1 1H1 1 1 1 1 1 1 1 1 1 11 11 11 11 11 11H11H11 11 11 11 11 11 11 1 11111111111111
AA t AA A A @@ @@ t HHH 1 HHHt 11 H1 - B 1
4
2
(a)
(b)
Figure 9: Merge operations at the boundary of the critical region. (a) The critical (widely dotted) and cocritical (largely dotted) regions at the deletion of triangle t3 . (b) When triangle t4 is reinserted, temporary node A must be merged at its right side (in the original IDAG construction, this operation created an unhooked node), temporary node B must be merged at its left side (in the original IDAG construction, this operation created a removed node).
13
1SS 1 1 SS 11 S S
1SS 1 1 SS 1 S 1 SS 11 t S 1 11 A t 1 SS 1 1 1 1 1AA1 1 1 11 11 1 1 1 1 1 111111111111111 1 1 1 1 1 1 A1 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1A 11 1 1 1 1 1 1 1 111111111111111 1 1 1 H1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1H 11111111111 1 1 1 1 1 1H1H1 1 t1 1 1 111 1 1 1 1 1 1 1 1 1 1H1 H1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 1 H1 11111 111111111111111
t S 11 SS 1 1 A 1 S 1 A 6? 6?t 1 AAA B 1 A 11
1
1
3
3
2
111111111111111 (a)
(b)
Figure 10: Transversal merge operations, at the boundary of the critical region, for re-creating an unhooked node. (a) The critical region (dotted) at the deletion of triangle t2. (b) When triangle t3 is reinserted, temporary nodes A and B must be merged at their transversal top edge, thus re-creating an unhooked node.
14
{ If the merge operation occurs at a vertical edge, then the corresponding unhooked node tp3 is found as a child of the node adjacent to the parent of tp1 along the disappearing edge. { For merges occurring at transversal edges, there are no adjacency links to help us. During the location step, the unhooked children of a removed node tp, which are the result of a merge operation at a transversal edge of tp, are stored in a transversal list (if a child tp0 of tp results from a merge operation at the upper edge of tp, then tp0 is stored in the upper list related to the triangle edge supporting the upper edge of tp). Separated transversal lists are constructed for every creator triangle, and stored in a dictionary. During the reinsertion of a triangle r, the upper and lower lists of unhooked nodes created by r are merged with those of temporary nodes newly created by r. The unhooked node(s) tp3 which must replace each temporary node tp1 are thus found (see Figures 10and 11).
While nodes created during normal insertion have an empty con ict list, now the con ict list of a
new edge must be derived from those of its parents. Let tp be a trapezoid created during the reinsertion of t0 , and not in con ict with t. Instead of creating a new node for tp, the old node, already present among unhoocked nodes, is used. In this way, original arcs starting from and pointing to node tp are preserved.
5
Randomized Analysis of the Algorithm
In this Section, we present a randomized analysis of the complexity of the algorithm, in the worst case. We provide an extimation of the expected space complexity of the auxiliary structure (i.e., the enriched IDAG) necessary for encoding the algorithm, and we bound the expected time complexity for the insertion and for the deletion of a triangle. The analysis is based on the following hypotheses:
at each insertion step, the inserted triangle is randomly chosen, with equal probability, within the given data set; at each deletion step, the triangle selected to be removed is with the same probability, anyone of the triangles taking part in the current envelope. The worst case is considered for the output size, i.e., O(n2) for n semi-disjoint triangles.
Under these hypotheses, the expected IDAG size is O(n2); the expected time complexity for the insertion of the i-th triangle is O(i log i), i.e., O(n2 log n) for inserting all the triangles, and the expected time for a random deletion is O(n log n). Let T be a set of n non-intersecting triangles. We denote by IT the set of all labeled trapezoids de ned by triangles in T , and with ITj the set of all labeled trapezoids de ned by triangles in T and in con ict with exactly j triangles in T . The trapezoidal decomposition of T is set IT0 of the trapezoids de ned by triangles in T which are not in con ict with triangles in T . Let Tr be the set of the rst r triangles inserted by the algorithm. In the analysis, Tr is supposed to be a random sample of r triangles in T . We denote by IT j the set of trapezoids de ned by triangles in Tr and in con ict with j triangles in Tr , and by dj (r) be the size of set IT j . For simplicity, we assume that a trapezoid is de ned by exactly ve triangles, even if in practice it can be de ned by less than ve. We rst recall two important facts (see [5], theorem of moments). Given a random sample Tr of r elements in T , the rst fact bounds the sum, for all the trapezoids tp in T rap(Tr ), of the number of triangles in T 0 Tr that are in con ict with tp: r
r
(A)
XX
r n0r j prob(tp 2 T rap(Tr )) = O(d0( ) 2 r ) j tp2IT j
15
The second fact has a less intuitive meaning:
XX
r n0r 2 j (j 0 1)prob(tp 2 T rap(Tr )) = O(d0( )( )) r 2 j tp2IT j
(B )
5.1 Expected Space Complexity First, we show that the expected size of the IDAG, except con ict lists, is O(n2). Since the number of children per node is bounded by 10, the IDAG size, except con ict lists, depends linearly on the number of nodes. The expected number of nodes in the IDAG is given by
X prob(tp IDAG node) = X Xn prob(tp created at step r)
(1)
tp2IT
tp2IT r=1
A trapezoid tp is created at step r if and only if it appears in T rap(Tr ), and the last triangle added to Tr is one of the ve triangles de ning tp, which occurs with probability 5r . Expression (1) is thus equal to
X Xn 5 prob(tp 2 T rap(T )) = Xn 5 X prob(tp 2 T rap(T ))
(2)
r
tp2IT r=1 r
P
r
r=1 r tp2IT
Since tp2IT prob(tp 2 T rap(Tr )) is the same as the expected number d0(r) of trapezoids in T rap(Tr ) IT 0 , expression (2) reduces to Xn 5 d0(r) = O(Xn d0(r) ) (3) r r r
r=1
r=1
In the worst case, d (r) is equal to O(r ), thus leading to an O(n2) expected number of nodes (and arcs) in the IDAG. In order to evaluate the size of con ict lists, we anticipate a result that will be shown in Section 5.2, i.e, that the expected number of trapezoids visited during the location step for the insertion of the i-th triangle is equal to O(i), in the worst case. When a node is created, its con ict list is empty. Every time a triangle t is inserted, the con ict list size of nodes visited during the location step is increased by one. Thus the total size of the con ict lists, is given by the sum of the number of nodes visited P during the location step for all the triangles currently in the structure. In the worst case, this is equal to ni=1 O(i) = O(n2). Thus, the expected storage cost for the IDAG is not increased by the presence of con ict lists, and results equal to O(n2 ) for n triangles, that is worst-case optimal. 0
2
5.2 Analysis of the Insertion Algorithm In order to evaluate the expected time complexity of the insertion of the (n+1)-th randomly-selected triangle t, we compute the expected number v of IDAG nodes corresponding to the trapezoids in con ict with t. The insertion of s requires an expected time equal to O(v log(v)), where the logarithmic factor is due to the search for matching pairs of lists during the internal merge step. We show that the expected value of v is O(n) in the worst case. Thus, the (n+1)-th triangle is inserted in expected OP (n log n) time, and the whole algorithm computes the lower envelope of a set of n triangles in expected time ni=1 O(i log i) = O(n2 log n), in the worst case. Given a random sample Tr , if a trapezoid tp 2 IT j is in T rap(Tr ), the probability that tp is in con ict with t is equal to the probability that t is one of the j triangles con icting with tp, i.e., it is equal to n0j r . The expected number v of nodes in the IDAG in con ict with the (n +1)-th triangle t is given by r
(1)
X X Xn j tp2IT j r=1
n 5 prob(tp 2 T rap(T )) = X 5 X X j prob(tp 2 T rap(T )) r r n0r r r=1 r(n 0 r) j tp2IT
j
j
16
For fact (A), the previuos expression rewrites in (2)
Xn
X
n 1 r n0r 0 r d0 ( ) d( ) = 2 2 2 r=1 r(n 0 r) r r=1 r
5
In the worst case d0 ( r2 ) = O(r2), and thus expression (2) results in O(n).
5.3 Analysis of the Deletion Algorithm We bound the average cost of deletion of a triangle t, randomly selected in the current set T of triangles:
Removing old nodes takes a time proportional to the number m of removed nodes, plus the size lm
of their con ict lists. Creation of new nodes, except con ict lists, requires a time proportional to the number c of new nodes plus the number of their parents, i.e., of critical and co-critical nodes. Critical nodes are at the beginning the nodes killed by t, and in the following the newly created nodes. The cost for creating new nodes is thus O(v + f + c), where f is the number of unremoved parents of removed nodes, v is the number of nodes in con ict with t, and the number of nodes killed by t (initial critical nodes) is O(v). The con ict list of a new node is derived from those of its parents. The con ict list of a parent node is examined only a constant number of times, that is once for each of its children. The work for nding con ict lists is bounded by O(lc + lv ), where lc is the size of the con ict lists of new nodes, and lv the size of the con ict lists of initial critical nodes. Finding critical and co-critical nodes in con ict with reinserted triangles has a cost proportional to the number of elements stored in the corresponding priority queues, up to a logarithmic factor. The priority queue of critical nodes, storing nodes killed by s and new nodes, has a worst-case size of O(v + c). Unremoved parents of removed nodes, stored in the priority queue are f . The number of nodes in the dictionary of unhoocked nodes is bounded by O(m), where the number of unhoocked nodes is O(m) because every removed node has a bounded number of children. Thus, access operations on such dictionary cost O(m log m). Building transversal lists of unhooked nodes has a cost linear in the number of transversal edges of removed nodes and on the number of unhooked nodes, both O(m). Transversal merge step has thus a O(m) log(m)) time complexity.
We have already bounded v with O(n). We will show that the expected worst case value of m, f and c is O(n), and that of the other terms is O(n log n). Thus, the deletion of a triangle is performed in expected O(n log n) time, in the worst case, when the structure contains n triangles. In order to bound the number m of removed nodes, we observe that a node is removed by t if it is in the IDAG and t is one of its three de ning triangles, that is with probability n5 . X prob(tp IDAG node) 5 (1) n
tp2IT
For the result found about the number of IDAG nodes, that is equal to (2)
O(
n d0(r) 1X )
n r=1 r
which is O(n), in the worst case. 17
We suppose that the removed triangle t was the k-th inserted triangle. A node is new if it is created as a leaf at some step r > k and it is in con ict with s. For a node in IT j and in T rap(Tr ), the con ict with t happens with probability n0jr+1 . The number c of newly created nodes is so
X X Xn
(1)
prob(tp created at step r)
j tp2IT j r=k+1 n 5
XX X
j tp2IT j r=k+1 r
prob(tp 2 T rap(Tr ))
From fact (A), the previous expression is equal to
Xn
j = n0r+1
j n0r+1
X
n 1 r n0r 0 r d ( ) = O( d0( )) 2 ( + 1) 2 2 r n r r r 0 r=k+1 r=k+1
(2)
5
When we take the average on k, that is a number between 1 and n with probalility n1 , we obtain O( n1 d0 ( n2 )), that, in the worst case, is O(n). The size lc of con ict lists of the new nodes can be bounded by observing that the con ict list of a node in IT j \ T rap(Tr ) contains j 0 1 elements (except t):
X X Xn
(1)
prob(tp created at step r)
j tp2IT j r=k+1 n 5
XX X
j tp2IT j r=k+1 r
prob(tp 2 T rap(Tr ))
For fact (B), that is equal to
Xn
j (j 0 1) = n0r+1
j (j 0 1) n0r+1
Xn
n0r 0 r d ( )) ( n 0r r )2 d0 ( 2r ) = O( 3 + 1 2 r n r 0 r=k+1 r=k+1 r P Then, we take the average on k, and obtain ni=1 i12 d0( 2i )), that, in the worst case, is equal to O(n). The total size lm of the con ict lists of removed nodes is X X prob(tp IDAG node) j 5 = X X Xn prob(tp 2 T rap(T )) j 5 (1)
(2)
5
1
n
j tp2IT j
For fact (A), this is equal to
j tp2IT j r=k+1
r
n
n 1 r 5 X 5 d0 ( r ) n 0 r = O ( X d0( )) 2 n r r 2 r 2 r=k+1 r
(2)
In the worst case, this is O(n). We now bound the size lv of the con ict lists of initial critical nodes, i.e., killed nodes. Again suppose t was the k-th inserted triangle. A node killed by t is a leaf node in T rap(Tk01) in con ict with t. A trapezoid in IT j \ T rap(Tk01) is in con ict with t with probability n0jr+1 , and its con ict list contains j 0 1 elements (except t). The size of con ict lists of the nodes killed by t is (1)
XX
j tp2IT j
For fact (B), that is equal to (2)
O(
prob(tp 2 T rap(Tk01))
j (j 0 1) n0k+1
k n0k+1 2 n0k k d0 ( ) ( O( 2 d0( )) ) ) = n0k+1 2 k k 2
1
18
Taking the average on k, we obtain O(n) in the worst case. Finally, we evaluate the number f of parents of removed nodes (co-critical nodes): (1)
XX
j tp2IT j
XX
prob(tp IDAG node) prob(a child of tp de ned by r) =
5 = O( 1 X X prob(tp IDAG node) n n j tp2I j tp2IT T P P Since j tp2IT prob(tp IDAG node) is the number of IDAG nodes, the previous expression is O(n) in the worst case. j
prob(tp IDAG node) 10
j
j
6
Computing the Visibility map on a Hierarchical Terrain
A hierarchical terrain model does not supply an explicit representation of the terrain surface. Thus, an application needs to extract, from the multilevel representation encoded in a hierarchical terrain model, information related to the terrain surface at a certain level " of precision. The tolerance value " may vary though the terrain domain (e.g., a detailed representation may be required only in a speci c area), and may be not constant in time (since the area of interest may vary in time). In this Section, we discuss the computation of the visibility map, at a given resolution ", and the update of such map when " changes. In our exposition, we consider a special class of HTMs, formed by hierarchical TINs, de ned in Section 2. However, an analogous approach could also be applied to any hierarchical terrain model from which the representation of the surface at a certain degree of resolution can be extracted in the form of a triangulated PTM, such as a ternary triangulation or a restricted quadtree. A restricted quadtree is a quadtree in which the terrain representation at the higher precision level turns out to be a PTM with triangular faces. The planarity of the faces is obtained by splitting every square cell in four right triangles through its two diagonals, while matching between adjacent patches is ensured by imposing the constraint that two adjacent regions must not dier by more than one level of re nement. Two dierent approaches can be used to compute the visibility map at level " on a hierarchical TIN. A rst method consists of extracting from the hierachical structure a terrain model, representing the surface at the requested level of precision, then apply an algorithm for computing a visibility map to such expanded model. An alternative method consists of extracting from the hierarchy just the triangles at level " of precision, without the explicit construction of a model. Dynamically maintaining the visibility map under deletion and insertions of faces, instead of recomputing it each time the precision of the terrain representation changes, is convenient if the modi cation in the terrain involves a small number of faces, compared with the total terrain size. This happens, for instance, when, starting from an initial coarse representation, the re nement of a restricted area is required.
6.1 Extracting an Expanded Terrain Model from its Hierarchical Representation Given a tolerance value ", a terrain model, representing the terrain surface at a level " of precision, can be extracted from a hierarchical TIN through a traversal of the tree representing its hierarchical structure [14]. The idea is to start from the root, and expand recursively every macrotriangle t, in which the error exceedes ", by the subdivision that re nes it, until the precision " is reached for every triangle. If " is not one of the tolerance values "0 ; . . . ; "m , corresponding to the levels of the hierarchical model, then additional work is necessary for the elimination of vertical gaps between triangles, in order to ensure the continuity of the surface described by the extracted model. Suppose that " fall between two precision levels "i and "i+1 . Let t1 and t2 be two adjacent triangles at level i, and let e denote the common edge of t1 and t2 . If the error on triangle t1 is less than " and the error on t2 it is greater than ", we should re ne t2 and not t1. 19
0CC 0 0 C 0 C00@@@ 0 0 CC t @ 0 t 00 01 1 1 1 C 1 1 1 1 1 @1 0 1 1 1 1 C1C 1 1 1 1 1 0Q 1 111111111 QQ 1 1 1 1 1C 1 1 1 1 1 QQ 11 11 11 11 11 CC11 11 11 11 11 QQA11 11 B11 11 11C 11C 11 11 11 11 HHHQQ CC 1 HHQHQQ C 1 HHQC 11 H1 t HH
0CC 0 0 C 0 C00@@@ 0 CC t @ t 00 @ 00 B B CC 0 0 BB 0Q P Q C 0 QQ CC 0 t B QQ C QQ C HHHQQ CC 1 HHQHQQ C 11 HHQC 1 t HH H1 4
4
1
3
1
2
2
(a)
(b)
Figure 11: Transversal merges when reinserting triangle t4 (after the deletion of t3 ). The critic nodes in con ict with t4 are dotted. The upper transversal list, related to lower edge of t1 , is formed by unhooked nodes P and Q, while the lower list is formed by newly created nodes A and B . The lower transversal list, related to upper edge of t2 , is formed by unhooked nodes P and Q, while the upper list is formed by newly created nodes B and C . Thus, temporary node A is replaced by unhooked P , C by Q and B is split between the two unhooked nodes P and Q.
20
11 XXXXXXX XX" 11 "2 1H`H```` """ 22 HH `"@ HHH@ 22 H@H@22 0XXXXXXXX 0 X 0XXX Q XXXXQQ 00 XXQ0 Figure 12: The vertical gap at an edge which is re ned in only one of its adjacent triangles.
@BHHHt 8t 88008@ t BB@@ HH8 0H -@@ 8t 88822@ BB AA11-1@@ 88H8HHHH0@0AP8PPP202 -00@@@ BB11HHHP0@P0@PP@00@RHHHAA08882200"0""" ``````AA02"" t t 1
3
4
6
t5
2
7
Figure 13: A case of re nement of a triangle which causes the expansion of a chain of adjacent triangles: the error is greater than " on t1, less than " on t2 ; . . . ; t7. But, if the expansion of t2 modi es edge e by inserting new points on it, this would lead to a vertical gap between the two terrain patches over t1 and t2 in the extracted TIN (see Figure 12). In order to avoid this undesiderable fact, we also expand every triangle t, such that some of its edges is re ned in the expansion of an adjacent triangle t0 , even if the error on t satis es the tolerance ". The time complexity of the extraction algorithm is proportional to the number of visited triangles, which is linear in the number of triangles in the extracted TIN [13]. One of the problems, in this approach is that the expansion of one triangle may cause the unnecessary expansion of an arbitrary number of other triangles (see Figure 13). It has been experimentally found that, if "i < " < "i+1 , the set of triangles in the extracted expanded model at level " are almost the set of triangles at level "i+1 , even if " is very close to "i [13, 14]. For this reason, it is not easy to obtain an expanded model in which only an area of interest is detailed. An alternative direct approach for computing the visibility map on a hierarchical TIN is possible if we do not need to represent the terrain at level ", but only to calculate its visibility map as a partition of the domain. In this case, it is not important that the extracted triangles belong to a surface with vertical discontinuities. Thus, we extract triangles at level " of precision from the hierarchical model by a visit of the hierarchy, starting from the root, which expands only those triangles in which the error exceedes the xed tolerance value. The method produces a smaller number of re nements than the real extraction of a terrain model at level " of precision, thus resulting in a smaller number of triangles. In addition, it is not necessary to compute a subdivision with all the adjacency relations between entities, but only to collect a list of triangles. As soon as the triangles at level " are detected, they can be passed to the incremental algorithm of Section 4. Alternatively, they can be collected in a list which, at the end of the extraction process, will be given as input to one of the static algorithms proposed in the literature (see Section 3).
21
6.2 Dynamic Maintenance of the Visibility Map The second aspect of visibility computation on a hierarchical terrain is related to the update of the current visibility map after the re nement of the terrain representation in a portion of the domain. We denote with T1 the set of triangles used for the computation of the old map, and T2 the set of triangles to be used in that of the new map. The new visibility map can be determined in two dierent ways. The classic approach is to compute the new visibility map by scratch, starting from triangle set T2, with a complexity of O((n2)2 ), if n2 is the cardinality of T2 , and the optimal algorithm by Edelesbrunner, Guibas and Sharir [18] for computing the lower envelope is used. Alternatively, we can perform an update on the old visibility map, using the dynamic algorithm presented in Section 4, by removing the triangles in T1 0 T2 and inserting the extra triangles in T2 0 T1. A pseudocode description of this approach is shown below. The procedures for inserting and removing a given triangle in the dynamic lower envelope algorithm are denoted by INSERT TRIANGLE and REMOVE TRIANGLE, respectively. Algorithm UPDATE LOWER ENVELOPE input
H: hierarchical TIN; T1, T2: set of triangles; E : lower envelope; f in input, E = Env(T1 ); in output, E = Env(T2 ) g "old : real f old precision level g "new : real f new precision level ("new "old ) g
begin for every do
triangle t 2 T1 0 T2
end for ; for every do
triangle t 2 T2 0 T1
REMOVE TRIANGLE(t, E ) INSERT TRIANGLE(t, E )
end for end algorithm
This latter approach turns out to be convenient when the two triangle sets dier only for a restricted number of elements, compared with their total size. This happens, for example, when a certain area of the terrain needs a more accurate representation, while the rest of the surface does not, and the area of interest changes with time. If n1 and n2 are, respectively, the number of triangles of T1 and T2, kold is the number of triangles in T1 0T2 , and knew that of triangles in T2 0T1, then the update costs O(kold n1 log n1 ) for deletions, and O(knewn2 log n2 ) for insertions. The update process results more ecient than the direct recomputation of the visibility map on T2 if such quantities are both less than O((n2 )2), i.e., if 2 kold < (nn21)loglognn1 2 and knew < logn2n2 .
7
Concluding Remarks
In this paper, we have considered the problem of computing the visibility map of a point on hierarchical triangulated terrains. A hierarchical terrain model provides a compact multilevel representation of a terrain. The problem can be reduced, on a triangulated terrain, to the computation of the lower envelope of a set of disjoint triangles in the space. In order to compute the visibility map on a hierachical terrain, related to a certain level " of accuracy, a suitable set of triangles must be extracted from the hierarchy. In a hierarchical terrain, passing from one level to another of the terrain representation means replacing a subset of terrain faces. Thus, an algorithm which allows updating the lower envelope under deletion and insertion of triangles is necessary to update the visibility map accordingly. In the paper, we have described a new algorithm for dynamically maintaining the visibility map of a triangle-based hierarchical terrain, 22
while varying the required level of resolution. This approach is useful when the modi cation in the terrain representation involves a rather small subset of faces. The proposed algorithm achieves a good performance by using an in uence graph to store the history of the computations performed. We have illustrated the application of such approach to a special class of HTMs, namely to hierarchical TINs, but the same method can be in principle applied to ternary triangulations, restricted quadtrees, or any hierarchical model which provide expanded terrain representations in the form of triangulated PTMs.
References [1] D.L. Allen, Visibility in two-and-half dimensions. Master's thesis, Rensselaer Polytechnic Institute, Troy, New York (1986). [2] R.Barrera, A.M.Vaquez, A hierarchical method for representing relief. Proceedings Pecora IX Symposium on Spatial Information Technologies for Remote Sensing Today and Tomorrow, Sioux Falls, South Dakota (1984), 87-92. [3] J.D.Boissonnat, K.Dobrindt, On-Line construction of the upper envelope of triangles in