Activedoc.Objects.AddMesh - Broken in latest Rhino 6?

Hi all,
This works in Rhino 5, but in Rhino 6, does not throw an exception, but does not do what it is supposed to do either:

Line 481 if (Mesh_Map != null) Rhino.RhinoDoc.ActiveDoc.Objects.AddMesh(Mesh_Map);

It pretty much does nothing, at least in my code. This seems to be in the latest Rhino 6 release (it was working fine a month ago, I think).

Is there a workaround? Does this need to change in transition to Rhino 6 for some reason?

Did you check if the mesh was null or invalid?

Is the mesh valid? If not, Rhino will not allow you to just add it to the document without jumping through extra hoops that prove you understand you’re doing something risky.

Yes. The mesh is valid. As I mentioned before, the exact same model exact same operation, works fine in Rhino 5. Checking during debug, I can’t find anything odd about it.

Arthur

I know, but the metrics for mesh validity may have been sharpened in Rhino6 turning a mesh that was previously considered valid into an invalid one.

Did you call the IsValid method on the mesh to see if it returns true?

Interesting… although my code doesn’t do anything interesting with the meshes at all. It stores a mesh that rhino generates and assigns colors. The only modification I think is that it gives each polygon a distinct set of vertices, so that it won’t interpolate colors between vertices. I will try it, though.

Is there a resource that explains the new criteria?

IsValid = false

Thanks for informing me of this change. So given my share that my code discretizes each polygon so that false color shading is disabled and each polygon can have its own color (and I suspect this is what is causing the issue), I have two questions:

  1. Should I be doing this? Is there some sort of consequence I should consider (bearing in mind that these are just analysis meshes, designed to demonstrate acoustical parameters over an area).
  2. If the answer to the above question is that it is fine, then what hoops do I need to jump through now, and will the code still work in Rhino 5 when I’m done.

Arthur

I suspect it’s a manifestation of a known bug (but I’m not sure yet where to find it). There seems to be a problem with maintaining synchronised single- and double-precision vertex lists in Rhino6.

If you can give me the code I need to replicate this particular invalidness I’ll append it to the original bug-report. It may help find an answer quicker.

Hi @Arthur, run mesh.IsValidWithLog() to find out what is wrong with the mesh. It would also help if you can show the object properties page of your mesh before you changed the mesh. My guess is that David is right and the problem is related to double precision mesh. If this is the case, note this.

How is this performed in your code ? Be unwelding or by creating a new mesh face vertex list ?

_
c.

Hi David,
It’s a little complicated, because I run the mesh through my own mesh and Ray tracing code.

Both functions that do this are here:

First, it runs the BREPs though Create_Map_Mesh(), and then through Rhino_to_HareMesh().

After it has run the simulation, when you plot the results, it calls PlotMesh, which calls Hare_to_RhinoMesh(). PlotMesh then rewrites the mesh as discrete faces. (PlotMesh might be what you’re looking for.)

Arthur

Clement, see my response to David.

It is never a rhino docobject before I put results on it, so I can’t check the properties of it easily. I’m traveling, so when I get to sit still, I’ll run IsValidWithLog().

Arthur

IsValidWithLog() - the log had this to say:

“ON_Mesh.m_F[285] has degenerate double precision vertex locations.\n”

Is this what you were suggesting, David?

Arthur

I think I fixed it. This wasn’t necessary in Rhino 5, because Triangles are represented as 4 vertex polygons, where C and D are the same, but I guess this has changed in Rhino 6?

        public static Mesh PlotMesh(PachMapReceiver[] Rec_List, System.Drawing.Color[] C)
        {
            Mesh MM = Hare_to_RhinoMesh(Rec_List[0].Map_Mesh, Rec_List[0].Rec_Vertex);

            if (!Rec_List[0].Rec_Vertex)
            {
                Mesh MF = new Mesh();
                for (int i = 0; i < MM.Faces.Count; i++)
                {
                    if (MM.Faces[i].IsQuad)
                    {
                        MF.Vertices.Add(MM.Vertices[MM.Faces[i].A]);
                        MF.Vertices.Add(MM.Vertices[MM.Faces[i].B]);
                        MF.Vertices.Add(MM.Vertices[MM.Faces[i].C]);
                        MF.Vertices.Add(MM.Vertices[MM.Faces[i].D]);
                        int f = MF.Vertices.Count - 4;
                        MF.Faces.AddFace(f, f + 1, f + 2, f + 3);
                        MF.VertexColors.SetColor(f, C[i]);
                        MF.VertexColors.SetColor(f + 1, C[i]);
                        MF.VertexColors.SetColor(f + 2, C[i]);
                        MF.VertexColors.SetColor(f + 3, C[i]);
                    }
                    else
                    {
                        MF.Vertices.Add(MM.Vertices[MM.Faces[i].A]);
                        MF.Vertices.Add(MM.Vertices[MM.Faces[i].B]);
                        MF.Vertices.Add(MM.Vertices[MM.Faces[i].C]);
                        int f = MF.Vertices.Count - 3;
                        MF.Faces.AddFace(f, f + 1, f + 2);
                        MF.VertexColors.SetColor(f, C[i]);
                        MF.VertexColors.SetColor(f + 1, C[i]);
                        MF.VertexColors.SetColor(f + 2, C[i]);
                    }
                }
                return MF;
            }
            else
            {
                MM.VertexColors.SetColors(C);
                return MM;
            }
        }

Thanks!