Grasshopper

algorithmic modeling for Rhino

# how to build meshes from breps

Hi everyone,

I am trying to build meshes from a series of breps that will be combined with some other code that I am doing, so its important for me to write theses meshes without any use of grasshopper components.

I have attached a 3dm file and a picture so you guys can see what I am talking about.

I have previously translated boxes into breps, which i did with this code:

Dim bbx As New box(pl, New interval(-.5, .5), New interval(-.5, .5), New interval(-.5, .5))
Dim ms As New Mesh()
ms.Normals.ComputeNormals()

ms.Compact()

I have tried to do something similar with this specific example, and I now that meshes only consist of quads or triangles, so i broke down the geometry into quads without any succes.

Looking foreward to any suggestions.

- Jens

Views: 1097

Attachments:

### Replies to This Discussion

Hi Jens,

are you simply looking to mesh these breps using the Rhino mesher-algorithm? Or are you seeking to convert them into meshes in a very specific way?

If the former, you can use a static method on Rhino.Geometry.Mesh called CreateFromBrep(). You can specify meshing parameters so you have some control over quads, triangles, simple planes, gridcounts etc.

--

David Rutten

david@mcneel.com

Thank you for the hint David, I didnt know of that specific possibility.

Its returning more or Lese what I want, but since its returning an array of meshes, is there then  a way of combining the meshes into one? I will try out some different things on my own, but I am sure there is a easy solution to this problem that I dont know of.

And is there a way of controling the mesh count(vertices and faces)?? so that the different geometries have the same numbers?

I am new to meshes, so I havent figures out how to deal with them yet, which is why these questions are so basic.

Just another question, which geometry is faster to output, breps or meshes?? because thats my main reason for wanting to work with meshes, because I was told at some point that they were more "efficient" in terms of computation. is that true?

Depends on the computation. If you want to shade Breps then you have to calculate meshes anyway so they are bound to be slower in that respect. I can't answer this question without knowing what you plan to do with these breps/meshes.

--

David Rutten

david@mcneel.com

it is only in relation to numbers... so if you have a list of x numbers of breps or meshes, which will then be faster?

It is because I am currently doing my thesis at the Architectural Association at the Emtech program with Andy VanMater, where we are doing an urban development, so we will be dealing with alot of buildings, and for our code to be able to run withn a given time frame, we need to cut time where possible...

Faster for what? Display? Volume calculations? Sight-lines? Can you generate meshes directly or do you have to create Breps and then convert them to meshes?

It's like asking what is faster; a bugatti or a T-90. A bugatti on the road, a T-90 in a mudfield.

--

David Rutten

david@mcneel.com

Hehe... okay the most specific answer I can give you is that its for previewing and Yes I will have to create breps before I would get the mesh.

Its because we will run our code on a timer and then screencapture the animation. And therefore we are wondering what is fastest to prewiev meshes or breps.

The numbers will be around 100.000 objects either meshes or breps that we want to preview, and se how they develop over time.

Sorry for not being specific enough from the very begining..

Ok, since there is a such a large amount of objects involved and since it's about previewing them, I'd say meshes are the best option. It might even be the case that a single mesh will be preferable to 100,000 individual meshes. Or maybe 1000 meshes consisting of 100 shapes each is better still, you'll need to test this.

You can use the Rhino mesher to convert your breps to meshes, switch off the Refinement and the Stitching as those take the longest time. Also use SimplePlanes=True.

You can merge meshes into larger meshes using the Mesh.Append() function. Something like this:

Dim meshes As New List(Of Mesh)

Dim mesh As New Mesh()

For i As Int32 = 0 To WhatEver

Dim brp As Brep = CreateYourBrepAtIndex(i)

If (brp Is Nothing) Then Continue For

Dim msh As Mesh() = Mesh.CreateFromBrep(brp, params)

If (msh Is Nothing) Then Continue For

For Each subMesh As Mesh in msh

mesh.Append(subMesh)

Next

If (mesh.Vertices.Count > 1000000) Then

mesh = New Mesh()

End If

Next

If (mesh.Vertices.Count > 0) Then meshes.Add(mesh)

this loop will create combined meshes by merging all the shading meshing until the combined shapes are roughly 1 million vertices each.

--

David Rutten

david@mcneel.com

Hi again david...

So far so good, everything is working more or less as it should the only issue is a small meshing problem, I have attached two photos of it. one out of the  breps isnt meshing correctly, but if I do it in rhino(with same settings) it meshes perfectly, do you know a way around this problem? its as if it skips a face when I code it.
Attachments:

Mesh has an Append() method that allows you to merge two meshes. Basically Append all the meshes in the array to the first one to get a single mesh.

"And is there a way of controling the mesh count(vertices and faces)?? so that the different geometries have the same numbers?"

No, the Rhino mesher does not allow you to specify specific vertex/face counts, unless you're meshing an untrimmed surface.

--

David Rutten

david@mcneel.com

And thank you for the help it works just great :D