LLNL / axom

CS infrastructure components for HPC applications
BSD 3-Clause "New" or "Revised" License
145 stars 24 forks source link

Adds winding number example to quest #1351

Open kennyweiss opened 2 weeks ago

kennyweiss commented 2 weeks ago

Summary

Examples

SVG Arcs:

This example uses rotated ellipses, elliptical arcs, and rounded rectangles:

<svg width="320" height="320" xmlns="http://www.w3.org/2000/svg"
      style="stroke:white;fill:none;stroke-width:2;fill-opacity:0.5">
    <path d="M 100 100 A 30 50 0 0 0 150 100" stroke="aqua" />
    <path d="M 100 100 A 30 50 0 1 1 150 100" stroke="blue" />
    <path d="M 100 100 A 30 50 0 0 1 150 100" stroke="tomato" />
    <path d="M 100 100 A 30 50 0 1 0 150 100" stroke="red"  />
    <ellipse cx="107.5" cy="100" rx="15" ry="35" transform="rotate(-90 107.5 100)" stroke="green"  />
    <rect rx="20" ry="20" x="50" y="10" width="150" height="200" stroke="forestgreen" />
</svg>

image

After running svg2contours to generate an mfem mesh and querying that via the quest_winding_number example, we get:

>../src/tools/svg2contours/svg2contours.py -i four_arcs.svg 
SVG dimensions: width='320' height='320' viewBox=None
Wrote 'drawing.mesh' with 32 vertices and NURBS 16 elements

>./examples/quest_winding_number_ex -i drawing.mesh query_mesh --min 0 0 --max 250 350 --res 250 350
[INFO] Curve mesh has a topological dimension of 1d, has 32 vertices and 16 elements 
[INFO] Curve mesh bounding box: { min:(37.5,110); max:(200,310); range:<162.5,200> } 

We can visualize the output mesh w/ VisIt. Here are the generated (rounded) winding numbers: image (the grid for the query mesh appears as faint gray lines).

Detail: Generated MFEM NURBS mesh ``` MFEM NURBS mesh v1.0 # MFEM Geometry Types (see fem/geom.hpp): # # SEGMENT = 1 | SQUARE = 3 | CUBE = 5 # # element: 1 # edge: 0 1 <-- idx increases by one each time # knotvector: [knots]; sizeof(knots) is 1+order+num_ctrl_pts # weights: array of weights corresponding to the NURBS element # FES: list of control points; vertex control points at top, then interior control points dimension 1 elements 16 1 1 0 1 2 1 2 3 2 1 4 5 3 1 6 7 4 1 8 9 4 1 10 11 5 1 12 13 5 1 14 15 6 1 16 17 6 1 18 19 6 1 20 21 6 1 22 23 6 1 24 25 6 1 26 27 6 1 28 29 6 1 30 31 boundary 0 edges 16 0 0 1 1 0 1 2 0 1 3 0 1 4 0 1 5 0 1 6 0 1 7 0 1 8 0 1 9 0 1 10 0 1 11 0 1 12 0 1 13 0 1 14 0 1 15 0 1 vertices 32 knotvectors 16 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 weights 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.7018471989283782 0.7018471989283782 0.648586036769599 0.6485860367695986 0.6485860367695991 0.6485860367695991 0.7018471989283773 0.7018471989283773 0.6485860367695994 0.6485860367695998 0.6485860367695988 0.6485860367695987 0.3333333333333333 0.33333333333333326 0.3333333333333333 0.33333333333333315 1 1 0.8047378541243677 0.8047378541243695 1 1 0.8047378541243648 0.8047378541243647 1 1 0.8047378541243648 0.8047378541243647 1 1 0.804737854124365 0.8047378541243656 FiniteElementSpace FiniteElementCollection: NURBS VDim: 2 Ordering: 1 100.0 220.0 150.0 220.0 125.0 297.63853991962833 100.0 220.0 150.0 220.0 125.0 297.63853991962833 150.0 220.0 100.0 220.0 100.0 220.0 125.0 142.36146008037167 125.0 142.36146008037167 150.0 220.0 107.5 205.0 107.50000000000001 235.0 107.50000000000001 235.0 107.5 205.0 180.0 310.0 70.0 310.0 200.0 290.0 180.0 310.0 200.0 130.0 200.0 290.0 180.0 110.0 200.0 130.0 70.0 110.0 180.0 110.0 50.0 130.0 70.0 110.0 50.0 290.0 50.0 130.0 70.0 310.0 50.0 290.0 136.87342963832748 187.01825100464583 113.1265703616725 187.01825100464583 84.98082170412339 257.737105353691 97.82928414534246 297.63853991962833 152.17071585465752 297.63853991962833 165.0191782958766 257.737105353691 113.1265703616725 252.98174899535417 136.8734296383275 252.98174899535417 97.82928414534246 142.36146008037167 84.98082170412339 182.262894646309 165.0191782958766 182.262894646309 152.17071585465752 142.36146008037167 177.5 235.0 177.5 205.0 37.5 205.0 37.499999999999986 235.0 106.66666666666667 310.0 143.33333333333334 310.0 191.71572875253813 310.0 200.0 301.7157287525381 200.0 236.66666666666669 200.0 183.33333333333334 200.0 118.2842712474619 191.7157287525381 110.0 143.33333333333334 109.99999999999997 106.66666666666667 110.0 58.2842712474619 110.0 50.0 118.2842712474619 50.0 183.33333333333331 50.0 236.66666666666666 50.0 301.7157287525381 58.28427124746191 310.0 ```

Inkscape example

A second example uses an SVG generated in inkscape using an (open) spiral curve, a polygon with straight edges, an ellipse and a circle

image

Detail: Input SVG file ```svg ```

Running through svg2contours and the quest_winding_number example, we get the following winding number and inout fields: image image

Detail: Generated MFEM NURBS mesh ``` MFEM NURBS mesh v1.0 # MFEM Geometry Types (see fem/geom.hpp): # # SEGMENT = 1 | SQUARE = 3 | CUBE = 5 # # element: 1 # edge: 0 1 <-- idx increases by one each time # knotvector: [knots]; sizeof(knots) is 1+order+num_ctrl_pts # weights: array of weights corresponding to the NURBS element # FES: list of control points; vertex control points at top, then interior control points dimension 1 elements 27 1 1 0 1 1 1 2 3 1 1 4 5 1 1 6 7 1 1 8 9 1 1 10 11 1 1 12 13 1 1 14 15 1 1 16 17 1 1 18 19 2 1 20 21 2 1 22 23 2 1 24 25 2 1 26 27 2 1 28 29 2 1 30 31 2 1 32 33 2 1 34 35 2 1 36 37 2 1 38 39 2 1 40 41 2 1 42 43 3 1 44 45 3 1 46 47 3 1 48 49 4 1 50 51 4 1 52 53 boundary 0 edges 27 0 0 1 1 0 1 2 0 1 3 0 1 4 0 1 5 0 1 6 0 1 7 0 1 8 0 1 9 0 1 10 0 1 11 0 1 12 0 1 13 0 1 14 0 1 15 0 1 16 0 1 17 0 1 18 0 1 19 0 1 20 0 1 21 0 1 22 0 1 23 0 1 24 0 1 25 0 1 26 0 1 vertices 54 knotvectors 27 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 3 4 0 0 0 0 1 1 1 1 weights 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.33333333333333337 0.33333333333333354 0.3333333333333334 0.33333333333333315 1 1 0.3333333333333333 0.3333333333333333 0.3333333333333333 0.33333333333333326 FiniteElementSpace FiniteElementCollection: NURBS VDim: 2 Ordering: 1 97.102267 145.062143 128.050192 136.84169300000002 72.785612 124.228263 97.102267 145.062143 71.04028 156.201753 72.785612 124.228263 43.711829 172.890241 71.04028 156.201753 73.58108299999999 184.430501 43.711829 172.890241 81.007826 215.57843 73.58108299999999 184.430501 101.21337199999999 190.73721799999998 81.007826 215.57843 133.131802 193.299205 101.21337199999999 190.73721799999998 115.75026199999999 166.406231 133.131802 193.299205 128.050192 136.84169300000002 115.75026199999999 166.406231 162.73842000000002 235.55502 164.74518 238.135136 159.58495000000002 242.148649 162.73842000000002 235.55502 170.76545000000002 245.875484 159.58495000000002 242.148649 175.06564 230.108109 170.76545000000002 245.875484 154.71139 225.234556 175.06564 230.108109 149.26448 250.175676 154.71139 225.234556 178.79247999999998 256.195948 149.26448 250.175676 185.38610999999997 222.081082 178.79247999999998 256.195948 146.68436999999997 214.914091 185.38610999999997 222.081082 138.94401999999997 258.20270300000004 146.68436999999997 214.914091 186.81949999999998 266.516412 138.94401999999997 258.20270300000004 195.70656999999997 214.054055 186.81949999999998 266.516412 107.409271 64.21621999999999 191.50192900000002 64.21621999999999 191.50192900000002 64.21621999999999 107.40927100000002 64.21621999999999 107.409271 64.21621999999999 107.40927100000002 64.21621999999999 20.640928000000002 250.557915 83.71042 250.557915 83.71042 250.557915 20.640928000000002 250.557915 117.734217 139.581843 107.41824199999999 142.321993 88.99671533333334 138.11751633333333 80.89116366666667 131.17288966666666 72.20383466666667 134.886093 71.62205733333333 145.543923 61.93079633333333 161.76458233333332 52.82131266666667 167.32741166666668 53.668247 176.73699433333334 63.62466499999999 180.58374766666668 76.056664 194.813144 78.53224499999999 205.195787 87.743008 207.298026 94.47818999999998 199.01762200000002 111.85284866666666 191.59121366666665 122.49232533333333 192.44520933333334 127.33795533333333 184.33488033333333 121.54410866666666 175.37055566666666 119.85023866666667 156.55138499999998 123.95021533333333 146.696539 166.29753 236.927749 163.88352 235.44691 159.63527000000002 235.84799 158.66646000000003 239.654731 161.22790000000003 246.60968300000002 166.79305000000002 247.803878 176.5951 243.045488 178.04433 235.519186 171.09551 222.89599400000003 161.54733 221.18875100000002 146.10907 230.325787 144.14294999999998 241.92139500000002 155.46734999999998 260.17271600000004 169.12349999999998 262.39819 190.18703 248.88682 192.67217999999997 233.16247600000003 176.97404999999998 209.287174 159.17665999999997 206.54211 132.48982999999998 224.42687 129.48466999999997 244.300574 149.55597999999998 273.79879 171.50831999999997 277.064189 203.81781999999998 254.80638000000002 207.34356999999997 230.773707 191.50192900000002 -19.876438000000007 107.40927100000002 -19.87643799999995 107.40927100000003 148.30887799999994 191.50192900000002 148.308878 107.40927100000002 64.21621999999996 107.409271 64.21621999999996 83.71042 204.306949 20.64092800000001 204.306949 20.64092800000001 296.808881 83.71042 296.808881 ```
agcapps commented 6 days ago

I foresee some interesting workflow steps arising from this feature + user creativity... : )

kennyweiss commented 5 days ago

Should the example svg files be added to axom_data ?

Thanks @bmhan12 -- yes, I'm planning to add a few small SVG files and generated MFEM NURBS meshes to axom_data as well as a test.

I also have to add a command line option to the python script to (optionally) reverse the edge orientations.