forked from sghr/iGeo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIGeometry.java
252 lines (189 loc) · 11.6 KB
/
IGeometry.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*---
iGeo - http://igeo.jp
Copyright (c) 2002-2013 Satoru Sugihara
This file is part of iGeo.
iGeo is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, version 3.
iGeo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with iGeo. If not, see <http://www.gnu.org/licenses/>.
---*/
package igeo;
import java.util.ArrayList;
import java.awt.Color;
import igeo.gui.*;
/**
Transformable objects.
@author Satoru Sugihara
*/
public abstract class IGeometry extends IObject implements ITransformable{
public IGeometry(){ super(); }
public IGeometry(IServerI holder){ super(holder); }
public IGeometry(IGeometry e){ super((IObject)e); }
public IGeometry(IServerI holder, IGeometry e){ super(holder,(IObject)e); }
public IGeometry dup(){ return null; } // need to be overridden
public IGeometry cp(){ return dup(); } // need to be overridden
/** returns center of geometry object */
abstract public IVecI center();
/****************************************************
* IObject API
***************************************************/
/** Set layer by ILayer object */
public IGeometry layer(ILayer l){ super.layer(l); return this; }
/** Set layer by layer name. If the layer specified by the name is not existing in the server, a new layer is automatically created in the server */
public IGeometry layer(String layerName){ super.layer(layerName); return this; }
public IGeometry attr(IAttribute at){ super.attr(at); return this; }
public IGeometry hide(){ super.hide(); return this; }
public IGeometry show(){ super.show(); return this; }
public IGeometry clr(IColor c){ super.clr(c); return this; }
public IGeometry clr(IColor c, int alpha){ super.clr(c,alpha); return this; }
public IGeometry clr(IColor c, float alpha){ super.clr(c,alpha); return this; }
public IGeometry clr(IColor c, double alpha){ super.clr(c,alpha); return this; }
public IGeometry clr(Color c){ super.clr(c); return this; }
public IGeometry clr(Color c, int alpha){ super.clr(c,alpha); return this; }
public IGeometry clr(Color c, float alpha){ super.clr(c,alpha); return this; }
public IGeometry clr(Color c, double alpha){ super.clr(c,alpha); return this; }
public IGeometry clr(int gray){ super.clr(gray); return this; }
public IGeometry clr(double dgray){ super.clr(dgray); return this; }
public IGeometry clr(float fgray){ super.clr(fgray); return this; }
public IGeometry clr(int gray, int alpha){ super.clr(gray,alpha); return this; }
public IGeometry clr(double dgray, double dalpha){ super.clr(dgray,dalpha); return this; }
public IGeometry clr(float fgray, float falpha){ super.clr(fgray,falpha); return this; }
public IGeometry clr(int r, int g, int b){ super.clr(r,g,b); return this; }
public IGeometry clr(double dr, double dg, double db){ super.clr(dr,dg,db); return this; }
public IGeometry clr(float fr, float fg, float fb){ super.clr(fr,fg,fb); return this; }
public IGeometry clr(int r, int g, int b, int a){ super.clr(r,g,b,a); return this; }
public IGeometry clr(double dr, double dg, double db, double da){ super.clr(dr,dg,db,da); return this; }
public IGeometry clr(float fr, float fg, float fb, float fa){ super.clr(fr,fg,fb,fa); return this; }
public IGeometry hsb(double dh, double ds, double db, double da){ super.hsb(dh,ds,db,da); return this; }
public IGeometry hsb(float h, float s, float b, float a){ super.hsb(h,s,b,a); return this; }
public IGeometry hsb(double dh, double ds, double db){ super.hsb(dh,ds,db); return this; }
public IGeometry hsb(float h, float s, float b){ super.hsb(h,s,b); return this; }
public IGeometry setColor(Color c){ return clr(c); }
public IGeometry setColor(Color c, int alpha){ return clr(c,alpha); }
public IGeometry setColor(int gray){ return clr(gray); }
public IGeometry setColor(float fgray){ return clr(fgray); }
public IGeometry setColor(double dgray){ return clr(dgray); }
public IGeometry setColor(int gray, int alpha){ return clr(gray,alpha); }
public IGeometry setColor(float fgray, float falpha){ return clr(fgray,falpha); }
public IGeometry setColor(double dgray, double dalpha){ return clr(dgray,dalpha); }
public IGeometry setColor(int r, int g, int b){ return clr(r,g,b); }
public IGeometry setColor(float fr, float fg, float fb){ return clr(fr,fg,fb); }
public IGeometry setColor(double dr, double dg, double db){ return clr(dr,dg,db); }
public IGeometry setColor(int r, int g, int b, int a){ return clr(r,g,b,a); }
public IGeometry setColor(float fr, float fg, float fb, float fa){ return clr(fr,fg,fb,fa); }
public IGeometry setColor(double dr, double dg, double db, double da){ return clr(dr,dg,db,da); }
public IGeometry setHSBColor(float h, float s, float b, float a){ return hsb(h,s,b,a); }
public IGeometry setHSBColor(double h, double s, double b, double a){ return hsb(h,s,b,a); }
public IGeometry setHSBColor(float h, float s, float b){ return hsb(h,s,b); }
public IGeometry setHSBColor(double h, double s, double b){ return hsb(h,s,b); }
public IGeometry weight(double w){ super.weight(w); return this; }
public IGeometry weight(float w){ super.weight(w); return this; }
/****************************************************
* ITransformable API
***************************************************/
abstract public IGeometry add(double x, double y, double z);
abstract public IGeometry add(IDoubleI x, IDoubleI y, IDoubleI z);
abstract public IGeometry add(IVecI v);
abstract public IGeometry sub(double x, double y, double z);
abstract public IGeometry sub(IDoubleI x, IDoubleI y, IDoubleI z);
abstract public IGeometry sub(IVecI v);
abstract public IGeometry mul(IDoubleI v);
abstract public IGeometry mul(double v);
abstract public IGeometry div(IDoubleI v);
abstract public IGeometry div(double v);
abstract public IGeometry neg();
/** alias of neg */
//abstract public IGeometry rev(); // rev is used in curve to revrse u parameter
/** alias of neg */
abstract public IGeometry flip();
/** scale add */
abstract public IGeometry add(IVecI v, double f);
/** scale add */
abstract public IGeometry add(IVecI v, IDoubleI f);
/** scale add alias */
abstract public IGeometry add(double f, IVecI v);
/** scale add alias */
abstract public IGeometry add(IDoubleI f, IVecI v);
/** rotation around z-axis and origin */
abstract public IGeometry rot(IDoubleI angle);
abstract public IGeometry rot(double angle);
/** rotation around axis vector */
abstract public IGeometry rot(IVecI axis, IDoubleI angle);
abstract public IGeometry rot(IVecI axis, double angle);
/** rotation around axis vector and center */
abstract public IGeometry rot(IVecI center, IVecI axis, IDoubleI angle);
abstract public IGeometry rot(IVecI center, IVecI axis, double angle);
/** rotate to destination direction vector */
abstract public IGeometry rot(IVecI axis, IVecI destDir);
/** rotate to destination point location */
abstract public IGeometry rot(IVecI center, IVecI axis, IVecI destPt);
/** rotation on xy-plane around origin; same with rot(IDoubleI) */
abstract public IGeometry rot2(IDoubleI angle);
/** rotation on xy-plane around origin; same with rot(double) */
abstract public IGeometry rot2(double angle);
/** rotation on xy-plane around center */
abstract public IGeometry rot2(IVecI center, IDoubleI angle);
abstract public IGeometry rot2(IVecI center, double angle);
/** rotation on xy-plane to destination direction vector */
abstract public IGeometry rot2(IVecI destDir);
/** rotation on xy-plane to destination point location */
abstract public IGeometry rot2(IVecI center, IVecI destPt);
/** alias of mul */
abstract public IGeometry scale(IDoubleI f);
abstract public IGeometry scale(double f);
abstract public IGeometry scale(IVecI center, IDoubleI f);
abstract public IGeometry scale(IVecI center, double f);
/** scale only in 1 direction */
abstract public IGeometry scale1d(IVecI axis, double f);
abstract public IGeometry scale1d(IVecI axis, IDoubleI f);
abstract public IGeometry scale1d(IVecI center, IVecI axis, double f);
abstract public IGeometry scale1d(IVecI center, IVecI axis, IDoubleI f);
/** reflect(mirror) 3 dimensionally to the other side of the plane */
abstract public IGeometry ref(IVecI planeDir);
abstract public IGeometry ref(IVecI center, IVecI planeDir);
/** mirror is alias of ref */
abstract public IGeometry mirror(IVecI planeDir);
abstract public IGeometry mirror(IVecI center, IVecI planeDir);
/** shear operation */
abstract public IGeometry shear(double sxy, double syx, double syz,
double szy, double szx, double sxz);
abstract public IGeometry shear(IDoubleI sxy, IDoubleI syx, IDoubleI syz,
IDoubleI szy, IDoubleI szx, IDoubleI sxz);
abstract public IGeometry shear(IVecI center, double sxy, double syx, double syz,
double szy, double szx, double sxz);
abstract public IGeometry shear(IVecI center, IDoubleI sxy, IDoubleI syx, IDoubleI syz,
IDoubleI szy, IDoubleI szx, IDoubleI sxz);
abstract public IGeometry shearXY(double sxy, double syx);
abstract public IGeometry shearXY(IDoubleI sxy, IDoubleI syx);
abstract public IGeometry shearXY(IVecI center, double sxy, double syx);
abstract public IGeometry shearXY(IVecI center, IDoubleI sxy, IDoubleI syx);
abstract public IGeometry shearYZ(double syz, double szy);
abstract public IGeometry shearYZ(IDoubleI syz, IDoubleI szy);
abstract public IGeometry shearYZ(IVecI center, double syz, double szy);
abstract public IGeometry shearYZ(IVecI center, IDoubleI syz, IDoubleI szy);
abstract public IGeometry shearZX(double szx, double sxz);
abstract public IGeometry shearZX(IDoubleI szx, IDoubleI sxz);
abstract public IGeometry shearZX(IVecI center, double szx, double sxz);
abstract public IGeometry shearZX(IVecI center, IDoubleI szx, IDoubleI sxz);
/** mv() is alias of add() */
abstract public IGeometry mv(double x, double y, double z);
abstract public IGeometry mv(IDoubleI x, IDoubleI y, IDoubleI z);
abstract public IGeometry mv(IVecI v);
/** cp() is alias of dup().add() */
abstract public IGeometry cp(double x, double y, double z);
abstract public IGeometry cp(IDoubleI x, IDoubleI y, IDoubleI z);
abstract public IGeometry cp(IVecI v);
/** translate() is alias of add() */
abstract public IGeometry translate(double x, double y, double z);
abstract public IGeometry translate(IDoubleI x, IDoubleI y, IDoubleI z);
abstract public IGeometry translate(IVecI v);
abstract public IGeometry transform(IMatrix3I mat);
abstract public IGeometry transform(IMatrix4I mat);
abstract public IGeometry transform(IVecI xvec, IVecI yvec, IVecI zvec);
abstract public IGeometry transform(IVecI xvec, IVecI yvec, IVecI zvec, IVecI translate);
}