Grasshopper

algorithmic modeling for Rhino

Hi there,

 

I'm trying to create a Mesh object from a given topology. So far I haven't been able to find a direct way of doing this (feeding it directly with the topology that is...). Closed thing I found is this old example based on the ON_Mesh object:

 

http://wiki.mcneel.com/developer/sdksamples/addmesh

 

Could someone point me in the right direction?

 

Thanks,

 

Joost

Views: 1638

Replies to This Discussion

weaverbird plug-in, or the program topmod.

Michael, thanks for your reply. However, I'm trying to implement a method able to create a Mesh object in a custom component. Currently I have a List<Point> (Vertices) and a List<int[]> (Topology) pointing to the Vertices for each face. I tried to do it by creating a mesh for each individual Face and then add this Face to the Mesh:

 

            //initiate the output mesh
            Mesh mesh = new Mesh();
            MeshingParameters meshParameters = new MeshingParameters();

            //create the output mesh
            meshParameters = MeshingParameters.Coarse;
            meshParameters.RefineGrid = false;
            meshParameters.MinimumEdgeLength = 500;

            //loop over the breps of the faces creating a single mesh for each element
            foreach (RTFace face in meshTopology.Faces)
            {
                Mesh[] meshTriangle = new Mesh[0];

                meshTriangle = Mesh.CreateFromBrep(face.Brep, meshParameters);

                mesh.Append(meshTriangle[0]);
            }

 

This however seems cumbersome, and doesn't return the proper results as it splits Faces, and contains many duplicate nodes.

 

Any suggestions?

Guess I was looking for something simple like this:

 

Rhino.Geometry.Mesh mesh = new Rhino.Geometry.Mesh();
mesh.Vertices.Add(0.0, 0.0, 1.0); //0
mesh.Vertices.Add(1.0, 0.0, 1.0); //1
mesh.Vertices.Add(2.0, 0.0, 1.0); //2
mesh.Vertices.Add(3.0, 0.0, 0.0); //3
mesh.Vertices.Add(0.0, 1.0, 1.0); //4
mesh.Vertices.Add(1.0, 1.0, 2.0); //5
mesh.Vertices.Add(2.0, 1.0, 1.0); //6
mesh.Vertices.Add(3.0, 1.0, 0.0); //7
mesh.Vertices.Add(0.0, 2.0, 1.0); //8
mesh.Vertices.Add(1.0, 2.0, 1.0); //9
mesh.Vertices.Add(2.0, 2.0, 1.0); //10
mesh.Vertices.Add(3.0, 2.0, 1.0); //11

mesh.Faces.AddFace(0, 1, 5, 4);
mesh.Faces.AddFace(1, 2, 6, 5);
mesh.Faces.AddFace(2, 3, 7, 6);
mesh.Faces.AddFace(4, 5, 9, 8);
mesh.Faces.AddFace(5, 6, 10, 9);
mesh.Faces.AddFace(6, 7, 11, 10);
mesh.Normals.ComputeNormals();

 

http://www.rhino3d.com/5/rhinocommon/

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service