1

FEM example

Hello! I am trying to implement a simple way to display the deformed shape of a beam. I found HelixToolkit that offers perfect tools, but I can't find the way to display different tiles of the same mesh with a different colour, or gradient. I found this: https://github.com/helix-toolkit/helix-toolkit/issues/885 that is the adding of the VertColorMaterial property, but it looks like it is for SharpDX library, but I started with HelixToolkit wpf (don't understand if in HelixToolkit is also available).

I can't even find a way to do it with SharpDX: it looks that there is almost no doc in internet.

Additionaly, SharpDX stopped its developement.

So:

  • do you know any example?
  • do you suggest me another library, which is fast/offers the ability of navigate the model, and it is compatible/use the wpf framework?

I also would like the ability to refine and subdivide a mesh.

Any kind of advice would be useful, I am new to the world of computer 3d graphic.

Thanks

EDIT 1:

I followed JonasH hint applying a texture, but it apply the texture for each tile. (See image).

I can only dinstict by out materian and in materia (set in the picture as Hue and the arrow Texture).

I need to apply one color for each polygon to give to the mesh a "FEM" style. Do you know how is it possibile with HelixToolkit? 3d mesh with applied texture

max_s
  • 83
  • 1
  • 8
  • _[Questions asking us to recommend or find a book, tool, **software library**, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.](http://stackoverflow.com/help/on-topic)_ –  Jul 17 '20 at 07:34
  • The plot you show at the start of your question is beautiful. Looks like it's displaying axial normal stress on the deformed shape. How did you generate that? – duffymo Sep 14 '20 at 21:05

2 Answers2

2

You might consider using Kitware VTK instead of HelixToolkit. It’s extremely powerful library for scientific data visualization, well documented, perfect for finite element pre and post processing. You can take a look on my app, unfortunately it has not been documented yet, but just as an example: https://github.com/galuszkm/STAN

0

I assume you have a color per vertex you want to use. I would recommend using wpf or helixToolkit wpf since they are quite easy to use. But as far as I'm aware they do not support vertex coloring.

A workaround would be to use a texture. I would assume you want to visualize some scalar property as a color. You would first need to create your MeshGeometry and assign the TextureCoordinates, simply assign the value you want to visualize to one of the texture coordinates in the 0-1 range. You would also need to create a gradient texture, either a gradientBrush or create an image. You would then assign the brush like:

        var brush = new ImageBrush()
        {
            ImageSource = new BitmapImage(new Uri("gradient.png", UriKind.Relative))
        };
           
        var material = new DiffuseMaterial(brush);
        GeometryModel3D model = new GeometryModel3D(mesh, material);
JonasH
  • 28,608
  • 2
  • 10
  • 23
  • I tried to follow your solutions, but I found some problems: I would need a 2d gradient more than a linear gradient (or, at least, a "triangle" gradient). Ok, maybe I can still make a workaround "mixing" two gradients (even if I think, the performance would not be the best). Then, the second problem is that I need to apply a different gradient for each polygon in the mesh: is it possible? The other solution is an UV mapping, with a gradient, but I don't find any good example to see how it works on custom meshes. – max_s Jul 17 '20 at 09:34
  • @max_s The texture is mapped to the triangles using the texture-coordinates. So you should get a unique gradient for each triangle as long as the texture-coordinates are unique. That said, I have not tested this, it is just how I would approach the problem. – JonasH Jul 17 '20 at 09:40