Skip to content

Commit

Permalink
Adds a default getMaxDimension() method to IShape
Browse files Browse the repository at this point in the history
Returns the largest of the 3 dimensions
  • Loading branch information
AlexisDrogoul committed Feb 28, 2022
1 parent 9335339 commit f5b9e42
Showing 1 changed file with 70 additions and 45 deletions.
115 changes: 70 additions & 45 deletions msi.gama.core/src/msi/gama/metamodel/shape/IShape.java
@@ -1,12 +1,11 @@
/*******************************************************************************************************
*
* IShape.java, in msi.gama.core, is part of the source code of the
* GAMA modeling and simulation platform (v.1.8.2).
* IShape.java, in msi.gama.core, is part of the source code of the GAMA modeling and simulation platform (v.1.8.2).
*
* (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
*
********************************************************************************************************/
package msi.gama.metamodel.shape;

Expand Down Expand Up @@ -40,6 +39,10 @@
* @modified November 2011 to include isPoint(), getInnerGeometry() and getEnvelope()
*
*/

/**
* The Interface IShape.
*/
@vars ({ @variable (
name = "area",
type = IType.FLOAT,
Expand Down Expand Up @@ -101,94 +104,95 @@
type = IType.GEOMETRY,
doc = { @doc ("Returns the polyline representing the contour of this geometry") }) })
public interface IShape extends ILocated, IValue, IAttributed {

/** The jts types. */
Map<String, Type> JTS_TYPES = GamaMapFactory.createUnordered();

/** The threed types. */
Set<Type> THREED_TYPES = new HashSet<>();

/**
* The Enum Type.
*/
enum Type {

/** The box. */
BOX("3D"),

/** The circle. */
CIRCLE("3D"),

/** The cone. */
CONE("3D"),

/** The cube. */
CUBE("3D"),

/** The square. */
SQUARE("3D"),

/** The rounded. */
ROUNDED(""),

/** The cylinder. */
CYLINDER("3D"),

/** The gridline. */
GRIDLINE(""),

/** The linearring. */
LINEARRING("LinearRing"),

/** The linestring. */
LINESTRING("LineString"),

/** The multilinestring. */
MULTILINESTRING("MultiLineString"),

/** The multipoint. */
MULTIPOINT("MultiPoint"),

/** The multipolygon. */
MULTIPOLYGON("MultiPolygon"),

/** The null. */
NULL(""),

/** The plan. */
PLAN("3D"),

/** The point. */
POINT("Point"),

/** The polygon. */
POLYGON("Polygon"),

/** The polyhedron. */
POLYHEDRON("3D"),

/** The polyplan. */
POLYPLAN("3D"),

/** The pyramid. */
PYRAMID("3D"),

/** The sphere. */
SPHERE("3D"),

/** The teapot. */
TEAPOT("3D"),

/** The linecylinder. */
LINECYLINDER("3D"),

/** The threed file. */
THREED_FILE("");

/**
* Instantiates a new type.
*
* @param name the name
* @param name
* the name
*/
Type(final String name) {
if (name.isEmpty()) return;
Expand All @@ -206,7 +210,8 @@ enum Type {
/**
* Copy.
*
* @param scope the scope
* @param scope
* the scope
* @return the i shape
*/
@Override
Expand All @@ -215,31 +220,35 @@ enum Type {
/**
* Covers.
*
* @param g the g
* @param g
* the g
* @return true, if successful
*/
boolean covers(IShape g);

/**
* Partially overlaps.
*
* @param g the g
* @param g
* the g
* @return true, if successful
*/
boolean partiallyOverlaps(IShape g);

/**
* Touches.
*
* @param g the g
* @param g
* the g
* @return true, if successful
*/
boolean touches(IShape g);

/**
* Crosses.
*
* @param g the g
* @param g
* the g
* @return true, if successful
*/
boolean crosses(IShape g);
Expand All @@ -252,15 +261,17 @@ enum Type {
/**
* Euclidian distance to.
*
* @param g the g
* @param g
* the g
* @return the double
*/
double euclidianDistanceTo(GamaPoint g);

/**
* Euclidian distance to.
*
* @param g the g
* @param g
* the g
* @return the double
*/
double euclidianDistanceTo(IShape g);
Expand Down Expand Up @@ -305,7 +316,8 @@ enum Type {
/**
* Intersects.
*
* @param g the g
* @param g
* the g
* @return true, if successful
*/
boolean intersects(IShape g);
Expand All @@ -327,28 +339,32 @@ enum Type {
/**
* Sets the agent.
*
* @param agent the new agent
* @param agent
* the new agent
*/
void setAgent(IAgent agent);

/**
* Sets the geometry.
*
* @param g the new geometry
* @param g
* the new geometry
*/
void setGeometry(IShape g);

/**
* Sets the inner geometry.
*
* @param intersection the new inner geometry
* @param intersection
* the new inner geometry
*/
void setInnerGeometry(Geometry intersection);

/**
* Sets the depth.
*
* @param depth the new depth
* @param depth
* the new depth
*/
void setDepth(double depth);

Expand Down Expand Up @@ -412,7 +428,8 @@ enum Type {
/**
* Gets the exterior ring.
*
* @param scope the scope
* @param scope
* the scope
* @return the exterior ring
*/
@getter ("contour")
Expand Down Expand Up @@ -442,6 +459,13 @@ enum Type {
@getter ("depth")
Double getDepth();

/**
* Gets the max dimension.
*
* @return the max dimension
*/
default Double getMaxDimension() { return Math.max(Math.max(getHeight(), getWidth()), getDepth()); }

/**
* Gets the geometric envelope.
*
Expand Down Expand Up @@ -481,7 +505,8 @@ default void copyShapeAttributesFrom(final IShape other) {
/**
* Sets the geometrical type.
*
* @param t the new geometrical type
* @param t
* the new geometrical type
*/
void setGeometricalType(Type t);

Expand Down

0 comments on commit f5b9e42

Please sign in to comment.