mirror of https://github.com/rusefi/jzy3d-api.git
fixed convex hull, update pom file
This commit is contained in:
parent
4cfe72803b
commit
d1e31e1466
|
@ -5,3 +5,4 @@ doc/javadoc
|
||||||
*.class
|
*.class
|
||||||
*.log
|
*.log
|
||||||
*~/
|
*~/
|
||||||
|
/target
|
||||||
|
|
19
README.md
19
README.md
|
@ -10,6 +10,16 @@ Source organisation
|
||||||
- ChartTest, a tool to compare a chart with a previously saved screenshot
|
- ChartTest, a tool to compare a chart with a previously saved screenshot
|
||||||
- Replay, a utility to record and validate a sequence of mouse and key interactions results on a chart (work in progress)
|
- Replay, a utility to record and validate a sequence of mouse and key interactions results on a chart (work in progress)
|
||||||
|
|
||||||
|
Build
|
||||||
|
- Eclipse: .project & .classpath files
|
||||||
|
- Ant: build.xml
|
||||||
|
- Maven: pom.xml
|
||||||
|
- Javadoc: javadoc.xml
|
||||||
|
|
||||||
|
Project dependencies
|
||||||
|
These project dependencies are set through eclipse .classpath file, ant build files and maven pom files.
|
||||||
|
- jzy3d-tools-convexhull
|
||||||
|
|
||||||
Library dependencies
|
Library dependencies
|
||||||
- jogl2
|
- jogl2
|
||||||
- jdt (currently copied in API but will be externalized soon)
|
- jdt (currently copied in API but will be externalized soon)
|
||||||
|
@ -18,15 +28,6 @@ Library dependencies
|
||||||
- log4j
|
- log4j
|
||||||
- junit
|
- junit
|
||||||
|
|
||||||
Project dependencies
|
|
||||||
These project dependencies are set through eclipse .classpath file.
|
|
||||||
- jzy3d-tools-convexhull
|
|
||||||
|
|
||||||
Build files
|
|
||||||
- build.xml
|
|
||||||
- javadoc.xml
|
|
||||||
|
|
||||||
|
|
||||||
Satellite projects depending on Jzy3d
|
Satellite projects depending on Jzy3d
|
||||||
--------------
|
--------------
|
||||||
Satellite projects are extensions of the framework that remain external to the API.
|
Satellite projects are extensions of the framework that remain external to the API.
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 127 KiB |
|
@ -0,0 +1,110 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<!--
|
||||||
|
To install a lib locally:
|
||||||
|
|
||||||
|
mvn install:install-file \
|
||||||
|
-DgroupId=org.jzyio \
|
||||||
|
-DartifactId=jzyio \
|
||||||
|
-Dversion=0.1 \
|
||||||
|
-Dpackaging=jar \
|
||||||
|
-Dfile=./lib/misc/org.jzyio-0.1.jar
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.jzy3d</groupId>
|
||||||
|
<artifactId>jzy3d-api</artifactId>
|
||||||
|
<version>0.9-SNAPSHOT</version>
|
||||||
|
<name>jzy3d</name>
|
||||||
|
<description>A Java API for 3d charts</description>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>swt-repo</id>
|
||||||
|
<url>https://swt-repo.googlecode.com/svn/repo/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jogamp.gluegen</groupId>
|
||||||
|
<artifactId>gluegen-rt-main</artifactId>
|
||||||
|
<version>2.0-rc11</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jogamp.jogl</groupId>
|
||||||
|
<artifactId>jogl-all-main</artifactId>
|
||||||
|
<version>2.0-rc11</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<version>1.2.16</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.swt</groupId>
|
||||||
|
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
|
||||||
|
<version>4.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sf.opencsv</groupId>
|
||||||
|
<artifactId>opencsv</artifactId>
|
||||||
|
<version>2.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!--
|
||||||
|
The next dep was installed locally by adding a POM to its project and executing 'mvn install'.
|
||||||
|
-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jzy3d</groupId>
|
||||||
|
<artifactId>jzy3d-convexhull</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<testSourceDirectory>src/tests</testSourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>add-source</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sources>
|
||||||
|
<source>src/api</source>
|
||||||
|
<source>src/bridge</source>
|
||||||
|
</sources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<configuration>
|
||||||
|
<!-- TODO: Change to 1.7 -->
|
||||||
|
<source>1.6</source>
|
||||||
|
<target>1.6</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>org/jzy3d/junit/ChartTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -1,6 +1,8 @@
|
||||||
package org.jzy3d.chart.controllers.mouse.selection;
|
package org.jzy3d.chart.controllers.mouse.selection;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.Deque;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jzy3d.maths.ConvexHull;
|
import org.jzy3d.maths.ConvexHull;
|
||||||
|
@ -9,9 +11,6 @@ import org.jzy3d.plot3d.primitives.selectable.SelectableSphere;
|
||||||
import org.jzy3d.plot3d.rendering.scene.Scene;
|
import org.jzy3d.plot3d.rendering.scene.Scene;
|
||||||
import org.jzy3d.plot3d.rendering.view.View;
|
import org.jzy3d.plot3d.rendering.view.View;
|
||||||
|
|
||||||
import utils.Stack;
|
|
||||||
import algorithms.Point2f;
|
|
||||||
|
|
||||||
public class SphereMouseSelector extends AbstractMouseSelector {
|
public class SphereMouseSelector extends AbstractMouseSelector {
|
||||||
public SphereMouseSelector(SelectableSphere scatter) {
|
public SphereMouseSelector(SelectableSphere scatter) {
|
||||||
this.sphere = scatter;
|
this.sphere = scatter;
|
||||||
|
@ -39,10 +38,10 @@ protected void drawSelection(Graphics2D g2d, int width, int height) {
|
||||||
|
|
||||||
if(projection!=null && sphere.isHighlighted()){
|
if(projection!=null && sphere.isHighlighted()){
|
||||||
hull = ConvexHull.build2d(projection);
|
hull = ConvexHull.build2d(projection);
|
||||||
Point2f prev = hull.pop();
|
Point2D prev = hull.pop();
|
||||||
Point2f next;
|
Point2D next;
|
||||||
g2d.setColor(java.awt.Color.GREEN);
|
g2d.setColor(java.awt.Color.GREEN);
|
||||||
while (!hull.empty()) {
|
while (!hull.isEmpty()) {
|
||||||
next = hull.pop();
|
next = hull.pop();
|
||||||
g2d.drawOval((int) prev.getX() - 4, (int) prev.getY() - 4, 8, 8);
|
g2d.drawOval((int) prev.getX() - 4, (int) prev.getY() - 4, 8, 8);
|
||||||
g2d.drawLine((int) prev.getX(), (int) prev.getY(), (int) next.getX(), (int) next.getY() );
|
g2d.drawLine((int) prev.getX(), (int) prev.getY(), (int) next.getX(), (int) next.getY() );
|
||||||
|
@ -64,5 +63,5 @@ protected void drawSelection(Graphics2D g2d, int width, int height) {
|
||||||
protected int width;
|
protected int width;
|
||||||
protected int height;
|
protected int height;
|
||||||
protected List<Coord3d> projection;
|
protected List<Coord3d> projection;
|
||||||
protected Stack<Point2f> hull;
|
protected Deque<Point2D> hull;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,44 @@
|
||||||
package org.jzy3d.maths;
|
package org.jzy3d.maths;
|
||||||
|
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.Deque;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import utils.Stack;
|
import org.jzy3d.convexhull.ConvexHullFunction;
|
||||||
import algorithms.Point2f;
|
import org.jzy3d.convexhull.GrahamScan;
|
||||||
import convexhull.ConvexHullFunction;
|
|
||||||
import convexhull.GrahamScan;
|
|
||||||
|
|
||||||
public class ConvexHull {
|
public class ConvexHull {
|
||||||
public static java.awt.Polygon hull(List<Coord3d> cell){
|
public static java.awt.Polygon hull(List<Coord3d> cell){
|
||||||
java.awt.Polygon out = new java.awt.Polygon();
|
java.awt.Polygon out = new java.awt.Polygon();
|
||||||
|
|
||||||
Stack<Point2f> hull = ConvexHull.build2d(cell);
|
Deque<Point2D> hull = ConvexHull.build2d(cell);
|
||||||
while (!hull.empty()) {
|
while (!hull.isEmpty()) {
|
||||||
Point2f p = hull.pop();
|
Point2D p = hull.pop();
|
||||||
out.addPoint( (int)p.getX(), (int)p.getY());
|
out.addPoint( (int)p.getX(), (int)p.getY());
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stack<Point2f> build2d(List<Coord3d> input2d){
|
public static Deque<Point2D> build2d(List<Coord3d> input2d){
|
||||||
int np = input2d.size();
|
int np = input2d.size();
|
||||||
Point2f[] data = new Point2f[ np ];
|
Point2D[] data = new Point2D[ np ];
|
||||||
for (int i = 0; i < data.length; i++) {
|
for (int i = 0; i < data.length; i++) {
|
||||||
data[i] = asPoint2f( input2d.get(i) );
|
data[i] = asPoint2f( input2d.get(i) );
|
||||||
}
|
}
|
||||||
return f.getConvexHull( data );
|
return f.getConvexHull( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stack<Point2f> build2d(PolygonArray input2d){
|
public static Deque<Point2D> build2d(PolygonArray input2d){
|
||||||
int np = input2d.length();
|
int np = input2d.length();
|
||||||
Point2f[] data = new Point2f[ np ];
|
Point2D[] data = new Point2D[ np ];
|
||||||
for (int i = 0; i < np; i++) {
|
for (int i = 0; i < np; i++) {
|
||||||
data[i] = new Point2f(input2d.x[i], input2d.y[i]);
|
data[i] = new Point2D.Float(input2d.x[i], input2d.y[i]);
|
||||||
}
|
}
|
||||||
return f.getConvexHull( data );
|
return f.getConvexHull( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Point2f asPoint2f(Coord3d c){
|
protected static Point2D asPoint2f(Coord3d c){
|
||||||
return new Point2f(c.x, c.y);
|
return new Point2D.Float(c.x, c.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ConvexHullFunction f = new GrahamScan();//new JarvisMarch();
|
protected static ConvexHullFunction f = new GrahamScan();//new JarvisMarch();
|
||||||
|
|
Loading…
Reference in New Issue