#include "stdafx.h" //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // // BEGIN TestJiangz command // #pragma region TestJiangz command class CCommandTestJiangz : public CRhinoCommand { public: CCommandTestJiangz() = default; UUID CommandUUID() override { // {47E07604-F973-4B17-8FC9-3C48D1529870} static const GUID TestJiangzCommand_UUID = { 0x47E07604, 0xF973, 0x4B17, { 0x8F, 0xC9, 0x3C, 0x48, 0xD1, 0x52, 0x98, 0x70 } }; return TestJiangzCommand_UUID; } const wchar_t* EnglishCommandName() override { return L"TestJiangz"; } CRhinoCommand::result RunCommand(const CRhinoCommandContext& context) override; }; // The one and only CCommandTestJiangz object static class CCommandTestJiangz theTestJiangzCommand; CRhinoCommand::result CCommandTestJiangz::RunCommand(const CRhinoCommandContext& context) { CRhinoObjectIterator it(CRhinoObjectIterator::undeleted_objects, CRhinoObjectIterator::active_objects); CRhinoObject* obj = nullptr; for (obj = it.First(); nullptr != obj; obj = it.Next()) { const ON_Geometry* geometry = obj->Geometry(); if (nullptr == geometry) return CRhinoCommand::failure; // Test for Brep object const ON_Brep* brep = ON_Brep::Cast(geometry); if (nullptr != brep) { ON_SimpleArray meshes(brep->m_F.Count()); const int mesh_count = brep->GetMesh(ON::render_mesh, meshes); if (mesh_count > 0) { // TODO: do something with array of ON_Mesh objects... // Append into a single mesh and add to the document ON_Mesh new_mesh; new_mesh.Append(mesh_count, meshes.Array()); context.m_doc.AddMeshObject(new_mesh); } continue; } // Test for extrusion object const ON_Extrusion* extrusion = ON_Extrusion::Cast(geometry); if (nullptr != extrusion) { const ON_Mesh* mesh = extrusion->m_mesh_cache.Mesh(ON::render_mesh); if (nullptr != mesh) { // TODO: do something with the ON_Mesh object... // Add a copy to the document context.m_doc.AddMeshObject(*mesh); } continue; } } context.m_doc.Redraw(); return CRhinoCommand::success; } #pragma endregion // // END TestJiangz command // //////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////