Commit 4d0caa68 authored by Robert Smith's avatar Robert Smith
Browse files

Fixed repeated pipe bug



Work around for bug where pipes are being read from the composite
repeatedly with different locations. The converter now checks if a pipe
with that id already exists in the plant before placing it in the tree.
Since the first one read was always the correct one, this essentially
fixes the bug.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 80adb4d9
......@@ -10,6 +10,7 @@ Import-Package: org.eclipse.ice.datastructures.ICEObject,
org.eclipse.ice.viz.service.datastructures.VizObject,
org.eclipse.ice.viz.service.geometry.reactor,
org.eclipse.ice.viz.service.javafx.geometry,
org.eclipse.ice.viz.service.javafx.geometry.datatypes,
org.eclipse.ice.viz.service.javafx.geometry.plant,
org.eclipse.ice.viz.service.modeling,
org.eclipse.swt.widgets,
......
......@@ -75,6 +75,7 @@ public class FXPlantCompositeConverter
*
* @return A JavaFX modeling data structure representation fo the plant.
*/
@Override
public AbstractController getPlant() {
// If the output has not been initialized, create it
......@@ -194,7 +195,8 @@ public class FXPlantCompositeConverter
if (!found) {
// Convert the pipe into a modeling data structure
input.accept(this);
// input.accept(this);
source.getPlantComponent(input.getId()).accept(this);
// Refresh the list of pipes
pipeList = root.getEntitiesByCategory("Pipes");
......@@ -241,7 +243,8 @@ public class FXPlantCompositeConverter
if (!found) {
// Convert the pipe into a modeling data structure
output.accept(this);
// output.accept(this);
source.getPlantComponent(output.getId()).accept(this);
// Refresh the list of pipes
pipeList = root.getEntitiesByCategory("Pipes");
......@@ -326,7 +329,8 @@ public class FXPlantCompositeConverter
if (!found) {
// Convert the pipe into a modeling data structure
primary.accept(this);
// primary.accept(this);
source.getPlantComponent(primary.getId()).accept(this);
// Refresh the list of pipes
pipeList = root.getEntitiesByCategory("Pipes");
......@@ -366,7 +370,8 @@ public class FXPlantCompositeConverter
if (!found) {
// Convert the pipe into a modeling data structure
primary.accept(this);
// primary.accept(this);
source.getPlantComponent(secondary.getId()).accept(this);
// Refresh the list of pipes
pipeList = root.getEntitiesByCategory("Pipes");
......@@ -391,20 +396,68 @@ public class FXPlantCompositeConverter
@Override
public void visit(Pipe plantComp) {
// Convert the pipe and add it to the root.
root.addEntityByCategory(createPipe(plantComp), "Pipes");
// If this pipe has already been converted, ignore it
boolean found = false;
// Create a list of all pipes in the plant by combining the pipes
// with the core channels
List<AbstractController> pipeList = root
.getEntitiesByCategory("Pipes");
pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
// Check the root to see if a pipe with that id already exists
for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == plantComp
.getId()) {
// Match found, stop the search
found = true;
break;
}
}
if (!found) {
// Convert the pipe and add it to the root.
root.addEntityByCategory(createPipe(plantComp), "Pipes");
}
}
@Override
public void visit(CoreChannel plantComp) {
// Convert the pipe
PipeController pipe = createPipe(plantComp);
// If this pipe has already been converted, ignore it
boolean found = false;
// Set the pipe as a core channel and add it to the root
pipe.setProperty("Core Channel", "True");
root.addEntity(pipe);
// Create a list of all pipes in the plant by combining the pipes
// with the core channels
List<AbstractController> pipeList = root
.getEntitiesByCategory("Pipes");
pipeList.addAll(root.getEntitiesByCategory("Core Channels"));
// Check the root to see if a pipe with that id already exists
for (AbstractController pipe : pipeList) {
if (Integer.parseInt(pipe.getProperty("Id")) == plantComp
.getId()) {
// Match found, stop the search
found = true;
break;
}
}
if (!found) {
// Convert the pipe
PipeController pipe = createPipe(plantComp);
// Set the pipe as a core channel and add it to the root
pipe.setProperty("Core Channel", "True");
root.addEntity(pipe);
}
}
......@@ -586,6 +639,9 @@ public class FXPlantCompositeConverter
double[] orientation = plantComp.getOrientation();
// System.out.println("Pipe Position: " + position[0] + " "
// + position[1] + " " + position[2]);
// Normalize the orientation vector
double[] normalized = new double[3];
double length = Math.sqrt(
......@@ -629,28 +685,36 @@ public class FXPlantCompositeConverter
}
// If the pitch and yaw are both zero, then the orientation vector
// is pointing down one of the axes. The code in this case works for
// the x axis and other arbitrary angles.
if ((yRotation != 0 && zRotation != 0) || normalized[0] != 0) {
// Set the rotation, adding a 90 degree rotation on the z axis
// so that the pipe is pointing down the x axis by defualt
// is pointing down one of the axes. For other angles, we simple set
// the rotation
if ((yRotation != 0 && zRotation != 0)) {
pipe.setRotation(0, -Math.atan(yRotation),
-Math.atan(zRotation) - Math.PI / 2);
-Math.atan(zRotation));
}
// Explicitly set the pipe to point down the y or z axis
// Explicitly set the pipe to point down the x, y, or z axis
else {
// Rotate the pipe to point down the x axis by rotating about
// the z
if (normalized[0] > 0) {
pipe.setRotation(0, 0, -Math.PI / 2);
}
// Rotate in the other direction if the vector is negative
else if (normalized[0] < 0) {
pipe.setRotation(0, 0, Math.PI / 2);
}
// Rotate the pipe to point down the z axis by rotating about
// the x
if (normalized[2] > 0) {
else if (normalized[2] > 0) {
pipe.setRotation(Math.PI / 2, 0, 0);
}
// Rotate in the other direction if the vector is negative
else if (normalized[2] < 0) {
pipe.setRotation(Math.PI / 2, 0, 0);
pipe.setRotation(-Math.PI / 2, 0, 0);
}
// If the orientation is the negated y vector, flip the tube by
......@@ -658,7 +722,7 @@ public class FXPlantCompositeConverter
// positive y vector is the tube's default position, and thus
// does not need to be handled.
else if (normalized[1] < 0) {
pipe.setRotation(Math.PI, 0, 0);
pipe.setRotation(-Math.PI, 0, 0);
}
}
......
......@@ -193,10 +193,9 @@ public class GeometricalComponent extends PlantComponent {
notifyListeners();
}
} else {
throw new InvalidParameterException(
"GeometricalComponent error:"
+ "The orientation array must be non-null and 3 elements in"
+ "size.");
throw new InvalidParameterException("GeometricalComponent error:"
+ "The orientation array must be non-null and 3 elements in"
+ "size.");
}
return;
}
......@@ -263,7 +262,8 @@ public class GeometricalComponent extends PlantComponent {
* <p>
* The other Object to compare against.
* </p>
* @return <p>
* @return
* <p>
* Returns true if the two objects are equal, otherwise false.
* </p>
*/
......@@ -292,7 +292,8 @@ public class GeometricalComponent extends PlantComponent {
equals = (super.equals(component)
&& Arrays.equals(position, component.position)
&& Arrays.equals(orientation, component.orientation)
&& rotation == component.rotation && numElements == component.numElements);
&& rotation == component.rotation
&& numElements == component.numElements);
}
return equals;
......@@ -303,7 +304,8 @@ public class GeometricalComponent extends PlantComponent {
* Performs a deep copy and returns a newly instantiated Object.
* </p>
*
* @return <p>
* @return
* <p>
* The newly instantiated Object.
* </p>
*/
......@@ -351,7 +353,8 @@ public class GeometricalComponent extends PlantComponent {
* Returns the hashCode of the object.
* </p>
*
* @return <p>
* @return
* <p>
* The hashCode of the Object.
* </p>
*/
......
......@@ -90,7 +90,7 @@ public class PlantComposite extends PlantComponent
if (component != null) {
int id = component.getId();
// If the ID is availalble, add the component and notify listeners
// If the ID is available, add the component and notify listeners
// that a component has been added.
if (!components.containsKey(id)) {
components.put(id, component);
......
......@@ -13,12 +13,14 @@ package org.eclipse.ice.viz.service.javafx.geometry.plant;
import org.eclipse.ice.viz.service.geometry.reactor.Extrema;
import org.eclipse.ice.viz.service.geometry.reactor.PipeMesh;
import org.eclipse.ice.viz.service.geometry.reactor.PipeView;
import org.eclipse.ice.viz.service.geometry.shapes.ShapeType;
import org.eclipse.ice.viz.service.javafx.geometry.datatypes.FXShapeView;
import org.eclipse.ice.viz.service.modeling.AbstractMesh;
import org.eclipse.ice.viz.service.modeling.IWireFramePart;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Sphere;
/**
* A class managing the JavaFX graphical representation of a Pipe part.
......@@ -105,13 +107,6 @@ public class FXPipeView extends FXShapeView
double[] skew = transformation.getSkew();
double[] translation = transformation.getTranslation();
// // Convert the radians to degrees
// double[] rotation = new double[3];
// rotation[0] = rotationRadians[0] * 180 / Math.PI;
// rotation[1] = rotationRadians[1] * 180 / Math.PI;
// rotation[2] = rotationRadians[2] * 180 / Math.PI;
// TODO Apply skew from the transformation
// Consider each point one at a time
for (int i = 0; i < points.length / 3; i++) {
......@@ -260,4 +255,17 @@ public class FXPipeView extends FXShapeView
// node.getChildren().add(mesh.getMesh());
// }
@Override
protected void createShape(AbstractMesh model, ShapeType type) {
super.createShape(model, type);
Extrema e = getLowerExtrema();
Sphere sphere = new Sphere(e.getMaxZ() - e.getMinZ());
// sphere.setTranslateX((e.getMaxX() - e.getMinX() / 2 + e.getMinX()));
// sphere.setTranslateY((e.getMaxY() - e.getMinY() / 2 + e.getMinY()));
// sphere.setTranslateZ((e.getMaxZ() - e.getMinZ() / 2 + e.getMinZ()));
sphere.setTranslateY(((PipeMesh) model).getLength() / 2);
node.getChildren().add(sphere);
}
}
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