blob: e871d2dcf651f90eeaacf7a423b6574c2fc83abb [file] [log] [blame]
/*******************************************************************************
* 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.addons.geometry.paths.impl;
import org.eclipse.apogy.common.geometry.data3d.CartesianPositionCoordinates;
import org.eclipse.apogy.common.geometry.data3d.Geometry3DUtilities;
import org.eclipse.apogy.common.topology.INodeVisitor;
public class WayPointPathCustomImpl extends WayPointPathImpl {
@Override
public double getLength() {
double length = 0.0;
if ((getPoints() != null) && (getPoints().size() > 1)) {
CartesianPositionCoordinates p1 = getPoints().get(0);
CartesianPositionCoordinates p2 = null;
for (int i = 1; i < getPoints().size(); i++) {
p2 = getPoints().get(i);
length += Geometry3DUtilities.getDistance(p1, p2);
p1 = p2;
}
}
return length;
}
@Override
public CartesianPositionCoordinates getEndPoint() {
CartesianPositionCoordinates endPoint = null;
if (getPoints().size() > 0) {
endPoint = getPoints().get(getPoints().size() - 1);
}
return endPoint;
}
@Override
public CartesianPositionCoordinates getStartPoint() {
CartesianPositionCoordinates endPoint = null;
if (getPoints().size() > 0) {
endPoint = getPoints().get(0);
}
return endPoint;
}
@Override
public void accept(INodeVisitor visitor) {
if (visitor.getType().isInstance(this)) {
visitor.visit(this);
}
}
} // WayPointPathImpl