...
 
Commits (18)
......@@ -32,5 +32,7 @@
<classpathentry kind="lib" path="lib/itext/itext-pdfa-5.5.5.jar"/>
<classpathentry kind="lib" path="lib/itext/itext-xtra-5.5.5.jar"/>
<classpathentry kind="lib" path="lib/itext/itextpdf-5.5.5_dgdgitlab.jar"/>
<classpathentry kind="lib" path="lib/batik/batik-svggen-1.8.jar"/>
<classpathentry kind="lib" path="lib/batik/batik-util-1.8.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
......@@ -92,6 +92,7 @@
<copy todir="${build}" description="copy resources to output folder">
<fileset dir="${src}">
<include name="de/jtem/halfedgetools/plugin/image/**"/>
<include name="de/jtem/halfedgetools/plugin/data/visualizer/Raleway-Thin.ttf"/>
<exclude name="**/ImageHook.java"/>
</fileset>
</copy>
......
......@@ -20,8 +20,10 @@ import de.jtem.halfedgetools.adapter.generic.BaryCenter4dAdapter;
import de.jtem.halfedgetools.adapter.generic.BaryCenterAdapter;
import de.jtem.halfedgetools.adapter.generic.EdgeLengthAdapter;
import de.jtem.halfedgetools.adapter.generic.EdgeLengthTexAdapter;
import de.jtem.halfedgetools.adapter.generic.EdgeNormalAdapter;
import de.jtem.halfedgetools.adapter.generic.EdgeVectorAdapter;
import de.jtem.halfedgetools.adapter.generic.FaceAreaAdapter;
import de.jtem.halfedgetools.adapter.generic.IndexLabelAdapter;
import de.jtem.halfedgetools.adapter.generic.NormalAdapter;
import de.jtem.halfedgetools.adapter.generic.Position2dAdapter;
import de.jtem.halfedgetools.adapter.generic.Position3dAdapter;
......@@ -481,6 +483,8 @@ public class AdapterSet extends TreeSet<Adapter<?>> {
aSet.add(new EdgeVectorAdapter());
aSet.add(new EdgeLengthAdapter());
aSet.add(new EdgeLengthTexAdapter());
aSet.add(new IndexLabelAdapter());
aSet.add(new EdgeNormalAdapter());
return aSet;
}
......
package de.jtem.halfedgetools.adapter.generic;
import de.jreality.math.Rn;
import de.jtem.halfedge.Edge;
import de.jtem.halfedge.Face;
import de.jtem.halfedge.Node;
import de.jtem.halfedge.Vertex;
import de.jtem.halfedgetools.adapter.AbstractAdapter;
import de.jtem.halfedgetools.adapter.AdapterSet;
import de.jtem.halfedgetools.adapter.type.EdgeNormal;
import de.jtem.halfedgetools.adapter.type.Normal;
import de.jtem.halfedgetools.adapter.type.VectorField;
import de.jtem.halfedgetools.adapter.type.generic.EdgeVector;
@EdgeNormal
@VectorField
public class EdgeNormalAdapter extends AbstractAdapter<double[]> {
public EdgeNormalAdapter() {
super(double[].class, true, false);
}
public EdgeNormalAdapter(Class<? extends double[]> typeClass, boolean getter, boolean setter) {
super(typeClass, getter, setter);
}
@Override
public double getPriority() {
return -1;
}
@Override
public <
V extends Vertex<V, E, F>,
E extends Edge<V, E, F>,
F extends Face<V, E, F>
> double[] getE(E e, AdapterSet a) {
double[] normal = new double[3];
if (e.getLeftFace() != null) {
normal = a.getD(Normal.class, e.getLeftFace());
return normal;
}
else if (e.getPreviousEdge()!= null && e.getNextEdge() != null) {
double[] edgeVector = a.getD(EdgeVector.class, e);
double[] prevEdgeVector = a.getD(EdgeVector.class, e.getPreviousEdge());
double[] nextEdgeVector = a.getD(EdgeVector.class, e.getNextEdge());
if (e.getPreviousEdge().equals(e.getNextEdge())){
//TODO
}
double[] n1 = Rn.crossProduct(null, edgeVector, Rn.negate(prevEdgeVector,prevEdgeVector));
Rn.add(normal, normal, n1);
if (e.getNextEdge() == null) {
return Rn.normalize(normal, normal);
}
double[] n2 = Rn.crossProduct(null, nextEdgeVector, Rn.negate(edgeVector,edgeVector));
Rn.add(normal, normal, n2);
return Rn.times(normal, 1.0 / 2.0, normal);
}
// else if (e.getRightFace() != null) {
// normal = a.getD(Normal.class, e.getRightFace());
// return normal;
// }
return normal;
}
@Override
public <N extends Node<?, ?, ?>> boolean canAccept(Class<N> nodeClass) {
return true;
}
@Override
public String toString() {
return "EdgeNormals";
}
}
......@@ -9,13 +9,13 @@ import de.jtem.halfedgetools.adapter.AdapterSet;
import de.jtem.halfedgetools.adapter.type.Label;
@Label
public class IndexLabelAdapter extends AbstractAdapter<String> {
public class IndexLabelAdapter extends AbstractAdapter<Integer> {
public IndexLabelAdapter() {
super(String.class, true, false);
super(Integer.class, true, false);
}
public IndexLabelAdapter(Class<? extends String> typeClass, boolean getter, boolean setter) {
public IndexLabelAdapter(Class<? extends Integer> typeClass, boolean getter, boolean setter) {
super(typeClass, getter, setter);
}
......@@ -35,8 +35,8 @@ public class IndexLabelAdapter extends AbstractAdapter<String> {
E extends Edge<V, E, F>,
F extends Face<V, E, F>,
N extends Node<V, E, F>
> String get(N n, AdapterSet a) {
return "" + n.getIndex();
> Integer get(N n, AdapterSet a) {
return n.getIndex();
}
}
package de.jtem.halfedgetools.adapter.type;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface EdgeNormal {
}
package de.jtem.halfedgetools.plugin.data.visualizer;
import de.jreality.math.Matrix;
import de.jreality.util.Rectangle3D;
import de.jtem.halfedge.Edge;
import de.jtem.halfedge.Face;
import de.jtem.halfedge.Node;
import de.jtem.halfedge.Vertex;
import de.jtem.halfedgetools.adapter.AdapterSet;
public abstract class AbstractLabelPosition implements LabelPosition {
protected double
marginFactor = 1.0,
offset = 0.0;
/**
* Gives the converted absolute margin factor.
*/
public double getMarginFactor(){
return marginFactor*getDefaultMargin();
}
public void setMarginFactor(double marginFactor){
this.marginFactor = marginFactor;//getDefaultMargin();
}
/**
* Gives the standard default margin fitting best for this LabelPosition class.
*/
public abstract double getDefaultMargin();
public double getOffset(){
return offset;
}
public void setOffset(double offset){
this.offset = offset;
}
@Override
public Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Node<?, ?, ?> n, AdapterSet as, boolean horizontalFlip, boolean verticalFlip) {
if(Vertex.class.isAssignableFrom(n.getClass())) {
return getTransformationMatrix(labelBoundingBox, (Vertex<?,?,?>)n, as, horizontalFlip, verticalFlip);
} else if(Edge.class.isAssignableFrom(n.getClass())) {
return getTransformationMatrix(labelBoundingBox, (Edge<?,?,?>)n, as, horizontalFlip, verticalFlip);
} else if(Face.class.isAssignableFrom(n.getClass())) {
return getTransformationMatrix(labelBoundingBox, (Face<?,?,?>)n, as, horizontalFlip, verticalFlip);
}
return null;
}
@Override
public abstract Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Vertex<?, ?, ?> v, AdapterSet as, boolean horizontalFlip, boolean verticalFlip);
@Override
public abstract Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Edge<?, ?, ?> e, AdapterSet as, boolean horizontalFlip, boolean verticalFlip);
@Override
public abstract Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Face<?, ?, ?> f, AdapterSet as, boolean horizontalFlip, boolean verticalFlip);
}
/**
*
*/
package de.jtem.halfedgetools.plugin.data.visualizer;
import de.jreality.math.Matrix;
import de.jreality.math.MatrixBuilder;
import de.jreality.math.Rn;
import de.jreality.util.Rectangle3D;
import de.jtem.halfedge.Edge;
import de.jtem.halfedge.Face;
import de.jtem.halfedgetools.adapter.AdapterSet;
import de.jtem.halfedgetools.adapter.type.EdgeNormal;
import de.jtem.halfedgetools.adapter.type.Normal;
import de.jtem.halfedgetools.adapter.type.generic.BaryCenter3d;
import de.jtem.halfedgetools.adapter.type.generic.EdgeVector;
/**
* @author hinzmann
*
*/
public class AlongEdgeLabelPosition extends ZUpLabelPosition {
@Override
public String toString(){
return "along Edge";
}
@Override
public Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Edge<?, ?, ?> e, AdapterSet as, boolean horizontalFlip, boolean verticalFlip) {
double[] labelbbCenter = labelBoundingBox.getCenter();
double[] edgeVector = as.getD(EdgeVector.class, e); //get edge as vector
// Face<?,?,?> face = e.getLeftFace();
double marginFactor = getMarginFactor();
// if(face == null) {
// face = e.getRightFace();
// }
// double[] faceNormal = (face == null)?new double[]{0,0,1}:as.getD(Normal.class, face);
// double[] faceNormal = (face == null)?as.getD(EdgeNormal.class, e):as.getD(Normal.class, face);
double[] faceNormal = as.getD(EdgeNormal.class, e);
double[][] edgeCoordinateSystem = new double[3][3];
edgeCoordinateSystem[2] = faceNormal; //the faces normal (will become labels z-direction by making a matrix out of these vectors)
edgeCoordinateSystem[1] = Rn.crossProduct(null, faceNormal, edgeVector); //vector orthogonal both to the edge and the faces normal, i.e. the vector orthogonal to the edge and lying in the face (will get labels y-direction)
Rn.normalize(edgeCoordinateSystem[1], edgeCoordinateSystem[1]); //normalize it
edgeCoordinateSystem[0] = edgeVector; //the edge (will become labels x-direction)
Rn.normalize(edgeCoordinateSystem[0], edgeCoordinateSystem[0]); //normalize it
double[] edgeCenter = as.getD(BaryCenter3d.class, e);
// double[] faceCenter = as.getD(BaryCenter3d.class, e.getLeftFace());
// Rn.linearCombination(edgeCenter, 0.95, edgeCenter, 0.05, faceCenter);
Rn.add(edgeCenter, edgeCenter, Rn.times(null, marginFactor, edgeCoordinateSystem[1])); //add a bit margin by "translating" edgeCenter
//for offsetting the label, move the edgeCenter with factor offset in direction of the facenormal
Rn.add(edgeCenter, edgeCenter, Rn.times(null, offset, faceNormal));
double[] anchorPoint = new double[3];
anchorPoint[0] = labelBoundingBox.getCenter()[0]; //take the x-coord of the center as x-coordinate for the anchorpoint
anchorPoint[1] = labelBoundingBox.getMinY(); //and choose minY as y-coordinate
anchorPoint[2] = labelBoundingBox.getMinZ(); //and we always take the min in z-direction, such that a 3D-label-boundingbox would stick out to the geometry's outside
Matrix M = getTransformationMatrix(edgeCoordinateSystem, edgeCenter); //puts together the coord-vectors to a matrix which will be the transformation of x-axis -> edgeCoordinateSystem[0], y-axis -> edgeCoordinateSystem[1], z-axis -> edgeCoordinateSystem[2] and the translation by edgeCenter
M.multiplyOnRight(MatrixBuilder.euclidean().translate(Rn.negate(null, anchorPoint)).getMatrix());
if(horizontalFlip || verticalFlip){
M.multiplyOnRight(MatrixBuilder.euclidean().translate(labelbbCenter).getMatrix());
if(horizontalFlip){
M.multiplyOnRight(MatrixBuilder.euclidean().rotateY(Math.PI).getMatrix());
}
if(verticalFlip){
M.multiplyOnRight(MatrixBuilder.euclidean().rotateX(Math.PI).getMatrix());
}
M.multiplyOnRight(MatrixBuilder.euclidean().translate(Rn.negate(null, labelbbCenter)).getMatrix());
}
return M;
//TEST: the following did not work... but thought it should do the same
// double[] edgeVector = as.getD(EdgeVector.class, e); //get edge as vector
// double[] normedEdgeVector = Rn.normalize(null, edgeVector);
// double[] faceNormal = as.getD(Normal.class, e.getLeftFace());
// double[] orthogToEdge = Rn.crossProduct(null, faceNormal, edgeVector);
// Rn.normalize(orthogToEdge, orthogToEdge);
//
// double[] edgeCenter = as.getD(BaryCenter3d.class, e);
//// double[] faceCenter = as.getD(BaryCenter3d.class, e.getLeftFace());
//// Rn.linearCombination(edgeCenter, 0.95, edgeCenter, 0.05, faceCenter);
// double marginFactor = 0.03;
// Rn.add(edgeCenter, edgeCenter, Rn.times(null, marginFactor, orthogToEdge)); //add a bit margin by "translating" edgeCenter
//
// double[] anchorPoint = new double[3];
// anchorPoint[0] = labelBoundingBox.getCenter()[0]; //take the x-coord of the center as x-coordinate for the anchorpoint
// anchorPoint[1] = labelBoundingBox.getMinY(); //and choose minY as y-coordinate
// anchorPoint[2] = labelBoundingBox.getMinZ(); //and we always take the min in z-direction, such that a 3D-label-boundingbox would stick out to the geometry's outside
//
// Matrix M = MatrixBuilder.euclidean() //generate the trafo-matrix, done/to read from bottom to top
// .translate(edgeCenter) //translate the label to the vertex position
// .rotateFromTo(new double[]{1,0,0}, normedEdgeVector)
// .rotateFromTo(new double[]{0,1,0}, orthogToEdge)
// .rotateFromTo(new double[]{0,0,1}, faceNormal) //new double[]{0, 0,1}, normal) //rotate the updirection to the vertexnormal
// .getMatrix();
// if(labelFlip){
// M.multiplyOnRight(MatrixBuilder.euclidean().rotateY(Math.PI).getMatrix()); //if the label shall be flipped: rotate it 180degree around central axis of its boundingbox (since translated in the origin this is the y-axis)
// }
// M.multiplyOnRight(MatrixBuilder.euclidean().translate(Rn.negate(null, anchorPoint)).getMatrix()); //translate the labels center to the origin
//
// return M;
}
/**
* Gives the standard default margin fitting best for this LabelPosition class.
*/
@Override
public double getDefaultMargin() {
return 0.03;
}
}
package de.jtem.halfedgetools.plugin.data.visualizer;
import de.jreality.math.Matrix;
import de.jreality.util.Rectangle3D;
import de.jtem.halfedge.Edge;
import de.jtem.halfedge.Face;
import de.jtem.halfedge.Node;
import de.jtem.halfedge.Vertex;
import de.jtem.halfedgetools.adapter.AdapterSet;
public interface LabelPosition {
public void setMarginFactor(double marginFactor);
public void setOffset(double offset);
public Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Node<?,?,?> n, AdapterSet as, boolean horizontalFlip, boolean verticalFlip);
public Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Vertex<?,?,?> v, AdapterSet as, boolean horizontalFlip, boolean verticalFlip);
public Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Edge<?, ?, ?> e, AdapterSet as, boolean horizontalFlip, boolean verticalFlip);
public Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Face<?,?,?> f, AdapterSet as, boolean horizontalFlip, boolean verticalFlip);
}
......@@ -29,7 +29,8 @@ import java.util.List;
import static de.jreality.shader.CommonAttributes.*;
public class VectorFieldVisualizer extends DataVisualizerPlugin implements
public class
VectorFieldVisualizer extends DataVisualizerPlugin implements
ActionListener, ChangeListener, SelectionListener {
private SpinnerNumberModel
......