DrawBrepShaded

#1

Rhino 6 SR13(6.13.19058.371, 27/02/2019) .
I created some solid breps with geometry methods and then i got their base geometries with brep.Duplicate() method.
If i display them in a displayconduit (drawoverlay) using DrawBrepShaded method ,casting them from gemoetrybase, “DrawBrepShaded” takes about 200 milliseconds for each brep.
If i create in the document the breps and i get the base geometries from getobject selection (objref -> geometry base) and i display in the same way , “DrawBrepShaded” takes minus than 1 millisecond for each brep.
Please someone can understand why should this happen???

(Menno Deij - van Rijswijk) #2

Probably because your newly created B-Reps do not have display meshes yet. These are then created ‘on-the-fly’ and that takes time.

1 Like
#3

Hi Menno , thank you, do you know the way, if exist, to add display meshes to a brep?

#4

I ask you because i read some topic but i did not understand very well. I use rhinocommon c#.
i have only a brep, not a rhinoobject. I don’t know if what i think to do is correct. I could get a mesh form each face of the brep and use the method setmesh() passing the mesh to the face. Am I in the right way?

(Menno Deij - van Rijswijk) #5

I suppose that you could do the following:

// this is just for demonstration purpose, you use your own BRep here:
Brep b = Brep.CreateFromBox(new BoundingBox(0,0,0,1,1,1));
      
// create meshes
Mesh[] faceMeshes = Mesh.CreateFromBrep(b, MeshingParameters.FastRenderMesh);

// assign them to faces
for (var i = 0; i < b.Faces.Count; i++)
{
  var f = b.Faces[i];
  f.SetMesh(MeshType.Render, faceMeshes[i]);
}

// now the Brep has render meshes for each face 
1 Like
#6

Very clear, thank you, I will try and post here the results. I will check also if it is faster to have directly the mesh and to draw it with darwmesh method. Normally with one brep it would be cracy to check faster results but with thousands of them moving all together it could be important.

#7

I saw something that for many is obvoius, not for all. In milliseconds the difference between drawbrepshaded (with a brep that has meshes set as Menno said ) and drawmeshshaded dipends on the complexity of the brep . IT is much better to convert directly the brep in a mesh if you have a heavy brep because it could take more then 10 milliseconds for each brep to be shown , while the same brep converted to mesh takes 0 milliseconds .
Thank you very much Menno, you are always present and very helpfull.
I wish I could reciprocate one day