JP3988945B2 - GRAPHIC DATA PROCESSING METHOD, GRAPHIC DATA PROCESSING PROGRAM, AND RECORDING MEDIUM CONTAINING THE PROGRAM - Google Patents

GRAPHIC DATA PROCESSING METHOD, GRAPHIC DATA PROCESSING PROGRAM, AND RECORDING MEDIUM CONTAINING THE PROGRAM Download PDF

Info

Publication number
JP3988945B2
JP3988945B2 JP2003354037A JP2003354037A JP3988945B2 JP 3988945 B2 JP3988945 B2 JP 3988945B2 JP 2003354037 A JP2003354037 A JP 2003354037A JP 2003354037 A JP2003354037 A JP 2003354037A JP 3988945 B2 JP3988945 B2 JP 3988945B2
Authority
JP
Japan
Prior art keywords
polygon
vertex
point
end point
polygons
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Lifetime
Application number
JP2003354037A
Other languages
Japanese (ja)
Other versions
JP2005122302A (en
Inventor
孝史 飯嶋
憲冶 石田
堅治 松森
拓也 嶺田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
National Agriculture and Food Research Organization
Original Assignee
National Agriculture and Food Research Organization
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by National Agriculture and Food Research Organization filed Critical National Agriculture and Food Research Organization
Priority to JP2003354037A priority Critical patent/JP3988945B2/en
Publication of JP2005122302A publication Critical patent/JP2005122302A/en
Application granted granted Critical
Publication of JP3988945B2 publication Critical patent/JP3988945B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Images

Description

本発明は、平面領域を多角形として表示する図形データの処理方法に関し、特に、地理情報システムで使用する図形データを修正するための図形データ処理方法に関する。   The present invention relates to a graphic data processing method for displaying a planar area as a polygon, and more particularly to a graphic data processing method for correcting graphic data used in a geographic information system.

地理情報システムで使用するデータ形式として広く採用されているシェープファイル形式では、例えば市町村の区域のような飛び地や穴のある平面領域を次の規則に従って複数の多角形で表すこととしている。
(1) 多角形が自己交差しないこと。
(2) 多角形同士が交差しないこと。なお、頂点で接しても良いが、辺を共有してはならない。
(3) 多角形の頂点列の方向に対して右側を当該多角形が表そうとする平面領域の内部としていること。
(4) 多角形が閉じていること。つまり、多角形の頂点列の始点と終点が同じ座標値であること。
In the shape file format widely adopted as a data format used in the geographic information system, for example, a plane area having an enclave or a hole such as a municipal area is represented by a plurality of polygons according to the following rules.
(1) The polygon must not self-intersect.
(2) The polygons should not intersect. You may touch at the apex, but you must not share the edge.
(3) The right side with respect to the direction of the vertex row of the polygon shall be the inside of the plane area that the polygon intends to express.
(4) The polygon is closed. In other words, the start point and end point of the polygonal vertex row have the same coordinate value.

しかし、地理情報システムで使われるデータはデジタイザ等を用いて手動操作により地図から読み込んで作成することも多く、細部にわたって完璧に上記規則に従ったものとするのは困難であり、部分的に規則に従わないデータが混在する場合がある。そして、たとえごく一部であっても規則に従わないデータが混在している場合には、地理情報システムはそれを正常に処理できないことがあり、また、多量のデータの中から規則に従わない部分を検出して修正するのには多大な労力を要するという問題がある。
特開昭61−180378号公報 特開平10−154237号公報 特開平10−21367号公報
However, data used in geographic information systems is often created by manually reading from a map using a digitizer, etc., and it is difficult to follow the above rules completely in detail. Data that does not comply may be mixed. And even if there is a small amount of data that does not comply with the rules, the geographic information system may not be able to handle it properly, and it does not comply with the rules from a large amount of data. There is a problem that a great deal of labor is required to detect and correct the portion.
Japanese Patent Laid-Open No. 61-180378 Japanese Patent Laid-Open No. 10-154237 Japanese Patent Laid-Open No. 10-21367

本発明は、地理情報システムによって表示、加工等の処理を行うことを目的として作成された平面領域を表すデータについて、上記規則に従わない部分があった場合に自動的に修正する図形データ処理方法を提供することを目的とするものである。   The present invention relates to a graphic data processing method that automatically corrects data representing a planar area created for the purpose of performing processing such as display and processing by a geographic information system when there is a portion that does not comply with the above rules. Is intended to provide.

本発明は、多角形をx座標値とy座標値からなる頂点データの配列(以下「頂点列」という)で表し、複数の多角形によってひとつの平面領域を構成するような形式のデータが与えられたとき、1個の平面領域のデータに対して次の処理を行う。
(1) 自己交差多角形分割処理
当該平面領域を構成する多角形のうち、自己交点又は自己接点(以下「カット点」という)を有する多角形について当該カット点で複数の多角形に分割する。図18(a)は自己交差多角形分割処理を行う前を示し、図18(b)は自己交差多角形分割処理を行った後を示す。
(2) 複数多角形の重複解消処理
当該平面領域を構成する多角形のうち、複数の多角形が交差して領域の一部で重なり合う場合(辺の一部を共有する場合を含む。以下同じ)に、当該複数の多角形を重なり合いのない複数の多角形に変換する。詳細には、次の3つの処理を含む。(a)全ての頂点列の方向を統一する。(b)2個の多角形の間の交点又は接点(以下「交点等」という)を検索する。(c)重複した2個の多角形を複数の多角形に変換する。こうして得られた複数の多角形より必要なものを選択する。図19(a)は複数多角形の重複解消処理を行う前を示し、図19(b)は複数多角形の重複解消処理を行った後を示す。
(3) 入れ子状多角形頂点列方向調整処理
当該平面領域を構成する多角形のうち、複数の多角形が入れ子状になっている場合に、最も外側の多角形の頂点列の方向を時計回りとして、内側の多角形の頂点列の方向をそのすぐ外側の多角形の頂点列の方向の逆方向にする。図20(a)は頂点列方向調整処理を行う前を示し、図20(b)は頂点列方向調整処理を行った後を示す。
(4) 後処理
当該平面領域を構成する全ての多角形の頂点列の終点に、当該頂点列の始点と同じ座標値の頂点を追加する。
In the present invention, a polygon is represented by an array of vertex data consisting of x-coordinate values and y-coordinate values (hereinafter referred to as “vertex row”), and data in such a form that a plurality of polygons constitute one plane area is given. If so, the following processing is performed on the data of one plane area.
(1) Self-intersecting polygon division processing Among polygons constituting the plane area, a polygon having a self-intersection or a self-contact (hereinafter referred to as “cut point”) is divided into a plurality of polygons at the cut point. FIG. 18A shows a state before performing the self-intersecting polygon division processing, and FIG. 18B shows a state after performing the self-intersecting polygon division processing.
(2) Deduplication processing of multiple polygons Among the polygons constituting the plane area, when multiple polygons intersect and overlap at a part of the area (including the case where a part of the side is shared, the same applies hereinafter) ), The plurality of polygons are converted into a plurality of non-overlapping polygons. Specifically, the following three processes are included. (A) Unify the directions of all vertex rows. (B) Search for an intersection or contact between two polygons (hereinafter referred to as “intersection etc.”). (C) Two overlapping polygons are converted into a plurality of polygons. A necessary one is selected from the plurality of polygons thus obtained. FIG. 19A shows the state before the multi-polygon deduplication processing is performed, and FIG. 19B shows the state after the multi-polygon deduplication processing is performed.
(3) Nested polygon vertex row direction adjustment processing When multiple polygons are nested among the polygons constituting the plane area, the direction of the vertex row of the outermost polygon is turned clockwise. The direction of the vertex row of the inner polygon is set to be opposite to the direction of the vertex row of the immediately outer polygon. FIG. 20A shows a state before the vertex row direction adjustment processing is performed, and FIG. 20B shows a state after the vertex row direction adjustment processing is performed.
(4) Post-processing A vertex having the same coordinate value as the start point of the vertex row is added to the end points of the vertex rows of all polygons constituting the plane area.

上述の一連の処理を、全ての平面領域のデータに対して施し、処理後のデータを外部記憶媒体に保存する。   The above-described series of processing is performed on the data of all planar areas, and the processed data is stored in an external storage medium.

本発明によると、平面領域を表すデータに含まれる不規則な部分を自動的に且つ簡単に修正するから、地理情報システムによって表示、加工等の処理を正常に行うことができる。
本発明によると、デジタイザ等を用いたデータ作成時に、規則をあまり気にせずに作成することができ、また、確認作業も省けることによって効率化できる。
According to the present invention, irregular portions included in the data representing the planar area are automatically and easily corrected, so that processing such as display and processing can be normally performed by the geographic information system.
According to the present invention, when creating data using a digitizer or the like, rules can be created without much concern, and efficiency can be improved by omitting confirmation work.

図1は、本発明における図形データ処理方法を実行するための回路のブロック図である。本例の装置は、CPU11、ROM12、RAM13、及び入出力I/F回路14を有し、これらは、内部バス15を介して互いに接続されており、互いにデータの通信が可能である。CPU11は装置全体の制御を司り、ROM12には本発明を構成する各処理方法がプログラムの形態で格納され、RAM13には各処理方法が使用するデータが格納される。入出力I/F回路14は外部記憶装置16と接続されている。本例の装置は、外部記憶装置16を介して外部記憶媒体からデータを受け取るとともに、本例の装置による処理後のデータを外部記憶媒体に対して出力する。   FIG. 1 is a block diagram of a circuit for executing the graphic data processing method according to the present invention. The apparatus of this example includes a CPU 11, a ROM 12, a RAM 13, and an input / output I / F circuit 14, which are connected to each other via an internal bus 15 and can communicate data with each other. The CPU 11 controls the entire apparatus. Each processing method constituting the present invention is stored in the ROM 12 in the form of a program, and the RAM 13 stores data used by each processing method. The input / output I / F circuit 14 is connected to the external storage device 16. The apparatus of this example receives data from the external storage medium via the external storage device 16 and outputs data processed by the apparatus of this example to the external storage medium.

図2は、本装置による図形データ処理の全体の手順を示したものである。まず、ステップS10にて、外部記憶媒体からデータを読み込み、それをRAM13に格納する。ステップS11にて、全ての平面領域のデータについて処理が終了したかを判定し、終了していない場合には、ステップS20にて、RAM13に格納されたデータより、平面領域を単位としてデータを取り出す。ステップS21にて、自己交差多角形分割処理を行い、ステップS22にて、複数多角形の重複解消処理を行い、ステップS23にて、入れ子状多角形頂点列方向調整処理を行い、ステップS24にて、後処理を施す。ステップS11にて、全ての平面領域のデータについてこれらの処理が終了したと判定したら、ステップS30にて、処理後のデータを外部記憶媒体に保存する。   FIG. 2 shows the entire procedure of graphic data processing by this apparatus. First, in step S10, data is read from the external storage medium and stored in the RAM 13. In step S11, it is determined whether the processing has been completed for all the plane area data. If not, the data is extracted from the data stored in the RAM 13 in units of the plane area in step S20. . In step S21, self-intersecting polygon division processing is performed. In step S22, multiple polygon deduplication processing is performed. In step S23, nested polygon vertex row direction adjustment processing is performed. In step S24. And post-processing. If it is determined in step S11 that these processes have been completed for all plane area data, the processed data is stored in an external storage medium in step S30.

以下、本発明における図形データ処理方法について詳述する。
(1) 自己交差多角形分割処理
特開平10-154237号公報には、y軸方向に対して凸な多角形を対象として自己交差する多角形を自己交点で分割する方法が提案されている。しかし、本発明が対象とする多角形は、地理情報システムによる処理の対象であり、形状に制約条件のない一般の多角形であるから、特開平10-154237号公報の方法は適用できない。
Hereinafter, the graphic data processing method in the present invention will be described in detail.
(1) Self-intersecting polygon division processing Japanese Patent Application Laid-Open No. 10-154237 proposes a method of dividing a self-intersecting polygon at a self-intersection for a polygon convex in the y-axis direction. However, since the polygon targeted by the present invention is an object to be processed by the geographic information system and is a general polygon with no constraint on the shape, the method of Japanese Patent Laid-Open No. 10-154237 cannot be applied.

図3を参照して、本発明による自己交差多角形分割処理の概要を説明する。図3(a)の多角形は、頂点p1が辺p3p4と接しており、辺p3p4と辺p5p0が交差している。図3(b)には、自己接点をc1、自己交点をc2としてそれらの位置を示した。まず、接点c1の座標値(この場合は頂点p1の座標値に等しい)と交点c2の座標値を求める。接点c1及び交点c2が存在する辺にそれぞれ、それらと座標値が等しい頂点を挿入する。すなわち、辺p3p4には接点c1の座標値に等しい頂点と交点c2の座標値に等しい頂点を挿入し、辺p5p0には、交点c2の座標値に等しい頂点を挿入する。尚、以下に、接点及び交点をカット点と称する。   With reference to FIG. 3, the outline of the self-intersecting polygon division processing according to the present invention will be described. In the polygon of FIG. 3A, the vertex p1 is in contact with the side p3p4, and the side p3p4 and the side p5p0 intersect. FIG. 3 (b) shows the positions of the self-contact as c1 and the self-intersection as c2. First, the coordinate value of the contact c1 (in this case, equal to the coordinate value of the vertex p1) and the coordinate value of the intersection c2 are obtained. A vertex having the same coordinate value is inserted into each of the sides where the contact point c1 and the intersection point c2 exist. That is, a vertex equal to the coordinate value of the contact c1 and a vertex equal to the coordinate value of the intersection c2 are inserted into the side p3p4, and a vertex equal to the coordinate value of the intersection c2 is inserted into the side p5p0. Hereinafter, the contact points and intersections are referred to as cut points.

図3(c)は、このようにして元の多角形に頂点を挿入し、番号をふり直したものである。このような処理を施した後の多角形の頂点列には、1個のカット点につき、その座標値に等しい頂点が2個以上存在することになる。   FIG. 3 (c) shows the result of inserting vertices in the original polygon and renumbering them. In the polygon vertex row after such processing, there are two or more vertices equal to the coordinate value for each cut point.

次に、この多角形について2個の頂点の組み合わせを番号の若い方から順番に調べていくと、頂点p1とp4の座標値が等しいこと、すなわちそれらがカット点に等しいことが見出される。そこで多角形をカット点p1とp4にて2分割すれば図3(d)と図3(e)の2個の多角形が得られる。さらに、図3(d)の頂点の番号をふり直して図3(f)となる。図3(f)において、同様に2個の頂点の組み合わせを調べると、頂点p2とp5がカット点に等しいことが見出されるので、そこで多角形を2分割すれば図3(g)と図3(h)の2個の多角形が得られる。   Next, when the combination of two vertices of this polygon is examined in order from the smallest number, it is found that the coordinate values of the vertices p1 and p4 are equal, that is, they are equal to the cut point. Therefore, if the polygon is divided into two at the cut points p1 and p4, the two polygons shown in FIGS. 3 (d) and 3 (e) are obtained. Further, the vertex numbers in FIG. 3 (d) are re-assigned to FIG. 3 (f). In FIG. 3 (f), if the combination of two vertices is examined in the same manner, it is found that the vertices p2 and p5 are equal to the cut point, so if the polygon is divided into two there, FIG. 3 (g) and FIG. Two polygons of (h) are obtained.

本発明が提案する分割方法は、上記のように、対象とする多角形にカット点に等しい頂点を挿入した上で、頂点列における座標値が等しい2個の頂点の探索と当該頂点における頂点列の2分割を再帰処理によって繰り返すことにより、カット点が複数ある場合でも分割することを可能とするものである。   As described above, the division method proposed by the present invention inserts a vertex that is equal to the cut point into the target polygon, and then searches for two vertices having the same coordinate value in the vertex row and the vertex row at the vertex. By repeating the above two divisions by recursive processing, it is possible to divide even when there are a plurality of cut points.

以下、この方法を実現するための具体的な処理手順について述べる。
(1-1)頂点列において連続する複数の頂点が等しい場合には、それらのうち1個のみを残して他は削除する。
上記説明から分かるように、本発明における分割方法では、2個の頂点の座標値が等しい場合にカット点であると判定するため、処理前の多角形の頂点列のうち連続する2個の頂点(当該頂点列の終点と始点の組み合わせを含む。以下同じ)の座標値が等しい場合には正しく判定できない。
Hereinafter, a specific processing procedure for realizing this method will be described.
(1-1) If a plurality of consecutive vertices in the vertex row are equal, only one of them is left and the others are deleted.
As can be seen from the above description, in the dividing method according to the present invention, when the coordinate values of two vertices are equal, it is determined that the cut point is a cut point. If the coordinate values (including the combination of the end point and the start point of the vertex row, and so on) are equal, it cannot be determined correctly.

そのため、前処理として、頂点列において連続する複数の頂点が等しい場合には、あらかじめ、それらのうち1個のみを残して他は削除することにより、連続する2頂点が重複しない頂点列に変換する。   Therefore, as a pre-processing, when multiple consecutive vertices in the vertex row are equal, in advance, only one of them is deleted and the others are deleted, so that the two consecutive vertices are converted into a non-overlapping vertex row. .

(1-2)カット点を探索し、探索したカット点の座標値に等しい頂点を頂点列の該当箇所に挿入する。
多角形の2辺の全ての組み合わせについて、2辺が交差するかどうか、又は一方の辺の端点が他方の辺上にあるかどうかを調べることによりカット点を探索する。カット点があった場合には、そのカット点の座標値に等しい頂点を頂点列の該当箇所に挿入する。
(1-2) A cut point is searched, and a vertex equal to the coordinate value of the searched cut point is inserted into a corresponding portion of the vertex row.
For all combinations of two sides of the polygon, the cut point is searched by checking whether the two sides intersect or whether the end point of one side is on the other side. If there is a cut point, a vertex equal to the coordinate value of the cut point is inserted into the corresponding portion of the vertex row.

図4及び図5を参照して、カット点の探索と頂点列にカット点に等しい頂点を挿入する処理の手順を説明する。ステップS400にて、多角形の頂点列{p0, p1, ..., pn-1}を選ぶ。ステップS401にて、頂点列に挿入すべき頂点の挿入位置の情報とその座標値を一時的に格納しておくための連想コンテナMを用意する。   With reference to FIG.4 and FIG.5, the procedure of the process of searching a cut point and inserting the vertex equal to a cut point into a vertex row | line | column is demonstrated. In step S400, a polygon vertex row {p0, p1,..., Pn-1} is selected. In step S401, an associative container M for temporarily storing information on the insertion position of the vertex to be inserted into the vertex row and its coordinate value is prepared.

連想コンテナMのキーは、頂点の挿入位置の情報として、頂点を挿入する位置の直前の頂点の番号とする。連想コンテナMに格納するデータは、当該位置に挿入すべき頂点の集合とする。M[ i ]は点piとpi+1の間に挿入すべき頂点の集合を表し、M[ j ]は点pjとpj+1の間に挿入すべき頂点の集合を表す。   The key of the associative container M is the vertex number immediately before the position at which the vertex is inserted as information on the vertex insertion position. The data stored in the associative container M is a set of vertices to be inserted at the position. M [i] represents a set of vertices to be inserted between the points pi and pi + 1, and M [j] represents a set of vertices to be inserted between the points pj and pj + 1.

ステップS401〜S412、及び、ステップS420〜S426はカット点の探索処理である。ステップS402〜S406は、n個の頂点を1つずつ処理し、全ての頂点に対して処理が完了したかを判定する。全ての頂点に対して処理が完了していない場合には、ステップS407に進む。   Steps S401 to S412 and steps S420 to S426 are cut point search processing. In steps S402 to S406, n vertices are processed one by one, and it is determined whether the processing has been completed for all vertices. If the processing has not been completed for all vertices, the process proceeds to step S407.

ステップS407にて、eiとejの傾きが等しいか否かを判定する。eiは頂点piとpi+1を端点とする辺、ejは、頂点pjとpj+1(j=n-1のときはp0)を端点とする辺である。
辺eiと辺ejの傾きが等しい場合には、ステップS408〜S412に進み、辺eiと辺ejの傾きが等しくない場合には、ステップS420〜S426に進む。
In step S407, it is determined whether the slopes of ei and ej are equal. ei is a side whose end points are vertices pi and pi + 1, and ej is a side whose end points are vertices pj and pj + 1 (p0 when j = n-1).
If the slopes of the side ei and ej are equal, the process proceeds to steps S408 to S412. If the slopes of the side ei and side ej are not equal, the process proceeds to steps S420 to S426.

ステップS408〜S412では、辺eiと辺ejが同一線状にあり、且つ、頂点pjが辺ei上にある場合には、M[ i ]に頂点pjと等しい頂点を追加し、頂点piが辺ej上にある場合には、M[ j ]に頂点piと等しい頂点を追加する。ステップS420〜S423では、辺eiと辺ejの傾きが同一でなく、且つ、頂点pjが辺ei上にある場合には、M[ i ]に頂点pjと等しい頂点を追加し、頂点piが辺ej上にある場合には、M[ j ]に頂点piと等しい頂点を追加する。ステップS424、S425では、辺eiと辺ejが交差する場合、M[ i ]及びM[ j ]に辺eiと辺ejの交点と等しい頂点を追加する。   In steps S408 to S412, if the side ei and the side ej are in the same line and the vertex pj is on the side ei, a vertex equal to the vertex pj is added to M [i], and the vertex pi is the side If it is on ej, add a vertex equal to vertex pi to M [j]. In steps S420 to S423, if the slopes of the side ei and the side ej are not the same and the vertex pj is on the side ei, a vertex equal to the vertex pj is added to M [i], and the vertex pi is a side. If it is on ej, add a vertex equal to vertex pi to M [j]. In steps S424 and S425, when the side ei and the side ej intersect, a vertex equal to the intersection of the side ei and the side ej is added to M [i] and M [j].

図5を参照する。ステップS4300〜S4304は頂点列にカット点に等しい頂点を挿入する処理である。ステップS4301は、連想コンテナMに格納された全てのデータに対して処理を完了したか否かを判定する。全てのデータに対して処理が完了していない場合には、ステップS4302に進み、M[ i ]に頂点のデータが格納されているかどうかを判定する。M[ i ]に頂点のデータが格納されている場合(空でない)には、ステップS4304に進み、頂点piとpi+1の間にM[ i ]に格納されている頂点のデータを頂点piからの距離の昇順で挿入する。   Please refer to FIG. Steps S4300 to S4304 are processes for inserting a vertex equal to the cut point into the vertex row. In step S4301, it is determined whether processing has been completed for all data stored in the associative container M. If processing has not been completed for all data, the process advances to step S4302 to determine whether vertex data is stored in M [i]. If the vertex data is stored in M [i] (not empty), the process proceeds to step S4304, and the vertex data stored in M [i] between the vertices pi and pi + 1 is converted to the vertex pi. Insert in ascending order of distance from.

(1-3)多角形をカット点で分割する。
以上の処理を施した後の多角形よりカット点を検索し、カット点が存在する場合には、そこで多角形を分割する。カット点の検索は、その頂点列中に同じ座標値の頂点が2個以上あるかどうかを調べることによってなされる。このことを利用した多角形の分割の手順について図6のフローチャートを参照して説明する。
(1-3) Divide the polygon at the cut points.
The cut point is searched from the polygon after the above processing is performed, and when the cut point exists, the polygon is divided there. The cut point is searched by checking whether there are two or more vertices having the same coordinate value in the vertex row. A procedure for dividing a polygon using this will be described with reference to the flowchart of FIG.

図6を参照して、多角形よりカット点を検索し、多角形を分割する手順を説明する。ステップS500にて、多角形の頂点列V0{p0, p1, ..., pn-1}を選ぶ。ステップS501〜S508は、座標値が等しい2個の頂点があるかどうかを調べる処理を、n個の頂点に対して順に行い、全ての頂点に対して処理が完了したかを判定する。ステップS507にて、座標値が等しい2個の頂点pi、pjが見つかった場合には、それらがカット点に等しい頂点であると判断できるので、ステップS510に進む。座標値が等しい2個の頂点が見つからなかった場合には、ステップS509に進み、当該多角形にはカット点がないと判断し、頂点列V0を更新後データに追加して終了する。ここで、更新後データとは、平面領域を表す全ての頂点列に対して分割処理が終了するまでの間、処理後の頂点列データを格納して保持しておくものである。   With reference to FIG. 6, a procedure for searching for a cut point from a polygon and dividing the polygon will be described. In step S500, a polygon vertex row V0 {p0, p1,..., Pn-1} is selected. In steps S501 to S508, processing for checking whether there are two vertices having the same coordinate value is sequentially performed on the n vertices, and it is determined whether the processing has been completed for all the vertices. If two vertices pi and pj having the same coordinate value are found in step S507, it can be determined that they are vertices equal to the cut point, and the process proceeds to step S510. If two vertices having the same coordinate value are not found, the process proceeds to step S509, where it is determined that there is no cut point in the polygon, the vertex row V0 is added to the updated data, and the process ends. Here, the post-update data is to store and hold the processed vertex string data until the division process is completed for all the vertex strings representing the planar area.

ステップS510にて、頂点列V0の始点p0からpiの直前の頂点pi-1までの部分頂点列{p0, ..., pi-1}と、pjを始点として頂点列V0の終点pn-1までの部分頂点列{pj, ..., pn-1}を連結することにより頂点列{p0, ..., pi-1, pj, ..., pn-1}を作成してV1とし、頂点piを始点としてpjの直前の頂点pj-1までの部分頂点列{pi, ..., pj-1}をV2とする。これらが、頂点列V0をカット点pi、pjで2分割した多角形の頂点列である。   In step S510, the partial vertex sequence {p0, ..., pi-1} from the start point p0 of the vertex sequence V0 to the vertex pi-1 immediately before pi, and the end point pn-1 of the vertex sequence V0 starting from pj Create a vertex sequence {p0, ..., pi-1, pj, ..., pn-1} by connecting the partial vertex sequences {pj, ..., pn-1} up to V1 , Let V2 be a partial vertex sequence {pi, ..., pj-1} from the vertex pi to the vertex pj-1 immediately before pj. These are polygonal vertex rows obtained by dividing the vertex row V0 into two by the cut points pi and pj.

ステップS511及びS512にて、このようにして作成された頂点列V1、V2をそれぞれ頂点列V0に読み替える。次に、図6の処理を再帰することにより、カット点がなくなるまで2分割が繰り返され、再帰処理が終了した時点で、全てのカット点で分割された複数の多角形の頂点列が更新後データに格納される。   In steps S511 and S512, the vertex rows V1 and V2 created in this way are read as vertex rows V0, respectively. Next, by repeating the process of FIG. 6, the division into two is repeated until there are no more cut points. When the recursion process is completed, the vertex sequences of the polygons divided at all the cut points are updated. Stored in the data.

ステップS501の処理について説明する。処理前の多角形において連続する2辺が同じ直線上で重なっている場合、上記処理の過程において重なっている部分が分離され、その両端の2頂点だけからなる頂点列が生成される。これは、面積のない線分であり、平面領域を表すデータとしては不要なものなので、ステップS501にて、分割後の頂点列の頂点数が3個未満の場合は格納しないことにより排除する。   The process of step S501 will be described. When two continuous sides overlap in the polygon before processing on the same straight line, the overlapping part is separated in the process of the above processing, and a vertex sequence consisting of only two vertices at both ends is generated. Since this is a line segment with no area and is unnecessary as data representing a plane area, in step S501, if the number of vertices in the divided vertex row is less than 3, it is excluded by not storing.

(1-4)元の平面領域データにおける全ての頂点列に対して上記(1-1)〜(1-3)の処理を施すことにより、自己交差しない複数の多角形の頂点列データに変換され、更新後データとして保持されているので、最後に、元の平面領域データを更新後データに置き換える。   (1-4) By applying the processes (1-1) to (1-3) above to all vertex sequences in the original planar area data, it is converted into a plurality of polygon vertex sequences that do not self-intersect. Since the data is stored as updated data, the original plane area data is finally replaced with the updated data.

(2) 複数多角形の重複解消処理
2個の多角形の重なり合いを解消するには、それを複数の多角形に変換すればよい。このような多角形の変換方法として、従来、頂点追跡による方法が知られている。図7を参照して、頂点追跡による方法を説明する。例えば、図7(a)の2個の多角形A、Bが図7(b)のように重なり合うときに、それらの頂点列を再編して図7(c)〜図7(e)に示すような複数の多角形に変換し、そのうち目的に応じて必要なものを利用すれば良い。
(2) Deduplication processing for multiple polygons
To eliminate the overlap of two polygons, you can convert them to multiple polygons. As such a polygon conversion method, a method by vertex tracking is conventionally known. A method using vertex tracking will be described with reference to FIG. For example, when two polygons A and B in FIG. 7 (a) overlap as shown in FIG. 7 (b), those vertex rows are reorganized and shown in FIGS. 7 (c) to 7 (e). It is necessary to convert them into a plurality of polygons, and use what is necessary according to the purpose.

先ず、図7(b)に示すように、多角形AとBの頂点列の向きを時計回りに統一し、多角形AとBの交点p1、p2、p3、p4を求める。次に、交点p1を出発点として多角形Aの頂点列をその方向に従って辿り、別の交点p4に達したところで多角形Bの頂点列に乗り換えて同様に辿り、出発点p1まで戻ると、図7(c)に示すように、多角形AとBの領域を結合した領域(以下、「結合領域」という)を囲む多角形が得られる。   First, as shown in FIG. 7B, the directions of the vertex rows of the polygons A and B are unified clockwise, and the intersection points p1, p2, p3, and p4 of the polygons A and B are obtained. Next, the vertex line of polygon A is traced according to the direction from intersection point p1 as the starting point.When another intersection point p4 is reached, the vertex line of polygon B is changed in the same manner, and when returning to starting point p1, As shown in FIG. 7 (c), a polygon is obtained that surrounds an area obtained by combining the areas of polygons A and B (hereinafter referred to as “combined area”).

このように、ある交点を出発点として多角形Aの頂点列を辿り、別の交点に達したら多角形Bの頂点列に乗り換え、更に、次の交点に達したときに、そこが出発点でなければ再び多角形Aの頂点列に乗り換えて頂点列を辿る。このように、多角形AとBの頂点列を交点で交互に乗り換えて出発点に戻るまで辿ることによって多角形を作成する手順を、多角形A、Bの全ての辺を一回ずつ辿り終わるまで行うことにより、複数個の多角形に変換できる。それらの多角形は、図7(c)に示す時計回りのもので最大のものが多角形AとBの結合領域を囲む多角形、図7(d)に示すその他の時計回りものが多角形AとBが重なり合う領域(以下「重複領域」という)を囲む多角形、及び図7(e)に示す反時計回りのものが多角形AとBを結合してできた穴の領域(以下「穴領域」という)を囲む多角形に分類できる。もちろん、多角形AとBの位置関係によっては、穴領域は発生しないこともある。こうして得られた複数の多角形より必要に応じて1又は複数の多角形を選択する。   In this way, the vertex line of polygon A is traced starting from a certain intersection, and when another intersection is reached, it is transferred to the vertex line of polygon B, and when the next intersection is reached, that is the starting point. If not, change to the vertex row of polygon A again and follow the vertex row. In this way, the procedure of creating a polygon by alternately switching the vertex rows of polygons A and B at the intersection and returning to the starting point is followed by tracing all the sides of polygons A and B once. Can be converted into a plurality of polygons. These polygons are the clockwise ones shown in FIG. 7 (c), the largest one enclosing the combined area of polygons A and B, and the other clockwise ones shown in FIG. 7 (d) are polygons. A polygon surrounding a region where A and B overlap (hereinafter referred to as “overlapping region”), and a counterclockwise region shown in FIG. Can be classified into polygons surrounding a hole area). Of course, depending on the positional relationship between the polygons A and B, the hole region may not be generated. One or a plurality of polygons are selected as necessary from the plurality of polygons thus obtained.

なお、多角形A、Bの頂点列の方向がいずれも反時計回りである場合には、前記手順と同様の手順で生成される多角形について、その分類における頂点列の向きをそれぞれ逆方向に読み替えれば同じ結果となる。   When the directions of the vertex rows of the polygons A and B are both counterclockwise, the orientation of the vertex rows in the classification is reversed for the polygons generated by the same procedure as described above. The same result will be obtained if it is read.

本発明における複数多角形の重複解消処理では、この頂点列追跡の方法によって、ひとつの平面領域を表す複数の多角形のうち、重なり合うものを結合領域を囲む多角形と穴領域を囲む多角形に変換する処理を行う。以下、具体的な処理手順について述べる。   In the multi-polygon deduplication processing in the present invention, by this vertex row tracking method, among the plurality of polygons representing one plane area, the overlapping polygons are converted into a polygon surrounding the combined area and a polygon surrounding the hole area. Perform the conversion process. A specific processing procedure will be described below.

(2-1) 頂点列方向判定処理及び頂点列方向統一化処理
以上の説明から明らかなように、頂点追跡の方法で期待する結果を得るには、対象とする多角形の頂点列の方向が時計回り又は反時計回りのどちらかで統一されている必要がある。そこで、まず、前処理として、平面領域を構成する全ての頂点列についてその方向を判定し、反時計回りであると判定された頂点列について頂点列の順番を逆転させることにより、全ての頂点列の方向を時計回りに統一する。
(2-1) Vertex row direction determination processing and vertex row direction unification processing As is clear from the above description, in order to obtain the expected result by the vertex tracking method, the direction of the vertex row of the target polygon is It must be unified either clockwise or counterclockwise. Therefore, as a pre-processing, first, the direction of all the vertex rows constituting the planar area is determined, and the vertex row order is reversed for the vertex rows that are determined to be counterclockwise. Unify the direction of.

従来、多角形の頂点列の方向を判定する方法としては、ベクトルの外積を計算し、外積の正負によって方向を判定する方法が知られている。この方法では、先ず、x座標値が最小の頂点、x座標値が最大の頂点、y座標値が最小の頂点、y座標値が最大の頂点のうちいずれか1個(p2とする)を選び、当該頂点列における頂点p2の直前の頂点(p1とする)と直後の頂点(p3とする)を選ぶ。次に、ベクトルp2p1とp2p3の外積Gを計算し、外積Gの正負を判定する。   Conventionally, as a method of determining the direction of a polygonal vertex row, a method of calculating the outer product of vectors and determining the direction based on the sign of the outer product is known. In this method, first, select one of the vertices with the smallest x coordinate value, the vertex with the largest x coordinate value, the vertex with the smallest y coordinate value, and the vertex with the largest y coordinate value (referred to as p2). Then, the vertex immediately before vertex p2 (referred to as p1) and the vertex immediately subsequent to vertex (referred to as p3) in the vertex row are selected. Next, the cross product G of the vectors p2p1 and p2p3 is calculated, and the sign of the cross product G is determined.

具体的には、x軸の正の方向が右向き、y軸の正の方向が上向きの座標系における多角形について、前述のように選んだ頂点p1、 p2、 p3の座標値をそれぞれ(x1, y1)、(x2, y2)、(x3, y3)とすると、外積Gは式1によって求められ、外積Gが正の場合は当該多角形の頂点列の方向は時計回り、負の場合は反時計回りであると判定できる。   Specifically, for polygons in a coordinate system in which the positive x-axis direction is right and the positive y-axis direction is upward, the coordinate values of the vertices p1, p2, and p3 selected as described above are (x1, If y1), (x2, y2), and (x3, y3), the outer product G is obtained by Equation 1, and if the outer product G is positive, the direction of the vertex row of the polygon is clockwise, and if it is negative, it is counterclockwise It can be determined to be clockwise.

G = p2p1 × p2p3 = (x1 − x2) × (y3 − y2) − (y1 − y2) × (x3 − x2) ・・・ (式1)   G = p2p1 × p2p3 = (x1 − x2) × (y3 − y2) − (y1 − y2) × (x3 − x2) (Equation 1)

しかし、この方法には外積Gが0になった場合には判定できないという問題がある。一般論として、ベクトルp2p1とp2p3の外積が0となるのは、点p1、点p2、点p3が全て同一直線上にある場合(いずれかの2点あるいは3点とも等しい場合を含む)である。ここで、点p1、p2、p3が前述の自己交差多角形分割処理を施した後の多角形の頂点であることを前提とすれば、3点p1、p2、p3はいずれも等しくないこと、及び辺p1p2と辺p2p3は重ならないことが保証されている。また、頂点列の方向を判定するうえで、x座標値が最小の頂点をp2とし、その直前の頂点をp1、直後の頂点をp3とすれば、点p2のx座標値は点p1及びp3のx座標値より大きくなることはない。したがって、ここでは、外積の計算結果が0の場合として、y軸に平行な直線上に3点p1、p2及びp3が{p1, p2, p3}又は{p3, p2, p1}の順番で並ぶ場合だけを考えればよい。以上の考察から、この問題は初等幾何学的な方法により解決できることが見出される。   However, this method has a problem that it cannot be determined when the outer product G becomes zero. In general, the cross product of vectors p2p1 and p2p3 is 0 when points p1, p2, and p3 are all on the same straight line (including the case where any two or three points are equal). . Here, assuming that the points p1, p2, and p3 are the vertices of the polygon after the above-described self-intersecting polygon division processing, the three points p1, p2, and p3 are not equal to each other. Also, it is guaranteed that side p1p2 and side p2p3 do not overlap. In determining the direction of the vertex row, if the vertex having the smallest x coordinate value is p2, the immediately preceding vertex is p1, and the immediately following vertex is p3, the x coordinate value of the point p2 is the points p1 and p3 It cannot be larger than the x coordinate value of. Therefore, here, assuming that the calculation result of the outer product is 0, the three points p1, p2, and p3 are arranged in the order of {p1, p2, p3} or {p3, p2, p1} on the straight line parallel to the y-axis. You only need to consider the case. From the above consideration, it is found that this problem can be solved by an elementary geometric method.

図8を参照して、多角形の頂点列の方向を判定し、反時計回りの場合に時計回りに変更する手順を説明する。ステップS700にて、多角形の頂点列V0を用意する。ステップS701にて、多角形の頂点列からx座標値が最小の頂点p2を選び、ステップS702にて、当該頂点列におけるその直前の頂点p1及び直後の頂点p3を選ぶ。ステップS703にて、ベクトルp2p1とp2p3の外積Gを計算する。ステップS704〜S707にて、外積Gが非0であれば従来の方法によって判定を行う。即ち、外積Gが正なら、時計回りであると判定し、外積Gが負なら、反時計回りであると判定する。外積Gが0の場合は、上記考察よりy軸に平行な同一の直線上に頂点列{p1, p2, p3}又は{p3, p2, p1}の順番で並んでいると判断できる。従って、ステップS706にて、頂点p3のy座標値と頂点p2のy座標値を比較する。頂点p3のy座標値が頂点p2のy座標値よりも大きければ当該多角形の頂点列の方向は時計回り、小さければ反時計回りであると判定できる。頂点p2と頂点p1のy座標値を比較することによっても同様の判定ができることは言うまでもない。反時計回りである場合には、ステップS707にて、多角形の頂点列の順を逆転する。   With reference to FIG. 8, a procedure for determining the direction of the vertex row of the polygon and changing it in the clockwise direction when it is counterclockwise will be described. In step S700, a polygon vertex row V0 is prepared. In step S701, a vertex p2 having the smallest x coordinate value is selected from the polygon vertex row, and in step S702, the immediately preceding vertex p1 and the immediately following vertex p3 in the vertex row are selected. In step S703, the outer product G of the vectors p2p1 and p2p3 is calculated. In steps S704 to S707, if the outer product G is non-zero, the determination is performed by the conventional method. That is, if the outer product G is positive, it is determined to be clockwise, and if the outer product G is negative, it is determined to be counterclockwise. When the outer product G is 0, it can be determined from the above consideration that the vertex rows {p1, p2, p3} or {p3, p2, p1} are arranged in the order on the same straight line parallel to the y axis. Accordingly, in step S706, the y coordinate value of the vertex p3 is compared with the y coordinate value of the vertex p2. If the y coordinate value of the vertex p3 is larger than the y coordinate value of the vertex p2, it can be determined that the direction of the vertex row of the polygon is clockwise, and if it is smaller, it is counterclockwise. It goes without saying that the same determination can be made by comparing the y-coordinate values of the vertex p2 and the vertex p1. If it is counterclockwise, the order of the polygonal vertex row is reversed in step S707.

(2-2) 2個の多角形間の交点等の探索と頂点の挿入を行う。
次に、平面領域データから2個の多角形A、Bの頂点列Va、Vbを取り出し、2つの多角形AとBの間の交点又は接点(以下「交点等」という)を探索する。2個の多角形A、Bの辺の全ての組み合わせについて交差するかどうか、又は一方の辺の端点が他方の辺上にあるかどうかを調べる。交点等があった場合、その交点等に等しい頂点を頂点列VaとVbの該当箇所に挿入する。
(2-2) Search for intersections between two polygons and insert vertices.
Next, the vertex rows Va and Vb of the two polygons A and B are extracted from the plane area data, and an intersection or contact point (hereinafter referred to as “intersection or the like”) between the two polygons A and B is searched. It is examined whether all combinations of the sides of the two polygons A and B intersect or whether the end point of one side is on the other side. If there is an intersection or the like, a vertex equal to the intersection or the like is inserted into the corresponding portion of the vertex rows Va and Vb.

図9及び図10を参照して、2個の多角形の間の交点等の探索と頂点挿入の手順を説明する。ステップS800にて、2個の多角形の頂点列Va{pa0, pa1, ..., pana-1}、Vb{pb0, pb1, ..., pbnb-1}を選ぶ。頂点列Va、Vbは、それぞれna個、nb個の頂点を持つ多角形A、Bを表す。ステップS801にて、頂点列Va、Vbに挿入すべき頂点の挿入位置の情報とその座標値を一時的に格納しておくための連想コンテナMa、Mbを用意する。   With reference to FIG. 9 and FIG. 10, a procedure for searching for an intersection between two polygons and inserting a vertex will be described. In step S800, two polygon vertex rows Va {pa0, pa1, ..., pana-1} and Vb {pb0, pb1, ..., pbnb-1} are selected. The vertex rows Va and Vb represent polygons A and B having na and nb vertices, respectively. In step S801, associative containers Ma and Mb for temporarily storing information on the insertion positions of the vertices to be inserted into the vertex rows Va and Vb and their coordinate values are prepared.

連想コンテナMa、Mbのキーは、頂点の挿入位置の情報として、頂点を挿入する位置の直前の頂点の番号とする。連想コンテナMa、Mbに格納するデータは、当該位置に挿入すべき頂点の集合とする。
Ma[ i ]は点paiとpai+1の間に挿入すべき頂点の集合を表し、Mb[ j ]は点pbjとpbj+1の間に挿入すべき頂点の集合を表す。
The keys of the associative containers Ma and Mb are the number of the vertex immediately before the position where the vertex is inserted, as information on the insertion position of the vertex. The data stored in the associative containers Ma and Mb is a set of vertices to be inserted at the positions.
Ma [i] represents a set of vertices to be inserted between the points pai and pai + 1, and Mb [j] represents a set of vertices to be inserted between the points pbj and pbj + 1.

ステップS802〜S812、及び、ステップS820〜S826は交点等の探索処理である。これらの処理は、図4のステップS402〜S412及びS420〜S426と同様であるが、図4の例では、同一の多角形におけるカット点を探索したが、図9の例では、異なる2個の多角形の間の交点等を探索する点が異なる。従って、本例では、eiは点paiとpai+1(i=na-1のときはpa0)を端点とする多角形Aの辺、ejは、点pbjとpbj+1(j=nb-1のときはpb0)を端点とする多角形Bの辺である。   Steps S802 to S812 and steps S820 to S826 are search processing for intersections and the like. These processes are the same as steps S402 to S412 and S420 to S426 in FIG. 4. In the example of FIG. 4, the cut points in the same polygon are searched. However, in the example of FIG. The point of searching for intersections between polygons is different. Therefore, in this example, ei is the side of the polygon A whose endpoints are the points pai and pai + 1 (pa0 when i = na-1), and ej is the points pbj and pbj + 1 (j = nb-1 Is the side of polygon B whose end point is pb0).

図10を参照する。ステップS8300〜S8304及びステップS8400〜S8404は頂点列に交点等に等しい頂点を挿入する処理である。ステップS8304では、頂点列Vaの頂点paiとpai+1の間にMa[ i ]に格納されている頂点のデータを頂点paiからの距離の昇順で挿入する。ステップS8404では、頂点列Vbの頂点pbjとpbj+1の間にMb[ j ]に格納されている頂点のデータを頂点pbjからの距離の昇順で挿入する。   Please refer to FIG. Steps S8300 to S8304 and steps S8400 to S8404 are processes for inserting vertices that are equal to intersections or the like into the vertex row. In step S8304, the vertex data stored in Ma [i] is inserted between the vertices pai and pai + 1 of the vertex row Va in ascending order of the distance from the vertex pai. In step S8404, the vertex data stored in Mb [j] is inserted between the vertices pbj and pbj + 1 of the vertex row Vb in ascending order of the distance from the vertex pbj.

この処理を平面領域を構成する頂点列の全ての組み合わせについて行うことにより、任意の2個の多角形の間に交点等がある場合、当該2個の多角形の両方が必ず当該交点等に等しい頂点を有することとなる。   By performing this process for all combinations of vertex rows that make up the planar area, if there are intersections between any two polygons, both of the two polygons must be equal to the intersections, etc. Will have vertices.

(2-3) 以上の処理を施した後、平面領域データから重なり合う2個の多角形を表す頂点列を取り出し、前述の頂点追跡の方法によってそれらを結合領域を囲む多角形と穴領域を囲む多角形に変換して平面領域データを更新する処理を、更新後の平面領域データに属する頂点列の全ての組み合わせにおいて重なり合いがなくなるまで繰り返すことにより、当該平面領域データにおける複数の多角形の重なり合いを解消する。   (2-3) After performing the above processing, extract the vertex sequence representing the two overlapping polygons from the planar area data, and enclose the polygon and hole area surrounding the combined area by the method of vertex tracking described above. By repeating the process of converting to polygons and updating the plane area data until there is no overlap in all combinations of vertex rows belonging to the updated plane area data, the overlapping of the polygons in the plane area data is repeated. Eliminate.

図11を参照して複数の多角形の重なり合いを解消する手順を説明する。ステップS900にて、平面領域データとして、n個の頂点列の集合{V0, V1, ..., Vn-1}を用意する。ステップS901〜S907は、2個の頂点列が表す2個の多角形が重なり合うかどうかを調べる処理を、n個の頂点列に対して順に行い、全ての頂点列に対して処理が完了したかを判定する。ステップS905にて、2個の頂点列Vi、Vjが表す2個の多角形が重なり合う場合には、ステップS908に進む。   With reference to FIG. 11, the procedure for eliminating the overlapping of a plurality of polygons will be described. In step S900, a set {V0, V1,..., Vn-1} of n vertex rows is prepared as plane area data. In steps S901 to S907, whether or not the two polygons represented by the two vertex rows overlap each other is sequentially performed on the n vertex rows, and the processing is completed for all the vertex rows. Determine. If it is determined in step S905 that the two polygons represented by the two vertex rows Vi and Vj overlap, the process proceeds to step S908.

ステップS908にて、頂点列ViのコピーVa、頂点列VjのコピーVbを作成し、平面領域データから、頂点列Vi、Vjを削除する。ステップS909にて、頂点列Va、Vbを頂点追跡法により、結合領域を囲む多角形と穴領域を囲む多角形に変換する。ステップS910にて、変換後の多角形の頂点列を平面領域データに追加する。ステップS911にて、更新後の平面領域データについて、再帰処理を行う。   In step S908, a copy Va of the vertex row Vi and a copy Vb of the vertex row Vj are created, and the vertex rows Vi and Vj are deleted from the plane area data. In step S909, the vertex rows Va and Vb are converted into a polygon surrounding the combined region and a polygon surrounding the hole region by the vertex tracking method. In step S910, the converted polygon vertex row is added to the plane area data. In step S911, recursion processing is performed on the updated planar area data.

(2-4) 図11のステップS905における、2個の多角形が重なり合うかどうかを判定する処理を説明する。ここでは、2個の多角形の間に交点があるかどうかを調べ、交点がある場合には重なり合うと判定し、交点がない場合には重なり合わないと判定する。処理(2-2)を施した後の平面領域データでは、2個の多角形の間に交点又は接点がある場合、それらの多角形を表す2個の頂点列に、必ず同一の座標値を有する頂点が存在することが保証されている。従って、2個の頂点列についてそれぞれの頂点の座標値を調べ、同じ座標値の頂点が見出された場合に、それは交点又は接点であると判定できる。   (2-4) Processing for determining whether or not two polygons overlap in step S905 in FIG. 11 will be described. Here, it is determined whether or not there is an intersection between the two polygons. If there is an intersection, it is determined that they overlap, and if there is no intersection, it is determined that they do not overlap. In the planar area data after processing (2-2), if there are intersections or contact points between two polygons, be sure to set the same coordinate value to the two vertex rows representing those polygons. It is guaranteed that there are vertices with. Therefore, the coordinate value of each vertex is examined for two vertex rows, and if a vertex having the same coordinate value is found, it can be determined that it is an intersection or a contact point.

図12を参照して、その頂点が交点又は接点であると判定されたとき、その頂点が交点と接点のどちらであるかを判定する方法を説明する。まず、2個の多角形をA、Bとし、それらの頂点の座標値を調べ、点pに等しい頂点が多角形AとBの両方に存在する、すなわち、点pが多角形AとBの間の交点又は接点であると分かったとする。多角形Aにおける点pに等しい頂点とその直前の頂点を結ぶ辺上の任意の点m1と、点pに等しい頂点とその直後の頂点を結ぶ辺上の任意の点m2を選ぶ。   With reference to FIG. 12, when it is determined that the vertex is an intersection or a contact, a method for determining whether the vertex is an intersection or a contact will be described. First, assume that two polygons are A and B, and the coordinate values of those vertices are examined, and vertices equal to point p exist in both polygons A and B, that is, point p is in polygons A and B. Suppose that it is an intersection or point of contact. In the polygon A, an arbitrary point m1 on the side connecting the vertex equal to the point p and the immediately preceding vertex, and an arbitrary point m2 on the side connecting the vertex equal to the point p and the immediately following vertex are selected.

そして、点m1とm2のいずれか一方が多角形Bの内部、他方が多角形Bの外部にある場合は点pは交点であり、点m1とm2の両方が多角形Bの外部又は内部にある場合は点pは接点であると判定する。例えば、図12(a)の場合は、点m1が多角形Bの内部、点m2が外部にあるからpは交点であり、図12(b)の場合は、点m1、m2が両方とも多角形Bの外部にあるから点pは接点であると判定できる。   If either point m1 or m2 is inside polygon B and the other is outside polygon B, point p is an intersection, and both points m1 and m2 are outside or inside polygon B. If there is, it is determined that the point p is a contact point. For example, in the case of FIG. 12 (a), point m1 is inside polygon B and point m2 is outside, so p is an intersection, and in FIG. 12 (b), both points m1 and m2 are many. Since it is outside the square B, it can be determined that the point p is a contact point.

また、本発明の目的から、2個の多角形の辺が重なる場合も重複解消処理の対象としなくてはならないので、例えば、図12(c)のように多角形AとBの辺が重なっている場合の点pも交点として取り扱う必要がある。図12(c)の場合について前述のように選んだ点m1、m2と多角形Bとの位置関係を見ると、点m1は多角形Bの外部、点m2は多角形Bの辺上にある。ここで、多角形の辺上の点は当該多角形の内部であると定義すれば、図12(c)の場合の点m2は多角形Bの内部にあると言えるので、図12(a)の場合と同様に、図12(c)の場合における点pも交点であると判定できるようになる。   Further, for the purpose of the present invention, when the sides of two polygons overlap each other, they must be subjected to the deduplication processing. For example, the sides of the polygons A and B overlap as shown in FIG. It is necessary to treat the point p as an intersection. In the case of FIG. 12C, when the positional relationship between the points m1 and m2 selected as described above and the polygon B is seen, the point m1 is outside the polygon B and the point m2 is on the side of the polygon B. . Here, if the point on the side of the polygon is defined to be inside the polygon, it can be said that the point m2 in the case of FIG. 12C is inside the polygon B. Therefore, FIG. Similarly to the case of FIG. 12, the point p in the case of FIG. 12C can be determined to be an intersection.

このことから、本発明における図形データ処理方法においては、多角形の辺上の点は当該多角形の内部にあると定義し、また、それとの整合性から、多角形の頂点と等しい点も当該多角形の内部にあると定義する。なお、上記説明中の点m1、m2の選び方としては、処理の簡便さを考慮して、点pとその直前又は直後の頂点を結ぶ辺の中点を選ぶ方法などが考えられる。   From this, in the graphic data processing method according to the present invention, the point on the side of the polygon is defined as being inside the polygon, and the point equal to the vertex of the polygon is also the point corresponding to the consistency with it. Defined as inside a polygon. In addition, as a method of selecting the points m1 and m2 in the above description, a method of selecting a midpoint of a side connecting the point p and the vertex immediately before or after it can be considered in consideration of the ease of processing.

上記の方法で交点かどうかを判定するには、任意の点が多角形の内部にあるかどうかを判定しなければならない。従来、任意の点が多角形の内部にあるかどうかを判定する方法としては、鉛直線算法による内点判定法が知られている。   In order to determine whether or not it is an intersection by the above method, it is necessary to determine whether or not an arbitrary point is inside the polygon. Conventionally, as a method for determining whether or not an arbitrary point is inside a polygon, an interior point determination method using a vertical line algorithm is known.

鉛直線算法による内点判定法とは、判定の対象とする点(以下、判定対象点という)から任意の方向に半直線を引き、その半直線が対象とする多角形と交差する回数を数え、それが偶数(0を含む)ならば当該判定対象点は当該多角形の外部にあり、奇数ならば内部にあると判定するものである。   The interior point determination method based on the vertical line algorithm is a method in which a half line is drawn in an arbitrary direction from a point to be determined (hereinafter referred to as a determination target point), and the number of times the half line intersects the target polygon is counted. If it is an even number (including 0), the determination target point is outside the polygon, and if it is an odd number, it is determined to be inside.

図13を参照して、鉛直線算法による内点判定法の具体的な手順について説明する。まず、判定対象点p1、点p2、点p3から半直線L1、L2、L3を引く。次に、多角形と半直線L1、L2、L3の交差回数を計算する。多角形と半直線L1の交差回数を計算する場合には、先ず、交差回数の初期値を0とし、6個の辺を順番に、辺と半直線L1との交差の有無について調べ、交差する場合には交差回数を1増加させる。例えば、辺abは半直線L1と交差するので交差回数を1増加させ、辺bc、cd、de、efは、半直線L1と交差しないので交差回数を変更せず、辺faは再び半直線L1と交差するので交差回数を1増加させる。結局、交差回数2(偶数)が得られ、判定対象点p1は多角形の外部にあると判定できる。同様の手順により、半直線L2については交差回数1(奇数)が得られ、判定対象点p2は多角形の内部にあると判定できる。   With reference to FIG. 13, the specific procedure of the interior point determination method by the vertical line calculation will be described. First, half straight lines L1, L2, and L3 are drawn from the determination target points p1, p2, and p3. Next, the number of intersections between the polygon and the half lines L1, L2, and L3 is calculated. When calculating the number of intersections between the polygon and the half line L1, first, the initial value of the number of intersections is set to 0, and the six sides are examined in turn for the presence or absence of intersection between the side and the half line L1. In some cases, increase the number of crossings by one. For example, the side ab intersects the half line L1, so the number of intersections is increased by 1, and the side bc, cd, de, and ef do not intersect the half line L1, so the number of intersections is not changed, and the side fa is again the half line L1 Increase the number of crossings by 1. Eventually, the intersection number 2 (even number) is obtained, and it can be determined that the determination target point p1 is outside the polygon. By the same procedure, the number of intersections 1 (odd number) is obtained for the half line L2, and it can be determined that the determination target point p2 is inside the polygon.

半直線L3は頂点bと頂点fを通る。このような場合に、その半直線が多角形と交差しているのか接しているのかを判別するために、特別な判定手順が必要となる。
具体的には、辺abについて調べたときには、半直線L3が辺abの終点bを通っていることと、辺abの始点aが半直線L3の方向に向かって左側にあることを記憶する。次に辺bcについて調べたときに、半直線L3が辺bcの始点bを通っていることと、辺bcの終点cが半直線L3の方向に向かって右側にあることを記憶する。それによって、半直線L3が通る頂点bの前後の頂点a及び頂点cが半直線L3の方向に向かって左側と右側に分かれていることが判明する。従って、半直線L3は頂点bでこの多角形と交差していると判定して交差回数を1増加させる。
The half line L3 passes through the vertex b and the vertex f. In such a case, a special determination procedure is required to determine whether the half line intersects or touches the polygon.
Specifically, when the side ab is examined, it is stored that the half line L3 passes through the end point b of the side ab and that the start point a of the side ab is on the left side in the direction of the half line L3. Next, when the side bc is examined, it is stored that the half line L3 passes through the start point b of the side bc and that the end point c of the side bc is on the right side in the direction of the half line L3. Thereby, it is found that the vertex a and the vertex c before and after the vertex b through which the half line L3 passes are divided into the left side and the right side in the direction of the half line L3. Therefore, it is determined that the half line L3 intersects this polygon at the vertex b, and the number of intersections is increased by one.

同様に、辺efについて調べたときには、半直線L3が辺fの終点fを通っていることと、辺efの始点eが半直線L3の方向に向かって左側にあることを記憶する。次に辺faについて調べたときに、半直線L3が辺faの始点fを通っていることと、辺faの終点aが半直線L3の方向に向かって左側にあることを記憶する。それによって、半直線L3が通る頂点fの前後の頂点e及び頂点aが半直線L3の方向に向かって同じ側にあることが判明する。従って、半直線L3は頂点fでこの多角形と接していると判定して交差回数は変更しない。   Similarly, when the side ef is examined, it is stored that the half line L3 passes through the end point f of the side f and that the start point e of the side ef is on the left side in the direction of the half line L3. Next, when the side fa is examined, it is memorized that the half line L3 passes through the start point f of the side fa and that the end point a of the side fa is on the left side in the direction of the half line L3. Thereby, it is found that the vertex e and the vertex a before and after the vertex f through which the half line L3 passes are on the same side in the direction of the half line L3. Accordingly, it is determined that the half line L3 is in contact with the polygon at the vertex f, and the number of intersections is not changed.

このような特別な判定手順を回避するために、例えば、特開昭61-180378号公報では、判定に用いる半直線が頂点を通る場合には、その半直線から平行にわずかに離れた位置、又は、判定対象点を中心としてわずかな角度回転させた位置に、多角形のどの頂点も通らない第2の半直線を設けて、第2の半直線と多角形の辺の交差回数を数える方法が提案されている。   In order to avoid such a special determination procedure, for example, in Japanese Patent Application Laid-Open No. 61-180378, when a half line used for determination passes through the apex, a position slightly parallel to the half line, Alternatively, a method is provided in which a second half line that does not pass through any vertex of the polygon is provided at a position rotated by a slight angle around the determination target point, and the number of intersections between the second half line and the side of the polygon is counted. Has been proposed.

前述のように、本発明における図形データ処理方法においては、多角形の辺上の点及び頂点と等しい点は当該多角形の内部にあると定義した。ここでは、従来の鉛直線算法による内点判定法によって、これを検証する。   As described above, in the graphic data processing method according to the present invention, the points on the sides of the polygon and the points equal to the vertices are defined to be inside the polygon. Here, this is verified by an interior point determination method using a conventional vertical line calculation method.

図14を参照して説明する。判定対象点p4、p5はいずれも多角形の辺上にあり、それらから半直線L4、L5を引く。半直線L4と多角形の辺との交差回数は、判定対象点p4における交差を含めて2回、半直線L5と多角形の辺との交差回数は、判定対象点p5における交差だけであり1回である。従って、判定対象点p4は多角形の外部、判定対象点p5は多角形の内部と判定される。また、判定対象点は半直線に含まないと定義すると、半直線L4と多角形の辺との交差回数は1回、半直線L5と多角形の辺との交差回数は0回となり、判定結果は逆になる。
さらに、半直線を引く方向をさまざまに変えた場合を考えると、判定対象点p4とp5についての判定結果は不定であることは明らかである。
This will be described with reference to FIG. The determination target points p4 and p5 are both on the sides of the polygon, and half lines L4 and L5 are drawn from them. The number of intersections between the half line L4 and the sides of the polygon is 2 including the intersection at the point to be judged p4, and the number of intersections between the half line L5 and the sides of the polygon is only the intersection at the point to be judged p5. Times. Therefore, the determination target point p4 is determined to be outside the polygon, and the determination target point p5 is determined to be inside the polygon. Also, if it is defined that the judgment target point is not included in the half line, the number of intersections of the half line L4 and the polygon side is 1, and the number of intersections of the half line L5 and the polygon side is 0. Is reversed.
Furthermore, considering the case where the direction of drawing the half-line is variously changed, it is clear that the determination results for the determination target points p4 and p5 are indefinite.

以上の検討から、従来の方法では、判定対象点を半直線に含むかどうかについてどのように定義しても、又は、半直線を引く方向をどのようにしても、辺上にある点について多角形の内部にあると判定することはできないことが分かる。特開昭61-180378号公報で提案されている方法も、この問題を解決するものではないことは明らかである。   From the above considerations, in the conventional method, no matter how the determination target point is included in the half line or how the half line is drawn, there are many points on the side. It can be seen that it cannot be determined that it is inside the square. It is obvious that the method proposed in Japanese Patent Application Laid-Open No. 61-180378 does not solve this problem.

(2-5) そこで、本発明では、鉛直線算法による内点判定法の原理を基本としつつ、次に述べるように、多角形の辺上の点及び頂点と等しい点を当該多角形の内部であると判定する手順を備えた内点判定法を提供する。
まず、鉛直線算法による内点判定法の原理に基づき、判定対象点から引いた半直線と多角形との周との交差回数を計数する手順について説明する。
(2-5) Therefore, in the present invention, based on the principle of the interior point determination method based on the vertical line algorithm, as described below, points on the sides of the polygon and points that are equal to the vertices are set inside the polygon. Provided is an interior point determination method including a procedure for determining that
First, a procedure for counting the number of intersections between the half line drawn from the determination target point and the circumference of the polygon based on the principle of the inner point determination method based on the vertical line calculation will be described.

判定対象点をpt(xt, yt)、多角形の頂点数をn、頂点列を{p0, p1, ... pi, ... pn-1}とし、鉛直線算法による内点判定に用いる半直線Ltを判定対象点ptからy軸と平行に且つy軸に正の方向に引く。   The point to be judged is pt (xt, yt), the number of vertices of the polygon is n, the vertex sequence is {p0, p1, ... pi, ... pn-1}, and is used for inner point judgment by vertical line algorithm A half line Lt is drawn from the determination target point pt in parallel to the y axis and in the positive direction along the y axis.

交差回数の初期値を0としたうえで、頂点pn-1を開始点とし、多角形の全周について、原則として辺を単位として調べていき、以下に説明する交差判定方法によって、半直線Ltと多角形の周が交差すると判定されたときに交差回数を1ずつ増加させることによって、交差回数を計数する。   The initial value of the number of intersections is set to 0, the vertex pn-1 is set as the starting point, the entire circumference of the polygon is examined in principle in units of edges, and the half straight line Lt is determined by the intersection determination method described below. The number of intersections is counted by increasing the number of intersections by 1 when it is determined that the perimeters of the polygons intersect.

上記半直線Ltと多角形の周の交差判定は、当該多角形のある辺についてみたとき、当該辺の両端の頂点が、いずれも判定対象点ptを通るy軸に平行な直線 x = xt 上にない場合(以下「ケースA」という)には、半直線Ltと当該辺が交差するか否かを判定することによって行い、当該辺の両端の頂点のいずれかが直線 x = xt 上にある場合(以下「ケースB」という)には、当該直線 x = xt 上にある頂点を間に挟み、かつ、直線 x = xt 上にない頂点を始点及び終点とする連続した複数の辺の範囲を選定し、当該辺の範囲において半直線Ltと多角形の周が交差するか否かを判定することによって行うことを基本とする。
ただし、判定対象点ptは多角形のどの頂点とも等しくなく、かつ、多角形のy軸に平行な辺上にはないものとする。
The above-mentioned determination of the intersection of the half-line Lt and the circumference of the polygon is based on a straight line x = xt parallel to the y-axis passing through the determination target point pt when both vertices of the side of the polygon are viewed If it is not (hereinafter referred to as “Case A”), it is determined by determining whether or not the corresponding side of the half-line Lt intersects, and one of the vertices at both ends of the side is on the line x = xt In the case (hereinafter referred to as “Case B”), a range of a plurality of continuous sides with a vertex on the straight line x = xt in between and a vertex not on the straight line x = xt as a start point and an end point is defined. Basically, the selection is performed by determining whether or not the circumference of the half line Lt and the polygon intersect in the range of the side.
However, it is assumed that the determination target point pt is not equal to any vertex of the polygon and is not on a side parallel to the y-axis of the polygon.

判定対象点ptが多角形の頂点のいずれかと等しい場合、あるいは、多角形のy軸に平行な辺上にある場合は、上記基本方針による交差判定手順は適用できないからであり、そのような場合の処理については、ケースCとして後述する。   If the point to be judged pt is equal to one of the vertices of the polygon, or if it is on a side parallel to the y-axis of the polygon, the intersection judgment procedure based on the above basic policy is not applicable. This process will be described later as case C.

ケースA
多角形のある辺pipi+1を見たとき、その両端の頂点が、いずれも直線 x = xt 上にない場合をケースAとする。
この場合は、半直線Ltと辺pipi+1が交差するか否かによって、頂点piとpi+1の間で半直線Ltが多角形の周と交差するか否かを判定する。
Case A
Case A is a case where when a side pipi + 1 with a polygon is viewed, none of its vertices are on the straight line x = xt.
In this case, whether or not the half line Lt intersects the circumference of the polygon between the vertices pi and pi + 1 is determined depending on whether or not the half line Lt and the side pipi + 1 intersect.

その方法を、図15(a)、図15(b)を参照して説明する。まず、判定対象点ptのx座標値xtが、辺の始点piのx座標値xiと、辺の終点pi+1のx座標値xi+1の範囲内にあるか否かを調べる。   The method will be described with reference to FIGS. 15 (a) and 15 (b). First, it is checked whether or not the x coordinate value xt of the determination target point pt is within the range of the x coordinate value xi of the start point pi of the side and the x coordinate value xi + 1 of the end point pi + 1 of the side.

判定対象点ptのx座標値xtが辺の始点piのx座標値xiと終点pi+1のx座標値xi+1の範囲外にある場合は、半直線Ltと辺pipi+1が交差することはないと判定できるで、交差回数を変更せずに、次の辺pi+1pi+2についての交差判定に移る。
判定対象点ptのx座標値xtが辺の始点piのx座標値xiと終点pi+1のx座標値xi+1の範囲内にあれば、半直線Ltと辺pipi+1が交差する可能性があると判定できる。
If the x coordinate value xt of the judgment target point pt is outside the range of the x coordinate value xi of the start point pi of the side and the x coordinate value xi + 1 of the end point pi + 1, the half line Lt and the side pipi + 1 intersect Since it can be determined that there is no such thing, the process proceeds to the intersection determination for the next side pi + 1pi + 2 without changing the number of intersections.
If the x coordinate value xt of the judgment target point pt is within the range of the x coordinate value xi of the start point pi of the side and the x coordinate value xi + 1 of the end point pi + 1, the half line Lt and the side pipi + 1 can intersect. It can be determined that there is sex.

図15(a)、図15(b)は、いずれも判定対象点ptのx座標値xt が辺の始点piのx座標値xiと終点pi+1のx座標値xi+1の範囲内にあるので、半直線Ltと辺pipi+1が交差する可能性があると判定できる場合の例である。   15 (a) and 15 (b), the x coordinate value xt of the judgment target point pt is within the range of the x coordinate value xi of the start point pi and the x coordinate value xi + 1 of the end point pi + 1. This is an example of a case where it can be determined that there is a possibility that the half line Lt and the side pipi + 1 intersect.

このように、半直線Ltと辺pipi+1が交差する可能性があると判定された場合には、次に、判定対象点ptを通るy軸に平行な直線 x = xt と辺pipi+1の交点pcのy座標値ycを求め、それと判定対象点のy座標値ytとの大小関係を調べる。   Thus, if it is determined that there is a possibility that the half line Lt and the side pipi + 1 intersect, then the straight line x = xt passing through the determination target point pt and the side pipi + 1 The y coordinate value yc of the intersection pc of is obtained, and the magnitude relationship between it and the y coordinate value yt of the determination target point is examined.

図15(a)のように、交点pcのy座標値ycが判定対象点のy座標値ytより大きい、即ち、yc>ytならば、半直線Ltは辺pipi+1と交差すると判定し、交差回数を1増加させ、次の辺pi+1pi+2についての交差判定に移る。   As shown in FIG. 15 (a), if the y-coordinate value yc of the intersection pc is larger than the y-coordinate value yt of the determination target point, that is, if yc> yt, it is determined that the half line Lt intersects the side pipi + 1. Increase the number of intersections by 1 and move to the intersection determination for the next side pi + 1pi + 2.

図15(b)のように、交点pcのy座標値ycが判定対象点のy座標値ytより小さい、即ち、yc<ytならば、半直線Ltは辺pipi+1と交差しないと判定し、交差回数を変更せずに、次の辺pi+1pi+2についての交差判定に移る。   As shown in FIG. 15 (b), if the y-coordinate value yc of the intersection pc is smaller than the y-coordinate value yt of the determination target point, that is, if yc <yt, it is determined that the half line Lt does not intersect the side pipi + 1. Without changing the number of intersections, the process proceeds to the intersection determination for the next side pi + 1pi + 2.

交点pcのy座標値ycが判定対象点のy座標値ytに等しい、即ち、yc=yt のときは、判定対象点ptは辺pipi+1上にあるので、ptは多角形の辺上にあると判定する。   The y coordinate value yc of the intersection pc is equal to the y coordinate value yt of the judgment target point, that is, when yc = yt, the judgment target point pt is on the side pipi + 1, so pt is on the side of the polygon Judge that there is.

ここで、本発明においては、前述のように多角形の辺上の点は、多角形の内部にあると定義したので、判定対象点ptが多角形の辺上にあると判定された場合には、判定対象点ptは多角形の内部にあると判定して、内点判定処理を終了する。   Here, in the present invention, as described above, since the point on the side of the polygon is defined as being inside the polygon, when the determination target point pt is determined to be on the side of the polygon, Determines that the determination target point pt is inside the polygon, and ends the inner point determination process.

ケースB
多角形のある辺pipi+1を見たとき、その両端のうち、いずれか一方の頂点が、直線 x = xt上にある場合をケースBとする。
まず、辺pipi+1の終点pi+1が、直線 x = xt上にある場合、すなわち、判定対象点ptのx座標値xtと終点pi+1のx座標値xi+1が等しい場合について考える。
Case B
Case B is a case where when one side pipi + 1 of a polygon is viewed, one of its vertices is on the straight line x = xt.
First, consider the case where the end point pi + 1 of the side pipi + 1 is on the straight line x = xt, that is, the x coordinate value xt of the determination target point pt is equal to the x coordinate value xi + 1 of the end point pi + 1. .

この場合は、頂点pi+1において半直線Ltが多角形の周と交差する可能性があるが、半直線Ltと辺pipi+1の相対的な位置関係を調べるだけでは、交差するのか接するだけなのかを判別することはできない。   In this case, there is a possibility that the half-line Lt intersects the circumference of the polygon at the vertex pi + 1, but just examining the relative positional relationship between the half-line Lt and the side pipi + 1 just touches or intersects It cannot be determined.

そこで判定対象点ptのx座標値xtと終点pi+1のx座標値xi+1が等しい場合、即ち、xt = xi+1の場合には、頂点piを始点とし、頂点pi+1から出発して1個ずつ頂点を前進させていき、最初に直線 x = xt上からはずれた頂点を終点とする、連続した複数の辺を選定し、当該連続する複数の辺の範囲において、半直線Ltが多角形の周と交差するか否かを判定することとする。   Therefore, if the x-coordinate value xt of the judgment target point pt is equal to the x-coordinate value xi + 1 of the end point pi + 1, that is, if xt = xi + 1, the vertex pi is taken as the starting point and the starting point is the vertex pi + 1. Then, the vertexes are advanced one by one, and first, a plurality of continuous sides with the vertex deviating from the straight line x = xt as the end point are selected, and the half line Lt It is determined whether or not intersects with the circumference of the polygon.

ここで、ケースAの場合の単一の辺も、上記のように選定した連続した複数の辺も、半直線Ltと交差するか否かの判定対象とする多角形の周の一部であるという意味においては同じものであるので、以下の説明において、両者を総称して「判定対象の辺の範囲」と言うこととする。   Here, the single side in case A and a plurality of continuous sides selected as described above are part of the circumference of the polygon to be determined as to whether or not the half line Lt intersects. In the following description, both are collectively referred to as “a range of sides to be determined”.

図15(c)、図15(d)、図15(e)、図15(f)を参照して、ケースBの場合の「判定対象の辺の範囲」の終点の選定手順と、当該「判定対象の辺の範囲」において半直線Ltが多角形の周と交差するか否かの判定手順について説明する。   With reference to FIG. 15 (c), FIG. 15 (d), FIG. 15 (e), FIG. 15 (f), in the case of Case B, the selection procedure of the end point of `` the range of the side to be determined '' and the `` A procedure for determining whether or not the half line Lt intersects the circumference of the polygon in the “range of sides to be determined” will be described.

図15(c)、図15(d)、図15(e)、図15(f)の辺pipi+1についてみたとき、xt = xi+1なので、頂点pi+1から出発して1個ずつ頂点を前進させていき、最初に直線 x = xt上からはずれた頂点を「判定対象の辺の範囲」の終点として選ぶ。   When looking at the side pipi + 1 in Fig. 15 (c), Fig. 15 (d), Fig. 15 (e), Fig. 15 (f), since xt = xi + 1, one by one starting from the vertex pi + 1 The vertex is moved forward, and the vertex that deviates from the straight line x = xt is first selected as the end point of the “side range to be judged”.

以下、このように選んだ「判定対象の辺の範囲」の終点をpeで表すこととする。例えば、図15(c)、図15(d)では頂点pi+2を、図15(e)、図15(f)では頂点pi+3を、終点peに選ぶことになる。   Hereinafter, the end point of the “side range to be determined” selected in this way is represented by pe. For example, the vertex pi + 2 is selected as the end point pe in FIGS. 15 (c) and 15 (d), and the vertex pi + 3 is selected in FIGS. 15 (e) and 15 (f).

次に、判定対象点ptのx座標値xtが、「判定対象の辺の範囲」の始点piのx座標値xiと終点peのx座標値xeの範囲内にあるか否かを調べる。
図15(f)のように、判定対象点ptのx座標値xtが始点piのx座標値xiと終点peのx座標値xeの範囲内になければ、半直線Ltが始点piと終点peの間で多角形の周と交差する可能性がないと判定できるので、交差回数を変更せずに、このときの終点peを始点とする次の「判定対象の辺の範囲」についての交差判定に移る。
Next, it is checked whether or not the x coordinate value xt of the determination target point pt is within the range of the x coordinate value xi of the start point pi and the x coordinate value xe of the end point pe of “the range of the determination target side”.
As shown in FIG. 15 (f), if the x coordinate value xt of the determination target point pt is not within the range of the x coordinate value xi of the start point pi and the x coordinate value xe of the end point pe, the half line Lt is the start point pi and the end point pe. Since it can be determined that there is no possibility of intersecting with the circumference of the polygon between, the intersection determination for the next "range of sides to be judged" starting from the end point pe at this time without changing the number of intersections Move on.

図15(c)、図15(d)、図15(e)のように、判定対象点ptのx座標値xtが始点piのx座標値xiと終点peのx座標値xeの範囲内にあれば、半直線Ltが「判定対象の辺の範囲」pipeの間で多角形の周と交差する可能性があると判定できる。   As shown in FIGS. 15 (c), 15 (d), and 15 (e), the x coordinate value xt of the determination target point pt is within the range of the x coordinate value xi of the start point pi and the x coordinate value xe of the end point pe. If there is, it can be determined that there is a possibility that the half straight line Lt may intersect the circumference of the polygon between the “range of sides to be determined” pipe.

図15(c)、図15(d)、図15(e)のように、半直線Ltが「判定対象の辺の範囲」pipeにおいて多角形の周と交差する可能性があると判定された場合には、始点piと終点peの間の頂点(直線 x = xt上にある)のy座標値と、判定対象点ptのy座標値ytとの大小関係を調べる。   As shown in FIG. 15 (c), FIG. 15 (d), and FIG. 15 (e), it is determined that there is a possibility that the half line Lt may intersect the circumference of the polygon in the “side range to be determined” pipe. In this case, the magnitude relationship between the y coordinate value of the vertex (on the straight line x = xt) between the start point pi and the end point pe and the y coordinate value yt of the determination target point pt is examined.

図15(c)、図15(d)の例では、始点piと終点pe(=pi+2)の間の頂点はpi+1の1個だけなので、頂点pi+1のy座標値yi+1と判定対象点ptのy座標値ytとの大小関係を調べればよい。
図15(e)の例では、始点piと終点pe(=pi+3)の間の頂点は、pi+1, pi+2の2個であるが、それらのy座標値と判定対象点ptのy座標値ytとの大小関係は一様である。
In the example of FIGS. 15 (c) and 15 (d), since there is only one vertex pi + 1 between the start point pi and the end point pe (= pi + 2), the y coordinate value yi + of the vertex pi + 1 What is necessary is just to investigate the magnitude relationship between 1 and the y coordinate value yt of the determination target point pt.
In the example of FIG. 15 (e), there are two vertices, pi + 1 and pi + 2, between the start point pi and the end point pe (= pi + 3). The y-coordinate value y is uniform.

さらに、始点piと終点peの間の頂点が3個以上あることも想定できるが、その場合でも、頂点pi+1は必ずそれらの頂点の内の1個であり、かつ、それらの頂点のy座標値と判定対象点ptのy座標値ytとの大小関係は一様である。   Furthermore, it can be assumed that there are three or more vertices between the start point pi and the end point pe, but even in that case, the vertex pi + 1 is always one of those vertices, and y of those vertices The magnitude relationship between the coordinate value and the y coordinate value yt of the determination target point pt is uniform.

したがって、始点piと終点peの間の頂点が複数ある場合でも、頂点pi+1でそれらを代表させ、頂点pi+1のy座標値yi+1と判定対象点ptのy座標値ytとの大小関係を調べることとする。   Therefore, even when there are a plurality of vertices between the start point pi and the end point pe, the vertex pi + 1 represents them, and the y coordinate value yi + 1 of the vertex pi + 1 and the y coordinate value yt of the determination target point pt Investigate the magnitude relationship.

頂点pi+1のy座標値yi+1と判定対象点ptのy座標値ytの大小関係を調べた結果、図15(c)、図15(e)のように、yi+1>ytならば、半直線Ltは、「判定対象の辺の範囲」pipeにおいて多角形の周と交差すると判定できるので、交差回数を1増加させ、このときの終点peを始点とする次の「判定対象の辺の範囲」についての交差判定に移る。   As a result of examining the magnitude relationship between the y coordinate value yi + 1 of the vertex pi + 1 and the y coordinate value yt of the determination target point pt, as shown in FIGS. 15 (c) and 15 (e), if yi + 1> yt For example, the half straight line Lt can be determined to intersect with the circumference of the polygon in the “side range to be determined” pipe, so the number of intersections is increased by 1, and the next “determination target to be determined” starting from the end point pe at this time The process proceeds to the intersection determination for “side range”.

図15(d)の例のように、yi+1<ytならば、半直線Ltは、「判定対象の辺の範囲」pipeにおいて多角形の周と交差しないと判定できるので、交差回数を変更せずに、このときの終点peを始点とする次の「判定対象の辺の範囲」についての交差判定に移る。
ここで、上記説明のように選んだ「判定対象の辺の範囲」の終点は、直線 x = xt 上にないことが保証されている。
As in the example of Fig. 15 (d), if yi + 1 <yt, the straight line Lt can be determined not to intersect the circumference of the polygon in the "range of sides to be judged" pipe, so the number of intersections is changed Without proceeding, the process proceeds to the intersection determination for the next “range of sides to be determined” starting from the end point pe at this time.
Here, it is guaranteed that the end point of the “determined side range” selected as described above is not on the straight line x = xt.

また、「判定対象の辺の範囲」の始点は、直前の処理における「判定対象の辺の範囲」の終点である。したがって、原則として、「判定対象の辺の範囲」の始点が直線 x = xt上にあることはないことが分かる。   Also, the start point of the “determination target side range” is the end point of the “determination target side range” in the immediately preceding process. Therefore, in principle, it can be seen that the starting point of the “range of sides to be judged” is not on the straight line x = xt.

ただし、計数処理を始めるときの開始点pn-1だけは、直線 x = xt上にある可能性がある。そこで、pn-1が直線 x = xt上にある場合をケースBの特殊ケースとして扱うこととし、その場合の「判定対象の辺の範囲」の設定手順と、当該「判定対象の辺の範囲」において半直線Ltと多角形の周と交差するか否かの判定手順について説明する。   However, only the starting point pn-1 when starting the counting process may be on the straight line x = xt. Therefore, the case where pn-1 is on the straight line x = xt is treated as a special case of Case B. In that case, the procedure for setting the "side range to be judged" and the "range of the side to be judged" A procedure for determining whether or not the half line Lt intersects the circumference of the polygon will be described.

まず、開始点pn-1から出発して頂点を1個ずつ遡り、最初に直線 x = xt上からはずれた頂点を選ぶ。例えば、頂点pn-2が直線 x = xt上になければ、頂点pn-2を選び、頂点pn-2もまた直線 x = xt上にあれば、さらに頂点を1個遡る、という処理を繰り返せばよい。
このように選んだ頂点が、開始点pn-1が直線 x = xt上にあった場合の「判定対象の辺の範囲」の始点であり、以下、psで表すこととする。
この場合、多角形の周と半直線Ltの交差回数の計数処理の開始点もpsに変更されたことになる。
First, start from the starting point pn-1, go back one vertex at a time, and first select a vertex that deviates from the straight line x = xt. For example, if the vertex pn-2 is not on the straight line x = xt, select the vertex pn-2, and if the vertex pn-2 is also on the straight line x = xt, repeat the process of going back one vertex. Good.
The vertex selected in this way is the start point of “the range of the side to be determined” when the start point pn-1 is on the straight line x = xt, and is represented by ps hereinafter.
In this case, the starting point of the counting process of the number of intersections between the circumference of the polygon and the half line Lt is also changed to ps.

頂点pn-1が直線 x = xt上にあった場合の最初の「判定対象の辺の範囲」の終点について説明する。上記のように最初の「判定対象の辺の範囲」の始点psが選ばれた時点で、その終点は頂点p0に仮定されている。ここで、頂点p0が直線 x = xt上になければ、頂点p0を最初の「判定対象の辺の範囲」の終点peとして決定する。   The end point of the first “range of sides to be judged” when the vertex pn-1 is on the straight line x = xt will be described. As described above, when the start point ps of the first “range of sides to be determined” is selected, the end point is assumed to be the vertex p0. If the vertex p0 is not on the straight line x = xt, the vertex p0 is determined as the end point pe of the first “range of sides to be determined”.

しかし、頂点p0もまた直線 x = xt上にあった場合には、前述の「判定対象の辺の範囲」の終点を選ぶ手順によって、頂点p0から出発して頂点を1個ずつ前進させ、最初に直線 x = xt上からはずれた頂点を、最初の「判定対象の辺の範囲」の終点peとして選ばよい。   However, if the vertex p0 is also on the straight line x = xt, the procedure for selecting the end point of the above-mentioned “range of sides to be judged” starts the vertex p0 and advances the vertex one by one. A vertex deviating from the straight line x = xt may be selected as the end point pe of the first “range of sides to be judged”.

次に、以上のように設定された最初の「判定対象の辺の範囲」pspeにおいて、半直線Ltと多角形の周が交差するか否かを判定する手順について説明する。   Next, the procedure for determining whether or not the half line Lt and the circumference of the polygon intersect in the first “range of sides to be determined” pspe set as described above will be described.

まず、判定対象点ptのx座標値xtが、始点psのx座標値xsと、終点peのx座標値xeの範囲内にあるか否かを調べる。   First, it is checked whether or not the x coordinate value xt of the determination target point pt is within the range of the x coordinate value xs of the start point ps and the end point pe.

判定対象点ptのx座標値xtが始点psのx座標値xsと終点peのx座標値xeの範囲内になければ、半直線Ltが始点psと終点peの間で多角形の周と交差する可能性がないと判定できるので、交差回数を変更せずに、このときの終点peを始点とする次の「判定対象の辺の範囲」についての交差判定に移る。   If the x-coordinate value xt of the judgment target point pt is not within the range of the x-coordinate value xs of the start point ps and the x-coordinate value xe of the end point pe, the half line Lt intersects the circumference of the polygon between the start point ps and the end point pe Since it can be determined that there is no possibility of making an intersection, without changing the number of intersections, the process proceeds to the intersection determination for the next “range of sides to be determined” starting at the end point pe at this time.

判定対象点ptのx座標値xtが始点psのx座標値xsと終点peのx座標値xeの範囲内にあれば、半直線Ltが「判定対象の辺の範囲」pspeの間で多角形の周と交差する可能性があると判定できる。   If the x-coordinate value xt of the judgment target point pt is within the range of the x-coordinate value xs of the start point ps and the x-coordinate value xe of the end point pe, the half line Lt is a polygon between the "side range of judgment target" pspe It can be determined that there is a possibility of intersecting with

このように、半直線Ltが「判定対象の辺の範囲」pspeにおいて多角形の周と交差する可能性があると判定された場合には、始点psと終点peの間にある頂点(直線 x = xt 上にある)と、判定対象点ptのy座標値ytとの大小関係を調べる。   In this way, when it is determined that the half line Lt may intersect the circumference of the polygon in the “range of sides to be determined” pspe, the vertex between the start point ps and the end point pe (straight line x = on xt) and the y-coordinate value yt of the determination target point pt is examined.

ここで、上記の始点psの選定手順から分かるように、頂点pn-1は「判定対象の辺の範囲」pspeの間の頂点の内の1個であるから、頂点pn-1で「判定対象の辺の範囲」pspeの間の頂点を代表させ、頂点pn-1のy座標値yn-1と判定対象点ptのy座標値ytとの大小関係を調べることとする。   Here, as can be seen from the above selection procedure of the start point ps, the vertex pn-1 is one of the vertices between the “range of sides to be judged” pspe. Let us suppose that the vertex in the range of “side” pspe is represented, and examine the magnitude relationship between the y coordinate value yn-1 of the vertex pn-1 and the y coordinate value yt of the determination target point pt.

頂点pn-1のy座標値yn-1と判定対象点ptのy座標値ytの大小関係を調べた結果、yn-1>ytならば、半直線Ltは、最初の「判定対象の辺の範囲」pspeにおいて多角形の周と交差すると判定できるので、交差回数を1増加させ、このときの終点peを始点とする次の「判定対象の辺の範囲」についての交差判定に移る。   As a result of examining the magnitude relationship between the y-coordinate value yn-1 of the vertex pn-1 and the y-coordinate value yt of the determination target point pt, if yn-1> yt, the half line Lt is the first " Since it can be determined that the area “pspe” intersects the circumference of the polygon, the number of intersections is increased by 1, and the process proceeds to the intersection determination for the next “range of determination target sides” starting from the end point pe at this time.

yn-1<ytならば、半直線Ltは、最初の「判定対象の辺の範囲」pspeにおいて多角形の周と交差しないと判定できるので、交差回数を変更せずに、このときの終点peを始点とする次の「判定対象の辺の範囲」についての交差判定に移る。   If yn-1 <yt, it can be determined that the half-line Lt does not intersect with the circumference of the polygon in the first "range of sides to be judged" pspe, so the end point pe at this time can be changed without changing the number of intersections. The process proceeds to the intersection determination for the next “range of sides to be determined” starting from.

以上のように、計数処理を開始するときの最初の辺の始点pn-1が直線 x = xt上にあった場合でも、開始点を遡って最初の「判定対象の辺の範囲」を設定することによって、半直線Ltとの交差判定が可能となった。   As described above, even if the start point pn-1 of the first side when the counting process is started is on the straight line x = xt, the first “range of sides to be judged” is set by going back to the start point. This makes it possible to determine the intersection with the half line Lt.

ここまでのケースAとケースBについての検討により、判定対象点ptが多角形のどの頂点とも等しくなく、かつ、多角形のy軸に平行な辺上にはない場合においては、鉛直線算法の原理を応用して、判定対象点ptからy軸と平行に且つy軸に正の方向に引いた半直線Ltと多角形の周との交差回数の計数処理が可能になり、かつ、それと一体的な手順の中で、判定対象点が辺上にある場合についても判定することが可能となった。   Based on the examination of Case A and Case B so far, if the target point pt is not equal to any vertex of the polygon and is not on a side parallel to the y-axis of the polygon, the vertical line algorithm By applying the principle, it is possible to count the number of intersections between the half-line Lt drawn in parallel with the y-axis from the judgment target point pt and in the positive direction of the y-axis and the circumference of the polygon, and integrated with it. In a typical procedure, the determination can be made even when the determination target point is on the side.

ケースC
判定対象点ptが多角形の頂点のいずれかと等しい場合、及び、判定対象点ptが多角形のy軸に平行な辺上にある場合をケースCとする。
前述のように、本発明においては、多角形の頂点上の点、辺上の点は当該多角形の内部であると定義したので、ケースCの場合には、判定対象点ptは多角形の内部にあると判定しなくてはならない。
Case C
Case C is a case where the determination target point pt is equal to one of the vertices of the polygon, and a case where the determination target point pt is on a side parallel to the y axis of the polygon.
As described above, in the present invention, the point on the vertex of the polygon and the point on the side are defined to be inside the polygon. Therefore, in the case C, the determination target point pt is a polygon. It must be determined that it is inside.

ケースCの場合には、これまでに説明した鉛直線算法の原理の応用による内点判定処理では正しく判定ができないため、鉛直線算法の原理の応用による内点判定処理を行う前に、多角形の全ての辺を順番に辿りつつ、各辺について以下の判定処理を行うことにより、ケースCに該当するか否かを判定するものとする。   In case C, the interior point determination process based on the application of the principle of the vertical line algorithm described above cannot be performed correctly. Therefore, before performing the interior point determination process based on the application of the principle of the vertical line algorithm, the polygon It is determined whether or not the case C is satisfied by performing the following determination process for each side while tracing all the sides in order.

まず、判定対象点ptが辺の始点と等しいか否かを判定する。ここで、判定対象点ptが辺の始点と等しいと判定された場合には、判定対象点ptは多角形の内部にあると判定して、内点判定処理を終了する。
判定対象点ptが辺の始点と等しくない場合には、当該辺がy軸に平行であり、かつ、判定対象点ptが当該辺上にあるか否かを判定する。
First, it is determined whether the determination target point pt is equal to the start point of the side. Here, if it is determined that the determination target point pt is equal to the start point of the side, it is determined that the determination target point pt is inside the polygon, and the interior point determination process is terminated.
If the determination target point pt is not equal to the start point of the side, it is determined whether or not the side is parallel to the y axis and the determination target point pt is on the side.

ここで、当該辺がy軸に平行であり、かつ、判定対象点ptが当該辺上にあると判定された場合には、判定対象点ptは多角形の内部にあると判定して、内点判定処理を終了する。
当該辺がy軸に平行でないか、または、y軸に平行であっても、判定対象点ptが当該辺上にないと判定された場合には、次の辺についての上記処理を繰り返す。
Here, when it is determined that the side is parallel to the y-axis and the determination target point pt is on the side, the determination target point pt is determined to be inside the polygon, The point determination process ends.
Even if the side is not parallel to the y-axis or is parallel to the y-axis, if it is determined that the determination target point pt is not on the side, the above processing for the next side is repeated.

多角形の全ての辺について上記処理を行っても、判定対象点ptが多角形の内部にあると判定されなかったならば、ケースCには該当しないので、前述の鉛直線算法の原理を応用した内点判定処理に移れば良い。   Even if the above processing is performed on all sides of the polygon, if it is not determined that the target point pt is inside the polygon, it does not fall under Case C, so the above-mentioned principle of the vertical line algorithm is applied. What is necessary is just to move to the inner point determination process.

(2-6) 図11のステップS909における、重なり合う2個の多角形の頂点列Va、Vbを変換する処理の手順を、図16の例を参照しながら説明する。AとBはそれぞれ11個の頂点を持つ多角形で、それらの頂点列Va、Vbをそれぞれ{a0, a1, a2, .... a10}、{b0, b1, b2, ..., b10}とし、図のように重なり合っているものとする。また、これらの多角形は、(2-1)、(2-2)の処理を終了したものであり、頂点列の方向はどちらも時計回りで統一されており、両方の頂点列には交点に等しい頂点がすでに挿入されていることを前提とする。図の記号で言えば、頂点a3とb7、a5とb5、a7とb3、a9とb1の組がそれぞれ等しく、かつ、交点と等しい頂点である。   (2-6) The procedure of the process of converting the vertex strings Va and Vb of two overlapping polygons in step S909 of FIG. 11 will be described with reference to the example of FIG. A and B are polygons each having 11 vertices, and their vertex arrays Va and Vb are {a0, a1, a2, .... a10}, {b0, b1, b2, ..., b10, respectively. } And overlapping as shown in the figure. In addition, these polygons are the ones that have completed the processing of (2-1) and (2-2), and the directions of the vertex rows are both unified in the clockwise direction. It is assumed that a vertex equal to is already inserted. In terms of the symbols in the figure, the vertexes a3 and b7, a5 and b5, a7 and b3, and a9 and b1 are equal to each other, and the vertex is equal to the intersection.

まず、頂点列Va、Vbから、交点に等しい頂点を始終点とした次のような頂点列の集合を作成する。
Sa = { Va0{a3, a4, a5}, Va1{a5, a6, a7}, Va2{a7, a8, a9}, Va3{a9, a10, a0, a1, a2, a3} }
Sb = { Vb0{b1, b2, b3}, Vb1{b3, b4, b5}, Vb2{b5, b6, b7}, Vb3{b7, b8, b9, b10, b0, b1} }
First, from the vertex rows Va and Vb, a set of the following vertex rows with the vertices equal to the intersection as the start and end points is created.
Sa = {Va0 {a3, a4, a5}, Va1 {a5, a6, a7}, Va2 {a7, a8, a9}, Va3 {a9, a10, a0, a1, a2, a3}}
Sb = {Vb0 {b1, b2, b3}, Vb1 {b3, b4, b5}, Vb2 {b5, b6, b7}, Vb3 {b7, b8, b9, b10, b0, b1}}

次に、集合Saの中から1個の頂点列、例えばVa0を選び、続いて、その終点a5と等しい始点を持つ集合Sbの要素を選ぶ。ここでは、頂点a5とb5が等しいから、頂点b5を始点とする頂点列Vb2が選ばれる。このとき、頂点列Vb2の終点b7は、頂点列Va0の始点a3と等しい。   Next, one vertex row, for example, Va0 is selected from the set Sa, and then an element of the set Sb having a start point equal to the end point a5 is selected. Here, since the vertices a5 and b5 are equal, the vertex row Vb2 starting from the vertex b5 is selected. At this time, the end point b7 of the vertex row Vb2 is equal to the start point a3 of the vertex row Va0.

このように選んだ頂点列Va0とVb2を、それぞれ終点を削除した上で連結し、頂点列V0{a3, a4, b5, b6 }を得る。以後、頂点列Va1、Va2、Va3を順次選んで同様の処理をすることによって、頂点列V1{a5, a6, b3, b4}、V2{a7, a8, b1, b2}、V3{a9, a10, a0, a1, a2, b7, b8, b9, b10, b0}が得られる。   The vertex trains Va0 and Vb2 selected in this way are connected after deleting their end points to obtain a vertex train V0 {a3, a4, b5, b6}. Thereafter, the vertex rows Va1, Va2, Va3 are sequentially selected and processed in the same manner, whereby the vertex rows V1 {a5, a6, b3, b4}, V2 {a7, a8, b1, b2}, V3 {a9, a10 , a0, a1, a2, b7, b8, b9, b10, b0}.

このようにして得られた頂点列について前述の頂点列の方向判定法を用いて、頂点列V0、V2、V3を時計回り、頂点列V1を反時計回りに分類する。
時計回りの頂点列のうち、それらが囲む領域の面積が最大のもの、この場合は頂点列V3が結合領域を囲む多角形のデータ、反時計回りの頂点列V1が穴領域を囲む多角形のデータであるので、これらを頂点列VaとVbの変換後の多角形とする。
For the vertex rows obtained in this way, the vertex rows V0, V2, and V3 are classified clockwise and the vertex row V1 is classified counterclockwise using the above-described vertex row direction determination method.
Among the clockwise vertices, the area of the area that they enclose is the largest, in this case the vertices V3 is the polygon data that surrounds the combined area, the counterclockwise vertices V1 is the polygon that surrounds the hole area Since this is data, these are polygons after the conversion of the vertex rows Va and Vb.

なお、変換前の2個の多角形の辺が重なっている場合にこのような手順で頂点列を生成すると、当該辺の両端の2頂点だけからなる頂点列が生成される。これは、面積のない線分であり、平面領域を表すデータに含む必要はないので、変換後の頂点列の頂点数が3個未満のものは、更新後の平面領域データには追加しないことにより排除すれば良い。   Note that when a vertex row is generated by such a procedure when two polygon sides before conversion overlap, a vertex row composed of only two vertices at both ends of the side is generated. This is a line segment with no area and does not need to be included in the data representing the planar area, so if the number of vertices in the converted vertex row is less than 3, do not add it to the updated planar area data Can be eliminated.

(3) 入れ子状多角形頂点列方向調整
平面領域を構成する多角形に入れ子状になっている多角形が存在する場合には、次のような処理によって、頂点列方向を調整する。
まず、平面領域に存在するn個の多角形を表す頂点列の格納順を、多角形の面積の降順に並び替える。並び替えられたn個の多角形P0, P1, ..., Pn-1の面積A0, A1, ..., An-1は、A0≧A1≧... ≧An-1の関係となる。先ず、面積最大の多角形P0を選択し、多角形P0とそれより面積が小さい多角形との間の内包関係を調べる。多角形P0の頂点列を時計回りにし、多角形P0に内包される全ての多角形の頂点列を反時計回りにし、多角形P0に内包されない全ての多角形の頂点列を時計回りにする。
(3) Nested polygon vertex row direction adjustment When there are polygons that are nested in the polygons forming the planar area, the vertex row direction is adjusted by the following process.
First, the storage order of vertex rows representing n polygons existing in the planar area is rearranged in descending order of polygon area. The areas A0, A1, ..., An-1 of the n rearranged polygons P0, P1, ..., Pn-1 have the relationship A0≥A1≥ ... ≥An-1 . First, the polygon P0 having the largest area is selected, and the inclusion relation between the polygon P0 and the polygon having a smaller area is examined. The vertex row of the polygon P0 is turned clockwise, the vertex rows of all polygons contained in the polygon P0 are turned counterclockwise, and the vertex rows of all polygons not contained in the polygon P0 are turned clockwise.

次に、2番目に面積が大きい多角形P1を選択し、多角形P1とそれより面積が小さい多角形との間の内包関係を調べる。多角形P1の頂点列はそのままにし、多角形P1に内包される全ての多角形の頂点列の方向を反転させ、多角形P1に内包されない且つ多角形P1より面積が小さい多角形の頂点列はそのままにする。   Next, the polygon P1 having the second largest area is selected, and the inclusion relation between the polygon P1 and the polygon having the smaller area is examined. The vertex sequence of the polygon P1 is left as it is, the direction of the vertex sequence of all polygons contained in the polygon P1 is reversed, and the polygon vertex sequence that is not contained in the polygon P1 and has a smaller area than the polygon P1 is leave it as it is.

以下、添字番号を1ずつ増やしながらn-2まで、処理を繰り返す。面積が2番目に小さい多角形Pn-2について処理が終了すると、全ての多角形の頂点列の方向が確定する。処理が終了すると、内包関係、即ち、入れ子状態にある多角形について、内側の多角形の頂点列の方向は、そのすぐ外側の多角形の頂点列の方向と反対になる。従って、全ての多角形において、頂点列の方向に向かって右側が内部領域となる。   Thereafter, the process is repeated up to n-2 while increasing the subscript number by one. When the processing is finished for the polygon Pn-2 having the second smallest area, the directions of the vertex rows of all the polygons are determined. When the process is completed, the direction of the vertex row of the inner polygon is opposite to the direction of the vertex row of the polygon just outside the inner relation, that is, the nested polygon. Therefore, in all polygons, the right side in the direction of the vertex row is an internal region.

図17を参照して具体例について説明する。図17(a)に示すように、6個の多角形P0, P1, P2, P3, P4, P5の面積A0, A1, A2, A3, A4, A5の大小関係を、A0≧ A1≧ A2≧ A3≧ A4≧ A5とする。図17(b)に示すように、先ず、面積最大の多角形P0を選択し、その頂点列を時計回りにする。次に、図17(c)に示すように、多角形P0とそれより面積が小さい多角形との間の内包関係を調べる。多角形P0の頂点列はそのままにし、多角形P0に内包される多角形P1, P3, P5の頂点列を反時計回りにし、多角形P0に内包されない且つ多角形P0より面積が小さい多角形P2, P4の頂点列を時計回りにする。図17(d)に示すように、多角形P0の次に面積が大きい多角形P1を選択し、多角形P1とそれより面積が小さい多角形との間の内包関係を調べる。多角形P1の頂点列はそのままにし、多角形P1に内包される多角形の頂点列の方向を反転させ、多角形P1に内包されない且つ多角形P1より面積が小さい多角形P2, P3, P4, P5の頂点列はそのままにする。図17(d)の例では、多角形P1に内包される多角形は存在しない。   A specific example will be described with reference to FIG. As shown in FIG. 17 (a), the size relationship of the areas A0, A1, A2, A3, A4, and A5 of the six polygons P0, P1, P2, P3, P4, and P5 is expressed as A0 ≧ A1 ≧ A2 ≧ A3 ≧ A4 ≧ A5. As shown in FIG. 17B, first, the polygon P0 having the largest area is selected, and its vertex row is turned clockwise. Next, as shown in FIG. 17C, the inclusion relation between the polygon P0 and a polygon having a smaller area is examined. Polygon P2 that is not contained in polygon P0 and has a smaller area than polygon P0, while the vertex row of polygon P0 is left as it is, and the vertex rows of polygons P1, P3, and P5 contained in polygon P0 are counterclockwise. , P4 vertex sequence is clockwise. As shown in FIG. 17D, the polygon P1 having the next largest area after the polygon P0 is selected, and the inclusion relation between the polygon P1 and the polygon having the smaller area is examined. Polygon P1, P3, P4, polygon polygon P1, which is not contained in polygon P1 and has a smaller area than polygon P1 Leave the vertex row of P5 as it is. In the example of FIG. 17D, there is no polygon included in the polygon P1.

図17(e)に示すように、多角形P1の次に面積が大きい多角形P2を選択し、多角形P2とそれより面積が小さい多角形との間の内包関係を調べる。多角形P2の頂点列はそのままにし、多角形P2に内包される多角形P4の頂点列の方向を反転させ、多角形P2に内包されない且つ多角形P2より面積が小さい多角形P3, P5の頂点列はそのままにする。図17(f)に示すように、多角形P2の次に面積が大きい多角形P3を選択し、多角形P3とそれより面積が小さい多角形との間の内包関係を調べる。多角形P3の頂点列はそのままにし、多角形P3に内包される多角形P5の頂点列の方向を反転させ、多角形P3に内包されない且つ多角形P3より面積が小さい多角形P4の頂点列はそのままにする。   As shown in FIG. 17E, the polygon P2 having the next largest area after the polygon P1 is selected, and the inclusion relationship between the polygon P2 and the polygon having the smaller area is examined. Leave the vertex row of the polygon P2 as it is, reverse the direction of the vertex row of the polygon P4 contained in the polygon P2, and the vertexes of the polygons P3 and P5 that are not contained in the polygon P2 and have a smaller area than the polygon P2 Leave the column as it is. As shown in FIG. 17F, the polygon P3 having the next largest area after the polygon P2 is selected, and the inclusion relation between the polygon P3 and the polygon having the smaller area is examined. The vertex row of the polygon P3 is left unchanged, the direction of the vertex row of the polygon P5 contained in the polygon P3 is reversed, and the vertex row of the polygon P4 that is not contained in the polygon P3 and has a smaller area than the polygon P3 is leave it as it is.

図17(g)に示すように、多角形P3の次に面積が大きい多角形P4を選択し、多角形P4とそれより面積が小さい多角形との間の内包関係を調べる。多角形P4の頂点列はそのままにし、多角形P4に内包される多角形の頂点列の方向を反転させ、多角形P4に内包されない且つ多角形P4より面積が小さい多角形P5の頂点列はそのままにする。図17(g)の例では、多角形P4に内包される多角形は存在しない。多角形P4は、面積が2番目に小さい。従って、ここまでの処理によって、全ての多角形の頂点列の方向が確定する。図17(h)の斜線にて示すように、頂点列の方向に向かって右側が内部領域となる。   As shown in FIG. 17 (g), the polygon P4 having the next largest area after the polygon P3 is selected, and the inclusion relation between the polygon P4 and the polygon having the smaller area is examined. Leave the vertex row of polygon P4 as it is, invert the direction of the vertex row of the polygon contained in polygon P4, and leave the vertex row of polygon P5 that is not contained in polygon P4 and has a smaller area than polygon P4 as it is To. In the example of FIG. 17 (g), there is no polygon included in the polygon P4. Polygon P4 has the second smallest area. Therefore, the directions of the vertex rows of all the polygons are determined by the processing so far. As shown by the oblique lines in FIG. 17H, the right side in the direction of the vertex row is the internal region.

上述の処理において、2個の多角形の内包関係を判定する処理が含まれる。その方法は、次のとおりである。ここで対象とする多角形は、前述の複数多角形の重複解消処理を施したものであり、重なり合うことがないことが保証されている。したがって、例えば、2個の多角形のうち面積が大きい方をA、小さい方をBとすれば、Bのうち1個の頂点がAの外部にあることが分かれば、BはAが表す多角形には内包されないと言える。   The above-described processing includes processing for determining the inclusion relation between two polygons. The method is as follows. Here, the target polygon has been subjected to the above-described multi-polygon deduplication processing, and is guaranteed not to overlap. Thus, for example, if the larger area of two polygons is A and the smaller one is B, then if one vertex of B is outside of A, B will be represented by A It can be said that it is not included in the square.

したがって、Bの頂点を順番に調べていき、Aの外部にある頂点が見つかった時点で内包されていないと判定し、全ての頂点を調べ終わった段階で外部にある頂点が見つからなければ、Aに内容されていると判定する。この手順中、Bの頂点がAの内部であるか外部であるかの判定は、前述の内点判定法を用いる。
(4) 後処理
以上の処理手順から明らかなように、ここまでの処理を施した平面領域データにおける頂点列は閉じていない。このため、後処理として全ての頂点列に対して、始点と同じ座標値の頂点データを終点に追加する処理を施す。
Therefore, it examines the vertices of B in order, determines that it is not included when vertices outside A are found, and if no vertices outside are found when all vertices are examined, A It is determined that the contents are included. In this procedure, the above-described interior point determination method is used to determine whether the vertex of B is inside or outside A.
(4) Post-processing As is clear from the above processing procedure, the vertex row in the planar area data subjected to the processing so far is not closed. For this reason, as a post-process, a process of adding vertex data having the same coordinate value as the start point to the end point is performed on all the vertex rows.

本発明による図形データ処理方法を実行する装置の構成を示す図である。It is a figure which shows the structure of the apparatus which performs the figure data processing method by this invention. 本発明による図形データ処理方法の全体の手順を示す図である。It is a figure which shows the procedure of the whole figure data processing method by this invention. 本発明による自己交差多角形分割処理の概要を説明するための説明図である。It is explanatory drawing for demonstrating the outline | summary of the self-intersection polygon division | segmentation process by this invention. 本発明による自己交差多角形分割処理のうち、多角形よりカット点を探索し、頂点列にカット点に等しい頂点を挿入する手順を説明するための説明図である。It is explanatory drawing for demonstrating the procedure which searches a cut point from a polygon among the self-intersection polygon division | segmentation processes by this invention, and inserts the vertex equal to a cut point into a vertex row | line | column. 図4の手順の次の手順を説明するための説明図である。It is explanatory drawing for demonstrating the procedure following the procedure of FIG. 本発明による自己交差多角形分割処理のうち、多角形よりカット点を検索し、多角形を分割する手順を説明するための説明図である。It is explanatory drawing for demonstrating the procedure which searches a cut point from a polygon among the self-intersection polygon division processes by this invention, and divides | segments a polygon. 複数多角形の重複解消処理のうち、従来の頂点追跡法を説明するための説明図である。It is explanatory drawing for demonstrating the conventional vertex tracking method among the duplication elimination processes of a several polygon. 本発明による複数多角形の重複解消処理のうち、多角形の頂点列の方向を判定し、反時計回りの場合に時計回りに変更する手順を説明するための説明図である。It is explanatory drawing for demonstrating the procedure which determines the direction of the vertex row | line | column of a polygon and changes it clockwise in the case of counterclockwise among the duplication elimination processing of the multiple polygon by this invention. 本発明による複数多角形の重複解消処理のうち、2個の多角形の間の交点等の探索と頂点挿入の手順を説明するための説明図である。It is explanatory drawing for demonstrating the procedure of a search of the intersection etc. between two polygons, and vertex insertion among the deduplication removal processing of the several polygon by this invention. 図9の手順の次の手順を説明するための説明図である。It is explanatory drawing for demonstrating the procedure following the procedure of FIG. 本発明による複数多角形の重複解消処理のうち、複数の多角形の重なり合いを解消する手順を説明するための説明図である。It is explanatory drawing for demonstrating the procedure which eliminates the overlap of a some polygon among the duplication elimination processing of the some polygon by this invention. 図11の処理にて、2個の多角形の間に交点又は接点が見つかった場合、それが交点と接点のどちらであるかを判定する方法を説明するための説明図である。It is explanatory drawing for demonstrating the method of determining whether it is an intersection or a contact, when an intersection or a contact is found between two polygons in the process of FIG. 従来の鉛直線算法による内点判定法を説明するための説明図である。It is explanatory drawing for demonstrating the interior point determination method by the conventional vertical line arithmetic. 鉛直線算法による内点判定法において、判定対象点が多角形の辺上にある場合の問題を説明するための説明図である。It is explanatory drawing for demonstrating the problem when the determination target point exists on the edge | side of a polygon in the interior point determination method by a perpendicular line method. 本発明による内点判定法を説明するための説明図である。It is explanatory drawing for demonstrating the interior point determination method by this invention. 図11のステップS909における、重なり合う2個の多角形の頂点列を変換する処理の手順を説明するための説明図である。It is explanatory drawing for demonstrating the procedure of the process which converts the vertex row | line | column of two polygons which overlap in step S909 of FIG. 本発明による入れ子状多角形頂点列方向調整処理を説明するための図である。It is a figure for demonstrating the nested polygon vertex row | line | column direction adjustment process by this invention. 本発明による自己交差多角形分割処理の具体例を示す図である。It is a figure which shows the specific example of the self-intersection polygon division | segmentation process by this invention. 本発明による複数多角形の重複解消処理の具体例を示す図である。It is a figure which shows the specific example of the duplication elimination process of the multiple polygon by this invention. 本発明による入れ子状多角形頂点列方向調整処理の具体例を示す図である。It is a figure which shows the specific example of the nested polygon vertex row | line | column direction adjustment process by this invention.

符号の説明Explanation of symbols

11…CPU、12…ROM、13…RAM、14…入出力I/F回路、15…内部バス、16…外部記憶装置 DESCRIPTION OF SYMBOLS 11 ... CPU, 12 ... ROM, 13 ... RAM, 14 ... Input / output I / F circuit, 15 ... Internal bus, 16 ... External storage device

Claims (17)

図形データとプログラムを格納する記憶装置と、上記図形データを一時的に格納するRAMと、上記図形データを用いて上記プログラムを実行するCPUと、を有するコンピュータを用いて、平面領域を複数の多角形によって表す図形データを処理する図形データ処理方法において、
上記記憶装置から多角形の図形データを読出し、上記RAMに格納する図形データ読出ステップと、
自己交差する多角形を自己交点又は自己接点で分割して自己交差のない複数の多角形に変換する自己交差多角形分割ステップと、
互いに交差する複数の多角形を交差しない複数の多角形に変換する複数多角形の重複解消ステップと、
入れ子状の多角形のうち、内包関係にあり且つ面積の大きさの順番が隣接する2つの多角形の頂点列の方向が互いに逆向きになるように、頂点列を調整する入れ子状多角形頂点列方向調整ステップと、
を上記CPUによって実行し、
上記自己交差多角形分割ステップは、
自己交差する多角形の頂点列に自己交点又は自己接点に等しい頂点を挿入する頂点挿入ステップと、
上記自己交差する多角形の頂点列より座標値が等しい2個の頂点の組み合わせを探索する組み合わせ探索ステップと、
座標値が等しい2個の頂点が見出された場合に当該頂点で上記多角形を2分割する多角形分割ステップと、
上記2分割後の多角形の各々について自己交差がなくなるまで上記組み合わせ探索ステップ及び上記多角形分割ステップを繰り返すことと、
を含むことを特徴とする図形データ処理方法。
Using a computer having a storage device for storing graphic data and a program, a RAM for temporarily storing the graphic data, and a CPU for executing the program using the graphic data, a planar area is divided into a plurality of plane areas. In a graphic data processing method for processing graphic data represented by a square,
Reading polygonal graphic data from the storage device and storing the graphic data in the RAM;
A self-intersecting polygon dividing step of dividing the self-intersecting polygon into self-intersecting polygons or self-intersecting polygons and converting them into a plurality of polygons without self-intersection;
A multi-polygon deduplication step of converting a plurality of intersecting polygons into a plurality of non-intersecting polygons;
Nested polygon vertices that adjust vertex rows so that the directions of the vertex rows of two polygons that are inclusive relations and are adjacent in the order of the size of the nested polygons are opposite to each other A column direction adjustment step;
Is executed by the above CPU,
The self-intersecting polygon division step includes
A vertex insertion step for inserting a vertex equal to a self-intersection or self-contact into a vertex array of self-intersecting polygons;
A combination search step of searching for a combination of two vertices having the same coordinate value from the vertex array of polygons intersecting with each other;
A polygon dividing step of dividing the polygon into two at the vertex when two vertices having the same coordinate value are found;
Repeating the combination search step and the polygon division step until there is no self-intersection for each of the polygons after the two divisions;
A graphic data processing method comprising:
請求項1記載の図形データ処理方法において、上記複数多角形の重複解消ステップは、上記自己交差多角形分割ステップによって得られた自己交差のない多角形の全てについて、多角形の頂点列の方向を判定する頂点列方向判定処理ステップと、
多角形の頂点列の方向を時計回り又は反時計回りに統一化する頂点列方向統一化処理ステップと、
一方の多角形の辺が他方の多角形の辺と交差する2個の多角形の組み合わせ、又は、一方の多角形の頂点が他方の多角形の辺に接する2個の多角形の組み合わせ、を探索する交点探索処理ステップと、
該交点探索処理ステップにて検出された2個の多角形の頂点列に交点又は接点の座標値に等しい頂点を挿入する頂点挿入処理ステップと、
互いに交差する2個の多角形を探索する多角形重畳検索処理ステップと、
交差する2個の多角形を頂点追跡法の原理により結合領域を囲む多角形と穴領域を囲む多角形に変換する多角形変換ステップと、
上記交差する2個の多角形の組み合わせがなくなるまで上記多角形重畳検索処理ステップと上記多角形変換ステップを繰り返すことを特徴とする図形データ処理方法。
2. The graphic data processing method according to claim 1, wherein the deduplication step of the plurality of polygons sets the direction of the vertex sequence of the polygons for all of the non-self-intersecting polygons obtained by the self-intersecting polygon division step. Vertex row direction determination processing step for determining,
Vertex row direction unification processing step for unifying the direction of the vertex row of the polygon clockwise or counterclockwise,
A combination of two polygons in which one side of the polygon intersects a side of the other polygon, or a combination of two polygons in which the vertex of one polygon touches the side of the other polygon. Intersection search processing step to search;
Vertex insertion processing step for inserting a vertex equal to the coordinate value of the intersection or contact point into the two polygonal vertex rows detected in the intersection search processing step;
A polygon superposition search processing step for searching for two polygons intersecting each other;
A polygon conversion step of converting two intersecting polygons into a polygon surrounding a connected region and a polygon surrounding a hole region by the principle of vertex tracking;
A graphic data processing method characterized by repeating the polygon superposition search processing step and the polygon conversion step until there is no combination of two intersecting polygons.
請求項記載の図形データ処理方法において、上記頂点列方向判定処理ステップは、
多角形の頂点列のうち、x座標値が最小の頂点p2と、当該頂点列におけるその直前の頂点p1及び直後の頂点p3を選び、ベクトルp2p1とベクトルp2p3の外積Gを計算することと、
上記外積Gが非ゼロの場合には、その正負により当該頂点列の回転方向を判定することと、
上記外積Gがゼロの場合には頂点p2と頂点p3、又は頂点p2と頂点p1のy座標値の大小関係により当該頂点列の回転方向を判定することと、
を含むことを特徴とする図形データ処理方法。
3. The graphic data processing method according to claim 2, wherein the vertex row direction determination processing step includes:
Selecting a vertex p2 having a minimum x coordinate value and a vertex p1 immediately before and a vertex p3 immediately after it in the vertex sequence of the polygon, and calculating an outer product G of the vectors p2p1 and p2p3;
When the outer product G is non-zero, determining the rotation direction of the vertex row by its positive / negative,
When the outer product G is zero, determining the rotation direction of the vertex row based on the magnitude relationship of the y coordinate values of the vertex p2 and the vertex p3, or the vertex p2 and the vertex p1,
A graphic data processing method comprising:
請求項記載の図形データ処理方法において、上記多角形重畳検索処理ステップは、
上記頂点挿入処理ステップによって得られた座標値が等しい頂点が挿入された2個の多角形の頂点列において、一方の多角形の頂点列における当該頂点と、その直前及び直後の頂点を結ぶ線分上に任意の2個の点を選ぶ2点選択ステップと、
上記2点選択ステップにて選んだ2個の点の一方が他方の多角形の内部にあり、かつ、2個の点の他方が他方の多角形の外部にある場合に、当該頂点は交点であると判定する交点判定ステップと、
該交点判定ステップにて当該頂点は交点であると判定されないとき当該頂点は接点であると判定する接点判定ステップと、を含むことを特徴とする図形データ処理方法。
3. The graphic data processing method according to claim 2, wherein the polygon superposition search processing step includes:
In two polygonal vertex rows in which vertices with the same coordinate value obtained in the vertex insertion processing step are inserted, the line segment connecting the vertexes in the vertex row of one polygon and the vertices immediately before and after it A two-point selection step to select any two points on top,
If one of the two points selected in the above two-point selection step is inside the other polygon and the other two points are outside the other polygon, the vertex is an intersection. An intersection determination step for determining that there is,
A graphic data processing method comprising: a contact determination step of determining that the vertex is a contact when the intersection is not determined to be an intersection in the intersection determination step.
請求項記載の図形データ処理方法において、上記交点判定ステップにおいて、2個の点の一方が他方の多角形の内部にあり、かつ、2個の点の他方が他方の多角形の外部にあると判定する工程は、
判定対象点を端とする半直線を引く半直線ステップと、
隣接する任意の2つの頂点を始点候補及び終点候補として選択し、該始点候補及び終点候補が上記半直線を含む直線上にあるか否かを判定し、上記始点候補及び上記終点候補が上記半直線を含む直線上にない場合には、上記始点候補及び上記終点候補を始点及び終点に選定する始点終点選定ステップと、
上記始点終点選定ステップにて、上記始点候補が上記半直線を含む直線上にあると判定された場合には、上記始点候補から頂点を1つずつ順次後退させ、上記半直線を含む直線上にない最初の頂点が見つかったらそれを始点とする始点選定ステップと、
上記始点終点選定ステップにて、上記終点候補が上記半直線を含む直線上にあると判定された場合には、上記終点候補から頂点を1つずつ順次前進させ、上記半直線を含む直線上にない最初の頂点が見つかったらそれを終点とする終点選定ステップと、
上記始点終点選定ステップ、又は、上記始点選定ステップ及び終点選定ステップにて選定された始点と終点の間を「判定対象の辺の範囲」に選定する判定対象の辺の範囲選定ステップと、
上記判定対象の辺の範囲にて、上記半直線が多角形と交差するか否かを判定する交差判定ステップと、
該交差判定ステップにて、上記半直線が多角形と交差すると判定された場合には交差回数を1増加し、交差しないと判定された場合には交差回数をそのままにする交差計数ステップと、
上記始点終点選定ステップ、上記始点選定ステップ、上記終点選定ステップ、上記判定対象の辺の範囲選定ステップ、上記交差判定ステップ及び上記交差計数ステップを、多角形の全周に渡って、順次繰り返す繰返しステップと、
上記交差計数ステップにて計数した交差回数が偶数である場合には、判定対象点は多角形の外部にあると判定し、交差回数が奇数である場合には、判定対象点は多角形の内部にあると判定する判定対象点判定ステップと、
を含むことを特徴とする図形データ処理方法。
5. The graphic data processing method according to claim 4, wherein, in the intersection determination step, one of the two points is inside the other polygon and the other of the two points is outside the other polygon. The process of determining that
A half-line step that draws a half-line with the judgment target point as an end;
Any two adjacent vertices are selected as a start point candidate and an end point candidate, it is determined whether or not the start point candidate and the end point candidate are on a straight line including the half line, and the start point candidate and the end point candidate are the half point. If not on a straight line including a straight line, a start point end point selection step for selecting the start point candidate and the end point candidate as a start point and an end point; and
When it is determined in the start point / end point selection step that the start point candidate is on a straight line including the half line, the vertices are sequentially retreated one by one from the start point candidate, and the start point candidate is on the straight line including the half line. When a first non-existent vertex is found, a starting point selection step starting from that point, and
In the start point / end point selection step, when it is determined that the end point candidate is on a straight line including the half line, the apexes are sequentially advanced one by one from the end point candidate, and then on the straight line including the half line. If the first non-existent vertex is found, the end point selection step will be the end point.
A range selection step of a determination target side that selects a range between the start point and the end point selected in the start point end point selection step or the start point selection step and the end point selection step as a range of a determination target side;
An intersection determination step for determining whether or not the half line intersects a polygon in the range of the determination target side;
In the intersection determination step, when it is determined that the half line intersects with the polygon, the number of intersections is increased by 1, and when it is determined that the intersection does not intersect, an intersection counting step for leaving the number of intersections as it is.
Repeating step of sequentially repeating the start point / end point selection step, the start point selection step, the end point selection step, the edge range selection step, the intersection determination step, and the intersection counting step over the entire circumference of the polygon. When,
If the number of intersections counted in the intersection counting step is an even number, it is determined that the determination target point is outside the polygon. If the number of intersections is an odd number, the determination target point is inside the polygon. A determination target point determination step for determining that the
A graphic data processing method comprising:
請求項1記載の図形データ処理方法において、上記入れ子状多角形頂点列方向調整ステップは、
上記複数の多角形がn個の多角形であるとし、該n個の多角形のうち面積最大の多角形を選択し、該面積最大の多角形とそれより面積が小さい全ての多角形との間の内包関係を調べる第1の内包関係検索ステップと、
上記面積最大の多角形を表す頂点列を時計回り又は反時計回りにし、上記面積最大の多角形に内包される全ての多角形の頂点列を上記面積最大の多角形を表す頂点列の方向とは逆の方向にし、上記面積最大の多角形に内包されない全ての多角形の頂点列を上記面積最大の多角形を表す頂点列の方向と同一の方向にする第1ステップと、
上記n個の多角形のうちk(k=2〜n-1)番目に面積が大きい多角形を選択し、該k番目に面積が大きい多角形とそれより面積が小さい全ての多角形との間の内包関係を調べる第2の内包関係検索ステップと、
上記k番目に面積が大きい多角形の頂点列はそのままにし、上記k番目に面積が大きい多角形に内包される全ての多角形の頂点列の方向を反転し、上記k番目に面積が大きい多角形に内包されない且つ上記k番目に面積が大きい多角形より面積が小さい多角形の頂点列はそのままにする第2のステップと、
を含み、上記第2の内包関係検索ステップ及び第2のステップをインデックスkを2から1ずつ増やしながらn-1まで処理を繰り返すことを特徴とする図形データ処理方法。
The graphic data processing method according to claim 1, wherein the nested polygon vertex row direction adjusting step includes:
The plurality of polygons are n polygons, a polygon having the largest area among the n polygons is selected, and the polygon having the largest area and all polygons having a smaller area are selected. A first inclusion relationship search step for examining an inclusion relationship between
The vertex row representing the polygon with the largest area is clockwise or counterclockwise, and the vertex rows of all the polygons included in the polygon with the largest area are the direction of the vertex row representing the polygon with the largest area. In the opposite direction, the first step is to make the vertex rows of all the polygons not included in the polygon with the largest area the same direction as the direction of the vertex row representing the polygon with the largest area;
A polygon having the kth (k = 2 to n-1) th largest area is selected from the n polygons, and the kth largest polygon and all polygons having a smaller area are selected. A second inclusion relationship search step for examining the inclusion relationship between the two,
The vertex array of the polygon with the kth largest area is left as it is, the directions of the vertex arrays of all the polygons included in the polygon with the largest area are reversed, and the kth largest area is A second step of leaving a vertex row of a polygon that is not enclosed in a polygon and smaller in area than the k-th largest polygon as it is,
A graphic data processing method characterized in that the second inclusion relation retrieval step and the second step are repeated up to n-1 while increasing the index k from 2 to 1.
請求項記載の図形データ処理方法において、上記入れ子状多角形検索ステップの第1及び第2の内包関係検索ステップは、
内包関係を調べる対象として互いに交わらない2個の多角形を設定することと、
該2個の多角形のうち面積が小さい方の多角形と面積が大きい方の多角形を判定することと、
面積が小さい方の多角形の少なくとも1個の頂点が面積が大きい方の多角形の外部にある場合には面積が小さい方の多角形は面積が大きい方の多角形に内包されないと判定することと、
面積が小さい方の多角形の全ての頂点が面積が大きい方の多角形の内部にある場合には面積が小さい方の多角形は面積が大きい方の多角形に内包されると判定することと、
を含むことを特徴とする図形データ処理方法。
The graphic data processing method according to claim 6, wherein the first and second inclusion relation search steps of the nested polygon search step include:
Setting two polygons that do not intersect with each other as the target for examining the inclusive relationship;
Determining the polygon with the smaller area and the polygon with the larger area of the two polygons;
If at least one vertex of the polygon with the smaller area is outside the polygon with the larger area, determine that the polygon with the smaller area is not included in the polygon with the larger area. When,
When all the vertices of the polygon with the smaller area are inside the polygon with the larger area, it is determined that the polygon with the smaller area is included in the polygon with the larger area. ,
A graphic data processing method comprising:
請求項1〜のいずれか1項記載の図形データ処理方法をコンピュータに実行させるためのコンピュータにより読み取り可能なプログラム。 Claim 1-7 readable program by a computer for executing the graphic data processing method according to any one of the computers. 請求項記載のプログラムを格納したコンピュータにより読み取り可能な媒体。 A computer-readable medium storing the program according to claim 8 . 図形データとプログラムを格納する記憶装置と、上記図形データを一時的に格納するRAMと、上記図形データを用いて上記プログラムを実行するCPUと、を有するコンピュータを用いて、自己交差する多角形を分割するための図形データ処理方法において、
上記記憶装置から多角形の図形データを読出し、上記RAMに格納する図形データ読出ステップと、
多角形を表す頂点列より座標値が等しい連続する複数の頂点があったとき、該連続する複数の頂点より1個の頂点を残し他の頂点を削除する重複頂点削除ステップと、
多角形を表す頂点列より多角形の辺と辺が交差する自己交点及び頂点が辺と接する自己接点の座標値を求める交点等座標値検出ステップと、
多角形の頂点列に上記自己交点及び自己接点の座標値に等しい頂点を挿入する頂点挿入ステップと、
上記頂点列より座標値が等しい2個の頂点の組み合わせを探索する組み合わせ探索ステップと、
座標値が等しい2個の頂点が見出された場合に当該頂点で上記多角形を2分割する2分割ステップと、
上記2分割後の多角形の各々について自己交差がなくなるまで上記組み合わせ探索ステップ及び上記2分割ステップを繰り返すことと、
を上記CPUによって実行することを特徴とする図形データ処理方法
Using a computer having a storage device for storing graphic data and a program, a RAM for temporarily storing the graphic data, and a CPU for executing the program using the graphic data, a self-intersecting polygon is obtained. In the graphic data processing method for dividing,
Reading polygonal graphic data from the storage device and storing the graphic data in the RAM;
When there are a plurality of continuous vertices whose coordinate values are equal to each other from a vertex sequence representing a polygon, a redundant vertex deletion step of deleting one vertex from the plurality of continuous vertices and deleting the other vertices;
A coordinate point detection step for calculating a coordinate value of a self-intersection where a side of the polygon intersects from a vertex row representing the polygon and a self-contact point where the vertex contacts the side; and
A vertex insertion step of inserting a vertex equal to the coordinate value of the self-intersection point and the self-contact point into a polygon vertex row;
A combination search step for searching for a combination of two vertices having the same coordinate value from the vertex sequence;
When two vertices having the same coordinate value are found, a two-dividing step of dividing the polygon into two at the vertices;
Repeating the combination search step and the two division step until there is no self-intersection for each of the polygons after the division into two,
Is executed by the CPU .
請求項10に記載の図形データ処理方法をコンピュータに実行させるためのコンピュータにより読み取り可能なプログラム。 A computer-readable program for causing a computer to execute the graphic data processing method according to claim 10 . 請求項11に記載のプログラムを格納したコンピュータにより読み取り可能な媒体。 A computer-readable medium storing the program according to claim 11 . 図形データとプログラムを格納する記憶装置と、上記図形データを一時的に格納するRAMと、上記図形データを用いて上記プログラムを実行するCPUと、を有するコンピュータを用いて、頂点列によって表される多角形と判定対象点が与えられたとき該判定対象点が上記多角形の内部にあるか又は外部にあるかを判定する図形データ処理方法において、
上記記憶装置から多角形の図形データを読出し、上記RAMに格納する図形データ読出ステップと、
判定対象点を端とする半直線を引く半直線ステップと、
隣接する任意の2つの頂点を始点候補及び終点候補として選択し、該始点候補及び終点候補が上記半直線を含む直線上にあるか否かを判定し、上記始点候補及び上記終点候補が上記半直線を含む直線上にない場合には、上記始点候補及び上記終点候補を始点及び終点に選定する始点終点選定ステップと、
上記始点終点選定ステップにて、上記始点候補が上記半直線を含む直線上にあると判定された場合には、上記始点候補から頂点を1つずつ順次後退させ、上記半直線を含む直線上にない最初の頂点が見つかったらそれを始点とする始点選定ステップと、
上記始点終点選定ステップにて、上記終点候補が上記半直線を含む直線上にあると判定された場合には、上記終点候補から頂点を1つずつ順次前進させ、上記半直線を含む直線上にない最初の頂点が見つかったらそれを終点とする終点選定ステップと、
上記始点終点選定ステップ、又は、上記始点選定ステップ及び終点選定ステップにて選定された始点と終点の間を「判定対象の辺の範囲」に選定する判定対象の辺の範囲選定ステップと、
上記判定対象の辺の範囲にて、上記半直線が多角形と交差するか否かを判定する交差判定ステップと、
該交差判定ステップにて、上記半直線が多角形と交差すると判定された場合には交差回数を1増加し、交差しないと判定された場合には交差回数をそのままにする交差計数ステップと、
上記始点終点選定ステップ、上記始点選定ステップ、上記終点選定ステップ、上記判定対象の辺の範囲選定ステップ、上記交差判定ステップ及び上記交差計数ステップを、多角形の全周に渡って、順次繰り返す繰返しステップと、
上記交差計数ステップにて計数した交差回数が偶数である場合には、判定対象点は多角形の外部にあると判定し、交差回数が奇数である場合には、判定対象点は多角形の内部にあると判定する判定対象点判定ステップと、
を上記CPUによって実行することを特徴とする図形データ処理方法
It is represented by a vertex sequence using a computer having a storage device for storing graphic data and a program, a RAM for temporarily storing the graphic data, and a CPU for executing the program using the graphic data. In the graphic data processing method for determining whether the determination target point is inside or outside the polygon when the polygon and the determination target point are given,
Reading polygonal graphic data from the storage device and storing the graphic data in the RAM;
A half-line step that draws a half-line with the judgment target point as an end;
Any two adjacent vertices are selected as a start point candidate and an end point candidate, it is determined whether or not the start point candidate and the end point candidate are on a straight line including the half line, and the start point candidate and the end point candidate are the half point. If not on a straight line including a straight line, a start point end point selection step for selecting the start point candidate and the end point candidate as a start point and an end point; and
When it is determined in the start point / end point selection step that the start point candidate is on a straight line including the half line, the vertices are sequentially retreated one by one from the start point candidate, and the start point candidate is on the straight line including the half line. When a first non-existent vertex is found, a starting point selection step starting from that point, and
In the start point / end point selection step, when it is determined that the end point candidate is on a straight line including the half line, the apexes are sequentially advanced one by one from the end point candidate, and then on the straight line including the half line. If the first non-existent vertex is found, the end point selection step will be the end point.
A range selection step of a determination target side that selects a range between the start point and the end point selected in the start point end point selection step or the start point selection step and the end point selection step as a range of a determination target side;
An intersection determination step for determining whether or not the half line intersects a polygon in the range of the determination target side;
In the intersection determination step, when it is determined that the half line intersects with the polygon, the number of intersections is increased by 1, and when it is determined that the intersection does not intersect, an intersection counting step for leaving the number of intersections as it is.
Repeating step of sequentially repeating the start point / end point selection step, the start point selection step, the end point selection step, the edge range selection step, the intersection determination step, and the intersection counting step over the entire circumference of the polygon. When,
If the number of intersections counted in the intersection counting step is an even number, it is determined that the determination target point is outside the polygon. If the number of intersections is an odd number, the determination target point is inside the polygon. A determination target point determination step for determining that the
Is executed by the CPU .
請求項13記載の図形データ処理方法において、上記交差判定ステップは、
上記半直線の方向をy軸の正の方向に設定するとき、判定対象点のx座標値が上記始点のx座標値と上記終点のx座標値の間にあるか否かを判定するx座標値判定ステップと、
上記x座標値判定ステップにて、判定対象点のx座標値が上記始点のx座標値と上記終点のx座標値の間にないと判定された場合には、上記交差判定ステップを終了する終了ステップと、
上記x座標値判定ステップにて、判定対象点のx座標値が上記始点のx座標値と上記終点のx座標値の間にあると判定された場合で、上記始点と上記終点が多角形の連続する2頂点である場合には、上記始点と上記終点を結ぶ直線と上記半直線を含む直線の交点のy座標値と判定対象点のy座標値とを比較し、上記始点又は上記終点が上記始点選定ステップ又は終点選定ステップにて選定された頂点である場合には、上記始点と上記終点の間にある頂点のy座標値と判定対象点のy座標値とを比較するy座標値比較ステップと、
上記y座標値比較ステップにおける比較結果から、上記判定対象の辺の範囲にて上記半直線が多角形と交差するか否かを判定する比較結果交差判定ステップと、
を有することを特徴とする図形データ処理方法
14. The graphic data processing method according to claim 13, wherein the intersection determination step includes:
X-coordinate to determine whether the x-coordinate value of the judgment target point is between the x-coordinate value of the start point and the x-coordinate value of the end point when setting the direction of the half line to the positive direction of the y-axis A value determination step;
When it is determined in the x coordinate value determining step that the x coordinate value of the determination target point is not between the x coordinate value of the start point and the x coordinate value of the end point, the end of the intersection determination step is ended. Steps,
In the x coordinate value determining step, when it is determined that the x coordinate value of the determination target point is between the x coordinate value of the start point and the x coordinate value of the end point, the start point and the end point are polygonal. When there are two consecutive vertices, the y-coordinate value of the intersection of the straight line connecting the start point and the end point and the straight line including the half line is compared with the y-coordinate value of the determination target point, and the start point or the end point is Y coordinate value comparison that compares the y coordinate value of the vertex between the start point and the end point with the y coordinate value of the judgment target point when the vertex is selected at the start point selection step or the end point selection step Steps,
From the comparison result in the y coordinate value comparison step, a comparison result intersection determination step for determining whether or not the half line intersects a polygon in the range of the side to be determined;
A graphic data processing method characterized by comprising :
請求項13記載の図形データ処理方法において、上記始点終点選定ステップは、2回目以降のループでは、前回のループにおける終点を始点として選択し、該始点から頂点を1つ前進させた頂点を終点候補として選択し、該終点候補が上記半直線を含む直線上にあるか否かを判定し、上記終点候補が上記半直線を含む直線上にない場合には、上記終点候補を終点とし、上記終点候補が上記半直線を含む直線上にある場合には、上記終点候補から頂点を1つずつ順次前進させ、上記半直線を含む直線上にない最初の頂点が見つかったらそれを終点とすることを特徴とする図形データ処理方法14. The graphic data processing method according to claim 13, wherein in the second and subsequent loops, the start point / end point selection step selects an end point in the previous loop as a start point, and selects a vertex obtained by advancing the vertex by one from the start point. And determines whether the end point candidate is on a straight line including the half line. If the end point candidate is not on the straight line including the half line, the end point candidate is set as the end point, and the end point is determined. If the candidate is on a straight line including the half line, the vertices are sequentially advanced one by one from the end point candidate, and if the first vertex that is not on the straight line including the half line is found, it shall be the end point. Characteristic graphic data processing method . 請求項1315のいずれか1項記載の図形データ処理方法をコンピュータに実行させるためのコンピュータにより読み取り可能なプログラム。 A computer-readable program for causing a computer to execute the graphic data processing method according to any one of claims 13 to 15 . 請求項16記載のプログラムを格納したコンピュータにより読み取り可能な媒体。 A computer-readable medium storing the program according to claim 16 .
JP2003354037A 2003-10-14 2003-10-14 GRAPHIC DATA PROCESSING METHOD, GRAPHIC DATA PROCESSING PROGRAM, AND RECORDING MEDIUM CONTAINING THE PROGRAM Expired - Lifetime JP3988945B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003354037A JP3988945B2 (en) 2003-10-14 2003-10-14 GRAPHIC DATA PROCESSING METHOD, GRAPHIC DATA PROCESSING PROGRAM, AND RECORDING MEDIUM CONTAINING THE PROGRAM

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003354037A JP3988945B2 (en) 2003-10-14 2003-10-14 GRAPHIC DATA PROCESSING METHOD, GRAPHIC DATA PROCESSING PROGRAM, AND RECORDING MEDIUM CONTAINING THE PROGRAM

Publications (2)

Publication Number Publication Date
JP2005122302A JP2005122302A (en) 2005-05-12
JP3988945B2 true JP3988945B2 (en) 2007-10-10

Family

ID=34612139

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003354037A Expired - Lifetime JP3988945B2 (en) 2003-10-14 2003-10-14 GRAPHIC DATA PROCESSING METHOD, GRAPHIC DATA PROCESSING PROGRAM, AND RECORDING MEDIUM CONTAINING THE PROGRAM

Country Status (1)

Country Link
JP (1) JP3988945B2 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7859537B2 (en) * 2007-01-23 2010-12-28 Microsoft Corporation Evaluation of self-intersecting vector graphics objects via planar map profiles
KR100876641B1 (en) 2008-01-07 2009-01-07 버추얼모션(주) Contact perception method and the system which use the subshell
JP5885388B2 (en) * 2011-01-19 2016-03-15 三菱プレシジョン株式会社 Method for determining the positional relationship between a first graphic and a second graphic, a device using such a method, a program for such a method, and a vehicle driving simulation device
JP6169048B2 (en) * 2013-07-16 2017-07-26 三菱電機株式会社 A method for transforming an input path, a method for labeling input path segments as internal or external, a method for rendering an input path, and a method for drawing an outline of an input path
CN111538800B (en) * 2020-04-23 2022-09-13 内蒙古师范大学 Method and system for correcting storage direction of complex polygonal geographic data
CN116645482B (en) * 2023-06-01 2024-03-22 中国铁路设计集团有限公司 Large-range ground continuous elevation extraction method

Also Published As

Publication number Publication date
JP2005122302A (en) 2005-05-12

Similar Documents

Publication Publication Date Title
US11573942B2 (en) System and method for determining exact location results using hash encoding of multi-dimensioned data
Shamos Computational geometry
Collins Fundamental numerical methods and data analysis
JP3962361B2 (en) Phase determining device, decomposable shape generating device, structural mesh generating device, phase determining method, decomposable shape generating method, computer executable program for executing the phase determining method, and decomposable shape generating method Computer executable program and structured mesh generation system
Mucke Shapes and implementations in three-dimensional geometry
US20040233191A1 (en) Robust tetrahedralization and triangulation method with applications in VLSI layout design and manufacturability
CA2750093A1 (en) Method for computing and storing voronoi diagrams, and uses therefor
JPH08185398A (en) Handwritten character inputting/displaying device
JP2019197438A (en) Graph updating device, graph updating method, and program
JP3988945B2 (en) GRAPHIC DATA PROCESSING METHOD, GRAPHIC DATA PROCESSING PROGRAM, AND RECORDING MEDIUM CONTAINING THE PROGRAM
Leroy Convergence under Subdivision and Complexity of Polynomial Minimization in the Simplicial Bernstein Basis.
Joswig et al. The schläfli fan
WO2011025385A1 (en) Method for local refinement of a geometric or physical representation
US6922602B2 (en) Method and device for generating sheet metal model from solid model
JP3332476B2 (en) Graphic correction method and information processing apparatus for implementing the method
Gold Three approaches to automated topology, and how computational geometry helps
US10830594B2 (en) Updating missing attributes in navigational map data via polyline geometry matching
JPH08235368A (en) Method for calculating intersection point of bezer curve and two-dimentional graphic and graphic processor therefor
JP4710029B2 (en) Geometric graphic data processing apparatus, geometric graphic data processing method, and geometric graphic data processing program
JP3168117B2 (en) 3D shape model processing device
Ramamurthy Voronoi diagrams and medial axes of planar domains with curved boundaries
JP3647075B2 (en) Image search method and apparatus
JP7469995B2 (en) Coil mesh creation device and creation method
RU2342705C9 (en) Computer-aided method of generating image of parts of broken line, lying inside or outside polygonal region, and computer-aided method of generating image of boundaries of one or more regions, obtained from using given logical operation on two polygonal regions
da Silva et al. A Robust Strategy for Handling Linear Features in Topologically Consistent Polyline Simplification.

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20060801

A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A712

Effective date: 20060803

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20061003

RD03 Notification of appointment of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7423

Effective date: 20061013

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20061204

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20070515

R155 Notification before disposition of declining of application

Free format text: JAPANESE INTERMEDIATE CODE: R155

R150 Certificate of patent or registration of utility model

Ref document number: 3988945

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

S533 Written request for registration of change of name

Free format text: JAPANESE INTERMEDIATE CODE: R313533

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

EXPY Cancellation because of completion of term