Browse Source

updated PolyVectorField demo (as presented in SGP 2014)

Former-commit-id: fb78a78751a0e9c9b81819617c6c7e18c314c887
Olga Diamanti 11 years ago
parent
commit
39f6076788
2 changed files with 1362 additions and 7 deletions
  1. 43 7
      tutorial/507_PolyVectorField/main.cpp
  2. 1319 0
      tutorial/shared/lilium.samples.0.2

+ 43 - 7
tutorial/507_PolyVectorField/main.cpp

@@ -25,6 +25,32 @@ double global_scale;
 // Random length factor
 double rand_factor = 5;
 
+Eigen::VectorXi samples;
+
+void readSamples(const std::string &fname, Eigen::VectorXi &samples)
+{
+    int numSamples;
+    FILE *fp = fopen(fname.c_str(),"r");
+    if (fscanf(fp, "%d", &numSamples)!=1)
+    {
+      fclose(fp);
+      return;
+    }
+    samples.resize(numSamples,1);
+    int vali;
+    for (int i =0; i<numSamples; ++i)
+    {
+      if (fscanf(fp, "%d", &vali)!=1 || vali<0)
+      {
+        fclose(fp);
+        samples.resize(0,1);
+        return;
+      }
+      samples[i]=vali;
+    }
+    fclose(fp);
+
+}
 // Create a random set of tangent vectors
 Eigen::VectorXd random_constraints(const
                                    Eigen::VectorXd& b1, const
@@ -56,8 +82,8 @@ bool key_down(igl::Viewer& viewer, unsigned char key, int modifier)
   // Interpolate
   cerr << "Interpolating " << num * 2 << "-PolyVector field" << endl;
 
-  VectorXi b(3);
-  b << 1511, 603, 506;
+  VectorXi b(4);
+  b << 4550, 2321, 5413, 5350;
 
   MatrixXd bc(b.size(),num*3);
   for (unsigned i=0; i<b.size(); ++i)
@@ -78,14 +104,20 @@ bool key_down(igl::Viewer& viewer, unsigned char key, int modifier)
 
   for (int n=0; n<num; ++n)
   {
-    const MatrixXd &VF = pvf.block(0,n*3,F.rows(),3);
+    MatrixXd VF = MatrixXd::Zero(F.rows(),3);
+    for (unsigned i=0; i<b.size(); ++i)
+      VF.row(b[i]) = bc.row(i);
+
+    for (int i=0; i<samples.rows(); ++i)
+      VF.row(samples[i]) = pvf.block(samples[i],n*3,1,3);
+    // MatrixXd VF = pvf.block(0,n*3,F.rows(),3);
+
     VectorXd c = VF.rowwise().norm();
     MatrixXd C2;
     igl::jet(c,1,1+rand_factor,C2);
     viewer.data.add_edges(B - global_scale*VF, B + global_scale*VF , C2);
   }
 
-
   return false;
 }
 
@@ -94,7 +126,8 @@ int main(int argc, char *argv[])
   using namespace Eigen;
   using namespace std;
   // Load a mesh in OBJ format
-  igl::readOBJ("../shared/snail.obj", V, F);
+  igl::readOBJ("../shared/lilium.obj", V, F);
+  readSamples("../shared/lilium.samples.0.2", samples);
 
   // Compute local basis for faces
   igl::local_basis(V,F,B1,B2,B3);
@@ -103,7 +136,7 @@ int main(int argc, char *argv[])
   igl::barycenter(V, F, B);
 
   // Compute scale for visualizing fields
-  global_scale =  .1*igl::avg_edge_length(V, F);
+  global_scale =  .2*igl::avg_edge_length(V, F);
 
   // Make the example deterministic
   srand(0);
@@ -112,6 +145,9 @@ int main(int argc, char *argv[])
   viewer.data.set_mesh(V, F);
   viewer.callback_key_down = &key_down;
   viewer.core.show_lines = false;
-  key_down(viewer,'3',0);
+  viewer.core.line_width = 10000;// this does not work, why?
+  key_down(viewer,'2',0);
+
+
   viewer.launch();
 }

+ 1319 - 0
tutorial/shared/lilium.samples.0.2

@@ -0,0 +1,1319 @@
+1318
+5567
+4947
+5711
+197
+6233
+5829
+5932
+5620
+2683
+6544
+2283
+2157
+4223
+2552
+4924
+5096
+830
+359
+2209
+6516
+3818
+6569
+2462
+630
+5528
+4141
+4769
+1607
+3370
+2879
+1084
+1274
+2226
+4308
+2965
+2
+2036
+5060
+4031
+605
+4371
+5026
+5493
+4864
+2349
+1841
+3834
+3287
+5740
+5720
+1697
+6482
+4138
+5247
+2645
+5665
+1808
+3753
+6324
+3184
+4009
+4110
+3472
+490
+40
+583
+2681
+6196
+1858
+6142
+2549
+3077
+5415
+4942
+367
+4433
+3614
+401
+5234
+1046
+210
+5859
+6557
+113
+5918
+2950
+6092
+35
+3281
+2193
+296
+1371
+2677
+4969
+4446
+5113
+3093
+803
+3112
+2149
+4696
+4063
+3877
+6494
+2110
+1438
+1577
+2454
+1296
+2423
+1547
+5047
+5206
+3076
+591
+6429
+4012
+2332
+5925
+1429
+467
+4168
+2946
+6547
+3670
+4406
+3696
+2312
+6520
+3809
+882
+5877
+6579
+510
+6224
+3667
+5213
+2587
+3841
+5330
+2304
+5069
+354
+4228
+1013
+1780
+5593
+1766
+1010
+5899
+1005
+5251
+5980
+3294
+5384
+5488
+2673
+4419
+1922
+752
+6194
+5558
+262
+4021
+2640
+2267
+1637
+1231
+1510
+4570
+2123
+6300
+525
+2616
+3761
+5285
+547
+6055
+3852
+1229
+2691
+6293
+5570
+4949
+4112
+5915
+1099
+4314
+3723
+5028
+4086
+696
+3846
+4687
+2646
+3384
+6362
+5699
+1826
+6023
+71
+6266
+4364
+4968
+6354
+4935
+4712
+755
+3498
+4143
+3036
+3963
+250
+6515
+1030
+415
+2334
+2768
+2608
+5972
+1940
+3060
+1706
+6461
+4487
+4424
+1608
+4388
+991
+5727
+1031
+1080
+1866
+3819
+774
+96
+101
+6317
+889
+1165
+2888
+1377
+6452
+1291
+5978
+443
+3043
+531
+2813
+5166
+763
+552
+2108
+2251
+4936
+5862
+4655
+3229
+3931
+2139
+2866
+4630
+5612
+2367
+5722
+5531
+3537
+2034
+1827
+4729
+5686
+4635
+2583
+3492
+2307
+2662
+886
+390
+4218
+5742
+4950
+1742
+3751
+757
+22
+4286
+1484
+4850
+1809
+2083
+5122
+3197
+307
+3971
+3608
+5755
+3767
+2085
+3145
+952
+6299
+1753
+6034
+873
+691
+2324
+6528
+1330
+5639
+6109
+3172
+544
+2345
+898
+3409
+4489
+1634
+1299
+69
+6118
+6147
+3842
+4047
+3481
+142
+2111
+3985
+606
+5332
+3838
+4032
+572
+4903
+3878
+77
+3274
+2501
+1636
+2783
+2053
+458
+4612
+4594
+5083
+1834
+553
+5764
+6361
+88
+1731
+240
+2285
+2842
+5075
+2099
+3155
+6377
+3260
+4415
+3552
+4587
+6097
+4029
+1692
+334
+2832
+3107
+1864
+41
+5144
+4125
+6214
+3821
+1664
+1865
+4814
+1411
+1684
+319
+3839
+2016
+3813
+3925
+3020
+2988
+1906
+4438
+2860
+5537
+3033
+982
+3332
+829
+3869
+2478
+4847
+5163
+2521
+5152
+3889
+1942
+5546
+4855
+4157
+5029
+103
+797
+1494
+901
+5201
+3994
+713
+5856
+1144
+2072
+4857
+1761
+791
+3536
+2963
+554
+2169
+3321
+4987
+4605
+21
+2669
+380
+2428
+550
+3774
+2520
+2414
+5943
+5887
+4098
+1285
+4482
+657
+5768
+1528
+5726
+2696
+5297
+4132
+1465
+6243
+2695
+3296
+4392
+6423
+586
+5103
+3681
+498
+2222
+4430
+2727
+2204
+1701
+3270
+4387
+3084
+790
+5351
+6208
+191
+5651
+4242
+945
+5135
+1146
+3106
+6451
+640
+4023
+1859
+5474
+5359
+870
+5733
+937
+6177
+4644
+4652
+5189
+4934
+4943
+1994
+915
+1976
+3747
+2144
+1279
+3661
+687
+6200
+4532
+3706
+1246
+3634
+4174
+134
+515
+1434
+5886
+2181
+3887
+1830
+6404
+857
+4325
+5930
+884
+5153
+6247
+6183
+6050
+3039
+801
+5134
+3054
+2475
+2896
+6245
+1642
+3844
+5464
+5037
+6474
+6441
+5422
+4837
+4954
+1508
+5261
+1786
+4845
+3769
+5279
+1975
+985
+287
+4990
+1066
+4797
+4683
+5575
+902
+5824
+4873
+697
+5964
+4149
+5591
+1619
+3961
+5812
+2912
+2638
+524
+2271
+948
+4299
+4159
+3298
+4418
+3545
+5719
+1039
+3171
+6048
+1205
+2162
+6502
+473
+2827
+3620
+3392
+3091
+1899
+973
+4598
+5666
+2711
+5983
+4563
+3404
+745
+1261
+4144
+1289
+1914
+5400
+3455
+2042
+6312
+4154
+6132
+5264
+1788
+2297
+2294
+3006
+1310
+5625
+2603
+1343
+5911
+511
+5885
+4955
+3152
+1836
+1598
+1056
+360
+6575
+1632
+996
+5407
+2785
+4870
+4682
+1353
+3880
+2456
+2221
+5737
+4632
+5543
+6498
+3568
+399
+2806
+1741
+3570
+1059
+1575
+1363
+6511
+1921
+1817
+5969
+5071
+1401
+6272
+6450
+3517
+6173
+663
+3597
+517
+2947
+3487
+3894
+5587
+2160
+1180
+2830
+2841
+4161
+3116
+724
+3243
+4033
+4062
+2702
+589
+3647
+4115
+1301
+3508
+739
+4282
+1513
+6349
+471
+3982
+463
+3705
+3916
+4548
+261
+6068
+6127
+5193
+629
+4467
+5758
+2738
+6558
+371
+3434
+1672
+1638
+5365
+5022
+5337
+5627
+1926
+3146
+2277
+2273
+661
+5057
+1407
+5141
+155
+1425
+2129
+4974
+3466
+6256
+5794
+5301
+1983
+6497
+4978
+6526
+1770
+2562
+1297
+760
+2327
+5836
+935
+598
+5520
+6044
+3104
+3353
+1831
+4711
+4829
+4536
+3013
+6232
+3401
+1495
+1255
+2050
+3181
+1918
+768
+678
+4798
+1592
+4486
+5747
+977
+1857
+2891
+5548
+3890
+1483
+2649
+6440
+2174
+3617
+4653
+4525
+633
+6456
+4707
+5319
+5523
+3493
+381
+3032
+2550
+6403
+431
+1045
+2207
+409
+2902
+5879
+1155
+2973
+1055
+2628
+6062
+4215
+3339
+1034
+4195
+364
+5460
+4303
+2442
+1048
+6069
+1655
+4448
+743
+3788
+5521
+4034
+1890
+3088
+4556
+4812
+5503
+6007
+992
+5250
+1341
+81
+4470
+2048
+1318
+4205
+169
+2183
+3748
+6477
+6484
+3193
+5679
+120
+706
+1971
+2949
+3044
+2535
+6447
+2519
+1379
+6032
+2063
+1963
+2540
+4970
+5426
+1444
+5792
+1997
+2544
+742
+2372
+6550
+2404
+1269
+3277
+3095
+65
+6417
+3439
+3944
+770
+6449
+612
+3911
+3373
+655
+5936
+3195
+6298
+1490
+408
+3975
+6368
+4617
+4002
+2576
+5048
+5331
+4677
+3221
+4588
+2141
+2592
+394
+1860
+677
+4001
+5706
+2796
+5800
+2316
+3604
+4217
+3806
+3313
+4663
+1815
+5729
+2865
+1600
+4991
+1737
+6545
+4234
+6052
+5370
+4775
+5173
+3467
+5209
+2355
+4355
+1406
+464
+1828
+4826
+5006
+5310
+459
+3672
+325
+6088
+2074
+5704
+4746
+3153
+5466
+4732
+2597
+6337
+690
+4458
+1345
+5901
+1821
+5810
+6392
+3530
+4375
+5533
+4201
+2913
+1867
+76
+1441
+6529
+6090
+3232
+5945
+670
+975
+5094
+3511
+6556
+1415
+4931
+6342
+5241
+3361
+78
+2461
+748
+6159
+5574
+4905
+2629
+4646
+2633
+482
+2140
+2448
+2200
+4709
+3418
+545
+5469
+3814
+5590
+1417
+5577
+4068
+4302
+2523
+3730
+5155
+4441
+3051
+4886
+5617
+4096
+4057
+6373
+5328
+504
+50
+2006
+3740
+3239
+2778
+1449
+2010
+4327
+1183
+4469
+6190
+3262
+1276
+115
+5156
+3219
+688
+4401
+5140
+3581
+6566
+6207
+6108
+2622
+3594
+3048
+6225
+1950
+3325
+6401
+6572
+3635
+6323
+1647
+3623
+1007
+400
+6420
+5004
+3564
+3432
+954
+3560
+1562
+6283
+5724
+3773
+256
+3732
+2164
+3630
+4189
+4994
+3167
+5129
+392
+4055
+2624
+2715
+4539
+4710
+2756
+1337
+1089
+6011
+5648
+2589
+3955
+943
+1596
+286
+2679
+3205
+855
+1021
+1580
+5717
+1505
+1714
+6549
+151
+6532
+3837
+6518
+304
+3693
+2924
+6568
+5199
+436
+6491
+2176
+6125
+1164
+3871
+2102
+4916
+1956
+1120
+6434
+1457
+5718
+4483
+3575
+5043
+699
+1032
+1464
+5314
+243
+5473
+6128
+3352
+4236
+1883
+5064
+4186
+4741
+4171
+1305
+1385
+3253
+3653
+3137
+6075
+1999
+2898
+6296
+6231
+1234
+1739
+6284
+906
+6121
+4067
+2441
+189
+5374
+6589
+172
+2585
+6493
+1057
+602
+2939
+5443
+476
+5471
+3941
+6216
+1954
+4770
+4657
+4435
+5853
+285
+1268
+4572
+574
+4490
+5217
+5653
+4270
+5034
+4361
+34
+671
+267
+4590
+2884
+3636
+4628
+2745
+5889
+4738
+5986
+4695
+4038
+4937
+2852
+4413
+2556
+217
+4897
+4962
+4103
+4369
+5416
+2753
+2257
+2059
+6002
+3203
+1979
+1290
+3569
+6076
+4997
+4559
+863
+1729
+4092
+3939
+1871
+1375
+4230
+4565
+2781
+4213
+2904
+766
+5753
+1239
+2518
+4751
+3833
+3473
+6543
+1199
+2530
+6053
+3491
+4434
+3858
+1445
+2233
+2177
+2087
+4506
+5850
+1132
+3120
+1240
+6106
+6028
+1479
+2609
+3002
+6509
+5922
+308
+4629
+6507
+4670
+4792
+5705
+5960
+1503
+6459
+4805
+3525
+1352
+2862
+4794
+2579
+4264
+3883
+4699
+837
+4037
+4499
+1628
+1801
+938
+1024
+4399
+1095
+2636
+164
+5823
+6394
+3959
+751
+5632
+2245
+3275
+3521
+2507
+3351
+1408
+2244
+6228
+1910
+1286
+3879
+1850
+3917
+3934
+6210
+4495
+5317
+6267
+1472
+4591
+1143
+5085
+4380
+1366
+5049
+1339
+2600
+819
+5197
+4552
+3444
+339
+682
+2905
+649
+6213
+5890
+5266
+3196
+3271
+4277
+3779
+3010
+5011
+5211
+3795
+5320
+6022
+1043
+5851
+340
+2663
+3962
+3895
+3499
+3066
+6490
+758
+139
+5412