Mesh reduction


#1

Hi All,

There is one problem I would like to share and if possible find solution.
I’m using C/C++ SDK for Rhino for Windows plugins.

  1. I tried to reduce a mesh object with the function from rhinoSdkMeshUtilities.h:
    bool RhinoReduceMesh(…);
  2. After this I reduced the same mesh object with Rhinoceros command: _ReduceMesh;
  3. The problem is the reduced meshes of both operations are different.

I used the same parameters of the reduction (at least I hope it’s so), but the result mesh of the function has lower precision then mesh generated by _ReduceMesh command.

For instance, parameters of the reducing:
0. Mesh object is the same for both operations;

  1. Parameters of the command _ReduceMesh:
    • Reduced by - 75 percent;
    • Accuracy of the reduction - max (Accurate);
  2. Parameters of the function “bool RhinoReduceMesh(…)”:
    RhinoReduceMesh(t_mesh, 25 * t_mesh.FaceCount() / 100, true, 10, true);

Is it possible to reduce mesh using the function “bool RhinoReduceMesh(…)” and obtain the reduced mesh similar (or better exactly the same) to the mesh generated with command _ReduceMesh?

Thanks in advance for any ideas.


(Dale Fugier) #2

Just to confirm,are you using Rhino 5 SR13?

Can you provide your mesh, the results of the ReduceMesh command, the results of calling RhinoReduceMesh, and the parameters you used to achieve each result?

My guess is the command is doing some pre and/or post processing of the mesh that you are not. But I want to see what you have before I go any further.

Thanks,

– Dale


#3

Hi Dale,
thanks for rapid reply.

Yes, I’m using Rhino5 SR13.

  1. In the following part of the code, you can see what parameters I used for mesh reduction with the function RhinoReduceMesh(…):
ON_Mesh* p_mesh = NULL;

CRhinoGetObject go;
go.SetCommandPrompt(L"Select Mesh:");
go.SetGeometryFilter(ON::mesh_object);
go.GetObjects(1, 1);

if (go.CommandResult() != success) {
	return go.CommandResult();
}

for (int i = 0; i < go.ObjectCount(); i++) {
	const ON_Mesh* t_p_mesh = go.Object(i).Mesh();
	if (t_p_mesh != NULL) {
		p_mesh = t_p_mesh->Duplicate();
		break;
	}
}

if (p_mesh != NULL) {
	int iDesiredPolygonCount = 25 * p_mesh->FaceCount() / 100;

	RhinoReduceMesh(*p_mesh, iDesiredPolygonCount, true, 10, true);
	context.m_doc.AddMeshObject(*p_mesh);

	delete p_mesh;
	p_mesh = NULL;
}
  1. Parameters of the command _ReduceMesh, the original mesh, the result of the command and the result of the function attached to the post.

MeshReduction.zip (931.1 KB)

Thanks.


(Dale Fugier) #4

Here are some samples that you can review:

https://github.com/mcneel/Rhino5Samples_CPP/blob/master/SampleCommands/cmdSampleReduceMesh.cpp
https://github.com/mcneel/Rhino5Samples_CPP/blob/master/SampleCommands/cmdSampleReduceMesh2.cpp

Do these help?

– Dale


#5

Yes, that’s exactly what I need.
Many thanks for your support.

Oles.