Commit 6709175f authored by Robert Smith's avatar Robert Smith
Browse files

Mesh data structure refactor and Mesh Editor JavaFX implementation



Created Mesh data structures based on the unifed modeling structures.
Also began work on the JavaFX version of the Mesh Editor.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent db08efe1
......@@ -27,16 +27,10 @@ import org.eclipse.ice.viz.service.jme3.mesh.MeshAppStateMode;
import org.eclipse.ice.viz.service.jme3.mesh.MeshAppStateModeFactory;
import org.eclipse.ice.viz.service.jme3.mesh.MeshAppStateModeFactory.Mode;
import org.eclipse.ice.viz.service.jme3.mesh.MeshSelectionManager;
import org.eclipse.ice.viz.service.mesh.datastructures.BezierEdge;
import org.eclipse.ice.viz.service.mesh.datastructures.Edge;
import org.eclipse.ice.viz.service.mesh.datastructures.Hex;
import org.eclipse.ice.viz.service.mesh.datastructures.IMeshPartVisitor;
import org.eclipse.ice.viz.service.mesh.datastructures.Polygon;
import org.eclipse.ice.viz.service.mesh.datastructures.PolynomialEdge;
import org.eclipse.ice.viz.service.mesh.datastructures.Quad;
import org.eclipse.ice.viz.service.mesh.datastructures.Vertex;
import org.eclipse.ice.viz.service.mesh.datastructures.VizMeshComponent;
import org.eclipse.ice.viz.service.mesh.properties.MeshSelection;
import org.eclipse.ice.viz.service.modeling.Edge;
import org.eclipse.ice.viz.service.modeling.Face;
import org.eclipse.ice.viz.service.modeling.Vertex;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.ToolBarManager;
......@@ -392,55 +386,6 @@ public class ICEMeshPage extends ICEFormPage
final List<Integer> edgeIds = new ArrayList<Integer>();
final List<Integer> polygonIds = new ArrayList<Integer>();
// Create a visitor to populate the above lists of IDs
IMeshPartVisitor visitor = new IMeshPartVisitor() {
@Override
public void visit(Vertex vertex) {
vertexIds.add(vertex.getId());
}
@Override
public void visit(PolynomialEdge edge) {
visit((Edge) edge);
}
@Override
public void visit(BezierEdge edge) {
visit((Edge) edge);
}
@Override
public void visit(Edge edge) {
edgeIds.add(edge.getId());
}
@Override
public void visit(Hex hex) {
visit((Polygon) hex);
}
@Override
public void visit(Quad quad) {
visit((Polygon) quad);
}
@Override
public void visit(Polygon polygon) {
polygonIds.add(polygon.getId());
}
@Override
public void visit(Object object) {
// Do nothing.
}
@Override
public void visit(VizMeshComponent mesh) {
// Do nothing.
}
};
// Get each element from the selection and add the ID for the
// corresponding vertex/edge/polygon to one of the above lists.
// These lists will be sent to the selection manager later.
......@@ -448,7 +393,20 @@ public class ICEMeshPage extends ICEFormPage
if (element instanceof MeshSelection) {
MeshSelection meshSelection = (MeshSelection) element;
meshSelection.selectedMeshPart.acceptMeshVisitor(visitor);
if (meshSelection.selectedMeshPart instanceof Vertex) {
vertexIds.add(
Integer.valueOf(meshSelection.selectedMeshPart
.getProperty("Id")));
} else if (meshSelection.selectedMeshPart instanceof Edge) {
edgeIds.add(
Integer.valueOf(meshSelection.selectedMeshPart
.getProperty("Id")));
} else if (meshSelection.selectedMeshPart instanceof Face) {
polygonIds.add(
Integer.valueOf(meshSelection.selectedMeshPart
.getProperty("Id")));
}
}
}
......
......@@ -18,12 +18,9 @@ import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener;
import org.eclipse.ice.datastructures.form.Form;
import org.eclipse.ice.datastructures.form.MeshComponent;
import org.eclipse.ice.viz.service.datastructures.VizObject.VizObject;
import org.eclipse.ice.viz.service.mesh.datastructures.Edge;
import org.eclipse.ice.viz.service.mesh.datastructures.IMeshPart;
import org.eclipse.ice.viz.service.mesh.datastructures.Polygon;
import org.eclipse.ice.viz.service.mesh.datastructures.Vertex;
import org.eclipse.ice.viz.service.mesh.properties.MeshSelection;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.Face;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
......@@ -49,8 +46,8 @@ import org.slf4j.LoggerFactory;
*
* @author Taylor Patterson
*/
public class MeshElementTreeView extends ViewPart implements
IUpdateableListener, IPartListener2, ISelectionListener,
public class MeshElementTreeView extends ViewPart
implements IUpdateableListener, IPartListener2, ISelectionListener,
ITabbedPropertySheetPageContributor {
/**
......@@ -194,12 +191,12 @@ public class MeshElementTreeView extends ViewPart implements
public Object[] getElements(Object inputElement) {
// Local Declaration
ArrayList<Polygon> allElements = (ArrayList<Polygon>) inputElement;
ArrayList<Face> allElements = (ArrayList<Face>) inputElement;
ArrayList<MeshSelection> contents = new ArrayList<MeshSelection>();
// Wrap the Polygons into PropertySources and add them to
// the array
for (Polygon i : allElements) {
for (Face i : allElements) {
contents.add(new MeshSelection(meshComponent.getMesh(), i));
}
......@@ -226,15 +223,31 @@ public class MeshElementTreeView extends ViewPart implements
// Load edges and vertices as children of polygons
ArrayList<MeshSelection> children = new ArrayList<MeshSelection>();
if (selection.selectedMeshPart instanceof Polygon) {
Polygon polygon = (Polygon) selection.selectedMeshPart;
// An array of every unique vertex from the selection
ArrayList<AbstractController> vertices = new ArrayList<AbstractController>();
if (selection.selectedMeshPart instanceof Face) {
Face polygon = (Face) selection.selectedMeshPart;
// Add new MeshSelections for the edges.
for (Edge e : polygon.getEdges()) {
children.add(new MeshSelection(meshComponent.getMesh(), e));
for (AbstractController e : polygon
.getEntitiesByCategory("Edges")) {
children.add(new MeshSelection(
meshComponent.getMesh(), e));
// Add each of the edge's vertices to the list if
// they are nto already present
for (AbstractController v : e
.getEntitiesByCategory("Vertices")) {
if (!vertices.contains(v)) {
vertices.add(v);
}
}
}
// Add new MeshSelections for the vertices.
for (Vertex v : polygon.getVertices()) {
children.add(new MeshSelection(meshComponent.getMesh(), v));
for (AbstractController v : vertices) {
children.add(new MeshSelection(
meshComponent.getMesh(), v));
}
}
......@@ -264,7 +277,8 @@ public class MeshElementTreeView extends ViewPart implements
public boolean hasChildren(Object element) {
// Only selected Polygons will have children.
return (element instanceof MeshSelection && ((MeshSelection) element).selectedMeshPart instanceof Polygon);
return (element instanceof MeshSelection
&& ((MeshSelection) element).selectedMeshPart instanceof Face);
}
});
......@@ -295,12 +309,12 @@ public class MeshElementTreeView extends ViewPart implements
if (element instanceof MeshSelection) {
// Get the wrapped IMeshPart.
IMeshPart meshPart = ((MeshSelection) element).selectedMeshPart;
AbstractController meshPart = ((MeshSelection) element).selectedMeshPart;
// Cast the IMeshPart to an ICEObject and set the label text
// from its name and ID.
VizObject object = (VizObject) meshPart;
label = object.getName() + " " + object.getId();
label = meshPart.getProperty("Name") + " "
+ meshPart.getProperty("Id");
return label;
}
......
......@@ -16,10 +16,10 @@ import java.util.ArrayList;
import java.util.Hashtable;
import org.eclipse.ice.client.common.PropertySource;
import org.eclipse.ice.viz.service.mesh.datastructures.Edge;
import org.eclipse.ice.viz.service.mesh.datastructures.IMeshPart;
import org.eclipse.ice.viz.service.mesh.datastructures.Polygon;
import org.eclipse.ice.viz.service.mesh.datastructures.Vertex;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.Edge;
import org.eclipse.ice.viz.service.modeling.Face;
import org.eclipse.ice.viz.service.modeling.Vertex;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
......@@ -63,8 +63,8 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
new PropertyDescriptor(ID_LENGTH, "Length"),
new PropertyDescriptor(ID_STARTLOC, "Start Location"),
new PropertyDescriptor(ID_ENDLOC, "End Location") };
vertexDescriptors = new IPropertyDescriptor[] { new PropertyDescriptor(
ID_LOCATION, "Location") };
vertexDescriptors = new IPropertyDescriptor[] {
new PropertyDescriptor(ID_LOCATION, "Location") };
}
/**
......@@ -77,7 +77,7 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
*/
static {
propDescMap = new Hashtable<Class<?>, IPropertyDescriptor[]>();
propDescMap.put(Polygon.class, polygonDescriptors);
propDescMap.put(Face.class, polygonDescriptors);
propDescMap.put(Edge.class, edgeDescriptors);
propDescMap.put(Vertex.class, vertexDescriptors);
}
......@@ -124,22 +124,24 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
@Override
public Object getValue(Object data, Object id) {
Polygon polygon = (Polygon) data;
Face polygon = (Face) data;
ArrayList<String> propertySet = new ArrayList<String>();
// If the caller seeks the edges, get them from the wrapped
// Polygon.
if (ID_EDGES.equals(id)) {
for (Edge e : polygon.getEdges()) {
propertySet.add("Edge " + e.getId());
for (AbstractController e : polygon
.getEntitiesByCategory("Edges")) {
propertySet.add("Edge " + e.getProperty("Id"));
}
return propertySet;
}
// If the caller seeks the vertices, get them from the wrapped
// Polygon.
else if (ID_VERTICES.equals(id)) {
for (Vertex v : polygon.getVertices()) {
propertySet.add("Vertex " + v.getId());
for (AbstractController v : polygon
.getEntitiesByCategory("Vertices")) {
propertySet.add("Vertex " + v.getProperty("Id"));
}
return propertySet;
}
......@@ -165,8 +167,10 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
// Collect the given edge's vertices
if (ID_VERTICES.equals(id)) {
for (int vId : edge.getVertexIds()) {
propertySet.add("Vertex " + vId);
for (AbstractController vertex : edge
.getEntitiesByCategory("Vertices")) {
propertySet.add("Vertex "
+ Integer.valueOf(vertex.getProperty("Id")));
}
return propertySet;
}
......@@ -176,17 +180,17 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
}
// Get the edge's start location
else if (ID_STARTLOC.equals(id)) {
float[] loc = edge.getStartLocation();
double[] loc = edge.getStartLocation();
for (int i = 0; i < loc.length; i++) {
propertySet.add(((Float) loc[i]).toString());
propertySet.add(((Double) loc[i]).toString());
}
return propertySet;
}
// Get the edge's end location
else if (ID_ENDLOC.equals(id)) {
float[] loc = edge.getEndLocation();
double[] loc = edge.getEndLocation();
for (int i = 0; i < loc.length; i++) {
propertySet.add(((Float) loc[i]).toString());
propertySet.add(((Double) loc[i]).toString());
}
return propertySet;
}
......@@ -212,9 +216,9 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
// Get the vertex's location
if (ID_LOCATION.equals(id)) {
float[] loc = vertex.getLocation();
double[] loc = vertex.getLocation();
for (int i = 0; i < loc.length; i++) {
propertySet.add(((Float) loc[i]).toString());
propertySet.add(((Double) loc[i]).toString());
}
return propertySet;
}
......@@ -228,7 +232,7 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
// Populate the handler map
propHandlerMap = new Hashtable<Class<?>, IPropertyTypeHandler>();
propHandlerMap.put(Polygon.class, polygonPropertyHandler);
propHandlerMap.put(Face.class, polygonPropertyHandler);
propHandlerMap.put(Edge.class, edgePropertyHandler);
propHandlerMap.put(Vertex.class, vertexPropertyHandler);
......@@ -241,7 +245,7 @@ public class MeshElementTreeViewPropertySource extends PropertySource {
* The object to be wrapped by PropertySource. For this subclass,
* this will be a Polygon, Edge, or Vertex.
*/
public MeshElementTreeViewPropertySource(IMeshPart part) {
public MeshElementTreeViewPropertySource(AbstractController part) {
// Just call the superclass constructor
super(part);
......
......@@ -13,6 +13,7 @@
package org.eclipse.ice.datastructures.form;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
......@@ -23,12 +24,10 @@ import org.eclipse.ice.datastructures.ICEObject.ICEObject;
import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateable;
import org.eclipse.ice.viz.service.datastructures.VizObject.IVizUpdateableListener;
import org.eclipse.ice.viz.service.mesh.datastructures.Edge;
import org.eclipse.ice.viz.service.mesh.datastructures.IMeshPart;
import org.eclipse.ice.viz.service.mesh.datastructures.IMeshPartVisitor;
import org.eclipse.ice.viz.service.mesh.datastructures.Polygon;
import org.eclipse.ice.viz.service.mesh.datastructures.Vertex;
import org.eclipse.ice.viz.service.mesh.datastructures.VizMeshComponent;
import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.Edge;
import org.eclipse.ice.viz.service.modeling.Face;
import org.eclipse.ice.viz.service.modeling.Vertex;
/**
* <p>
......@@ -42,13 +41,28 @@ import org.eclipse.ice.viz.service.mesh.datastructures.VizMeshComponent;
*/
@XmlRootElement(name = "MeshComponent")
@XmlAccessorType(XmlAccessType.FIELD)
public class MeshComponent extends ICEObject implements Component, IMeshPart,
IVizUpdateableListener {
public class MeshComponent extends ICEObject
implements Component, IVizUpdateableListener {
/**
* The wrapped VizMeshComponent.
*/
private VizMeshComponent mesh;
private AbstractController mesh;
/**
* The next unused ID for polygons.
*/
private int nextPolygonID;
/**
* The next unused ID for vertices.
*/
private int nextVertexID;
/**
* The next unused ID for edges.
*/
private int nextEdgeID;
/**
* <p>
......@@ -59,7 +73,7 @@ public class MeshComponent extends ICEObject implements Component, IMeshPart,
*/
public MeshComponent() {
super();
mesh = new VizMeshComponent();
mesh = new AbstractController();
mesh.register(this);
return;
}
......@@ -69,7 +83,7 @@ public class MeshComponent extends ICEObject implements Component, IMeshPart,
*
* @return The wrapped VizMeshComponent
*/
public VizMeshComponent getMesh() {
public AbstractController getMesh() {
return mesh;
}
......@@ -79,7 +93,7 @@ public class MeshComponent extends ICEObject implements Component, IMeshPart,
* @param newMesh
* The new mesh to hold
*/
public void setMesh(VizMeshComponent newMesh) {
public void setMesh(AbstractController newMesh) {
mesh = newMesh;
}
......@@ -97,8 +111,8 @@ public class MeshComponent extends ICEObject implements Component, IMeshPart,
* The new polygon to add to the existing list.
* </p>
*/
public void addPolygon(Polygon polygon) {
mesh.addPolygon(polygon);
public void addPolygon(Face polygon) {
mesh.addEntity(polygon);
notifyListeners();
return;
......@@ -117,8 +131,20 @@ public class MeshComponent extends ICEObject implements Component, IMeshPart,
* </p>
*/
public void removePolygon(int id) {
mesh.removePolygon(id);
notifyListeners();
// Check each entity for the given id
for (AbstractController entity : mesh.getEntities()) {
// If the id was found, remove the corresponding entity from the
// list
if (Integer.toString(id).equals(entity.getProperty("Id"))) {
mesh.removeEntity(entity);
// Notify listeners of the change
notifyListeners();
return;
}
}
return;
}
......@@ -137,8 +163,11 @@ public class MeshComponent extends ICEObject implements Component, IMeshPart,
* </p>
*/
public void removePolygons(ArrayList<Integer> ids) {
mesh.removePolygons(ids);
notifyListeners();
// Remove each individual id in the list
for (int i : ids) {
removePolygon(i);
}
return;
}
......@@ -148,12 +177,13 @@ public class MeshComponent extends ICEObject implements Component, IMeshPart,
* IDs.
* </p>
*
* @return <p>
* @return
* <p>
* A list of polygons contained in this MeshComponent.
* </p>
*/
public ArrayList<Polygon> getPolygons() {
return mesh.getPolygons();
public List<AbstractController> getPolygons() {
return mesh.getEntities();
}
/**
......@@ -165,13 +195,22 @@ public class MeshComponent extends ICEObject implements Component, IMeshPart,
* <p>
* The ID of the polygon.
* </p>
* @return <p>
* @return
* <p>
* The polygon referred to by the ID, or null if there is no polygon
* with the ID.
* </p>
*/
public Polygon getPolygon(int id) {
return mesh.getPolygon(id);
public AbstractController getPolygon(int id) {
// Seach the entities for a polygon with the given ID
for (AbstractController entity : mesh.getEntities()) {
if (id == Integer.valueOf(entity.getProperty("Id"))) {
return entity;
}
}
return null;
}
/**
......@@ -179,40 +218,66 @@ public class MeshComponent extends ICEObject implements Component, IMeshPart,
* Returns the next available ID for polygons.
* </p>
*
* @return <p>
* @return
* <p>
* The greatest polygon ID (or zero) plus one.
* </p>
*/
public int getNextPolygonId() {
return mesh.getNextPolygonId();
}
/**
* <p>
* Sets the list of all polygons stored in the MeshComponent.
* </p>
*
* @param polygons
* <p>
* The list of polygons to replace the existing list of polygons
* in the MeshComponent.
* </p>
*/
public void setPolygons(ArrayList<Polygon> polygons) {
mesh.setPolygons(polygons);
// Increment the next polygon id then return its original value
int temp = nextPolygonID;
nextPolygonID++;
return temp;
}
// /**
// * <p>
// * Sets the list of all polygons stored in the MeshComponent.
// * </p>
// *
// * @param polygons
// * <p>
// * The list of polygons to replace the existing list of polygons
// * in the MeshComponent.
// * </p>
// */
// public void setPolygons(ArrayList<Polygon> polygons) {
// mesh.setPolygons(polygons);
// }
/**
* <p>
* Gets a list of all vertices associated with this MeshComponent.
* </p>
*
* @return <p>
* @return
* <p>
* All vertices managed by this MeshComponent.
* </p>
*/
public ArrayList<Vertex> getVertices() {
return mesh.getVertices();
public List<AbstractController> getVertices() {
// A list of every unique vertex
List<AbstractController> vertices = new ArrayList<AbstractController>();
// Get every vertex
for (AbstractController face : mesh.getEntities()) {
for (AbstractController edge : face
.getEntitiesByCategory("Edges")) {
for (AbstractController vertex : edge
.getEntitiesByCategory("Vertices")) {
// If the vertex is not already in the list, add it