Skip to content

Commit

Permalink
UtilsOption.getDefined substituted by flatten
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallisto committed Nov 22, 2024
1 parent 34ca9b8 commit 6296dbc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import conversion.DOT
import conversion.DOT.toDOT
import conversion.SVGInvalid.*
import utility.Utils.*
import utility.UtilsOption.getDefined

import scala.xml.Elem

Expand Down Expand Up @@ -134,11 +133,10 @@ object TilingErrorMessages:
sideCouples.map((s1, s2) => (edgeFromSide(s1), edgeFromSide(s2)))
val crossings: List[Point] =
edgeCouples
.map({
.flatMap({
case (edge1, edge2) => List(edge1, edge2).toSegments(tiling.perimeterCoords).toCouple match
case (f, s) => f.intersection(s)
})
.getDefined
val svg: String =
addInvalidPerimeterSVG(
Description("Invalid intersecting edges"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import RegularPolygon.Vertex
import Topology.{Edge, Node, NodeOrdering}
import TilingUniformity.groupUniformsNestedComplete
import utility.Utils.toCouple
import utility.UtilsOption.getDefined
import io.github.scala_tessella.ring_seq.RingSeq.Index

import scala.xml.Elem
Expand Down Expand Up @@ -203,7 +202,7 @@ object SVG extends ConverterSVG:
)
.withStyle(Style(
(
if isMono then attributes
if isMono then attributes
else fill(fillUniform(index)) :: attributes
) *
))
Expand Down Expand Up @@ -366,7 +365,7 @@ object SVG extends ConverterSVG:
growthSVG(showGrowth),
marksSVG(markStyle),
labelsSVG(labelledNodes)
).getDefined *
).flatten *
)

/** `svg` element with metadata and `viewBox` fitting the tiling */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import TilingGrowth.OtherNodeStrategy.BEFORE_PERIMETER
import RegularPolygon.{Polygon, Vertex}
import TilingSymmetry.perimeterRotationalSymmetry
import Topology.{Edge, Node}
import utility.UtilsOption.getDefined

import io.github.scala_tessella.ring_seq.RingSeq.{Index, applyO}

Expand Down Expand Up @@ -86,7 +85,7 @@ object Symmetric:
yield
grown
)
tilings.getDefined.distinct
tilings.flatten.distinct

/** Expands by symmetric axes
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ object UtilsOption:
yield
c

/** Filters and gets defined options only */
def getDefined: CC[A] =
options.filter(_.isDefined).map(_.get)

private def emptied: CC[A] =
getDefined.take(0)
options.flatten.take(0)

/** Option of a sequence */
def sequence: Option[CC[A]] =
Expand Down

0 comments on commit 6296dbc

Please sign in to comment.