Commit d447bb58 authored by Thilo Rörig's avatar Thilo Rörig

Added some boundary treatment to LabelPositions for Visualizer, added

IndexLabelAdapter to generic adapter set,
changed return type of IndexLabelAdapter to Integer
parent a410cb30
......@@ -22,6 +22,7 @@ import de.jtem.halfedgetools.adapter.generic.EdgeLengthAdapter;
import de.jtem.halfedgetools.adapter.generic.EdgeLengthTexAdapter;
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 +482,7 @@ public class AdapterSet extends TreeSet<Adapter<?>> {
aSet.add(new EdgeVectorAdapter());
aSet.add(new EdgeLengthAdapter());
aSet.add(new EdgeLengthTexAdapter());
aSet.add(new IndexLabelAdapter());
return aSet;
}
......
......@@ -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();
}
}
......@@ -8,11 +8,11 @@ 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.Normal;
import de.jtem.halfedgetools.adapter.type.generic.BaryCenter3d;
import de.jtem.halfedgetools.adapter.type.generic.EdgeVector;
import de.jtem.halfedgetools.adapter.type.generic.Position3d;
/**
* @author hinzmann
......@@ -29,7 +29,13 @@ public class AlongEdgeLabelPosition extends ZUpLabelPosition {
public Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Edge<?, ?, ?> e, AdapterSet as, boolean labelFlip) {
double[] labelbbCenter = labelBoundingBox.getCenter();
double[] edgeVector = as.getD(EdgeVector.class, e); //get edge as vector
double[] faceNormal = as.getD(Normal.class, e.getLeftFace());
Face<?,?,?> face = e.getLeftFace();
double marginFactor = 0.03;
if(face == null) {
face = e.getRightFace();
}
double[] faceNormal = (face == null)?new double[]{0,0,1}:as.getD(Normal.class, face);
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)
......@@ -41,7 +47,7 @@ public class AlongEdgeLabelPosition extends ZUpLabelPosition {
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, edgeCoordinateSystem[1])); //add a bit margin by "translating" edgeCenter
double[] anchorPoint = new double[3];
......
......@@ -44,13 +44,22 @@ public class ZUpLabelPosition extends AbstractLabelPosition {
public Matrix getTransformationMatrix(Rectangle3D labelBoundingBox, Edge<?, ?, ?> e, AdapterSet as, boolean labelFlip) {
double[] labelbbCenter = labelBoundingBox.getCenter();
double[] edgeVector = as.getD(EdgeVector.class, e); //get edge as vector
double[][] localCoordinateSystem = getFacesCoordinateSystem(e.getLeftFace(),as);
Face<?,?,?> face = e.getLeftFace();
double offset = 0.05;
if(face == null) {
face = e.getRightFace();
offset *= -1.0;
}
if(face == null) {
return null;
}
double[][] localCoordinateSystem = getFacesCoordinateSystem(face,as);
double[] anchorPoint = getAnchorPoint(edgeVector, localCoordinateSystem, labelBoundingBox);
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[] faceCenter = as.getD(BaryCenter3d.class, face);
Rn.linearCombination(edgeCenter, 0.95, edgeCenter, offset, faceCenter);
Matrix M = getTransformationMatrix(localCoordinateSystem, edgeCenter);
M.multiplyOnRight(MatrixBuilder.euclidean().translate(Rn.negate(null, anchorPoint)).getMatrix());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment