Commit 2e1182f9 authored by Robert Smith's avatar Robert Smith
Browse files

Continued updating MeshComponentTester



Made further changes to MeshComponentTester to work with the changed
Mesh Editor.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 5c02b279
...@@ -26,9 +26,9 @@ import org.eclipse.ice.viz.service.mesh.datastructures.NekPolygonComponent; ...@@ -26,9 +26,9 @@ import org.eclipse.ice.viz.service.mesh.datastructures.NekPolygonComponent;
import org.eclipse.ice.viz.service.modeling.AbstractController; import org.eclipse.ice.viz.service.modeling.AbstractController;
import org.eclipse.ice.viz.service.modeling.AbstractView; import org.eclipse.ice.viz.service.modeling.AbstractView;
import org.eclipse.ice.viz.service.modeling.Edge; import org.eclipse.ice.viz.service.modeling.Edge;
import org.eclipse.ice.viz.service.modeling.EdgeComponent;
import org.eclipse.ice.viz.service.modeling.FaceEdge; import org.eclipse.ice.viz.service.modeling.FaceEdge;
import org.eclipse.ice.viz.service.modeling.FaceEdgeComponent; import org.eclipse.ice.viz.service.modeling.FaceEdgeComponent;
import org.eclipse.ice.viz.service.modeling.LinearEdgeComponent;
import org.eclipse.ice.viz.service.modeling.Vertex; import org.eclipse.ice.viz.service.modeling.Vertex;
import org.eclipse.ice.viz.service.modeling.VertexComponent; import org.eclipse.ice.viz.service.modeling.VertexComponent;
import org.junit.Test; import org.junit.Test;
...@@ -132,7 +132,7 @@ public class MeshComponentTester { ...@@ -132,7 +132,7 @@ public class MeshComponentTester {
// Set up the edges. // Set up the edges.
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
edges.add(new Edge( edges.add(new Edge(
new EdgeComponent((Vertex) vertices.get(i), new LinearEdgeComponent((Vertex) vertices.get(i),
(Vertex) vertices.get((i + 1) % 4)), (Vertex) vertices.get((i + 1) % 4)),
new AbstractView())); new AbstractView()));
allEdges.add(edges.get(i)); allEdges.add(edges.get(i));
...@@ -184,7 +184,7 @@ public class MeshComponentTester { ...@@ -184,7 +184,7 @@ public class MeshComponentTester {
for (int i = 1; i < 4; i++) { for (int i = 1; i < 4; i++) {
edges.set(i, edges.set(i,
new Edge( new Edge(
new EdgeComponent((Vertex) vertices.get(i), new LinearEdgeComponent((Vertex) vertices.get(i),
(Vertex) vertices.get((i + 1) % 4)), (Vertex) vertices.get((i + 1) % 4)),
new AbstractView())); new AbstractView()));
allEdges.add(edges.get(i)); allEdges.add(edges.get(i));
...@@ -233,7 +233,7 @@ public class MeshComponentTester { ...@@ -233,7 +233,7 @@ public class MeshComponentTester {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
edges.set(i, edges.set(i,
new Edge( new Edge(
new EdgeComponent((Vertex) vertices.get(i), new LinearEdgeComponent((Vertex) vertices.get(i),
(Vertex) vertices.get((i + 1) % 4)), (Vertex) vertices.get((i + 1) % 4)),
new AbstractView())); new AbstractView()));
allEdges.add(edges.get(i)); allEdges.add(edges.get(i));
...@@ -283,7 +283,7 @@ public class MeshComponentTester { ...@@ -283,7 +283,7 @@ public class MeshComponentTester {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
edges.set(i, edges.set(i,
new Edge( new Edge(
new EdgeComponent((Vertex) vertices.get(i), new LinearEdgeComponent((Vertex) vertices.get(i),
(Vertex) vertices.get((i + 1) % 4)), (Vertex) vertices.get((i + 1) % 4)),
new AbstractView())); new AbstractView()));
allEdges.add(edges.get(i)); allEdges.add(edges.get(i));
...@@ -588,7 +588,7 @@ public class MeshComponentTester { ...@@ -588,7 +588,7 @@ public class MeshComponentTester {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
edges.add( edges.add(
new Edge( new Edge(
new EdgeComponent(vertices.get(i), new LinearEdgeComponent(vertices.get(i),
vertices.get((i + 1) % 3)), vertices.get((i + 1) % 3)),
new AbstractView())); new AbstractView()));
edges.get(i).setProperty("Id", Integer.toString(i + 1)); edges.get(i).setProperty("Id", Integer.toString(i + 1));
...@@ -609,7 +609,7 @@ public class MeshComponentTester { ...@@ -609,7 +609,7 @@ public class MeshComponentTester {
for (int i = 1; i < 3; i++) { for (int i = 1; i < 3; i++) {
edges.set(i, edges.set(i,
new Edge( new Edge(
new EdgeComponent(vertices.get(i), new LinearEdgeComponent(vertices.get(i),
vertices.get((i + 1) % 3)), vertices.get((i + 1) % 3)),
new AbstractView())); new AbstractView()));
edges.get(i).setProperty("Id", Integer.toString(i + 3)); edges.get(i).setProperty("Id", Integer.toString(i + 3));
...@@ -752,7 +752,7 @@ public class MeshComponentTester { ...@@ -752,7 +752,7 @@ public class MeshComponentTester {
} }
// Make sure the edges in the copy's first triangle were updated. // Make sure the edges in the copy's first triangle were updated.
for (int i = 1; i < 4; i++) { for (int i = 0; i < 3; i++) {
assertTrue(listeners.get(i).wasNotified()); assertTrue(listeners.get(i).wasNotified());
listeners.get(i).reset(); listeners.get(i).reset();
} }
......
...@@ -99,6 +99,46 @@ public class EdgeComponent extends AbstractMeshComponent { ...@@ -99,6 +99,46 @@ public class EdgeComponent extends AbstractMeshComponent {
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.modeling.AbstractMeshComponent#
* addEntityByCategory(org.eclipse.ice.viz.service.modeling.
* AbstractController, java.lang.String)
*/
@Override
public void addEntityByCategory(AbstractController entity,
String category) {
// When a vertex is added, take action to ensure the edge maintains a
// proper state
if ("Vertices".equals(category)) {
// The number of vertices
List<AbstractController> vertices = entities.get("Vertices");
int verticesNum = (vertices != null ? vertices.size() : 0);
// If the object is a vertex and the edge already has both vertices,
// fail silently.
if (verticesNum >= 2) {
return;
}
// Add the entity
super.addEntityByCategory(entity, category);
// If this was the second vertex, calculate the edge's new length.
if (verticesNum == 1) {
length = calculateLength();
}
}
// Otherwise, add the entity normally
else {
super.addEntityByCategory(entity, category);
}
}
/** /**
* Calculates the length of the edge. This method does nothing by default, * Calculates the length of the edge. This method does nothing by default,
* and is intended to be overwritten by subclasses. * and is intended to be overwritten by subclasses.
...@@ -182,9 +222,6 @@ public class EdgeComponent extends AbstractMeshComponent { ...@@ -182,9 +222,6 @@ public class EdgeComponent extends AbstractMeshComponent {
addEntity((Vertex) vertex.clone()); addEntity((Vertex) vertex.clone());
} }
// Copy the length
length = ((EdgeComponent) otherObject).length;
// Copy the rest of the data members and fire an update // Copy the rest of the data members and fire an update
// Copy each of the other component's data members // Copy each of the other component's data members
type = otherObject.type; type = otherObject.type;
......
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