Brep mesh extraction

rendering
rhino5
mesh
conduit
brep

#1

Hi everybody,

I am trying to quickly extract a mesh from a brep. My approach is in brief the one below:

brep->CreateMesh(mp,meshList);
	ON_Mesh* mesh = NULL;
	for(int i = 0; i < meshList.Count(); i++) {
		meshList[i]->ConvertQuadsToTriangles();
		if(mesh == NULL)
			mesh = meshList[0];      
			else {
			      mesh->Append(*meshList[i]);
			}
		} 

I need a really fast mesh extraction and this seems not to be a suitable way for my needs even with the DefaultFastMeshParameters. I assume a mesh is created for rendering purpose for each object of the document but also the dp.drawbrep method for temporary objects in the conduit seems to be more than 10x faster (am I wrong?) than the mesh extraction above. I guess somewhere in the SDK library must be a faster way to get a mesh, even if coarser. Anybody has a hint?

Thanks!
G.


(Karol Wierzbicki) #2

I may be wrong, but the fastest way seem to be to get renderMesh from brep.


(Dale Fugier) #3

Hi @gennaro,

When Rhino needs to draw a Brep, that are in the document, in some kind of shaded display, it just retrieves the render mesh that is cached on the Brep using ON_Brep::GetMesh.

If the Brep is newly added to the document, or it does not have a cached render mesh, then one is created as needed using ON_Brep::CreateMesh. This mesh is cached on the Brep for quick retrieval.

If you are creating Breps on the fly and want to draw them in a shaded way, then you really don’t have any choice but to create them using ON_Brep::CreateMesh.

Does any of this help?

– Dale


#4

Thank you all!

The ON_Brep::GetMesh method totally helps. I have also noticed that for a temporary object I can get rendering mesh if I call before the CRhinoDisplayPipeline::DrawBrep in a conduit. This might be the workaround I needed because the two methods seem to be together faster than ON_Brep::CreateMesh method. Am I forgetting something which may cause a delay in this way?

G.


(Menno Deij - van Rijswijk) #5

It all depends on the MeshingParameters you provide to ON_Brep::CreateMesh, are you sure you are using the rendering mesh parameters?


(Dale Fugier) #6

Hi @gennaro,

Like I said before, ON_Brep::GetMesh gets cached meshes. If the Brep does not have cached meshes, you won’t get a mesh in return.

Also, CRhinoDisplayPipeline::DrawBrep draws mesh wires, not shared faces. It also will not generate meshes.

CRhinoDisplayPipeline::DrawShadedBrep will create a render mesh if needed, and cache it on the input Brep.

And of course, ON_Brep::CreateMesh will create meshes…

– Dale


#7

Hi @dale,

Is there any way to get Brep render mesh from .NET OpenNURBS 6, similar to what you do in the example from c++? I can’t find any GetMesh method there.

Thanks


(Dale Fugier) #8

Hi @qlabrosse,

If you are working from within a RhinoCommon plug-in and you have a Rhino Brep object, then you can use RhinoObject.GetMeshes.

If you just have a Brep, or you are using Rhino3dmIo, then you’ll need to iterate through the Brep’s faces and accumulate the meshes from each individual face using BrepFace.GetMesh.

Does this help?

– Dale


#9

Yes perfect with BrepFace.GetMesh. Was it there before? I guess I just didn’t search right.
Thanks @dale !