Skip to content

Commit

Permalink
Fix WolframModelPlot for Wolfram Language 12.2 (#433)
Browse files Browse the repository at this point in the history
## Changes
* `ConvexHullMesh` is broken in Wolfram Language 12.2. It seems that only 1D examples evaluate, 2D and 3D example return unevaluated even if using examples from the documentation.
* Because of this, `WolframModelPlot` is currently broken.
* This PR changes `WolframModelPlot` to use the new `convexHullPolygon` (#432) instead of `ConvexHullMesh`.

## Comments
* The tests will fail until #432 is merged.
* I will also update the CI soon to version 12.2 so that the tests on the current master will start failing as well.
* Visually verified `WolframModelPlot` and `RulePlot` on all examples from documentation.

## Examples
* `WolframModelPlot` now works as expected:
```wl
In[] := $Version
Out[] = "12.2.0 for Mac OS X x86 (64-bit) (October 3, 2020)"
```
```wl
In[] := WolframModelPlot[{{1, 2, 3}, {3, 4, 5}, {5, 6, 7}}]
```
![image](https://user-images.githubusercontent.com/1479325/95257565-1e7a3800-07ea-11eb-8325-0f7e269444d2.png)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/maxitg/setreplace/433)
<!-- Reviewable:end -->
  • Loading branch information
maxitg authored Oct 7, 2020
1 parent 06bffec commit b82c93e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions Kernel/WolframModelPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,7 @@

addConvexPolygons[edgeType_][edge_, subgraphsShapes_] := Module[{points, region, convexPolygons, polygon},
points = Flatten[#, 2] & @ (subgraphsShapes /. {Line[pts_] :> {pts}, Point[pts_] :> {{pts}}});
region = ConvexHullMesh[Map[# + RandomReal[1.*^-10] &, points, {2}]];
convexPolygons = Polygon /@ Table[MeshCoordinates[region][[polygon]], {polygon, MeshCells[region, 2][[All, 1]]}];
edge -> Join[subgraphsShapes, convexPolygons]
edge -> If[Length[points] > 2, Append[subgraphsShapes, convexHullPolygon[points]], subgraphsShapes]
]

(** Drawing **)
Expand Down

0 comments on commit b82c93e

Please sign in to comment.