All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.meteoinfo.chart.jogl.pipe.PipeShape Maven / Gradle / Ivy

There is a newer version: 3.8
Show newest version
package org.meteoinfo.chart.jogl.pipe;

import org.meteoinfo.chart.jogl.Transform;
import org.meteoinfo.geometry.shape.PointZ;
import org.meteoinfo.geometry.shape.PolylineZShape;
import org.joml.Vector3f;

import java.util.List;
import java.util.Vector;

public class PipeShape extends PolylineZShape {
    private float radius = 0.05f;
    private int steps = 48;
    private Pipe pipe;
    private Transform transform;

    /**
     * Constructor
     * @param shape PolylineZShape
     */
    public PipeShape(PolylineZShape shape) {
        this.setPoints(shape.getPoints());
        //generatePipe();
    }

    /**
     * Constructor
     * @param shape PolylineZShape
     * @param radius Radius
     * @param steps Steps
     */
    public PipeShape(PolylineZShape shape, float radius, int steps) {
        this.setPoints(shape.getPoints());
        this.radius = radius;
        this.steps = steps;
        //generatePipe();
    }

    /**
     * Get pipe
     * @return Pipe
     */
    public Pipe getPipe() {
        return this.pipe;
    }

    /**
     * Get radius
     * @return Radius
     */
    public float getRadius() {
        return this.radius;
    }

    /**
     * Get steps
     * @return Steps
     */
    public int getSteps() {
        return this.steps;
    }

    void generatePipe() {
        Vector path = new Vector<>();
        for (PointZ p : (List) this.getPoints()) {
            path.add(new Vector3f((float)p.X, (float)p.Y, (float)p.Z));
        }
        this.pipe = new Pipe(path, this.radius, this.steps);
    }

    /**
     * Transform
     * @param transform The transform
     */
    public void transform(Transform transform) {
        if (this.transform != null) {
            if (this.transform.equals(transform))
                return;
        }
        this.transform = (Transform) transform.clone();

        Vector path = new Vector<>();
        for (PointZ p : (List) this.getPoints()) {
            path.add(new Vector3f(transform.transform_x((float)p.X), transform.transform_y((float)p.Y),
                    transform.transform_z((float)p.Z)));
        }
        this.pipe = new Pipe(path, this.radius, this.steps);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy