Skip to content

Commit

Permalink
reading polygonal domains from ipe files
Browse files Browse the repository at this point in the history
  • Loading branch information
noinia committed Dec 22, 2024
1 parent 113ef35 commit 7b16cec
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hgeometry/hgeometry.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ library
HGeometry.Polygon.Convex.MinkowskiSum
HGeometry.Polygon.Triangulation.Types

-- HGeometry.PlaneGraph.Type
HGeometry.PlaneGraph.Type
HGeometry.PlaneGraph.Connected.Type

HGeometry.LineSegment.Intersection.Types
Expand Down
9 changes: 6 additions & 3 deletions hgeometry/src/HGeometry/PlaneGraph/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
--------------------------------------------------------------------------------
module HGeometry.PlaneGraph.Type
( PlaneGraph(..)
, fromAdjacencyRep
, fromConnectedSegments
-- , fromAdjacencyRep
-- , fromConnectedSegments
-- , VertexData(VertexData), location

, E(..)
-- , E(..)
) where

import Control.Lens hiding (holes, holesOf, (.=))
Expand Down Expand Up @@ -160,6 +160,7 @@ instance ( Point_ v 2 (NumType v)
fromAdjacencyLists = fromEmbedding . toEmbedding
-}

{-
instance ( Point_ v 2 (NumType v)
, Ord (NumType v), Num (NumType v)
Expand Down Expand Up @@ -265,3 +266,5 @@ instance (Ord r, Num r) => Eq (E r) where
a == b = a `compare` b == EQ
instance (Ord r, Num r) => Ord (E r) where
(E v) `compare` (E u) = ccwCmpAroundWith (Vector2 0 1) (origin :: Point 2 r) (Point v) (Point u)
-}
7 changes: 7 additions & 0 deletions hgeometry/test/Polygon/SeqSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Data.Maybe
import qualified Data.Sequence as Seq
import qualified Data.Vector.NonEmpty as NV
import HGeometry.Cyclic
import HGeometry.Number.Real.Rational
import HGeometry.Point
import HGeometry.Polygon
import HGeometry.Polygon.Instances ()
Expand Down Expand Up @@ -101,3 +102,9 @@ spec = describe "Polygon with Seq1 spec" $ do
prop "cw traversals consistent" $
\(pg :: SimplePolygon (Point 2 Rational)) (i :: Int) ->
itoListOf (cwOuterBoundaryFrom i) pg === itoListOf (cwOuterBoundaryFrom i) (toSeqPoly pg)

it "gets rid of duplicate points at the beginning and end" $
let myPoly :: SimplePolygon (Point 2 (RealNumber 5))
myPoly = fromJust . fromPoints $
read @[Point 2 (RealNumber 5)] "[Point2 0 0,Point2 26 37.1,Point2 7.1 45.2,Point2 (-6.6) 39,Point2 (-1.9) 15.1,Point2 (-1.4) 12.7,Point2 0 0]"
in myPoly^..vertices `shouldBe` [Point2 26 37.1,Point2 7.1 45.2,Point2 (-6.6) 39,Point2 (-1.9) 15.1,Point2 (-1.4) 12.7,Point2 0 0]
2 changes: 1 addition & 1 deletion hgeometry/test/Polygon/Triangulation/MakeMonotoneSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Control.Lens
import Data.Maybe (fromJust)
import qualified Data.Set as Set
import HGeometry.Ext
import HGeometry.Point
import HGeometry.LineSegment
import HGeometry.Point
import HGeometry.Polygon.Class
import HGeometry.Polygon.Simple
import HGeometry.Polygon.Triangulation.MakeMonotone
Expand Down
2 changes: 1 addition & 1 deletion todo.org
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ cabal run hgeometry-examples:hgeometry-triangulateworld -- -i -o 130.82s user



** TODO verify fromPoints
** DONE verify fromPoints

i.e. add a test that makes sure that the cyclic zero's are correct,
i.e. that
Expand Down

0 comments on commit 7b16cec

Please sign in to comment.