Skip to content
Snippets Groups Projects
Commit 9d7cad76 authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Merge branch '172-visualize-bouding-box-for-cutting-plane' into 'master'

Resolve "Visualize bouding box for cutting plane"

Closes #172

See merge request grp-fidentis/analyst2!181
parents 85a892f1 68f736dd
No related branches found
No related tags found
No related merge requests found
...@@ -21,9 +21,10 @@ public class DrawableCuttingPlane extends DrawablePlane { ...@@ -21,9 +21,10 @@ public class DrawableCuttingPlane extends DrawablePlane {
* *
* @param plane plane * @param plane plane
* @param bbox bounding box used to estimate cutting pale shape (rectangle) * @param bbox bounding box used to estimate cutting pale shape (rectangle)
* @param showBBox whether to render bounding box
*/ */
public DrawableCuttingPlane(Plane plane, BBox bbox) { public DrawableCuttingPlane(Plane plane, BBox bbox, boolean showBBox) {
super(plane, bbox); super(plane, bbox, showBBox);
} }
/** /**
......
...@@ -17,6 +17,7 @@ public class DrawablePlane extends Drawable { ...@@ -17,6 +17,7 @@ public class DrawablePlane extends Drawable {
private Plane plane; private Plane plane;
private final BBox bbox; private final BBox bbox;
private boolean showBoundingBox;
/** /**
...@@ -24,10 +25,12 @@ public class DrawablePlane extends Drawable { ...@@ -24,10 +25,12 @@ public class DrawablePlane extends Drawable {
* *
* @param plane plane * @param plane plane
* @param bbox bounding box used to estimate cutting pale shape (rectangle) * @param bbox bounding box used to estimate cutting pale shape (rectangle)
* @param showBBox whether to render bounding box
*/ */
public DrawablePlane(Plane plane, BBox bbox) { public DrawablePlane(Plane plane, BBox bbox, boolean showBBox) {
this.plane = plane; this.plane = plane;
this.bbox = bbox; this.bbox = bbox;
this.showBoundingBox = showBBox;
} }
/** /**
...@@ -39,12 +42,30 @@ public class DrawablePlane extends Drawable { ...@@ -39,12 +42,30 @@ public class DrawablePlane extends Drawable {
super(drPlane); super(drPlane);
this.plane = new Plane(drPlane.getPlane()); this.plane = new Plane(drPlane.getPlane());
this.bbox = drPlane.bbox; this.bbox = drPlane.bbox;
this.showBoundingBox = drPlane.showBoundingBox;
} }
public Plane getPlane() { public Plane getPlane() {
return plane; return plane;
} }
/**
* Returns {@code true} if the bounding box is to be rendered.
* @return {@code true} if the bounding box is to be rendered.
*/
public boolean isShownBBobx() {
return this.showBoundingBox;
}
/**
* Switches on/off bounding box rendering.
*
* @param show If {@code true], then the bounding box is rendered as well
*/
public void setShowBBox(boolean show) {
this.showBoundingBox = show;
}
protected void setPlane(Plane plane) { protected void setPlane(Plane plane) {
this.plane = plane; this.plane = plane;
} }
...@@ -59,11 +80,56 @@ public class DrawablePlane extends Drawable { ...@@ -59,11 +80,56 @@ public class DrawablePlane extends Drawable {
// get the normal and tex coords indicies for face i // get the normal and tex coords indicies for face i
for (int v = 0; v < facet.getCornerTable().getSize(); v++) { for (int v = 0; v < facet.getCornerTable().getSize(); v++) {
Point3d vert = facet.getVertices().get(facet.getCornerTable().getRow(v).getVertexIndex()).getPosition(); Point3d vert = facet.getVertices().get(facet.getCornerTable().getRow(v).getVertexIndex()).getPosition();
if (v == 0) {
}
gl.glVertex3d(vert.x, vert.y, vert.z); gl.glVertex3d(vert.x, vert.y, vert.z);
} }
gl.glEnd(); gl.glEnd();
if (showBoundingBox) {
Point3d min = bbox.getMinPoint();
Point3d max = bbox.getMaxPoint();
gl.glBegin(GL2.GL_LINES);
// bottom rectangle:
gl.glVertex3d(min.x, min.y, min.z);
gl.glVertex3d(max.x, min.y, min.z);
gl.glVertex3d(max.x, min.y, min.z);
gl.glVertex3d(max.x, min.y, max.z);
gl.glVertex3d(max.x, min.y, max.z);
gl.glVertex3d(min.x, min.y, max.z);
gl.glVertex3d(min.x, min.y, max.z);
gl.glVertex3d(min.x, min.y, min.z);
// top rectangle:
gl.glVertex3d(min.x, max.y, min.z);
gl.glVertex3d(max.x, max.y, min.z);
gl.glVertex3d(max.x, max.y, min.z);
gl.glVertex3d(max.x, max.y, max.z);
gl.glVertex3d(max.x, max.y, max.z);
gl.glVertex3d(min.x, max.y, max.z);
gl.glVertex3d(min.x, max.y, max.z);
gl.glVertex3d(min.x, max.y, min.z);
// vertical edges:
gl.glVertex3d(min.x, min.y, min.z);
gl.glVertex3d(min.x, max.y, min.z);
gl.glVertex3d(max.x, min.y, min.z);
gl.glVertex3d(max.x, max.y, min.z);
gl.glVertex3d(max.x, min.y, max.z);
gl.glVertex3d(max.x, max.y, max.z);
gl.glVertex3d(min.x, min.y, max.z);
gl.glVertex3d(min.x, max.y, max.z);
gl.glEnd();
}
} }
protected BBox getBBox() { protected BBox getBBox() {
......
...@@ -221,7 +221,7 @@ public class Scene { ...@@ -221,7 +221,7 @@ public class Scene {
} }
if (drawableSymmetryPlanes.get(slot) == null) { // add new if (drawableSymmetryPlanes.get(slot) == null) { // add new
drawableSymmetryPlanes.set(slot, new DrawablePlane(face.getSymmetryPlane(), face.getBoundingBox())); drawableSymmetryPlanes.set(slot, new DrawablePlane(face.getSymmetryPlane(), face.getBoundingBox(), false));
} else { // replace existing } else { // replace existing
drawableSymmetryPlanes.get(slot).setPlane(face.getSymmetryPlane()); drawableSymmetryPlanes.get(slot).setPlane(face.getSymmetryPlane());
} }
......
...@@ -274,7 +274,7 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe ...@@ -274,7 +274,7 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe
protected void computeVerticalCuttingPlanes() { protected void computeVerticalCuttingPlanes() {
BBox bbox = getCanvas().getPrimaryFace().getBoundingBox(); BBox bbox = getCanvas().getPrimaryFace().getBoundingBox();
Plane plane = new Plane(new Vector3d(1,0,0), bbox.getMidPoint().x); Plane plane = new Plane(new Vector3d(1,0,0), bbox.getMidPoint().x);
DrawableCuttingPlane cuttingPlane = new DrawableCuttingPlane(plane, bbox); DrawableCuttingPlane cuttingPlane = new DrawableCuttingPlane(plane, bbox, true);
cuttingPlane.setTransparency(0.5f); cuttingPlane.setTransparency(0.5f);
if (priCuttingPlaneSlot == -1) { if (priCuttingPlaneSlot == -1) {
priCuttingPlaneSlot = getCanvas().getScene().getFreeSlotForOtherDrawables(); priCuttingPlaneSlot = getCanvas().getScene().getFreeSlotForOtherDrawables();
...@@ -284,7 +284,7 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe ...@@ -284,7 +284,7 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe
if (getSecondaryDrawableFace() != null) { if (getSecondaryDrawableFace() != null) {
bbox = getCanvas().getSecondaryFace().getBoundingBox(); bbox = getCanvas().getSecondaryFace().getBoundingBox();
plane = new Plane(new Vector3d(1,0,0), bbox.getMidPoint().x); plane = new Plane(new Vector3d(1,0,0), bbox.getMidPoint().x);
cuttingPlane = new DrawableCuttingPlane(plane, bbox); cuttingPlane = new DrawableCuttingPlane(plane, bbox, true);
cuttingPlane.setTransparency(0.5f); cuttingPlane.setTransparency(0.5f);
if (secCuttingPlaneSlot == -1) { if (secCuttingPlaneSlot == -1) {
secCuttingPlaneSlot = getCanvas().getScene().getFreeSlotForOtherDrawables(); secCuttingPlaneSlot = getCanvas().getScene().getFreeSlotForOtherDrawables();
...@@ -305,7 +305,8 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe ...@@ -305,7 +305,8 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe
} }
DrawableCuttingPlane cuttingPlane = new DrawableCuttingPlane( DrawableCuttingPlane cuttingPlane = new DrawableCuttingPlane(
new Plane(symmetryPlane), new Plane(symmetryPlane),
getCanvas().getPrimaryFace().getBoundingBox() getCanvas().getPrimaryFace().getBoundingBox(),
false
); );
cuttingPlane.setTransparency(0.5f); cuttingPlane.setTransparency(0.5f);
if (priCuttingPlaneSlot == -1) { if (priCuttingPlaneSlot == -1) {
...@@ -321,7 +322,8 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe ...@@ -321,7 +322,8 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe
} }
cuttingPlane = new DrawableCuttingPlane( cuttingPlane = new DrawableCuttingPlane(
new Plane(symmetryPlane), new Plane(symmetryPlane),
getCanvas().getSecondaryFace().getBoundingBox() getCanvas().getSecondaryFace().getBoundingBox(),
false
); );
cuttingPlane.setTransparency(0.5f); cuttingPlane.setTransparency(0.5f);
if (secCuttingPlaneSlot == -1) { if (secCuttingPlaneSlot == -1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment