Mesh Face Coloring

What is the most efficient approach to mesh face coloring for a large mesh (say 50,000 faces or more)? Each face will be painted a solid color based on user-defined information. The approaches I have considered so far include:

a. Display conduit in which I draw each face as a polygon with a specific color (first attempts at this seem to be very slow).
b. Add redundant vertices to the mesh so that each face has its own set of 3 or 4 vertices and set vertex colors (seems less than ideal).
c. Break the mesh up into separate meshes with common face colors (additional bookkeeping to track the “child” meshes)

Any other ideas?

Thanks, Larry

Hi Larry,

If possible, I would just use a display conduit. Here is a C++ sample to draw a face-colored mesh.

https://github.com/mcneel/Rhino5Samples_CPP/blob/master/SampleDisplayConduits/cmdSampleMeshFaceColor.cpp

If you run into roadblocks porting this to RhinoCommon, let me know.

– Dale

Thanks Dale. I’ll give that a shot.

Larry

Wow, that is a really long and hard path to take to draw colored mesh faces. I can see why Dale’s sample is written the way it is, but we should really try to come up with a better solution.

@jeff, I’ve seen this request for drawing each face of a mesh as a different color before. We may want to think about a way to add this functionality to the V6 display SDK so a set of “face colors” could be used instead of vertex colors.

Larry, I would go personally go with the approach of adding redundant vertices where face colors need to change. You could optimize this by only adding vertices where the color actually needs to change instead of blindly adding vertices for every face. This is going to draw a lot faster in a conduit than looping over each face and calling DrawFace.

2 Likes

Steve, thanks for the reply. I wanted to make sure I correctly interpreted your last statement, “This is going to draw a lot faster in a conduit than looping over each face and calling DrawFace.” Are you suggesting I still somehow use a conduit for adding vertices? I was thinking the multi-vertex approach would forgo the conduit entirely.

Hi Larry,
I just thought you were working in a conduit to perform some sort of temporary analysis display. Yes, if you use the multi-vertex approach, you could completely forgo the conduit when it makes sense to just have the mesh in the model.

@dale, the link above is broken. Is the sample still available someplace?

Rene

HI @rene_hiemstra,

All of the developer samples have been consolidated here:

– Dale

Hi @dale,

I couldn’t find the mesh displayconduit from the developer samples. Is there any progress in this matter of speeding the drawing of colored mesh with constant face colors? Right now I’m creating a new mesh from each face and then drawing them one by one in the display conduit. This becomes over 10 times slower than drawing the whole mesh at once. It is a little bit of a problem when I have a mesh with over 10 000 faces.

Hi @matti.pirinen,

Can you provide more details on why what you are trying to do. I understand you want to draw each mesh with a different face color. But why? What problem does this help you solve?

– Dale

Hi @dale,

As part of our plugin we have a postprosessor for FEM calculations. So we will import a fem mesh and the results for the mesh. Some results are only available for each face. So I want to show the result with colors and it should be constant over face. That’s why I need a constant color for each mesh face. As I said in the message above this is done now by dividing each mesh face in my result mesh into its own mesh instance and giving the same color to each vertice of this mesh.

Hi @matti.pirinen,

The details are helpful - thanks. I’ve added a wish item to the pile.

https://mcneel.myjetbrains.com/youtrack/issue/RH-54608

– Dale

2 Likes

Hi @Matti,

I am also using rhino as a postprocessor of FEM calculation results.

We are working on IFC export, and also having this issue of defining colors by faces rather that by vertex.

Would you like to talk about your plug-in ? We might be interested. My mail : tanguy.prevost@setec.com

Tanguy