| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Pierre Allard, |
| * Regent L'Archeveque - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.common.geometry.data3d.converters; |
| |
| import java.io.File; |
| import java.net.URL; |
| |
| import org.eclipse.apogy.common.converters.ApogyCommonConvertersFacade; |
| import org.eclipse.apogy.common.geometry.data3d.CartesianTriangularMesh; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| public class URLTopoToCartesianTriangularMeshConverter extends URLToCartesianTriangularMeshConverter { |
| private static final Logger Logger = LoggerFactory.getLogger(URLTopoToCartesianTriangularMeshConverter.class); |
| |
| private static String[] fileExtensions = new String[] { ".topo", "xml" }; |
| |
| @Override |
| public Class<?> getOutputType() { |
| return CartesianTriangularMesh.class; |
| } |
| |
| @Override |
| public Class<?> getInputType() { |
| return URL.class; |
| } |
| |
| @Override |
| public String[] getSupportedFileExtension() { |
| return fileExtensions; |
| } |
| |
| @Override |
| public Object convert(Object input) throws Exception { |
| CartesianTriangularMesh mesh = null; |
| |
| try { |
| URL url = (URL) input; |
| |
| File tempFile = copyURLContent(url); |
| |
| if (tempFile != null) { |
| mesh = (CartesianTriangularMesh) ApogyCommonConvertersFacade.INSTANCE.convert(tempFile, |
| CartesianTriangularMesh.class); |
| } |
| |
| if (mesh != null) { |
| Logger.info("Sucessfully loaded CartesianTriangularMesh from URL<" + url + ">."); |
| } else { |
| Logger.error("Could not load CartesianTriangularMesh from URL<" + url + ">."); |
| } |
| } catch (Throwable t) { |
| Logger.error(t.getMessage(), t); |
| } |
| return mesh; |
| } |
| } |