#include //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // // BEGIN CmdTestAlberto command // class CCommandCmdTestAlberto : public CRhinoCommand { public: CCommandCmdTestAlberto() {} ~CCommandCmdTestAlberto() {} UUID CommandUUID() { // {7FB77009-684A-4F44-926B-E95991ACB868} static const GUID cmdTestAlbertoCommand_UUID = { 0x7FB77009, 0x684A, 0x4F44, { 0x92, 0x6B, 0xE9, 0x59, 0x91, 0xAC, 0xB8, 0x68 } }; return cmdTestAlbertoCommand_UUID; } const wchar_t* EnglishCommandName() { return L"cmdTestAlberto"; } const wchar_t* LocalCommandName() { return L"cmdTestAlberto"; } CRhinoCommand::result RunCommand(const CRhinoCommandContext&); }; // The one and only CCommandCMDTestOles object static class CCommandCmdTestAlberto theCmdTestAlbertoCommand; CRhinoCommand::result CCommandCmdTestAlberto::RunCommand(const CRhinoCommandContext& context) { CRhinoGetObject go; go.SetCommandPrompt(L"Select surface"); go.SetGeometryFilter(CRhinoGetObject::surface_object); go.GetObjects(1, 1); if (go.CommandResult() != success) { return go.CommandResult(); } const CRhinoObjRef& objref = go.Object(0); const ON_Brep* brep = objref.Brep(); if (brep == NULL) { return CRhinoCommand::failure; } const double tolerance = 0.005 / 3.6; // 0.0013888888888888889 ON_MeshParameters meshParameters = ON_MeshParameters::DefaultMesh; meshParameters.SetTolerance(tolerance); meshParameters.SetGridAspectRatio(0); const bool m_bSimplePlane = meshParameters.SimplePlanes(); // false const unsigned int m_face_type = meshParameters.FaceType(); // 0 const int m_grid_min_count = meshParameters.GridMinCount(); // 0 const double m_tolerance = meshParameters.Tolerance(); // 0.0013888888888888889 const double m_relative_tolerance = meshParameters.RelativeTolerance(); // 0.0 const double m_grid_aspect_ratio = meshParameters.GridAspectRatio(); // 0.0 const double m_grid_angle_radians = meshParameters.GridAngleRadians(); // 0.34906585039886590 ~ 20° const double m_grid_amplification = meshParameters.GridAmplification(); // 1.0 for (int faceIdx = 0; faceIdx < brep->m_F.Count(); ++faceIdx) { const ON_BrepFace* brepFace = brep->Face(faceIdx); ON_Mesh* mesh = brepFace->CreateMesh(meshParameters); if (mesh == NULL) { return CRhinoCommand::failure; } if (!mesh->IsValid()) { mesh->Destroy(); return CRhinoCommand::failure; } if (mesh->QuadCount() > 0) { mesh->ConvertQuadsToTriangles(); } context.m_doc.AddMeshObject(*mesh); mesh->Destroy(); } return CRhinoCommand::success; } // // END CmdTestAlberto command // //////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////