CityGMLViewer.java 16.3 KB
Newer Older
Matthias Betz's avatar
Matthias Betz committed
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
/*-
 * Copyright 2021 Hochschule für Technik Stuttgart
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.hft.stuttgart.citygml.viewer;

import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
Matthias Betz's avatar
Matthias Betz committed
28
29
30
31
32
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
Matthias Betz's avatar
Matthias Betz committed
33
34
35
36
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.imageio.ImageIO;
37
import javax.swing.JOptionPane;
Matthias Betz's avatar
Matthias Betz committed
38
import javax.xml.namespace.QName;
Matthias Betz's avatar
Matthias Betz committed
39
40
import javax.xml.parsers.ParserConfigurationException;

Matthias Betz's avatar
Matthias Betz committed
41
42
43
44
45
46
import org.citygml4j.core.model.core.AbstractFeature;
import org.citygml4j.core.util.CityGMLConstants;
import org.citygml4j.xml.CityGMLContext;
import org.citygml4j.xml.CityGMLContextException;
import org.citygml4j.xml.reader.ChunkOptions;
import org.citygml4j.xml.reader.CityGMLChunk;
Matthias Betz's avatar
Matthias Betz committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import org.citygml4j.xml.reader.CityGMLInputFactory;
import org.citygml4j.xml.reader.CityGMLReadException;
import org.citygml4j.xml.reader.CityGMLReader;
import org.lwjgl.PointerBuffer;
import org.lwjgl.glfw.Callbacks;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWMouseButtonCallback;
import org.lwjgl.glfw.GLFWScrollCallback;
import org.lwjgl.glfw.GLFWWindowSizeCallbackI;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL30;
61
62
import org.lwjgl.opengl.GLUtil;
import org.lwjgl.system.Callback;
Matthias Betz's avatar
Matthias Betz committed
63
64
65
66
67
68
69
70
import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil;
import org.lwjgl.util.nfd.NativeFileDialog;
import org.xml.sax.SAXException;

import com.jogamp.opengl.GLException;

import de.hft.stuttgart.citygml.viewer.datastructure.BoundingBox;
Matthias Betz's avatar
Matthias Betz committed
71
import de.hft.stuttgart.citygml.viewer.datastructure.Polygon;
Matthias Betz's avatar
Matthias Betz committed
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
import de.hft.stuttgart.citygml.viewer.math.Vector3d;
import de.hft.stuttgart.citygml.viewer.parser.CityGMLParser;
import de.hft.stuttgart.citygml.viewer.parser.FeatureMapper;
import de.hft.stuttgart.citygml.viewer.parser.ObservedInputStream;
import de.hft.stuttgart.citygml.viewer.parser.ParserConfiguration;

public class CityGMLViewer {

	private static final Logger log = Logger.getLogger(CityGMLViewer.class.getName());

	private static Camera camera;

	private static boolean mouse1Down = false;
	private static boolean mouse2Down = false;

	private static double x;
	private static double y;

	private static int width = 1024;
	private static int height = 768;

	private static List<PolygonViewInformation> viewing = new ArrayList<>();
	private static float cameraViewDistance = 10000f;

	private static long windowId;

	private static ProgressBar bar;

Matthias Betz's avatar
Matthias Betz committed
100
101
102
103
104
105
106
107
108
	private static final String CITY_OBJECT_MEMBER = "cityObjectMember";
	private static List<QName> chunkProperties = new ArrayList<>();

	static {
		chunkProperties.add(new QName(CityGMLConstants.CITYGML_1_0_CORE_NAMESPACE, CITY_OBJECT_MEMBER));
		chunkProperties.add(new QName(CityGMLConstants.CITYGML_2_0_CORE_NAMESPACE, CITY_OBJECT_MEMBER));
		chunkProperties.add(new QName(CityGMLConstants.CITYGML_3_0_CORE_NAMESPACE, CITY_OBJECT_MEMBER));
	}

Matthias Betz's avatar
Matthias Betz committed
109
	public static void main(String[] args) {
110
111
112
113
114
115
		boolean useDebug = false;
		for (String arg : args) {
			if (arg.equals("-debug")) {
				useDebug = true;
			}
		}
Matthias Betz's avatar
Matthias Betz committed
116
117
118
119
120
121
122
123
124
125
126
127
		File f = null;
		if (args != null && args.length == 1) {
			f = new File(args[0]);
			if (!f.exists() || f.isDirectory()) {
				// no file given
				f = null;
			}
		}
		if (f == null) {
			f = showFileChooserDialog();
		}
		try {
128
			setupWindow(f, useDebug);
129
		} catch (Exception e) {
130
			String message = e.getClass().getSimpleName() + ": " + e.getMessage();
131
			if (e.getCause() != null) {
132
				message += "\nCause: " + e.getCause().getClass().getSimpleName() + ": " + e.getCause().getMessage();
133
134
			}
			JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);
Matthias Betz's avatar
Matthias Betz committed
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
		} finally {
			for (PolygonViewInformation view : viewing) {
				view.destroy();
			}
		}
	}

	private static File showFileChooserDialog() {
		File f = null;
		try (MemoryStack stack = MemoryStack.stackPush()) {
			File defaultPath = new File("bla");
			PointerBuffer pathPointer = stack.mallocPointer(1);
			int success = NativeFileDialog.NFD_OpenDialog("gml,xml", defaultPath.getAbsolutePath(), pathPointer);
			if (success == NativeFileDialog.NFD_OKAY) {
				String filePath = pathPointer.getStringUTF8(0);
				f = new File(filePath);
			} else {
				System.exit(0);
			}
		}
		return f;
	}

	private static void screenShot() {
		// Creating an rbg array of total pixels
		int[] pixels = new int[width * height];
		int bindex;
		// allocate space for RBG pixels
		ByteBuffer fb = ByteBuffer.allocateDirect(width * height * 3);

		// grab a copy of the current frame contents as RGB
		GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, fb);

		BufferedImage imageIn = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		// convert RGB data in ByteBuffer to integer array
		for (int i = 0; i < pixels.length; i++) {
			bindex = i * 3;
			pixels[i] = (fb.get(bindex) << 16) + (fb.get(bindex + 1) << 8) + (fb.get(bindex + 2));
		}
		// Allocate colored pixel to buffered Image
		imageIn.setRGB(0, 0, width, height, pixels, 0, width);

		// Creating the transformation direction (horizontal)
		AffineTransform at = AffineTransform.getScaleInstance(1, -1);
		at.translate(0, -imageIn.getHeight(null));

		// Applying transformation
		AffineTransformOp opRotated = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
		BufferedImage imageOut = opRotated.filter(imageIn, null);

		try {
			int nr = 0;
			File f = new File("screen_" + nr + ".png");
			while (f.exists()) {
				nr++;
				f = new File("screen_" + nr + ".png");
			}
			ImageIO.write(imageOut, "png", f);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

198
199
200
201
	private static void setupWindow(File f, boolean useDebug) {
		GLFW.glfwSetErrorCallback(GLFWErrorCallback.create((code, desc) -> {
			log.severe("Encountered OpenGL error with code: " + code);
		}));
Matthias Betz's avatar
Matthias Betz committed
202
203
204
		if (!GLFW.glfwInit()) {
			throw new IllegalStateException("Unable to initialize GLFW");
		}
Matthias Betz's avatar
Matthias Betz committed
205
		String title = "CityGMLViewer" + f.getName();
Matthias Betz's avatar
Matthias Betz committed
206
207

		GLFW.glfwDefaultWindowHints(); // Loads GLFW's default window settings
208
209
210
		if (useDebug) {
			GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, GLFW.GLFW_TRUE);
		}
Matthias Betz's avatar
Matthias Betz committed
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
		GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE); // Sets window to be visible
		GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE); // Sets whether the window is resizable
		GLFW.glfwWindowHint(GLFW.GLFW_SAMPLES, 2);

		windowId = GLFW.glfwCreateWindow(width, height, title, 0, 0);
		if (windowId == 0) {
			GLFW.glfwTerminate();
			throw new IllegalStateException("Failed to create window");
		}

		GLFW.glfwSetWindowSizeCallback(windowId, new GLFWWindowSizeCallbackI() {

			@Override
			public void invoke(long window, int width, int height) {
				CityGMLViewer.width = width;
				CityGMLViewer.height = height;
				if (camera != null) {
					camera.reshape(width, height, cameraViewDistance);
				}
				if (bar != null) {
					bar.updateWindowSize(width, height);
				}
				GL11.glViewport(0, 0, width, height);
			}
		});

		GLFW.glfwSetKeyCallback(windowId, (window, key, scancode, action, mods) -> {
			if (key == GLFW.GLFW_KEY_ESCAPE && action == GLFW.GLFW_PRESS) {
				GLFW.glfwSetWindowShouldClose(window, true);
			} else if (key == GLFW.GLFW_KEY_F9 && action == GLFW.GLFW_PRESS) {
				screenShot();
			}
		});

		GLFW.glfwSetMouseButtonCallback(windowId, new GLFWMouseButtonCallback() {

			@Override
			public void invoke(long window, int button, int action, int mods) {
				if (button == GLFW.GLFW_MOUSE_BUTTON_1 && action == GLFW.GLFW_PRESS) {
					mouse1Down = true;
					try (MemoryStack stack = MemoryStack.stackPush()) {
						DoubleBuffer xBuffer = stack.mallocDouble(1);
						DoubleBuffer yBuffer = stack.mallocDouble(1);
						GLFW.glfwGetCursorPos(windowId, xBuffer, yBuffer);
						x = xBuffer.get(0);
						y = yBuffer.get(0);
					}
				} else if (button == GLFW.GLFW_MOUSE_BUTTON_1 && action == GLFW.GLFW_RELEASE) {
					mouse1Down = false;
				} else if (button == GLFW.GLFW_MOUSE_BUTTON_2 && action == GLFW.GLFW_PRESS) {
					mouse2Down = true;
					try (MemoryStack stack = MemoryStack.stackPush()) {
						DoubleBuffer xBuffer = stack.mallocDouble(1);
						DoubleBuffer yBuffer = stack.mallocDouble(1);
						GLFW.glfwGetCursorPos(windowId, xBuffer, yBuffer);
						x = xBuffer.get(0);
						y = yBuffer.get(0);
					}
				} else if (button == GLFW.GLFW_MOUSE_BUTTON_2 && action == GLFW.GLFW_RELEASE) {
					mouse2Down = false;
				}
			}
		});

		GLFW.glfwSetScrollCallback(windowId, new GLFWScrollCallback() {

			@Override
			public void invoke(long window, double xoffset, double yoffset) {
				camera.scroll((int) (-yoffset));
			}
		});

		GLFW.glfwSetCursorPosCallback(windowId, (window, xPos, yPos) -> {
			if (mouse1Down) {
				try (MemoryStack stack = MemoryStack.stackPush()) {
					double dragDiffX = xPos - x;
					double dragDiffY = yPos - y;
					camera.drag(dragDiffX, dragDiffY);
					x = xPos;
					y = yPos;
				}
			} else if (mouse2Down) {
				try (MemoryStack stack = MemoryStack.stackPush()) {
					double dragDiffX = xPos - x;
					double dragDiffY = yPos - y;
					camera.move(dragDiffX, dragDiffY);
					x = xPos;
					y = yPos;
				}
			}
		});

		GLFW.glfwMakeContextCurrent(windowId); // glfwSwapInterval needs a context on the calling thread, otherwise will
												// cause
		// NO_CURRENT_CONTEXT error
		org.lwjgl.opengl.GLCapabilities caps = GL.createCapabilities(); // Will let lwjgl know we want to use this
																		// context as the context to draw with
308
309
310
311
312
		Callback cb = null;
		if (useDebug) {
			cb = GLUtil.setupDebugMessageCallback();
		}

Matthias Betz's avatar
Matthias Betz committed
313
314
		if (!caps.OpenGL30) {
			log.warning("OpenGL 3.0 is not supported");
Matthias Betz's avatar
Matthias Betz committed
315
316
317
318
319
320
321
322
323
324
325
		}
		GLFW.glfwSwapInterval(1); // How many draws to swap the buffer

		GL11.glEnable(GL11.GL_DEPTH_TEST);
		GL11.glEnable(GL13.GL_MULTISAMPLE);
		GL11.glDisable(GL11.GL_CULL_FACE);

		GL11.glViewport(0, 0, width, height);
		GLFW.glfwShowWindow(windowId); // Shows the window

		if (log.isLoggable(Level.INFO)) {
Matthias Betz's avatar
Matthias Betz committed
326
			log.fine("OpenGL error code after displaying the window: " + GL11.glGetError());
Matthias Betz's avatar
Matthias Betz committed
327
328
329
330
331
332
		}

		FloatBuffer clearColor = null;
		FloatBuffer clearDepth = null;

		try {
333
			Shader program = new Shader("vertex.vert", "fragment.frag", useDebug);
Matthias Betz's avatar
Matthias Betz committed
334
			program.use();
Matthias Betz's avatar
Matthias Betz committed
335
			log.fine(() -> "OpenGL error code after shader loading: " + GL11.glGetError());
Matthias Betz's avatar
Matthias Betz committed
336
337
338
339
340
			camera = new Camera(program);
			camera.setOrtho(true);
			camera.reshape(width, height, cameraViewDistance);
			bar = new ProgressBar(windowId, width, height);
			bar.drawProgress(0);
Matthias Betz's avatar
Matthias Betz committed
341
			log.fine(() -> "OpenGL error code after drawing initial progress bar: " + GL11.glGetError());
Matthias Betz's avatar
Matthias Betz committed
342
343

			loadGmlFile(f);
Matthias Betz's avatar
Matthias Betz committed
344
			log.fine(() -> "OpenGL error code after loading GML file: " + GL11.glGetError());
Matthias Betz's avatar
Matthias Betz committed
345
346
			bar.free();
			bar = null;
Matthias Betz's avatar
Matthias Betz committed
347

Matthias Betz's avatar
Matthias Betz committed
348
349
350
351
352
353
354
355
			camera.setOrtho(false);
			camera.reshape(width, height, cameraViewDistance);

			clearColor = MemoryUtil.memAllocFloat(4);
			clearColor.put(0, 0.9411765f).put(1, 1f).put(2, 1f).put(3, 1f);
			clearDepth = MemoryUtil.memAllocFloat(1);
			clearDepth.put(0, 1f);

Matthias Betz's avatar
Matthias Betz committed
356
			log.fine(() -> "OpenGL error code before loop: " + GL11.glGetError());
Matthias Betz's avatar
Matthias Betz committed
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
			while (!GLFW.glfwWindowShouldClose(windowId)) {
				/* Do something */
				GL30.glClearBufferfv(GL11.GL_COLOR, 0, clearColor);
				GL30.glClearBufferfv(GL11.GL_DEPTH, 0, clearDepth);

				for (PolygonViewInformation view : viewing) {
					view.draw();
				}

				Thread.sleep(15);

				GLFW.glfwSwapBuffers(windowId);
				GLFW.glfwPollEvents();
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
			Thread.currentThread().interrupt();
		} finally {
			MemoryUtil.memFree(clearColor);
			MemoryUtil.memFree(clearDepth);
			if (camera != null) {
				camera.free();
			}
		}

382
383
384
		if (cb != null) {
			cb.free();
		}
Matthias Betz's avatar
Matthias Betz committed
385
386
387
388
389
390
391
392
393
394
395
396
		GLFW.glfwDestroyWindow(windowId);
		Callbacks.glfwFreeCallbacks(windowId);
		GLFW.glfwTerminate();
	}

	private static void loadGmlFile(File f) {
		try {
			File file = f;
			ParserConfiguration config = new ParserConfiguration();
			CityGMLParser.parseEpsgCodeFromFile(file, config);
			CityGMLContext context = CityGMLContext.newInstance();
			CityGMLInputFactory in = context.createCityGMLInputFactory()
Matthias Betz's avatar
Matthias Betz committed
397
					.withChunking(ChunkOptions.chunkByProperties(chunkProperties).skipCityModel(true));
Matthias Betz's avatar
Matthias Betz committed
398
399
400
			try (ObservedInputStream ois = new ObservedInputStream(file);
					CityGMLReader reader = in.createCityGMLReader(file.getAbsolutePath(), ois)) {
				ois.addListener(p -> bar.drawProgress((int) (p * 82)));
401
402
403

				int threads = Runtime.getRuntime().availableProcessors();
				ExecutorService service = Executors.newFixedThreadPool(threads);
Matthias Betz's avatar
Matthias Betz committed
404
				List<Future<FeatureMapper>> mappers = new ArrayList<>();
Matthias Betz's avatar
Matthias Betz committed
405
				while (reader.hasNext()) {
Matthias Betz's avatar
Matthias Betz committed
406
407
408
409
410
411
412
					CityGMLChunk nextChunk = reader.nextChunk();
					mappers.add(service.submit(() -> {
						FeatureMapper mapper = new FeatureMapper(config);
						AbstractFeature feature = nextChunk.build();
						feature.accept(mapper);
						return mapper;
					}));
Matthias Betz's avatar
Matthias Betz committed
413
				}
Matthias Betz's avatar
Matthias Betz committed
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
				service.shutdown();
				service.awaitTermination(20, TimeUnit.MINUTES);
				List<Polygon> lod1Polygons = new ArrayList<>();
				List<Polygon> lod2Polygons = new ArrayList<>();
				List<Polygon> lod3Polygons = new ArrayList<>();
				List<Polygon> lod4Polygons = new ArrayList<>();
				List<FeatureMapper> fMappers = mappers.stream().map(t -> {
					try {
						return t.get();
					} catch (InterruptedException e) {
						Thread.currentThread().interrupt();
						log.severe("Could not finish parsing file in 20 minutes, aborting");
						throw new IllegalStateException(e);
					} catch (ExecutionException e) {
						log.severe("Could not parsing file completely, cause: " + e.getCause().getMessage());
						throw new IllegalStateException(e);
					}
				}).toList();
				fMappers.stream().forEach(m -> {
					lod1Polygons.addAll(m.getLod1Polygons());
					lod2Polygons.addAll(m.getLod2Polygons());
					lod3Polygons.addAll(m.getLod3Polygons());
					lod4Polygons.addAll(m.getLod4Polygons());
				});
				BoundingBox bbox = BoundingBox.of(lod1Polygons, lod2Polygons, lod3Polygons, lod4Polygons);
Matthias Betz's avatar
Matthias Betz committed
439
440
				bar.drawProgress(81);
				Vector3d center = bbox.getCenter();
Matthias Betz's avatar
Matthias Betz committed
441
				fMappers.forEach(m -> m.movePolygonsBy(center));
Matthias Betz's avatar
Matthias Betz committed
442
				bar.drawProgress(82);
443
444
				long nrOfPolygons = (long) lod1Polygons.size() + lod2Polygons.size() + lod3Polygons.size()
						+ lod4Polygons.size();
Matthias Betz's avatar
Matthias Betz committed
445
				long[] count = new long[1];
Matthias Betz's avatar
Matthias Betz committed
446
				log.info(() -> "Found " + nrOfPolygons + " polygons");
Matthias Betz's avatar
Matthias Betz committed
447
448
449
450
				PolygonListener l = () -> {
					count[0]++;
					bar.drawProgress(82 + (int) (count[0] * 9 / nrOfPolygons));
				};
Matthias Betz's avatar
Matthias Betz committed
451
452
				if (!lod1Polygons.isEmpty()) {
					PolygonViewInformation lod1ViewInfo = new PolygonViewInformation(lod1Polygons, l);
Matthias Betz's avatar
Matthias Betz committed
453
454
					viewing.add(lod1ViewInfo);
				}
Matthias Betz's avatar
Matthias Betz committed
455
456
				if (!lod2Polygons.isEmpty()) {
					PolygonViewInformation lod2ViewInfo = new PolygonViewInformation(lod2Polygons, l);
Matthias Betz's avatar
Matthias Betz committed
457
458
					viewing.add(lod2ViewInfo);
				}
Matthias Betz's avatar
Matthias Betz committed
459
460
				if (!lod3Polygons.isEmpty()) {
					PolygonViewInformation lod3ViewInfo = new PolygonViewInformation(lod3Polygons, l);
Matthias Betz's avatar
Matthias Betz committed
461
462
					viewing.add(lod3ViewInfo);
				}
Matthias Betz's avatar
Matthias Betz committed
463
464
				if (!lod4Polygons.isEmpty()) {
					PolygonViewInformation lod4ViewInfo = new PolygonViewInformation(lod4Polygons, l);
Matthias Betz's avatar
Matthias Betz committed
465
466
467
468
469
470
471
472
473
					viewing.add(lod4ViewInfo);
				}

				double longestSide = bbox.getDiagonalLength() * 0.2;
				double d = longestSide / Math.tan(Math.toRadians(30) / 2);
				double translateZ = -d;
				camera.setDistance((float) translateZ);
				cameraViewDistance = (float) longestSide * 20f;
				camera.reshape(width, height, cameraViewDistance);
Matthias Betz's avatar
Matthias Betz committed
474
475
476
			} catch (InterruptedException e) {
				Thread.currentThread().interrupt();
				log.severe("Could not finish parsing file in 20 minutes, aborting");
Matthias Betz's avatar
Matthias Betz committed
477
478
479
480
481
482
483
			}
		} catch (GLException | IOException | ParserConfigurationException | SAXException | CityGMLContextException
				| CityGMLReadException e) {
			e.printStackTrace();
		}
	}
}