THREE-DIME SIO AL PRIMITIVE OBJECTS FOR EXT GE ERATIO OF GEO-DATABASE MA AGEME T SYSTEM

advertisement
THREE-DIMESIOAL PRIMITIVE OBJECTS FOR EXT GEERATIO
OF GEO-DATABASE MAAGEMET SYSTEM
OR SUHAIBAH BITI AZRI
UIVERSITI TEKOLOGI MALAYSIA
THREE-DIMENSIONAL PRIMITIVE OBJECTS FOR NEXT GENERATION OF
GEO-DATABASE MANAGEMENT SYSTEM
NOR SUHAIBAH BINTI AZRI
A thesis submitted in fulfillment of the
requirements for the award of the degree of
Master of Science (Geoinformatics)
Faculty of Geoinformation and Real Estate
Universiti Teknologi Malaysia
DECEMBER 2011
iv
Dedicate to my family
v
ACKOWLEDGEMET
In preparing this thesis, I was in contact with many people, researchers,
academicians, and practitioners. They have contributed towards my understanding and
thoughts. In particular, I wish to express my sincere appreciation to my main thesis
supervisor, Professor Dr. Alias Abdul Rahman, for encouragement, guidance, critics and
friendship.
I am also indebted to Ministry of Science, Technology & Innovation (MOSTI)
for funding me with National Science Fellowship (NSF) scholarship for my MSc study.
My fellow postgraduate students especially member of 3D GIS Laboratory
should also be recognised for their support. My sincere appreciation also extends to all
my colleagues and others who have provided assistance at various occasions. Their
views and tips are useful indeed. Unfortunately, it is not possible to list all of them in
this limited space. I am grateful to all my family members.
vi
ABSTRACT
A variety of issues and aspects need to be addressed and investigated during
the evolutions of two - dimensional Geographical Information System (2D GIS) to
three - dimensional Geographical Information System (3D GIS). Issues that need to
be addressed are 3D spatial data modeling, 3D data management and 3D analysis. In
order to construct objects in 3D environment, variety of 3D geometries are needed in
Database Management System (DBMS). Most mainstream DBMS only supports
several simple 3D geometries such as 3D points, 3D lines, and 3D polygons.
Complex shapes and volumetric shapes are not supported by the current DBMSs.
However in the real world, objects are modeled by various shapes of geometry and
not restricted to simple shapes. The lack of various geometries in DBMS may give
limitations to users to model and store some objects in the database. Thus, this
research attempts to investigate and implement several 3D geometries based on
volumetric shapes or known as 3D primitive objects. Four types of 3D primitive
objects were used in this research and the objects are cone, cylinder, sphere and
torus. New procedure to construct each shape were investigated and implemented in
the database. Each developed procedure was tested using simulation datasets as well
as real datasets. The constructed object should be able to provide users with some
information by using simple query to the related objects table. This research work
could be extended in the future by providing more geometry types in geo-DBMS.
vii
ABSTRAK
Pelbagai isu dan aspek perlu dikaji dan diberi perhatian ketika evolusi Sistem
Maklumat Geografi dua - dimensi (2D GIS) ke Sistem Maklumat Geografi tiga dimensi (3D GIS).Antara isu yang perlu diberikan perhatian ialah permodelan data
spatial 3D, pengurusan data 3D dan analisis 3D. Untuk membentuk objek dalam
persekitaran 3D, kepelbagaian
geometri 3D diperlukan dalam sesebuah sistem
pengurusan pangkalan data (DBMS). Sebahagian besar DBMS hanya menyokong
beberapa geometri 3D yang mudah seperti titik 3D, garis 3D, poligon 3D. Bentuk
kompleks dan bentuk yang berisipadu tidak disokong oleh DBMS buat masa ini.
Walaubagaimanapun, di dalam dunia nyata, objek dimodelkan dengan pelbagai
bentuk geometri dan tidak terhad kepada bentuk mudah sahaja. Kurangnya pelbagai
geometri di dalam sesebuah DBMS mungkin akan memberikan batasan kepada
pengguna untuk memodelkan dan menyimpan beberapa objek di dalam pangkalan
data. Oleh itu, penyelidikan ini bertujuan untuk menyiasat dan melaksanakan
beberapa jenis
geometri 3D berdasarkan bentuk yang mempunyai isipadu atau
dikenali sebagai objek 3D primitif. Empat jenis objek 3D primitif sahaja yang
digunakan dalam penyelidikan ini dan objek tersebut ialah kon, silinder, sfera dan
torus. Prosidur baru untuk membentuk setiap bentuk diselidiki dan dilaksanakan
dalam pangkalan data. Setiap prosedur yang dibangunkan diuji dengan menggunakan
set data simulasi serta set data sebenar. Objek yang dibentuk seharusnya dapat
memberikan pengguna beberapa maklumat dengan menggunakan pertanyaan mudah
terhadap jadual objek. Kerja penyelidikan boleh diperluaskan lagi di masa depan
dengan menyediakan pelbagai jenis geometri dalam geo-DBMS.
viii
TABLE OF CO
TE
TS
CHAPTER
1
TITLE
PAGE
DECLARATIO
ii
DECLARATIO
iii
DEDICATIO
iv
ACK
OWLEDGEME
TS
v
ABSTRACT
vi
ABSTRAK
vii
TABLE OF CO
TE
TS
viii
LIST OF TABLES
xii
LIST OF FIGURES
xiii
LIST OF ABBREVIATIO
S
xvii
LIST OF SYMBOLS
xviii
I
TRODUCTIO
1.1
Introduction
1
1.2
Background to The Problem
3
1.3
The Problem Statement
8
1.4
The Aim
9
1.5
The Objectives
9
1.6
The Scope
9
1.6.1 The Objects
10
1.6.2 The Datasets
11
1.6.3 The Hardware and Software
11
Brief Methodology
12
1.7
ix
2
1.8
Research Workflow
15
1.9
The Thesis Structure
16
1.10
Conclusions
17
3D PRIMITIVE OBJECTS A
D SPATIAL DBMS
2.1
Background
18
2.2
Primitive Objects
19
2.2.1 Sphere
20
2.2.1.1 Spherical Coordinates
2.2.2 Cylinder
24
2.2.3 Cone
26
2.2.4 Torus
28
Solid Modeling
31
2.3.1 Decompositions Model
33
2.3.2 Constructive Solid Geometry (CSG)
36
2.3.3 Boundary Representation
37
2.4
Polyhedron
40
2.5
Polygon Orientation
42
2.6
Spatial Database Management System
44
2.6.1 Geometry and Dimension in Spatial DBMS
45
2.6.2 Volumetric Object in Spatial DBMS
46
Oracle Spatial DBMS
47
2.7.1 Supported Geometry Types
49
2.7.2 SDO_Geometry
51
2.7.3 Interoperability
54
Summary
55
2.3
2.7
2.8
3
21
MODELI
G 3D PRIMITIVE OBJECTS
3.1
Background
3.2
Modeling Objects using B-Rep and
3.3
56
Spherical Coordinates
57
Constructing 3D Primitive Objects
58
3.3.1 Sphere
58
3.3.2 Modeling Solid Sphere
60
x
3.4
4
3.3.3 Cylinder
68
3.3.4 Modeling Cylinder
70
3.3.5 Cone
72
3.3.6 Modeling Cone
74
3.3.7 Torus
76
3.3.8 Modeling Torus
78
Conclusion
81
THE IMPLEME
TIO
OF 3D PRIMITIVE OBJECTS AT
DBMS LEVEL
4.1
Background
83
4.2
Implementation Approach
84
4.2.1 Stored Procedure
84
4.2.2 Create Procedure
86
4.2.3 Load Procedure in DBMS
90
3D Primitive Objects in DBMS
91
4.3.1 Indexing of Spatial Data
93
4.3
4.3.2 Creating Spatial Index and
5
Spatial Index Parameter
95
4.3.3 3D Primitive Objects Procedure
98
4.3.4 Volume and Area Calculation
100
4.4
Rotation Element
110
4.5
Conclusion
117
RESULTS A
D QUERY
5.1
Background
118
5.2
Visualization of 3D Primitive Objects
119
5.3
3D Primitive Objects in DBMS
119
5.3.1 Cone
121
5.3.2 Cylinder
123
5.3.3 Torus
125
5.3.4 Sphere
128
5.3.5 Half Cone
130
5.3.6 Half Cylinder
131
xi
6
5.3.7 Half Torus
132
5.3.8 Quarter Torus
134
5.3.9 Hemisphere (Half Sphere)
135
5.4
Rotation Element
136
5.5
Combination of 3D Primitive Objects
145
5.6
3D Primitive Objects and Real Datasets
151
5.7
Query
155
5.8
Surface Smoothness
157
5.9
Conclusion
159
CO
CLUSIO
A
D RECOMME
DATIO
6.1
Conclusion
160
6.2
Recommendation
164
REFERE
CES
166
Appendices A-C
173-189
xii
LIST OF TABLES
TABLE O.
TITLE
PAGE
2.1
Supported geometry types in Geo-DBMS
42
2.2
Valid SDO_GTYPE values Oracle (2007)
52
4.1
DBMSs and supported programming language for stored
procedure (Wikipedia, 2010)
85
4.2
Parameters of 3D primitive objects
93
4.3
Rotation Matrix
111
4.4
Location of rotation point
115
xiii
LIST OF FIGURES
FIGURE O.
TITLE
PAGE
1.1
A procedure to store cube in Oracle DBMS
5
1.2
Missing procedure in DBMS
6
1.3
Polyhedron to construct a cylinder
7
1.4
Missing Objects in DBMS level
12
1.5
Basics syntax for the CREATE OR REPLACE PROCEDURE
statement
13
2.1
Several 3D primitive objects
19
2.2
Extended 3D primitives objects
20
2.3
Structure of sphere
20
2.4
Spherical Coordinates
21
2.5
Location of point P by spherical coordinates (r, θ, φ) and
23
rectangular coordinates (x, y, z)
2.6
Sphere with center (xo,yo,zo) and radius R
23
2.7
Points on sphere with radius r
24
2.8
Structure of cylinder
25
2.9
Right Cone
27
2.10
Simple Torus
28
2.11
Structure of Torus
29
2.12
Location of variable c and a in equation 2.29, 2.30 and
30
2.31
2.13
Location of variable u and v in equation 2.29, 2.30 and
31
2.31
2.14
Location u and v in torus structure with x, y and z plane
31
2.15
Exhaustive Enumerations
34
2.16
Quad tree models
35
2.17
Boolean operations on 3D primitive objects using CSG
37
xiv
method
2.18
Modeling cube using Boundary Representation method
38
2.19
Baumgart’s winged-edge data structure
38
2.20
Right Hand Thumb Rules
43
2.21
Polygon drawn counter-clockwise
43
2.22
Direction of normal surface
44
2.23
Oracle Spatial Components
48
2.24
Geometry type in Oracle 11g
50
2.25
Conceptual class diagram of the SDO_GEOMETRY
54
data type
3.1
Location of φ , θ and r on the x,y,z plane
58
3.2
Radius r from centre point of sphere
59
3.3
Polyhedron on the sphere surface (up and bottom)
60
3.4
The degree of round circle is 360°
61
3.5
Divided sector angle is θ = 18°
61
3.6
New points generated along the latitude
62
3.7
Divided sphere diameter
62
3.8
New latitude with its centre point xn, yn, zn
64
3.9
Ten generated latitudes with the origin latitudes
64
3.10
Right triangle is formed after joining all the three points
65
3.11
Triangle in Theorem Pythagoras definition
66
3.12
The right triangle
66
3.13
Complete generated points along the latitudes
67
3.14
Generating Polyhedron from points to model Sphere
68
3.15
Cylinder with height h and radius r
68
3.16
Top and bottom surface of cylinder
69
3.17
Body of cylinder
69
3.18
Location of φ, θ and r.
70
3.19
Generated points at the bottom surface of cylinder
71
3.20
Generated centre points for the top and bottom surface of
71
cylinder
3.21
Generated Polyhedron from points to model Cylinder
72
3.22
Cone with height of h and base radius of r
73
xv
3.23
Collection of face to construct the body and base of cone
73
3.24
Location of φ, θ and r for the circular base of cone
74
3.25
Generated point along the cone base
75
3.26
Generated cone from several points
76
3.27
Torus with the main radius of Rmain and subradius of rtube.
76
3.28
Types of Torus
77
3.29
Constructed torus from rectangle
78
3.30
Collection of polygon faces to construct torus
78
3.31
Circle base geometry for torus
79
3.32
Illustrate the generated points on torus surface based on
80
the centre point and radius R
3.33
Generated points using sub radius r along tube cross
80
section
3.34
Polyhedron to construct torus
81
4.1
PL/SQL in Oracle database server Oracle, 2007
86
4.2
The basic syntax for the CREATE OR REPLACE
88
PROCEDURE statement
4.3
Procedure is created in DBMS
90
4.4
MBR enclosing the geometry
94
4.5
Example of R-Tree index for a set of points
94
4.6
Storage of R-Tree spatial indexes
95
4.7
Area and volume value for cone
103
4.8
Area and volume value for cylinder
106
4.9
Area and volume value for torus
108
4.10
Area and volume value for sphere
110
4.11
Rotation on the axis x, y and z
111
4.12
The left-handed orientation is shown on the left, and the 112
right-handed on the right.
5.1
Data interoperability through Oracle and Bentley
119
5.2
Retrieved cone datasets through CAD viewer
122
5.3
The Geometry of Cylinder in Bentley Map
125
5.4
Retrieved Geometry of Torus in Bentley Map
127
5.5
Visualization of Sphere
129
xvi
5.6
Visualization of half cone from different views
131
5.7
Visualization of half cylinder from different views
132
5.8
Visualization of half torus from different views
133
5.9
Visualization of quarter torus from different views
134
5.10
Visualization of hemisphere from different views
135
5.11
Rotation of cone towards the axis –x Rx(θ) = 90° (right)
136
5.12
Rotation of cone towards the axis –y Ry(θ) = 90°
137
5.13
Rotation of cone towards the axis –z Rz(θ) = 90°
138
5.14
Rotation of cylinder for axis –x Rx(θ) = 90°
139
5.15
Rotation of cylinder for axis –y Ry(θ) = 90°
139
5.16
Rotation of cylinder for axis –z Rz(θ) = 90°.
140
5.17
Rotation of torus for axis –x Rx(θ) = 90°
141
5.18
Rotation of torus for axis –y Ry(θ) = 90°
142
5.19
Rotation of torus for axis –z Rz(θ) = 90°
142
5.20
Rotation of sphere for axis –x Rx(θ) = 90°
143
5.21
Rotation of sphere for axis –y Ry(θ) = 90°
144
5.22
Rotation of sphere for axis –z Rz(θ) = 90°
144
5.23
Simulation of tower structure
147
5.24
SALT building structure SAOO (2010).
148
5.25
Simulation of SALT building
149
5.26
Simulation of pipeline in various directions
150
5.27
Real datasets of building tower in Suleymaniye area
151
5.28
The real image (left) and the constructed tower using 3D
153
primitive objects with cube and faces (right)
5.29
Image of the experimented object
154
5.30
Dome in the AutoCAD format (left) and rendered
155
datasets from DBMS (right)
5.31
Retrieved record from DBMS through SQL function
157
5.32
Different Level of Surface Smoothness on Torus
158
xvii
LIST OF ABBREVIATIOS
2D
-
Two-dimensional
2.5D
-
Two-and-a-half-dimensional
3D
-
Three-dimensional
CAD
-
Computer Aided Design
GIS
-
Geography Information System
DBMS
-
Database Management System
SQL
-
Structured Query Language
CSG
-
Constructive Solid Geometry
B-Rep
-
Boundary Representation
PL/SQL
-
Procedural Language/Structured Query Language
xviii
LIST OF SYMBOLS
A
-
area
Asphere
-
surface area of sphere
Acylinder
-
surface area of cylinder
Acone
-
surface area of cone
Atorus
-
surface area of torus
Awithout top or bottom
-
surface area without the top or bottom
Awith top or bottom
-
surface area with the top or bottom
Tcylinder
-
total surface area of cylinder
π
-
pi = 3.142
r
-
radius
Rmain
-
radius from the center of the hole to the
center of the torus tube
Rtube
-
radius of the tube
V
-
volume
Vsphere
-
volume of sphere
Vcylinder
-
volume of cylinder
Vcone
-
volume of cone
Vtorus
-
volume of torus
θ
-
angle
φ
-
azimuth
h
-
height
s
-
cone side/slant height
c
-
c is the radius from the center of the hole to the center of the
torus tube
a
-
a is the radius of the tube
u
-
angle of torus longitude
v
-
angle of torus latitude
D
-
Diameter of sphere
CHAPTER 1
ITRODUCTIO
1.1
Introduction
In the past few years, Geographical Information System (GIS) has evolved
rapidly due to a great demand on its application. These evolutions of GIS have also
influenced the way we manage, store and manipulate our data. Primitively, we managed
our data in two dimensional (2D) ways that are referred to as two- dimensional GIS. Due
to the development of technology, user requirement and environment, people have
moved forward from 2D GIS to 2.5D GIS and now to 3D GIS. This evolution of
multidimensional GIS came about several years ago and has been discussed by Stoter et.
al (2003), Abdul-Rahman (2006) and Berry (2007). Since then, several approaches
towards 3D GIS have been implemented and today, various fields of study such as urban
planning, underground construction, and telecommunication require the involvement of
GIS in third dimension. It cannot be denied that GIS in 2D has its own advantages and
roles, but its limitations for certain situations have made users to turn to 3D GIS. The
limitations of 2D GIS for 3D situations have been discussed by Zlatanova (2004),
Abdul-Rahman et. al (2002), Oosterom et. al (2002) and Stoter et.al (2003). They
discussed on how 2D GIS limitation confines the analysis, data manipulation,
2
visualization and information of the spatial objects and leads to incorrect understanding
and information.
Due to the restrictions of 2D GIS, users have begun using 3D GIS. 3D GIS can
offer a better understanding and provide better information to users. With regards to this
issue, several researches on 3D GIS have been done in the past few years. Zlatanova et.
al (2002), Stoter et. al (2005), and Abdul Rahman et. al (2002) have discussed and done
some research on 3D GIS concerning various issues such as 3D object visualization,
editing, modeling and future direction. With these attempts, the existence of 3D GIS can
be seen today in many applications, systems and software. For example, an attempt to
realizing a 3D format and tool based on XML format. This 3D XML-based format
known as CityGML, which is an open data model for storage and exchange of virtual
city models. CityGML is a common information model for the representation of 3D
urban objects, and was developed by a group of researchers in Germany (SIG 3D) in
2002. Mainstream GIS software such as ArcGIS (ESRI), PAMAP GIS Topographer
(PCIGeomatics) and Geomedia Terrain (Intergraph) are also embedded with 3D
elements, tools or functions. These 3D elements in GIS software have been discussed by
Zlatanova et. al (2002). Given the effect of various attempts and approaches, 3D GIS has
today emerged as a trend to provide information in various fields and applications.
As widely known, one of the core components in GIS is the database itself.
Database can be defined as an integrated collection of logically related records or files.
While database management system (DBMS) can be defined as a collection of
interrelated data and a set of programs to access those data according to Silberschatz et.
al (2002). The main goal of DBMS is to allow for efficient storage and retrieval of
information. There are two types of DBMSs, which are typical DBMS and spatial
DBMS. Spatial DBMS contains a record or data related to geometry objects such as
point, line and polygon while typical DBMS contains various numeric and character
types of data. Spatial DBMS is more related to GIS, as it allows for efficient storing of
3
spatial and semantic attributes. In addition, the Open Geospatial Consortium (OGC)
created the Simple Features specification and set the standards for adding spatial
functionality to database systems. Standards on a manner of representing, accessing and
disseminating spatial information in a central DBMS were set by OGC as a benchmark
for DBMS vendors in developing spatial DBMS. Thus, DBMS vendors such as Oracle,
PostGIS and Ingres have developed spatial DBMS based on traditional DBMS. As a
result, the current spatial DBMSs are able to maintain spatial data types such as point,
linestring and polygon.
As mentioned before, the current spatial DBMSs are capable of handling several
geometry types such as point, linestring and polygon. These geometry types were
successfully implemented in DBMS level. Moving towards 3D GIS means that 3D data
have to be managed in DBMS level. Furthermore, 2D geometry type in DBMS level is
almost complete while in contrast, 3D geometry type is not completely implemented at
DBMS level. There are still other 3D geometry types that need to be implemented, such
as volumetric geometry type. Thus, this research focuses on how to construct several
missing geometry types based on volumetric shapes at DBMS level.
1.2
Background to the Problem
Today, 3D databases are seemingly one of the important components in
providing spatial information. More GIS users would like to incorporate spatial objects
in such systems, especially 3D spatial objects. The problem is that current spatial
DBMS are still in 2D environment and are quite unmanageable for 3D datasets. 2D
geometry data types in DBMS are almost complete while 3D geometry data types are
limited. For example, Informix DBMS supports three basic spatial data types of point,
4
line and polygon while Ingres supports the additional type of a circle besides the three
basic types. Unlike Informix and Ingres, Oracle DBMS supports more than three basic
types. The supported types are line, point, polygon, circle, arc strings and compound
polygon.
GIS and Computer Aided Design (CAD) are two different systems and both are
designed for different purposes. The CAD system is designed for modeling and
visualizing 3D objects and provides designing tools in many applications such as
modeling, construction and industrial parts. Since CAD is developed for designing
objects, a lot of emphasises was given to editing tools and 3D visualization without
maintenance of attributes and coordinate system as stated by Zlatanova (2004).
Meanwhile, GIS provides the integration of semantic, geometric data and spatial
relationship; according to Stoter et. al (2003), this makes GIS the most appropriate
system for serving spatial applications. Typically, GIS supports only a limited number of
geometry types such as point, line and polygon while CAD system supports more
complex geometry such as sphere, cone, nurbs and etc. However, all these complex
geometries in CAD cannot be manipulated and are quite unmanageable for proper GIS
purposes.
It would be appropriate to have a system to act as a center of spatial information,
so as to provide maintenance of spatial data and attribute in one environment. This
integrated environment between CAD and GIS can be implemented using a system
called DBMS. Thus several DBMS vendors such as Oracle, Informix and PostGIS have
provided a spatial module based on existing DBMS. These DBMSs are capable of
supporting and managing simple geometry, besides some operations and basic geometry
transformations.
5
As mentioned in the preceding section, most of mainstream DBMSs support
basic simple geometry type. Due to the increasing requirement for representing,
accessing and disseminating data from CAD and GIS field, Zlatanova et. al. (2002)
suggested that DBMS should give more support to spatial data type and its operations
especially in 3D environment. There has been an attempt to provide a 3D environment
in DBMS level by supporting 3D points, 3D lines and 3D face and recently a solid
cube, by Oracle (2007). Although all these geometry data types have been successfully
implemented in DBMS level, other geometry types especially those based on
volumetric objects are still missing. Figure 1.1 shows the supported geometry of cube
and its procedure in DBMS and Figure 1.2 shows a volumetric based object i.e. sphere
which is still a problem for spatial DBMS. Thus the construction of volumetric objects
such as sphere, cone and other shapes are investigated thoroughly in this research.
•
•
x1,y1, z1
x2,y2, z2
SDO_GEOMETRY:
3008 – 3-dimensional
solid,
SRID
NULL,
SDO_ELEM_INFO_ARRAY(1
– starting offset,
1007 – solid element
3), – Axis-aligned
box,
SDO_ORDINATE_ARRAY(
x1,y1, z1, -- first end
point (x1,y1, z1 , x2,y2,
z2)– second endpoint
x2,y2, z2);
Figure 1.1: A Procedure to store cube in Oracle DBMS.
6
New Procedure???
Figure 1.2: Missing procedure in DBMS.
A few researches on implementing 3D objects at DBMS level have already been
investigated by a few researchers. The first attempt of 3D spatial data type and
corresponding operations in a spatial DBMS was investigated by Arens (2003) and
Arens et. al (2005), and later extended by Chen (2008). The basic idea of these
researches is that a 3D polyhedron can be defined as a bounded subset of 3D space
enclosed by finite set of flat polygons; hence every edge of a polygon is shared exactly
by one another. Here, the polygons are in 3D space because they are represented by
vertices, which can be 3D points in a spatial DBMS.
Another research related to 3D objects is the modeling of freeform curves and
surfaces by Pu (2005). In his research, Pu (2005) attempted to manage freeform curves
and surfaces in spatial DBMS. In the real world, objects are freeform and not limited
only to points, lines and polygons. Objects such as roads, territory surfaces and earth
surfaces need freeform geometry types or shapes to model it. Freeform shapes can be
simulated by tiny line segments/triangles/polygons but this is quite unrealistic and
inefficient, especially for complex surfaces and huge areas. Therefore, Zlatanova et. al
(2006) introduced a mechanism or procedure to store freeform shapes directly in DBMS.
With this effort, the possibility of developing a new 3D data types in DBMS has been
made obvious.
7
In the preceding section, all of the researches were capable of proving the
possibility of implementing more 3D geometry data types. One of the ways to store 3D
object in DBMS is by a bounded sets of multipolygon or triangle on the objects surface,
as shown by Arens (2003) and Arens et. al (2005) whereby by using this mechanism,
coordinates on each faces would be defined manually. The problem with this
mechanism is that it may be quite inefficient and time consuming to define points on
the object surface, especially when one is dealing with complex objects with a huge
surface. Thus a better and reliable method is needed to generate 3D objects, especially
for volume based objects such as sphere, cylinder and others in DBMS level. Figure 1.3
shows an example of constructing a body of cylinder using polyhedron method. By
inserting the coordinate manually, one has to define the coordinate for all faces to
generate a cylindrical body. From the figures, it is clearly shown a large set of
coordinates is required to generate that 3D object by using polyhedron method.
•• • ••
•
•
•• •••
•
•
• • • ••
Figure 1.3: Polyhedron to construct a cylinder.
As mentioned before, Arens (2003) had done some research on modeling 3D
objects using the polyhedron method. Chen et. al (2008) extended this research by
investigating a suitable way of developing a new 3D data type, polyhedron, for both
geometrical and topological data types and spatial operations. By using this approach,
more 3D objects or solid volumetric objects can be investigated such as Cone, Cylinder,
Sphere and Torus. It is therefore possible to model objects using a certain modeling
technique and construct them in DBMS with new procedure.
8
Based on the discussion above, it can be seen that there is a possibility of
creating and implementing more 3D objects, especially 3D primitive objects, in DBMS
level. This research focuses on how to model and construct 3D primitive objects, then
implement the constructed objects in DBMS.
1.3
The Problem Statement
Several spatial DBMSs such as Oracle, PostGIS and Postgres are able to manage
simple geometries such as point, line, polygon, arc string and many more. Due to a great
demand for 3D application, several spatial DBMSs have recently added and supported
3D simple features such as 3D line, 3D point and 3D polygon. In the past few years,
several researchers have carried out investigations on how to incorporate 3D objects in
DBMS level, as exemplified by Arens et. al (2002), Arens (2003), Pu (2005) and Chen
et. al (2008). Arens (2003) had come out with a basic idea of 3D polyhedron, which was
later extended by Chen et. al, (2008). This method is quite inefficient especially for
modeling complex objects, as it is time consuming. Recently, Oracle (2007) added a
simple solid cube in the DBMS but it is still limited for other complex objects and solid
objects. None of the available procedures in current DBMSs are capable of creating the
other type of solid objects, especially basic 3D primitive objects such as Cone, Cylinder,
Sphere and Torus. Even so, it is important to have those objects in DBMS in order to
have a full 3D environment in spatial DBMS; hence a better and reliable way to
construct those objects in DBMS needs to be investigated. Thus this research area
focuses on how to construct 3D primitive objects and implement the objects in DBMS
level.
9
1.4
The Aim
The aim of this research is to investigate new 3D objects representation based on
sphere, cone, cylinder and torus, and incorporate all these objects with spatial DBMS.
Queries are performed from the developed database.
1.5
The Objectives
In this research, there are three objectives to be achieved and completed. The
objectives are:
1. To design 3D primitives based on sphere, cone, cylinder and torus for geospatial
DBMS.
2. To develop a database for the 3D objects.
3. To test the object by using real dataset and simulation dataset and perform
queries from the developed database.
1.6
The Scope
In this research there are three main scopes to be applied. The scopes are the
objects, the datasets and the software and hardware used in this research. In the
following paragraph, details for every scope are listed.
10
1.6.1. The Objects
In this experiment, only four primitive objects are used to be implemented in
DBMS level. The objects are Cone, Cylinder, Sphere and Torus. Each object is
constructed with suggested minimum number of points on the object to get the exact
shapes of the object. Every object may have different minimum number of points. The
numbers of points on each object are:
i.
Sphere
Minimum number of points along the latitude of sphere is determined to
20 points. 10 latitudes plus the origin latitudes are used to construct a
sphere. Thus minimum numbers of points are 220 points.
ii.
Cylinder
On the top and bottom of the cylinder, 20 minimum numbers of points is
generated along the circular based. Total minimum numbers of points to
construct a cylinder are 40 points.
iii.
Cone
Along the circular base of cone 20 points is defined and 1 point is defined
on the top of the cone. Thus the total numbers of minimum points on the
cone surface are 21 points.
iv.
Torus
Torus is divided into two parts of cross section. The main cross section is
latitude cross section while the other one is tube cross section. Both are
formed from circle base. For the latitude cross section, 20 points are
defined. While for the tube cross section, the circle is divided into 10
11
parts for 10 points. Total minimum number of points on the torus surface
is 200 points.
1.6.2. The Datasets
In this experiment, two type of data set are used. The datasets are:
i.
Real datasets
In this research, the datasets are derived from architecture drawings in
CAD within Suleymaniye area, Istanbul, Turkey. Only certain parts of the
building are modeled using 3D primitive objects in this experiment, which
are the parts based on sphere, cylinder, cone and torus forms.
ii.
Simulation datasets
3D primitive objects are tested using simulation datasets.
1.6.3. The Software and Hardware
The software and hardware for this research are:
•
Oracle Spatial 11g R2 as a DBMS to store spatial datasets
•
Bentley Map as a spatial viewer
•
PL/SQL language as a platform to compile new procedure in DBMS
•
Stored procedure is used as a platform to launch the created procedure
12
1.7
Brief Methodology
There are five phases of methodology in this research. Each phase is explained in
the following paragraph:
Phase 1: Object Modeling
i.
In this phase, several 3D primitive objects are identified. The objects
are:
(a) Sphere
(b) Cylinder
(c) Torus
(d) Cone
Figure 1.4 shows several identified object are missing in DBMS level.
(a) Sphere
(b) Cylinder
(c) Torus
(d) Cone
Figure 1.4 Missing Objects in DBMS level.
ii.
Every object’s formula is identified
iii.
A suitable technique to model the objects is investigated
13
Phase 2: Create a Procedure for 3D Primitive Objects and Load the
procedure in DBMS.
In this experiment, a function called stored procedure in DBMS is used as a
platform to create and launch object’s procedure. Possible compilers such as Java
and PL/SQL are used as a compiler to develop the procedure. The procedures are
then loaded in DBMS. The following railroad diagram in Figure 1.5 illustrates
the basic syntax for the
CREATE OR REPLACE PROCEDURE
statement using PL/SQL
language in stored procedure:
Figure 1.5: Basics syntax for the CREATE OR REPLACE PROCEDURE statement
(Urman et. al. 2004)
After creating the procedure, it is loaded in the database. Procedure is loaded
only for the first time. After that,
CALL
statement is used to call the procedure.
Wrapping the procedure into .plb format is easier than running the long
procedure code and the procedure can be wrapped from command prompt. In this
research, procedure is called the SQL*Plus interface.
14
Phase 3: Create a Database for 3D Primitive Objects and Call Created
Procedure
The table is designed based on the constructed objects in Phase 3, after which
each created table must be indexed as a prerequisite for the created procedure to
be ready for execution. Each table must be indexed with spatial indexes to speed
up query on the tables. Spatial index is considered as a logical index. Several
issues that should be considered in this phase are updating the user sdo geometry
metadata and the index parameter.
Phase 4: Integrating DBMS and CAD Viewer
CAD viewer is a suitable viewer for visualizing objects from DBMS. There are
several CAD applications capable of visualizing and modeling objects from
DBMS such as Bentley and Autodesk. In this research, Bentley Map is used as a
viewer. To integrate Oracle DBMS and CAD viewer, interoperability function is
used to connect both of this system.
Phase 5: Test and Query from the Developed Database
i.
Result is viewed using CAD viewer in order to test stored datasets in
DBMS.
ii.
Query is performed from DBMS based on stored dataset.
15
1.8
Research Workflow
Create Procedure
Compile the
objects
Procedure
•
•
Possible Volumetric Objects
Create Table
Update Metadata
Indexed
LOAD
Execute Procedure
Retrieve data using CAD
Viewer
Query
Query the developed database
Figure 1.6 Research workflow
16
1.9
The Thesis Structure
Chapter 1 starts with the introduction of 3D GIS and issues related to spatial DBMS.
This chapter also includes the background on the research aspects such as background of
the problem, the problem statement, the objectives, the aims, the scopes, the
methodology, summary of methodology and the thesis structure.
Chapter 2 discusses and reviews some related literature. The related literature includes
objects modeling, 3D primitive objects, spatial DBMS and its issue. From the reviewed
literature, a method to construct 3D primitive objects is also discussed.
Chapter 3 explains how to construct and model 3D primitive objects based on the
reviewed literature. This chapter also highlights the conceptual model of 3D primitive
objects.
Chapter 4 is regarding the implementation of constructed 3D primitive objects in
DBMS. The main process in this chapter is on how to structure data and map the
conceptual model in DBMS.
Chapter 5 discusses the test or experiment towards implemented objects in DBMS. The
query is performed and the results are discussed in this chapter.
Chapter 6 discusses the conclusion of this research. Several recommendations for future
works are also listed.
17
1.10
Conclusion
As previously mentioned, this research is an attempt to implement more 3D
objects in DBMS level as there are several geometry types still missing in DBMS level.
Therefore this research focuses on missing geometry types in DBMS that are based on
volumetric objects, which are sphere, cylinder, torus and cone respectively. The
combination of this shape may be useful in giving a better description of objects around
us. This research might be useful to help users solve a certain issue or aspect in 3D GIS.
Thus, this research needs to be continued as an approach to provide full 3D environment
in DBMS level.
CHAPTER 2
3D PRIMITIVE OBJECTS AD SPATIAL DBMS
2.1
Background
In this chapter, several issues and topics related to this research are explained
and reviewed. In the first section, primitive objects are defined. Each primitive object
is defined together with its mathematical definition and equation, after which several
techniques for modeling solid objects are reviewed and discussed. The techniques are
Decomposition Model, Constructive Solid Geometry (CSG) and Boundary
representation (B-Rep). The next section discusses on Polyhedron and Polyhedron
orientation. Spatial DBMS is then briefly explained in the following section, which
also includes the review of several topics related to spatial DBMS such as geometry,
dimension and volumetric objects in DBMS level. The last section in this chapter
discusses the ability, advantage and supported features in Oracle Spatial.
19
2.2
Primitive Objects
The word primitive is also known as base or basic. In computer science, basic
and simple solid models are known as 3D primitive objects. Primitive objects are a
base for creating more complex objects. There are several types of primitive objects,
with the most common 3D primitive objects being Cubes, Pyramid, Cone, Sphere,
Cylinder and Torus. Figure 2.1 shows several commonly used 3D primitive objects.
Figure 2.1: Several 3D primitive objects.
According to Giambruno (2003), all basic primitive objects can be extended
to other shapes, which are known as “extended” 3D primitives. Extended 3D
primitive objects are more complex rather than basic primitives. Figure 2.2 shows
several shapes of extended primitive objects such as Filleted Cube, Spindle, Bevelled
Cylinder, Torus Knot, Capsule and Star Polyhedron, which are only available in
several applications or programs due to their difficult-to-model-shape. These
complex objects are actually designed based on the combination of primitive objects,
and the combination of these objects are capable of forming man-made objects such
as building (combination of cube, pyramid, cone, sphere), tower (combination of
cylinder and cone) and utilities (combination of torus and cylinder). This research
focuses only on four types of 3D primitive objects which are cone, cylinder, torus
and sphere.
20
Figure 2.2: Extended 3D primitives objects (Giambruno, 2003).
2.2.1 Sphere
Sphere can be defined as a round object in three dimensional Euclidean R3
space. It can also be said that the sphere surface is covered by several points that are
located at equal distance from its center point. The distance from center point of a
sphere to any given point on sphere surface is known as radius, r. Diameter is twice
the radius r, and pairs of end point of diameters are called antipodes. According to
Weisstein (2005), any cross section through a sphere is a circle. The maximum size
of circle is the plane that defines the cross section passing through the diameter. The
structure of sphere could be explained in Figure 2.3.
r
Figure 2.3: Structure of sphere
21
The surface area, Asphere and volume of a sphere, Vsphere are given by:
Asphere = 4πr2
(2.1)
Vsphere = 4πr3
3
(2.2)
2.2.1.1 Spherical Coordinates
Spherical coordinates are also known as spherical polar coordinates. It is a
curvilinear coordinates system for describing location on spherical geometry.
According to Weisstein (2005), in his spherical coordinates article, θ is the azimuthal
angle in x y plane from the x – axis with 0 < θ < 2π, φ is the polar angle and is also
known as zenith angle and colatitudes. φ is equal to 90° - σ where σ is the latitude
from positive z – axis with 0 < φ < π and r is the radius from the origin or centre
point. This convention is commonly used in mathematics. Figure 2.4 explains the
location of r, θ and φ.
Figure 2.4: Spherical coordinates (Weisstein, 2005).
Several different conventions exist for representing three coordinates and the
order in which they should be written. The use of (r, θ, φ) to denote, respectively,
radial distance, inclination (or elevation), and azimuth, is common practice in
22
physics.To define a unique set of spherical coordinates for each point, one may
restrict their ranges. A common choice is:
r≥0
(2.3)
0° ≤ θ ≤ 180° (π rad)
(2.4)
0° ≤ φ < 360° (2π rad)
(2.5)
However, the azimuth φ is often restricted to the interval (−180°, +180°), or (−π, +π)
in radians, instead of [0, 360°). This is the standard convention for geographic
longitude. The range (0°, 180°) for inclination is equivalent to (−90°, +90°) for
elevation (latitude).
According to Conrad (2011),a point P can be located by spherical coordinates
(r, θ, φ) as well as rectangular coordinates (x, y, z). The spherical coordinates (r, θ,
φ) are related to the Cartesian coordinates x,y,z by this following equation 2.6, 2.7,
2.8, 2.9, 2.10 and 2.11:
r =√ x2 + y2 + z2
(2.6)
θ =tan-1 y
(2.7)
φ = cos-1 z
rx
(2.8)
x = r cos θ cos φ
(2.9)
y = r cos θ sin φ
(2.10)
z = r sin θ
(2.11)
x
This equation could be explained in the Figure 2.5.
23
Figure 2.5: Location of point P by spherical coordinates (r, θ, φ) and rectangular
coordinates (x, y, z) Petrov, (2005).
Figure 2.6: Sphere with center (xo,yo,zo) and radius R, Petrov (2005)
A sphere with center (xo, yo, zo) and radius R is the locus of all points (x, y, z) as
shown in Figure 2.6. Such that equation 2.12 is explained a sphere centered at the
point xo, yo, zo with radius R is:
(x - xo)2 + ( y - yo )2 + ( z - zo )2 = R2
(2.12)
24
x,y,z
Figure 2.7: Points on sphere with radius r, Wikipedia, (2010)
According to Wikipedia (2010), points on sphere with radius r (see Figure 2.7) could
be parameterized via equation 2.13, 2.14 and 2.15.
x = xo + r cos θ cos φ
(2.13)
y = yo + r cos θ sin φ
(2.14)
z = zo + r sin θ
(2.15)
where 0 ≤ φ ≤ 2π and 0 ≤ θ ≤ π.
2.2.2 Cylinder
The geometry of a cylinder is very basic, with a circular base shape on its top and
bottom. In differential geometry, a cylinder is defined more broadly as any ruled
surface spanned by a one-parameter family of parallel lines. A cylinder with a cross
25
section in the form of an ellipse, parabola, or hyperbola is called an elliptic cylinder,
parabolic cylinder, or hyperbolic cylinder respectively. A cylinder is called a right
cylinder if it is straight, with its cross sections lying directly on top of each other;
otherwise, the cylinder is said to be oblique. Figure 2.8 shows a structure of
Cylinder.
h
r
Figure 2.8: Structure of cylinder
According to Weisstein, (2005) the surface area of cylinder Acylinder and volume of
the cylinder Vcylinder of height h and radius r (see Figure 2.8) is explained by equation
2.16 and 2.17.
Acylinder = 2 π r h
(2.16)
Vcylinder = π r2 h
(2.17)
If the top and bottom surface are included, the total surface area of a cylinder Tcylinder
is then calculated by using equation 2.18 and 2.19 where r is the radius and h is the
height of cylinder.
Tcylinder
= 2 π r h +2( π r2)
(2.18)
= 2 π r (r + h)
(2.19)
Cylinder is taken to mean a finite section of a right circular cylinder as stated in
Wikipedia (2010), with its ends closed to form two circular surfaces, as shown in
Figure 2.8. If the cylinder has a radius r and length (height) h, then its volume
Vcylinder is given by the equation 2.20.
26
Vcylinder = 2 π r (r + h)
(2.20)
and its surface area is:
•
area of the top (π r2) +
•
area of the bottom (π r2) +
•
area of the side 2 π r h.
Therefore without the top or bottom, the surface area could be calculated using the
equation 2.21
Awithout top or bottom = 2 π r h
(2.21)
Whereas with the top and bottom, the surface area could be calculated using the
equation 2.22.
Awith top and bottom = 2(πr2) + 2πrh = 2πr (r + h)
(2.22)
2.2.3 Cone
A cone is generally a three-dimensional geometric shape that tapers smoothly from a
flat, usually circular base to a point called the apex or vertex, or otherwise identified
as a pyramid with a circular cross section. A right cone is a cone with its vertex
above the center of its base. However, when used without qualification, the term
cone usually refers to a right cone Weisstein, (2005). Figure 2.9 shows the right
cone.
27
s
h
r
Figure 2.9: Right cone
For a circular cone (see Figure 2.9) with radius r and height h, the formula for
volume of cone Vcone could be obtained via equation 2.23
Vcone = 1 πr2h
3
(2.23)
For a right circular cone, the surface area of cone, Acone could be calculated through
equation 2.24:
Acone = πrs
(2.24)
Where s is the slant height (see figure 2.9). s could be obtained by using equation
2.25.
s = √r2 + h2
(2.25)
28
2.2.4 Torus
Torus is also known as tori, and its geometry is generally a surface of revolution
generated by revolving a circle in three dimensional spaces around an axis coplanar
with the circle. Torus is also available in the form of simple torus, horn torus and
spindle torus. Figure 2.10 shows a simple torus. A degenerate case is when the axis is
a diameter of the circle and surface is a sphere. The ring torus bounds a solid known
as a toroid; it should also be noted that the adjective of toroidal can be applied to tori,
toroids or, more generally, any ring shape as in toroidal inductors and transformers.
Real world examples of approximately toroidal objects include doughnuts, inner
tubes, O-rings and Vortex rings.
Figure 2.10: Simple Torus, Moore and Smith (2003)
According to Weisstein (2005) and Irons (2005), the surface area of torus ATorus and
volume of torus VTorus can be easily computed using Pappus's centroid theorem (see
equation 2.26 and 2.27):
ATorus = π2 x (Rmain2 – rtube2)
(2.26)
VTorus = 1 π2 X (Rmain + rtube) X (Rmain - rtube)2
4
(2.27)
29
Where,
Rmain is the distance from the center of the tube to the center of the torus and rtube is
the radius of the tube. Figure 2.11 shows the structure of torus..
+
Rmain
rtube
Figure 2.11: Structure of Torus
In Cartesian coordinates for a torus azimuthally symmetric about the z-axis, it could
be parameterized by equation 2.28:
(c – √x2 + y2)2 + z2 = a2
(2.28)
Where c is the radius from the center of the hole to the center of the torus tube which
is Rmain (see figure 2.11), and a is the radius of the tube which is rtube (see figure
2.11).
Parametric equations for torus could be parameterized in the following equations
2.29, 2.30 and 2.31
x = (c + a cos v) cos u
(2.29)
y = (c + a cos v) sin u
(2.30)
z = a sin v
(2.31)
30
Where:
c is the radius from the center of the hole to the center of the torus tube
a is the radius of the tube
u and v is parametric variables in the interval [0,2π]
All of the above variables in equation 2.29, 2.30 and 2.31 could be described in the
following figure 2.12 and 2.13. Figure 2.12 shows the location of c which is the
radius from the center of the hole to the center of torus tube. Figure 2.12 also shown
the location of a which is the radius of tube.
Radius from centre
of the hole
•
Centre of the hole
•
Radius of the tube
Centre of the tube
Figure 2.12: Location of variable c and a in equation 2.29, 2.30 and 2.31
For the variables u and v where the value is in the interval [0,2π], it could be describe
as the angle of latitude and longitude of the torus structure. Following Figure 2.13
explain the location of u and v (Irons,2005).
Figure 2.13: Location of variable u and v in equation 2.29, 2.30 and 2.31
(Irons, 2005)
31
Figure 2.14 gives a detail description to obtain u and v value by describing the torus
structure with x, y and z plane. From the Figure 2.14 we could obtain the value of u
and v by getting the angle of both variables.
Figure 2.14: Location u and v in torus structure with x, y and z plane, Moore and
Smith (2003).
2.3
Solid Modeling
Object modeling is a technique for constructing objects using geometrical
functions based on its original structure. Mortenson (1997) defined geometric
modeling as the method used to illustrate the shape of an object. Modeling is usually
built to scale the real object and represent it into another detail. Modeling objects can
also help users in interpreting and understanding constructed objects directly without
having familiarity with the real objects. Modeling object in DBMS level does not
only deal with the way the object is constructed; instead it is also about how the
database stores the object’s structure. As mentioned in the previous section, 3D
objects have yet to be fully implemented in DBMS level. Thus issues, problems and
challenges pertaining to the modeling of 3D objects in DBMS level have been
32
investigated since several years ago by Stoter et. al (2002), Arens et. al (2003),
Peninnga (2005), Pu (2005) and Chen (2008).
In computer graphics and CAD, there are several types of 3D object modeling
such as surface modeling, solid modeling, wireframe modeling and feature based
modeling. This paper focuses on solid modeling to model 3D objects. Solid modeling
is used as the ultimate tool in many fields such as manufacturing, engineering and
industry, and was introduced since the 1980’s (Holly, 1999). Originally, basic solid
models comprised of cone, torus, cylinder, pyramid, tube and sphere. These basic
solid models are also known as 3D primitive objects. The characteristic of solid
model is that it is not limited to the edges and surfaces of the object, and also the
volume enclosed by those surfaces. According to Hoffman et. al (1996), any solid
representation should admit the unambiguous, algorithmic determination of point
membership. Given any point in the equation:
p = (x, y, z)
(2.32)
The point p must be able to algorithmically define whether the point is inside,
outside, or on the surface of a solid model. Each type of 3D object modeling has its
own advantage in modeling objects. One major advantage of solid modeling is that
the spatial integrity of the solid model can be verified computationally (LaCourse,
1995). By using solid modeling, it is easy for the user or designer to construct virtual
or software prototypes for visualization and analysis purposes. The other advantage
of solid modeling is the realistic and unambiguous visual display which permits the
user or designer to see exactly what was created. Thus, solid modeling has become a
preferred solution in modeling 3D objects.
Modeling solid objects into the database requires several techniques to
construct and structure the objects. Three dominant modeling techniques for solid
objects are Boundary representation (B-Rep), Constructive Solid Geometry (CSG)
and Decomposition models. Other techniques such as instances or parameterized
33
shapes, spatial occupancy enumeration, and wire frame representation are less widely
used.
2.3.1 Decomposition Models
In Decomposition models, solid objects are represented in a variety of
decomposition schemes. Solid objects are decomposed into cells and each cell built
with a simple geometric structure. According to Patrikalakis (2003), there are three
categories of decomposition model, which are the Exhaustive Enumeration,
Boundary Cell Enumeration, Space Subdivision and Cell Decomposition).
•
Exhaustive Enumeration
Exhaustive enumeration is a representation using cubes with a regular
size, orientation, and non-overlapping as shown in figure 2.15. For each
object, three dimensional Boolean arrays is represented together with a
volume of space for cell cubic volume. It is consider having a true value
once a cell intersects with the region of interest. Otherwise, the value is
false. As stated by Patrikalakis (2003), the representations are:
Regular subdivision of space.
Storing just one corner of each cube.
The requirement of just a 3-D array, Cijk of binary data, and
overall box/space coordinates for fixed space of interest are in the
equation 2.33:
34
Cijk =
1 if the cube i,j,k intersects the solid
(2.33)
0 if the cube i,j,k is empty
There are several applications of exhaustive enumeration methods
listed by Patrikalakis (2003) the methods are:
The representation of underwater environment.
Finite elements meshing.
The representation of Medical 3D data.
Speeding up operations in other representations such as
approximating integral properties e.g. (volume, centre of
gravity, moments of inertia, and distance transformations). All
of
these
operations
are
done
as
a
pre-processing
representation.
Figure 2.15: Exhaustive Enumerations, Patrikalakis (2003).
•
Boundary cell enumeration
This is a boundary-based version of the previous technique, with only the
cells that intersect region boundaries having true values.
35
•
Space subdivision
The incentives behind space subdivision methods include:
Smaller memory requirements
Quad tree representations leading to a recursive subdivision into 8
octants that can be represented as an 8-ary tree (see Figure 2.16)
Figure 2.16: Quad tree models (Patrikalakis, 2003).
•
Cell Decompositions
This model is often used to achieve finite element and scientific
visualization, with the elements of cell decompositions involving other
than cubes. By using this method, cells become parameterized instances
of a generic cell type, eg. a cell bounded by quadratic curves and surfaces.
Under this method, cells meet at a vertex, edge or face; otherwise the
36
representation is invalid and cells become disjoint and non-overlapping.
The properties of cell decomposition methods are:
Expressive power: very general and accurate
Validity: requires an intersection test for verification
Unambiguous representation
Non-unique
Generation: by conversion from other representations
Concise: memory utilization is less than octrees
Applicability: finite element meshing, multi-material, nonhomogeneous objects
2.3.2 Constructive Solid Geometry (CSG)
Constructive Solid Geometry is a technique to form new shapes by using 3D
primitive objects (solid primitive). The most popular constructive representation,
CSG involves joining or cutting 3D primitive objects such as cylinder, cone and
sphere with Boolean operators. The primitive objects may be assigned multiple times
with different parameter values, positions, and orientations. The primitive objects
may also be transformed through rigid body motions such as by combining rotations
and translations or scaling, and the resulting transformed objects may in turn be
combined by using Boolean operations i.e. union, intersection, and difference. These
operators perform the corresponding set theoretic Boolean operations, and then
transform the result into the set by applying the topological interior operation and
later by the topological closure. This procedure always returns valid solids.
Furthermore, these three Boolean operators are convenient and sufficient as amongst
the 16 different Boolean combinations of two sets, A and B, 8 are unbounded, 3 are
trivial, and only 5 are useful for solid modeling:
37
•
union A+B
•
intersection A ∩ B
•
differences A-B and B-A (Example, Figure 2.17)
•
symmetric difference, (A-B)+(B-A)
A
B
Difference A - B
Figure 2.17: Boolean operations on 3D primitive objects using CSG method
CSG representations are concise and easily parameterized and edited. Many
solid modeling algorithms also work directly on CSG representations. However,
CSG representations do not include any explicit information on the connectivity or
even the existence of the corresponding solid. Hence these topological questions are
best addressed through some form of boundary evaluation such as Boundary
Representation (Tsuzuki et. al., 2007).
2.3.3 Boundary Representation (B-Rep)
Boundary representation is a method that represents the surface of solid
objects. A solid surface is represented as a quilt of faces, edges and vertices. In other
words, the object can be fully described by its boundary with each face acting as a
subset of the complete boundary. Geometrically, the entities in Boundary
38
Representation must not intersect anywhere except in edges and vertices that are
explicitly represented in the topological structure (Hoffman et. al., 1996). Figure 2.18
shows an example of an object as depicted in Boundary Representation.
Figure 2.18: Modeling cube using Boundary Representation method.
Boundary Representation models contain two parts of information, which are
geometry and topology. The main geometric items are faces, edges and vertices. A
face is a bounded subset of complete boundary, an edge is a bounded piece of a line
and a vertex lies at a point. The important aspect of a Boundary Representation
model is the connectivity present amongst the topological items i.e. faces, edges and
vertices. The most popular data structure type in defining such connectivity is
Baumgart’s winged-edge data structure. Figure 2.19 below shows the structure of
Baumgart’s winged-edge data structure.
Figure 2.19: Baumgart’s winged-edge data structure (Xu, 2009).
39
According to Xu (2009), the winged-edge data structure uses edges to keep
track of almost everything and to traverse various entities in the model. This can be
exemplified by the cube in Figure 2.18 forming 6 faces, with each face containing a
loop of 4 edges. Two faces are shared by one edge, each edge is bounded by 2
vertices and every vertex is shared by three edges.
Prior to modeling an object, it is necessary to consider the advantages and
disadvantages of the method. Several features may not be compatible or reliable in
constructing the objects. Due to this, the advantages and disadvantages of Boundary
Representation method were investigated and the properties listed in the following
paragraphs:
Advantages:
•
Closely related to traditional drafting
•
Can store very complex geometries
•
Easy to propagate changes to faces, edges and vertices
•
Can easily generate and store complex surfaces
•
Appropriate for constructing solid models of unusual shapes
•
Can be used to mimic CSG
•
It is relatively simple to convert a B-rep model into a wireframe
model
Disadvantages:
•
High level information is still not present in model
•
Requires large amounts of storage
•
Hard to recognize some simple features like a block
Given its simplicity of structure compared to other methods, Boundary
Representation has been widely used in modeling objects. Several researchers have
attempted to model objects in DBMS level using Boundary Representation
technique, such as Arens (2003), Stoter and Zlatanova (2003) and Arens et. al
40
(2005). Most of the utilized objects in those researches were based on simple
structures such as cube and flat building. From these researches, it is seemingly easy
and simple to model objects using Boundary Representation method.
After comparing and analyzing all possible methods and techniques,
Boundary Representation was chosen to construct 3D primitive objects in this
research due to its advantages and flexibility in modeling complex objects, as well as
its characteristic of easily propagating changes to faces, edges, and vertices. Due to
its uncomplicated method, many systems support this technique such as CAD and
Parasolids. Even if the CSG method was chosen, Boundary Representation can
imitate the implementation of the technique. Thus, Boundary Representation seems
to be the most compatible technique for this research.
2.4
Polyhedron
3D geometric primitives are a common basic geometry comprising of point,
line, polygon, triangle, circles, spline, curve and ellipse. These have been
successfully implemented in spatial DBMS, with the exception of geometry based on
volume (3D primitive object). There are a number of geometric primitives and 3D
primitives in modeling 3D objects such as Tetrahedron, Polyhedron and Polyhedron,
combined with spherical and cylindrical patches. However, only certain models are
compatible with the B-rep Method. As mentioned before, polyhedron has the
potential for modeling 3D objects and modeling objects by using polyhedron has
been successfully investigated by Arens (2003) and Arens et. al (2005). Polyhedron
can be realized in DBMS by storing x, y, and z vertices, with the arrangement of
vertices described by each polyhedron face. Polyhedron can be recognized by its own
characteristics, as discussed by Aguilera and Ayala (1997), Aguilera (1998), Arens
(2003), Chen (2008) and Chandra and Govardhan (2008 ). The characteristics are:
41
i.
Flatness
•
Polygons that make up a polyhedron must have to be flat. It can be
verified by the following equation 2.34:
Ax + By + Cz + D = 0
ii.
(2.34)
Single Volume or 2-Manifold
•
A set of polygons that make up a polyhedron should be bounded as a
single volume. This can be done by following the rule whereby each edge
must be shared with only 2 polygons. If an edge is shared by more than 2
polygons, the polyhedron may consist of at least 2 volumes that would
defeat its single volume characteristic.
iii.
Simplicity
•
Each edge has exactly 2 vertices only.
•
The starting and ending points of a polygon is same, and is only be stored
once.
•
Polygon must have an area.
•
Lines from a polygon must not self-intersect.
•
Singularity of polyhedron is not allowed, lower dimension object must
not exist in the interior of higher dimension.
•
iv.
The inner rings of faces are not allowed to interact with the outer ring.
Orientable
•
Vertices of the face must be specified in counter-clockwise order, which
means that the face is seen from inside to outside.
•
Vertices in inner rings of faces need to be ordered in the opposite
direction (clockwise).
v.
Euler’s Law
•
Euler proved in 1752 that polyhedrons are topologically valid if they
satisfy the following equation 2.35:
42
F – E + V – L = 2(B – G)
(2.35)
Whereby F, E, V, L, B, and G refer to the number of faces, edges,
vertices, faces’ inner loop, bodies, and genus respectively. Equation (1) is
known as the Euler or Euler-Poincare law. Open objects satisfy the
following Euler’s law (equation 2.36):
F–E+V–L=B–G
•
(2.36)
To validate a B-Rep model, Euler’s law states that a polyhedron is
topologically valid (or a sane solid) if the following equation 2.37 is
satisfied,
F–E+V=2
2.5
(2.37)
Polyhedron Orientation
In order to represent a solid object by its surfaces, the orientation of each
surface should be defined to show the inside or outside of the object. By convention,
the inside is the material and the outside is the void space. The direction of the face is
often regarded as the orientation of the face; meanwhile the face that carries the
orientation information is referred to as the orientable surface, which is constantly
defined to be always pointing away from the solid. Since a solid is bounded by
orientable surfaces, one can define solid objects by a set of faces.
In this research, polyhedron is utilized to model 3D primitive objects.
Polyhedron is stored in the database with several sequence oriented points on the
polygon surface. There are two types of orientation rules, clockwise and anti-
43
clockwise. A clockwise rule is defined to show the inside of the object while an anticlockwise rule shows the outside of the object.
Each polygon surface points
outwards from the solid that it binds, and this can be illustrated by the right-hand
thumb rule. Figure 2.19 shows the right-hand thumb rule.
Figure 2.20: Right Hand Thumb Rules (Morse, 1998)
From the Figure 2.20, it can be seen that the fingers would curl towards 90
degrees when the thumbs point in the positive Z - axis rotation. The direction of
curling fingers shows the counter-clockwise direction. To define a polygon surface
orientation, the right-hand should be held with curling fingers as the polygon surface
in order to see from the outside of the object. As illustrated by Morse (1998) in
Figure 2.21, a normal polygon is illustrated by drawing counter-clockwise.
Figure 2.21: Polygon drawn counter-clockwise (Morse, 1998)
44
Spatial DBMS does not demand the orientation of polygon surface. For
instance, it was stated in the Oracle documentation that the order of vertices is not
stipulated in the Oracle DBMS. However it was implicitly specified that the surface
is normally defined using the “right-hand thumb” rule. If the fingers curl along the
order of the specification of the vertices, the outward thumb is the direction of the
surface normal for the polygon (Kothuri, 2007) as shown in Figure 2.22.
Figure 2.22: Direction of normal surface (Kothuri, 2007)
2.6
Spatial Database Management System
Spatial objects is something related to space. The word spatial itself is
derived from the word ‘space’. Geographic and geometry data are things that very
much spatial-related, and can be exemplified by the earth surface (geographic data)
or man-made objects or anything around us as long as it relates to space. These
spatial data need to be managed, manipulated, stored and controlled by a system;
however the advent of spatial database management system or Geo-DBMS has
caused several problems regarding this issue (Guting, 1994).
45
Before the advent of spatial DBMS, spatial data was organized in two
separated data management systems. The separated data management systems are
Relational DBMS for administrative data and GIS for spatial data (Zlatanova, 2007).
To date, most mainstream DBMSs such as Oracle, PostGIS, MySQL, Informix and
Ingres offer spatial data types and spatial functions. These mainstream DBMSs are
extended in terms of object-relational from Relational DBMS (Zlatanova and Stoter,
2006). From the database, users could query both spatial and semantic features. The
supported spatial features in spatial DBMS are in two dimensional and three
dimensional features, with the simple two dimensional features fully supported in the
DBMS while the management of fully-3D features is still being investigated,
especially in 3D modeling, analysis and presentations. The following section
discusses supported geometry and dimension in spatial DBMS, after which modeling
objects in spatial DBMS is discussed.
2.6.1 Geometry and Dimension in Spatial DBMS
Different database vendors offer different numbers of supported geometry
and dimensions in DBMS, but most spatial databases offer the same functions in
managing spatial data. Basic geometries that are supported in spatial DBMS are
point, line and polygon, which have been extended to other geometry such as circle,
line string, arc and polygon.
As mentioned before, two dimensional features have been fully implemented
in spatial DBMS as compared to 3D features. However, most DBMSs including
Oracle, Postgres, IBM, lngres and Informix support the storage of simple features in
3D space such as 3D point, 3D line and 3D polygon. Hence it is generally possible to
store 3D features as a geometrical model i.e. polyhedrons using 3D polygons. A
possibility of having a 3D geometrical primitive in DBMS level is shown by Arens et
al. (2003). In this study, 3D objects as polyhedron were defined as part of the
46
geometrical spatial model of Oracle Spatial, including validation functions and
spatial functions in 3D. The following Table 2.1 shows several mainstream spatial
DBMSs and the supported geometry type.
Table 2.1: Supported geometry types in Geo-DBMS
Spatial DBMS
Geometry Type
Oracle
Points and point clusters, Line string, n-point polygons,
Arc line strings,
Arc polygon, Compound polygons,
Compound line strings, Circles, Optimized rectangles
Informix
Point,
LineString,
Polygon,
MultiPoint,
MultiLineString,MultiPolygon
PostGIS
Linestring,
Polygon,
Multipoint,
Multilinestring,
Multipolygon, Geometrycollection
MySQL
Point
,
LineString,
MultiLineString,
Polygon,
MultiPolygon,Geometry Collection
2.6.2 Volumetric Object in Spatial DBMS
Most of 3D features are volumetric objects. Volumetric objects can be used to
model man-made objects such as building and utilities, and even natural objects such
as geological formation. Until today, no volumetric objects have been implemented
47
in spatial DBMS. Only simple volumetric primitive objects i.e. cube was
implemented in Oracle Spatial database (Oracle, 2007).
To enable these volumetric objects managed in the database, users can choose
to model the object based on created geometry types in DBMS or by creating userdefined types. These approaches were previously discussed by Zlatanova (2007). The
first option can be realized by provided data types i.e. polygon or multipolygon, and
simple volumetric objects that may be suggested for this option are polyhedron,
triangulated polyhedron or tetrahedron. Users can choose to either store the polygon
one by one, or store as multipolygon. The advantages and disadvantages of these
approaches have been investigated by Stoter and Zlatanova (2003). If the object is to
be stored as a 3D multipolygon, it is identifiable as one object by front-end
application i.e. CAD. This approach also relies on the one to one connection between
a record and an object. The major disadvantage for both approaches is that the
DBMS cannot recognize the object as a 3D object and as a result, no volume
computation can be done due to this problem. Thus, it would be a great effort if this
issue can be addressed through the implementation of 3D primitive objects in
DBMS.
2.7
Oracle Spatial DBMS
In the past five to ten years, database vendors such as Oracle have progressed
into the area of spatial technology. Specifically, Oracle introduced the Oracle Spatial
technology suite to support spatial processing inside an Oracle database. The Oracle
Spatial suite is often referred to as Spatial and provides SQL schema and functions.
Based on the provided schema and functions, both non-spatial and spatial attributes
can be stored, retrieved, updated and queried.
48
Oracle Spatial is spread across two tiers: the Database Server and the
Application Server. Figure 2.23 depicts the various components that make up
Oracle’s Spatial technology stack, and indicates the distribution of the components
across the Database Server and Application Server tiers. The basic components that
are provided as part of Oracle Database Server 11g include the storage model, query
and analysis tools, and location-enabling/loading utilities.
Figure 2.23: Oracle Spatial Components (Kothuri, 2004)
As shown in Figure 2.23, the basic component of Oracle Spatial can be
described as follows:
•
Data
model:
Oracle
Spatial
uses
a
SQL
data
type,
SDO_GEOMETRY, to store spatial data in an Oracle database.
SDO_GEOMETRY is defined as a column in the table to store the
locations and spatial extents of geographic entities.
49
•
Location-enabling: SDO_GEOMETRY columns can be added to
application tables and populate the tables with SDO_GEOMETRY
data using standard Oracle.
•
Spatial query and analysis: SDO_GEOMETRY data can be queried
and manipulated using the query and analysis component, comprising
the Index Engine and Geometry Engine.
•
Advanced Spatial Engine: This component comprises of several
components that cater to sophisticated spatial applications, such as
Geographical Information Systems (GIS) and bioinformatics.
•
Visualization: The Application Server components of Oracle’s
Spatial technology include the means to visualize spatial data via the
MapViewer tool. MapViewer renders the spatial data that is stored in
SDO_GEOMETRY columns of Oracle tables as displayable maps.
2.7.1 Supported Geometry Types
In Oracle Spatial, the spatial feature is the geometric representation of its
shape in some coordinate space. This is referred to as its geometry. Geometry is an
ordered sequence of vertices that are connected by straight line segments or circular
arcs, whereas the semantics of the geometry are determined by its type. Spatial
DBMS supports several primitive types and geometrics are composed of the
collections of these types, including two-dimensional:
•
Points and point clusters
•
Line strings
•
n-point polygons
•
Arc line strings (all arcs are generated as circular arcs.)
•
Arc polygons
•
Compound polygons
50
•
Compound line strings
•
Circles
•
Optimized rectangles
The latest version of Oracle Spatial (Oracle 11g) supports three-dimensional
elements in the database. Figure 2.24 illustrates some elements and categorizes them
into types supported in both two and three dimensions and types supported in only
three dimensions.
Figure 2.24: Geometry type in Oracle 11g.
Each geometry type is uniquely defined in SDO_GEOMETRY column, which is
known as SDO_GTYPE. The next section explains on the SDO_GEOMETRY
column in Oracle Spatial.
51
2.7.2 SDO_GEOMETRY
In a user-defined table, the geometry object or spatial object is stored within a
single column of object type SDO_GEOMETRY. Any table that has a column of
type SDO_GEOMETRY must have another column, or set of columns, that defines a
unique primary key for that table. The tables are sometimes referred to as spatial
tables or spatial geometry tables.
Oracle Spatial defines the object type SDO_GEOMETRY as:
CREATE TYPE sdo_geometry AS OBJECT (
SDO_GTYPE NUMBER,
SDO_SRID NUMBER,
SDO_POINT SDO_POINT_TYPE,
SDO_ELEM_INFO SDO_ELEM_INFO_ARRAY,
SDO_ORDINATES SDO_ORDINATE_ARRAY);
The paragraph below explains each element in SDO_GEOMETRY:
•
SDO_GTYPE
The SDO_GTYPE value is a 4 digit number in the format dltt. d refers to
dimension (2, 3, or 4); l specifies which dimension (3 or 4) contains the
measure value 3. tt refers to geometry types, for example, dl01 represents
point, dl02 represents line/curve, dl03 represents polygon and others.
Table 2.2 shows the valid SDO_GTYPE values.
52
Table 2.2: Valid SDO_GTYPE values Oracle (2007)
•
SDO_SRID
SDO_SRID describes a spatial reference. If it gives ‘null’ values, the
geometry does not relate to any reference system.
•
SDO_POI:T
If SDO_POINT value is not null, the object geometry is only a single
point; otherwise it is one of other geometries. SDO_POINT is utilized
when there are only point geometries in a layer.
•
SDO_ELEM_I:FO
SDO_ELEM_INFO stores the format of coordinates in SDO_ORDINATES
by repeating the following attributes:
53
SDO_STARTI:G_OFFSET
It refers to the starting offset of the current element’s first
coordinate in SDO_ORDINATES;
SDO_ETYPE
The current element can either be simple elements or compound
elements. Geometries that are not supported by Oracle Spatial can
be represented by setting SDO_ETYPE to zero. Geometries with type
0 elements must contain at least one nonzero element, which should
be an approximation of the unsupported geometry.
SDO_I:TERPRETATIO:
It is the interpretation for SDO_ETYPE. If it is a zero type element,
the SDO_INTERPRETATION value for the type zero element can be
any numeric value and applications would be responsible for
determining the validity and significance of the value.
•
SDO_ORDI:ATES
The arrays of coordinates are stored here with the format specified in
SDO_ELEM_INFO.
The shape of spatial objects can generally be quite complex as it requires a
large number of connected points (or vertices). To represent such complex
geometric shapes, the SDO_GEOMETRY type is logically implemented using
an array of elements, as shown in Figure 2.25.
54
Figure 2.25: Conceptual class diagram of the SDO_GEOMETRY data type
(Kothuri, 2007)
2.7.3 Interoperability
Interoperability is the ability to communicate with other products. Oracle
provided interoperability kits in their product that are capable of connecting, sharing
and retrieving stored data by other products. Software vendors such as Autodesk,
Intergraph, Laser-Scan, Bentley and MapInfo realized that by enabling interoperable
access to spatial data stored in an Oracle database, they are increasing the value of their
offerings by making it possible for organizations to use other applications
simultaneously. This, in turn, indirectly benefits the user.
55
In this research, the interoperability function is seemingly important in
visualizing constructed 3D primitive objects. Oracle Map viewer only supports 2D
element to view stored objects. Thus, other alternatives are necessary if 3D objects
are to be retrieved and viewed. With the availability of interoperability functions in
Oracle database, this issue may possibly be addressed.
Computer Aided Design (CAD) application is a powerful viewer in designing
structures, models and utilities. CAD has also been widely used in many fields,
especially in the engineering field. Since CAD vendors such as Autodesk and
Bentley have enabled the interoperability function, it would be beneficial if both
software can retrieve spatial column in Oracle DBMS and render the object in the
viewer. Several researchers have experimented in their researches by communicating
CAD and Oracle, for example Stoter and Zlatanova (2003), Arens et. al. (2003) and
Pu (2005). The objects were successfully retrieved and viewed in CAD software.
2.8
Summary
In this chapter, several issues related to the research were reviewed and
discussed. Based on the reviewed literature, suitable methods or techniques and
aspects to be considered have been revealed. Boundary Representation was chosen as
a technique to model 3D primitive objects. As discussed in this chapter, 3D primitive
objects are constructed based on mathematical definition and equation. As a
conclusion, this chapter revealed the steps and suitable technique in implementing
3D primitive objects as described in Chapters 4 and 5.
CHAPTER 3
MODELIG 3D PRIMITIVE OBJECTS
3.1
Background
Before exploring on how to develop 3D primitive objects in spatial DBMS, it
may be required for one to understand how to construct it with mathematical
formula. In this chapter, each primitive object is constructed using mathematical
formula and fitted with modeling technique, Boundary Representation (B-Rep). The
first section in this chapter discusses the B-Rep technique to be used in constructing
objects. That section also explains polyhedron as a geometric primitive to be used
with modeling technique. Section 3.2 discusses the use of spherical coordinates in
generating points on 3D primitive objects surface and making up polygon. Section
3.3 explains how to construct each 3D primitive object.
57
3.2
Modeling Objects using B-Rep and Spherical Coordinates
Based on the discussion in Chapter 2, Boundary Representation (B-Rep) is
utilized as a modeling technique to construct 3D primitive objects. B-Rep is a
method to represent the surface of solid objects. Solid surface is represented as a
quilt of faces, edges and vertices. In other words, the object is covered with several
faces or shapes without any intersection and as a result, a flexible shape is needed to
cover the object’s surface. Polygon is seemingly a suitable shape for constructing 3D
primitive objects, and a group of polygon in 3D is known as polyhedron. The
characteristics of polyhedron were discussed in Chapter 2.
A polygon is made up of a composed sequence line segment, with a line
segment connecting two points. Hence, polygon can be formed from a collection of
points which are connected by a line segment. Most of the basic 3D primitive objects
surfaces are based on curvilinear shapes. Thus, the points on an object’s surface can
be generated by spherical coordinate equation as explained in Chapter 2 section
2.2.1. Points along the curvilinear could be generated by using the following
equation 2.13, 2.14 and 2.15
x = xo + r cos θ cos φ
(2.13)
y = yo + r cos θ sin φ
(2.14)
z = zo + r sin θ
(2.15)
where (0 ≤ φ ≤ 2π and 0 ≤ θ ≤ π)
In the above equation 2.13, 2.14 and 2.15, xo, yo, zo is the centre point of curvilinear
line with angle 360o. r is the radius from centre point to the line while θ and φ
represent the angle of axis xy and yz. All of this variable is described in Figure 3.1.
58
z
φ
θ
r
•
y
x
Figure 3.1: Location of φ , θ and r on the x,y,z plane.
3.3
Constructing 3D Primitive Objects
Each 3D primitive object is constructed using B-Rep method and polyhedron.
Objects are constructed using mathematical formula with several parameters such as
radius r, centre point xo, yo, zo and height h.
3.3.1 Sphere
Sphere can be defined as a round object in 3D space or described as a circle
in three dimensions. The basic requirement in creating a circle is its centre point and
radius, which is also applicable for sphere. Bourke (1992) gave a definition of a
sphere surface by describing it with a set of points and equal distance (radius, r)
which have been measured from a single point (centre point). Radius can be defined
59
as a distance from the centre of a circle to its perimeter, or from the centre of a
sphere to its surface. The radius is equal to half of a diameter. Figure 3.2 shows
radius r from centre point of sphere xo, yo, zo.
xo, yo, zo
r
x1, y1, z1
Figure 3.2: Radius r from centre point of sphere.
The difference between circle and sphere is only at its space of coordinates. A
normal circle only deals with 2 space of coordinates (x, y) but a circle on sphere
deals with 3 space coordinates (x,y,z). Points on the sphere surface must be satisfied
previous equation 2.12 in Chapter 2. Following equation is the equation 2.12 with a
condition of radius r centered from origin (xo,yo,zo).
(x - xo)2 + (y - yo)2 + (z - zo)2 = r2
(2.12)
Before modeling and developing the sphere in DBMS, the skeleton of sphere
model that is based on polyhedron may give a better understanding on how it would
be modeled. In the following Figure 3.3, the surface of a sphere is divided into two
parts (half from top part and half from bottom part) and bounded by several faces of
polygon that make up a polyhedron.
60
•
Top of sphere
•
Bottom of sphere
Figure 3.3: Polyhedron on the sphere surface (up and bottom)
From Figure 3.3, it can be seen that polyhedron is made up of a group of
polygons as discussed in Chapter 2. Every polygon is connected by a single line
between two points. To generate a sphere using only its centre point and its end point
of radius (as illustrated in Figure 3.2), several points need to be generated to form a
group of polygon and make up a polyhedron. Using the previous equation 2.13, 2.14
and 2.15 in chapter 2, points can be generated on the sphere surface. The next section
briefly explains on how spheres can be generated and modeled using centre point and
end point of radius.
3.3.2 Modeling a Solid Sphere
A 3D circle in a form of a horizontal cross is known as latitude in
geographical terms, or in other words latitude is a line that runs horizontally on a
sphere. To generate points along the latitude using previous equation, the circle has
to be divided into parts. As illustrated in Figure 3.4, the angle of a round circle is
360°.
61
360°
r
r
Figure 3.4: The degree of round circle is 360°
From the figure 3.4, the latitude needs to be divided into parts to generate points. As
mentioned in Chapter 1 in the Scope section, only 20 points are generated along the
latitude. More than 20 points or less than 20 points are still accepted to construct a
sphere but in this research 20 points is best number to form a basic shape of sphere.
Therefore the divided angle of each part is 18° as shown in the figure 3.5. The range
of divided angle of latitude could be in 0° to 360°.
360 ° 18°
=
20
θ
θ = 18°
Figure 3.5: Divided sector angle is θ = 18°
Using equation 2.13, 2.14 and 2.15 points are generated along the latitude as
illustrated in the following Figure 3.6.
x = xo + r cos θ cos φ
(2.13)
y = yo + r cos θ sin φ
(2.14)
z = zo + r sin θ
(2.15)
62
xo, yo, zo
r
x1, y1, z1
New generated points
Figure 3.6: New points generated along the latitude
In this experiment, 10 new latitudes were created using Pythagoras Theorem
equation. To generate latitudes the diameter of sphere D is divided into 10 parts,
which represents 10 latitudes. Figure 3.6 shows the diameter of sphere divided into
10 parts.
xo, yo, zo
a
r
x1, y1, z1
r
D
a
a
D
r
a
a
a
r
a
a
a
Figure 3.7: Divided sphere diameter.
From the above Figure 3.7, it can be seen that the diameter has been divided
into 10 parts. The diameter is obtained from the radius r as illustrated in the figure
3.7. The diameter of a circle is equal to two times of a radius. In this research, the
diameter which is r plus r is divided into 10 parts. It is not a constraint to divide the
63
diameter more than 10 parts or less. Each parts have the same value a. a is an added
value or deduct value of z to get the new z of new latitudes. Following equation
describes how to get the value of diameter D and added or deduct value for every
new z, a.
D=r+r
(3.1)
D=a
10
(3.2)
Where:
D = Diameter of Sphere
a = added or deduct value for new z
In order to get the zn the value of a from equation 3.2 is added or deduct to the value
of z centre point zo as explained in the following equation 3.3.
zn = zo ± a
(3.1)
The value of xn, and yn are maintained because they are parallel with the centre point
xo, yo, zo. Hence the new centre point of new latitude is xn, yn, zn ( see Figure 3.8)
where:
xn is equal to xo
yn is equal to yo
zn = zo ± a
zo is a value of z origin
a is added or deduct value for every new z
64
xn, yn, zn
a
New latitude
xo, yo, zo
Figure 3.8: New latitude with its centre point xn, yn, zn .
The same procedure or steps is used to get the other latitude of sphere. Figure 3.9
illustrate the 10 latitudes generated using the above step.
1
2
3
4
5
The origin latitude
6
7
8
9
10
Figure 3.9: Ten generated latitudes with the origin latitude.
Points along the generated latitudes could be generated using the same step which is
using the equation 2.13, 2.14 and 2.15.
65
x = xo + r cos θ cos φ
(2.13)
y = yo + r cos θ sin φ
(2.14)
z = zo + r sin θ
(2.15)
In order to the equation 2.13, 2.14 and 2.15, the value of radius r for each new
latitude must be acquired to run with the equations. Radius r for the new latitude
could be aquired using the equation of Pythagoras Theorem. Centre point (xo, yo, zo),
new centre point (xn, yn, zn) and end point of horizontal line from the new centre point
(xn, yn, zn) are joined to form a right triangle as satisfied in Pythagoras Theorem.
Figure 3.10 shows the right triangle is formed after joining the points.
xn, yn, zn
new r
a
r
xo, yo, zo
Figure 3.10: Right triangle is formed after joining all the three points.
From the Theorem Pythagoras equation, a right triangle has one angle equal to 90
degrees. Based on the triangle in Figure 3.9, one of the angles is in 90 degrees at the
adjacent side (a) and opposite side (new r). Here is the triangle in Pythagoras
Theorem definition and Figure 3.11 explains the right triangle in Pythagoras theorem
definition.
66
•
The angle between right triangle must be equal to 90 degrees (adjacent
side b and opposite side c).
•
The hypotenuse is the longest side on the triangle (the side opposite the
right angle, a)
•
The square of a (a²) plus the square of b (b²) is equal to the square of c
(c²) which described in the following equation 3.3 :
a2 = c2 + b2
(3.3)
a
b
c
Figure 3.11: Triangle in Pythagoras Theorem definition
Following Figure 3.12 shows the obtained triangle as illustrated in figure 3.9 before.
xn, yn, zn
a
new r
r
xo, yo, zo
Figure 3.12: The right triangle.
Thus, the new r could be acquired using the equation 3.4 and 3.5 where:
r2 = (new r) 2 + a2
(3.4)
new r = √ r2 - a2
(3.5)
67
It is needed to be aware that the value of new r may vary for each new latitude. For
example, the value of new r for the top latitude is different with the value of new r
for the middle latitude. With the new r, points along the new latitude could be
generated using the same equation 2.13, 2.14 and 2.15 as before.
x = xo + r cos θ cos φ
(2.13)
y = yo + r cos θ sin φ
(2.14)
z = zo + r sin θ
(2.15)
This method is repeated until all points are generated along created latitudes. As a
result, the complete generated points are described as following Figure 3.13:
• •••
• •
• ••
•
•
• •
•
• •
•
•• ••
•
•
•
•
••
••
•
•
•
•
• •
•• •
••
• • •
• • •
• • •
• •• •
•
Figure 3.13: Complete generated points along the latitudes.
In creating a solid object using B-Rep method and polyhedron techniques, bounded
polygon faces need to be created first as discussed in chapter 2. Each face of the
polygon contains three or four points and every two points are connected by a single
line as illustrated in the Figure 3.14 below:
68
•
• •• ••
•
•
•
•• • •
•
•
• •
•
•
•
• • •
• •
•
•
•
•
• •
•
•
•
•
Figure 3.14: Generating Polyhedron from points to model Sphere
3.3.3 Cylinder
Cylinder also has a basic curvilinear geometric shape. Its surface is formed by
points at fixed distances from a given straight line, and the solid enclosed by this
surface and by two planes perpendicular to the axis. The basic shape of a cylinder is
actually two circles and one rectangle. The body of cylinder is formed when one of the
edges of the rectangle meets another edge. The circles then cover up its top and bottom
surface. Figure 3.15 shows a cylinder with radius r and height h.
h
r
Figure 3.15: Cylinder with height h and radius r
69
Constructing cylinder using polyhedron is much easier in comparison with
sphere. The shape of cylinder is quite simple and uncomplicated. Modeling cylinder
using polyhedron does not involve complex polygon shapes and uses less number of
polygons compared to sphere. The top and bottom of cylinder (Figure 3.16) can be
defined as a round polygon and the body of cylinder (Figure 3.17) can be defined by
several rectangle patches.
Figure 3.16: Top and bottom surface of cylinder
Figure 3.17: Body of cylinder
Based on the above figure, the points are generated as is similar in the process of
constructing spheres. Points are generated using the same mathematical equation i.e.
Cartesian coordinate equation 2.13, 2.14 and 2.15 for top and bottom cylinder.
x = xo + r cos θ cos φ
(2.13)
y = yo + r cos θ sin φ
(2.14)
z = zo + r sin θ
(2.15)
where (0 ≤ φ ≤ 2π and 0 ≤ θ ≤ π)
70
All of the variables in the above equation 2.13, 2.14 and 2.15 are same as applied to
sphere. The different is, its only apply to the bottom and top part of cylinder since its
shapes is curvilinear or circle base. Figure 3.18 illustrate the location of φ and θ for
the circular base of cylinder.
z
φ
xo,yo,zo
θ
r
•
y
x
Figure 3.18: Location of φ, θ and r.
3.3.4 Modeling a Cylinder
The top and bottom surfaces of cylinder are a circular base. Thus equation
2.13, 2.14 and 2.15 can be used to generate points along the perimeter of that surface.
For an example, points along the curvilinear of the bottom cylinder are generated
using centre point xo, yo, zo and radius r. this parameters are then applied together
with other variables in equation 2.13, 2.14 and 2.15. Figure 3.19 illustrates new
generated points from centre point and radius.
71
xo, yo, zo
r
x1, y1, z1
• • •
xn, yn, zn
xn, yn, zn
xn, yn, zn
Figure 3.19: Generated points at the bottom surface of cylinder
To generate the top surface of cylinder, a new centre point is calculated using
the value of height h. The value of height h is added to the z value of centre point xo,
yo, zo to obtain the z value of top surface zt. The value of x,y coordinates for top
surface xt, yt is maintained as the value of x,y centre point xb, yb for the bottom
surface. Radius r is also maintained by using the same radius of the bottom surface.
Same equation 2.13, 2.14 and 2.15 is used to generate points along the perimeter of
the top surface. Figure 3.20 shows generated points along the curvilinear shapes of
top and bottom surface of cylinder.
xt, yt, zt
• • •
•
• • •
h
•
• • r•
• • •
xo, yo, zo
xb, yb, zb
Figure 3.20: Generated centre points for the top and bottom surface of cylinder
72
In this research, points along the bottom and top surfaces are generated with 20
numbers of points. This number of points is the minimum number suggested to form
a solid cylinder as mentioned in Chapter 1 in scope of work. More points or fewer
points could be generated and it might affect the shapes of solid cylinder.
To form a solid cylinder, the polyhedron technique is used to bind the surface with
polygon faces. From the generated points, a close polygon can be developed by
joining every point with a line segment. The top and bottom surface of the polygon
forms a round face, while the cylinder body is formed using rectangle shape of face
by joining parallel points from the top and bottom surfaces as illustrated in Figure
3.21.
•••
• ••
•
•
•
•
•
•
•
•
•
•
•
•
•
•• ••
Figure 3.21: Generated Polyhedron from points to model Cylinder
3.3.5 Cone
Cone is a three dimensional pyramid object with a circular base shape. The
difference between cone and pyramid is in their base shape. Cone can either be right
circular cone or oblique circular cone; this experiment focuses on right circular cone.
Right circular cone is a cone with its vertex above the centre of its base, and is
73
normally known as a cone. Figure 3.22 shows a cone with height h and radius r for
circular base.
h
r
Figure 3.22: Cone with height of h and base radius of r
Modeling cone using polyhedron is simple as only two parts of its body need
to be bounded with the face, its base and its body. The cone body can be designed
with a collection of triangle face, and the base designed with a round face (see Figure
3.23).
•
Figure 3.23: Collection of face to construct the body and base of cone
74
3.3.6 Modeling a Cone
Using parameterized previous equation 2.13, 2.14 and 2.15, points can be
generated along the circular base of cone. By joining every point with the highest
vertex point, polyhedron can be generated. The equation is:
x = xo + r cos θ cos φ
(2.13)
y = yo + r cos θ sin φ
(2.14)
z = zo + r sin θ
(2.15)
where (0 ≤ φ ≤ 2π and 0 ≤ θ ≤ π)
All of the variables in the above equation 2.13, 2.14 and 2.15 are same as applied to
sphere and cylinder. The different is, its only apply to the circular base of cone.
Figure 3.24 illustrate the location of φ and θ for the circular base of cone.
z
φ
θ
r
•
y
x
Figure 3.24: Location of φ, θ and r for the circular base of cone.
75
The following figures 3.25 show the generated points along the base cone using the
same equation 2.13, 2.14 and 2.15. Points are generated from centre point (xo, yo, zo)
and end point of radius r (x1, y1, z1).
xo, yo, zo+h
Highest vertex
point
xo, yo, zo
h
x1, y1, z1
•r • •
•
• • •
Figure 3.25: Generated point along the cone base
In this experiment, only 20 points are generated on the circular base cone as
discussed in scope of work Chapter 1. Thus total numbers of points generated to
construct a solid cone are 21 points.
Each point on the base cone is attached to the highest vertex to form a solid model.
The single highest vertex point on cone can be calculated by simply adding the value
of height h to the z of centre point zo. x and y values for the highest vertex point are
maintained from x and y centre point xo and yo as they are parallel with the x and y
from centre point (see Figure 3.25). Solid cone is then constructed by joining all the
points from circular base to the highest vertex point to form a polyhedron as shown
in Figure 3.26.
76
•
•
•
•
• •
• • • •
Figure 3.26: Generated cone from several points.
3.3.7 Torus
In mathematics, torus is a doughnut-shaped object, such as an O-ring. In
general, tori can also have multiple holes, with the term n-torus used for a torus with
n-holes. The special case of a 2-torus is sometimes called the double torus, the 3torus is called the triple torus, and the usual single-holed torus is simply called a
torus. The main characteristic of torus is on its radius, with the main radius Rmain
representing the radius from the center of the hole. The subradius or also known as
radius tube rtube is the radius for the tube. Figure 3.27 show a torus with the main
radius of Rmain and subradius of rtube.
Rmain rtube
+
Figure 3.27: torus with the main radius of Rmain and subradius of rtube.
77
Three types of torus (Figure 3.28), known as the standard tori, are possible,
depending on the relative sizes of rtube and Rmain. Rmain > rtube corresponds to the ring
torus, Rmain = rtube corresponds to a horn torus which is tangent to itself at the point
(0, 0, 0), and Rmain < rtube corresponds to a self-intersecting spindle torus (Weisstein,
2005). In this research ring torus is chosen as a 3D primitive object to be
implemented in DBMS.
Figure 3.28: Types of Torus, Weisstein (2005).
Polyhedron is also utilized to model a torus, but with a torus the polygon needs to
cover the entire torus surface. It is quite complex compared with other objects due to
its curvilinear shapes. Similar with sphere, its entire surface is curvilinear. Torus can
be constructed from a rectangle by combining both pairs of opposite edges together
to form a tube. The tube edge is then connected to form a torus shape as illustrated
in Figure 3.29.
78
A
B
Figure 3.29: constructed torus from rectangle.
It is quite hard to apply a method in Figure 3.29 in computer graphics. Thus a group
of faces are needed to cover up the entire torus. Figure 3.30 shows a group of
polygon i.e. rectangle covering up the entire torus surface.
Figure 3.30: Collection of polygon faces to construct torus.
3.3.8 Modeling a Torus
The geometry of torus is basically formed from a circle. The cross section of
torus is based on circle, as well as the cross section of a torus’s tube. The basic
geometry of torus that is based on a circle can be described as following Figure 3.31:
79
+
Rmain
rtube
+
Figure 3.31: circle base geometry for torus.
As shown in the Figure 3.31, the black circle with radius Rmain is the main circle for
torus while the red circle with radius rtube is the circle base for tube. As explained in
Chapter 2, from the Cartesian coordinates, a torus azimuthally symmetric at the zaxis can be described in this equation 2.28:
(c – √x2 + y2)2 + z2 = a2
(2.28)
The parametric equation for torus in Chapter 2, could described point (x,y,z) on
torus in this following equations 2.29, 2.30 and 2.31
x = (c + a cos v) cos u
(2.29)
y = (c + a cos v) sin u
(2.30)
z = a sin v
(2.31)
Where:
c is the radius from the center of the hole to the center of the torus tube
a is the radius of the tube
u and v is parametric variables in the interval [0,2π]
The definition of variables c, a, u and v in the above equations 2.28, 2.29, 2.30 and
2.31 are best described in the Figure 2.12, 2.13 and 2.14 in Chapter 2.
80
In the above equations 2.29, 2.30 and 2.31,the variables c is equal to Rmain and a is
equal to rtube. Thus, point (x,y,z) on torus surface could be described by equations 3.6,
3.7 and 3.8
x = (Rmain + rtube cos v) cos u
(3.6)
y = (Rmain + rtube cos v) sin u
(3.7)
z = rtube sin v
(3.8)
Using the above equations 3.6, 3.7 and 3.8 points could be generated on the torus
surface. The following Figure 3.32 shows generated points from centre point xo, yo, zo,
radius Rmain.
• • •
• •
• r
R
•
•
•
•
• •
•
• •
tube
main
xn, yn, zn
xo, yo, zo
Figure 3.32: Illustrates the generated points on torus surface based on the centre
point and radius Rmain.
From the generated points, each point is pointed as a centre point xn, yn, zn for radius
tube rtube. Using sub radius rtube and centre point xn, yn, zn for tube, points are
generated along the circle cross section of tube. This can be described by the
following Figure 3.33:
• • • •
• •
• r •
R
•
•
•
•
•
•
•• •
• •
• • •
tube
main
xn, yn, zn
xo, yo, zo
Figure 3.33: Generated points using sub radius r along tube cross section.
81
In this experiment points generated along the main circle are 20 numbers of points
while points generated along the sub circle for tube are generated with 10 numbers of
points. Thus, total generated points are 200 numbers of points. This number of points
has been discussed in the Chapter 1 in Scope of work. It is not restricted to generates
more or less than 200 number points, but the best minimum number to form a torus
in this experiment is suggested with 200 points.
Upon completion of the process, each parallel point is connected by a line segment to
form a polygon face. Figure 3.34 shows the complete generated points and all of the
points are connected by a line segment in constructing a torus.
• • • ••
•• • • •
•
• • •• • •
• •• •• • •• • •
••
• • •
• • • ••
• • •
• •
• •
•
•
•
•
•
•
•
•
•
•
•
•
• ••
• • • • ••
• • • • •• • •
• •• •
• • • • ••
• • •
•
• • • •
•
•
• •• ••
•
• •
Figure 3.34: Polyhedron to construct torus.
3.4
Conclusion
In this chapter, the way to construct primitive objects using B-Rep method
and polyhedron is revealed. Every object uses a mathematical formula to construct
polyhedron with the B-Rep method. Mathematical formula is important to construct
each 3D primitive object. For an example, Cartesian coordinate equation is utilized
82
as a mathematical formula to construct sphere, cone and cylinder while the
parametric equation for torus is used in a torus construction.
CHAPTER 4
THE IMPLEMETATIO OF 3D PRIMITIVE OBJECTS AT DBMS LEVEL
4.1
Background
This chapter gives a detailed explanation of how 3D primitive objects are
implemented from constructed models that were shown in Chapter 3, and explains
how 3D primitive objects can be stored in a spatial DBMS. Oracle Spatial was
chosen to build 3D primitive objects, instead of other spatial DBMSs. Section 4.1
discusses the possible implementation approaches, and then explains how to create
3D primitive objects. Section 4.2 details out the implementation of 3D primitive
objects, besides discussing the volume and area and rotation element towards the
creation of 3D primitive objects. On the other hand, Section 4.3 shows some
examples of how to manipulate created 3D primitive objects.
84
4.2
Implementation Approach
Conceptual models as constructed in Chapter 3 can be implemented in Oracle
Spatial with different approaches. Among the provided approaches, stored procedure
was chosen as a platform to implement 3D primitive objects in DBMS. This section
explains how this approach works on a practical basis in Oracle Spatial.
4.2.1 Stored Procedure
Stored procedure is the available subroutine applications to access a relational
database system. Stored procedure is also known as proc, sproc, StoPro, or SP; it also
offers advantages in the areas of development, integrity, security, performance, and
memory allocation. Typically, stored procedure is used to store procedures such as
data validation or access control mechanism. Stored procedure is also used to
consolidate and centralize logic that was implemented in applications. Large or
complex processing that may require the execution of several SQL statements is
moved into stored procedures, and all applications would thus rely only on these
procedures.
Stored procedures are similar to User-Defined Functions (UDF). The
difference is that UDF can be utilized similar to any other expression within SQL
statements, whereas stored procedures must be invoked using the CALL statement.
The advantage of a stored procedure is that when it is run in response to a user
request, it is run directly by the database engine that usually runs on a separate
database server. As a result, it has direct access to the data it needs to manipulate and
only needs to send its results back to the user, doing away with the overhead of
communicating large amounts of data back and forth. Due to this, stored procedure
was chosen as the possible implementation approach in this research. Most
85
mainstream DBMSs including Oracle, SQL Server and MySQL support stored
procedure. Stored procedure can be also implemented in a variety of programming
languages such as SQL, Java, C or C++. Table 4.1 shows the list of DBMS and
supported programming language for stored procedures.
Table 4.1: DBMSs and supported programming language for stored
procedure (Wikipedia, 2010)
DBMS
Implementation Language
Microsoft SQL Server
Transact-SQL and various .NET Framework languages
Oracle
PL/SQL or Java
DB2
SQL/PL
Informix
SPL
PostgreSQL
PL/pgSQL, also use own function languages such as pl/perl
or pl/php
Firebird
PSQL (Fyracle also supports portions of Oracle's PL/SQL)
MySQL
Own stored procedures, closely adhering to SQL:2003
standard
As shown in Table 4.1, Oracle Spatial supports stored procedure with
PL/SQL and Java language. Users can use either PL/SQL or Java or even both
languages, depending on several factors. According to Mensah (2006), selecting to
use PL/SQL or Java depends on the goals, requirements, the available skills within
the organization; and whether there would be a future need to migrate the code in
question from the database to the middle tier or vice versa. Compared to Java,
PL/SQL is much more straightforward and uncomplicated. Java can be preferable
when data logic has moderate SQL data access requirements and moderate
computational requirements or when users already have skills in Java. Java is also
preferred when one needs to accomplish things that cannot be done in PL/SQL, such
as interaction with ERP systems, RMI servers, Java/J2EE, and Web services. Since
the implementations of 3D primitive objects are not related to any of this, PL/SQL
was chosen to implement stored procedure in Oracle DBMS.
86
PL/SQL is known as Procedural Language for Structured Query Language. It
provides a server-side, stored procedural language that is easy-to-use, seamless with
SQL, robust, portable, and secure. Several advantages of PL/SQL are that it supports
SQL, supports object-oriented programming and gives better performance, higher
productivity, full portability, tight integration with Oracle and tight security. Besides
that, PL/SQL stored procedures can be solicited from a number of Oracle clients,
such as Pro*C or Oracle Call Interface, and from Oracle Reports and Oracle Forms.
Figure 4.1 shows the architecture of PL/SQL in Oracle database server.
Figure 4.1: PL/SQL in Oracle database server (Oracle, 2007).
4.2.2 Create Procedure
The constructed model of 3D primitive objects can be mapped into DBMS by
creating a new procedure using PL/SQL. In PL/SQL, procedures and functions are
provided to allow users to create standalone procedures or functions that are stored in
87
the database. Both the procedure and function utilize parameters, which can be of
any mode. In addition, the procedure and function are different forms of PL/SQL
blocks, with declarative, executable, and exception sections. Both can be stored in
the database or declared within a block. However, a procedure call is a PL/SQL
statement by itself, while a function call is called as part of an expression. According
to Urman et. al. (2004), the choice between procedure and function generally
depends on how many values the subprogram is expected to return and how those
values would be used. The rule of thumb is that procedure should be used if there is
more than one returns value. In this research, procedure was chosen to implement
constructed 3D primitive objects at DBMS level.
A procedure was introduced by the keywords CREATE PROCEDURE, followed
by the procedure name and its parameters. An option is to follow up with CREATE by
OR REPLACE.
When a procedure is created, it is first compiled and then stored in the
database in compiled form. Parameter can be passed by calling the procedure; a
procedure call is a PL/SQL statement by itself and is not called as part of an
expression. When a procedure is called, control passes to the first executable
statement inside the procedure. When the procedure finishes, control resumes at the
statement following the procedure call. Figure 4.2 illustrates the basic syntax for the
CREATE OR REPLACE PROCEDURE
statement:
The body of a procedure is a PL/SQL block with declarative, executable, and
exception sections. The declarative section is located between the
and the
BEGIN
EXCEPTION
IS
or
AS
keyword. The executable section is located between the
keyword
BEGIN
and
keywords or between the BEGIN and END keywords if there is no exception-
handling section. In the case that the exception section is present, it is located
between the
EXCEPTION
and
END
statement therefore looks like this:
keywords. The structure of a procedure creation
88
CREATE OR REPLACE PROCEDURE procedure_name [parameter_list]
AS
/* Declarative section is here */
BEGIN
/* Executable section is here */
EXCEPTION
/* Exception section is here */
END [procedure_name];
Figure 4.2: The basic syntax for the CREATE OR REPLACE PROCEDURE
statement (Urman et. al. 2004)
Just as how a table can be dropped, procedures can also be dropped. This removes
the procedure or function from the data dictionary. The syntax for dropping a
procedure is:
DROP PROCEDURE procedure_name;
89
The full structure of creating procedure for Cone looks like this:
CREATE OR REPLACE PROCEDURE CREATECONE (TabName VARCHAR2, ObjID NUMBER, RxK
NUMBER, RyK NUMBER, RzK NUMBER) IS
ObjID NUMBER (2);*/
nAng number (15,3);
nCenterX number (15,3);
nCenterY number (15,3);
nCenterZ number (15,3);
Rx NUMBER (15,4);
Ry NUMBER (15,4);
Rz NUMBER (15,4);
nCenterXbaru number (15,3);
nCenterYbaru number (15,3);
nCenterZbaru number (15,3);
nNewX number (15,3);
nNewY number (15,3);
nNewZ number (15,3);
nCenterXtemp number (15,3);
nCenterYtemp number (15,3);
nCenterZtemp number (15,3);
nHeight number (15,3);
i number (3);
ID number (6);
TYPE newX IS VARRAY(300) OF number (15,3);
TYPE newY IS VARRAY(300) OF number (15,3);
TYPE newZ IS VARRAY(300) OF number (15,3);
newXagain newX := newX();
newYagain newY := newY();
newZagain newZ := newZ();
nSqrt2 number (15,3);
iCntrPrint number (3);
anoCone mdsys.sdo_ordinate_array;
anoConeID number (15);
nSisi number (15,3);
nArea number (15,3);
BEGIN
**** see appendix
90
4.2.3 Load Procedure in DBMS
After the procedure was created, it must be loaded in the database and is
loaded only for the first time. After that, CALL statement is used to call the procedure.
Wrapping the procedure into .plb format is easier than running the long procedure
code; furthermore procedure can be wrapped from command prompt. In this
research, procedure is called from SQL*Plus interface. Figure 4.3 shows the
successfully loaded procedure in DBMS.
Figure 4.3: Procedure is created in DBMS
The same steps also apply to other procedures for 3D primitive objects such as
Cylinder Procedure, Sphere Procedure and Torus Procedure. To describe created
procedure in DBMS describe statement,
desc
description of implemented procedure for cone is:
SQL> desc createcone;
procedure_name was used. The
91
PROCEDURE createcone
Argument Name
Type
------------------------------ --------TABNAME
VARCHAR2
OBJID
NUMBER
RXK
NUMBER
RYK
NUMBER
RZK
NUMBER
Explanation for procedure parameters:
TABNAME
OBJID
is the table name.
is id number of object.
RXK
is x-plane coordinate for point.
RYK
is y-plane coordinate for point.
RZK
is z-plane coordinate for point.
The full method and example for calling created procedure and creating 3D primitive
objects in DBMS can be found in Section 4.3. Prior to that, Section 4.2 discussed
spatial column in DBMS table and spatial indexing for spatial column.
4.3
3D Primitive Objects in DBMS
The 3D primitive objects procedure was successfully loaded in DBMS, along
with the utilization of the object’s table. Without a table, a procedure cannot process
any input or output for 3D primitive objects. The table in database is needed to store
object’s attribute i.e. semantic and spatial. Spatial attribute is stored in spatial
column, which is defined as SDO_Geometry column in Oracle Spatial DBMS. As
mentioned in Chapter 2, Oracle Spatial defines the object type of geometry column
(Oracle, 2007). The object type of geometry column is:
92
CREATE TYPE sdo geometry AS OBJECT (
SDO GTYPE NUMBER,
SDO SRID NUMBER,
SDO POINT SDO POINT TYPE,
SDO ELEM INFO SDO ELEM INFO ARRAY,
SDO ORDINATES SDO ORDINATE ARRAY);
The geometry column in Oracle Spatial DBMS is a standard format to store
spatial objects. It cannot be directly modified and requires user understanding on
each SDO_Geometry parameter. Geometry column is usually created together with
semantic attribute column in the same table, with the users allowed the freedom to
create and name their own column. But in this experiment, table structure is fixed
and cannot be used in other format, with only the table name decided by the user.
This is due to the created procedure in the previous section. New columns, values
and formats can only be modified if the created PL/SQL is modified too. The
description of created table structure for 3D primitive objects is:
SQL> desc PRIMITIVE_OBJECTS;
Name
Null?
Type
-------------------------------- -------- ----------ID
NOT NULL NUMBER(6)
DESCRIPTION
VARCHAR2(250)
RADIUS
NUMBER(15,3)
RADIUS_SUB
NUMBER(15,3)
CENTREPOINT_X
NUMBER(18,3)
CENTREPOINT_Y
NUMBER(18,3)
CENTREPOINT_Z
NUMBER(18,3)
HEIGHT
NUMBER(15,3)
VOLUME
NUMBER(15,3)
AREA
NUMBER(15,3)
GEOMETRY
MDSYS.SDO_GEOMETRY
In this fixed table format, users can create any of 3D primitive objects i.e
Cone, Sphere, Cylinder and Torus. Objects are stored in a different row in the table
while data can be stored using INSERT
INTO
statement. The parameter’s columns such
as radius, sub radius, control point and others are considered as required value
(depends on object’s parameter) to construct 3D primitive objects in the database.
93
Geometry, volume and area are left as a null value and are updated after procedure is
successfully called. Table 4.2 shows object with required parameter to run the
created procedure.
Table 4.2: Parameters of 3D primitive objects.
Object
Radius
Radius_Sub
CP_X
CP_Y
CP_Z
Height
Cone
*
*
*
*
*
Cylinder
*
*
*
*
*
*
*
*
Sphere
*
*
*
Torus
*
*
*
* - required parameter to create 3D primitive objects.
Each value of parameter is utilised in
INSERT INTO
statement as following syntax.
The syntax below shows how to insert cone parameter into the table. Cone
parameters are radius, coordinate x,y and z of center point and height.
INSERT INTO PRIMITIVE_OBJECTS VALUES (
1,NULL,15,NULL,10.0,10.0,10.0,30.0,NULL,NULL,NULL,NULL);
1 row created.
4.3.1 Indexing of Spatial Data
Creating tables for 3D primitive objects is not the only matter of concern.
Each table must be indexed with spatial indexes to speed up query on the tables. In
addition, spatial index is considered as a logical index and entries in spatial index are
dependent on geometry location in a coordinate space. Oracle provides two types of
indexing, R-Tree indexing and quadtree indexing. However, quadtree indexes are
94
discouraged and users are instead encouraged to use R-Tree indexing. A spatial Rtree index can index spatial data of up to four dimensions, and approximate each
geometry by a single rectangle that minimally encloses the geometry (called the
minimum bounding rectangle, or MBR). Figure 4.4 shows MBR enclosing geometry.
Figure 4.4: MBR enclosing the geometry.
For a layer of geometries, an R-Tree index consists of a hierarchical index on the
MBRs of the geometries in the layer, as shown in Figure 4.5.
Figure 4.5: Example of R-Tree index for a set of points, Kothuri (2007).
As shown in Figure 4.5, points are clustered into three divisions: A, B, and C. Each
division is associated with an MBR that encloses the points in the subtree, and these
divisions are further clustered together into a ‘root’. In this manner, an R-Tree
constructs a hierarchical tree structure using the MBRs of the SDO_GEOMETRY
data in a table. It then utilizes this hierarchy of MBRs to guide queries to appropriate
branches of the tree and finally to the rows of the data table. Figure 4.6 illustrates
how the R-tree index is stored in Oracle. The logical tree structure is stored as an
Oracle table that starts with the prefix MDRT. Each node of the tree structure is
stored as a separate row in this table.
95
Figure 4.6: Storage of R-Tree spatial indexes.
4.3.2 Creating Spatial Index and Spatial Index Parameter
The spatial index is created with a simple syntax, which creates a spatial
index on a column of type MDSYS.SDO_GEOMETRY. Example of syntax for
creating indexes is:
SQL> CREATE INDEX index_name ON table_name(column_name)
INDEXTYPE IS MDSYS.SPATIAL_INDEX;
However, spatial index may fail due to unpopulated appropriate metadata for
the spatial layer. To perform validation, index creation, and querying with respect to
each spatial layer (in other words, all the geometry objects in a specific
SDO_GEOMETRY column of a table), the appropriate metadata is required to be
specified for each layer. This includes the following information:
96
•
The number of dimensions
•
The bounds for each dimension
•
The tolerance for each dimension
•
The coordinate system
This information for each spatial layer is populated in the
USER_SDO_GEOM_METADATA
dictionary view. This view has the fields as follows:
SQL> DESCRIBE USER_SDO_GEOM_METADATA;
Name
Null?
Type
-------------------------- -------- ---------TABLE_NAME
NOT NULL VARCHAR2(32)
COLUMN_NAME
NOT NULL VARCHAR2(1024)
DIMINFO
MDSYS.SDO_DIM_ARRAY
SRID
NUMBER
In a
DIMINFO
structure of
field, the attribute for
MDSYS.SDO_DIM_ARRAY
must be specified. The
MDSYS.SDO_DIM_ARRAY
is:
SQL> DESCRIBE SDO_DIM_ARRAY;
SDO_DIM_ARRAY VARRAY(4) OF MDSYS.SDO_DIM_ELEMENT
Name Null?
Type
------------------------------------------------
----------- ----
SDO_DIMNAME VARCHAR2(64)
SDO_LB NUMBER
SDO_UB NUMBER
SDO_TOLERANCE NUMBER
It is important to set all the specify attributes in
DIMINFO
field and specify the suitable tolerance. Detailed explanations on inserting
USER_SDO_GEOM_METADATA
can be found in the Oracle Spatial User Guide and
Reference. The syntax of inserting
USER_SDO_GEOM_METADATA
3D primitive object’s table is:
SQL> INSERT INTO USER_SDO_GEOM_METADATA
(TABLE_NAME,
COLUMN_NAME,
DIMINFO,
SRID)
VALUES (
USER_SDO_GEOM_METADATA
attributes for a created
97
'PRIMIITVE_OBJECTS',
'GEOMETRY',
MDSYS.SDO_DIM_ARRAY(
MDSYS.SDO_DIM_ELEMENT('X', 100000, -100000, 0.005),
MDSYS.SDO_DIM_ELEMENT('Y', 100000, -100000, 0.005),
MDSYS.SDO_DIM_ELEMENT('z', 100, 50, 0.005)
),
NULL);
After
USER_SDO_GEOM_METADATA
has been created, creating an index should be
successful and not contain an error related to
USER_SDO_GEOM_METADATA.
Creating a
spatial index can require an additional PARAMETERS clause that can be used to specify
a number of parameters, including where to store the index information. The syntax
for creating a spatial index, including the PARAMETERS clause is:
CREATE INDEX <indexname> ON <tablename>(<columnname>)
INDEXTYPE IS MDSYS.SPATIAL_INDEX
PARAMETERS ('parameter_string');
The parameter_string is a list of
parameter_name=value
pairs.
Some of the
parameters that can be used in user applications are:
TABLESPACE Parameter
WORK_TABLESPACE Parameter
LAYER_GTYPE Parameter
SDO_INDX_DIMS Parameter
SDO_DML_BATCH_SIZE Parameter
SDO_LEVEL Parameter
In this experiment,
LAYER_GTYPE
Parameter
was chosen as an index
parameter. LAYER_GTYPE parameter refers to the type of data in the table. If the type is
mismatched with the data, an error would occur. Based on the created table in the
previous section and created metadata, the spatial index for 3D primitive objects can
be described as follows:
98
SQL>CREATE INDEX PrimitiveObjects_IDX
ON PRIMITIVE_OBJECTS(GEOMETRY)
INDEXTYPE IS MDSYS.SPATIAL_INDEX
PARAMETERS('layer_gtype=MULTIPOLYGON');
Index created.
4.3.3 3D Primitive Objects Procedure
This section shows the example of how to call created procedure after insert
statements has been successfully loaded into the data. Primitive Objects is
successfully created once the syntax shows it successfully created. Example:
SQL> CREATE Primitive_Objects (
ID NUMBER(6) PRIMARY KEY,
DESCRIPTION VARCHAR2(250),
RADIUS NUMBER(15,3),
RADIUS_SUB NUMBER(15,3),
CENTREPOINT_X NUMBER(18,3),
CENTREPOINT_Y NUMBER(18,3),
CENTREPOINT_Z NUMBER(18,3),
HEIGHT NUMBER(15,3),
VOLUME NUMBER(15,3),
AREA NUMBER(15,3),
GEOMETRY MDSYS.SDO_GEOMETRY);
Table created.
Insert statement for 3D primitive objects i.e. Cone, Cylinder, Sphere and Torus are:
-----Cone----SQL> INSERT INTO BUILDING VALUES(
1,’Cone’,15,NULL,10.0,10.0,10.0,30.0,NULL,NULL,NULL,NULL);
1 row created.
-----Cylinder----INSERT INTO BUILDING VALUES(
2,’Cylinder’,15,NULL,20.0,20.0,20.0,30.0,NULL,NULL,NULL,NULL);
99
1 row created.
-----Torus----INSERT INTO BUILDING VALUES(
3,’Torus’,150,50,30.0,30.0,30.0,NULL,NULL,NULL,NULL,NULL);
1 row created.
-----Sphere----INSERT INTO BUILDING VALUES(
4,’Sphere’,15,NULL,40.0,40.0,40.0,30.0,NULL,NULL,NULL,NULL);
1 row created.
The created procedures only work if insert statement had successfully stored
attributes in the table’s column. The procedure is called and run with four required
parameters which are:
•
Procedure Name
•
Table Name
•
Object ID
•
Rotation Axis and Rotation Angle
The examples of how to call created procedure to construct 3D primitive objects in
DBMS are:
Call <procedure_name> (<table_name>, <object_id>, <rotation angle for axisx, rotation angle for axis-y and rotation angle for axis-z>);
-----Cone----Call createcone (‘Primitive_Objects’, 1, 0,0,0);
Call completed.
-----Cylinder----Call createcylinder (‘Primitive_Objects’, 2, 0,0,0);
Call completed.
-----Torus----Call createtorus (‘Primitive_Objects’, 3, 0,0,0);
Call completed.
-----Sphere----Call createsphere (‘Primitive_Objects’, 4, 0,0,0);
100
Call completed.
The call procedure is completed when three columns in the table i.e. area, volume
and geometry column is filled with semantic and spatial attributes. Simple queries
can be done directly from SQL*Plus to check the availability of the column’s
attributes.
4.3.4 Volume and Area Calculation
The volume and surface areas are the information that would be gathered
from objects, especially 3D primitive objects. As shown in the created procedure in
Section 4.2, the volume is calculated and stored directly in the Volume and Area
field in the created standard table. Below is the created table structure of 3D
primitive objects:
SQL> desc PRIMITIVE_OBJECTS;
Name
Null?
Type
----------------------------------------- -------- ----------------ID
NOT NULL NUMBER(6)
DESCRIPTION
VARCHAR2(250)
RADIUS
NUMBER(15,3)
RADIUS_SUB
NUMBER(15,3)
CENTREPOINT_X
NUMBER(18,3)
CENTREPOINT_Y
NUMBER(18,3)
CENTREPOINT_Z
NUMBER(18,3)
HEIGHT
NUMBER(15,3)
VOLUME
NUMBER(15,3)
AREA
NUMBER(15,3)
GEOMETRY
MDSYS.SDO_GEOMETRY
From the table structure, it can be seen that Volume and Area fields are created
together with other fields. The created procedure as shown in Section 4.1 calculates
the area and volume based on inserted parameter in the
INSERT INTO
statement. The
101
following syntax and expression shows the process of calculating the area and
volume of cone in the creation of the procedure.
(a) Cone
INSERT INTO PRIMITIVE_OBJECTS VALUES (
1,NULL,15,NULL,10.0,10.0,10.0,30.0,NULL,NULL,NULL,NULL);
1 row created.
From the
INSERT INTO
statement, parameter values related to area and volume
computation were extracted by procedure. The extracted parameter values for
calculate cone area and cone volume are:
i. Radius, r: 15
ii. Height h: 30.0
From equation (2.24) in Chapter 2, surface area of cone Acone is computed as follows:
s
h
r
Acone = π r s where,
(2.24)
π = 3.142
r = radius
s = cone side
s is equal to cone side value. It is not extracted together with other parameters value.
Using the extracted parameter value, s can be calculated using Pythagoras equation
where:
102
c2
a2 + b2 = c2
(4.1)
r2 + h2 = s2
(4.2)
√ r2 + h2 = s
(4.3)
a2
b2
s
2
h2
r
2
Hence, surface area of cone Acone is:
Acone = π r (√ r2 + h2)
(4.4)
By applying the extracted parameter, surface area of cone is:
Acone = π r ( √ r2 + h2 )
(4.5)
Acone = 3.142 X 15.0 X ( √ 15.02 + 30.02
Acone = 1580.7882 unit2
The same process also applies to calculating the volume of cone. Based on the
equation (2.27) in Chapter 2, the volume of cone Vcone is:
103
h
r
Vcone = 1 π r2 h where,
3
(2.23)
π = 3.142
r = radius
h = cone height
By applying the extracted parameter, volume of cone Vcone is:
Vcone = 1 π r2 h
3
Vcone = 1 X 3.142 X 15.0 X 15.0 X 30.0
3
Vcone = 7069.5 unit3
Figure 4.7 shows a query on area and volume field through the primitive objects
table.
Figure 4.7: Area and volume value for cone
104
(b) Cylinder
INSERT INTO PRIMITIVE_OBJECTS VALUES (
2, Cylinder',15,NULL,20.0,20.0,20.0,30.0,NULL,NULL,NULL,NULL);
1 row created.
From the INSERT
INTO
statement, parameter values related to area and volume
computation were extracted by procedure. The extracted parameter values to
calculate cylinder area and cylinder volume are:
i. Radius, r: 15
ii. Height h: 30.0
From equation 2.16 in Chapter 2, the surface area of cylinder Scylinder is
computed as:
h
r
Scylinder = 2 π r2+ 2 π r h where,
( 2.16)
π = 3.142
r = radius
h = cylinder height
By applying the extracted parameter, surface area of cylinder Scylinder is:
105
Scylinder = 2 π r2+ 2 π r h
Scylinder = (2X3.142X15.0X15.0) + (2X3.142X15.0X 30.0)
Scylinder = 4241.7 unit2
The same process is also applicable for calculating the volume of cone. Based
on the equation (2.17) in Chapter 2, the volume of cylinder Vcylinder is:
h
r
Vcylinder = π r2 h where,
( 2.17)
π = 3.142
r = radius
h = cone height
By applying the extracted parameter, the volume of cylinder is:
Vcylinder = π r2 h
(2.17)
Vcylinder = 3.142 X 15.0 X 15.0 X 30.0
Vcylinder = 21208.5 unit3
Figure 4.8 shows a query on area and volume field through the primitive
objects table.
106
Figure 4.8: Area and volume value for cylinder
(c) Torus
INSERT INTO PRIMITIVE_OBJECTS VALUES (
3, ’Torus', 150,50,30.0,30.0,30.0,NULL,NULL,NULL,NULL,NULL);
1 row created.
From the
INSERT INTO
statement, the extracted parameter values to calculate
torus area and torus volume are:
i. Radius, R: 150
ii. Tube Radius, r: 50
From the equation (2.26) in Chapter 2, the surface area of torus ATorus is
computed as:
+
Rmain rtube
107
ATorus = π2 x (Rmain)2 – (rtube)2 where,
(2.26)
π = 3.142
rtube = Tube radius
Rmain = Radius
By applying the extracted parameter, surface area of torus ATorus is:
ATorus = π2 x (Rmain2 – rtube2)
ATorus = ( 3.142 )2 X ( (150)2 - (50.0)2 )
ATorus = 197443.28 unit2
The same process also applies for calculating the volume of torus. Based on
equation (2.27) in Chapter 2, volume of torus VTorus is:
+
Rmain rtube
VTorus = 1 π2 X (Rmain + rtube) X (Rmain - rtube)2
4
VTorus = 1 X (3.142) 2 X (150 + 50) X (150 - 50)2
4
VTorus = 4936082 unit3
(2.27)
108
The figure 4.9: shows a query on area and volume field through primitive
objects table.
Figure 4.9 Area and volume value for torus
(d) Sphere
INSERT INTO PRIMITIVE_OBJECTS VALUES (
4, ’Sphere',15,NULL,40.0,40.0,40.0,NULL,NULL,NULL,NULL,NULL);
1 row created.
From the
INSERT INTO
statement, the extracted parameter values to calculate
sphere area and torus volume are:
i. Radius, r: 15
From equation (2.1) in chapter 2, the surface area of sphere Asphere is:
r
109
Asphere = 4π (r)2 where,
(2.1)
π = 3.142
r = radius
By applying the extracted parameter, surface area of sphere Asphere is:
Asphere = 4π (r)2
Asphere = 4 X 3.142
X
(15.0)2
Asphere = 2827.8 unit2
The same process is also applicable in calculating the volume of cone. Based
on equation (2.2) in Chapter 2, the volume of sphere Vsphere is:
r
Vsphere = 4 π r3
3
π = 3.142
r = radius
By applying the extracted parameter, the volume of sphere Vsphere is:
Vsphere = 4 π r3
3
Vsphere = 4 X 3.142 X (15.0)3
3
(2.2)
110
Vsphere = 14139 unit3
Figure 4.10 shows a query on area and volume field through primitive
objects table.
Figure 4.10 Area and volume value for sphere
4.4
Rotation Element
The rotation element should be implemented together with the created
procedure, due to the object’s location and condition. Given that objects are not
necessarily in an upright condition, the rotation element is therefore needed when 3D
primitive objects are stored. By implementing rotation element, users are allowed to
specify the exact object’s condition and location. Nevertheless, the element of
rotation and how it works on oriented plane need to be fully understood. It can be
quite confusing when the rotation element is dealing axis and angle. Furthermore,
the rotation is in three dimension matrix.
111
According to Wikepidia (2010), there are three basic 3D rotation matrixes rotate
vectors about the axis x,y and z :
Rx (θ) =
1
0
0
0
0
cos θ sin θ
sin θ cos θ
Ry (θ) =
cos θ
0
-sin θ
0
1
0
Rz (θ) =
cos θ
sin θ
0
-sin θ 0
cos θ 0
0
1
sin θ
0
cos θ
θ is the rotation angle for the axis x,y and z. It could be described by following figure
4.11 where the direction of the arrow in degree or radiant is θ for the rotation angle.
Figure 4.11: Rotation on the axis x, y and z Bethel, (2003)
112
The direction of the rotation is as follows: Rx rotates the y-axis towards the z-axis, Ry
rotates the z-axis towards the x-axis, and Rz rotates the x-axis towards the y-axis. The
resulting coordinates (x',y',z') for a point (x,y,z), for each of these rotations can be
described in the following table 4.3.
Table 4.3: Rotation matrix.
x'
y'
Rx(θ)
x
y cos θ – z sin θ
Ry(θ)
x cos θ + z sin θ
Rz(θ)
x cos θ – y sin θ
y
z'
z cos θ + y sin θ
-x sin θ – z cos θ
y cos θ + x sin θ
z
Usually in 3D space y – axis is going to the right, x– axis is going to the front
and z– axis is going up. Thus, these three rotations would be counterclockwise when
the third axis moves towards the observer. This direction of the rotation can be
determined by the right-hand rule. In mathematics and physics, there are two rules in
rotation which are the right-hand rule and left-hand rule (see figure 4.12).
z
z
x
y
y
x
Figure 4.12: The left-handed orientation is shown on the left, and the right-handed on
the right.
113
By considering the angle and axis in rotation, element of rotation is
implemented together with 3D primitive objects. This rotation element is embedded
in the procedure for 3D primitive object as shown in Section 4.1. The user must
specify the object’s axis and angle during call procedure process in order to rotate
objects when needed. For each 3D primitive object, a point of rotation is different
with one another. The rotation point of cone is set up to the centre point of its
circular base. This is similar for cylinder, whereby the rotation point is located at the
centre point of its circular base (bottom). For torus shape, its rotation point is located
at the main centre point but care must be taken to not be confused with the centre
point of the tube. Last but not least, the rotation point for sphere is its centre point at
xo,yo,zo. Table 4.4 describes the location of rotation point for 3D primitive objects.
Table 4.4: Location of rotation point.
Object
Object’s Figure
Location of Rotation Point
Name
Cone
Centre point of Cone base
•
Centre point of Cylinder base
Cylinder
•
Torus
•
Main Centre point of Torus
114
Sphere
•
Centre Point of Sphere
Using the equations in Table 4.3, objects can be rotated at the point rotation. The
rotation of 3D primitive objects towards the axis x, y and z can be described in the
following paragraphs and figures. The example is based on left-handed orientation.
•
Rotation on Cone
When no value is set for the rotation element, the cone’s position is in the
right angle towards the axis x, y and z.
Call createcone (‘Cone’, 1, 0,0,0);
Call completed.
Z
•
Y
X
When the y-axis is rotated towards the z-axis, the x of x,y,z point is fixed.
Only y and z would result in new coordinates. The row below from Table 4.3
describes the statement.
115
x'
y'
x
Rx(θ)
z'
y cos θ – z sin θ
z cos θ + y sin θ
The following procedure shows the rotation element of axis-y towards axis-z.
The rotation angle for axis-x Rx(θ) is set to 90°.
Call createcone (‘Cone’, 1, 90,0,0);
Call completed.
The new position of cone can be described in the following figure.
Z
•
Y
X
Rotation angle for axis – y, Ry rotates the z-axis towards the x-axis. Coordinate y for
point x,y,z remains in its position. As taken from Table 4.3, the rotation angle at axis
– y is described in the following row.
Ry(θ)
x'
y'
z'
x cos θ + z sin θ
y
-x sin θ – z cos θ
The procedure below shows the rotation element of axis-z towards axis-x. The
rotation angle for axis-y Ry(θ) is set to 90°.
116
Call createcone (‘Cone’, 1, 0,90,0);
Call completed.
The new position of cone can be described in the following figure.
Z
•
Y
X
When the rotation angle on the axis – z is set to 90°, it rotates the x-axis towards the
y-axis. Rotation angle at axis – z is described in the following row:
x'
Rz(θ)
y'
x cos θ – y sin θ
y cos θ + x sin θ
z'
z
The procedure below shows the rotation element of axis-x towards axis-y. The
rotation angle for axis-z Rz(θ) is set to 90°.
Call createcone (‘Cone’, 1, 0,0,90);
Call completed.
Z
•
X
Y
117
4.5
Conclusion
In this chapter, 3D primitive objects are created. The procedure for each
objects is created using PL/SQL language in Oracle stored procedure. All of 3D
primitive objects procedures are based on the constructed models shown in Chapter
3. Before the procedure is called, the table had to be created and successfully
indexed. The procedure is called using
call
statement in SQL*Plus. Several
examples on insert statement and load procedure can also be found in this chapter,
along with the implementation and discussion on the rotation element for axis x,y and
z.
CHAPTER 5
RESULTS AD QUERY
5.1
Background
This chapter explains some results from the tests conducted on the
implementation of 3D primitive objects in DBMS level. This chapter is divided into
several sections, with Section 5.1 explaining how to visualize 3D primitive objects
from DBMS. In Section 5.2, 3D primitive objects are tested using simulation data
and retrieved in CAD viewer. The combination of objects are also tested and
discussed in this section. Meanwhile, Section 5.3 shows some samples of 3D
primitive objects using real datasets while in Section 5.4, rotation element is tested.
Surface smoothness and rendering is discussed in Section 5.5 while Section 5.6
explains some simple queries towards DBMS.
119
5.2
Visualization of 3D primitive Objects.
Objects stored in Oracle DBMS can be viewed through their own interface
i.e. Oracle Spatial map viewer. Unfortunately this interface cannot support objects in
3D due to the absence of visualizing objects in 3D. Interoperability function is also
provided by Oracle to allow users to integrate data with CAD applications. There are
several CAD applications which are able to read data from spatial column in spatial
DBMS, as exemplified by Bentley Map that is capable of querying data from
SDO_Geometry column in Oracle. This built-in connection is also available in
Autodesk product i.e. Autodesk Map 3D. The data retrieval from spatial DBMS to
Bentley is explained in Figure 5.1.
SDO_Geometry
Column
Retrieve Data
Interoperability
Figure 5.1: Data interoperability through Oracle and Bentley
5.3
3D Primitive Objects in DBMS
In Chapter 4, the procedure to create 3D primitive objects was briefly
explained. The three main steps to create 3D primitive objects are:
120
•
Create Standard Table
•
Insert Statement
•
Call Procedure
As mentioned in the previous chapter, the standard table structure to create 3D
primitive objects is:
SQL> desc PRIMITIVE_OBJECTS;
Name
Null?
Type
------------------------------------ -------- -------------------ID
NOT NULL NUMBER(6)
DESCRIPTION
VARCHAR2(250)
RADIUS
NUMBER(15,3)
RADIUS_SUB
NUMBER(15,3)
CENTREPOINT_X
NUMBER(18,3)
CENTREPOINT_Y
NUMBER(18,3)
CENTREPOINT_Z
NUMBER(18,3)
HEIGHT
NUMBER(15,3)
VOLUME
NUMBER(15,3)
AREA
NUMBER(15,3)
GEOMETRY
MDSYS.SDO_GEOMETRY
This structure is fixed, with only the table name modifiable.
Parameter values were needed to run the
INSERT
INTO
statement and created
procedure. The syntax below shows the insert into statement and call created
procedure:
INSERT INTO <Table_Name> VALUES (
<Object_ID>,<Object_Description>,<Radius>,<Sub_Radius>,<CenterPoint_X>,<Cent
erPoint_Y>,<CenterPoint_Z>,<Height>,<Volume>,<Area>,<Geometry> );
Call <procedure_name> (<table_name>, <object_id>, <rotation angle for axisx, rotation angle for axis-y and rotation angle for axis-z>);
121
5.3.1 Cone
In generating a cone, several parameters with its values had to be included in
INSERT INTO
statement. The parameters and values used to create cone were:
•
Radius, r: 15
•
Centre Point xo, yo, zo: 10.0, 10.0, 10.0
•
Height, h: 30.0
SQL> INSERT INTO Cone VALUES(
1,’Cone’,15,NULL,10.0,10.0,10.0,30.0,NULL,NULL,NULL,NULL);
1 row created.
The call procedure was done after insert statement was successfully created. The
syntax below shows the call procedure syntax. The rotation parts were set as ‘0’
which means no rotation element.
SQL> Call createcone (‘Cone’, 1, 0,0,0);
Call completed.
The cone geometry was retrievable through SQL
SELECT
statement once call
procedure was successfully created. The following syntax shows generated geometry
from created procedure.
SQL> SELECT GEOMETRY
2
FROM Cone
3
WHERE ID = 1;
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
----------------------------------------------------------------------------------SDO_GEOMETRY(3007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 13, 1003, 1, 25,1003,
1, 37, 1003, 1, 49, 1003, 1, 61, 1003, 1, 73, 1003, 1, 85, 1003, 1, 97, 1003, 1, 109,
1003, 1, 121, 1003, 1, 133, 1003, 1, 145, 1003, 1, 157, 1003, 1, 169, 1003, 1, 181,
1003, 1, 193, 1003, 1, 205,1003, 1, 217, 1003, 1, 229, 1003, 1,241, 1003, 1),
SDO_ORDINATE_ARRAY(10, 10, 40, 5.367, 24.267, 10, 10, 25, 10, 10, 10, 40, 10, 10, 40,
1.187, 22.138, 10, 5.367, 24.267, 10, 10, 10, 40, 10, 10,40, -2.131, 18.823, 10,
1.187, 22.138, 10, 10, 10, 40, 10, 10, 40, -4.268, 14.63, 10, -2.131, 18.823, 10, 10,
10, 40, 10, 10, 40, -5, 9.997, 10, -4.268, 14.63,10, 10, 10, 40, 10, 10, 40, -4.266,
122
5.364, 10, -5, 9.997, 10, 10, 10, 40, 10, 10, 40, -2.136, 1.185, 10, -4.266, 5.364,
10, 10, 10, 40, 10, 10, 40, 1.18, -2.133, 10, -2.136, 1.185, 10, 10, 10, 40, 10, 10,
40, 5.359, -4.264, 10, 1.18, 2.133, 10, 10,
10,
40,
10,
10,
40,
10.006,
-5,
10,
5.359, -4.264, 10, 10, 10, 40, 10,10, 40, 14.639, -4.265, 10, 10.006, -5, 10, 10, 10,
40, 10, 10, 40, 18.818, -2.134, 10, 14.639,-4.265, 10, 10, 10, 40, 10, 10, 40,
22.135, 1.182, 10, 18.818,-2.134, 10, 10, 10, 40, 10, 10, 40, 24.265, 5.361, 10,
22.135, 1.182, 10, 10, 10, 40, 10, 10, 40, 25, 9.994, 10, 24.265, 5.361, 10, 10, 10,
40, 10, 10, 40, 24.264, 14.642, 10, 25, 9.994, 10, 10, 10, 40, 10, 10, 40, 22.133,
18.82, 10, 24.264, 14.642, 10, 10, 10, 40, 10, 10, 40, 18.815, 22.136, 10, 22.133,
18.82, 10,10,10, 40, 10, 10, 40, 14.636, 24.266, 10, 18.815, 22.136, 10, 10, 10, 40,
10, 10,40,
10,1.187,
14.636, 24.266, 10, 10, 25, 10, 10, 10, 40, 10, 25, 10, 5.367, 24.267,
22.138,
10,
-2.131,
18.823,
10,
-4.268,
14.63,
10,-5,9.997,
10,-
4.266,5.364, 10, -2.136, 1.185, 10, 1.18, -2.133, 10, 5.359, -4.264, 10, 10.006, 5,10, 14.639,-4.265, 10, 18.818, -2.134, 10, 22.135, 1.182, 10, 24.265, 5.361, 10,
25, 9.994, 10, 24.264,14.642,10, 22.133, 18.82,10,18.815, 22.136, 10, 14.636,24.266,
10, 10, 25, 10))
1 row selected.
Figure 5.2 below shows a visualization of cone geometry in CAD i.e. Bentley Map.
Figure 5.2: Retrieved cone datasets through CAD viewer.
123
5.3.2 Cylinder
The parameters for creating a cylinder are height h, radius r and centre point xo, yo, zo.
The parameters and values used to create a cone are:
•
Radius, r: 15
•
Centre Point xo, yo, zo: 10.0, 10.0, 10.0
•
Height, h: 30.
SQL> INSERT INTO Cylinder VALUES(
2,’Cone’,15,NULL,20.0,20.0,20.0,30.0,NULL,NULL,NULL,NULL);
1 row created.
The call procedure was done after insert statement was successfully created. The
following syntax shows call procedure syntax. The rotation parts is set as ‘0’ which
means no rotation element.
SQL> Call createcylinder (‘Cylinder’, 2, 0,0,0);
Call completed.
By using
SELECT
statement, the geometry of cylinder could be queried from
SQL*Plus. The syntax of the generated geometry of cylinder from the created
procedure is:
SQL> SELECT GEOMETRY
2
FROM CYLINDER
3
WHERE ID = 2;
GEOMETRY(SDO_GTYPE,
SDO_SRID,
SDO_POINT(X,
Y,
Z),
SDO_ELEM_INFO,
SDO_ORDINATES)
--------------------------------------------------------------------------SDO_GEOMETRY(3007,
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,
1003,
1,
64,
1003,
1,
79,1003, 1, 94, 1003, 1, 109, 1003, 1, 124, 1003, 1, 139, 1003, 1, 154, 1003, 1, 169,
1003, 1, 184, 1003, 1, 199, 1003, 1, 214, 1003, 1, 229, 1003, 1, 244, 1003, 1, 259,
1003, 1, 274, 1003, 1, 289, 1003, 1, 304, 1003, 1, 319, 1003, 1, 334, 1003, 1, 349,
1003, 1, 364, 1003, 1), SDO_ORDINATE_ARRAY(20, 35, 50, 15.367, 34.267, 50, 11.187,
32.138, 50, 7.869, 28.823, 50, 5.732, 24.63, 50, 5, 19.997, 50, 5.734, 15.364, 50,
7.864, 11.185, 50, 11.18, 7.867, 50, 15.359, 5.736, 50, 20.006,5, 50, 24.639, 5.735,
50, 28.818, 7.866, 50, 32.135, 11.182, 50, 34.265, 15.361, 50, 35, 19.994, 50,
124
34.264, 24.642, 50, 32.133, 28.82, 50, 28.815, 32.136, 50,24.636, 34.266, 50, 20, 35,
50, 20, 35, 50, 15.367, 34.267, 50, 15.367, 34.267,20, 20, 35, 20, 20, 35, 50,
15.367, 34.267, 50, 11.187, 32.138, 50, 11.187, 32.138, 20, 15.367, 34.267, 20,
15.367, 34.267, 50, 11.187, 32.138, 50, 7.869, 28.823, 50, 7.869, 28.823, 20, 11.187,
32.138, 20, 11.187, 32.138, 50, 7.869, 28.823, 50, 5.732, 24.63, 50, 5.732, 24.63,
20, 7.869, 28.823, 20, 7.869, 28.823, 50,5.732, 24.63, 50, 5, 19.997, 50, 5, 19.997,
20, 5.732, 24.63, 20, 5.732, 24.63,50, 5, 19.997, 50, 5.734, 15.364, 50, 5.734,
15.364, 20, 5, 19.997, 20, 5, 19.997, 50, 5.734, 15.364, 50, 7.864, 11.185, 50,
7.864, 11.185, 20, 5.734, 15.364, 20, 5.734, 15.364, 50, 7.864, 11.185, 50, 11.18,
7.867, 50, 11.18, 7.867, 20, 7.864, 11.185, 20, 7.864, 11.185, 50, 11.18, 7.867, 50,
15.359, 5.736, 50, 15.359,5.736, 20, 11.18, 7.867, 20, 11.18, 7.867, 50, 15.359,
5.736, 50, 20.006, 5, 50,20.006, 5, 20, 15.359, 5.736, 20, 15.359, 5.736, 50, 20.006,
5, 50, 24.639, 5.735, 50, 24.639, 5.735, 20, 20.006, 5, 20, 20.006, 5, 50, 24.639,
5.735, 50, 28.818, 7.866, 50, 28.818, 7.866, 20, 24.639, 5.735, 20, 24.639, 5.735,
50, 28.818,7.866, 50, 32.135, 11.182, 50, 32.135, 11.182, 20, 28.818, 7.866, 20,
28.818,
7.866,
50,
32.135,
11.182,
50,
34.265, 15.361,
50,
34.265,
15.361,
20,
32.135, 11.182, 20, 32.135, 11.182, 50, 34.265, 15.361, 50, 35, 19.994, 50, 35,
19.994, 20,34.265, 15.361, 20, 34.265, 15.361, 50, 35, 19.994, 50, 34.264, 24.642,
50, 34.264, 24.642, 20, 35, 19.994, 20, 35, 19.994, 50, 34.264, 24.642, 50, 32.133,
28.82, 50, 32.133, 28.82, 20, 34.264, 24.642, 20, 34.264, 24.642, 50, 32.133, 28.82,
50, 28.815, 32.136, 50, 28.815, 32.136, 20, 32.133, 28.82, 20, 32.133, 28.82,50,
28.815,
32.136,
50,
24.636,
34.266,
50,
24.636,
34.266,
20,
28.815,
32.136,20,
28.815, 32.136, 50,24.636, 34.266, 50, 20, 35, 50, 20, 35, 20, 24.636, 34.266, 20,
24.636, 34.266, 50, 20, 35, 20, 15.367, 34.267, 20, 11.187, 32.138, 20,7.869, 28.823,
20, 5.732, 24.63, 20, 5, 19.997, 20, 5.734, 15.364, 20, 7.864, 11.185, 20, 11.18,
7.867, 20, 15.359, 5.736, 20, 20.006, 5, 20, 24.639, 5.735, 20,28.818, 7.866, 20,
32.135, 11.182, 20, 34.265, 15.361, 20, 35, 19.994, 20, 34.264, 24.642, 20, 32.133,
28.82, 20, 28.815, 32.136, 20, 24.636, 34.266, 20, 20, 35, 20))
1 row selected.
The retrieved geometry datasets could be mapped to CAD viewer through
interoperability functions. Figure 5.3 shows rendered datasets of cylinder from
Oracle to CAD viewer
125
Figure 5.3: The Geometry of Cylinder in Bentley Map.
5.3.3 Torus
Several parameters with the respective values had to be included in
INTO
statement. The parameters and values used to create torus are:
•
Radius, R: 150
•
Sub Radius, r: 50.0
•
Centre Point xo, yo, zo: 30.0, 30.0, 30.0
SQL> INSERT INTO Torus VALUES(
3,’Torus’,150,50,30.0,30.0,30.0,NULL,NULL,NULL,NULL,NULL);
1 row created.
INSERT
126
The call procedure should be done after the insert statement is successfully created.
The rotation part is set as ‘0’ which means no rotation element. The call procedure
syntax is:
SQL> CALL createtorus (‘Torus’, 3, 0,0,0);
Call completed.
The torus geometry is retrieve through SQL
SELECT
statement once call procedure
had been successfully completed. The following syntax is generated geometry from
the created procedure.
SQL> SELECT GEOMETRY
2
FROM TORUS
3
WHERE ID = 3;
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
-----------------------------------------------------------------------------SDO_GEOMETRY(3007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 16, 1003, 1, 31,1003,
1, 46, 1003, 1, 61, 1003, 1, 76, 1003, 1, 91, 1003, 1, 106, 1003, 1, 121,1003, 1,
136, 1003, 1, 151, 1003, 1, 166, 1003, 1, 181, 1003, 1, 196, 1003, 1, 211, 1003, 1,
226, 1003, 1, 241, 1003, 1, 256, 1003, 1, 271, 1003, 1, 286, 1003,1, 301, 1003, 1,
316, 1003, 1, 331, 1003, 1, 346, 1003, 1, 361, 1003, 1, 376, 1003, 1, 391, 1003, 1,
406, 1003, 1, 421, 1003, 1, 436, 1003, 1, 451, 1003, 1, 466, 1003, 1, 481, 1003, 1,
496, 1003, 1, 511, 1003, 1, 526, 1003, 1, 541, 1003, 1,556, 1003, 1, 571, 1003, 1,
586, 1003, 1, 601, 1003, 1, 616, 1003, 1, 631, 1003, 1, 646, 1003, 1, 661, 1003, 1,
676, 1003, 1, 691, 1003, 1, 706, 1003, 1, 721,1003, 1, 736, 1003, 1, 751, 1003, 1,
766, 1003, 1, 781, 1003, 1, 796, 1003, 1, 811, 1003, 1, 826, 1003, 1, 841, 1003, 1,
856, 1003, 1, 871, 1003, 1, 886, 1003,1, 901, 1003, 1, 916, 1003, 1, 931, 1003, 1,
946, 1003, 1, 961, 1003, 1, 976, 1003, 1, 991, 1003, 1, 1006, 1003, 1, 1021, 1003, 1,
1036, 1003, 1, 1051, 1003, 1,1066, 1003, 1, 1081, 1003, 1, 1096, 1003, 1, 1111, 1003,
1, 1126, 1003, 1, 1141, 1003, 1, 1156, 1003, 1, 1171, 1003, 1, 1186, 1003, 1, 1201,
1003, 1, 1216, 100, 1003, 1, 2836, 1003, 1, 2851, 1003, 1, 2866, 1003, 1, 2881, 1003,
1, 2896, 1003, 1, 2911, 1003, 1, 2926, 1003, 1, 2941, 1003, 1, 2956, 1003, 1, 2971,
1003,
1,2986,
1003,
1),
SDO_ORDINATE_ARRAY(230,
30,
30,
220.221,
-31.773,
30,
211.148,-28.827, .624, 220.46, 30, .624, 230, 30, 30, 220.46, 30, .624, 211.148, 28.827, .624, 187.345, -21.097, -17.558, 195.434, 30, -17.558, 220.46, 30, .624,
195.434,
30,
-17.558,
187.345,
-21.097,
-17.558,
157.968,
-11.557,
-17.552,
164.547,30, -17.552, 195.434, 30, -17.558, 164.547, 30, -17.552, 157.968, -11.557, 17.552, 134.2, -3.838, .6, 139.557, 30, .6, 164.547, 30, -17.552, 139.557, 30, .6,
134.2, -3.838, .6, 125.111, -.887, 30.02, 130, 30, 30.02, 139.557, 30, .6, 130, 30,
30.02, 125.111, -.887, 30.02, 134.196, -3.837, 59.393, 139.552, 30, 59.393, 130, 30,
30.02,
139.552,
30,
59.393,
134.196,
-3.837,
59.393,
157.96,
-11.554,
77.549,
164.538, 30, 77.549, 139.552, 30, 59.393, 164.538, 30, 77.549, 157.96, -11.554,
77.549, 187.381, -21.109, 77.546, 195.472, 30, 77.546, 164.538, 30, 77.549, 195.472,
30, 77.546, 187.381, -21.109, 77.546, 211.143, -28.825, 59.384, 220.455, 30, 59.384,
127
195.472, 30, 77.546, 220.455, 30, 59.384, 211.143, -28.825, 59.384, 220.221, -31.773,
30, 230, 30, 30, 220.455, 30, 59.384, 220.221, -31.773, 30, 191.841, -87.506, 30,
184.121, -81.9, .624, 211.148, -28.827, .624, 220.221, -31.773, 30, 211.148, -28.827,
-34.368,
.6,
110.92,
-28.753,
30.02,
125.111,
-.887,
30.02,
134.2,
-3.838,
.6,
125.111, -.887, 30.02, 110.92, -28.753, 30.02, 118.65, -34.365,59.393, 134.196, 3.837, 59.393, 125.111, -.887, 30.02, 134.196, -3.837, 77.549, 187.381, -21.109,
77.546, 163.901, -67.219, 77.546, 184.117, -81.898, 59.384, 211.143, -28.825, 59.384,
187.381,
-21.109,
77.546,
211.143,
-28.825,
59.384,
184.117,
-81.898,
59.384,
191.841, -87.506, 30, 220.221, -31.773, 30, 211.143, -28.825, 59.384, 191.841, 87.506, 30, 147.634, -131.747, 30, 142.023, -124.032, .624, 184.121,-81.9, .624,
191.841, -87.506, 30, 184.121, -81.9, .624, 142.023, -124.032, .6250.874, 30.02,
94.435, -58.599, 59.393, 118.65, -34.365, 59.393, 138.869, -49.045, 77.549, 109.131,
-78.806,
77.549,
127.326,
-103.823,
77.546,
163.901,
-67.219,
77.546,138.869,
49.045, 77.549, 163.901, -67.219, 77.546, 127.326, -103.823, 77.546,))
1 row selected.
Figure 5.4 shows a visualization of torus geometry in CAD i.e. Bentley Map.
Figure 5.4: Retrieved Geometry of Torus in Bentley Map.
-
128
5.3.4 Sphere
The parameters and values used to create Sphere were:
•
Radius, R: 150
•
Sub Radius, r: 50.0
•
Centre Point xo, yo, zo: 30.0, 30.0, 30.0
These parameter values had to be included during insert
into
statement.
SQL> INSERT INTO Sphere VALUES(
4,’Sphere’,15,NULL,40.0,40.0,40.0,NULL,NULL,NULL,NULL,NULL);
1 row created.
The call procedure should be done after insert statement is successfully created. The
rotation part is set as ‘0’ which means no rotation element. The call procedure syntax
for sphere is:
SQL> CALL createsphere (‘Sphere’, 3, 0,0,0);
Call completed.
The geometry of sphere was retrievable through SQL SELECT statement once the call
procedure was successfully created. Generated geometry from the created procedure
are:
SQL> SELECT GEOMETRY
2
FROM SPHERE
3
WHERE ID = 4;
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
-----------------------------------------------------------------------------SDO_GEOMETRY(3007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 13, 1003, 1, 25,1003,
1, 37, 1003, 1, 49, 1003, 1, 61, 1003, 1, 73, 1003, 1, 85, 1003, 1, 97, 1003, 1, 109,
1003, 1, 121, 1003, 1, 133, 1003, 1, 145, 1003, 1, 157, 1003, 1, 169, 1003, 1, 181,
1003, 1, 193, 1003, 1, 205, 1003, 1, 217, 1003, 1, 229, 1003, 1,241, 1003, 1, 256,
1003, 1, 271, 1003, 1, 286, 1003, 1, 301, 1003, 1, 316, 1003, 1, 331, 1003, 1, 346,
1003, 1, 361, 1003, 1, 376, 1003, 1, 391, 1003, 1, 406,1003, 1, 421, 1003, 1, 436,
1003, 1, 451, 1003, 1, 466, 1003, 1, 481, 1003, 1, 496, 1003, 1, 511, 1003, 1, 526,
1003, 1, 541, 1003, 1, , 1426, 1003, 1, 1441, 1003, 1, 1456, 1003, 1, 1471, 1003, 1,
1,2809, 1003, 1,
2821,
1003, 1,
2833, 1003,
1, 2845, 1003,
1, 2857, 1003, 1,
129
2869,1003, 1), SDO_ORDINATE_ARRAY(40, 40, 55, 37.22, 48.56, 52, 40, 49, 52, 40, 40,5,
40, 40, 55, 34.712, 47.283, 52, 37.22, 48.56, 52, 40, 40, 55, 40, 40, 55, 32.721,
45.294, 52, 34.712, 47.283, 52, 40, 40, 55, 40, 40, 55, 31.439, 42.778, 52, 32.721,
45.294, 52, 40, 40, 55, 40, 40, 55, 31, 39.998, 52, 31.439, 42.778, 52, 40, 40, 55,
40, 40, 55, 31.441, 37.218, 52, 31, 39.998, 52, 40, 40, 55, 40, 40, 55, 32.718,
34.711, 52, 31.441, 37.218, 52, 40, 40, 55, 40, 40, 55, 34.708, 32.72, 52, 32.718,
34.711, 52, 40, 40, 55, 40, 40, 55, 37.215, 31.442, 52, 34.708,32.72, 52, 40, 40, 55,
40, 40, 55, 40.004, 31, 52, 37.215, 31.442, 52, 40, 40,55, 40, 40, 55, 42.783,
31.441, 52, 40.004, 31, 52, 40, 40, 55, 40, 40, 55, 45.291, 32.719, 52, 42.783,
31.441, 52, 40, 40, 55, 40, 40, 55, 47.281, 34.709, 52,45.291, 32.719, 52, 40, 40,
55, 40, 40, 55, 48.559, 37.217, 52, 47.281, 34.709,52, 40, 40, 55, 40, 40, 55, 49,
39.996, 52, 48.559, 37.217, 52, 40, 40, 55, 40,40, 55, 48.558, 42.785, 52, 49,
39.996, 52, 40, 40, 55, 40, 40, 55, 47.28, 45.292, 52, 48.558, 42.785, 52, 40, 40,
55, 40, 40, 55, 45.289, 47.282, 52, 47.28, 45.292, 52, 40, 40, 55, 40, 40, 55,
42.781, 48.559, 52, 45.289, 47.282, 52, 40, 40, 55, 40, 40, 55, 42.781, 48.559, 52,
40, 49, 52,
**** see appendix for full row))
1 row selected.
Figure 5.5 below shows a visualization of sphere geometry in CAD i.e. Bentley Map.
Figure 5.5: Visualization of Sphere.
130
With this, 3D primitive objects have been successfully implemented in DBMS level.
The objects procedure were extended and modified to be used with objects based on
created 3D primitive objects. The procedure was also extended to create half of the
cone, half of the cylinder, half of the torus, quarter of the torus and half of the sphere
or known as hemisphere. This is followed by the example of
call
procedure in
creating these objects, as well as figures showing the retrieved objects from Bentley
Map. These created objects still used the same standard table structure, same
parameters and same simulation dataset as shown in previous example.
5.3.5 Half Cone
To create a half cone, the following syntax was processed through SQL*Plus.
This process required a table name and object id as stated in the insert into statement.
In the following syntax, rotation elements remained as having as no rotation.
Call createhalfcone (‘Cone’, 1, 0,0,0);
Call completed.
With the same procedure, the half cone geometry was retrievable and viewable
through front-end application i.e. Bentley Map. In Figure 5.6, different views of half
cone are viewable
131
Figure 5.6: Visualization of half cone from different views.
5.3.6 Half Cylinder
The syntax below was processed through SQL*Plus in order to create a half
cylinder. It is not that different when compared with the procedure for creating a half
cone. The difference is only in the table name and object id. In this example, rotation
elements remained as having zero value.
Call createhalfcylinder (‘Cylinder’, 2, 0,0,0);
Call completed.
132
By using the same procedure, the half cylinder geometry could be retrieved and
viewed through Bentley Map. In Figure 5.7, different views of the half cylinder can
be viewed.
Figure 5.7: Visualization of half cylinder from different views.
5.3.7 Half Torus
Half of the torus was also created by using the same procedure as cylinder
and cone. The procedure was called and run using SQL*Plus. The syntax below
shows the called procedure for half of the torus.
133
Call createhalftorus (‘Torus’, 3, 0,0,0);
Call completed.
With the same procedure, the half torus geometry was retrievable and viewable
through Bentley Map. In Figure 5.8, different views of half cylinder are shown.
Figure 5.8: Visualization of half torus from different views.
134
5.3.8 Quarter Torus
The procedure to create a torus was also extended for creating quarter of a torus.
Quarter of torus can be created through
call
procedure statement. To create quarter
torus, the following syntax had to be processed.
Call createquartertorus (‘Torus’, 3, 0,0,0);
Call completed.
Figures 5.9 shows different angles or views of quarter torus. Bentley Map is
connected to spatial DBMS and reads spatial column directly through
interoperability function.
Figure 5.9: Visualization of quarter torus from different views.
135
5.3.9 Hemisphere (Half Sphere)
Half of a sphere is more familiarly known as hemisphere. In this example, an
extended procedure from sphere was named as ‘createhalfsphere’ procedure. This
procedure was called by using call statement in SQL*Plus. The syntax shows the call
statement for half of the sphere.
Call createhalfsphere (‘Sphere’, 4, 0,0,0);
Call completed.
Figure 5.10 shows various angles or views of quarter torus. Bentley Map is
connected to spatial DBMS and reads spatial column directly through the
interoperability function.
Figure 5.10: Visualization of hemisphere from different views.
136
5.4
Rotation Element
The 3D primitive objects constructed were also experimented with rotation
element. As mentioned in Chapter 4, there are three rotation axis for each objects
which is x,y,z. Each primitive object was rotated at a different rotation point
respectively.
(a)
Rotation of Cone
The following syntax shows the rotation element of axis-y towards axis-z. The
rotation angle for axis-x Rx(θ) was set to 90°.
Call createcone (‘Cone’, 1, 90,0,0);
Call completed.
Figure 5.11: Rotation of cone towards the axis –x Rx(θ) = 90° (right)
In Figure 5.11, the left figure shows the position of cone without element of rotation.
By executing rotation element on the axis –x Rx(θ) = 90° the cone was rotated from the
axis-z towards the axis - y. The position of rotated cone can be seen on the right figure of
Figure 5.10.
For axis-y rotation, Ry(θ) = 90° :
137
Call createcone (‘Cone’, 1, 0,90,0);
Call completed.
Figure 5.12: Rotation of cone towards the axis –y Ry(θ) = 90°
The left figure in Figure 5.12 illustrates the initial position of the cone. Only after the
rotation angle of axis – y is set to 90°, the position of cone was moved as shown on
the right figure of Figure 5.12.
For axis-z rotation, Rz(θ) = 90° :
Call createcone (‘Cone’, 1, 0,0,90);
Call completed.
138
Figure 5.13: Rotation of cone towards the axis –z Rz(θ) = 90°
On the left of Figure 5.13, the cone is shown without any rotation element while the
cone in the right figure is with the rotation angle Rz (θ) = 90°. No changes can be seen
from the above figure even though it was rotated.
(b)
Rotation of Cylinder
The syntax below shows the rotation element of axis-y towards axis-z. The rotation
angle for axis-x Rx(θ) was set to 90°.
Call createcylinder (‘Cylinder’, 2, 90,0,0);
Call completed.
139
Figure 5.14: Rotation of cylinder for axis –x Rx(θ) = 90°
In Figure 5.14, the left figure shows the position of cylinder without element of
rotation. By executing rotation element on the axis –x Rx(θ) = 90° the cylinder was
rotated from the axis-z towards the axis - y. The position of rotated cylinder can be
seen in the right figure of Figure 5.10.
For axis-y rotation, Ry(θ) = 90° :
Call createcylinder (‘Cylinder’, 2, 0,90,0);
Call completed
Figure 5.15: Rotation of cylinder for axis –y Ry(θ) = 90°
140
The left figure in Figure 5.15 illustrates the initial position of cylinder prior to being
rotated. Only after the rotation angle of axis – y was set to 90°, the position of
cylinder moved as shown on the right figure of Figure 5.15.
For axis-z rotation, Rz(θ) = 90° :
Call createcylinder (‘Cylinder’, 2, 0,0,90);
Call completed.
Figure 5.16: Rotation of cylinder for axis –z Rz(θ) = 90°.
In Figure 5.16, the left figure illustrates a cylinder without any rotation
element while the right figure is a cylinder with the rotation angle Rz (θ) = 90°.
No changes can be seen from the above figure even though it was rotated.
141
(c)
Rotation of Torus
The syntax below shows the rotation element of axis-y towards axis-z. The rotation
angle for axis-x Rx(θ) was set to 90°.
Call createtorus (‘Torus’, 2, 90,0,0);
Call completed.
Figure 5.17: Rotation of torus for axis –x Rx(θ) = 90°.
In Figure 5.17, the left figure illustrates the position of torus without element of
rotation. By executing rotation element on the axis –x Rx(θ) = 90° the torus was
rotated from the axis-z towards the axis - y. The position of rotated torus is as shown
in the right figure of Figure 5.17.
For axis-y rotation, Ry(θ) = 90° :
Call createtorus (‘Torus’, 3, 0,90,0);
Call completed.
142
Figure 5.18: Rotation of torus for axis –y Ry(θ) = 90°.
The left figure in Figure 5.18 illustrates the initial position of torus before being
rotated. Only after the rotation angle of axis – y was set to 90°, the position of torus
was moved as shown in the right figure of Figure 5.18.
For axis-z rotation, Rz(θ) = 90° :
Call createtorus (‘torus’, 3, 0,0,90);
Call completed
Figure 5.19: Rotation of torus for axis –z Rz(θ) = 90°
143
In Figure 5.19, the left figure shows the torus without any rotation element while the
right figure shows the torus with the rotation angle Rz (θ) = 90°. No changes can be
seen from the above figure even though it was rotated.
(d)
Rotation of Sphere
The syntax below shows the rotation element of axis-y towards axis-z. The rotation
angle for axis-x Rx(θ) was set to 90°.
Call createsphere (‘Sphere’, 2, 90,0,0);
Call completed.
Figure 5.20: Rotation of sphere for axis –x Rx(θ) = 90°
In Figure 5.20, the left figure shows the position of sphere without element of
rotation. By executing rotation element on the axis –x Rx(θ) = 90° the sphere was
rotated from the axis-z towards the axis - y. The position of rotated sphere is as
shown in the right figure of Figure 5.20.
For axis-y rotation, Ry(θ) = 90° :
Call createsphere (‘Sphere’, 3, 0,90,0);
Call completed
144
Figure 5.21: Rotation of sphere for axis –y Ry(θ) = 90°
The left figure in Figure 5.21 illustrates the initial position of sphere before it was
rotated. Only after the rotation angle of axis – y was set to 90°, the position of sphere
was moved as shown in the right figure of Figure 5.21.
For axis-z rotation, Rz(θ) = 90° :
Call createsphere (‘sphere’, 3, 0,0,90);
Call completed.
Figure 5.22: Rotation of sphere for axis –z Rz(θ) = 90°
145
In Figure 5.22, the left figure illustrates the sphere without any rotation element
while the right figure shows the sphere with the rotation angle Rz (θ) = 90°. No
changes can be seen from the above figure even though it was rotated.
5.5
Combination of 3D Primitive Objects
Objects in the real world were mostly developed by using a combination of
several objects. Therefore, there is a need to experiment with the created 3D
primitive objects by combining the objects with one another. In the DBMS, the
objects were stored in one table and each object was identified by a different row.
The table was developed based on a standard table structure.
(a)
Tower Simulation
The tower was built based on the combination of cylinder, sphere, cone and
torus. The following statement shows the
insert into
statement to the table
Tower.
--Cone
INSERT INTO TOWER
VALUES(1,NULL,12,NULL,20.0,20.0,120.0,73.0,NULL,NULL,NULL,NULL);
--Cylinder
INSERT INTO TOWER VALUES(2,NULL,15,NULL,20.0,20.0,30.0,140.0,NULL,NULL,NULL,NULL);
--Torus
INSERT INTO TOWER
VALUES(3,NULL,15,3,20.0,20.0,110.0,NULL,NULL,NULL,NULL,NULL);
146
INSERT INTO TOWER
VALUES(4,NULL,13,3,20.0,20.0,115.0,NULL,NULL,NULL,NULL,NULL);
INSERT INTO TOWER
VALUES(5,NULL,12,3,20.0,20.0,120.0,NULL,NULL,NULL,NULL,NULL);
INSERT INTO TOWER
VALUES(7,NULL,18,5,20.0,20.0,-40.0,NULL,NULL,NULL,NULL,NULL);
INSERT INTO TOWER
VALUES(8,NULL,15,5,20.0,20.0,-35.0,NULL,NULL,NULL,NULL,NULL);
INSERT INTO TOWER
VALUES(9,NULL,13,7,20.0,20.0,-30.0,NULL,NULL,NULL,NULL,NULL);
--Sphere
INSERT INTO TOWER
VALUES(6,NULL,5,NULL,20.0,20.0,160.0,NULL,NULL,NULL,NULL,NULL);
INSERT INTO TOWER
VALUES(10,NULL,3,NULL,20.0,20.0,179.0,NULL,NULL,NULL,NULL,NULL);
INSERT INTO TOWER
VALUES(11,NULL,2.5,NULL,20.0,20.0,184.0,NULL,NULL,NULL,NULL,NULL);
With the Bentley Map and Oracle verifying the connection from the
interoperability function and the connection, Bentley Map retrieved spatial
column and displayed the geometry as in Figure 5.23:
147
Figure 5.23: Simulation of tower structure.
In Figure 5.23, the combination of several primitives was successfully stored
and retrieved. During the insert statement procedure, four types of objects
were stored in the Tower’s table and retrieved through front-end application
as one object.
(b)
SALT (Southern African Large Telescope) Simulation
SALT is the Southern African Large Telescope. It is the largest single optical
telescope in the southern hemisphere. The building structure of SALT is
based on cylinder, sphere and several basic shapes such as rectangular. This
148
experiment attempted to model SALT structure based on implemented 3D
primitive objects. Figure 5.24 shows the image of SALT.
Figure 5.24: SALT building structure SAOO (2010).
The statement below shows the
insert into
statement towards the table
SALT.
--Cylinder
INSERT INTO SALT
VALUES(1,NULL,30,NULL,20.0,20.0,20.0,60.0,NULL,NULL,NULL,NULL);
INSERT INTO SALT
VALUES(3,NULL,15,NULL,-15.0,-15.0,20.0,20.0,NULL,NULL,NULL,NULL);
INSERT INTO SALT
VALUES(4,NULL,5,NULL,-20.0,-20.0,20.0,65.0,NULL,NULL,NULL,NULL);
INSERT INTO SALT
VALUES(5,NULL,4,NULL,-20.0,-20.0,85.0,25.0,NULL,NULL,NULL,NULL);
INSERT INTO SALT
VALUES(6,NULL,5.5,NULL,-19.0,-19.0,110.0,1.5,NULL,NULL,NULL,NULL);
--Hemisphere
149
INSERT INTO SALT
VALUES(2,NULL,30,NULL,20.0,20.0,80.0,NULL,NULL,NULL,NULL,NULL);
INSERT INTO SALT
VALUES(7,NULL,5.5,NULL,-19.0,-19.0,111.5,NULL,NULL,NULL,NULL,NULL);
--Torus
INSERT INTO SALT
VALUES(8,NULL,30,1.0,20.0,20.0,80.0,NULL,NULL,NULL,NULL,NULL);
INSERT INTO SALT VALUES(9,NULL,5,0.5,-20.0,20.0,85.0,NULL,NULL,NULL,NULL,NULL);
The combination of objects was successfully stored in SALT’s table, after
which the connection between Bentley Map and Oracle was verified. From
the connection of Bentley Map and Oracle, the model of SALT could be
retrieved and viewed as figure 5.25.
Figure 5.25: Simulation of SALT building.
150
(c)
Pipeline Simulation
A pipeline structure can be modeled using the implemented 3D primitive
objects. The structure of pipeline can be basically developed using cylinder
base shape. Using the respective simulation datasets, underground pipeline
was modeled using 3D primitive cylinder and torus. The figure below shows
the retrieved pipeline datasets that was modeled in Bentley Map.
Figure 5.26: Simulation of pipeline in various directions.
In Figure 5.26, quarter of torus was used as a connecter to connect pipe bars. It is
shown that the combination of 3D primitive objects i.e. quarter of torus and cylinder
is capable of modeling utilities based on cylinder shape such as pipelines. In
addition, this experiment also made use of the rotation element due to the various
directions of pipelines.
151
5.6
3D Primitive Objects and Real Datasets
The 3D primitive objects were then experimented with by utilizing the real
datasets, which were based on a building in Suleymaniye area, Istanbul, Turkey. The
datasets were built in CAD format and further converted to the geometry representation
of Oracle Spatial. From the drawing model, only certain parts of the building were
tested with 3D primitive objects in DBMS. The parts were based on implemented 3D
primitives such as sphere base, cone base, cylinder base and torus base. Figure 5.27
shows the real datasets in CAD format i.e. Autodesk Map 3D.
Figure 5.27: Real datasets of building tower in Suleymaniye area.
The datasets of tower were captured and remodeled in CAD format as shown in
Figure 5.27. Several parameters were extracted from the CAD datasets and executed
in insert
into
statement. The extracted parameters were:
152
For tower body (cylinder base):
• centre point xo,yo,zo
• radius r
• height h
For tower roof (cone base):
•
center point xo,yo,zo
•
base radius r
•
height h
By using the same method in previous examples, the table was first created. The
parameters were later stored into the DBMS using insert into statement. The
syntax below shows insert into statement for extracted parameters.
SQL> INSERT INTO Tower VALUES(
1,’Cylinder’,15,NULL,40.0,40.0,40.0,NULL,NULL,NULL,NULL,NULL);
1 row created.
SQL> INSERT INTO Tower VALUES(
2,’Cone’,15,NULL,40.0,40.0,40.0,NULL,NULL,NULL,NULL,NULL);
1 row created.
The objects were then generated and modeled by the execution of 3D primitive
objects procedure. The following syntax shows call statement in constructing the
tower body and roof.
SQL> Call createcylinder (‘Tower’, 1, 0,0,0);
Call completed.
SQL> Call createcylinder (‘Tower’, 2, 0,0,0);
Call completed.
To model the tower exactly like in real life, the cube and faces were stored together
in towers table. The cube and faces were stored using the provided procedure in
Oracle Spatial. To view and map the building geometry, Bentley Map was
synchronized with Oracle database to retrieve the geometry column in towers table.
In Figure 5.28, the results are described and compared with the real image.
153
Figure 5.28: The real image (left) and the constructed tower using 3D primitive
objects with cube and faces (right)
The next example also shows a part of a building in the Suleymaniye area. In this
example, hemisphere and cylinder were tested together to model the roof part.
Hemisphere was used to model the dome part while cylinder was used to model the
roof base. Figure 5.29 shows the image of the building used in this experimentation.
154
Figure 5.29: Image of the experimented object.
Real datasets were built in CAD format; hence parameters were extracted directly
from CAD format. In this example, the hemisphere and cylinder procedures were
utilized to model building parts i.e. dome and roof base. Thus, parameters related to
3D primitive objects were necessitated in processing the created procedure. The
paragraph below lists the required parameters.
For tower body (cylinder base):
•
centre point xo,yo,zo
•
radius r
•
height h
For dome (hemisphere base):
•
center point xo,yo,zo
•
base radius r
155
Figure 5.30: Dome in the AutoCAD format (left) and rendered datasets from
DBMS (right)
In Figure 5.30, it can be seen that the roof of the construction building was successfully
stored and retrieved. The construction objects were modeled from the shape of cylinder
and hemisphere. As explained in the previous paragraph, the parameters were extracted
from CAD drawing and executed with the procedures for cylinder and hemisphere. From
the result, it can be proved that modeling the construction building with 3D primitive
objects does represent the same shape as the original objects.
5.7 Query
Query can be performed directly to the database. The result of the query is the
information that is returned by the database, depending on the user’s question. By using
structured query language (SQL), users can execute the questions on SQL*Plus platform
from Oracle. The statement below shows an example of query on table SALT from the
previous section.
156
SQL> SELECT ID, DESCRIPTION
FROM SALT
WHERE ID = 1 or ID = 2;
The following syntax is the retrieved information from the database.
ID
DESCRIPTION
----------------1
Cylinder
2
Hemisphere
2 rows selected.
Another example of simple query through the SALT table is:
SQL> SELECT ID, DESCRIPTION, VOLUME, AREA
FROM SALT
WHERE DESCRIPTION = ‘cylinder’;
The return result is:
ID
DESCRIPTION
VOLUME
AREA
--------------------------------------1
cylinder
169668
16966.8
3
cylinder
14139
3299.1
5
cylinder
1256.8
728.944
4
cylinder
5105.75
2199.4
6
cylinder
142.568
241.934
5 rows selected.
Simple queries on the database can also be performed from Bentley Map. With the
provided query function i.e. Visual Query Builder or Search in interoperability
function, users can carry out queries and view the related results. Through this
function, the database interprets the query and selects the related rows and columns.
From that, the geometry of selected rows and columns are mapped directly in the
viewer. The figure below shows an example of a query towards a Pipeline’s table and
the result is shown in Figure 5.31.
157
SQL> SELECT ID, DESCRIPTION, VOLUME, HEIGHT
FROM PIPELINE
WHERE DESCRIPTION = ‘cylinder’;
Figure 5.31: Retrieved records from DBMS through SQL function.
5.8
Surface Smoothness
In computer graphics, surface smoothness is one of the factors to be achieved
in modeling objects. Various studies have been done in achieving a fine surface in
computer graphics, for example by Rase (2000), Liao et. al (2003), Fontana et. al
(2003) and Buelow (2004). By applying related algorithms, equations and functions
these researchers provided approaches, ideas and suggestions to achieve a smooth
surface.
In this research, no algorithms, equations and functions were applied to the
objects’ surface. The implemented 3D primitive objects were basically developed
158
using several polygon faces. As a result, the object’s surface is quite rough and
bumpy. The only way to make it smoother is by generating more points on the
objects surface.
Another factor needs to be taken into consideration in order to achieve
surface smoothness in time validity and storage size. From the generated points,
polygon faces were generated by connecting points with lines. According to Alliez
et. al (2010), the generation of more points decreases the size of polygon faces and
increases the number of polygon faces. This can be described as follows:
Number of Points α
1
Polygon Size
Number of Points α Storage size
Implemented 3D primitive objects were then experimented by increasing the number
of points on the objects’ surface. Figure 5.32 shows a torus with two different levels
of surface smoothness.
Figure 5.32: Different Levels of Surface Smoothness on Torus.
159
In Figure 5.32, the different levels of surface smoothness on the torus’s surface can
be evidently seen. The left figure shows the low quality of surface smoothness as
compared to the figure on the right. This is due to the generated number of points
while constructing the objects. The torus on the left figure was generated by 200
points while the torus on the right figure was generated by 96000 points. Thus,
surface smoothness can be achieved by increasing the number of points on the
objects’ surface.
5.9
Conclusion
In this chapter, the implemented 3D primitive objects were tested and
experimented. From the experimental results, it is shown that 3D primitive objects
were successfully implemented in the DBMS level. The combination of objects were
also tested and modeled in DBMS. The objects were then tested with simulation
datasets to model several objects such as buildings and pipeline. Real datasets were
also utilized in this chapter in order to further experiment with 3D primitive objects.
After that, the surface smoothness of the objects was discussed in the last section.
CHAPTER 6
COCLUSIO AD RECOMMEDATIO
6.1
Conclusion
This research attempts to implement 3D primitive objects in DBMS level.
Four basic 3D primitive objects, which were Cone, Cylinder, Torus and Sphere, were
constructed in DBMS. Based on the mathematical equation, every object was
designed in the conceptual model using stored procedure. The stated objective in
Chapter 1 is answered by the following paragraph:
Based on the first objective, four basic primitive objects were successfully
created and stored in DBMS. The objects are Cone, Cylinder, Sphere and Torus. The
objects were constructed using mathematical equations as described in Section 2.1 of
Chapter 2. By using the mathematical equation, the objects were then designed and
modeled based on the Boundary Representation technique. This technique was
briefly explained in Chapter 2 and the designed model based on that technique was
illustrated in Chapter 3. Boundary Representation technique was chosen due to its
simplicity and flexibility in modeling complex objects. Based on the test case in
Chapter 5, the constructed object based on this technique produced the desired result.
161
The conceptual model of those objects was developed using Stored Procedure
module in Oracle Spatial DBMS. PL/SQL was used as a language to construct
objects and map the procedure in Oracle Spatial. This method can be found in
Chapters 3 and 4. By using Stored Procedure, each primitive object was developed
with its own procedure and uniquely named such as
createcylinder
procedure,
createsphere
procedure and
createcone
procedure,
createtorus
procedure.
Parameters were needed to execute the created procedure, with every primitive
object having its own parameters such as radius, centre point, height and many more.
Using a
call
statement in each procedure produced one of the 3D primitive objects.
In Chapters 3 and 4, a brief explanation and method can be found regarding how to
use call statement.
The only way to prove that 3D primitive objects were successfully created
and stored in DBMS is by examining the row in the database. The database for each
object was designed by using a standard table as shown in Chapter 4. Users are
required to use the standard table prior to creating and storing 3D primitive objects.
Based on the created standard table, the second objective in this research has been
fulfilled. However, several steps need to be made aware of when creating a database
of 3D primitive objects such as updating
USER_SDO_GEOM_METADATA
and indexing the
table. All these issues were discussed in Chapter 4 under several sections such as
section 4.2.1 Indexing of Spatial Data and 4.2.2 Creating Spatial Index and Spatial
Index Parameter.
The proposed 3D primitive objects in Chapter 1 i.e. Cone, Cylinder, Sphere
and Torus were successfully created and stored in the database. To verify the stored
objects, a front-end application i.e. Bentley map was used to query and render the
objects. The objects that were tested and visualized are as illustrated in Chapter 5. In
addition, utilizing the interoperability function that was provided by both Bentley
and Oracle software allowed for the retrieval of the 3D primitive objects by
accessing the geometry column. Other information and attribute could also be
accessed by using this function. The results in Chapter 5 proved that both objectives
1 and 2 had been successfully implemented.
162
In this research, four primitive volumetric objects were proposed to be
implemented in DBMS level. The objects were then extended to create various object
shapes based on the original one. The extended shapes of objects were half of the
cone, half of the cylinder, half of the sphere or hemisphere, half of the torus and
quarter of the torus. With these extended shapes, users can have a variety of choice.
The implementation of these extended objects is similar to the implementation of
four proposed objects as explained in Chapter 3 and Chapter 4. These extended
objects were also tested and the result is shown in Chapter 5. The rotation element
was also embedded in the objects procedure, as every procedure must be executed
with rotation element along with parameters. In Chapter 4 a brief explanation and
example of Matrix Rotation was discussed and reviewed. The rotation element
rotates the object towards the axis x,y and z and users are required to understand the
direction of rotation before executing the created procedure. Every object i.e. cone,
cylinder, sphere and torus were successfully experimented with the rotation element,
with the results shown in Chapter 5.
The 3D primitive objects were also tested to be combined with one or more
objects, given that the combination of objects could produce other shapes or objects.
Several simulation datasets were built, and the results shown in Chapter 5. From the
results, it was proven that the implementation of 3D primitive objects is not limited
to producing single basic objects but could be extended to produce more complex
objects.
Furthermore, it is important to test the objects or created procedure with the
real datasets. From the real datasets, only required parameters were extracted. This
research utilized real datasets in CAD format, with the advantage that is quite easy
and simple to extract parameters from the CAD format and transform it to the
procedure order. The experiments using real datasets required the utilization of all
the provided function and object’s capability such as objects rotation and
combination. The test cases of this experiment were buildings from Suleymaniye
area, Istanbul, Turkey. The test results are as shown in Chapter 5.
163
As mentioned in Chapter 2, the major disadvantage in using the provided
method in DBMS to construct 3D objects is that the DBMS cannot recognize the
object as a 3D object. Thus, no volume computation could be done on the objects.
This research attempted to address this issue by suggesting and implementing a
simple solution of calculating the objects volume and area from the object’s
parameter. Hence users can simply retrieve the volume and area information through
a simple query towards the DBMS.
In the process of implementing 3D primitive objects, several problems and
difficulties were found due to several weaknesses that need to be investigated in any
future studies. A problem of 3D primitive objects is its surfaces, whereby they may
look quite rough and bumpy. This problem was discussed in the last section of
Chapter 5. To obtain a smooth surface, it was suggested that more points should be
generated. To achieve this objective, however, users cannot simply add the number
of points unless the procedure’s program has been modified. In Oracle, the number
of points to be stored in geometry column has been limited to 999 points. But
compared with the multipolygon method or face by face method in Oracle DBMS,
the created procedure allows users to conduct more than 999 points.
Users may face a problem when the table is restricted to a standard table. The
standard table can be reviewed in Chapter 4. This is because different users may have
different information to be stored in the table, and thus require more columns to store
the information. The only solution to this problem is to add the required column
manually using
alter
table
command. Through this method, users can use a
standard table and simply add on any required columns.
Using a Bentley as front-end application may give an advantage through its
interoperability function. However, the concern here is the compatibility of the
version to be used with the Oracle DBMS. Problems may arise if the version of
Oracle DBMS and Bentley are not compatible with each other, and as a result users
164
may experience several errors. For an example, a different version of Bentley
supports a different type of index parameter. Index parameter has been explained in
Chapter 4. In this research the utilized type of index parameter is
parameter. The
LAYER_GTYPE
LAYER_GTYPE
parameter was chosen due to its compatibility with
Bentley Map and Oracle 11g. Nevertheless users may experience error if
SDO_INDX_DIMS
parameter is utilized with this version of Bentley Map and Oracle.
According to Bentley (2010), only the latest version of Bentley products i.e. Bentley
Power Map V8i together with Oracle 11g Release 2 database has resolved this
problem. Thus it is necessary to check the compatible version and suitable index
parameter in this research.
From the above discussion, 3D primitive objects have been successfully
implemented in DBMS level. The implementation and the development of the
database were also successful. As a conclusion, both of the objectives in this research
have been achieved.
6.2
Recommendation
Several recommendations for further research could be made:
•
It would be interesting to have more 3D volumetric objects in DBMS.
The currently supported 3D geometry types in Oracle are still limited, and
this research only focuses on four 3D primitive objects. Other 3D
primitive objects such as tube, pyramid and extended 3D primitive such
as Filleted Cube, Spindle, Bevelled Cylinder, Torus Knot and many more
could be implemented.
•
In this research, boundary representation technique was utilized as a
technique to model 3D primitive objects. It would be interesting if 3D
165
primitive objects are utilized using other techniques such as CSG and
Decomposition Model.
•
Boolean operation is applied in CSG modeling technique. One of the
advantages of B-Rep method is that it can imitate CSG modeling. Thus
the idea of applying Boolean operation with B-rep method can be of
interest. Suggested Boolean operators are union A+B, intersection A ∩ B,
differences A-B and B-A and symmetric difference, (A-B)+(B-A).
•
To achieve the surface smoothness for the 3D volumetric objects, suitable
algorithms, equations and functions from computer graphics could be
applied while structuring the 3D primitive objects procedure. Several
researches from computer graphics on surface smoothness might be
useful in addressing this issue such as Rase (2000), Tasdizen (2002), Liao
et. al (2003), Fontana et. al (2003) and Buelow (2004).
•
No topological element embedded within the objects. Thus it’s hard to
execute an analysis on the objects. Further research on developing a
topological element for those objects are recommended for further 3D
analysis.
•
This research was tested with Oracle Spatial DBMS. It would be
interesting to implement 3D primitive objects in other spatial DBMSs
than Oracle Spatial. From the research, a comparison on database
capability and ability can be performed.
166
REFERECES
Abdul Rahman, A., 2006, GIS – 3D and Beyond, Retrieved on Jan 7, 2010,
from http://www.gisdevelopment.net/
Abdul-Rahman A., Pilouk M., 2007, Spatial Data Modeling For 3D GIS
Springer-Verlag Berlin and Heidelberg Gmbh & Co. Kg (Germany)
Aguilera, A.,Ayala, D. 1997 :Orthogonal Polyhedra As Geometric Bounds in
Constructive Solid Geometry. In : Hoffman, C, Bronsvort, W(eds)Fourth
ACMSiggraph Symposium on Solid Modelling and Applications, vol 4,
pp. 56 -57. ACM Press, New York
Aguilera, A. 1998, Orthogonal Polyhedra : Study and Application. Ph.D
Thesis, LSI-Universitat Politecnica de Cataluya.
Arens C., 2003, Maintaining Reality, Modeling 3D Spatial Objects in a
GeoDBMS using a 3D primitives, MSc Thesis TUDelft
Arens C., Stoter J.E, and Oosterom Van P.J.M, 2005, Modeling 3D Spatial
Objectsin GeoDBMS using 3D Primitive, In: Computers & Geosciences,
Volume 31, 2, page 165-177.
Bethel J., 2003, Lecture notes on Introduction to Rotation Matrices, CE 503
Photogrammetry I Fall '03, Purdue University - School of Civil
Engineering.
167
Kazar, B. M., R. Kothuri, Peter V. Oosterom, Siva Ravada, (2008). On Valid
and
Invalid
Three-Dimensional
Geometries.
Advances
in
3D
Geoinformation Systems: 19-46.
Bentley, 2007, Bentely Map User Guide and Reference.
Berry, Joseph K., 2007, Beyond Mapping III Topic 27 : GIS Evolutions and
Future Trends.
Bourke Paul,1992,Spheres,equationandterminology.http://local.wasp.uwa.edu.
au/~ pbourke/geometry/sphere/
Buelow Thomas, 2004, Spherical Diffusion for 3D Surface Smoothing. IEEE
Transactions On Pattern Analysis And Machine Intelligence, Vol. 26, No.
12, December 2004
Chandra N. Subash, Govardhan A, 2008, Design and Implementation of
Polyhedron as a primitive to represent 3D Spatial Objeccts. Jounal of
Theoretical And Applied Information Technology 2008.
Chen T. K. , A Abdul Rahman, S. Zlatanova, 2008, 3D solids and Their
Management In DBMS, Chapter 16, Advances in 3D Geoinformation
Systems, Springer Berlin Heidelberg.
Clint Conrad, 2011, Lecture 2: Spherical Geometry Week 1 (Jan 10-14):
Planetary Orbits and Physics Review. http://www.soet.hawaii.edu/GG
/FACULTY/conrad/=classes/GG304/handouts/Lecture_02.pdf
CityGML 2007, What is CityGML? . http://www.citygml.org Retrieved 200902-24.
ESRI,2003,ArcGIS3DAnalyst.http://www.esri.com/software/arcgis/extension
s/3danalyst/index.html. Retrieved 2009-02-24.
168
Fontana R., M.C. Gambino, M.Greco, L. Marras, M. Materazzi, E.
Pampaloni, L. Pezzati, 2003, A high-precision surface analysis of the
roughness of Michelangelo’s David. Proceedings of SPIE Vol. 5146,
2003.
Giambruno Mark, 2002, 3D Graphics & Animation, 2nd Edition. Publish by
New Riders.
Giambruno Mark, 2003, 3D Modeling Basic.Retrieve on May 9, 2009 at
http://www.peachpit.com/articles/article
Guting, Ralf Hartmut, 1994, an Introduction to Spatial Database System.
Hilbert, David, 1952, Geometry and the imagination Publish by New York:
Chelsea
Hoffmann Christoph M., Jaroslaw R.Rossignac. 1996, A Road To Solid
Modeling. IEEE Transactions on Visualization and Computer Graphics
Volume 2. No 1 March 1996.
Holly K. Ault, 1999, 3D Geometric Modeling for the 21st Century. Worcester
Polytechnic Institute. Engineering Design Graphics Journal Volume 63
Number 2
Mark L. Irons, 2005, The Curvature and Geodesics of the Torus
http://www.rdrop.com/~half/math/torus/index.xhtml
Kothuri R., E. Beinat, and A. Godfrind, 2004. Pro Oracle Spatial 9i. Publish
by Apress.
Kothuri R., E. Beinat, and A. Godfrind, 2007, Pro Oracle Spatial 11g Publish
by Apress.
LaCourse, Donald E., 1995, Handbook of Solid Modeling. Publisher New
York : McGraw-Hill
169
Liao Y.S. , J.T. Huang, Y.H. Chen, 2003, A study to achieve a fine surface
finish in Wire-EDM.
Mensah, Kuasi, 2006, Oracle Database Programming Using Java and Web
Services. Publish by: Elsevier Digital Press 2006.
Lawrence C. Moore and David A. Smith 2003, Parametric Representations of
Surfaces . https://www.math.duke.edu/education/ccp/materials/mvcalc/
parasurfs/para1.html
Morse, Rick 1998, Polygon Normal in DataCAD, Technical Bulletin
DataCAD LLC.
Mortenson, M., 1997, Geometric Modeling 2nd edition. Publish by New
York, NY: John Wiley & Sons.
Oosterom Van P.J.M, Mark J. Van Kreveld, 2006, Geo-Information and
Computational Geometry Seminar of Netherland Geodetic Commission
Oracle, 2003, Oracle PL/SQL User’s Guide and Reference 11G release 1
Oracle 2007, Oracle 11g User Guide and Reference
OGC 1999, OpenGIS Simple Features Specification for SQL. Revision 1.1,
OpenGISProject Document 99-049
Penninga F, 2005 3D topographic data modelling: why rigidity is preferable
to pragmatism. In: Spatial Information Theory, Cosit’05, Vol. 3693 of
Lecture Notes on Computer Science, Springer. pp 409-425
Patrikalakis, Nicholas M., 2003, Computational Geometry Lecture 1.Massachusetts
Institute of Technology Cambridge, MA 02139-4307, USA
170
Pu. Shi, 2005, Managing Freeform Curves and Surfaces in Saptial DBMS,
MSc Thesis TU Delft
Rase, Wolf-Dieter, 2000, Volume Preserving Interpolation of Smooth Surface
from Polygon-related Data. Journal of Geographical System, 2001.
Reese, George 2000, Database Programming with JDBC Second Edition.
SAOO, 2010, Retrieved on November 22, 2009 at http://www.saao.ac.za/.
Scott, Urman, R. H., M. McLaughlin 2004,. Oracle Database 10g PL/SQL
Programming. Publish by: McGraw-Hill/Osborne.
Silberschatz, A., H.Korth, S.Sudarshan, 2002, Database System Concepts 4th
Edition
Stoter, J. and P. Van Oosterom, 2002, Incorporating 3D GeoObjects into a 2D
GeoDBMS, Proceeding of ISPRS/ACSM, 19-26 April, 2002, Washington,
USA.
Stoter, Jantien. and S. Zlatanova, 2003, 3D GIS, Where Are We Standing?
Joint Workshop on Spatial, Temporal and Multi-Dimensional Data
Modelling and Analysis, 2-3 October, Quebec city, Canada, 6p
Stoter J., and Zlatanova S., 2003, Visualization and Editing of 3D Objects
organized in a DBMS, Proceedings of EuroSDR Com V. Workshop on
Visualization and Rendering.
Stoter, J.E., and P.J.M. van Oosterom, 2005, Technological aspects of a full
3D cadastral registration In: International Journal of Geographical
Information Science, Volume 19, 6, pp. 669-696
Tsuzuki. Marcos de Sales G, Fabio K. Takase, Murilo Antônio S. Garcia,
Thiago de Castro Martins, 2007, Converting CSG models into Meshed B-
171
Rep Models Using Euler Operators and Propagation Based Marching
Cubes In: Journal of the Brazil Soc. of Mechanical Science &
Engineering Vol. XXIX, No. 4
Weisstein, Eric W.,2005, Spherical Coordinates MathWorld. Retrieve on Sep
27, 2009 at http://mathworld.wolfram.com/SphericalCoordinates.html.
Weisstein, Eric W.,2005,Cylinder. From MathWorld – A wolfram Web
Resource. Retrieve on Sep 27, 2009 at http://mathworld.wolfram.com/
SphericalCoordinates.html.
Weisstein, Eric W.,2005,Cone. From MathWorld – A wolfram Web
Resource. Retrieve on Sep 27, 2009 at http://mathworld.wolfram.com/
SphericalCoordinates.html.
Weisstein, Eric W.,2005,Torus. From MathWorld – A wolfram Web
Resource. Retrieve on Sep 27, 2009 at http://mathworld.wolfram.com/
SphericalCoordinates.html.
Wikipedia 2010, Cylinder geometry.http://en.wikipedia.org/wiki/Cylin
der_%28geometry%29
Xu. Xun, 2009, Geometric Modelling and Computer-Aided Design In:
Integrating Advanced Computer-Aided Design, Manufacturing, and
Numerical Control: Principles and Implementations, pp. 1-31
Yordan
Petrov,
2005,
Formulas
from
Solid
Analytic
Geometry
http://www.math10.com/en/geometry/analytic-geometry/geometry4/solidanalytic-geometry.html
Zlatanova, S., A.Abdul-Rahman and M.Pilouk, 2002, Trends in 3D GIS
development, in: Journal of Geospatial Engineering, Vol.4, No.2, pp. 1-10
172
Zlatanova S., A Abdul-Rahman, M.pilouk, 2002, 3D GIS : Current Status and
Perspectives, Proceedings of ISPRS/8-12 July/Ottawa Canada
Zlatanova S., 2004, Large Scale 3D data integration – An Introduction to the
Challenges for CAD and GIS integration, Directions Magazine
Zlatanova S., S. Pu, W.S Broonvoort, 2006, Freeform Curves and Surfaces in
DBMS : Step forward in Spatial Integration
Zlatanova S., 2007, 3D Geometries in Spatial DBMS, Lecture Notes in
Geoinformation and Cartography. In: Innovations in 3D Geo Information
Systems pp. 1-14
Zlatanova S., J. Stoter, 2007, The role of DBMS in the new generation GIS
Architecture. GDMC Publication.
APPEDIX A
Procedure of creating object
174
APPEDIX A
**Procedure of creating cone**
CREATE OR REPLACE PROCEDURE CREATECONE (TabName VARCHAR2, ObjID
NUMBER, RxK NUMBER, RyK NUMBER, RzK NUMBER) IS
TabName VARCHAR2 (10);
ObjID NUMBER (2);
Rx NUMBER (15,4);
Ry NUMBER (15,4);
Rz NUMBER (15,4);
nCenterXbaru number (15,3);
nCenterYbaru number (15,3);
nCenterZbaru number (15,3);
nNewX number (15,3);
nNewY number (15,3);
nNewZ number (15,3);
nCenterXtemp number (15,3);
nCenterYtemp number (15,3);
nCenterZtemp number (15,3);
nHeight number (15,3);
i number (3);
z number (3);
ID number (6);
TYPE newX IS VARRAY(300) OF number (15,3);
TYPE newY IS VARRAY(300) OF number (15,3);
TYPE newZ IS VARRAY(300) OF number (15,3);
newXagain newX := newX();
newYagain newY := newY();
newZagain newZ := newZ();
nSqrt1 number (15,3);
nSqrt2 number (15,3);
iCntrPrint number (3);
anoCone mdsys.sdo_ordinate_array
anoConeID number (15);
nSisi number (15,3);
nArea number (15,3);
nVolume number (15,3);
BEGIN
/*TabName := '';
ObjID := 1;
Rx := 45;
Ry := 0;
Rz := 0;*/
i := 0;
175
EXECUTE IMMEDIATE 'SELECT CENTREPOINT_X
WHERE ID =' || ObjID into nCenterX ;
EXECUTE IMMEDIATE 'SELECT CENTREPOINT_Y
WHERE ID =' || ObjID into nCenterY ;
EXECUTE IMMEDIATE 'SELECT CENTREPOINT_Z
WHERE ID =' || ObjID into nCenterZ ;
EXECUTE IMMEDIATE 'SELECT Height FROM '
ID =' || ObjID into nHeight ;
EXECUTE IMMEDIATE 'SELECT Radius FROM '
ID =' || ObjID into nRadius ;
FROM ' || TabName || '
FROM ' || TabName || '
FROM ' || TabName || '
|| TabName || ' WHERE
|| TabName || ' WHERE
nCenterXtemp := 0;
nCenterYtemp := 0;
nCenterZtemp := 0 + nHeight;
IF RxK <> 0 THEN
nCenterXbaru :=
nCenterXtemp;
nCenterYbaru := (nCenterYtemp * COS (Rx)) +
((nCenterZtemp) * SIN (Rx));
nCenterZbaru := ((nCenterZtemp * COS(Rx)) (nCenterYtemp * SIN(Rx)));
nCenterXtemp := nCenterXbaru;
nCenterYtemp := nCenterYbaru;
nCenterZtemp := nCenterZbaru;
END IF;
IF RyK <> 0 THEN
nCenterXbaru := ((nCenterXtemp * COS(Ry)) (nCenterZtemp * SIN(Ry)));
nCenterYbaru := nCenterYtemp;
nCenterZbaru := ((nCenterXtemp) * SIN(Ry)) +
(nCenterZtemp * COS(Ry));
nCenterXtemp := nCenterXbaru;
nCenterYtemp := nCenterYbaru;
nCenterZtemp := nCenterZbaru;
END IF;
IF RzK <> 0 THEN
nCenterXbaru := ((nCenterXtemp * COS(Rz)) + (nCenterYtemp *
SIN(Rz)));
nCenterYbaru := ((nCenterYtemp * COS(Rz)) (nCenterXtemp * SIN(Rz)));
nCenterZbaru := nCenterZtemp;
nCenterXtemp := nCenterXbaru;
nCenterYtemp := nCenterYbaru;
nCenterZtemp := nCenterZbaru;
END IF;
newXagain.extend;
newYagain.extend;
newZagain.extend;
newXagain (1) := nCenterXtemp + nCenterX;
newYagain (1) := nCenterYtemp + nCenterY;
newZagain (1) := nCenterZtemp + nCenterZ;
176
i := 0;
for z in 1..20 loop
nCenterXtemp := 0;
nCenterYtemp := 0;
nCenterZtemp := 0;
nAng := 2 * ASIN(-1) * i / 360;
--angle is 2 pi x i /
360.
nNewX := nRadius * SIN(nAng) + nCenterXtemp;
nNewY := nRadius * COS(nAng) + nCenterYtemp;
nNewZ := nCenterZtemp;
IF RxK <> 0 THEN
nCenterXbaru := nNewX;
nCenterYbaru := (nNewY * COS (Rx)) + ((nNewZ) *
SIN (Rx));
nCenterZbaru := ((nNewZ * COS(Rx)) - (nNewY *
SIN(Rx)));
nNewX := nCenterXbaru;
nNewY := nCenterYbaru;
nNewZ := nCenterZbaru;
END IF;
IF RyK <> 0 THEN
nCenterXbaru := ((nNewX * COS(Ry)) - (nNewZ * SIN(Ry)));
nCenterYbaru := nNewY;
nCenterZbaru := ((nNewX) * SIN(Ry)) + (nNewZ *
COS(Ry));
nNewX := nCenterXbaru;
nNewY := nCenterYbaru;
nNewZ := nCenterZbaru;
END IF;
IF RzK <> 0 THEN
nCenterXbaru := ((nNewX * COS(Rz)) + (nNewY *
SIN(Rz)));
nCenterYbaru := (nNewY * COS(Rz)) - (nNewX *
SIN(Rz));
nCenterZbaru := nNewZ;
nNewX := nCenterXbaru;
nNewY := nCenterYbaru;
nNewZ := nCenterZbaru;
END IF;
newXagain.extend;
newYagain.extend;
newZagain.extend;
newXagain (ID) := nNewX + nCenterX;
newYagain (ID) := nNewY + nCenterY;
newZagain (ID) := nNewZ + nCenterZ;
ID := ID + 1;
i := i + 36;
end loop;
anoCone := mdsys.sdo_ordinate_array ();
anoConeID := 0;
177
ID := 2;
iCntrPrint := 0;
for z in 1..19 loop
anoCone.EXTEND (12);
anoCone(anoConeID + 1) := newXagain(1);
coordinate
anoCone(anoConeID + 2) := newYagain(1);
anoCone(anoConeID + 3) := newZagain(1);
anoCone(anoConeID + 4) := newXagain(ID + 1);
coordinate
anoCone(anoConeID + 5) := newYagain(ID + 1);
anoCone(anoConeID + 6) := newZagain(ID + 1);
anoCone(anoConeID + 7) := newXagain(ID);
coordinate
anoCone(anoConeID + 8) := newYagain(ID);
anoCone(anoConeID + 9) := newZagain(ID);
anoCone(anoConeID + 10) := newXagain(1);
coordinate
anoCone(anoConeID + 11) := newYagain(1);
anoCone(anoConeID + 12) := newZagain(1);
anoConeID := anoConeID + 12;
ID := ID + 1;
iCntrPrint := iCntrPrint + 1;
IF iCntrPrint = 19 THEN
--ID := ID + 1;
anoCone.EXTEND (12);
anoCone(anoConeID + 1) := newXagain(1);
-- 1st
-- 2nd
-- 3rd
-- 4th
-- 1st
coordinate
anoCone(anoConeID + 2) := newYagain(1);
anoCone(anoConeID + 3) := newZagain(1);
anoCone(anoConeID + 4) := newXagain(ID);
-- 2nd
anoCone(anoConeID + 5) := newYagain(ID);
anoCone(anoConeID + 6) := newZagain(ID);
anoCone(anoConeID + 7) := newXagain(2);
-- 3rd
anoCone(anoConeID + 8) := newYagain(2);
anoCone(anoConeID + 9) := newZagain(2);
anoCone(anoConeID + 10) := newXagain(1);
-- 4th
coordinate
coordinate
coordinate
anoCone(anoConeID + 11) := newYagain(1);
anoCone(anoConeID + 12) := newZagain(1);
anoConeID := anoConeID + 12;
iCntrPrint := 0;
END IF;
end loop;
ID := 2;
for z in 1..20 loop
iCntrPrint := iCntrPrint + 1;
anoCone.EXTEND (3);
anoCone(anoConeID + 1) := newXagain(ID);
anoCone(anoConeID + 2) := newYagain(ID);
anoCone(anoConeID + 3) := newZagain(ID);
anoConeID := anoConeID + 3;
ID:= ID + 1;
IF iCntrPrint = 20 THEN
178
anoCone.EXTEND (3);
anoCone(anoConeID + 1) := newXagain(2);
anoCone(anoConeID + 2) := newYagain(2);
anoCone(anoConeID + 3) := newZagain(2);
anoConeID := anoConeID + 3;
iCntrPrint := 0;
END IF;
end loop;
END;
/
APPEDIX B
Table’s structure in database
180
APPEDIX B
************************ Table Pipeline*******************************
SQL> DESC PIPELINE;
Name
Null?
----------------------------------------- -------ID
NOT NULL
DESCRIPTION
RADIUS
RADIUS_SUB
CENTREPOINT_X
CENTREPOINT_Y
CENTREPOINT_Z
HEIGHT
MATERIAL
VOLUME
AREA
GEOMETRY
MDSYS.SDO_GEOMETRY
Type
---------------NUMBER(6)
VARCHAR2(250)
NUMBER(15,3)
NUMBER(15,3)
NUMBER(18,3)
NUMBER(18,3)
NUMBER(18,3)
NUMBER(15,3)
VARCHAR2(250)
NUMBER(15,3)
NUMBER(15,3)
************************ Table Tower_519*****************************
SQL> DESC Tower_519;
Name
Null?
----------------------------------------- -------ID
NOT NULL
DESCRIPTION
RADIUS
RADIUS_SUB
CENTREPOINT_X
CENTREPOINT_Y
CENTREPOINT_Z
HEIGHT
MATERIAL
VOLUME
AREA
GEOMETRY
MDSYS.SDO_GEOMETRY
Type
---------------NUMBER(6)
VARCHAR2(250)
NUMBER(15,3)
NUMBER(15,3)
NUMBER(18,3)
NUMBER(18,3)
NUMBER(18,3)
NUMBER(15,3)
VARCHAR2(250)
NUMBER(15,3)
NUMBER(15,3)
181
************************ Table Roof_576*****************************
SQL> DESC Roof_576;
Name
Null?
----------------------------------------- -------ID
NOT NULL
DESCRIPTION
RADIUS
RADIUS_SUB
CENTREPOINT_X
CENTREPOINT_Y
CENTREPOINT_Z
HEIGHT
MATERIAL
VOLUME
AREA
GEOMETRY
MDSYS.SDO_GEOMETRY
Type
---------------NUMBER(6)
VARCHAR2(250)
NUMBER(15,3)
NUMBER(15,3)
NUMBER(18,3)
NUMBER(18,3)
NUMBER(18,3)
NUMBER(15,3)
VARCHAR2(250)
NUMBER(15,3)
NUMBER(15,3)
************************ Table Tower*****************************
SQL> DESC Tower;
Name
Null?
----------------------------------------- -------ID
NOT NULL
DESCRIPTION
RADIUS
RADIUS_SUB
CENTREPOINT_X
CENTREPOINT_Y
CENTREPOINT_Z
HEIGHT
MATERIAL
VOLUME
AREA
GEOMETRY
MDSYS.SDO_GEOMETRY
Type
---------------NUMBER(6)
VARCHAR2(250)
NUMBER(15,3)
NUMBER(15,3)
NUMBER(18,3)
NUMBER(18,3)
NUMBER(18,3)
NUMBER(15,3)
VARCHAR2(250)
NUMBER(15,3)
NUMBER(15,3)
************************ Table SALT*****************************
SQL> DESC SALT;
Name
Null?
----------------------------------------- -------ID
NOT NULL
DESCRIPTION
RADIUS
RADIUS_SUB
CENTREPOINT_X
CENTREPOINT_Y
CENTREPOINT_Z
HEIGHT
MATERIAL
VOLUME
AREA
GEOMETRY
MDSYS.SDO_GEOMETRY
Type
---------------NUMBER(6)
VARCHAR2(250)
NUMBER(15,3)
NUMBER(15,3)
NUMBER(18,3)
NUMBER(18,3)
NUMBER(18,3)
NUMBER(15,3)
VARCHAR2(250)
NUMBER(15,3)
NUMBER(15,3)
APPEDIX C
Example of query results
183
APPEDIX C
****************************** Query 1 *****************************
SQL> SELECT GEOMETRY
2
FROM SPHERE
3
WHERE ID = 4;
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
---------------------------------------------------------------------------SDO_GEOMETRY(3007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 13, 1003, 1,
25,1003, 1, 37, 1003, 1, 49, 1003, 1, 61, 1003, 1, 73, 1003, 1, 85, 1003, 1,
97, 1003, 1, 109, 1003, 1, 121, 1003, 1, 133, 1003, 1, 145, 1003, 1, 157,
1003, 1, 169, 1003, 1, 181, 1003, 1, 193, 1003, 1, 205, 1003, 1, 217, 1003, 1,
229, 1003, 1,241, 1003, 1, 256, 1003, 1, 271, 1003, 1, 286, 1003, 1, 301,
1003, 1, 316, 1003, 1, 331, 1003, 1, 346, 1003, 1, 361, 1003, 1, 376, 1003, 1,
391, 1003, 1, 406,1003, 1, 421, 1003, 1, 436, 1003, 1, 451, 1003, 1, 466,
1003, 1, 481, 1003, 1, 496, 1003, 1, 511, 1003, 1, 526, 1003, 1, 541, 1003, 1,
, 1426, 1003, 1, 1441, 1003, 1, 1456, 1003, 1, 1471, 1003, 1, 1,2809, 1003, 1,
2821, 1003, 1, 2833, 1003, 1, 2845, 1003, 1, 2857, 1003, 1, 2869,1003, 1),
SDO_ORDINATE_ARRAY(40, 40, 55, 37.22, 48.56, 52, 40, 49, 52, 40, 40,5, 40, 40,
55, 34.712, 47.283, 52, 37.22, 48.56, 52, 40, 40, 55, 40, 40, 55, 32.721,
45.294, 52, 34.712, 47.283, 52, 40, 40, 55, 40, 40, 55, 31.439, 42.778, 52,
32.721, 45.294, 52, 40, 40, 55, 40, 40, 55, 31, 39.998, 52, 31.439, 42.778,
52, 40, 40, 55, 40, 40, 55, 31.441, 37.218, 52, 31, 39.998, 52, 40, 40, 55,
40, 40, 55, 32.718, 34.711, 52, 31.441, 37.218, 52, 40, 40, 55, 40, 40, 55,
34.708, 32.72, 52, 32.718, 34.711, 52, 40, 40, 55, 40, 40, 55, 37.215, 31.442,
52, 34.708,32.72, 52, 40, 40, 55, 40, 40, 55, 40.004, 31, 52, 37.215, 31.442,
52, 40, 40,55, 40, 40, 55, 42.783, 31.441, 52, 40.004, 31, 52, 40, 40, 55, 40,
40, 55, 45.291, 32.719, 52, 42.783, 31.441, 52, 40, 40, 55, 40, 40, 55,
47.281, 34.709, 52,45.291, 32.719, 52, 40, 40, 55, 40, 40, 55, 48.559, 37.217,
52, 47.281, 34.709,52, 40, 40, 55, 40, 40, 55, 49, 39.996, 52, 48.559, 37.217,
52, 40, 40, 55, 40,40, 55, 48.558, 42.785, 52, 49, 39.996, 52, 40, 40, 55, 40,
40, 55, 47.28, 45.292, 52, 48.558, 42.785, 52, 40, 40, 55, 40, 40, 55, 45.289,
47.282, 52, 47.28, 45.292, 52, 40, 40, 55, 40, 40, 55, 42.781, 48.559, 52,
45.289, 47.282, 52, 40, 40, 55, 40, 40, 55, 42.781, 48.559, 52, 40, 49, 52,
52, 34.708,32.72, 52, 40, 40, 55, 40, 40, 55, 40.004, 31, 52, 37.215, 31.442,
52, 40, 40,55, 40, 40, 55, 42.783, 31.441, 52, 40.004, 31, 52, 40, 40, 55, 40,
40, 55, 45.291, 32.719, 52, 42.783, 31.441, 52, 40, 40, 55, 40, 40, 55,
47.281, 34.709, 52,45.291, 32.719, 52, 40, 40, 55, 40, 40, 55, 48.559, 37.217,
52, 47.281, 34.709,52, 40, 40, 55, 40, 40, 55, 49, 39.996, 52, 48.559, 37.217,
52, 40, 40, 55, 40,40, 55, 48.558, 42.785, 52, 49, 39.996, 52, 40, 40, 55, 40,
40, 55, 47.28, 45.292, 52, 48.558, 42.785, 52, 40, 40, 55, 40, 40, 55, 45.289,
47.282, 52, 47.28, 45.292, 52, 40, 40, 55, 40, 40, 55, 42.781, 48.559, 52,
45.289, 47.282, 52, 40, 40, 55, 40, 40, 55, 42.781, 48.559, 52, 40, 49, 52, 11.554, 77.549, 164.538, 30, 77.549, 139.552, 30, 59.393, 164.538, 30, 77.549,
157.96,
-11.554,
77.549,
187.381,
-21.109,
77.546,
195.472,
30,
77.546,
184
164.538, 30, 77.549, 195.472, 30, 77.546, 187.381, -21.109, 77.546, 211.143, 28.825, 59.384, 220.455, 30, 59.384, 195.472, 30, 77.546, 220.455, 30, 59.384,
211.143, -28.825, 59.384, 220.221, -31.773, 30, 230, 30, 30, 220.455, 30,
59.384, 220.221, -31.773, 30, 191.841, -87.506, 30, 184.121, -81.9, .624,
211.148, -28.827, .624, 220.221, -31.773, 30, 211.148, -28.827, -34.368, .6,
110.92, -28.753, 30.02, 125.111, -.887, 30.02, 134.2, -3.838, .6, 125.111, .887, 30.02, 110.92, -28.753, 30.02, 118.65, -34.365,59.393, 134.196, -3.837,
59.393, 125.111, -.887, 30.02, 134.196, -3.837, 77.549, 187.381, -21.109,
77.546, 163.901, -67.219, 77.546, 184.117, -81.898, 59.384, 211.143, -28.825,
59.384, 187.381, -21.109, 77.546, 211.143, -28.825, 59.384, 184.117, -81.898,
59.384, 191.841, -87.506, 30, 220.221, -31.773, 30, 211.143, -28.825, 59.384,
191.841,
-87.506,
30,
147.634,
-131.747,
30,
142.023,
-124.032,
.624,
184.121,-81.9, .624, 191.841, -87.506, 30, 184.121, -81.9, .624, 142.023, 124.032, .6250.874, 30.02, 94.435, -58.599, 59.393, 118.65, -34.365, 59.393,
138.869, -49.045, 77.549, 109.131, -78.806, 77.549, 127.326, -103.823, 77.546,
163.901, -67.219, 77.546,138.869, -49.045, 77.549, 163.901, -67.219, 77.546,
127.326, -103.823, 77.546))
1 row selected.
****************************** Query 2*****************************
SQL> SELECT ID, DESCRIPTION, VOLUME, AREA, GEOMETRY
2 FROM PIPELINE
3 WHERE ID = 5;
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------5
cylinder
.491
4.32
SDO_GEOMETRY(3007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 64,
1003, 1, 79,
1003, 1, 94, 1003, 1, 109, 1003, 1, 124, 1003, 1, 139, 1003, 1, 154,
1003, 1, 16
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ----------
185
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------9, 1003, 1, 184, 1003, 1, 199, 1003, 1, 214, 1003, 1, 229, 1003, 1,
244, 1003, 1
, 259, 1003, 1, 274, 1003, 1, 289, 1003, 1, 304, 1003, 1, 319, 1003,
1, 334, 100
3, 1, 349, 1003, 1, 364, 1003, 1), SDO_ORDINATE_ARRAY(4.88822313,
8.92651458, -.
251, 4.81122313, 8.92651458, -.239, 4.74122313, 8.92651458, -.203,
4.68622313, 8
.92651458, -.148, 4.65022313, 8.92651458, -.078, 4.63822313,
8.92651458, -.001,
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------4.65022313, 8.92651458, .076, 4.68622313, 8.92651458, .146,
4.74122313, 8.926514
58, .201, 4.81122313, 8.92651458, .237, 4.88822313, 8.92651458,
.249, 4.96522313
, 8.92651458, .237, 5.03522313, 8.92651458, .201, 5.09022313,
8.92651458, .146,
5.12622313, 8.92651458, .076, 5.13822313, 8.92651458, -.001,
5.12622313, 8.92651
458, -.078, 5.09022313, 8.92651458, -.148, 5.03522313, 8.92651458, .203, 4.9652
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------2313, 8.92651458, -.239, 4.88822313, 8.92651458, -.251, 4.81122313,
8.92651458,
-.239, 4.74122313, 8.92651458, -.203, 4.74122313, 6.42651458, -.202,
4.81122313,
6.42651458, -.238, 4.81122313, 8.92651458, -.239, 4.68622313,
8.92651458, -.148
, 4.65022313, 8.92651458, -.078, 4.65022313, 6.42651458, -.077,
4.68622313, 6.42
651458, -.147, 4.68622313, 8.92651458, -.148, 4.63822313,
8.92651458, -.001, 4.6
ID
----------
186
DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------5022313, 8.92651458, .076, 4.65022313, 6.42651458, .077, 4.63822313,
6.42651458,
0, 4.63822313, 8.92651458, -.001, 4.68622313, 8.92651458, .146,
4.74122313, 8.9
2651458, .201, 4.74122313, 6.42651458, .202, 4.68622313, 6.42651458,
.147, 4.686
22313, 8.92651458, .146, 4.81122313, 8.92651458, .237, 4.88822313,
8.92651458, .
249, 4.88822313, 6.42651458, .25, 4.81122313, 6.42651458, .238,
4.81122313, 8.92
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------651458, .237, 4.96522313, 8.92651458, .237, 5.03522313, 8.92651458,
.201, 5.0352
2313, 6.42651458, .202, 4.96522313, 6.42651458, .238, 4.96522313,
8.92651458, .2
37, 5.09022313, 8.92651458, .146, 5.12622313, 8.92651458, .076,
5.12622313, 6.42
651458, .077, 5.09022313, 6.42651458, .147, 5.09022313, 8.92651458,
.146, 5.1382
2313, 8.92651458, -.001, 5.12622313, 8.92651458, -.078, 5.12622313,
6.42651458,
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
-------------------------------------------------------------------------------.077, 5.13822313, 6.42651458, 0, 5.13822313, 8.92651458, -.001,
5.09022313, 8.9
2651458, -.148, 5.03522313, 8.92651458, -.203, 5.03522313,
6.42651458, -.202, 5.
09022313, 6.42651458, -.147, 5.09022313, 8.92651458, -.148,
4.96522313, 8.926514
58, -.239, 4.88822313, 8.92651458, -.251, 4.88822313, 6.42651458, .25, 4.965223
187
13, 6.42651458, -.238, 4.96522313, 8.92651458, -.239, 4.88822313,
8.92651458, -.
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------251, 4.81122313, 8.92651458, -.239, 4.81122313, 6.42651458, -.238,
4.88822313, 6
.42651458, -.25, 4.88822313, 8.92651458, -.251, 4.74122313,
8.92651458, -.203, 4
.68622313, 8.92651458, -.148, 4.68622313, 6.42651458, -.147,
4.74122313, 6.42651
458, -.202, 4.74122313, 8.92651458, -.203, 4.65022313, 8.92651458, .078, 4.6382
2313, 8.92651458, -.001, 4.63822313, 6.42651458, 0, 4.65022313,
6.42651458, -.07
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------7, 4.65022313, 8.92651458, -.078, 4.65022313, 8.92651458, .076,
4.68622313, 8.92
651458, .146, 4.68622313, 6.42651458, .147, 4.65022313, 6.42651458,
.077, 4.6502
2313, 8.92651458, .076, 4.74122313, 8.92651458, .201, 4.81122313,
8.92651458, .2
37, 4.81122313, 6.42651458, .238, 4.74122313, 6.42651458, .202,
4.74122313, 8.92
651458, .201, 4.88822313, 8.92651458, .249, 4.96522313, 8.92651458,
.237, 4.9652
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------2313, 6.42651458, .238, 4.88822313, 6.42651458, .25, 4.88822313,
8.92651458, .24
188
9, 5.03522313, 8.92651458, .201, 5.09022313, 8.92651458, .146,
5.09022313, 6.426
51458, .147, 5.03522313, 6.42651458, .202, 5.03522313, 8.92651458,
.201, 5.12622
313, 8.92651458, .076, 5.13822313, 8.92651458, -.001, 5.13822313,
6.42651458, 0,
5.12622313, 6.42651458, .077, 5.12622313, 8.92651458, .076,
5.12622313, 8.92651
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------458, -.078, 5.09022313, 8.92651458, -.148, 5.09022313, 6.42651458, .147, 5.1262
2313, 6.42651458, -.077, 5.12622313, 8.92651458, -.078, 5.03522313,
8.92651458,
-.203, 4.96522313, 8.92651458, -.239, 4.96522313, 6.42651458, -.238,
5.03522313,
6.42651458, -.202, 5.03522313, 8.92651458, -.203, 4.88822313,
6.42651458, -.25,
4.81122313, 6.42651458, -.238, 4.74122313, 6.42651458, -.202,
4.68622313, 6.426
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ---------GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------51458, -.147, 4.65022313, 6.42651458, -.077, 4.63822313, 6.42651458,
0, 4.650223
13, 6.42651458, .077, 4.68622313, 6.42651458, .147, 4.74122313,
6.42651458, .202
, 4.81122313, 6.42651458, .238, 4.88822313, 6.42651458, .25,
4.96522313, 6.42651
458, .238, 5.03522313, 6.42651458, .202, 5.09022313, 6.42651458,
.147, 5.1262231
3, 6.42651458, .077, 5.13822313, 6.42651458, 0, 5.12622313,
6.42651458, -.077, 5
ID
---------DESCRIPTION
------------------------------------------------------------------------------VOLUME
AREA
---------- ----------
189
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO,
SDO_ORDINATES)
------------------------------------------------------------------------------.09022313, 6.42651458, -.147, 5.03522313, 6.42651458, -.202,
4.96522313, 6.42651
458, -.238, 4.88822313, 6.42651458, -.25))
Download