I would like to mesh polysurfaces automatically. I have seen the “How To: Mesh Objects using RhinoMeshObjects” example…but if I already have an ON_Brep, it seems a bit much to generate a CRhinoObject from it just to mesh it. So i thought of using the CreateMesh function of the ON_Brep class. But, this gives me separate meshes for separate Brep faces…and i need just one mesh for the entire polysurface…
How do I do this? Do I have to resort to the CRhinoObject solution? Should I use the CreateMesh and join somehow the meshes afterwards? Is there some setting in the ON_MeshParameters to export a single mesh?
After creating the meshes, using ON_Brep::CreateMesh, you need to set each mesh piece on the corresponding face using ON_BrepFace::SetMesh. Here is a simple example:
thanks, but I don`t understand. In this example brep object is drawn at the end. Where is my final (joined) mesh? Is the idea to use CRhinoBrepObject and mesh it following the “How To: Mesh Objects using RhinoMeshObjects” example?
this works…but the final product is still not what i want, so i hope i can ask you two more short questions:
I would like a “solid”…clean mesh. No double points or edges. When drawing, I would do Weld Vertices… is there a function for that?
I very often use SelNakedMeshEdgePt, cause it is important to identify the edge of the mesh…is there a function for this? Or some ON_Mesh member that holds this information?
…I am going to try and answer my questions so I can ask another quick one.
I am guessing that RhinoWeldMesh is the solution for welding?..and I am guessing the NakedMeshEdge secret is hidden in the “mesh_edge.m_topf_count” like in the Create a Bounding Polyline of a Mesh Object example?
The new short question I have is about ON_MeshParameters mp settings, I have been playing with it and it mostly works fine…except for some parameters, one of them is mp.m_face_type. It just doesn`t care if I put 0,1 or 2…it always does what it wants (usually mixed quads and triangles).
I also noticed that if I do mp = mp.FastRenderMesh, it doesn’t matter what mp parameters i change afterwards( grid count, edge length, …), they are not considered.
Yep[quote=“dimcic, post:6, topic:6289”]
I am guessing the NakedMeshEdge secret is hidden in the “mesh_edge.m_topf_count”…
[/quote]
This should do the trick:
const ON_MeshTopology& top = pMesh->Topology();
if( top.TopEdgeCount() > 0 )
{
int b, c, d;
for( b = 0; b < top.m_tope.Count(); b++ )
{
const ON_MeshTopologyEdge& tope = top.m_tope[b];
for( c = 0; c < 2; c++ )
{
const ON_MeshTopologyVertex& topv = top.m_topv[ tope.m_topvi[c] ];
if( tope.m_topf_count == 1 || topv.m_v_count > 1 )
{
for( d = 0; d < topv.m_v_count; d++ )
{
int vi = topv.m_vi[d];
// TODO...
}
}
}
}
}
```[quote="dimcic, post:6, topic:6289"]
The new short question I have is about ON_MeshParameters...
[/quote]
Yes, some of the mesh parameters are interpreted a little differently in V5. This was necessary in order to improve meshing (and to fix some bugs) without breaking the SDK. If you are unable to produce the mesh you want (where you could in V4), then please provide me some sample geometry and code. Note, you might want to move this to a new topic, as I believe the original topic has been answered.
Rhino will try its best to use the mesh parameters. But there are occasions where the mesher needs to deviate from what has been specified in order to generate a valid mesh. If you need quads or triangles, you can always call ON::ConvertQuadsToTriangles or ON_Mesh::ConvertTrianglesToQuads after the fact.