Package micycle.pgs
Class PGS_Coloring
java.lang.Object
micycle.pgs.PGS_Coloring
Minimal colorings of meshes (or mesh-like shapes). It ensures that no two
adjacent faces share the same color while also minimizing the total number of
colors used.
This class differentiates between "conforming meshes" and "non-conforming meshes".
Conforming Meshes : Consist of adjacent cells that share edges and
every pair of shared edges are identical, meaning they have the same
coordinates. An example of a conforming mesh is a triangulation.
Non-Conforming Meshes : Consist of adjacent cells that share edges
(i.e. edges may overlap) but adjacent edges do not necessarily have identical
start and end coordinates.
- Since:
- 1.2.0
- Author:
- Michael Carleton
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Specifies the algorithm/heuristic used by the underlying graph coloring process to find an approximate minimal coloring for mesh faces. -
Method Summary
Modifier and TypeMethodDescriptioncolorMesh
(Collection<processing.core.PShape> shapes, PGS_Coloring.ColoringAlgorithm coloringAlgorithm) Computes a coloring of the given mesh shape, returning a color class for each mesh face.colorMesh
(processing.core.PShape meshShape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm) Computes a coloring of the given mesh shape, returning a color class for each mesh face.static processing.core.PShape
colorMesh
(processing.core.PShape shape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm, int[] colorPalette) Computes a coloring of the given mesh shape and colors its faces using the colors provided.static processing.core.PShape
colorMesh
(processing.core.PShape shape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm, String[] colorPalette) Computes a coloring of the given mesh shape and colors its faces using the colors provided.colorNonMesh
(processing.core.PShape shape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm) Computes a coloring of the given non-conforming mesh shape, returning a color class for each face of the pre-processed (noded) mesh.static processing.core.PShape
colorNonMesh
(processing.core.PShape shape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm, int[] colorPalette) Computes a coloring of the given non-conforming mesh shape and colors the faces of its noded representation using the colors provided.static processing.core.PShape
colorNonMesh
(processing.core.PShape shape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm, String[] colorPalette) Computes a coloring of the given non-conforming mesh shape and colors the faces of its noded representation using the colors provided.
-
Method Details
-
colorMesh
public static Map<processing.core.PShape,Integer> colorMesh(processing.core.PShape meshShape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm) Computes a coloring of the given mesh shape, returning a color class for each mesh face.- Parameters:
meshShape
- a GROUP PShape, whose children constitute the faces of a conforming meshcoloringAlgorithm
- coloring algorithm used to color the mesh- Returns:
- a color-class map; a mapping of each mesh face (PShape) -> color class (integer)
-
colorMesh
public static Map<processing.core.PShape,Integer> colorMesh(Collection<processing.core.PShape> shapes, PGS_Coloring.ColoringAlgorithm coloringAlgorithm) Computes a coloring of the given mesh shape, returning a color class for each mesh face.- Parameters:
shapes
- a collection of shapes that constitute the faces of a conforming meshcoloringAlgorithm
- coloring algorithm used to color the mesh- Returns:
- a color-class map; a mapping of each mesh face (PShape) -> color class (integer)
-
colorMesh
public static processing.core.PShape colorMesh(processing.core.PShape shape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm, int[] colorPalette) Computes a coloring of the given mesh shape and colors its faces using the colors provided. This method mutates the fill colour of the input shape.- Parameters:
shape
- a GROUP PShape, whose children constitute the faces of a conforming meshcoloringAlgorithm
- coloring algorithm used to color the meshcolorPalette
- the (integer) colors with which to color the mesh- Returns:
- the input shape (whose faces have now been colored)
-
colorMesh
public static processing.core.PShape colorMesh(processing.core.PShape shape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm, String[] colorPalette) Computes a coloring of the given mesh shape and colors its faces using the colors provided. This method mutates the fill colour of the input shape.- Parameters:
shape
- a GROUP PShape, whose children constitute the faces of a conforming meshcoloringAlgorithm
- coloring algorithm used to color the meshcolorPalette
- the string colors (e.g. "#FFFFFF", or "cba5e8") with which to color the mesh- Returns:
- the input shape (whose faces have now been colored)
-
colorNonMesh
public static Map<processing.core.PShape,Integer> colorNonMesh(processing.core.PShape shape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm) Computes a coloring of the given non-conforming mesh shape, returning a color class for each face of the pre-processed (noded) mesh.- Parameters:
shape
- a GROUP PShape, whose children constitute the faces of a non-conforming meshcoloringAlgorithm
- coloring algorithm used to color the mesh- Returns:
- a color-class map; a mapping of each noded mesh face (PShape) -> color class (integer)
-
colorNonMesh
public static processing.core.PShape colorNonMesh(processing.core.PShape shape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm, int[] colorPalette) Computes a coloring of the given non-conforming mesh shape and colors the faces of its noded representation using the colors provided.- Parameters:
shape
- a GROUP PShape, whose children constitute the faces of a non-conforming meshcoloringAlgorithm
- coloring algorithm used to color the meshcolorPalette
- the (integer) colors with which to color the mesh- Returns:
- noded representation of the input shape (whose faces have now been colored)
-
colorNonMesh
public static processing.core.PShape colorNonMesh(processing.core.PShape shape, PGS_Coloring.ColoringAlgorithm coloringAlgorithm, String[] colorPalette) Computes a coloring of the given non-conforming mesh shape and colors the faces of its noded representation using the colors provided.- Parameters:
shape
- a GROUP PShape, whose children constitute the faces of a non-conforming meshcoloringAlgorithm
- coloring algorithm used to color the meshcolorPalette
- the string colors (e.g. "#FFFFFF", or "cba5e8") with which to color the mesh- Returns:
- noded representation of the input shape (whose faces have now been colored)
-