diff --git a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java index e14f99d08..4d167d58d 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import net.sf.openrocket.util.BoundingBox; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +26,7 @@ import net.sf.openrocket.util.MathUtil; * * @author Sampo Niskanen */ -public class InnerTube extends ThicknessRingComponent implements AxialPositionable, Clusterable, RadialParent, MotorMount { +public class InnerTube extends ThicknessRingComponent implements AxialPositionable, BoxBounded, Clusterable, RadialParent, MotorMount { private static final Translator trans = Application.getTranslator(); private static final Logger log = LoggerFactory.getLogger(InnerTube.class); @@ -135,6 +136,18 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab } } + public BoundingBox getInstanceBoundingBox(){ + BoundingBox instanceBounds = new BoundingBox(); + + instanceBounds.update(new Coordinate(this.getLength(), 0,0)); + + final double r = getOuterRadius(); + instanceBounds.update(new Coordinate(0,r,r)); + instanceBounds.update(new Coordinate(0,-r,-r)); + + return instanceBounds; + } + @Override public int getInstanceCount() { return cluster.getClusterCount(); diff --git a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java index 0824a3aef..6eb7840bc 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java +++ b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java @@ -8,12 +8,13 @@ import net.sf.openrocket.preset.ComponentPreset; import net.sf.openrocket.preset.ComponentPreset.Type; import net.sf.openrocket.rocketcomponent.position.*; import net.sf.openrocket.startup.Application; +import net.sf.openrocket.util.BoundingBox; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.MathUtil; -public class LaunchLug extends ExternalComponent implements AnglePositionable, Coaxial, LineInstanceable { +public class LaunchLug extends ExternalComponent implements AnglePositionable, BoxBounded, Coaxial, LineInstanceable { private static final Translator trans = Application.getTranslator(); @@ -252,7 +253,20 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, C public int getInstanceCount(){ return this.instanceCount; } - + + @Override + public BoundingBox getInstanceBoundingBox() { + BoundingBox instanceBounds = new BoundingBox(); + + instanceBounds.update(new Coordinate(this.getLength(), 0,0)); + + final double r = getOuterRadius(); + instanceBounds.update(new Coordinate(0,r,r)); + instanceBounds.update(new Coordinate(0,-r,-r)); + + return instanceBounds; + } + @Override public String getPatternName(){ return (this.getInstanceCount() + "-Line"); @@ -281,5 +295,4 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, C public void setAngleMethod(AngleMethod newMethod) { // no-op } - } diff --git a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java index c63b84066..88cc83198 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java @@ -13,6 +13,7 @@ import net.sf.openrocket.rocketcomponent.position.AnglePositionable; import net.sf.openrocket.rocketcomponent.position.AxialMethod; import net.sf.openrocket.rocketcomponent.position.AxialPositionable; import net.sf.openrocket.startup.Application; +import net.sf.openrocket.util.BoundingBox; import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.MathUtil; @@ -22,7 +23,7 @@ import net.sf.openrocket.util.MathUtil; * @author widget (Daniel Williams) * */ -public class RailButton extends ExternalComponent implements AnglePositionable, AxialPositionable, LineInstanceable { +public class RailButton extends ExternalComponent implements AnglePositionable, AxialPositionable, BoxBounded, LineInstanceable { private static final Translator trans = Application.getTranslator(); @@ -210,6 +211,18 @@ public class RailButton extends ExternalComponent implements AnglePositionable, fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE); } + public BoundingBox getInstanceBoundingBox(){ + BoundingBox instanceBounds = new BoundingBox(); + + instanceBounds.update(new Coordinate(0, this.getTotalHeight(), 0)); + + final double r = this.getOuterDiameter(); + instanceBounds.update(new Coordinate(r,r,0)); + instanceBounds.update(new Coordinate(-r,-r,0)); + + return instanceBounds; + } + @Override public Coordinate[] getInstanceOffsets(){ Coordinate[] toReturn = new Coordinate[this.getInstanceCount()]; diff --git a/core/src/net/sf/openrocket/rocketcomponent/RingComponent.java b/core/src/net/sf/openrocket/rocketcomponent/RingComponent.java index 77e3ddeb3..1b9655e6d 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RingComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RingComponent.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import net.sf.openrocket.util.BoundingBox; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.MathUtil; @@ -16,7 +17,7 @@ import net.sf.openrocket.util.MathUtil; * * @author Sampo Niskanen */ -public abstract class RingComponent extends StructuralComponent implements Coaxial { +public abstract class RingComponent extends StructuralComponent implements BoxBounded, Coaxial { protected boolean outerRadiusAutomatic = false; protected boolean innerRadiusAutomatic = false; @@ -111,9 +112,18 @@ public abstract class RingComponent extends StructuralComponent implements Coaxi fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); } + public BoundingBox getInstanceBoundingBox(){ + BoundingBox instanceBounds = new BoundingBox(); + + instanceBounds.update(new Coordinate(this.getLength(), 0,0)); + + final double r = getOuterRadius(); + instanceBounds.update(new Coordinate(0,r,r)); + instanceBounds.update(new Coordinate(0,-r,-r)); + + return instanceBounds; + } - - /** * Return the radial position of the component. The position is the distance * of the center of the component from the center of the parent component.