I have an array of ON_Mesh elements that intersect and overlap each other. This array represents the result of machining a workpiece with a tool. For display, the algorithm used the
void CRhinoDisplayPipeline::DrawShadedMesh(const ON_Mesh& mesh, const CDisplayPipelineMaterial* = nullptr);
function, drawing each mesh one by one. But this approach was extremely time-consuming. I tried using
void CRhinoDisplayPipeline::DrawShadedMeshes(const ON_Mesh* const* meshes, int count, const CDisplayPipelineMaterial* material, CRhinoCacheHandle* const * caches);
, which displays the entire array of meshes and caches their state. This became an order of magnitude faster.
However, during testing, I encountered an inexplicable problem.
If I use a cylinder as the initial workpiece, the meshes of the cylindrical shell do not disappear during the cutter’s pass. That is, the tool plunges into the cylindrical workpiece, moves, and the toolpath meshes are displayed, but the outer meshes of the workpiece shell do not disappear and continue to obscure the emerging toolpath meshes. To make this easier to understand, imagine a bolt being threaded with a tool. The tool plunges into the bolt initial workpiece and moves along it. Toolpaths are also generated - you can see them by zooming in on the initial workpiece. However, the toolpath remain hidden within the initial workpiece, not disappearing where the toolpath are. If I use a parallelepiped as the initial workpiece, everything works fine — the initial workpiece shell disappears above the toolpath.
However, when using DrawShadedMesh, everything displays correctly for the same set of meshes from the cylindrical initial workpiece described above. So, as I understand it, Rhinoceros somehow automatically removes outer meshes if other meshes appear underneath them.
Does anyone know how this mechanism works and how to force it to work for DrawShadedMeshes? And why does it work for a parallelepiped with DrawShadedMeshes, but not for a cylinder?