7
$\begingroup$

Does anyone know how one can plot contour lines on a meshed surface? For example I would like to be able to plot contour lines indicating lines of equal distance from a given point such as data coming from (here). The data that I have would be the mesh, on which I know the value of my function at each vertex. A related questions is I see (here) but this seems to be related to analytical surfaces, perhaps it is also possible to interpolate (like the question here), but I only want the interpolation to run on the mesh itself not in 3D.

One workaround that I had was to use Blend (based on Federico's answer here) to define a colour function such as:

stripes[x_] := Blend[{Black, White, White, Black, White, White, Black, White, White, Black, White, White}, x]

This can be used to plot the following data:

data={1.75204, 0., 1.10202, 2.02667, 2.02667, 2.02667, 1.10202, 1.10202,1.37795, 1.37795, 0.650958, 0.650958, 1.37795, 1.75204, 1.75204, 2.47668, 2.47668, 0.650958, 1.75204, 0.650958, 1.75204, 2.47668, 0.650958, 1.37795, 1.37795, 2.47668, 2.47668, 1.10202, 3.1221, 1.10202, 2.02667, 2.02667, 1.53907, 1.31533, 1.17645, 1.27226, 1.49697, 1.62933, 1.31533, 1.53907, 1.62933, 1.49697, 1.27226, 1.17645, 1.59089, 1.81417, 1.94988, 1.85371, 1.62983, 1.49697, 1.81417, 1.59089, 1.49697, 1.62933, 1.85371, 1.94988, 2.34889, 2.18956, 1.94988, 1.85371, 1.9889, 2.24038, 1.49697, 1.62933, 1.85371, 1.94988, 1.85371, 1.94988, 2.18956, 2.34889, 2.24038, 1.9889, 1.94988, 1.85371, 1.62933, 1.49697, 1.17645, 1.27226, 1.14074, 0.888443, 0.774045, 0.933683, 1.27226, 1.17645, 1.27226, 1.17645, 0.933683, 0.774045, 0.888443, 1.14074, 1.17645, 1.27226, 1.81417, 1.59089, 1.49697, 1.62933, 1.62983, 1.49697, 0.774045, 0.933683, 1.14074, 0.888443, 0.933683, 0.774045, 0.888443, 1.14074, 2.34889, 2.18956, 1.94988, 1.85371, 1.9889, 2.24038, 2.18956, 2.34889, 1.85371, 1.94988, 1.81417, 1.59089, 1.49697, 1.62933, 1.62933, 1.49697, 1.59089, 1.81417, 2.18956, 2.34889, 2.56, 2.56, 2.34889, 2.18956, 2.34889, 2.18956, 2.18956, 2.34889, 2.56, 2.56, 1.31533, 1.53907, 1.27226, 1.17645, 1.31533, 1.53907, 1.17645, 1.27226, 1.53907, 1.31533, 0.563442, 0.563442, 0.774045, 0.933683, 0.933683, 0.774045, 0.563442, 0.563442, 2.91082, 2.68867, 2.56, 2.56, 2.68867, 2.91082, 0.213492, 0.437551, 0.563442, 0.563442, 0.437551, 0.213492, 1.9889, 2.24038, 2.24038, 1.9889, 2.68867, 2.91082, 2.91082, 2.68867, 0.774045, 0.933683, 1.14074, 0.888443, 0.933683, 0.774045, 0.563442, 0.563442, 0.774045, 0.933683, 0.933683, 0.774045, 0.563442, 0.563442, 0.437551, 0.213492, 0.213492, 0.437551, 0.437551, 0.213492, 1.94988, 1.85371, 1.85371, 1.94988, 1.17645, 1.27226, 1.27226, 1.17645, 2.56, 2.56, 2.68867, 2.91082, 2.56, 2.56, 2.18956, 2.34889, 2.34889, 2.18956, 1.40159, 1.40159, 1.72514, 1.72514, 2.10217, 1.72514, 2.10217, 1.72514, 1.02297, 1.40159, 1.02297, 1.40159, 1.72514, 1.72514, 1.02297, 1.02297, 2.10217, 2.10217, 1.72514, 1.72514, 2.38575, 2.38575, 1.40159, 1.40159, 1.40159, 1.40159, 0.74117, 0.74117, 2.76365, 0.360999, 2.10217, 2.10217, 2.76365, 2.76365, 1.02297, 1.02297, 0.74117, 0.74117, 0.360999, 0.360999, 1.72514, 1.72514, 1.40159, 1.40159, 2.76365, 2.76365, 2.10217, 2.10217, 1.02297, 1.02297, 0.360999, 0.360999, 0.74117, 2.38575, 2.38575, 2.38575, 2.10217, 2.10217, 1.02297, 1.02297};

vertices={{-0.607062,0.,0.794654},{0.894427,0.,0.447214},{0.,0.,1.},{-0.723607,-0.525731,0.447214},{-0.723607,0.525731,0.447214},{0.,0.,-1.},{0.276393,-0.850651,0.447214},{0.276393,0.850651,0.447214},{-0.187592,-0.57735,0.794654},{-0.187592,0.57735,0.794654},{0.491123,0.356822,0.794654},{0.491123,-0.356822,0.794654},{0.607062,0.,-0.794654},{0.187592,-0.57735,-0.794654},{0.187592,0.57735,-0.794654},{-0.491123,0.356822,-0.794654},{-0.491123,-0.356822,-0.794654},{0.794654,-0.57735,0.187592},{-0.303531,-0.934172,0.187592},{0.794654,0.57735,0.187592},{-0.303531,0.934172,0.187592},{-0.982247,0.,0.187592},{0.982247,0.,-0.187592},{0.303531,-0.934172,-0.187592},{0.303531,0.934172,-0.187592},{-0.794654,-0.57735,-0.187592},{-0.794654,0.57735,-0.187592},{0.723607,-0.525731,-0.447214},{-0.894427,0.,-0.447214},{0.723607,0.525731,-0.447214},{-0.276393,-0.850651,-0.447214},{-0.276393,0.850651,-0.447214},{-0.115625,-0.950755,0.287569},{0.0871575,-0.92155,0.378351},{0.127698,-0.796779,0.590623},{-0.0345446,-0.701214,0.712114},{-0.240241,-0.739387,0.62896},{-0.28128,-0.865689,0.414082},{0.0871575,0.92155,0.378351},{-0.115625,0.950755,0.287569},{-0.28128,0.865689,0.414082},{-0.240241,0.739387,0.62896},{-0.0345446,0.701214,0.712114},{0.127698,0.796779,0.590623},{0.115625,-0.950755,-0.287569},{-0.0871575,-0.92155,-0.378351},{-0.127698,-0.796779,-0.590623},{0.0345446,-0.701214,-0.712114},{0.240241,-0.739387,-0.62896},{0.28128,-0.865689,-0.414082},{-0.0871575,0.92155,-0.378351},{0.115625,0.950755,-0.287569},{0.28128,0.865689,-0.414082},{0.240241,0.739387,-0.62896},{0.0345446,0.701214,-0.712114},{-0.127698,0.796779,-0.590623},{-0.343464,-0.249541,-0.905407},{-0.171732,-0.12477,-0.977211},{0.0655957,-0.201883,-0.977211},{0.131191,-0.403766,-0.905407},{-0.0410381,-0.535025,-0.843839},{-0.28128,-0.456966,-0.843839},{0.107439,-0.991992,-0.0664011},{-0.107439,-0.991992,0.0664011},{-0.308919,-0.950755,-0.0251864},{-0.29943,-0.92155,-0.24716},{0.131191,0.403766,-0.905407},{0.0655957,0.201883,-0.977211},{-0.171732,0.12477,-0.977211},{-0.343464,0.249541,-0.905407},{-0.28128,0.456966,-0.843839},{-0.0410381,0.535025,-0.843839},{-0.29943,0.92155,-0.24716},{-0.308919,0.950755,-0.0251864},{-0.107439,0.991992,0.0664011},{0.107439,0.991992,-0.0664011},{-0.0655957,-0.201883,0.977211},{-0.131191,-0.403766,0.905407},{0.0410381,-0.535025,0.843839},{0.28128,-0.456966,0.843839},{0.343464,-0.249541,0.905407},{0.171732,-0.12477,0.977211},{0.308919,-0.950755,0.0251864},{0.29943,-0.92155,0.24716},{-0.131191,0.403766,0.905407},{-0.0655957,0.201883,0.977211},{0.171732,0.12477,0.977211},{0.343464,0.249541,0.905407},{0.28128,0.456966,0.843839},{0.0410381,0.535025,0.843839},{0.29943,0.92155,0.24716},{0.308919,0.950755,0.0251864},{0.212272,0.,-0.977211},{0.424544,0.,-0.905407},{0.496158,-0.204362,-0.843839},{0.347681,-0.408723,-0.843839},{0.347681,0.408723,-0.843839},{0.496158,0.204362,-0.843839},{0.652383,-0.701214,0.287569},{0.471161,-0.796779,0.378351},{0.496158,-0.865689,-0.0664011},{0.669998,-0.739387,0.0664011},{0.471161,0.796779,0.378351},{0.652383,0.701214,0.287569},{0.669998,0.739387,0.0664011},{0.496158,0.865689,-0.0664011},{-0.939952,-0.183833,0.287569},{-0.849513,-0.367666,0.378351},{-0.718321,-0.367666,0.590623},{-0.677569,-0.183833,0.712114},{-0.777438,0.,0.62896},{-0.91024,0.,0.414082},{-0.849513,0.367666,0.378351},{-0.939952,0.183833,0.287569},{-0.677569,0.183833,0.712114},{-0.718321,0.367666,0.590623},{-0.571645,-0.569549,0.590623},{-0.384216,-0.587599,0.712114},{-0.347681,-0.408723,0.843839},{-0.496158,-0.204362,0.843839},{-0.496158,0.204362,0.843839},{-0.347681,0.408723,0.843839},{-0.384216,0.587599,0.712114},{-0.571645,0.569549,0.590623},{-0.471161,-0.796779,-0.378351},{-0.652383,-0.701214,-0.287569},{-0.736399,-0.535025,-0.414082},{-0.62896,-0.456966,-0.62896},{-0.44011,-0.546989,-0.712114},{-0.365025,-0.719667,-0.590623},{-0.652383,0.701214,-0.287569},{-0.471161,0.796779,-0.378351},{-0.365025,0.719667,-0.590623},{-0.44011,0.546989,-0.712114},{-0.62896,0.456966,-0.62896},{-0.736399,0.535025,-0.414082},{-0.212272,0.,0.977211},{-0.424544,0.,0.905407},{0.677569,-0.183833,-0.712114},{0.718321,-0.367666,-0.590623},{0.571645,-0.569549,-0.590623},{0.384216,-0.587599,-0.712114},{0.718321,0.367666,-0.590623},{0.677569,0.183833,-0.712114},{0.384216,0.587599,-0.712114},{0.571645,0.569549,-0.590623},{0.736399,-0.535025,0.414082},{0.62896,-0.456966,0.62896},{0.44011,-0.546989,0.712114},{0.365025,-0.719667,0.590623},{0.365025,0.719667,0.590623},{0.44011,0.546989,0.712114},{0.62896,0.456966,0.62896},{0.736399,0.535025,0.414082},{-0.797243,0.12477,-0.590623},{-0.656219,0.249541,-0.712114},{-0.521521,0.126302,-0.843839},{-0.521521,-0.126302,-0.843839},{-0.656219,-0.249541,-0.712114},{-0.797243,-0.12477,-0.590623},{0.797243,0.12477,0.590623},{0.656219,0.249541,0.712114},{0.521521,0.126302,0.843839},{0.521521,-0.126302,0.843839},{0.656219,-0.249541,0.712114},{0.797243,-0.12477,0.590623},{-0.496158,-0.865689,0.0664011},{-0.669998,-0.739387,-0.0664011},{-0.669998,0.739387,-0.0664011},{-0.496158,0.865689,0.0664011},{-0.868491,-0.403766,-0.287569},{-0.903379,-0.201883,-0.378351},{-0.903379,0.201883,-0.378351},{-0.868491,0.403766,-0.287569},{0.939952,-0.183833,-0.287569},{0.849513,-0.367666,-0.378351},{0.777438,0.,-0.62896},{0.91024,0.,-0.414082},{0.849513,0.367666,-0.378351},{0.939952,0.183833,-0.287569},{0.976641,-0.204362,-0.0664011},{0.91024,-0.408723,0.0664011},{0.80876,-0.587599,-0.0251864},{0.783917,-0.569549,-0.24716},{0.783917,0.569549,-0.24716},{0.80876,0.587599,-0.0251864},{0.91024,0.408723,0.0664011},{0.976641,0.204362,-0.0664011},{0.999683,0.,0.0251864},{0.968975,0.,0.24716},{0.903379,-0.201883,0.378351},{0.868491,-0.403766,0.287569},{0.868491,0.403766,0.287569},{0.903379,0.201883,0.378351},{-0.612185,-0.69432,0.378351},{-0.465297,-0.83714,0.287569},{-0.465297,0.83714,0.287569},{-0.612185,0.69432,0.378351},{0.612185,-0.69432,-0.378351},{0.465297,-0.83714,-0.287569},{0.465297,0.83714,-0.287569},{0.612185,0.69432,-0.378351},{-0.91024,-0.408723,-0.0664011},{-0.976641,-0.204362,0.0664011},{-0.999683,0.,-0.0251864},{-0.968975,0.,-0.24716},{-0.976641,0.204362,0.0664011},{-0.91024,0.408723,-0.0664011},{-0.783917,-0.569549,0.24716},{-0.80876,-0.587599,0.0251864},{-0.80876,0.587599,0.0251864},{-0.783917,0.569549,0.24716},{-0.077538,-0.852969,0.516171},{-0.077538,0.852969,0.516171},{0.077538,-0.852969,-0.516171},{0.077538,0.852969,-0.516171},{-0.109603,-0.337325,-0.934986},{-0.0998042,-0.981815,-0.161487},{-0.109603,0.337325,-0.934986},{-0.0998042,0.981815,-0.161487},{0.109603,-0.337325,0.934986},{0.0998042,-0.981815,0.161487},{0.109603,0.337325,0.934986},{0.0998042,0.981815,0.161487},{0.286946,-0.208478,-0.934986},{0.286946,0.208478,-0.934986},{0.496353,-0.852969,0.161487},{0.496353,0.852969,0.161487},{-0.835182,-0.189839,0.516171},{-0.835182,0.189839,0.516171},{-0.548236,-0.398317,0.735378},{-0.548236,0.398317,0.735378},{-0.564092,-0.64449,-0.516171},{-0.564092,0.64449,-0.516171},{-0.286946,-0.208478,0.934986},{-0.286946,0.208478,0.934986},{0.548236,-0.398317,-0.735378},{0.548236,0.398317,-0.735378},{0.564092,-0.64449,0.516171},{0.564092,0.64449,0.516171},{-0.677657,1.50336*10^-17,-0.735378},{0.677657,1.50336*10^-17,0.735378},{-0.496353,-0.852969,-0.161487},{-0.496353,0.852969,-0.161487},{-0.787261,-0.337325,-0.516171},{-0.787261,0.337325,-0.516171},{0.835182,-0.189839,-0.516171},{0.835182,0.189839,-0.516171},{0.902921,-0.398317,-0.161487},{0.902921,0.398317,-0.161487},{0.964603,-0.208478,0.161487},{0.964603,0.208478,0.161487},{-0.438633,-0.735642,0.516171},{-0.438633,0.735642,0.516171},{0.438633,-0.735642,-0.516171},{0.438633,0.735642,-0.516171},{-0.964603,-0.208478,-0.161487},{-0.964603,0.208478,-0.161487},{-0.65784,-0.735642,0.161487},{-0.65784,0.735642,0.161487},{0.65784,-0.735642,-0.161487},{0.65784,0.735642,-0.161487},{0.787261,-0.337325,0.516171},{0.787261,0.337325,0.516171},{0.354684,0.,0.934986},{-0.902921,-0.398317,0.161487},{-0.902921,0.398317,0.161487},{-0.354684,0.,-0.934986},{-0.209408,-0.64449,-0.735378},{-0.209408,0.64449,-0.735378},{0.209408,-0.64449,0.735378},{0.209408,0.64449,0.735378}};

tris={{7,35,34},{34,35,213},{34,213,33},{33,213,38},{33,38,19},{35,36,213},{213,36,37},{213,37,38},{36,9,37},{21,41,40},{40,41,214},{40,214,39},{39,214,44},{39,44,8},{41,42,214},{214,42,43},{214,43,44},{42,10,43},{31,47,46},{46,47,215},{46,215,45},{45,215,50},{45,50,24},{47,48,215},{215,48,49},{215,49,50},{48,14,49},{25,53,52},{52,53,216},{52,216,51},{51,216,56},{51,56,32},{53,54,216},{216,54,55},{216,55,56},{54,15,55},{6,59,58},{58,59,217},{58,217,57},{57,217,62},{57,62,17},{59,60,217},{217,60,61},{217,61,62},{60,14,61},{24,63,45},{45,63,218},{45,218,46},{46,218,66},{46,66,31},{63,64,218},{218,64,65},{218,65,66},{64,19,65},{6,69,68},{68,69,219},{68,219,67},{67,219,72},{67,72,15},{69,70,219},{219,70,71},{219,71,72},{70,16,71},{21,75,74},{74,75,220},{74,220,73},{73,220,51},{73,51,32},{75,76,220},{220,76,52},{220,52,51},{76,25,52},{9,79,78},{78,79,221},{78,221,77},{77,221,82},{77,82,3},{79,80,221},{221,80,81},{221,81,82},{80,12,81},{7,34,84},{84,34,222},{84,222,83},{83,222,63},{83,63,24},{34,33,222},{222,33,64},{222,64,63},{33,19,64},{3,87,86},{86,87,223},{86,223,85},{85,223,90},{85,90,10},{87,88,223},{223,88,89},{223,89,90},{88,11,89},{8,91,39},{39,91,224},{39,224,40},{40,224,75},{40,75,21},{91,92,224},{224,92,76},{224,76,75},{92,25,76},{13,95,94},{94,95,225},{94,225,93},{93,225,59},{93,59,6},{95,96,225},{225,96,60},{225,60,59},{96,14,60},{6,68,93},{93,68,226},{93,226,94},{94,226,98},{94,98,13},{68,67,226},{226,67,97},{226,97,98},{67,15,97},{7,84,100},{100,84,227},{100,227,99},{99,227,102},{99,102,18},{84,83,227},{227,83,101},{227,101,102},{83,24,101},{8,103,91},{91,103,228},{91,228,92},{92,228,106},{92,106,25},{103,104,228},{228,104,105},{228,105,106},{104,20,105},{4,109,108},{108,109,229},{108,229,107},{107,229,112},{107,112,22},{109,110,229},{229,110,111},{229,111,112},{110,1,111},{22,112,114},{114,112,230},{114,230,113},{113,230,116},{113,116,5},{112,111,230},{230,111,115},{230,115,116},{111,1,115},{9,119,118},{118,119,231},{118,231,117},{117,231,109},{117,109,4},{119,120,231},{231,120,110},{231,110,109},{120,1,110},{1,121,115},{115,121,232},{115,232,116},{116,232,124},{116,124,5},{121,122,232},{232,122,123},{232,123,124},{122,10,123},{26,127,126},{126,127,233},{126,233,125},{125,233,130},{125,130,31},{127,128,233},{233,128,129},{233,129,130},{128,17,129},{32,133,132},{132,133,234},{132,234,131},{131,234,136},{131,136,27},{133,134,234},{234,134,135},{234,135,136},{134,16,135},{3,137,77},{77,137,235},{77,235,78},{78,235,119},{78,119,9},{137,138,235},{235,138,120},{235,120,119},{138,1,120},{3,86,137},{137,86,236},{137,236,138},{138,236,121},{138,121,1},{86,85,236},{236,85,122},{236,122,121},{85,10,122},{28,141,140},{140,141,237},{140,237,139},{139,237,95},{139,95,13},{141,142,237},{237,142,96},{237,96,95},{142,14,96},{13,98,144},{144,98,238},{144,238,143},{143,238,146},{143,146,30},{98,97,238},{238,97,145},{238,145,146},{97,15,145},{18,147,99},{99,147,239},{99,239,100},{100,239,150},{100,150,7},{147,148,239},{239,148,149},{239,149,150},{148,12,149},{8,151,103},{103,151,240},{103,240,104},{104,240,154},{104,154,20},{151,152,240},{240,152,153},{240,153,154},{152,11,153},{16,157,156},{156,157,241},{156,241,155},{155,241,160},{155,160,29},{157,158,241},{241,158,159},{241,159,160},{158,17,159},{11,163,162},{162,163,242},{162,242,161},{161,242,166},{161,166,2},{163,164,242},{242,164,165},{242,165,166},{164,12,165},{19,167,65},{65,167,243},{65,243,66},{66,243,125},{66,125,31},{167,168,243},{243,168,126},{243,126,125},{168,26,126},{27,169,131},{131,169,244},{131,244,132},{132,244,73},{132,73,32},{169,170,244},{244,170,74},{244,74,73},{170,21,74},{29,160,172},{172,160,245},{172,245,171},{171,245,127},{171,127,26},{160,159,245},{245,159,128},{245,128,127},{159,17,128},{27,136,174},{174,136,246},{174,246,173},{173,246,155},{173,155,29},{136,135,246},{246,135,156},{246,156,155},{135,16,156},{28,140,176},{176,140,247},{176,247,175},{175,247,178},{175,178,23},{140,139,247},{247,139,177},{247,177,178},{139,13,177},{23,178,180},{180,178,248},{180,248,179},{179,248,143},{179,143,30},{178,177,248},{248,177,144},{248,144,143},{177,13,144},{23,181,175},{175,181,249},{175,249,176},{176,249,184},{176,184,28},{181,182,249},{249,182,183},{249,183,184},{182,18,183},{30,185,179},{179,185,250},{179,250,180},{180,250,188},{180,188,23},{185,186,250},{250,186,187},{250,187,188},{186,20,187},{2,191,190},{190,191,251},{190,251,189},{189,251,181},{189,181,23},{191,192,251},{251,192,182},{251,182,181},{192,18,182},{23,188,189},{189,188,252},{189,252,190},{190,252,194},{190,194,2},{188,187,252},{252,187,193},{252,193,194},{187,20,193},{19,38,196},{196,38,253},{196,253,195},{195,253,117},{195,117,4},{38,37,253},{253,37,118},{253,118,117},{37,9,118},{5,124,198},{198,124,254},{198,254,197},{197,254,41},{197,41,21},{124,123,254},{254,123,42},{254,42,41},{123,10,42},{24,50,200},{200,50,255},{200,255,199},{199,255,141},{199,141,28},{50,49,255},{255,49,142},{255,142,141},{49,14,142},{30,146,202},{202,146,256},{202,256,201},{201,256,53},{201,53,25},{146,145,256},{256,145,54},{256,54,53},{145,15,54},{26,203,171},{171,203,257},{171,257,172},{172,257,206},{172,206,29},{203,204,257},{257,204,205},{257,205,206},{204,22,205},{22,207,205},{205,207,258},{205,258,206},{206,258,173},{206,173,29},{207,208,258},{258,208,174},{258,174,173},{208,27,174},{4,209,195},{195,209,259},{195,259,196},{196,259,167},{196,167,19},{209,210,259},{259,210,168},{259,168,167},{210,26,168},{5,198,212},{212,198,260},{212,260,211},{211,260,169},{211,169,27},{198,197,260},{260,197,170},{260,170,169},{197,21,170},{18,102,183},{183,102,261},{183,261,184},{184,261,199},{184,199,28},{102,101,261},{261,101,200},{261,200,199},{101,24,200},{25,106,201},{201,106,262},{201,262,202},{202,262,185},{202,185,30},{106,105,262},{262,105,186},{262,186,185},{105,20,186},{2,166,191},{191,166,263},{191,263,192},{192,263,147},{192,147,18},{166,165,263},{263,165,148},{263,148,147},{165,12,148},{20,154,193},{193,154,264},{193,264,194},{194,264,161},{194,161,2},{154,153,264},{264,153,162},{264,162,161},{153,11,162},{3,82,87},{87,82,265},{87,265,88},{88,265,163},{88,163,11},{82,81,265},{265,81,164},{265,164,163},{81,12,164},{4,108,209},{209,108,266},{209,266,210},{210,266,203},{210,203,26},{108,107,266},{266,107,204},{266,204,203},{107,22,204},{5,212,113},{113,212,267},{113,267,114},{114,267,207},{114,207,22},{212,211,267},{267,211,208},{267,208,207},{211,27,208},{6,58,69},{69,58,268},{69,268,70},{70,268,157},{70,157,16},{58,57,268},{268,57,158},{268,158,157},{57,17,158},{17,62,129},{129,62,269},{129,269,130},{130,269,47},{130,47,31},{62,61,269},{269,61,48},{269,48,47},{61,14,48},{15,72,55},{55,72,270},{55,270,56},{56,270,133},{56,133,32},{72,71,270},{270,71,134},{270,134,133},{71,16,134},{7,150,35},{35,150,271},{35,271,36},{36,271,79},{36,79,9},{150,149,271},{271,149,80},{271,80,79},{149,12,80},{10,90,43},{43,90,272},{43,272,44},{44,272,151},{44,151,8},{90,89,272},{272,89,152},{272,152,151},{89,11,152}};

Graphics3D[{EdgeForm[],GraphicsComplex[vertices, Map[Polygon, tris], VertexColors -> Table[stripes[data[[i]]/Max[data]], {i, 1,Length[vertices]}]]}, Boxed -> False, Lighting -> "Neutral"]

which gives:

example

Clearly this method using VertexColors goes in the right direction giving bands on the surface that are associated with a given distance (scaling needs to be sorted afterwards for such a function), but the interpolation with this method is fairly coarse. Does anyone have hints about how a contour line could be calculated based on this sort of data?g

$\endgroup$
  • $\begingroup$ You can probably use SliceContourPlot3D to get what you need. I made a contour plot on the space shuttle example mesh here $\endgroup$ – Jason B. Mar 15 '17 at 14:49
  • $\begingroup$ Also, if you only know the function value at the mesh points, then ListSliceContourPlot3D would be appropriate. $\endgroup$ – rcollyer Mar 15 '17 at 14:52
  • $\begingroup$ @JasobB and rcollyer. Thanks, both look promising. I will try them out and see what I get. I have to admit I didn't think about checking the FEM functionality at all. $\endgroup$ – Dunlop Mar 15 '17 at 15:46
  • $\begingroup$ @rcollyer Something like this worked well: mesh = BoundaryDiscretizeRegion[Ball[{0, 0, 0}, 1], MaxCellMeasure -> {"Length" -> 0.3}, PrecisionGoal -> 1] plotdata = Map[Join[vertices[[#]], {data[[#]]}] &, Range[Length[vertices]]]; ListSliceContourPlot3D[data, a]; $\endgroup$ – Dunlop Mar 15 '17 at 16:04
11
$\begingroup$

You can feed this data almost as-is to ListSliceContourPlot3D,

surf = MeshRegion[vertices, Map[Polygon, tris]];
ListSliceContourPlot3D[MapThread[Append, {vertices, data}], surf]

Mathematica graphics

| improve this answer | |
$\endgroup$
4
$\begingroup$

straightforward draw a line where each contour cuts each triangle:

conttri[tri_, v_] := Module[{s},
   s = Select[ Subsets[tri, {2}] , 
     Ordering[ Append[MinMax@data[[#]], v]] == {1, 3, 2} & ];
   Line[(Interpolation[Transpose[{data[[#]], vertices[[#]]}], 
         InterpolationOrder -> 1])[v] & /@ s]
   ];
cline[v_] := (conttri[#, v] & /@ 
   Select[tris, Ordering[ Append[MinMax@data[[#]], v]] == {1, 3, 2} &])
Show[{g1,  Graphics3D[{Hue[#], cline[#]} & /@ 
         Subdivide[Sequence @@ MinMax@data, 10]]}]

enter image description here

( g1 is the Graphics3D from the OP )

| improve this answer | |
$\endgroup$
  • $\begingroup$ That is great and adds a lot of flexibility into the presentation of the data. Many thanks $\endgroup$ – Dunlop Mar 15 '17 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.