CRhinoCommand::result CCommandTestHistoryExample::RunCommand( const CRhinoCommandContext& context ) { CRhinoCommand::result rc = CRhinoCommand::failure; CRhinoGetObject go; go.SetCommandPrompt(L"Pick two curves"); go.SetGeometryFilter(CRhinoGetObject::curve_object); go.GetObjects(2,2); if( go.Result()== CRhinoGet::object && go.ObjectCount()==2) { CRhinoObjRef CObj0 = go.Object(0); CRhinoObjRef CObj1 = go.Object(1); const ON_Curve* c0 = CObj0.Curve(); const ON_Curve* c1 = CObj1.Curve(); if( c0 && c1) { ON_Surface* pSrf = MakeBilinearSurface( *c0, *c1); ON_Brep brep; if(pSrf && brep.Create(pSrf)) { CRhinoHistory history(*this); WriteHistory(history, CObj0, CObj1); context.m_doc.AddBrepObject(brep,NULL,&history); rc = CRhinoCommand::success; } } } return rc; }
CRhinoCommand::result CCommandSampleMeshDir::RunCommand( const CRhinoCommandContext& context ) { CRhinoGetObject go; go.SetGeometryFilter( CRhinoObject::mesh_object | CRhinoObject::surface_object | CRhinoObject::polysrf_object | CRhinoObject::instance_reference ); go.SetCommandPrompt( L"Select mesh, surface, or polysurface objects" ); go.GetObjects(1,0); if( go.Result() != CRhinoGet::object ) return CRhinoCommand::cancel; int i = 0; ON_SimpleArray<const CRhinoObject*> objects( go.ObjectCount() ); for( i = 0; i < go.ObjectCount(); i++ ) objects.Append( go.Object(i).Object() ); ON_ClassArray<CRhinoObjRef> render_meshes; int count = RhinoGetRenderMeshes( objects, render_meshes, true, false ); if( count > 0 ) { CMeshDirDrawCallback callback; callback.m_mesh_list.Reserve( count ); for( i = 0; i < render_meshes.Count(); i++ ) { const ON_Mesh* mesh = render_meshes[i].Mesh(); if( mesh ) callback.m_mesh_list.AppendNew().SetMesh( mesh ); } CRhinoGetOption go; go.SetCommandPrompt( L"Press Enter when done" ); go.AcceptNothing(); go.AddCommandOptionToggle( RHCMDOPTNAME(L"FaceNormals"), RHCMDOPTVALUE(L"No"), RHCMDOPTVALUE(L"Yes"), m_draw_face_normals, &m_draw_face_normals ); go.AddCommandOptionToggle( RHCMDOPTNAME(L"VertexNormals"), RHCMDOPTVALUE(L"No"), RHCMDOPTVALUE(L"Yes"), m_draw_vertex_normals, &m_draw_vertex_normals ); CRhinoGet::result res = CRhinoGet::nothing; for( ;; ) { callback.m_draw_face_normals = m_draw_face_normals; callback.m_draw_vertex_normals = m_draw_vertex_normals; CRhinoView::AddDrawCallback( &callback ); context.m_doc.Redraw( CRhinoView::regenerate_display_hint ); res = go.GetOption(); CRhinoView::RemoveDrawCallback( &callback ); if( res == CRhinoGet::option ) continue; break; } } context.m_doc.Redraw( CRhinoView::regenerate_display_hint ); return CRhinoCommand::success; }