From 2a22322d3c7d38e1fa375c18f09ae189ee4570cc Mon Sep 17 00:00:00 2001 From: Dale Fugier Date: Fri, 15 Nov 2024 10:58:05 -0800 Subject: [PATCH 01/10] Added some comments --- .../SampleCsCommands/SampleCsAddNurbsCurve.cs | 20 ++++++++++++- .../SampleCsCommands/SampleCsNurbsCircle.cs | 30 +++++++++++++++---- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs index 79d0ef6b..091a8647 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs @@ -10,11 +10,16 @@ public class SampleCsAddNurbsCurve : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { + // The degree must be >= 1 and the number of control points const int degree = 3; + // The order is degree + 1 + const int order = degree + 1; + // The number of control points const int cv_count = 6; + // The number of knots is always (number of control points + degree - 1) const int knot_count = cv_count + degree - 1; - const int order = degree + 1; + // Define the "Euclidean" (world 3-D) locations for the control points. var cvs = new Point3d[cv_count]; cvs[0] = new Point3d(0.0, 0.0, 0.0); cvs[1] = new Point3d(5.0, 10.0, 0.0); @@ -23,21 +28,34 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) cvs[4] = new Point3d(20.0, 0.0, 0.0); cvs[5] = new Point3d(25.0, 10.0, 0.0); + // Define the knots. + // Unless you are doing something special, knot vectors should be clamped. + // "Clamped" means the first and last degree many knots are the same. + // In this example the first three knots are 0 and the last three knots are 3. + // The interior knots can have multiplicity from 1 (a "simple" knot) + // to degree (a "full multiplicity") var knots = new double[knot_count]; + // Start with a full multiplicity knot knots[0] = 0.0; knots[1] = 0.0; knots[2] = 0.0; + // Simple interior knot knots[3] = 1.0; + // Simple interior knot knots[4] = 2.0; + // End with a full multiplicity knot knots[5] = 3.0; knots[6] = 3.0; knots[7] = 3.0; + // Create a non-rational NURBS curve var curve = new NurbsCurve(3, false, order, cv_count); + // Set the control points for (int i = 0; i < cv_count; i++) curve.Points.SetPoint(i, cvs[i]); + // Set the knots for (int i = 0; i < knot_count; i++) curve.Knots[i] = knots[i]; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs b/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs index 6cfb1e08..b8d9561f 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; @@ -12,11 +10,16 @@ public class SampleCsNurbsCircle : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { + // The degree must be >= 1 and the number of control points const int degree = 2; + // The order is degree + 1 + const int order = degree + 1; + // The number of control points const int cv_count = 7; + // The number of knots is always (number of control points + degree - 1) const int knot_count = cv_count + degree - 1; - const int order = degree + 1; + // Define the "Euclidean" (world 3-D) locations for the control points. var points = new Point3d[cv_count]; points[0] = new Point3d(2.500, 0.000, 0.000); points[1] = new Point3d(5.000, 0.000, 0.000); @@ -25,7 +28,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) points[4] = new Point3d(1.250, 2.165, 0.000); points[5] = new Point3d(0.000, 0.000, 0.000); points[6] = new Point3d(2.500, 0.000, 0.000); - + + // Define the weights + // Weights must be > 0. + // In general you should set the first and last weight to 1. var weights = new double[cv_count]; weights[0] = 1.0; weights[1] = 0.5; @@ -35,24 +41,38 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) weights[5] = 0.5; weights[6] = 1.0; + // Define the knots. + // Unless you are doing something special, knot vectors should be clamped. + // "Clamped" means the first and last degree many knots are the same. + // In this example the first three knots are 0 and the last three knots are 3. + // The interior knots can have multiplicity from 1 (a "simple" knot) + // to degree (a "full multiplicity") var knots = new double[knot_count]; + // Start with a full multiplicity knot knots[0] = 0.000; knots[1] = 0.000; + // Full multiplicity interior knot knots[2] = 0.333; knots[3] = 0.333; + // Full multiplicity interior knot knots[4] = 0.667; knots[5] = 0.667; + // End with a full multiplicity knot knots[6] = 1.000; knots[7] = 1.000; + // Create a rational NURBS curve var curve = new NurbsCurve(3, true, order, cv_count); + // Set the control points and weights. + // Since our curve is rational, we need homogeneous points (4-D for (var ci = 0; ci < cv_count; ci++) { var cv = new Point4d(points[ci].X * weights[ci], points[ci].Y * weights[ci], points[ci].Z * weights[ci], weights[ci]); curve.Points.SetPoint(ci, cv); } + // Set the knots for (var ki = 0; ki < knot_count; ki++) curve.Knots[ki] = knots[ki]; From 92c75f482cca680fa068e424c54927c1bf52528e Mon Sep 17 00:00:00 2001 From: Dale Fugier Date: Fri, 15 Nov 2024 11:06:41 -0800 Subject: [PATCH 02/10] Parameterization should match the length of a curve --- rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCircle.cs | 4 ++++ rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs | 5 +++++ rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCircle.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCircle.cs index 24ce70b5..bc1c0b8c 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCircle.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCircle.cs @@ -39,6 +39,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (curve.IsValid) { + var length = curve.GetLength(); + var domain = new Interval(0.0, length); + curve.Domain = domain; + doc.Objects.AddCurve(curve); doc.Views.Redraw(); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs index 091a8647..1d420d7b 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs @@ -61,6 +61,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (curve.IsValid) { + // Parameterization should match the length of a curve + var length = curve.GetLength(); + var domain = new Interval(0.0, length); + curve.Domain = domain; + doc.Objects.AddCurve(curve); doc.Views.Redraw(); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs b/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs index b8d9561f..d891188d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs @@ -78,6 +78,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (curve.IsValid) { + // Parameterization should match the length of a curve + var length = curve.GetLength(); + var domain = new Interval(0.0, length); + curve.Domain = domain; + doc.Objects.AddCurve(curve); doc.Views.Redraw(); } From f6a650a7219aa888f35a92a825b8649da3a57966 Mon Sep 17 00:00:00 2001 From: Dale Fugier Date: Thu, 21 Nov 2024 13:54:50 -0800 Subject: [PATCH 03/10] Added a undo helper class --- cpp/SampleCommands/SampleFunctions.cpp | 76 +++++++++++++++++++ cpp/SampleCommands/SampleFunctions.h | 47 ++++++++++++ .../cmdSampleAddNurbsCircle.cpp | 2 +- 3 files changed, 124 insertions(+), 1 deletion(-) diff --git a/cpp/SampleCommands/SampleFunctions.cpp b/cpp/SampleCommands/SampleFunctions.cpp index a8b82018..d0447b0b 100644 --- a/cpp/SampleCommands/SampleFunctions.cpp +++ b/cpp/SampleCommands/SampleFunctions.cpp @@ -388,3 +388,79 @@ bool RhinoHasFocus() } return false; } + +static HWND GetRealParent(HWND hWnd) +{ + // To obtain a window's owner window, instead of using GetParent, + // use GetWindow with the GW_OWNER flag. + HWND hWndOwner = ::GetWindow(hWnd, GW_OWNER); + if (NULL != hWndOwner) + return hWndOwner; + + // Obtain the parent window and not the owner + return GetAncestor(hWnd, GA_PARENT); +} + +/// +/// Returns true if the Rhino main window has been re-parented to some other application window. +/// Returns true if the Rhino main window parent is the Windows Desktop. +/// +bool IsRhinoReparented() +{ + HWND hParent = GetRealParent(RhinoApp().MainWnd()); + HWND hDesktop = ::GetDesktopWindow(); + return hParent != hDesktop; +} + + +/// +/// Begin a CRhinoDoc undo record. +/// +/// The active document. +/// The undo description. +CRhinoDocUndoRecordHelper::CRhinoDocUndoRecordHelper(CRhinoDoc& doc, const wchar_t* pszDescription) +{ + m_docRuntimeSerialNumber = doc.RuntimeSerialNumber(); + m_undoRecordSerialNumber = doc.BeginUndoRecord(pszDescription); +} + +/// +/// Begin a CRhinoDoc undo record. +/// +/// The active document's runtime serial number. +/// The undo description. +CRhinoDocUndoRecordHelper::CRhinoDocUndoRecordHelper(unsigned int docRuntimeSerialNumber, const wchar_t* pszDescription) +{ + CRhinoDoc* pDoc = CRhinoDoc::FromRuntimeSerialNumber(docRuntimeSerialNumber); + if (pDoc) + { + m_docRuntimeSerialNumber = pDoc->RuntimeSerialNumber(); + m_undoRecordSerialNumber = pDoc->BeginUndoRecord(pszDescription); + } +} + +/// +/// Class destructor, ends the undo record. +/// +CRhinoDocUndoRecordHelper::~CRhinoDocUndoRecordHelper() +{ + EndUndoRecord(); +} + +/// +/// Ends the undo record. +/// +/// true if the undo record was ended. +bool CRhinoDocUndoRecordHelper::EndUndoRecord() +{ + bool rc = (m_docRuntimeSerialNumber > 0 && m_undoRecordSerialNumber > 0); + if (rc) + { + CRhinoDoc* pDoc = CRhinoDoc::FromRuntimeSerialNumber(m_docRuntimeSerialNumber); + if (pDoc) + rc = pDoc->EndUndoRecord(m_undoRecordSerialNumber); + m_docRuntimeSerialNumber = m_undoRecordSerialNumber = 0; + } + return rc; +} + diff --git a/cpp/SampleCommands/SampleFunctions.h b/cpp/SampleCommands/SampleFunctions.h index 41740fce..d8fe4602 100644 --- a/cpp/SampleCommands/SampleFunctions.h +++ b/cpp/SampleCommands/SampleFunctions.h @@ -156,3 +156,50 @@ bool IsRhinoRunningAsExe(); /// Returns true if Rhino has input focus. /// bool RhinoHasFocus(); + +/// +/// Returns true if the Rhino main window has been re-parented to some other application window. +/// Returns true if the Rhino main window parent is the Windows Desktop. +/// +bool IsRhinoReparented(); + + +/// +/// CRhinoDoc::BeginUndoRecord and CRhinoDoc::EndUndoRecord helper. +/// Undo record will be ended when classes goes out of scope. +/// Useful in modeless user interface code that modifies document objects. +/// Not useful Rhino command, as Rhino's command handler tracks undo records. +/// +class CRhinoDocUndoRecordHelper +{ +public: + /// + /// Begin a CRhinoDoc undo record. + /// + /// The active document. + /// The undo description. + CRhinoDocUndoRecordHelper(CRhinoDoc& doc, const wchar_t* pszDescription); + + /// + /// Begin a CRhinoDoc undo record. + /// + /// The active document's runtime serial number. + /// The undo description. + CRhinoDocUndoRecordHelper(unsigned int docRuntimeSerialNumber, const wchar_t* pszDescription); + + /// + /// Class destructor, ends the undo record. + /// + ~CRhinoDocUndoRecordHelper(); + + /// + /// Ends the undo record. + /// + /// true if the undo record was ended. + /// The class destructor calls this method. + bool EndUndoRecord(); + +private: + unsigned int m_docRuntimeSerialNumber = 0; + unsigned int m_undoRecordSerialNumber = 0; +}; diff --git a/cpp/SampleCommands/cmdSampleAddNurbsCircle.cpp b/cpp/SampleCommands/cmdSampleAddNurbsCircle.cpp index 9a812f8c..2a3fb28f 100644 --- a/cpp/SampleCommands/cmdSampleAddNurbsCircle.cpp +++ b/cpp/SampleCommands/cmdSampleAddNurbsCircle.cpp @@ -42,7 +42,7 @@ CRhinoCommand::result CCommandSampleAddNurbsCircle::RunCommand(const CRhinoComma int degree = 2; int order = degree + 1; int cv_count = 9; - int knot_count = cv_count + degree - 1; + //int knot_count = cv_count + degree - 1; // Make a rational, degree 2 NURBS curve with 9 control points ON_NurbsCurve nc(dimension, bIsRational, order, cv_count); From 192481392ef9c75d1d27dc2f7a9ce7c257a5bf11 Mon Sep 17 00:00:00 2001 From: Dale Fugier Date: Thu, 21 Nov 2024 14:02:42 -0800 Subject: [PATCH 04/10] Added FancyGetModuleHandle --- cpp/SampleCommands/SampleFunctions.cpp | 14 ++++++++++++++ cpp/SampleCommands/SampleFunctions.h | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/cpp/SampleCommands/SampleFunctions.cpp b/cpp/SampleCommands/SampleFunctions.cpp index d0447b0b..3355fb7f 100644 --- a/cpp/SampleCommands/SampleFunctions.cpp +++ b/cpp/SampleCommands/SampleFunctions.cpp @@ -412,6 +412,20 @@ bool IsRhinoReparented() return hParent != hDesktop; } +/// +/// Returns module handle where "this" function is running in: EXE or DLL. +/// +HMODULE FancyGetModuleHandle() +{ + HMODULE hModule = NULL; + ::GetModuleHandleEx( + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCTSTR)FancyGetModuleHandle, + &hModule + ); + return hModule; +} + /// /// Begin a CRhinoDoc undo record. diff --git a/cpp/SampleCommands/SampleFunctions.h b/cpp/SampleCommands/SampleFunctions.h index d8fe4602..8ddd47c8 100644 --- a/cpp/SampleCommands/SampleFunctions.h +++ b/cpp/SampleCommands/SampleFunctions.h @@ -163,6 +163,11 @@ bool RhinoHasFocus(); /// bool IsRhinoReparented(); +/// +/// Returns module handle where "this" function is running in: EXE or DLL. +/// +HMODULE FancyGetModuleHandle(); + /// /// CRhinoDoc::BeginUndoRecord and CRhinoDoc::EndUndoRecord helper. From 6e7c638c5a2155bae85f4ce7a5b52dfe0876be3a Mon Sep 17 00:00:00 2001 From: Dale Fugier Date: Wed, 11 Dec 2024 12:21:03 -0800 Subject: [PATCH 05/10] Updated SampleCsWpf to .NET 7 --- cpp/SampleCommands/SampleCommandsPlugIn.cpp | 4 +- .../cs/SampleCsWpf/Properties/AssemblyInfo.cs | 42 +---- .../Properties/launchSettings.json | 14 ++ rhinocommon/cs/SampleCsWpf/README.md | 6 +- rhinocommon/cs/SampleCsWpf/SampleCsWpf.csproj | 147 ++++-------------- 5 files changed, 51 insertions(+), 162 deletions(-) create mode 100644 rhinocommon/cs/SampleCsWpf/Properties/launchSettings.json diff --git a/cpp/SampleCommands/SampleCommandsPlugIn.cpp b/cpp/SampleCommands/SampleCommandsPlugIn.cpp index 1d58a48b..02afc74a 100644 --- a/cpp/SampleCommands/SampleCommandsPlugIn.cpp +++ b/cpp/SampleCommands/SampleCommandsPlugIn.cpp @@ -35,7 +35,7 @@ RHINO_PLUG_IN_ICON_RESOURCE_ID(IDI_ICON1); // Rhino plug-in developer declarations RHINO_PLUG_IN_DEVELOPER_ORGANIZATION(L"Robert McNeel & Associates"); -RHINO_PLUG_IN_DEVELOPER_ADDRESS(L"3670 Woodland Park Avenue North\r\nSeattle WA 98103"); +RHINO_PLUG_IN_DEVELOPER_ADDRESS(L"146 North Canal Street, Suite 320\r\nSeattle WA 98103"); RHINO_PLUG_IN_DEVELOPER_COUNTRY(L"United States"); RHINO_PLUG_IN_DEVELOPER_PHONE(L"206-545-6877"); RHINO_PLUG_IN_DEVELOPER_FAX(L"206-545-7321"); @@ -273,4 +273,4 @@ HCURSOR CSampleCommandsPlugIn::SampleCursor() if (0 == m_hCursor) m_hCursor = (HCURSOR)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDC_SAMPLE_CURSOR), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE); return m_hCursor; -} \ No newline at end of file +} diff --git a/rhinocommon/cs/SampleCsWpf/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsWpf/Properties/AssemblyInfo.cs index 1f9d1660..a2724c2c 100644 --- a/rhinocommon/cs/SampleCsWpf/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsWpf/Properties/AssemblyInfo.cs @@ -1,48 +1,18 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; -// Plug-in Description Attributes - all of these are optional -// These will show in Rhino's option dialog, in the tab Plug-ins -[assembly: PlugInDescription(DescriptionType.Address, "3670 Woodland Park Avenue North\r\nSeattle, WA 98103")] +[assembly: PlugInDescription(DescriptionType.Address, "146 North Canal Street, Suite 320\r\nSeattle, WA 98103")] [assembly: PlugInDescription(DescriptionType.Country, "United States")] -[assembly: PlugInDescription(DescriptionType.Email, "devsupport@mcneel.com")] +[assembly: PlugInDescription(DescriptionType.Email, "dale@mcneel.com")] [assembly: PlugInDescription(DescriptionType.Phone, "206-545-6877")] [assembly: PlugInDescription(DescriptionType.Fax, "206-545-7321")] [assembly: PlugInDescription(DescriptionType.Organization, "Robert McNeel & Associates")] [assembly: PlugInDescription(DescriptionType.UpdateUrl, "https://github.com/mcneel/rhino-developer-samples")] -[assembly: PlugInDescription(DescriptionType.WebSite, "http://www.rhino3d.com/")] +[assembly: PlugInDescription(DescriptionType.WebSite, "https://github.com/mcneel/rhino-developer-samples")] [assembly: PlugInDescription(DescriptionType.Icon, "SampleCsWpf.Resources.SampleCs.ico")] -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SampleCsWpf")] // Plug-In title is extracted from this -[assembly: AssemblyDescription("RhinoCommon Sample - SampleCsWpf")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Robert McNeel & Associates")] -[assembly: AssemblyProduct("SampleCsWpf")] -[assembly: AssemblyCopyright("Copyright © 2017, Robert McNeel & Associates")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("b9b3c836-5b53-4f93-b359-e64bdf2a159b")] // This will also be the Guid of the Rhino plug-in - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.0.0.0")] +[assembly: Guid("b9b3c836-5b53-4f93-b359-e64bdf2a159b")] \ No newline at end of file diff --git a/rhinocommon/cs/SampleCsWpf/Properties/launchSettings.json b/rhinocommon/cs/SampleCsWpf/Properties/launchSettings.json new file mode 100644 index 00000000..1eef7cd6 --- /dev/null +++ b/rhinocommon/cs/SampleCsWpf/Properties/launchSettings.json @@ -0,0 +1,14 @@ +{ + "profiles": { + "Rhino 8 (net7.0)": { + "commandName": "Executable", + "executablePath": "C:\\Program Files\\Rhino 8\\System\\Rhino.exe", + "commandLineArgs": "/netcore" + }, + "Rhino 8 net48)": { + "commandName": "Executable", + "executablePath": "C:\\Program Files\\Rhino 8\\System\\Rhino.exe", + "commandLineArgs": "/netfx" + } + } +} \ No newline at end of file diff --git a/rhinocommon/cs/SampleCsWpf/README.md b/rhinocommon/cs/SampleCsWpf/README.md index 873a6e3e..8f37a495 100644 --- a/rhinocommon/cs/SampleCsWpf/README.md +++ b/rhinocommon/cs/SampleCsWpf/README.md @@ -8,12 +8,12 @@ Building Sample -------------------- To build the sample, you are going to need: -* Rhinoceros 6 (http://www.rhino3d.com) -* Microsoft Visual C# 2017 +* Rhinoceros 8 (http://www.rhino3d.com) +* Microsoft Visual C# 2022 Legal Stuff ----------- -Copyright © 2017, Robert McNeel & Associates. All Rights Reserved. +Copyright © 2017-2024, Robert McNeel & Associates. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/rhinocommon/cs/SampleCsWpf/SampleCsWpf.csproj b/rhinocommon/cs/SampleCsWpf/SampleCsWpf.csproj index 5d9bae96..540bff92 100644 --- a/rhinocommon/cs/SampleCsWpf/SampleCsWpf.csproj +++ b/rhinocommon/cs/SampleCsWpf/SampleCsWpf.csproj @@ -1,133 +1,38 @@ - - + - Debug64 - AnyCPU - 8.0.30703 - 2.0 - {098AF3EE-CF77-4FEF-859B-B3BC22C7336A} + net7.0-windows;net48 + true + true + .rhp + ..\Bin\ Library - Properties - SampleCsWpf - SampleCsWpf - v4.8 - 512 - false - + Robert McNeel & Associates + Copyright © 2013-2024, Robert McNeel & Associates + SampleCsWpf + Sample WPF Plug-in + 8.0.0 - - true - full - false - ..\bin\ - DEBUG;TRACE - prompt - false + + 1701;1702;NU1701 - - pdbonly - true - ..\bin\ - TRACE - prompt - 4 - false + + 1701;1702;NU1701 + + + 1701;1702;NU1701 + + + 1701;1702;NU1701 - - - - C:\Program Files\Rhino 7\System\Rhino.UI.dll - False - - - ..\..\..\..\..\..\..\Program Files\Rhino 7\System\RhinoWindows.dll - False - - - - - - - - False - C:\Program Files\Rhino 7\System\rhinocommon.dll - False - - - - - - - - - - - - - - SampleCsWpfDialog.xaml - - - SampleCsWpfPanel.xaml - - - True - True - Resources.resx - - - - - SampleCsWpfViewportDialog.xaml - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - + - + + + - + - - - - Copy "$(TargetPath)" "$(TargetDir)$(ProjectName).rhp" -Erase "$(TargetPath)" - - - en-US - - - C:\Program Files\Rhino 7\System\Rhino.exe - - - Program - false - \ No newline at end of file From 39c9ecfc7dbbda4daf3c603df7ee7e82bccf8ba6 Mon Sep 17 00:00:00 2001 From: Dale Fugier Date: Thu, 12 Dec 2024 09:03:26 -0800 Subject: [PATCH 06/10] Upgraded SampleCsWithLicense --- .../dotnet/SampleWinFormsApp/Program.cs | 2 + .../Properties/AssemblyInfo.cs | 2 +- .../SampleCsCommands/SampleCsCommands.csproj | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 44 +------- .../Properties/launchSettings.json | 14 +++ .../SampleCsWithLicense.csproj | 101 +++++------------- .../SampleCsWithLicensePlugIn.cs | 5 +- .../cs/SampleCsWpf/Properties/AssemblyInfo.cs | 2 +- 10 files changed, 52 insertions(+), 124 deletions(-) create mode 100644 rhinocommon/cs/SampleCsWithLicense/Properties/launchSettings.json diff --git a/rhino.inside/dotnet/SampleWinFormsApp/Program.cs b/rhino.inside/dotnet/SampleWinFormsApp/Program.cs index 75de2fd2..2c5ee0d4 100644 --- a/rhino.inside/dotnet/SampleWinFormsApp/Program.cs +++ b/rhino.inside/dotnet/SampleWinFormsApp/Program.cs @@ -12,6 +12,8 @@ static void Main() // NOTE: Make sure to adjust your project settings so this is compiled as a 64 bit // application. Rhino.Inside will only run in 64 bit + RhinoInside.Resolver.UseLatest = true; + // Set up RhinoInside resolver at the very beginning of the application // This helps find and load Rhino assemblies while the program runs RhinoInside.Resolver.Initialize(); diff --git a/rhinocommon/cs/SampleCsCommands/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsCommands/Properties/AssemblyInfo.cs index 082fcaf8..2216f8a2 100644 --- a/rhinocommon/cs/SampleCsCommands/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsCommands/Properties/AssemblyInfo.cs @@ -4,7 +4,7 @@ [assembly: PlugInDescription(DescriptionType.Address, "146 North Canal Street, Suite 320\r\nSeattle, WA 98103")] [assembly: PlugInDescription(DescriptionType.Country, "United States")] -[assembly: PlugInDescription(DescriptionType.Email, "dale@mcneel.com")] +[assembly: PlugInDescription(DescriptionType.Email, "devsupport@mcneel.com")] [assembly: PlugInDescription(DescriptionType.Phone, "206-545-6877")] [assembly: PlugInDescription(DescriptionType.Fax, "206-545-7321")] [assembly: PlugInDescription(DescriptionType.Organization, "Robert McNeel & Associates")] diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCommands.csproj b/rhinocommon/cs/SampleCsCommands/SampleCsCommands.csproj index 87ccca52..a0c5e9c2 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCommands.csproj +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCommands.csproj @@ -7,7 +7,7 @@ Library Robert McNeel & Associates Copyright © 2013-2024, Robert McNeel & Associates - SampleCsUserData + SampleCsCommands Sample Commands Plug-in 8.0.0 diff --git a/rhinocommon/cs/SampleCsEventWatcher/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsEventWatcher/Properties/AssemblyInfo.cs index cd760f8e..2f1afbd1 100644 --- a/rhinocommon/cs/SampleCsEventWatcher/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsEventWatcher/Properties/AssemblyInfo.cs @@ -4,7 +4,7 @@ [assembly: PlugInDescription(DescriptionType.Address, "146 North Canal Street, Suite 320\r\nSeattle, WA 98103")] [assembly: PlugInDescription(DescriptionType.Country, "United States")] -[assembly: PlugInDescription(DescriptionType.Email, "dale@mcneel.com")] +[assembly: PlugInDescription(DescriptionType.Email, "devsupport@mcneel.com")] [assembly: PlugInDescription(DescriptionType.Phone, "206-545-6877")] [assembly: PlugInDescription(DescriptionType.Fax, "206-545-7321")] [assembly: PlugInDescription(DescriptionType.Organization, "Robert McNeel & Associates")] diff --git a/rhinocommon/cs/SampleCsUserData/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsUserData/Properties/AssemblyInfo.cs index d2aa4377..65e18245 100644 --- a/rhinocommon/cs/SampleCsUserData/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsUserData/Properties/AssemblyInfo.cs @@ -4,7 +4,7 @@ [assembly: PlugInDescription(DescriptionType.Address, "146 North Canal Street, Suite 320\r\nSeattle, WA 98103")] [assembly: PlugInDescription(DescriptionType.Country, "United States")] -[assembly: PlugInDescription(DescriptionType.Email, "dale@mcneel.com")] +[assembly: PlugInDescription(DescriptionType.Email, "devsupport@mcneel.com")] [assembly: PlugInDescription(DescriptionType.Phone, "206-545-6877")] [assembly: PlugInDescription(DescriptionType.Fax, "206-545-7321")] [assembly: PlugInDescription(DescriptionType.Organization, "Robert McNeel & Associates")] diff --git a/rhinocommon/cs/SampleCsWithLicense/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsWithLicense/Properties/AssemblyInfo.cs index 348a2d1e..5c1f7f4a 100644 --- a/rhinocommon/cs/SampleCsWithLicense/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsWithLicense/Properties/AssemblyInfo.cs @@ -1,52 +1,18 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; -// Plug-in Description Attributes - all of these are optional. -// These will show in Rhino's option dialog, in the tab Plug-ins. -[assembly: PlugInDescription(DescriptionType.Address, "3670 Woodland Park Avenue North\r\nSeattle, WA 98103")] +[assembly: PlugInDescription(DescriptionType.Address, "146 North Canal Street, Suite 320\r\nSeattle, WA 98103")] [assembly: PlugInDescription(DescriptionType.Country, "United States")] [assembly: PlugInDescription(DescriptionType.Email, "devsupport@mcneel.com")] [assembly: PlugInDescription(DescriptionType.Phone, "206-545-6877")] [assembly: PlugInDescription(DescriptionType.Fax, "206-545-7321")] [assembly: PlugInDescription(DescriptionType.Organization, "Robert McNeel & Associates")] [assembly: PlugInDescription(DescriptionType.UpdateUrl, "https://github.com/mcneel/rhino-developer-samples")] -[assembly: PlugInDescription(DescriptionType.WebSite, "http://www.rhino3d.com/")] +[assembly: PlugInDescription(DescriptionType.WebSite, "https://github.com/mcneel/rhino-developer-samples")] [assembly: PlugInDescription(DescriptionType.Icon, "SampleCsWithLicense.Resources.SampleCs.ico")] - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SampleCsWithLicense")] -[assembly: AssemblyDescription("RhinoCommon Sample - SampleCsWithLicense")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Robert McNeel & Associates")] -[assembly: AssemblyProduct("SampleCsCommands")] -[assembly: AssemblyCopyright("Copyright © 2018, Robert McNeel & Associates")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5deff610-a9c2-4922-92bc-ff6d3deb8d5e")] // This will also be the Guid of the Rhino plug-in - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.0.0.0")] - -// Make compatible with Rhino Installer Engine -[assembly: AssemblyInformationalVersion("2")] +[assembly: Guid("5deff610-a9c2-4922-92bc-ff6d3deb8d5e")] diff --git a/rhinocommon/cs/SampleCsWithLicense/Properties/launchSettings.json b/rhinocommon/cs/SampleCsWithLicense/Properties/launchSettings.json new file mode 100644 index 00000000..1eef7cd6 --- /dev/null +++ b/rhinocommon/cs/SampleCsWithLicense/Properties/launchSettings.json @@ -0,0 +1,14 @@ +{ + "profiles": { + "Rhino 8 (net7.0)": { + "commandName": "Executable", + "executablePath": "C:\\Program Files\\Rhino 8\\System\\Rhino.exe", + "commandLineArgs": "/netcore" + }, + "Rhino 8 net48)": { + "commandName": "Executable", + "executablePath": "C:\\Program Files\\Rhino 8\\System\\Rhino.exe", + "commandLineArgs": "/netfx" + } + } +} \ No newline at end of file diff --git a/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicense.csproj b/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicense.csproj index 2092d277..1eabe0f6 100644 --- a/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicense.csproj +++ b/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicense.csproj @@ -1,89 +1,36 @@ - - + - Debug - AnyCPU - 8.0.30703 - 2.0 - {5DEFF610-A9C2-4922-92BC-FF6D3DEB8D5E} + net7.0-windows;net48 + .rhp + ..\Bin\ Library - Properties - SampleCsWithLicense - SampleCsWithLicense - v4.8 - 512 - false - + Robert McNeel & Associates + Copyright © 2013-2024, Robert McNeel & Associates + SampleCsWithLicense + Sample Rhino Licensing Plug-in + 8.0.0 - - true - full - false - ..\bin\ - DEBUG;TRACE - prompt - false + + 1701;1702;NU1701 - - pdbonly - true - ..\bin\ - TRACE - prompt - 4 + + 1701;1702;NU1701 + + + 1701;1702;NU1701 + + + 1701;1702;NU1701 - - C:\Program Files\Rhino 7\System\RhinoWindows.dll - False - - - - - - - False - C:\Program Files\Rhino 7\System\rhinocommon.dll - False - - - False - C:\Program Files\Rhino 7\System\Eto.dll - False - - - False - C:\Program Files\Rhino 7\System\Rhino.UI.dll - False - + - - - + + + - + - - - - Copy "$(TargetPath)" "$(TargetDir)$(ProjectName).rhp" -Erase "$(TargetPath)" - - - en-US - - - C:\Program Files\Rhino 7\System\Rhino.exe - - - Program - \ No newline at end of file diff --git a/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs b/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs index fdffac6f..645bbfbf 100644 --- a/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs +++ b/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs @@ -78,9 +78,8 @@ private static System.Drawing.Icon ProductIcon // is displayed if a license for the requesting product is not found. Note, the // "Close" button will always be displayed. /// - private static LicenseCapabilities Capabilities => LicenseCapabilities.CanBeEvaluated | - LicenseCapabilities.CanBePurchased | - LicenseCapabilities.CanBeSpecified; + private static LicenseCapabilities Capabilities => LicenseCapabilities.SupportsRhinoAccounts | + LicenseCapabilities.SupportsLicenseDiscovery; #endregion diff --git a/rhinocommon/cs/SampleCsWpf/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsWpf/Properties/AssemblyInfo.cs index a2724c2c..c618d523 100644 --- a/rhinocommon/cs/SampleCsWpf/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsWpf/Properties/AssemblyInfo.cs @@ -4,7 +4,7 @@ [assembly: PlugInDescription(DescriptionType.Address, "146 North Canal Street, Suite 320\r\nSeattle, WA 98103")] [assembly: PlugInDescription(DescriptionType.Country, "United States")] -[assembly: PlugInDescription(DescriptionType.Email, "dale@mcneel.com")] +[assembly: PlugInDescription(DescriptionType.Email, "devsupport@mcneel.com")] [assembly: PlugInDescription(DescriptionType.Phone, "206-545-6877")] [assembly: PlugInDescription(DescriptionType.Fax, "206-545-7321")] [assembly: PlugInDescription(DescriptionType.Organization, "Robert McNeel & Associates")] From 2d1b478a44689f955ee16404382c912818ef5587 Mon Sep 17 00:00:00 2001 From: Dale Fugier Date: Fri, 13 Dec 2024 09:49:29 -0800 Subject: [PATCH 07/10] License plug-in updates --- .../cs/SampleCsWithLicense/SampleCsWithLicenseCommand.cs | 2 +- .../cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicenseCommand.cs b/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicenseCommand.cs index bb726c1f..9b6614c0 100644 --- a/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicenseCommand.cs +++ b/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicenseCommand.cs @@ -9,7 +9,7 @@ public class SampleCsWithLicenseCommand : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - RhinoApp.WriteLine($"{0} plug-in loaded.", SampleCsWithLicensePlugIn.Instance.Name); + RhinoApp.WriteLine("{0} plug-in loaded.", SampleCsWithLicensePlugIn.Instance.Name); return Result.Success; } } diff --git a/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs b/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs index 645bbfbf..674063e0 100644 --- a/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs +++ b/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs @@ -79,7 +79,8 @@ private static System.Drawing.Icon ProductIcon // "Close" button will always be displayed. /// private static LicenseCapabilities Capabilities => LicenseCapabilities.SupportsRhinoAccounts | - LicenseCapabilities.SupportsLicenseDiscovery; + LicenseCapabilities.SupportsStandalone | + LicenseCapabilities.SupportsZooPerUser; #endregion @@ -151,6 +152,8 @@ private static ValidateResult OnValidateProductKey(string licenseKey, out Licens licenseData.DateToExpire = expire; } + var rc = licenseData.IsValid(); + return ValidateResult.Success; } From 1151c1448547749210580ed60da14372bebcd70c Mon Sep 17 00:00:00 2001 From: Dale Fugier Date: Thu, 19 Dec 2024 12:52:57 -0800 Subject: [PATCH 08/10] Added Rhino.Inside C++ sample --- rhino.inside/cpp/Main.cpp | 70 +++++++++++ rhino.inside/cpp/RhinoCore.cpp | 28 +++++ rhino.inside/cpp/RhinoCore.h | 11 ++ rhino.inside/cpp/RhinoInsideCpp.vcxproj | 113 ++++++++++++++++++ .../cpp/RhinoInsideCpp.vcxproj.filters | 36 ++++++ rhino.inside/cpp/RhinoLibrary.lib | Bin 0 -> 2498 bytes rhino.inside/cpp/pch.cpp | 5 + rhino.inside/cpp/pch.h | 21 ++++ 8 files changed, 284 insertions(+) create mode 100644 rhino.inside/cpp/Main.cpp create mode 100644 rhino.inside/cpp/RhinoCore.cpp create mode 100644 rhino.inside/cpp/RhinoCore.h create mode 100644 rhino.inside/cpp/RhinoInsideCpp.vcxproj create mode 100644 rhino.inside/cpp/RhinoInsideCpp.vcxproj.filters create mode 100644 rhino.inside/cpp/RhinoLibrary.lib create mode 100644 rhino.inside/cpp/pch.cpp create mode 100644 rhino.inside/cpp/pch.h diff --git a/rhino.inside/cpp/Main.cpp b/rhino.inside/cpp/Main.cpp new file mode 100644 index 00000000..2538f4c8 --- /dev/null +++ b/rhino.inside/cpp/Main.cpp @@ -0,0 +1,70 @@ +#include "pch.h" +#include "RhinoCore.h" + +int wmain(int argc, wchar_t** argv) +{ + // Load Rhino + CRhinoCore rhino_core(argc, argv); + + // Geet the Rhino version number, etc. + int ver = RhinoApp().ExeVersion(); + int sr = RhinoApp().ExeServiceRelease(); + ON_wString date; + RhinoApp().GetBuildDate(date); + std::wstring str0(static_cast(date)); + std::wcout << "Rhino " << ver << "." << sr << " (" << str0 << ") loaded." << std::endl; + + // Create a NURBS curve by interpolating points + ON_3dPointArray points(16); + points.Append(ON_3dPoint(0.0, 3.12494, 0.0)); + points.Append(ON_3dPoint(7.01306, 3.31419, 0.0)); + points.Append(ON_3dPoint(8.01888, 3.34416, 0.0)); + points.Append(ON_3dPoint(9.02578, 3.37375, 0.0)); + points.Append(ON_3dPoint(10.0338, 3.40260, 0.0)); + points.Append(ON_3dPoint(11.0430, 3.43034, 0.0)); + points.Append(ON_3dPoint(12.0533, 3.45659, 0.0)); + points.Append(ON_3dPoint(13.0648, 3.48098, 0.0)); + points.Append(ON_3dPoint(14.0776, 3.50313, 0.0)); + points.Append(ON_3dPoint(15.0916, 3.52267, 0.0)); + points.Append(ON_3dPoint(16.1068, 3.53923, 0.0)); + points.Append(ON_3dPoint(17.1233, 3.55249, 0.0)); + points.Append(ON_3dPoint(18.1410, 3.56222, 0.0)); + points.Append(ON_3dPoint(19.1587, 3.56829, 0.0)); + points.Append(ON_3dPoint(20.1758, 3.57091, 0.0)); + points.Append(ON_3dPoint(30.3156, 3.45748, 0.0)); + + const int knot_style = 0; // uniform + ON_NurbsCurve* pCurve = RhinoInterpCurve(3, points, nullptr, nullptr, knot_style, nullptr); + if (pCurve) + { + double length = ON_UNSET_VALUE; + if (pCurve->GetLength(&length)) + std::cout << "ON_NurbsCurve with " << length << " length created" << std::endl; + + CRhinoCreateDocumentOptions options; + options.SetCreateHeadless(true); + int doc_runtime_serial_number = CRhinoDoc::CreateDocument(nullptr, &options); + + CRhinoDoc* pDoc = CRhinoDoc::FromRuntimeSerialNumber(doc_runtime_serial_number); + pDoc->AddCurveObject(*pCurve, nullptr, nullptr, 0); + delete pCurve; // Don't leak + + ON_wString path; + CRhinoFileUtilities::GetMyDocumentsFolder(path); + path += L"\\RhinoInsideConsoleCxx.3dm"; + + FILE* pFile = ON::OpenFile(static_cast(path), L"wb"); + if (nullptr != pFile) + { + ON_BinaryFile archive(ON::archive_mode::write3dm, pFile); + CRhinoFileWriteOptions fwo; + pDoc->Write3dmFile(archive, fwo); + ON::CloseFile(pFile); + + std::wstring str1(static_cast(path)); + std::wcout << "Curve saved to " << str1 << std::endl; + } + } + + system("pause"); +} diff --git a/rhino.inside/cpp/RhinoCore.cpp b/rhino.inside/cpp/RhinoCore.cpp new file mode 100644 index 00000000..318525fa --- /dev/null +++ b/rhino.inside/cpp/RhinoCore.cpp @@ -0,0 +1,28 @@ +#include "pch.h" +#include "RhinoCore.h" + +// https://learn.microsoft.com/en-us/cpp/build/reference/understanding-the-helper-function +static FARPROC WINAPI delayHookRhinoLibrary(unsigned dliNotify, PDelayLoadInfo pdli) +{ + static const wchar_t* RhinoLibraryPath = L"C:\\Program Files\\Rhino 8\\System\\RhinoLibrary.dll"; + if (dliNotify == dliNotePreLoadLibrary && pdli && _stricmp(pdli->szDll, "RhinoLibrary.dll") == 0) + return (FARPROC)LoadLibraryEx(RhinoLibraryPath, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); + return nullptr; +} + +static const PfnDliHook __pfnDliNotifyHook2 = delayHookRhinoLibrary; + +// Exported from RhinoCore.dll +extern "C" HRESULT StartupInProcess(int argc, wchar_t** argv, const STARTUPINFO* pStartUpInfo, HWND hHostWnd); +extern "C" HRESULT ShutdownInProcess(); + +CRhinoCore::CRhinoCore(int argc, wchar_t** argv) +{ + StartupInProcess(argc, argv, nullptr, HWND_DESKTOP); +} + +CRhinoCore::~CRhinoCore() +{ + ShutdownInProcess(); +} + diff --git a/rhino.inside/cpp/RhinoCore.h b/rhino.inside/cpp/RhinoCore.h new file mode 100644 index 00000000..0ed8dee0 --- /dev/null +++ b/rhino.inside/cpp/RhinoCore.h @@ -0,0 +1,11 @@ +#pragma once + +/// +/// RhinoCore.dll loader +/// +class CRhinoCore +{ +public: + CRhinoCore(int argc, wchar_t** argv); + ~CRhinoCore(); +}; diff --git a/rhino.inside/cpp/RhinoInsideCpp.vcxproj b/rhino.inside/cpp/RhinoInsideCpp.vcxproj new file mode 100644 index 00000000..3754d5fe --- /dev/null +++ b/rhino.inside/cpp/RhinoInsideCpp.vcxproj @@ -0,0 +1,113 @@ + + + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {D7FF073D-B25B-4911-BB56-AE0E6030944C} + Win32Proj + RhinoInsideCpp + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + true + + + false + + + + Use + Level3 + Disabled + true + NDEBUG;WIN64;_CONSOLE;%(PreprocessorDefinitions) + pch.h + C:\Program Files\Rhino 8 SDK\inc\ + ProgramDatabase + false + stdcpp17 + + + Console + true + C:\Program Files\Rhino 8 SDK\lib\Release + opennurbs.lib;RhinoCore.lib;RhinoLibrary.lib;%(AdditionalDependencies) + opennurbs.dll;RhinoCore.dll;RhinoLibrary.dll + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;WIN64;_CONSOLE;%(PreprocessorDefinitions) + pch.h + C:\Program Files\Rhino 8 SDK\inc\ + stdcpp17 + + + Console + true + true + true + C:\Program Files\Rhino 8 SDK\lib\Release + opennurbs.lib;RhinoCore.lib;RhinoLibrary.lib;%(AdditionalDependencies) + opennurbs.dll;RhinoCore.dll;RhinoLibrary.dll + + + + + + + + + Create + Create + + + + false + + + + + + \ No newline at end of file diff --git a/rhino.inside/cpp/RhinoInsideCpp.vcxproj.filters b/rhino.inside/cpp/RhinoInsideCpp.vcxproj.filters new file mode 100644 index 00000000..16721bf4 --- /dev/null +++ b/rhino.inside/cpp/RhinoInsideCpp.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/rhino.inside/cpp/RhinoLibrary.lib b/rhino.inside/cpp/RhinoLibrary.lib new file mode 100644 index 0000000000000000000000000000000000000000..987feec0e743fb0bde6dce1564cb0fcc30036637 GIT binary patch literal 2498 zcmcIl%}!H66#n{0p&D(_=muj^jJUA>#gG_M6pRg}G;P@sliSjZ-Zs!S{fWAA$I3Mi z;X@c6!MHT6T=)=d>N)q$l-s$LQbQ-1Idi@__ntFnzB9A^Yk^2;xIK>z>r#t~ zNqkk#$^ig30M7#8+XH4!0ROqwXX}93&qz|A%X8PX%yxdKP|`Lwi?0ird}*hk6^vS= znXT=&EA7wFwA^ks>$JibyP0KFdb^w3(l*vh>)8BM>t-7HcC&iW>CjJVM=fm_%T{`g zs-fDbXwm3(_2$QhYUjj@-AcRLYdH*6c+%`9q8HiqQ+gLXz@85{nE}oTsLujt)bn#@ z>fwbCGw{O&_h9Z(@-cpwBX;w@2Q@1B7N&+_q0ZC_T+QU=42UR+9>?O?3(4zpz)r2O zet3vLL>_`L8uzzUEGaC@0sYv6KDB!;Vm_T9x3GS&-}|ssv^3xiO}(T|yyQ>XF`h=~)J^g}h$_^A>NcO^PLL_~!(0Y# z;Wp~V{C2I{Zg!gQyP@U6vrsmZ+Y;+T;wEVv4R`Ww&Vn=&RS8pFQ8d-&QH#Q^8!lJB zZ~u-y0LSTu+s?$h!nY?5q4A7NmVxl1cVJCuEZlfU7fFk+lH9v9X#aCBsxw9(o zH+itme01(Esl1d-7gsJ + +#include +#include +#include +#include + +// Rhino SDK classes +#pragma warning (disable: 4251) +#include +#include From c2a7730713a975e04c1136ce68223fd632f73497 Mon Sep 17 00:00:00 2001 From: Dale Fugier Date: Thu, 19 Dec 2024 12:59:08 -0800 Subject: [PATCH 09/10] Removed obsolete library --- rhino.inside/cpp/RhinoLibrary.lib | Bin 2498 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 rhino.inside/cpp/RhinoLibrary.lib diff --git a/rhino.inside/cpp/RhinoLibrary.lib b/rhino.inside/cpp/RhinoLibrary.lib deleted file mode 100644 index 987feec0e743fb0bde6dce1564cb0fcc30036637..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2498 zcmcIl%}!H66#n{0p&D(_=muj^jJUA>#gG_M6pRg}G;P@sliSjZ-Zs!S{fWAA$I3Mi z;X@c6!MHT6T=)=d>N)q$l-s$LQbQ-1Idi@__ntFnzB9A^Yk^2;xIK>z>r#t~ zNqkk#$^ig30M7#8+XH4!0ROqwXX}93&qz|A%X8PX%yxdKP|`Lwi?0ird}*hk6^vS= znXT=&EA7wFwA^ks>$JibyP0KFdb^w3(l*vh>)8BM>t-7HcC&iW>CjJVM=fm_%T{`g zs-fDbXwm3(_2$QhYUjj@-AcRLYdH*6c+%`9q8HiqQ+gLXz@85{nE}oTsLujt)bn#@ z>fwbCGw{O&_h9Z(@-cpwBX;w@2Q@1B7N&+_q0ZC_T+QU=42UR+9>?O?3(4zpz)r2O zet3vLL>_`L8uzzUEGaC@0sYv6KDB!;Vm_T9x3GS&-}|ssv^3xiO}(T|yyQ>XF`h=~)J^g}h$_^A>NcO^PLL_~!(0Y# z;Wp~V{C2I{Zg!gQyP@U6vrsmZ+Y;+T;wEVv4R`Ww&Vn=&RS8pFQ8d-&QH#Q^8!lJB zZ~u-y0LSTu+s?$h!nY?5q4A7NmVxl1cVJCuEZlfU7fFk+lH9v9X#aCBsxw9(o zH+itme01(Esl1d-7gsJ Date: Wed, 8 Jan 2025 11:34:21 -0800 Subject: [PATCH 10/10] Code cleanup --- .../SampleCsConsole/Program.cs | 4 +- .../Properties/AssemblyInfo.cs | 1 - .../SampleCsRhino/Properties/AssemblyInfo.cs | 4 +- .../SampleCsRhino/SampleCsRhinoCommand.cs | 4 +- .../SampleCsRhino/SampleCsRhinoHelpers.cs | 14 +- .../SampleCsRhino/SampleCsRhinoObject.cs | 36 +-- .../SampleCsRhino/SampleCsRhinoPlugIn.cs | 10 +- .../CollapsibleSectionUICommand.cs | 7 +- .../CollapsibleSectionUIPanel.cs | 5 +- .../Properties/AssemblyInfo.cs | 4 +- .../SectionOne.cs | 4 +- .../SectionTwo.cs | 4 +- .../SampleCSParseTextFields.cs | 29 ++- .../cs/SampleCsCommands/SampleCSQuadRemesh.cs | 12 +- .../SampleCSRibbonOffsetCurve.cs | 16 +- .../SampleCSSilhouetteDraftCurve.cs | 31 ++- .../SampleCsAddAlignedDimension.cs | 18 +- .../SampleCsAddNurbsCircle.cs | 18 +- .../SampleCsCommands/SampleCsAddNurbsCurve.cs | 14 +- .../SampleCsAddNurbsSurface.cs | 14 +- .../SampleCsAddRadialDimension.cs | 12 +- .../SampleCsAddRdkMaterials.cs | 10 +- .../cs/SampleCsCommands/SampleCsAddTextDot.cs | 16 +- .../SampleCsCommands/SampleCsAlignProfiles.cs | 48 ++-- .../SampleCsAppearanceColors.cs | 4 +- .../cs/SampleCsCommands/SampleCsApplyCrv.cs | 52 ++-- .../cs/SampleCsCommands/SampleCsArc.cs | 54 ++-- .../cs/SampleCsCommands/SampleCsArray.cs | 10 +- .../SampleCsAutomateGrasshopper.cs | 6 +- .../cs/SampleCsCommands/SampleCsBlock.cs | 20 +- .../SampleCsBooleanDifference2.cs | 14 +- .../SampleCsBooleanDifference3.cs | 28 +-- .../SampleCsBooleanDifference4.cs | 36 +-- .../SampleCsCommands/SampleCsBoundingBox.cs | 40 +-- .../cs/SampleCsCommands/SampleCsBoxMorph.cs | 8 +- .../SampleCsCachedTextureCoordinates.cs | 23 +- .../SampleCsCommands/SampleCsCircleOfLines.cs | 24 +- .../SampleCsCommands/SampleCsCircleRadius.cs | 16 +- .../SampleCsCommands/SampleCsClashMeshes.cs | 68 ++--- .../SampleCsCommands/SampleCsClashObjects.cs | 30 +-- .../SampleCsCommands/SampleCsClassifyCurve.cs | 86 +++---- .../SampleCsColorfulMeshBox.cs | 6 +- .../SampleCsCommandLineOptions.cs | 20 +- .../SampleCsCommandsPlugIn.cs | 12 +- .../cs/SampleCsCommands/SampleCsContour.cs | 64 ++--- .../SampleCsCommands/SampleCsContourMesh.cs | 3 +- .../SampleCsCreateBooleanRegions.cs | 46 ++-- .../SampleCsCreateNestedBlock.cs | 22 +- .../SampleCsCommands/SampleCsCreateUVCurve.cs | 8 +- .../SampleCsCurveDirection.cs | 9 +- .../SampleCsCurveDiscontinuity.cs | 38 +-- .../SampleCsCurveEditPoints.cs | 3 +- .../SampleCsCommands/SampleCsCurveGetter.cs | 6 +- .../SampleCsCommands/SampleCsCurvePoints.cs | 4 +- .../cs/SampleCsCommands/SampleCsCurveSeam.cs | 44 ++-- .../cs/SampleCsCommands/SampleCsCustomLine.cs | 3 +- .../SampleCsCustomRenderMeshSettings.cs | 5 +- .../SampleCsCommands/SampleCsCylinderTest.cs | 37 ++- .../SampleCsDeleteMeshFace.cs | 8 +- .../SampleCsDeleteSubCurve.cs | 6 +- .../cs/SampleCsCommands/SampleCsDetailLock.cs | 6 +- .../cs/SampleCsCommands/SampleCsDrawArrow.cs | 28 +-- .../SampleCsCommands/SampleCsDrawDistance.cs | 6 +- .../SampleCsCommands/SampleCsDrawGrayscale.cs | 24 +- .../cs/SampleCsCommands/SampleCsDrawMesh.cs | 10 +- .../cs/SampleCsCommands/SampleCsDrawPin.cs | 28 +-- .../SampleCsDrawRightAlignedText.cs | 18 +- .../cs/SampleCsCommands/SampleCsDrawText.cs | 11 +- .../SampleCsCommands/SampleCsDumpBlockTree.cs | 20 +- .../SampleCsDuplicateBorder.cs | 28 +-- .../SampleCsDuplicateMeshBorder.cs | 6 +- .../SampleCsDuplicateObjectFromNameTag.cs | 46 ++-- .../SampleCsCommands/SampleCsEditPolyline.cs | 17 +- .../SampleCsCommands/SampleCsEmbedTextFile.cs | 20 +- .../cs/SampleCsCommands/SampleCsEscapeKey.cs | 6 +- .../cs/SampleCsCommands/SampleCsEscapeKey2.cs | 16 +- .../SampleCsCommands/SampleCsExplodeBlock.cs | 30 +-- .../SampleCsCommands/SampleCsExplodeHatch.cs | 3 +- .../SampleCsExplodePolyCurve.cs | 8 +- .../cs/SampleCsCommands/SampleCsExportDXF.cs | 14 +- .../SampleCsExportSvgWithDialog.cs | 20 +- .../SampleCsExtractInflectionPoints.cs | 38 +-- .../SampleCsExtractMinMaxRadiusPoints.cs | 70 +++--- .../SampleCsExtractPreview.cs | 6 +- .../SampleCsExtrudeMeshFace.cs | 34 +-- .../cs/SampleCsCommands/SampleCsExtrusion.cs | 36 +-- .../SampleCsCommands/SampleCsFaceWithHole.cs | 96 ++++---- .../cs/SampleCsCommands/SampleCsFairCurves.cs | 40 +-- .../cs/SampleCsCommands/SampleCsFilletSrf.cs | 29 ++- .../SampleCsFindUnweldedEdges.cs | 48 ++-- .../SampleCsCommands/SampleCsGetDirection.cs | 10 +- .../SampleCsGetMultiplePoints.cs | 14 +- .../cs/SampleCsCommands/SampleCsGetPoint.cs | 27 +- .../SampleCsGetPointOnBreps.cs | 27 +- .../cs/SampleCsCommands/SampleCsGroup.cs | 14 +- .../cs/SampleCsCommands/SampleCsGuilloche.cs | 60 ++--- .../SampleCsGumballCylinder.cs | 52 ++-- .../cs/SampleCsCommands/SampleCsHatch.cs | 10 +- .../SampleCsCommands/SampleCsHideInDetail.cs | 28 +-- .../cs/SampleCsCommands/SampleCsHistory.cs | 3 +- .../SampleCsCommands/SampleCsHistoryDivide.cs | 5 +- .../SampleCsImportNamedViews.cs | 16 +- .../SampleCsIntersectBreps.cs | 24 +- .../SampleCsIntersectCircles.cs | 22 +- .../SampleCsIntersectCurveBrepFace.cs | 16 +- .../SampleCsIntersectCurveLine.cs | 36 +-- .../SampleCsIntersectCurveSelf.cs | 20 +- .../SampleCsIntersectCurves.cs | 24 +- .../SampleCsIntersectionMeshPolyline.cs | 14 +- .../SampleCsInvertSelected.cs | 12 +- .../cs/SampleCsCommands/SampleCsIsolate.cs | 11 +- .../SampleCsLastCreatedObjects.cs | 14 +- .../cs/SampleCsCommands/SampleCsLayerOff.cs | 24 +- .../SampleCsCommands/SampleCsLayerPathName.cs | 28 +-- .../cs/SampleCsCommands/SampleCsMake2D.cs | 32 +-- .../cs/SampleCsCommands/SampleCsMeshBox.cs | 37 ++- .../cs/SampleCsCommands/SampleCsMeshBrep.cs | 3 +- .../SampleCsCommands/SampleCsMeshOutline.cs | 12 +- .../SampleCsModifySphereRadius.cs | 4 +- .../cs/SampleCsCommands/SampleCsMove.cs | 10 +- .../cs/SampleCsCommands/SampleCsMoveGrips.cs | 12 +- .../cs/SampleCsCommands/SampleCsMoveNormal.cs | 35 ++- .../SampleCsNamedPlaneSurface.cs | 12 +- .../SampleCsCommands/SampleCsNurbsCircle.cs | 20 +- .../SampleCsObjectEnumerator.cs | 61 +++-- .../cs/SampleCsCommands/SampleCsOpen3dm.cs | 4 +- .../cs/SampleCsCommands/SampleCsOpenDwg.cs | 12 +- .../SampleCsCommands/SampleCsOptionsList.cs | 26 +- .../SampleCsCommands/SampleCsOrientOnMesh.cs | 38 +-- .../SampleCsOrientPerpendicularToCurve.cs | 24 +- .../cs/SampleCsCommands/SampleCsOverCut.cs | 126 +++++----- .../SampleCsPerFaceMaterial.cs | 17 +- .../SampleCsPersistentSettings.cs | 34 +-- .../cs/SampleCsCommands/SampleCsPickHole.cs | 138 +++++------ .../SampleCsCommands/SampleCsPictureFrame.cs | 9 +- .../SampleCsPlanarClosedCurveRelationship.cs | 16 +- .../SampleCsPlanarFaceLoops.cs | 18 +- .../SampleCsPointCloudPoints.cs | 16 +- .../SampleCsCommands/SampleCsPointOnMesh.cs | 5 +- .../SampleCsCommands/SampleCsPrePostSelect.cs | 10 +- .../SampleCsCommands/SampleCsPrintViewList.cs | 3 +- .../SampleCsProjectCurvesToBrep.cs | 31 ++- .../SampleCsProjectPointToMesh.cs | 27 +- .../SampleCsPullGripsToMesh.cs | 24 +- .../cs/SampleCsCommands/SampleCsRTree.cs | 46 ++-- .../SampleCsRenderBackground.cs | 3 +- .../SampleCsRestoreNamedView.cs | 6 +- .../cs/SampleCsCommands/SampleCsRotate.cs | 62 ++--- .../cs/SampleCsCommands/SampleCsSave3DS.cs | 12 +- .../cs/SampleCsCommands/SampleCsSaveAs.cs | 8 +- .../SampleCsScriptedSweep2.cs | 36 +-- .../cs/SampleCsCommands/SampleCsSelCircle.cs | 8 +- .../SampleCsCommands/SampleCsSelectHoles.cs | 24 +- .../SampleCsSelectLayerObjects.cs | 10 +- .../SampleCsSetCameraTarget.cs | 14 +- .../SampleCsSetDisplayMode.cs | 5 +- .../SampleCsSetDocumentUserText.cs | 2 +- .../SampleCsCommands/SampleCsSetObjectName.cs | 16 +- .../cs/SampleCsCommands/SampleCsSetPoint.cs | 7 +- .../SampleCsCommands/SampleCsSetUserText.cs | 28 +-- .../cs/SampleCsCommands/SampleCsShadedBrep.cs | 11 +- .../cs/SampleCsCommands/SampleCsShadedView.cs | 5 +- .../SampleCsCommands/SampleCsSineWaveLoft.cs | 18 +- .../cs/SampleCsCommands/SampleCsSketch.cs | 22 +- .../cs/SampleCsCommands/SampleCsSmash.cs | 3 +- .../cs/SampleCsCommands/SampleCsSmooth.cs | 5 +- .../cs/SampleCsCommands/SampleCsSpiral.cs | 17 +- .../cs/SampleCsCommands/SampleCsSplitCurve.cs | 10 +- .../SampleCsStackedControlPointsCurve.cs | 16 +- .../cs/SampleCsCommands/SampleCsSubCurve.cs | 9 +- .../SampleCsCommands/SampleCsSubDEditPts.cs | 154 ++++++------ .../cs/SampleCsCommands/SampleCsSweep1.cs | 7 +- .../SampleCsTestPlanarCurveContainment.cs | 12 +- .../cs/SampleCsCommands/SampleCsText.cs | 30 +-- .../SampleCsTextEntityBoundingBox.cs | 18 +- .../SampleCsCommands/SampleCsTrimSurface.cs | 26 +- .../SampleCsCommands/SampleCsTrimmedPlane.cs | 50 ++-- .../cs/SampleCsCommands/SampleCsUnisolate.cs | 11 +- .../cs/SampleCsCommands/SampleCsUnweldAll.cs | 26 +- .../cs/SampleCsCommands/SampleCsUtilities.cs | 50 ++-- .../SampleCsViewBoundingBox.cs | 4 +- .../SampleCsCommands/SampleCsViewCapture.cs | 16 +- .../SampleCsViewCaptureBoundingBox.cs | 58 ++--- .../cs/SampleCsCommands/SampleCsViewSize.cs | 32 ++- .../SampleCsCommands/SampleCsViewportSize.cs | 11 +- .../SampleCsWorldToPageTransform.cs | 24 +- .../SampleCsCommands/SampleCsWrite3dmFile.cs | 22 +- .../cs/SampleCsCommands/SampleCsWriteStl.cs | 34 +-- .../cs/SampleCsCommands/SampleCsZAnalysis.cs | 52 ++-- .../SampleCsCommands/SampleCsZebraAnalysis.cs | 10 +- .../cs/SampleCsCommands/SampleCsZoom.cs | 22 +- .../CustomLightManager.cs | 12 +- .../Properties/AssemblyInfo.cs | 4 +- .../SampleCustomLightManagerCommand.cs | 7 +- .../Properties/AssemblyInfo.cs | 5 +- .../SampleCsCustomMeshMappingCommand.cs | 12 +- .../SampleCsCustomMeshMappingPlugIn.cs | 44 ++-- .../CustomRenderSection1.cs | 6 +- .../CustomRenderSettingsSectionsPlugIn.cs | 9 +- .../CustomRenderSettingsViewModel.cs | 13 +- .../Properties/AssemblyInfo.cs | 4 +- .../CustomSunSection1.cs | 5 +- .../CustomSunSection2.cs | 4 +- .../CustomSunSectionsCommand.cs | 7 +- .../CustomSunSectionsPlugIn.cs | 7 +- .../Properties/AssemblyInfo.cs | 4 +- ...pleCsDeserializeEmbeddedResourceCommand.cs | 4 +- .../SampleCsSerializeBrepToFileCommand.cs | 14 +- .../Properties/AssemblyInfo.cs | 4 +- .../SampleCsGeometryHelper.cs | 32 +-- .../Properties/AssemblyInfo.cs | 4 +- .../SampleCsDockBar/SampleCsDockbarCommand.cs | 7 +- .../SampleCsDockBar/SampleCsDocklBarPlugIn.cs | 8 +- .../SampleCsDockBar/SampleCsWinFormPanel.cs | 10 +- .../Properties/AssemblyInfo.cs | 5 +- .../SampleCsDragDropCommand.cs | 18 +- .../cs/SampleCsDragDrop/SampleCsDropTarget.cs | 10 +- .../SampleCsDragDrop/SampleCsUserControl.cs | 4 +- .../SampleCsEto/Commands/SampleCsEtoCoffee.cs | 40 +-- .../Commands/SampleCsEtoModalDialogCommand.cs | 8 +- .../SampleCsEtoModelessFormCommand.cs | 4 +- .../Commands/SampleCsEtoOrderCurvesCommand.cs | 56 ++--- .../Commands/SampleCsEtoPanelCommand.cs | 18 +- .../Commands/SampleCsEtoRebuildCurve.cs | 36 +-- .../SampleCsEtoSemiModalDialogCommand.cs | 8 +- .../Commands/SampleCsEtoViewportCommand.cs | 10 +- .../cs/SampleCsEto/Properties/AssemblyInfo.cs | 3 +- .../cs/SampleCsEto/SampleCsEtoPlugIn.cs | 10 +- .../Views/SampleCsEtoModalDialog.cs | 8 +- .../Views/SampleCsEtoModelessForm.cs | 8 +- .../Views/SampleCsEtoOptionsPage.cs | 12 +- .../cs/SampleCsEto/Views/SampleCsEtoPanel.cs | 13 +- .../Views/SampleCsEtoPropertiesPage.cs | 18 +- .../Views/SampleCsEtoSemiModalDialog.cs | 6 +- .../SampleCsEventHandlers.cs | 8 +- .../SampleCsEventWatcherCommand.cs | 16 +- .../Properties/AssemblyInfo.cs | 4 +- .../SampleCsMobilePlaneCommand.cs | 52 ++-- .../SampleCsMobilePlaneUserData.cs | 36 +-- .../Properties/AssemblyInfo.cs | 5 +- .../SampleCsMouseCallbackCommand.cs | 57 ++--- .../SampleCsMouseCallbackPlugIn.cs | 46 ++-- .../SampleMouseCallback.cs | 44 ++-- .../cs/SampleCsRdk/BufferedTreeView.cs | 28 +-- rhinocommon/cs/SampleCsRdk/CustomContentIo.cs | 7 +- .../cs/SampleCsRdk/CustomEnvironment.cs | 44 ++-- .../SampleCsRdk/CustomEtoUiSectionMaterial.cs | 32 +-- rhinocommon/cs/SampleCsRdk/CustomMaterial.cs | 16 +- .../CustomMaterialUserInterfaceSection.cs | 16 +- .../CustomMaterialUserInterfaceSection2.cs | 7 +- .../cs/SampleCsRdk/CustomMaterialViewModel.cs | 61 +++-- rhinocommon/cs/SampleCsRdk/CustomTexture.cs | 114 +++++---- .../cs/SampleCsRdk/Properties/AssemblyInfo.cs | 5 +- .../cs/SampleCsRdk/TestCustomMeshProvider.cs | 141 ++++++----- .../cs/SampleCsRdk/rdktest_csCommand.cs | 1 - .../cs/SampleCsRdk/rdktest_csPlugIn.cs | 45 ++-- .../Properties/AssemblyInfo.cs | 4 +- .../SampleRdkMaterial.cs | 9 +- .../SampleRdkMaterialAutoUICommand.cs | 4 +- .../SampleRdkMaterialAutoUIPlugIn.cs | 9 +- .../SampleRenderContentSerializer.cs | 18 +- .../Properties/AssemblyInfo.cs | 4 +- .../SampleCsRectangleGrips.cs | 58 ++--- .../SampleCsRectangleGripsCommand.cs | 6 +- .../SampleCsRectangleGripsEnabler.cs | 4 +- .../SampleCsRectangleHelper.cs | 26 +- .../CommandPluginCommand.cs | 106 ++++---- .../CommandPluginPlugIn.cs | 232 +++++++++--------- .../Properties/AssemblyInfo.cs | 1 - .../SampleCsCommon/Properties/AssemblyInfo.cs | 1 - .../SampleCsCommon/SampleCsStringTable.cs | 10 +- .../SampleCsStringTableHelpers.cs | 4 +- .../SampleCsMain/Properties/AssemblyInfo.cs | 4 +- .../SampleCsMain/SampleCsMainCommand.cs | 2 +- .../SampleCsMain/SampleCsMainPanel.cs | 4 +- .../SampleCsMain/SampleCsMainPlugIn.cs | 8 +- .../SampleCsTest1/Properties/AssemblyInfo.cs | 4 +- .../SampleCsTest2/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../SampleCsSettings1Command.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../SampleCsSettings2Command.cs | 7 +- .../SampleCsSettings2PlugIn.cs | 14 +- .../SampleCsSkin/Properties/AssemblyInfo.cs | 5 +- .../cs/SampleCsSkin/SampleCsSkinObject.cs | 10 +- .../SampleCsSplashScreenWorker.cs | 8 +- .../Properties/AssemblyInfo.cs | 4 +- .../SampleCsSnapshotsClientCommand.cs | 7 +- .../SampleCsSnapshotsClientPlugIn.cs | 2 +- .../SampleSnapShotClient.cs | 12 +- .../Commands/SampleCsAddBrepFaceUserData.cs | 20 +- .../Commands/SampleCsAddGroupUserData.cs | 4 +- .../Commands/SampleCsAddLayerUserData.cs | 8 +- .../Commands/SampleCsAddSimpleDocumentData.cs | 10 +- .../Commands/SampleCsAddUserData.cs | 10 +- .../Commands/SampleCsModifyUserData.cs | 8 +- .../Commands/SampleCsQueryLayerUserData.cs | 6 +- .../Commands/SampleCsQueryUserData.cs | 4 +- .../Commands/SampleCsRemoveUserData.cs | 6 +- .../Commands/SampleCsStringTable.cs | 38 +-- .../SampleCsSimpleDocumentData.cs | 24 +- .../SampleCsStringDocumentData.cs | 8 +- .../SampleCsUserDataObject.cs | 2 +- .../SampleCsUserDataPlugIn.cs | 8 +- .../CollapsibleSectionUIPanel.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../SampleViewportPropertiesETOUIPlugIn.cs | 1 - .../SectionOne.cs | 4 +- .../SectionTwo.cs | 4 +- .../ViewportPropertiesPage.cs | 116 +++++---- .../Commands/SampleCsFibonacciCommand.cs | 6 +- .../Commands/SampleCsModalFormCommand.cs | 12 +- .../Commands/SampleCsModelessFormCommand.cs | 4 +- .../SampleCsModelessTabFormCommand.cs | 4 +- .../Commands/SampleCsPanelCommand.cs | 18 +- .../Commands/SampleCsSemiModalFormCommand.cs | 12 +- .../Forms/SampleCsDocPropertiesPage.cs | 3 +- .../Forms/SampleCsDocPropertiesUserControl.cs | 4 +- .../Forms/SampleCsFibonacciForm.cs | 4 +- .../Forms/SampleCsModalForm.cs | 6 +- .../Forms/SampleCsModelessTabFix.cs | 6 +- .../Forms/SampleCsObjectPropertiesPage.cs | 11 +- .../Forms/SampleCsOptionsPage.cs | 3 +- .../Properties/AssemblyInfo.cs | 4 +- .../SampleCsWinFormsPlugIn.cs | 12 +- .../SampleCsWithLicensePlugIn.cs | 16 +- .../cs/SampleCsWizardPanel/EtoPanel0.cs | 2 +- .../cs/SampleCsWizardPanel/MainPanel.cs | 6 +- .../Properties/AssemblyInfo.cs | 4 +- .../SampleCsWizardPanelViewModel.cs | 6 +- .../Commands/SampleCsWpfPanelCommand.cs | 28 +-- .../SampleCsWpfSemiModalDialogCommand.cs | 2 +- .../Commands/SampleCsWpfViewportCommand.cs | 2 +- .../ViewModels/SampleCsWpfPaneViewModel.cs | 2 +- .../Views/SampleCsWpfDialog.xaml.cs | 17 +- .../Views/SampleCsWpfPanel.xaml.cs | 10 +- 336 files changed, 3286 insertions(+), 3475 deletions(-) diff --git a/rhinocommon/cs/SampleCsAutomation/SampleCsConsole/Program.cs b/rhinocommon/cs/SampleCsAutomation/SampleCsConsole/Program.cs index d7c044e0..ea4d4de1 100644 --- a/rhinocommon/cs/SampleCsAutomation/SampleCsConsole/Program.cs +++ b/rhinocommon/cs/SampleCsAutomation/SampleCsConsole/Program.cs @@ -12,7 +12,7 @@ static void Main() try { const string rhino_id = "Rhino.Application"; - var type = Type.GetTypeFromProgID(rhino_id); + Type type = Type.GetTypeFromProgID(rhino_id); rhino = Activator.CreateInstance(type); } catch @@ -28,7 +28,7 @@ static void Main() // Wait until Rhino is initialized before calling into it const int bail_milliseconds = 15 * 1000; - var time_waiting = 0; + int time_waiting = 0; while (0 == rhino.IsInitialized()) { Thread.Sleep(100); diff --git a/rhinocommon/cs/SampleCsAutomation/SampleCsConsole/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsAutomation/SampleCsConsole/Properties/AssemblyInfo.cs index 604b24ff..6ca3bc3f 100644 --- a/rhinocommon/cs/SampleCsAutomation/SampleCsConsole/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsAutomation/SampleCsConsole/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/Properties/AssemblyInfo.cs index 105d7944..2e802b1a 100644 --- a/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoCommand.cs b/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoCommand.cs index 5666ccb6..1b74f558 100644 --- a/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoCommand.cs +++ b/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoCommand.cs @@ -1,6 +1,6 @@ -using System.Runtime.InteropServices; -using Rhino; +using Rhino; using Rhino.Commands; +using System.Runtime.InteropServices; namespace SampleCsRhino { diff --git a/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoHelpers.cs b/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoHelpers.cs index 47c1d004..9c18f2f0 100644 --- a/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoHelpers.cs +++ b/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoHelpers.cs @@ -1,6 +1,6 @@ -using System; +using Rhino.Geometry; +using System; using System.Collections.Generic; -using Rhino.Geometry; namespace SampleCsRhino { @@ -11,7 +11,7 @@ public class SampleCsRhinoHelpers /// public static bool ConvertToPoint3d(object pointObj, ref Point3d point) { - var rc = false; + bool rc = false; if (pointObj is Array point_arr && 3 == point_arr.Length) { try @@ -43,13 +43,13 @@ public static bool ConvertToPoint3d(object pointObj, ref Point3d point) /// public static bool ConvertToPoint3dList(object pointsObj, ref List points) { - var rc = false; - var points_count = points.Count; + bool rc = false; + int points_count = points.Count; if (pointsObj is Array point_arr) { - for (var i = 0; i < point_arr.Length; i++) + for (int i = 0; i < point_arr.Length; i++) { - var point = new Point3d(); + Point3d point = new Point3d(); if (ConvertToPoint3d(point_arr.GetValue(i), ref point)) points.Add(point); } diff --git a/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoObject.cs b/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoObject.cs index 7e32c12a..c48b5550 100644 --- a/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoObject.cs +++ b/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoObject.cs @@ -1,8 +1,8 @@ -using System.Collections; +using Rhino; +using Rhino.Geometry; +using System.Collections; using System.Collections.Generic; using System.Linq; -using Rhino; -using Rhino.Geometry; namespace SampleCsRhino { @@ -39,7 +39,7 @@ public string GetString() /// public object GetPoint() { - var pt = new ArrayList(3) {2.0, 1.0, 0.0}; + ArrayList pt = new ArrayList(3) { 2.0, 1.0, 0.0 }; return pt.ToArray(); } @@ -48,18 +48,18 @@ public object GetPoint() /// public object GetPoints() { - var pts = new ArrayList(); + ArrayList pts = new ArrayList(); - var p0 = new ArrayList {0.0, 0.0, 0.0}; + ArrayList p0 = new ArrayList { 0.0, 0.0, 0.0 }; pts.Add(p0.ToArray()); - var p1 = new ArrayList {10.0, 0.0, 0.0}; + ArrayList p1 = new ArrayList { 10.0, 0.0, 0.0 }; pts.Add(p1.ToArray()); - var p2 = new ArrayList {10.0, 10.0, 0.0}; + ArrayList p2 = new ArrayList { 10.0, 10.0, 0.0 }; pts.Add(p2.ToArray()); - var p3 = new ArrayList {0.0, 10.0, 0.0}; + ArrayList p3 = new ArrayList { 0.0, 10.0, 0.0 }; pts.Add(p3.ToArray()); return pts.ToArray(); @@ -70,13 +70,13 @@ public object GetPoints() /// public object AddPoint(object pointObj) { - var point = new Point3d(); + Point3d point = new Point3d(); if (SampleCsRhinoHelpers.ConvertToPoint3d(pointObj, ref point)) { - var doc = RhinoDoc.ActiveDoc; + RhinoDoc doc = RhinoDoc.ActiveDoc; if (null != doc) { - var object_id = doc.Objects.AddPoint(point); + System.Guid object_id = doc.Objects.AddPoint(point); if (!object_id.Equals(System.Guid.Empty)) { doc.Views.Redraw(); @@ -92,16 +92,16 @@ public object AddPoint(object pointObj) /// public object AddPoints(object pointsObj) { - var points = new List(); + List points = new List(); if (SampleCsRhinoHelpers.ConvertToPoint3dList(pointsObj, ref points)) { - var doc = RhinoDoc.ActiveDoc; + RhinoDoc doc = RhinoDoc.ActiveDoc; if (null != doc) { - var object_ids = new ArrayList(); - for (var i = 0; i < points.Count(); i++) + ArrayList object_ids = new ArrayList(); + for (int i = 0; i < points.Count(); i++) { - var object_id = doc.Objects.AddPoint(points[i]); + System.Guid object_id = doc.Objects.AddPoint(points[i]); if (!object_id.Equals(System.Guid.Empty)) object_ids.Add(object_id.ToString()); } @@ -121,7 +121,7 @@ public object AddPoints(object pointsObj) public bool RunScript(string script, bool echo) { script = script.TrimStart('!'); - var rc = RhinoApp.RunScript(script, echo); + bool rc = RhinoApp.RunScript(script, echo); return rc; } } diff --git a/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoPlugIn.cs b/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoPlugIn.cs index 7055c1e4..3d8326d2 100644 --- a/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoPlugIn.cs +++ b/rhinocommon/cs/SampleCsAutomation/SampleCsRhino/SampleCsRhinoPlugIn.cs @@ -1,6 +1,6 @@ -using System.Reflection; -using Rhino; +using Rhino; using Rhino.PlugIns; +using System.Reflection; namespace SampleCsRhino { @@ -31,8 +31,8 @@ public static SampleCsRhinoPlugIn Instance /// protected override LoadReturnCode OnLoad(ref string errorMessage) { - var app_name = Assembly.GetExecutingAssembly().GetName().Name; - var app_version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + string app_name = Assembly.GetExecutingAssembly().GetName().Name; + string app_version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); RhinoApp.WriteLine("{0} {1} loaded.", app_name, app_version); return LoadReturnCode.Success; } @@ -43,7 +43,7 @@ protected override LoadReturnCode OnLoad(ref string errorMessage) /// public override object GetPlugInObject() { - var rhino_obj = new SampleCsRhinoObject(); + SampleCsRhinoObject rhino_obj = new SampleCsRhinoObject(); return rhino_obj; } } diff --git a/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/CollapsibleSectionUICommand.cs b/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/CollapsibleSectionUICommand.cs index cd7c3615..5ebd8128 100644 --- a/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/CollapsibleSectionUICommand.cs +++ b/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/CollapsibleSectionUICommand.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; -using Rhino.Geometry; -using Rhino.Input; -using Rhino.Input.Custom; namespace Project { diff --git a/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/CollapsibleSectionUIPanel.cs b/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/CollapsibleSectionUIPanel.cs index bf669e67..7fe5e0ba 100644 --- a/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/CollapsibleSectionUIPanel.cs +++ b/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/CollapsibleSectionUIPanel.cs @@ -1,8 +1,5 @@ -using System; -using Rhino; -using Rhino.Commands; +using Eto.Forms; using Rhino.UI.Controls; -using Eto.Forms; namespace Project { diff --git a/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/Properties/AssemblyInfo.cs index 9cd6fc2c..31b68d7f 100644 --- a/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/SectionOne.cs b/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/SectionOne.cs index 29a00e51..c3ed4a05 100644 --- a/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/SectionOne.cs +++ b/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/SectionOne.cs @@ -1,6 +1,6 @@ -using System; -using Eto.Forms; +using Eto.Forms; using Rhino.UI; +using System; namespace Project { diff --git a/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/SectionTwo.cs b/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/SectionTwo.cs index 848b95fe..daa45b41 100644 --- a/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/SectionTwo.cs +++ b/rhinocommon/cs/SampleCsCollapsibleSectionETO_UI/SectionTwo.cs @@ -1,6 +1,6 @@ -using System; -using Eto.Forms; +using Eto.Forms; using Rhino.UI; +using System; namespace Project { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCSParseTextFields.cs b/rhinocommon/cs/SampleCsCommands/SampleCSParseTextFields.cs index 402a137d..8c147547 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCSParseTextFields.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCSParseTextFields.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Input.Custom; @@ -26,9 +25,9 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - + //Select some objects to add attribute user text to - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects"); go.GroupSelect = true; go.GetMultiple(1, 0); @@ -37,14 +36,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) //Apply the ObjectName textfield as the user text value to the selected objects - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var obj_ref = go.Object(i); - var obj = obj_ref.Object(); + Rhino.DocObjects.ObjRef obj_ref = go.Object(i); + Rhino.DocObjects.RhinoObject obj = obj_ref.Object(); if (null != obj) { //Create an ObjectName TextField and apply it as the value of the user text - var fx = $"%%"; + string fx = $"%%"; obj.Attributes.SetUserString("ObjectName", fx); } } @@ -52,15 +51,15 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) //Now retrieve the values we just set and parse them - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var obj_ref = go.Object(i); - var obj = obj_ref.Object(); + Rhino.DocObjects.ObjRef obj_ref = go.Object(i); + Rhino.DocObjects.RhinoObject obj = obj_ref.Object(); if (null == obj) continue; //Read user text value and parse it as a textfield - var user_string_value = obj.Attributes.GetUserString("ObjectName"); + string user_string_value = obj.Attributes.GetUserString("ObjectName"); if (!string.IsNullOrEmpty(user_string_value)) { if (user_string_value.StartsWith("%<") && user_string_value.EndsWith(">%")) @@ -68,15 +67,15 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) //RhinoApp.ParseTextField will try to automatically parse any string that looks like a valid textfield containing //a formula. %% for example and return the results. //The parent object parameter is required only for page objects such as detail object viewport info. - var parsed_string = RhinoApp.ParseTextField(user_string_value, obj_ref.Object(), null); + string parsed_string = RhinoApp.ParseTextField(user_string_value, obj_ref.Object(), null); RhinoApp.WriteLine($"Parsed TextField: {parsed_string}"); } } //Direct method call to TextField ObjectName Example //You can also call the ObjectName and other TextField functions directly instead of using ParseTextField should you wish to do so. - var direct_string = Rhino.Runtime.TextFields.ObjectName(obj_ref.ObjectId.ToString()); - var direct_area = Rhino.Runtime.TextFields.Area(obj_ref.ObjectId.ToString(), UnitSystem.Millimeters.ToString()); + string direct_string = Rhino.Runtime.TextFields.ObjectName(obj_ref.ObjectId.ToString()); + double direct_area = Rhino.Runtime.TextFields.Area(obj_ref.ObjectId.ToString(), UnitSystem.Millimeters.ToString()); RhinoApp.WriteLine($"Direct ObjectName call: {direct_string}"); RhinoApp.WriteLine($"Direct Area call: {direct_area}"); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCSQuadRemesh.cs b/rhinocommon/cs/SampleCsCommands/SampleCSQuadRemesh.cs index 3af9f232..a13c2a6e 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCSQuadRemesh.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCSQuadRemesh.cs @@ -29,7 +29,7 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { //Select some object - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select object to remesh"); go.GeometryFilter = ObjectType.Brep | ObjectType.Mesh; go.Get(); @@ -38,11 +38,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Cancel; //Grab the results of the object picker. - var rhino_object = go.Object(0).Object(); + RhinoObject rhino_object = go.Object(0).Object(); //Set our desired quad remesh parameters - var quad_remesh_parameters = new QuadRemeshParameters() + QuadRemeshParameters quad_remesh_parameters = new QuadRemeshParameters() { TargetQuadCount = 2000, AdaptiveQuadCount = true, @@ -62,7 +62,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) //Optionally this method also accepts an IEnumerable overload. //Pass it your curve object array/list if you want guide curves) //If guide curves, lastly change your quad_remesh_parameters.GuideCurveInfluence if using curves - var remeshed = Mesh.QuadRemeshBrep(brep, quad_remesh_parameters); + Mesh remeshed = Mesh.QuadRemeshBrep(brep, quad_remesh_parameters); if (remeshed == null) return Result.Cancel; @@ -73,7 +73,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) RhinoApp.WriteLine("1 Brep successfully remeshed"); } //Remesh a selected Mesh - else if(rhino_object.ObjectType == ObjectType.Mesh) + else if (rhino_object.ObjectType == ObjectType.Mesh) { if (!(rhino_object is MeshObject mesh_object)) return Result.Cancel; @@ -83,7 +83,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Cancel; //Do the remeshing of the Mesh Objects Mesh Geometry - var remeshed = mesh_object.MeshGeometry.QuadRemesh(quad_remesh_parameters); + Mesh remeshed = mesh_object.MeshGeometry.QuadRemesh(quad_remesh_parameters); if (remeshed == null) return Result.Cancel; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCSRibbonOffsetCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCSRibbonOffsetCurve.cs index f7986ac7..0f18e2de 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCSRibbonOffsetCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCSRibbonOffsetCurve.cs @@ -29,7 +29,7 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { //Get a closed curve to offset - var go = new GetObject + GetObject go = new GetObject { GeometryFilter = ObjectType.Curve, GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve @@ -42,12 +42,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Cancel; //Get the curve from the GetObject - var crv = go.Object(0).Curve(); + Curve crv = go.Object(0).Curve(); if (crv == null) return Result.Cancel; //Get the side of the curve to offset towards. - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Select curve side to offset"); gp.Get(); @@ -55,7 +55,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gp.Result() != GetResult.Point) return Result.Cancel; //The selected Point - var pt = gp.Point(); + Point3d pt = gp.Point(); //Try to get the plane from the curve crv.TryGetPlane(out Plane ribbon_plane); @@ -63,10 +63,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) ribbon_plane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane(); //Set the ribbon plane vector - var plane_vector = ribbon_plane.Normal; + Vector3d plane_vector = ribbon_plane.Normal; //Create the ribbon offset, its cross sections, and its ruled surfaces - var ribbon_curve_output = crv.RibbonOffset(1, .1, pt, plane_vector, doc.ModelAbsoluteTolerance,out Curve[] cross_sections, out Surface[] ruled_surfaces); + Curve ribbon_curve_output = crv.RibbonOffset(1, .1, pt, plane_vector, doc.ModelAbsoluteTolerance, out Curve[] cross_sections, out Surface[] ruled_surfaces); //Add the ribbon curve to the document if (ribbon_curve_output != null) @@ -77,7 +77,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) //Add any cross section curves to the document if (cross_sections != null) { - foreach (var curve in cross_sections) + foreach (Curve curve in cross_sections) { doc.Objects.AddCurve(curve); } @@ -86,7 +86,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) //Add any ruled surfaces to the document if (ruled_surfaces != null) { - foreach (var surface in ruled_surfaces) + foreach (Surface surface in ruled_surfaces) { doc.Objects.AddSurface(surface); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCSSilhouetteDraftCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCSSilhouetteDraftCurve.cs index b76c100d..96a4f8e4 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCSSilhouetteDraftCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCSSilhouetteDraftCurve.cs @@ -1,11 +1,10 @@ -using System; -using System.Drawing; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System.Drawing; namespace SampleCsCommands { @@ -32,14 +31,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { //Select a brep or mesh to extract some curves from - var go = new GetObject() {GeometryFilter = ObjectType.Brep | ObjectType.Mesh}; + GetObject go = new GetObject() { GeometryFilter = ObjectType.Brep | ObjectType.Mesh }; go.SetCommandPrompt("Select object for draft curve extraction"); go.Get(); if (go.Result() != GetResult.Object) return Result.Cancel; //The selected geometry base - var geometry = go.Object(0).Geometry(); + GeometryBase geometry = go.Object(0).Geometry(); //Min & Max angle must be specified in Radians @@ -54,20 +53,20 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) double angle_tolerance = doc.ModelAngleToleranceRadians; //Compute the minimum draft angle curves - var min_draft_silhouettes = Silhouette.ComputeDraftCurve(geometry, min_angle, direction, tolerance,angle_tolerance); + Silhouette[] min_draft_silhouettes = Silhouette.ComputeDraftCurve(geometry, min_angle, direction, tolerance, angle_tolerance); //Compute the maximum draft angle curves - var max_draft_silhouettes = Silhouette.ComputeDraftCurve(geometry, max_angle, direction, tolerance, angle_tolerance); - + Silhouette[] max_draft_silhouettes = Silhouette.ComputeDraftCurve(geometry, max_angle, direction, tolerance, angle_tolerance); + //Add all of the minimum draft angle silhouette curves to the doc if (min_draft_silhouettes != null) { - var oa = new ObjectAttributes(){ObjectColor = Color.Red,ColorSource = ObjectColorSource.ColorFromObject}; - foreach (var silhouette in min_draft_silhouettes) + ObjectAttributes oa = new ObjectAttributes() { ObjectColor = Color.Red, ColorSource = ObjectColorSource.ColorFromObject }; + foreach (Silhouette silhouette in min_draft_silhouettes) { - var crv = silhouette.Curve; - doc.Objects.AddCurve(crv,oa); + Curve crv = silhouette.Curve; + doc.Objects.AddCurve(crv, oa); } } @@ -75,11 +74,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) //Add all of the maximum draft angle silhouette curves to the doc if (max_draft_silhouettes != null) { - var oa = new ObjectAttributes(){ObjectColor = Color.Blue, ColorSource = ObjectColorSource.ColorFromObject }; - foreach (var silhouette in max_draft_silhouettes) + ObjectAttributes oa = new ObjectAttributes() { ObjectColor = Color.Blue, ColorSource = ObjectColorSource.ColorFromObject }; + foreach (Silhouette silhouette in max_draft_silhouettes) { - var crv = silhouette.Curve; - doc.Objects.AddCurve(crv,oa); + Curve crv = silhouette.Curve; + doc.Objects.AddCurve(crv, oa); } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAddAlignedDimension.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAddAlignedDimension.cs index 5b9c109e..1bdda40a 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAddAlignedDimension.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAddAlignedDimension.cs @@ -10,25 +10,25 @@ public class SampleCsAddAlignedDimension : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var style = doc.DimStyles.Current; - var plane = Plane.WorldXY; + Rhino.DocObjects.DimensionStyle style = doc.DimStyles.Current; + Plane plane = Plane.WorldXY; - var p1 = new Point3d(1.0, 1.0, 0.0); - var p2 = new Point3d(5.0, 2.0, 0.0); - var pl = new Point3d(5.0, 4.0, 0.0); + Point3d p1 = new Point3d(1.0, 1.0, 0.0); + Point3d p2 = new Point3d(5.0, 2.0, 0.0); + Point3d pl = new Point3d(5.0, 4.0, 0.0); - var xaxis = p2 - p1; - var yaxis = pl - p1; + Vector3d xaxis = p2 - p1; + Vector3d yaxis = pl - p1; if (xaxis.Unitize() && yaxis.Unitize()) { - var zaxis = Vector3d.CrossProduct(xaxis, yaxis); + Vector3d zaxis = Vector3d.CrossProduct(xaxis, yaxis); if (zaxis.Unitize()) { plane = new Plane(p1, xaxis, yaxis); } } - var dim = LinearDimension.Create(AnnotationType.Aligned, style, plane, Plane.WorldXY.XAxis, p1, p2, pl, 0.0); + LinearDimension dim = LinearDimension.Create(AnnotationType.Aligned, style, plane, Plane.WorldXY.XAxis, p1, p2, pl, 0.0); //string displaytext = dim.GetDistanceDisplayText(doc.ModelUnitSystem, style); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCircle.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCircle.cs index bc1c0b8c..0b03287f 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCircle.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCircle.cs @@ -1,7 +1,7 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; +using System; namespace SampleCsCommands { @@ -13,8 +13,8 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { const int order = 3; // order = degree + 1 const int cv_count = 9; - - var curve = new NurbsCurve(3, true, order, cv_count); + + NurbsCurve curve = new NurbsCurve(3, true, order, cv_count); curve.Points.SetPoint(0, 1.0, 0.0, 0.0, 1.0); curve.Points.SetPoint(1, 0.707107, 0.707107, 0.0, 0.707107); @@ -36,17 +36,17 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) curve.Knots[7] = 1.5 * Math.PI; curve.Knots[8] = 2.0 * Math.PI; curve.Knots[9] = 2.0 * Math.PI; - + if (curve.IsValid) { - var length = curve.GetLength(); - var domain = new Interval(0.0, length); + double length = curve.GetLength(); + Interval domain = new Interval(0.0, length); curve.Domain = domain; doc.Objects.AddCurve(curve); doc.Views.Redraw(); - } - + } + return Result.Success; } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs index 1d420d7b..86a90416 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsCurve.cs @@ -20,7 +20,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) const int knot_count = cv_count + degree - 1; // Define the "Euclidean" (world 3-D) locations for the control points. - var cvs = new Point3d[cv_count]; + Point3d[] cvs = new Point3d[cv_count]; cvs[0] = new Point3d(0.0, 0.0, 0.0); cvs[1] = new Point3d(5.0, 10.0, 0.0); cvs[2] = new Point3d(10.0, 0.0, 0.0); @@ -34,7 +34,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // In this example the first three knots are 0 and the last three knots are 3. // The interior knots can have multiplicity from 1 (a "simple" knot) // to degree (a "full multiplicity") - var knots = new double[knot_count]; + double[] knots = new double[knot_count]; // Start with a full multiplicity knot knots[0] = 0.0; knots[1] = 0.0; @@ -49,7 +49,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) knots[7] = 3.0; // Create a non-rational NURBS curve - var curve = new NurbsCurve(3, false, order, cv_count); + NurbsCurve curve = new NurbsCurve(3, false, order, cv_count); // Set the control points for (int i = 0; i < cv_count; i++) @@ -62,14 +62,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (curve.IsValid) { // Parameterization should match the length of a curve - var length = curve.GetLength(); - var domain = new Interval(0.0, length); + double length = curve.GetLength(); + Interval domain = new Interval(0.0, length); curve.Domain = domain; doc.Objects.AddCurve(curve); doc.Views.Redraw(); - } - + } + return Result.Success; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsSurface.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsSurface.cs index 5bc40ae5..8353dd6d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsSurface.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAddNurbsSurface.cs @@ -16,7 +16,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) const int v_degree = 3; const int u_cv_count = 3; const int v_cv_count = 5; - + int i; int j; @@ -24,8 +24,8 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // at the start and end of the knot vector. If you are // coming from a system that has the 2 superfluous knots, // just ignore them when creating NURBS surfaces. - var u_knot = new double[u_cv_count + u_degree - 1]; - var v_knot = new double[v_cv_count + v_degree - 1]; + double[] u_knot = new double[u_cv_count + u_degree - 1]; + double[] v_knot = new double[v_cv_count + v_degree - 1]; // make up a quadratic knot vector with no interior knots u_knot[0] = u_knot[1] = 0.0; @@ -39,14 +39,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Rational control points can be in either homogeneous // or euclidean form. Non-rational control points do not // need to specify a weight. - var cv = new Point3d[u_cv_count, v_cv_count]; + Point3d[,] cv = new Point3d[u_cv_count, v_cv_count]; for (i = 0; i < u_cv_count; i++) { for (j = 0; j < v_cv_count; j++) - cv[i, j] = new Point3d {X = i, Y = j, Z = i - j}; + cv[i, j] = new Point3d { X = i, Y = j, Z = i - j }; } - var nurbs_surface = NurbsSurface.Create(dim, rational, u_degree + 1, v_degree + 1, u_cv_count, v_cv_count); + NurbsSurface nurbs_surface = NurbsSurface.Create(dim, rational, u_degree + 1, v_degree + 1, u_cv_count, v_cv_count); for (i = 0; i < nurbs_surface.KnotsU.Count; i++) nurbs_surface.KnotsU[i] = u_knot[i]; @@ -60,7 +60,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) nurbs_surface.Points.SetPoint(i, j, cv[i, j]); } - var rc = Result.Failure; + Result rc = Result.Failure; if (nurbs_surface.IsValid) { doc.Objects.AddSurface(nurbs_surface); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAddRadialDimension.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAddRadialDimension.cs index f3be4c52..53f3acf2 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAddRadialDimension.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAddRadialDimension.cs @@ -11,17 +11,17 @@ public class SampleCsAddRadialDimension : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var plane = Plane.WorldXY; + Plane plane = Plane.WorldXY; - var cp = new Point3d(2.0, 2.0, 0.0); - var p1 = new Point3d(4.0, 4.0, 0.0); - var p2 = new Point3d(8.0, 6.0, 0.0); + Point3d cp = new Point3d(2.0, 2.0, 0.0); + Point3d p1 = new Point3d(4.0, 4.0, 0.0); + Point3d p2 = new Point3d(8.0, 6.0, 0.0); - var style = doc.DimStyles.Current; + DimensionStyle style = doc.DimStyles.Current; if (style.LeaderContentAngleType == DimensionStyle.LeaderContentAngleStyle.Aligned) p2.Y = 8.0; - var dim = RadialDimension.Create(style, AnnotationType.Radius, plane, cp, p1, p2); + RadialDimension dim = RadialDimension.Create(style, AnnotationType.Radius, plane, cp, p1, p2); if (null != dim) { doc.Objects.Add(dim); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAddRdkMaterials.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAddRdkMaterials.cs index 43d85785..25713d6e 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAddRdkMaterials.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAddRdkMaterials.cs @@ -1,9 +1,9 @@ -using System.Drawing; using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Render; +using System.Drawing; namespace SampleCsCommands { @@ -27,14 +27,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // basic material because it does not target any particular rendering plug-in. // 1. Create a Rhino material. - var rhino_material = new Material + Material rhino_material = new Material { Name = "Burly", DiffuseColor = Color.BurlyWood }; // 2. Create a basic Render material from the Rhino material. - var render_material = RenderMaterial.CreateBasicMaterial(rhino_material, doc); + RenderMaterial render_material = RenderMaterial.CreateBasicMaterial(rhino_material, doc); // 3. Add the basic Render material to the document. doc.RenderMaterials.Add(render_material); @@ -50,8 +50,8 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // However, this is no longer recommended because Render materials should always be used. // 4. Now create a sphere with the Render material assigned to it. - var sphere = new Sphere(Plane.WorldXY, 5); - var attr = new ObjectAttributes { RenderMaterial = render_material }; + Sphere sphere = new Sphere(Plane.WorldXY, 5); + ObjectAttributes attr = new ObjectAttributes { RenderMaterial = render_material }; doc.Objects.AddSphere(sphere, attr); doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAddTextDot.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAddTextDot.cs index 8956322c..d65d85e6 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAddTextDot.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAddTextDot.cs @@ -1,9 +1,9 @@ -using System.Globalization; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System.Globalization; namespace SampleCsCommands { @@ -13,21 +13,21 @@ public class SampleCsAddTextDot : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var count = 0; + int count = 0; - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.AcceptNothing(true); for (; ; ) { gp.SetCommandPrompt(0 == count ? "Location of text dot" : "Location of text dot. Press Enter when done"); - var res = gp.Get(); + GetResult res = gp.Get(); if (res == GetResult.Point) { - var point = gp.Point(); - var str = count.ToString(CultureInfo.InvariantCulture); - var dot = new TextDot(str, point); + Point3d point = gp.Point(); + string str = count.ToString(CultureInfo.InvariantCulture); + TextDot dot = new TextDot(str, point); doc.Objects.Add(dot); doc.Views.Redraw(); count++; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAlignProfiles.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAlignProfiles.cs index c66eaaa4..3d50fc09 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAlignProfiles.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAlignProfiles.cs @@ -12,13 +12,13 @@ public class SampleCsAlignProfiles : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var curve_objs = new CurveObject[2]; - var boxes = new BoundingBox[2]; - var rects = new Rectangle3d[2]; + CurveObject[] curve_objs = new CurveObject[2]; + BoundingBox[] boxes = new BoundingBox[2]; + Rectangle3d[] rects = new Rectangle3d[2]; - for (var i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) { - var go = new GetObject { GeometryFilter = ObjectType.Curve, SubObjectSelect = false }; + GetObject go = new GetObject { GeometryFilter = ObjectType.Curve, SubObjectSelect = false }; if (i == 0) { go.SetCommandPrompt("Select curve to align to"); @@ -36,14 +36,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (!(go.Object(0).Object() is CurveObject curve_obj)) return Result.Failure; - var rc = RhinoObject.GetTightBoundingBox(new [] { curve_obj }, out var box); + bool rc = RhinoObject.GetTightBoundingBox(new[] { curve_obj }, out BoundingBox box); if (!rc || !box.IsValid) { RhinoApp.WriteLine("Cannot calculate bounding box."); return Result.Failure; } - rc = IsBoundingBoxRectangle(box, doc.ModelAbsoluteTolerance, out var rect); + rc = IsBoundingBoxRectangle(box, doc.ModelAbsoluteTolerance, out Rectangle3d rect); if (!rc) { RhinoApp.WriteLine("Profile is not planar in world coordinates."); @@ -88,20 +88,20 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Failure; } - var plane = new Plane(rects[0].Plane.Origin, shared_axis); - var dist = plane.DistanceTo(rects[1].Plane.Origin); - var trans = new Vector3d(shared_axis); + Plane plane = new Plane(rects[0].Plane.Origin, shared_axis); + double dist = plane.DistanceTo(rects[1].Plane.Origin); + Vector3d trans = new Vector3d(shared_axis); trans *= -dist; - var A = Transform.Translation(trans); + Transform A = Transform.Translation(trans); - var scale_factor = 1.0; + double scale_factor = 1.0; if (target_width != 0) scale_factor = source_width / target_width; - var B = Transform.Scale(rects[1].Plane.Origin, scale_factor); + Transform B = Transform.Scale(rects[1].Plane.Origin, scale_factor); - var xform = A * B; + Transform xform = A * B; doc.Objects.Transform(curve_objs[1].Id, xform, true); doc.Objects.UnselectAll(); @@ -117,27 +117,27 @@ private bool IsBoundingBoxRectangle(BoundingBox box, double tolerance, out Recta if (box.IsDegenerate(tolerance) != 1) return false; - var origin = box.Min; + Point3d origin = box.Min; if (IsBoundingBoxDegenerateX(box, tolerance)) { - var plane = new Plane(origin, Vector3d.YAxis, Vector3d.ZAxis); - var width = box.Max.Y - box.Min.Y; - var height = box.Max.Z - box.Min.Z; + Plane plane = new Plane(origin, Vector3d.YAxis, Vector3d.ZAxis); + double width = box.Max.Y - box.Min.Y; + double height = box.Max.Z - box.Min.Z; rect = new Rectangle3d(plane, width, height); } else if (IsBoundingBoxDegenerateY(box, tolerance)) { - var plane = new Plane(origin, Vector3d.XAxis, Vector3d.ZAxis); - var width = box.Max.X - box.Min.X; - var height = box.Max.Z - box.Min.Z; + Plane plane = new Plane(origin, Vector3d.XAxis, Vector3d.ZAxis); + double width = box.Max.X - box.Min.X; + double height = box.Max.Z - box.Min.Z; rect = new Rectangle3d(plane, width, height); } else if (IsBoundingBoxDegenerateZ(box, tolerance)) { - var plane = new Plane(origin, Vector3d.XAxis, Vector3d.YAxis); - var width = box.Max.X - box.Min.X; - var height = box.Max.Y - box.Min.Y; + Plane plane = new Plane(origin, Vector3d.XAxis, Vector3d.YAxis); + double width = box.Max.X - box.Min.X; + double height = box.Max.Y - box.Min.Y; rect = new Rectangle3d(plane, width, height); } return rect.IsValid; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAppearanceColors.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAppearanceColors.cs index 8df23fc2..ce5938a3 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAppearanceColors.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAppearanceColors.cs @@ -1,7 +1,7 @@ -using System.Drawing; -using Rhino; +using Rhino; using Rhino.ApplicationSettings; using Rhino.Commands; +using System.Drawing; namespace SampleCsCommands { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsApplyCrv.cs b/rhinocommon/cs/SampleCsCommands/SampleCsApplyCrv.cs index f4c1668f..e1679860 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsApplyCrv.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsApplyCrv.cs @@ -1,11 +1,9 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; -using Rhino.UI.Controls; +using System.Collections.Generic; namespace SampleCsCommands { @@ -15,7 +13,7 @@ public class SampleCsApplyCrv : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var gc = new GetObject(); + GetObject gc = new GetObject(); gc.SetCommandPrompt("Select curves on world XY plane to apply to a surface"); gc.GeometryFilter = ObjectType.Curve; gc.EnablePreSelect(true, true); @@ -23,13 +21,13 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gc.CommandResult() != Result.Success) return gc.CommandResult(); - var tol = doc.ModelAbsoluteTolerance; - var bbox = new BoundingBox(); + double tol = doc.ModelAbsoluteTolerance; + BoundingBox bbox = new BoundingBox(); - var input_curves = new List(gc.ObjectCount); - foreach (var curve_ref in gc.Objects()) + List input_curves = new List(gc.ObjectCount); + foreach (ObjRef curve_ref in gc.Objects()) { - var curve = curve_ref.Curve(); + Curve curve = curve_ref.Curve(); if (null == curve) continue; if (!curve.IsValid) @@ -45,7 +43,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (0 == input_curves.Count) return Result.Failure; - var gs = new GetObject(); + GetObject gs = new GetObject(); gs.SetCommandPrompt("Select surface to apply the planar curves to"); gs.GeometryFilter = ObjectType.Surface; gs.EnablePreSelect(false, true); @@ -54,27 +52,27 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gs.CommandResult() != Result.Success) return gs.CommandResult(); - var brep_face = gs.Object(0).Face(); - var surface = brep_face?.UnderlyingSurface(); + BrepFace brep_face = gs.Object(0).Face(); + Surface surface = brep_face?.UnderlyingSurface(); if (surface == null) return Result.Failure; - var srf_u_domain = surface.Domain(0); - var srf_v_domain = surface.Domain(1); - var srf_u_extent = srf_u_domain.Max - srf_u_domain.Min; - var srf_v_extent = srf_v_domain.Max - srf_v_domain.Min; + Interval srf_u_domain = surface.Domain(0); + Interval srf_v_domain = surface.Domain(1); + double srf_u_extent = srf_u_domain.Max - srf_u_domain.Min; + double srf_v_extent = srf_v_domain.Max - srf_v_domain.Min; - var bbox_x_domain = new Interval(bbox.Min.X, bbox.Max.X); - var bbox_y_domain = new Interval(bbox.Min.Y, bbox.Max.Y); - var bbox_x_extent = bbox_x_domain.Max - bbox_x_domain.Min; - var bbox_y_extent = bbox_y_domain.Max - bbox_y_domain.Min; + Interval bbox_x_domain = new Interval(bbox.Min.X, bbox.Max.X); + Interval bbox_y_domain = new Interval(bbox.Min.Y, bbox.Max.Y); + double bbox_x_extent = bbox_x_domain.Max - bbox_x_domain.Min; + double bbox_y_extent = bbox_y_domain.Max - bbox_y_domain.Min; if (bbox_x_extent <= 0.0 || bbox_y_extent <= 0.0) return Result.Failure; - var scale0 = srf_u_extent / bbox_x_extent; - var scale1 = srf_v_extent / bbox_y_extent; + double scale0 = srf_u_extent / bbox_x_extent; + double scale1 = srf_v_extent / bbox_y_extent; - var xform = new Transform + Transform xform = new Transform { M00 = scale0, M11 = scale1, @@ -84,13 +82,13 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) M13 = srf_v_domain.Min - bbox_y_domain.Min * scale1 }; - foreach (var curve in input_curves) + foreach (Curve curve in input_curves) { - var curve2d = curve.DuplicateCurve(); + Curve curve2d = curve.DuplicateCurve(); if (null != curve2d) { curve2d.Transform(xform); - var curve3d = surface.Pushup(curve2d, tol); + Curve curve3d = surface.Pushup(curve2d, tol); if (null != curve3d) doc.Objects.AddCurve(curve3d); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsArc.cs b/rhinocommon/cs/SampleCsCommands/SampleCsArc.cs index d26c2bb7..bfbb7c21 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsArc.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsArc.cs @@ -1,8 +1,8 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -102,12 +102,12 @@ protected override void OnDynamicDraw(GetPointDrawEventArgs e) e.Display.DrawPoint(m_arc.Center); } - var relative_length = 1.5; - var v1 = m_args.Point2 - m_args.Point1; - var v2 = m_args.Point3 - m_args.Point1; - var v3 = e.CurrentPoint - m_args.Point1; - var length1 = v1.Length * relative_length; - var length3 = v3.Length; + double relative_length = 1.5; + Vector3d v1 = m_args.Point2 - m_args.Point1; + Vector3d v2 = m_args.Point3 - m_args.Point1; + Vector3d v3 = e.CurrentPoint - m_args.Point1; + double length1 = v1.Length * relative_length; + double length3 = v3.Length; v2.Unitize(); v1 *= relative_length; if (length1 > length3) @@ -131,16 +131,16 @@ public static bool CalculateArc(ArcArguments args, out Arc arc) { arc = new Arc(); - var x = args.Point2 - args.Point1; - var y = args.Point3 - args.Point1; + Vector3d x = args.Point2 - args.Point1; + Vector3d y = args.Point3 - args.Point1; if (x.IsTiny() || y.IsTiny()) return false; - var radius = x.Length; - var quadrant = args.Quadrant; - var dir = args.Dir; + double radius = x.Length; + int quadrant = args.Quadrant; + int dir = args.Dir; - var new_quadrant = WhichQuadrant(args.Point1, args.Point2, args.Point3, args.Normal); + int new_quadrant = WhichQuadrant(args.Point1, args.Point2, args.Point3, args.Normal); if (quadrant == 0) dir = (new_quadrant < 3) ? 1 : -1; // unspecified previous quadrant else if ((quadrant == 1 && new_quadrant == 4 && dir == 1) || (quadrant == 4 && new_quadrant == 1 && dir == -1)) @@ -150,16 +150,16 @@ public static bool CalculateArc(ArcArguments args, out Arc arc) x.Unitize(); y.Unitize(); - var dot = x * y; + double dot = x * y; dot = RhinoMath.Clamp(dot, -1.0, 1.0); - var angle = Math.Acos(dot); + double angle = Math.Acos(dot); if (dir > 0) y = Vector3d.CrossProduct(args.Normal, x); else y = Vector3d.CrossProduct(-args.Normal, x); - var plane = new Plane(args.Point1, x, y); + Plane plane = new Plane(args.Point1, x, y); if (!plane.IsValid) return false; @@ -167,7 +167,7 @@ public static bool CalculateArc(ArcArguments args, out Arc arc) angle = 2.0 * Math.PI - angle; arc = new Arc(plane, args.Point1, radius, angle); - var rc = arc.IsValid; + bool rc = arc.IsValid; if (rc) { args.Quadrant = quadrant; @@ -183,11 +183,11 @@ public static bool CalculateArc(ArcArguments args, out Arc arc) /// private static int WhichQuadrant(Point3d point1, Point3d point2, Point3d point3, Vector3d normal) { - var x = point2 - point1; - var r = point3 - point1; - var y = Vector3d.CrossProduct(normal, x); - var dotX = x * r; - var dotY = y * r; + Vector3d x = point2 - point1; + Vector3d r = point3 - point1; + Vector3d y = Vector3d.CrossProduct(normal, x); + double dotX = x * r; + double dotY = y * r; if (dotX >= 0.0) return (dotY >= 0.0) ? 1 : 4; else @@ -207,10 +207,10 @@ public class SampleCsArc : Command /// protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var args = new ArcArguments(); + ArcArguments args = new ArcArguments(); // Center of arc - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Center of arc"); gp.Get(); if (gp.CommandResult() != Result.Success) @@ -229,12 +229,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) args.Point2 = gp.Point(); - var arc_plane = gp.View().ActiveViewport.ConstructionPlane(); + Plane arc_plane = gp.View().ActiveViewport.ConstructionPlane(); arc_plane.Origin = args.Point1; args.Normal = arc_plane.ZAxis; // End of arc - var gp3 = new GetThirdArcPoint(args); + GetThirdArcPoint gp3 = new GetThirdArcPoint(args); gp3.SetCommandPrompt("End of arc"); gp3.Constrain(arc_plane, false); gp3.ConstrainDistanceFromBasePoint(args.Point1.DistanceTo(args.Point2)); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsArray.cs b/rhinocommon/cs/SampleCsCommands/SampleCsArray.cs index 44a9d902..80c687e3 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsArray.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsArray.cs @@ -1,8 +1,8 @@ -using System; +using Rhino; +using Rhino.Commands; +using System; using System.Collections.Generic; using System.Linq; -using Rhino; -using Rhino.Commands; namespace SampleCsCommands { @@ -65,7 +65,7 @@ public void ValidateOffsets() public void ResetOffsets() { ValidateOffsets(); - for (var i = 0; i < Offsets.Count; i++) + for (int i = 0; i < Offsets.Count; i++) Offsets[i] = Rhino.Geometry.Vector3d.Zero; } @@ -144,7 +144,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) args.CalculateOffsets(); // Array the unit Brep box - for (var i = 0; i < args.Offsets.Count; i++) + for (int i = 0; i < args.Offsets.Count; i++) { // Skip the first one... if (!args.Offsets[i].IsZero) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsAutomateGrasshopper.cs b/rhinocommon/cs/SampleCsCommands/SampleCsAutomateGrasshopper.cs index 342c22ca..2928915c 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsAutomateGrasshopper.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsAutomateGrasshopper.cs @@ -1,9 +1,9 @@ -using System; +using Rhino; +using Rhino.Commands; +using System; using System.IO; using System.Reflection; using System.Windows.Forms; -using Rhino; -using Rhino.Commands; namespace SampleCsCommands { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsBlock.cs b/rhinocommon/cs/SampleCsCommands/SampleCsBlock.cs index a7ebf4cd..9cd4d416 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsBlock.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsBlock.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -15,15 +15,15 @@ public class SampleCsBlock : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Select objects to define block - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects to define block"); go.ReferenceObjectSelect = false; go.SubObjectSelect = false; go.GroupSelect = true; // Phantoms, grips, lights, etc., cannot be in blocks. - var forbidden_geometry_filter = ObjectType.Light | ObjectType.Grip | ObjectType.Phantom; - var geometry_filter = forbidden_geometry_filter ^ ObjectType.AnyObject; + ObjectType forbidden_geometry_filter = ObjectType.Light | ObjectType.Grip | ObjectType.Phantom; + ObjectType geometry_filter = forbidden_geometry_filter ^ ObjectType.AnyObject; go.GeometryFilter = geometry_filter; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) @@ -31,7 +31,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Block base point Point3d base_point; - var rc = RhinoGet.GetPoint("Block base point", false, out base_point); + Result rc = RhinoGet.GetPoint("Block base point", false, out base_point); if (rc != Result.Success) return rc; @@ -55,11 +55,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } // Gather all of the selected objects - var geometry = new List(); - var attributes = new List(); + List geometry = new List(); + List attributes = new List(); for (int i = 0; i < go.ObjectCount; i++) { - var rh_object = go.Object(i).Object(); + RhinoObject rh_object = go.Object(i).Object(); if (rh_object != null) { geometry.Add(rh_object.Geometry); @@ -68,7 +68,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } // Gather all of the selected objects - var idef_index = doc.InstanceDefinitions.Add(idef_name, string.Empty, base_point, geometry, attributes); + int idef_index = doc.InstanceDefinitions.Add(idef_name, string.Empty, base_point, geometry, attributes); if (idef_index < 0) { RhinoApp.WriteLine("Unable to create block definition", idef_name); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference2.cs b/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference2.cs index f99af78d..767af946 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference2.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference2.cs @@ -12,7 +12,7 @@ public class SampleCsBooleanDifference2 : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go0 = new GetObject(); + GetObject go0 = new GetObject(); go0.SetCommandPrompt("Select surface or polysurface to subtract from"); go0.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go0.SubObjectSelect = false; @@ -20,11 +20,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go0.CommandResult() != Result.Success) return go0.CommandResult(); - var brep0 = go0.Object(0).Brep(); + Brep brep0 = go0.Object(0).Brep(); if (null == brep0) return Result.Failure; - var go1 = new GetObject(); + GetObject go1 = new GetObject(); go1.SetCommandPrompt("Select surface or polysurface to subtract with"); go1.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go1.SubObjectSelect = false; @@ -34,15 +34,15 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go1.CommandResult() != Result.Success) return go1.CommandResult(); - var brep1 = go1.Object(0).Brep(); + Brep brep1 = go1.Object(0).Brep(); if (null == brep1) return Result.Failure; - var tolerance = doc.ModelAbsoluteTolerance; - var out_breps = Brep.CreateBooleanDifference(brep0, brep1, tolerance); + double tolerance = doc.ModelAbsoluteTolerance; + Brep[] out_breps = Brep.CreateBooleanDifference(brep0, brep1, tolerance); if (null != out_breps && out_breps.Length > 0) { - foreach (var b in out_breps) + foreach (Brep b in out_breps) doc.Objects.AddBrep(b); doc.Objects.Delete(go0.Object(0).ObjectId, true); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference3.cs b/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference3.cs index 985d2662..ee58c3df 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference3.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference3.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; +using System; +using System.Collections.Generic; namespace SampleCsCommands { @@ -13,9 +13,9 @@ public class SampleCsBooleanDifference3 : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { const double height = 20.0; - var tolerance = doc.ModelAbsoluteTolerance; + double tolerance = doc.ModelAbsoluteTolerance; - var points0 = new List + List points0 = new List { new Point3d(-1.0, 0.0, 0.0), new Point3d(-1.0, -1.0, 0.0), @@ -27,11 +27,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) new Point3d(-1.0, 0.0, 0.0) }; - var brep0 = CreateBrep(points0, height, tolerance); + Brep brep0 = CreateBrep(points0, height, tolerance); if (null == brep0) return Result.Failure; - var points1 = new List + List points1 = new List { new Point3d(-1.0, 0.0, 0.0), new Point3d(-1.0, -1.0, 0.0), @@ -40,17 +40,17 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) new Point3d(-1.0, 0.0, 0.0) }; - var brep1 = CreateBrep(points1, height, tolerance); + Brep brep1 = CreateBrep(points1, height, tolerance); if (null == brep1) return Result.Failure; brep1.Rotate((Math.PI * 0.5), new Vector3d(1.0, 0.0, 0.0), new Point3d(0.0, 0.0, (0.5 * height))); brep1.Translate(new Vector3d(0.0, -1.0, 5.0)); - var results = Brep.CreateBooleanDifference(brep0, brep1, tolerance); + Brep[] results = Brep.CreateBooleanDifference(brep0, brep1, tolerance); if (null != results) { - foreach (var rc in results) + foreach (Brep rc in results) doc.Objects.AddBrep(rc); } @@ -68,17 +68,17 @@ protected Brep CreateBrep(List points, double height, double tolerance) return null; // Create the profile curve - var profile = new PolylineCurve(points); + PolylineCurve profile = new PolylineCurve(points); if (!profile.IsClosed || !profile.IsPlanar(tolerance)) return null; // Create a surface by extruding the profile curve - var surface = Surface.CreateExtrusion(profile, new Vector3d(0.0, 0.0, height)); + Surface surface = Surface.CreateExtrusion(profile, new Vector3d(0.0, 0.0, height)); if (null == surface) return null; // Create a Brep from the surface - var brep = surface.ToBrep(); + Brep brep = surface.ToBrep(); // The profile curve is a degree=1 curve. Thus, the extruded surface will // have kinks. Because kinked surface can cause problems down stream, Rhino @@ -88,7 +88,7 @@ protected Brep CreateBrep(List points, double height, double tolerance) brep.Faces.SplitKinkyFaces(RhinoMath.DefaultAngleTolerance, true); // Cap any planar holes - var capped_brep = brep.CapPlanarHoles(tolerance); + Brep capped_brep = brep.CapPlanarHoles(tolerance); if (null == capped_brep) return null; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference4.cs b/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference4.cs index f09ffca6..2a1bbe3e 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference4.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsBooleanDifference4.cs @@ -1,9 +1,9 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -20,7 +20,7 @@ public class SampleCsBooleanDifference4 : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go0 = new GetObject(); + GetObject go0 = new GetObject(); go0.SetCommandPrompt("Select surface or polysurface to subtract from"); go0.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go0.SubObjectSelect = false; @@ -28,13 +28,13 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go0.CommandResult() != Result.Success) return go0.CommandResult(); - var objref0 = go0.Object(0); - var rh_obj = objref0.Object(); - var brep0 = objref0.Brep(); + ObjRef objref0 = go0.Object(0); + RhinoObject rh_obj = objref0.Object(); + Brep brep0 = objref0.Brep(); if (null == rh_obj || null == brep0) return Result.Failure; - var go1 = new GetObject(); + GetObject go1 = new GetObject(); go1.SetCommandPrompt("Select surface or polysurface to subtract with"); go1.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go1.SubObjectSelect = false; @@ -44,14 +44,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go1.CommandResult() != Result.Success) return go1.CommandResult(); - var objref1 = go1.Object(0); - var brep1 = objref1.Brep(); + ObjRef objref1 = go1.Object(0); + Brep brep1 = objref1.Brep(); if (null == brep1) return Result.Failure; - var tolerance = doc.ModelAbsoluteTolerance; + double tolerance = doc.ModelAbsoluteTolerance; - var out_breps = Brep.CreateBooleanDifference(brep0, brep1, tolerance); + Brep[] out_breps = Brep.CreateBooleanDifference(brep0, brep1, tolerance); if (null == out_breps || 0 == out_breps.Length) { RhinoApp.WriteLine("Boolean difference failed."); @@ -59,14 +59,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } // Create a history record - var history = new HistoryRecord(this, HISTORY_VERSION); + HistoryRecord history = new HistoryRecord(this, HISTORY_VERSION); WriteHistory(history, objref0, objref1, tolerance); - var attributes = rh_obj.Attributes.Duplicate(); + ObjectAttributes attributes = rh_obj.Attributes.Duplicate(); attributes.ObjectId = Guid.Empty; attributes.RemoveFromAllGroups(); - foreach (var brep in out_breps) + foreach (Brep brep in out_breps) doc.Objects.AddBrep(brep, attributes, history, false); doc.Views.Redraw(); @@ -80,23 +80,23 @@ protected override bool ReplayHistory(ReplayHistoryData replay) { ObjRef objref0 = null; ObjRef objref1 = null; - var tolerance = RhinoMath.UnsetValue; + double tolerance = RhinoMath.UnsetValue; if (!ReadHistory(replay, ref objref0, ref objref1, ref tolerance)) return false; - var brep0 = objref0.Brep(); + Brep brep0 = objref0.Brep(); if (null == brep0) return false; - var brep1 = objref1.Brep(); + Brep brep1 = objref1.Brep(); if (null == brep1) return false; if (!RhinoMath.IsValidDouble(tolerance)) return false; - var out_breps = Brep.CreateBooleanDifference(brep0, brep1, tolerance); + Brep[] out_breps = Brep.CreateBooleanDifference(brep0, brep1, tolerance); if (null == out_breps || 0 == out_breps.Length) return false; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsBoundingBox.cs b/rhinocommon/cs/SampleCsCommands/SampleCsBoundingBox.cs index e8a7eb97..95de8527 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsBoundingBox.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsBoundingBox.cs @@ -14,18 +14,18 @@ public class SampleCsBoundingBox : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var cs_option = new OptionToggle(m_use_cplane, "World", "CPlane"); + OptionToggle cs_option = new OptionToggle(m_use_cplane, "World", "CPlane"); - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects for bounding box calculation"); go.GroupSelect = true; go.SubObjectSelect = false; - for (;;) + for (; ; ) { go.ClearCommandOptions(); go.AddOptionToggle("CoordinateSystem", ref cs_option); - var res = go.GetMultiple(1, 0); + GetResult res = go.GetMultiple(1, 0); if (res == GetResult.Option) continue; @@ -35,20 +35,20 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) break; } - var plane = go.View().ActiveViewport.ConstructionPlane(); + Plane plane = go.View().ActiveViewport.ConstructionPlane(); m_use_cplane = cs_option.CurrentValue; - var world_to_plane = new Transform(1.0); + Transform world_to_plane = new Transform(1.0); if (m_use_cplane) world_to_plane = Transform.ChangeBasis(Plane.WorldXY, plane); - - var bounding_box = new BoundingBox(); - for (var i = 0; i < go.ObjectCount; i++) + + BoundingBox bounding_box = new BoundingBox(); + for (int i = 0; i < go.ObjectCount; i++) { - var rhino_obj = go.Object(i).Object(); + Rhino.DocObjects.RhinoObject rhino_obj = go.Object(i).Object(); if (null != rhino_obj) { - var box = rhino_obj.Geometry.GetBoundingBox(world_to_plane); + BoundingBox box = rhino_obj.Geometry.GetBoundingBox(world_to_plane); if (box.IsValid) { if (i == 0) @@ -65,7 +65,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Failure; } - var box_corners = new Point3d[8]; + Point3d[] box_corners = new Point3d[8]; box_corners[0] = bounding_box.Corner(false, false, false); box_corners[1] = bounding_box.Corner(true, false, false); box_corners[2] = bounding_box.Corner(true, true, false); @@ -79,13 +79,13 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Transform corners points from cplane coordinates // to world coordinates if necessary. - var plane_to_world = Transform.ChangeBasis(plane, Plane.WorldXY); - for (var i = 0; i < 8; i++) + Transform plane_to_world = Transform.ChangeBasis(plane, Plane.WorldXY); + for (int i = 0; i < 8; i++) box_corners[i].Transform(plane_to_world); } - + Point3d[] rect; - var type = ClassifyBoundingBox(box_corners, out rect); + BoundingBoxClassification type = ClassifyBoundingBox(box_corners, out rect); if (type == BoundingBoxClassification.Point) { @@ -101,7 +101,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else //if (type == BoundingBoxClassification.Box) { - var brep = Brep.CreateFromBox(box_corners); + Brep brep = Brep.CreateFromBox(box_corners); doc.Objects.AddBrep(brep); } @@ -139,9 +139,9 @@ private BoundingBoxClassification ClassifyBoundingBox(Point3d[] boxCorners, out { rect = new Point3d[5]; - var num_flat = 0; - var xflat = false; - var yflat = false; + int num_flat = 0; + bool xflat = false; + bool yflat = false; //var zflat = false; const float flt_epsilon = 1.192092896e-07F; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsBoxMorph.cs b/rhinocommon/cs/SampleCsCommands/SampleCsBoxMorph.cs index 7fc5f9f8..d0503558 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsBoxMorph.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsBoxMorph.cs @@ -79,7 +79,7 @@ public BoxMorph(Rhino.Geometry.Point3d[] box, Rhino.Geometry.Point3d[] corners) if (8 == box.Length) { m_box = new Rhino.Geometry.Point3d[8]; - for (var i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) m_box[i] = box[i]; } @@ -100,7 +100,7 @@ public BoxMorph(Rhino.Geometry.Point3d[] box, Rhino.Geometry.Point3d[] corners) public bool IsValid() { - if (null != m_box && null != m_corners) + if (null != m_box && null != m_corners) return true; return false; } @@ -129,9 +129,9 @@ public bool IsIdentity() if (!IsValid()) return false; - for (int i = 0; i < 8; i++ ) + for (int i = 0; i < 8; i++) { - if( m_corners[i] != m_box[i] ) + if (m_corners[i] != m_box[i]) return false; } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCachedTextureCoordinates.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCachedTextureCoordinates.cs index d34c2b16..310b62e6 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCachedTextureCoordinates.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCachedTextureCoordinates.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; @@ -17,23 +16,23 @@ public class SampleCsCachedTextureCoordinates : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects"); go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - foreach (var rhinoObjectRef in go.Objects()) + foreach (ObjRef rhinoObjectRef in go.Objects()) { RhinoObject rhinoObject = rhinoObjectRef.Object(); if (null == rhinoObject) continue; // Get the object material, this material is used where subobject material is not defined - var objectMaterial = rhinoObject.GetMaterial(true); + Material objectMaterial = rhinoObject.GetMaterial(true); // Get the render meshes from the object - var meshes = rhinoObject.GetMeshes(MeshType.Render); + Mesh[] meshes = rhinoObject.GetMeshes(MeshType.Render); // If there are no render meshes, create them and get them again if (meshes == null || meshes.Length == 0) @@ -51,12 +50,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Iterate through the meshes, each polysurface face has a corresponding mesh for (int mi = 0; mi < meshes.Length; mi++) { - var mesh = meshes[mi]; + Mesh mesh = meshes[mi]; if (null == mesh) continue; // Figure out which material to use for this mesh - var meshMaterial = objectMaterial; + Material meshMaterial = objectMaterial; if (rhinoObject.HasSubobjectMaterials) { // If this object has subobject materials, figure out what is the component type of its subobject @@ -70,19 +69,19 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Ask if there is a subobject material for the current subobject ComponentIndex ci = new ComponentIndex(ciSubMaterialComponentType, mi); - var subObjectMaterial = rhinoObject.GetMaterial(ci); + Material subObjectMaterial = rhinoObject.GetMaterial(ci); if (subObjectMaterial != null) meshMaterial = subObjectMaterial; } - RhinoApp.WriteLine($" Mesh {mi} material {meshMaterial.Id}"); + RhinoApp.WriteLine($" Mesh {mi} material {meshMaterial.Id}"); // Set up cached texture coordinates based on the material texture channels mesh.SetCachedTextureCoordinatesFromMaterial(rhinoObject, meshMaterial); // Get all the textures used by the material - var textures = meshMaterial.GetTextures(); - foreach (var texture in textures) + Texture[] textures = meshMaterial.GetTextures(); + foreach (Texture texture in textures) { if (texture == null) continue; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCircleOfLines.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCircleOfLines.cs index f2cbff5c..66a6b118 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCircleOfLines.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCircleOfLines.cs @@ -1,7 +1,7 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; +using System; namespace SampleCsCommands { @@ -11,18 +11,18 @@ public class SampleCsCircleOfLines : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var rc = Rhino.Input.RhinoGet.GetCircle(out var circle); + Result rc = Rhino.Input.RhinoGet.GetCircle(out Circle circle); if (rc != Result.Success) return rc; - var n = 19; + int n = 19; - var points = PointsOnCircle(new Point3d(0, 0, 0), 5.0, n); - for (var i = 0; i < n; i++) + Point3d[] points = PointsOnCircle(new Point3d(0, 0, 0), 5.0, n); + for (int i = 0; i < n; i++) { - for (var j = i + 1; j < n; j++) + for (int j = i + 1; j < n; j++) { - var line = new Line(points[i], points[j]); + Line line = new Line(points[i], points[j]); doc.Objects.AddLine(line); } } @@ -34,12 +34,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) Point3d[] PointsOnCircle(Point3d center, double radius, int n) { - var alpha = Math.PI * 2 / n; - var points = new Point3d[n]; + double alpha = Math.PI * 2 / n; + Point3d[] points = new Point3d[n]; - for (var i = 0; i < n; i++) + for (int i = 0; i < n; i++) { - var theta = alpha * i; + double theta = alpha * i; points[i] = new Point3d( center.X + Math.Cos(theta) * radius, center.Y + Math.Sin(theta) * radius, diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCircleRadius.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCircleRadius.cs index 2457bd4a..72a1132e 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCircleRadius.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCircleRadius.cs @@ -11,20 +11,20 @@ public class SampleCsCircleRadius : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Center of circle"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var view = gp.View(); + Rhino.Display.RhinoView view = gp.View(); if (null == view) return Result.Failure; - var plane = view.ActiveViewport.ConstructionPlane(); + Plane plane = view.ActiveViewport.ConstructionPlane(); plane.Origin = gp.Point(); - var gr = new GetRadiusPoint(plane); + GetRadiusPoint gr = new GetRadiusPoint(plane); gr.SetCommandPrompt("Radius"); gr.Get(); if (gr.CommandResult() != Result.Success) @@ -45,7 +45,7 @@ internal class GetRadiusPoint : GetPoint private Plane BasePlane { get; } private bool CanDraw { get; set; } private System.Drawing.Color DrawColor { get; } - + public Circle Circle { get; private set; } public GetRadiusPoint(Plane basePlane) @@ -63,9 +63,9 @@ public GetRadiusPoint(Plane basePlane) public bool CalculateCircle(Point3d testPoint) { - var rc = false; - var point = BasePlane.ClosestPoint(testPoint); - var dir = point - BasePlane.Origin; + bool rc = false; + Point3d point = BasePlane.ClosestPoint(testPoint); + Vector3d dir = point - BasePlane.Origin; if (!dir.IsTiny()) { Circle = new Circle(BasePlane, dir.Length); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsClashMeshes.cs b/rhinocommon/cs/SampleCsCommands/SampleCsClashMeshes.cs index f9c8b482..085a9ac0 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsClashMeshes.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsClashMeshes.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; -using System.Linq; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Geometry.Intersect; using Rhino.Input.Custom; +using System.Collections.Generic; +using System.Linq; namespace SampleCsCommands { @@ -26,13 +26,13 @@ private double Distance /// protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var setA = new List(); - var setB = new List(); - var rc = SelectClashSets(setA, setB); + List setA = new List(); + List setB = new List(); + Result rc = SelectClashSets(setA, setB); if (rc != Result.Success) return rc; - var gd = new GetNumber(); + GetNumber gd = new GetNumber(); gd.SetCommandPrompt("Clearance distance"); gd.SetDefaultNumber(Distance); gd.SetLowerLimit(0.0, true); @@ -53,9 +53,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) /// private Result SelectClashSets(List setA, List setB) { - var filter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Extrusion | ObjectType.SubD; + ObjectType filter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Extrusion | ObjectType.SubD; - var go0 = new GetObject(); + GetObject go0 = new GetObject(); go0.SetCommandPrompt("Select first set of objects for clash detection"); go0.GeometryFilter = filter; go0.GroupSelect = true; @@ -64,15 +64,15 @@ private Result SelectClashSets(List setA, List setB) if (go0.CommandResult() != Result.Success) return go0.CommandResult(); - foreach (var objref in go0.Objects()) + foreach (ObjRef objref in go0.Objects()) { - var rh_obj = objref.Object(); + RhinoObject rh_obj = objref.Object(); if (null == rh_obj) return Result.Failure; setA.Add(rh_obj); } - var go1 = new GetObject(); + GetObject go1 = new GetObject(); go1.SetCommandPrompt("Select second set of objects for clash detection"); go1.GeometryFilter = filter; go1.GroupSelect = true; @@ -83,9 +83,9 @@ private Result SelectClashSets(List setA, List setB) if (go1.CommandResult() != Result.Success) return go1.CommandResult(); - foreach (var objref in go1.Objects()) + foreach (ObjRef objref in go1.Objects()) { - var rh_obj = objref.Object(); + RhinoObject rh_obj = objref.Object(); if (null == rh_obj) return Result.Failure; setB.Add(rh_obj); @@ -100,20 +100,20 @@ private Result SelectClashSets(List setA, List setB) private Result ClashObjects(RhinoDoc doc, List setA, List setB, double distance) { // Get the meshes for each Rhino object - var map = new Dictionary[2]; - var mp = MeshingParameters.FastRenderMesh; - for (var dex = 0; dex < 2; dex++) + Dictionary[] map = new Dictionary[2]; + MeshingParameters mp = MeshingParameters.FastRenderMesh; + for (int dex = 0; dex < 2; dex++) { map[dex] = new Dictionary(); - var rh_objects = (0 == dex) ? setA : setB; - for (var i = 0; i < rh_objects.Count; i++) + List rh_objects = (0 == dex) ? setA : setB; + for (int i = 0; i < rh_objects.Count; i++) { if (null != rh_objects[i]) { - var meshes = GetGeometryMeshes(rh_objects[i].Geometry, mp); + Mesh[] meshes = GetGeometryMeshes(rh_objects[i].Geometry, mp); if (meshes.Length > 0) { - for (var j = 0; j < meshes.Length; j++) + for (int j = 0; j < meshes.Length; j++) map[dex].Add(meshes[j], rh_objects[i]); } } @@ -123,14 +123,14 @@ private Result ClashObjects(RhinoDoc doc, List setA, List setA, List private Mesh[] GetGeometryMeshes(GeometryBase geometry, MeshingParameters mp) { - var rc = new Mesh[0]; + Mesh[] rc = new Mesh[0]; if (null != geometry) { if (null == mp) @@ -159,10 +159,10 @@ private Mesh[] GetGeometryMeshes(GeometryBase geometry, MeshingParameters mp) { case ObjectType.Surface: { - var surface = geometry as Surface; + Surface surface = geometry as Surface; if (null != surface) { - var mesh = Mesh.CreateFromSurface(surface, mp); + Mesh mesh = Mesh.CreateFromSurface(surface, mp); if (null != mesh) rc = new Mesh[] { mesh }; } @@ -171,10 +171,10 @@ private Mesh[] GetGeometryMeshes(GeometryBase geometry, MeshingParameters mp) case ObjectType.Brep: { - var brep = geometry as Brep; + Brep brep = geometry as Brep; if (null != brep) { - var meshes = Mesh.CreateFromBrep(brep, mp); + Mesh[] meshes = Mesh.CreateFromBrep(brep, mp); if (null != meshes && meshes.Length > 0) rc = meshes; } @@ -183,13 +183,13 @@ private Mesh[] GetGeometryMeshes(GeometryBase geometry, MeshingParameters mp) case ObjectType.Extrusion: { - var extrusion = geometry as Extrusion; + Extrusion extrusion = geometry as Extrusion; if (null != extrusion) { - var brep = extrusion.ToBrep(); + Brep brep = extrusion.ToBrep(); if (null != brep) { - var meshes = Mesh.CreateFromBrep(brep, mp); + Mesh[] meshes = Mesh.CreateFromBrep(brep, mp); if (null != meshes && meshes.Length > 0) rc = meshes; } @@ -199,7 +199,7 @@ private Mesh[] GetGeometryMeshes(GeometryBase geometry, MeshingParameters mp) case ObjectType.Mesh: { - var mesh = geometry as Mesh; + Mesh mesh = geometry as Mesh; if (null != mesh) rc = new Mesh[] { mesh }; } @@ -207,11 +207,11 @@ private Mesh[] GetGeometryMeshes(GeometryBase geometry, MeshingParameters mp) case ObjectType.SubD: { - var subd = geometry as SubD; + SubD subd = geometry as SubD; if (null != subd) { // 2 == ON_SubDDisplayParameters::CourseDensity - var mesh = Mesh.CreateFromSubD(geometry as SubD, 2); + Mesh mesh = Mesh.CreateFromSubD(geometry as SubD, 2); if (null != mesh) rc = new Mesh[] { mesh }; } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsClashObjects.cs b/rhinocommon/cs/SampleCsCommands/SampleCsClashObjects.cs index c9218dc2..948a332d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsClashObjects.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsClashObjects.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Geometry.Intersect; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -25,13 +25,13 @@ private double Distance /// protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var setA = new List(); - var setB = new List(); - var rc = SelectClashSets(setA, setB); + List setA = new List(); + List setB = new List(); + Result rc = SelectClashSets(setA, setB); if (rc != Result.Success) return rc; - var gd = new GetNumber(); + GetNumber gd = new GetNumber(); gd.SetCommandPrompt("Clearance distance"); gd.SetDefaultNumber(Distance); gd.SetLowerLimit(0.0, true); @@ -42,7 +42,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) Distance = gd.Number(); // Search for object clashes - var clashes = MeshClash.Search(setA, setB, Distance, MeshType.Render, MeshingParameters.FastRenderMesh); + MeshInterference[] clashes = MeshClash.Search(setA, setB, Distance, MeshType.Render, MeshingParameters.FastRenderMesh); if (clashes.Length == 1) RhinoApp.WriteLine("1 clash found."); @@ -51,7 +51,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (clashes.Length > 1) { - foreach (var clash in clashes) + foreach (MeshInterference clash in clashes) doc.Objects.AddPoints(clash.HitPoints); } @@ -65,9 +65,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) /// private Result SelectClashSets(List setA, List setB) { - var filter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Extrusion | ObjectType.SubD; + ObjectType filter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Extrusion | ObjectType.SubD; - var go0 = new GetObject(); + GetObject go0 = new GetObject(); go0.SetCommandPrompt("Select first set of objects for clash detection"); go0.GeometryFilter = filter; go0.GroupSelect = true; @@ -76,15 +76,15 @@ private Result SelectClashSets(List setA, List setB) if (go0.CommandResult() != Result.Success) return go0.CommandResult(); - foreach (var objref in go0.Objects()) + foreach (ObjRef objref in go0.Objects()) { - var rh_obj = objref.Object(); + RhinoObject rh_obj = objref.Object(); if (null == rh_obj) return Result.Failure; setA.Add(rh_obj); } - var go1 = new GetObject(); + GetObject go1 = new GetObject(); go1.SetCommandPrompt("Select second set of objects for clash detection"); go1.GeometryFilter = filter; go1.GroupSelect = true; @@ -95,9 +95,9 @@ private Result SelectClashSets(List setA, List setB) if (go1.CommandResult() != Result.Success) return go1.CommandResult(); - foreach (var objref in go1.Objects()) + foreach (ObjRef objref in go1.Objects()) { - var rh_obj = objref.Object(); + RhinoObject rh_obj = objref.Object(); if (null == rh_obj) return Result.Failure; setB.Add(rh_obj); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsClassifyCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsClassifyCurve.cs index 5977ae3c..70b58c46 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsClassifyCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsClassifyCurve.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Geometry.Intersect; using Rhino.Input; +using System; +using System.Collections.Generic; namespace SampleCsCommands { @@ -96,15 +96,15 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) break; case 6: RhinoApp.WriteLine("Curve is a regular hexagon."); - break; + break; case 7: RhinoApp.WriteLine("Curve is a regular heptagon."); break; case 8: - RhinoApp.WriteLine("Curve is a regular octagon."); + RhinoApp.WriteLine("Curve is a regular octagon."); break; case 9: - RhinoApp.WriteLine("Curve is a regular nonagon."); + RhinoApp.WriteLine("Curve is a regular nonagon."); break; case 10: RhinoApp.WriteLine("Curve is a regular decagon."); @@ -125,16 +125,16 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) RhinoApp.WriteLine("Curve is an triangle."); break; case 4: - { - // I'll leave searching for parallelogram and trapezoids for somebody else... - if (bAngle) - RhinoApp.WriteLine("Curve is a rectangle."); - else if (bLength) - RhinoApp.WriteLine("Curve is a rhombus."); - else - RhinoApp.WriteLine("Curve is a quadrilateral."); - break; - } + { + // I'll leave searching for parallelogram and trapezoids for somebody else... + if (bAngle) + RhinoApp.WriteLine("Curve is a rectangle."); + else if (bLength) + RhinoApp.WriteLine("Curve is a rhombus."); + else + RhinoApp.WriteLine("Curve is a quadrilateral."); + break; + } case 5: RhinoApp.WriteLine("Curve is a irregular pentagon."); break; @@ -208,7 +208,7 @@ private bool IsLine(Curve curve) // (Should never need to test for this...) if (curve is PolyCurve poly_curve) { - if (poly_curve.TryGetPolyline(out var polyline)) + if (poly_curve.TryGetPolyline(out Polyline polyline)) { if (2 == polyline.Count) return true; @@ -218,7 +218,7 @@ private bool IsLine(Curve curve) // Is the curve a NURBS curve that looks like a line? if (curve is NurbsCurve nurbs_curve) { - if (nurbs_curve.TryGetPolyline(out var polyline)) + if (nurbs_curve.TryGetPolyline(out Polyline polyline)) { if (2 == polyline.Count) return true; @@ -247,7 +247,7 @@ private bool IsArc(Curve curve, ref bool bCircle) // (Should never need to test for this...) if (curve is PolyCurve poly_curve) { - if (poly_curve.TryGetArc(out var arc)) + if (poly_curve.TryGetArc(out Arc arc)) { bCircle = arc.IsCircle; return true; @@ -257,7 +257,7 @@ private bool IsArc(Curve curve, ref bool bCircle) // Is the curve a NURBS curve that looks like an arc? if (curve is NurbsCurve nurbs_curve) { - if (nurbs_curve.TryGetArc(out var arc)) + if (nurbs_curve.TryGetArc(out Arc arc)) { bCircle = arc.IsCircle; return true; @@ -279,7 +279,7 @@ private bool IsEllipse(Curve curve, ref bool bEllipticalArc) // (Should never need to test for this...) if (curve is PolyCurve poly_curve) { - if (poly_curve.TryGetEllipse(out var ellipse)) + if (poly_curve.TryGetEllipse(out Ellipse ellipse)) { bEllipticalArc = !ellipse.ToNurbsCurve().IsClosed; return true; @@ -289,7 +289,7 @@ private bool IsEllipse(Curve curve, ref bool bEllipticalArc) // Is the curve a NURBS curve that looks like an ellipse? if (curve is NurbsCurve nurbs_curve) { - if (nurbs_curve.TryGetEllipse(out var ellipse)) + if (nurbs_curve.TryGetEllipse(out Ellipse ellipse)) { bEllipticalArc = !nurbs_curve.IsClosed; return true; @@ -322,12 +322,12 @@ bool IsPolyline(Curve curve, ref int pointCount, ref bool bClosed, ref bool bPla // Is the curve a polycurve that looks like an polyline? if (curve is PolyCurve poly_curve) { - if (poly_curve.TryGetPolyline(out var polyline)) + if (poly_curve.TryGetPolyline(out Polyline polyline)) { if (polyline.Count <= 2) return false; - for (var i = 0; i < polyline.Count; i++) + for (int i = 0; i < polyline.Count; i++) points.Add(polyline[i]); } } @@ -335,12 +335,12 @@ bool IsPolyline(Curve curve, ref int pointCount, ref bool bClosed, ref bool bPla // Is the curve a NURBS curve that looks like an polyline? if (curve is NurbsCurve nurbs_curve) { - if (nurbs_curve.TryGetPolyline(out var polyline)) + if (nurbs_curve.TryGetPolyline(out Polyline polyline)) { if (polyline.Count <= 2) return false; - for (var i = 0; i < polyline.Count; i++) + for (int i = 0; i < polyline.Count; i++) points.Add(polyline[i]); } } @@ -358,7 +358,7 @@ bool IsPolyline(Curve curve, ref int pointCount, ref bool bClosed, ref bool bPla pointCount = (bClosed ? points.Count - 1 : points.Count); // Test for self-intersection. - var intesections = Intersection.CurveSelf(curve, m_tolerance); + CurveIntersections intesections = Intersection.CurveSelf(curve, m_tolerance); bIntersect = intesections.Count > 0; // If the curve is not closed, no reason to continue... @@ -366,14 +366,14 @@ bool IsPolyline(Curve curve, ref int pointCount, ref bool bClosed, ref bool bPla return true; // Test if the distance between each point is identical. - var distance = 0.0; - for (var i = 1; i < points.Count; i++) + double distance = 0.0; + for (int i = 1; i < points.Count; i++) { - var p0 = points[i - 1]; - var p1 = points[i]; - var v = p0 - p1; + Point3d p0 = points[i - 1]; + Point3d p1 = points[i]; + Vector3d v = p0 - p1; - var d = v.Length; + double d = v.Length; if (i == 1) { distance = d; @@ -392,20 +392,20 @@ bool IsPolyline(Curve curve, ref int pointCount, ref bool bClosed, ref bool bPla bLength = RhinoMath.IsValidDouble(distance); // Test if the angle between each point is identical. - var angle = 0.0; - for (var i = 1; i < points.Count - 1; i++) + double angle = 0.0; + for (int i = 1; i < points.Count - 1; i++) { - var p0 = points[i - 1]; - var p1 = points[i]; - var p2 = points[i + 1]; + Point3d p0 = points[i - 1]; + Point3d p1 = points[i]; + Point3d p2 = points[i + 1]; - var v0 = p1 - p0; - var v1 = p1 - p2; + Vector3d v0 = p1 - p0; + Vector3d v1 = p1 - p2; v0.Unitize(); v1.Unitize(); - var a = Vector3d.VectorAngle(v0, v1); + double a = Vector3d.VectorAngle(v0, v1); if (i == 1) { angle = a; @@ -422,7 +422,7 @@ bool IsPolyline(Curve curve, ref int pointCount, ref bool bClosed, ref bool bPla } // Set return value. - bAngle = RhinoMath.IsValidDouble(angle); + bAngle = RhinoMath.IsValidDouble(angle); return true; } @@ -441,7 +441,7 @@ private bool IsPolyCurve(Curve curve) return false; } - + /// /// Test for a curve that is a NURBS curve. /// diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsColorfulMeshBox.cs b/rhinocommon/cs/SampleCsCommands/SampleCsColorfulMeshBox.cs index 3a6743d0..8d4157c7 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsColorfulMeshBox.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsColorfulMeshBox.cs @@ -1,6 +1,6 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; +using System; namespace SampleCsCommands { @@ -24,7 +24,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Rhino.Geometry.Mesh mesh = new Rhino.Geometry.Mesh(); - mesh.Vertices.Add(new Rhino.Geometry.Point3d(0.5, 0.5, 0.5)); + mesh.Vertices.Add(new Rhino.Geometry.Point3d(0.5, 0.5, 0.5)); mesh.Vertices.Add(new Rhino.Geometry.Point3d(0.5, 0.5, -0.5)); mesh.Vertices.Add(new Rhino.Geometry.Point3d(0.5, -0.5, 0.5)); mesh.Vertices.Add(new Rhino.Geometry.Point3d(0.5, -0.5, -0.5)); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCommandLineOptions.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCommandLineOptions.cs index 06cccd2c..58d3a5f6 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCommandLineOptions.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCommandLineOptions.cs @@ -13,13 +13,13 @@ public class SampleCsCommandLineOptions : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { const ObjectType geometry_filter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Mesh; - var integer1 = 300; - var integer2 = 300; + int integer1 = 300; + int integer2 = 300; - var option_integer1 = new OptionInteger(integer1, 200, 900); - var option_integer2 = new OptionInteger(integer2, 200, 900); + OptionInteger option_integer1 = new OptionInteger(integer1, 200, 900); + OptionInteger option_integer2 = new OptionInteger(integer2, 200, 900); - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select surfaces, polysurfaces, or meshes"); go.GeometryFilter = geometry_filter; go.AddOptionInteger("Option1", ref option_integer1); @@ -27,11 +27,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) go.GroupSelect = true; go.SubObjectSelect = false; - var have_preselected_objects = false; + bool have_preselected_objects = false; while (true) { - var res = go.GetMultiple(1, 0); + GetResult res = go.GetMultiple(1, 0); if (res == GetResult.Option) { @@ -68,15 +68,15 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // of pre-selected and post-selected. So, to make sure everything // "looks the same", lets unselect everything before finishing // the command. - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var rhino_object = go.Object(i).Object(); + RhinoObject rhino_object = go.Object(i).Object(); rhino_object?.Select(false); } doc.Views.Redraw(); } - var object_count = go.ObjectCount; + int object_count = go.ObjectCount; integer1 = option_integer1.CurrentValue; integer2 = option_integer2.CurrentValue; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCommandsPlugIn.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCommandsPlugIn.cs index 3d0e2386..5c628fd0 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCommandsPlugIn.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCommandsPlugIn.cs @@ -1,8 +1,8 @@ -using System; +using Rhino; +using Rhino.PlugIns; +using System; using System.IO; using System.Text; -using Rhino; -using Rhino.PlugIns; namespace SampleCsCommands { @@ -76,7 +76,7 @@ private void StagePlugInToolbarFile() // EXAMPLE: // Get the version number of our plug-in, that was last used, from our settings file. - var plugin_version = Settings.GetString("PlugInVersion", null); + string plugin_version = Settings.GetString("PlugInVersion", null); if (!string.IsNullOrEmpty(plugin_version)) { @@ -85,14 +85,14 @@ private void StagePlugInToolbarFile() if (0 != string.Compare(Version, plugin_version, StringComparison.OrdinalIgnoreCase)) { // Build a path to the user's staged .rui file. - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); sb.Append("\\McNeel\\Rhinoceros\\5.0\\Plug-ins\\"); sb.AppendFormat("{0} ({1})", Name, Id); sb.Append("\\settings\\"); sb.AppendFormat("{0}.rui", Assembly.GetName().Name); - var path = sb.ToString(); + string path = sb.ToString(); // Verify the .rui file exists. if (File.Exists(path)) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsContour.cs b/rhinocommon/cs/SampleCsCommands/SampleCsContour.cs index de62e958..c41d8c6d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsContour.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsContour.cs @@ -1,9 +1,9 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; -using Rhino.Input; -using Rhino.Geometry; using Rhino.DocObjects; +using Rhino.Geometry; +using Rhino.Input; +using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -16,66 +16,66 @@ public class SampleCsContour : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { const ObjectType filter = ObjectType.Brep | ObjectType.Extrusion | ObjectType.Mesh; - var rc = RhinoGet.GetMultipleObjects("Select objects to contour", false, filter, out var objrefs); + Result rc = RhinoGet.GetMultipleObjects("Select objects to contour", false, filter, out ObjRef[] objrefs); if (rc != Result.Success) return rc; if (objrefs == null || objrefs.Length < 1) return Result.Failure; - rc = RhinoGet.GetPoint("Contour plane base point", false, out var base_point); + rc = RhinoGet.GetPoint("Contour plane base point", false, out Point3d base_point); if (rc != Result.Success) return rc; - var gp = new Rhino.Input.Custom.GetPoint(); + Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint(); gp.SetCommandPrompt("Direction perpendicular to contour planes"); gp.DrawLineFromPoint(base_point, false); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var end_point = gp.Point(); + Point3d end_point = gp.Point(); - var interval = 1.0; + double interval = 1.0; rc = RhinoGet.GetNumber("Distance between contours", true, ref interval, 0.001, 10000); if (rc != Result.Success) return rc; - var bounds = BoundingBox.Unset; - var geometries = new List(); - foreach (var objref in objrefs) + BoundingBox bounds = BoundingBox.Unset; + List geometries = new List(); + foreach (ObjRef objref in objrefs) { - var geometry = objref.Geometry(); + GeometryBase geometry = objref.Geometry(); if (geometry is Extrusion) geometry = objref.Brep(); geometries.Add(geometry); - var bbox = geometry.GetBoundingBox(false); + BoundingBox bbox = geometry.GetBoundingBox(false); bounds.Union(bbox); } - var normal = end_point - base_point; + Vector3d normal = end_point - base_point; normal.Unitize(); - var curplane = new Plane(base_point, normal); - if (!curplane.DistanceTo(bounds, out var min_t, out var max_t)) + Plane curplane = new Plane(base_point, normal); + if (!curplane.DistanceTo(bounds, out double min_t, out double max_t)) return Result.Failure; min_t -= interval; max_t += interval; min_t = Math.Floor(min_t / interval); max_t = Math.Ceiling(max_t / interval); - var tolerance = doc.ModelAbsoluteTolerance; + double tolerance = doc.ModelAbsoluteTolerance; - var tasks = new List>(); - var gc = new Rhino.Input.Custom.GetCancel(); - for (var t = min_t; t <= max_t; t += 1.0) + List> tasks = new List>(); + Rhino.Input.Custom.GetCancel gc = new Rhino.Input.Custom.GetCancel(); + for (double t = min_t; t <= max_t; t += 1.0) { - var offset = t * interval; - var point = base_point + normal * offset; - var plane = new Plane(point, normal); - foreach (var geom in geometries) + double offset = t * interval; + Point3d point = base_point + normal * offset; + Plane plane = new Plane(point, normal); + foreach (GeometryBase geom in geometries) { - var geom1 = geom; - var task = Task.Run(() => Section(plane, geom1, tolerance), gc.Token); + GeometryBase geom1 = geom; + Task task = Task.Run(() => Section(plane, geom1, tolerance), gc.Token); tasks.Add(task); } } @@ -88,10 +88,10 @@ private void OnTaskCompleted(object sender, Rhino.Input.Custom.TaskCompleteEvent { if (e.Task is Task t && t.Status == TaskStatus.RanToCompletion) { - var curves = t.Result; + Curve[] curves = t.Result; if (curves != null && curves.Length > 0) { - foreach (var curve in curves) + foreach (Curve curve in curves) e.Doc.Objects.AddCurve(curve); e.Redraw = true; } @@ -100,16 +100,16 @@ private void OnTaskCompleted(object sender, Rhino.Input.Custom.TaskCompleteEvent private static Curve[] Section(Plane plane, GeometryBase geometry, double tolerance) { - var rc = new Curve[0]; + Curve[] rc = new Curve[0]; if (geometry is Brep brep) { - Rhino.Geometry.Intersect.Intersection.BrepPlane(brep, plane, tolerance, out rc, out var pts); + Rhino.Geometry.Intersect.Intersection.BrepPlane(brep, plane, tolerance, out rc, out Point3d[] pts); return rc; } if (geometry is Mesh mesh) { - var polylines = Rhino.Geometry.Intersect.Intersection.MeshPlane(mesh, plane); + Polyline[] polylines = Rhino.Geometry.Intersect.Intersection.MeshPlane(mesh, plane); if (polylines != null) { rc = new Curve[polylines.Length]; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsContourMesh.cs b/rhinocommon/cs/SampleCsCommands/SampleCsContourMesh.cs index 87738b45..a6a51aec 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsContourMesh.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsContourMesh.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCreateBooleanRegions.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCreateBooleanRegions.cs index bdc41cff..055df30d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCreateBooleanRegions.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCreateBooleanRegions.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -14,18 +14,18 @@ public class SampleCsCreateBooleanRegions : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var all = false; - var combine = false; + bool all = false; + bool combine = false; - var all_option = new OptionToggle(all, "No", "Yes"); - var combine_option = new OptionToggle(combine, "No", "Yes"); - var res = GetResult.Nothing; + OptionToggle all_option = new OptionToggle(all, "No", "Yes"); + OptionToggle combine_option = new OptionToggle(combine, "No", "Yes"); + GetResult res = GetResult.Nothing; - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select curves"); go.GeometryFilter = ObjectType.Curve; go.EnablePreSelect(false, true); - for (;;) + for (; ; ) { go.ClearCommandOptions(); go.AddOptionToggle("AllRegions", ref all_option); @@ -38,10 +38,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (res != GetResult.Object) return Result.Cancel; - var curves = new List(go.ObjectCount); - foreach (var obj_ref in go.Objects()) + List curves = new List(go.ObjectCount); + foreach (ObjRef obj_ref in go.Objects()) { - var curve = obj_ref.Curve(); + Curve curve = obj_ref.Curve(); if (null == curve) return Result.Failure; curves.Add(curve); @@ -50,13 +50,13 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) all = all_option.CurrentValue; combine = combine_option.CurrentValue; - var points = new List(); + List points = new List(); if (!all) { - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Pick region points. Press when done"); gp.AcceptNothing(true); - for (;;) + for (; ; ) { res = gp.Get(); if (res != GetResult.Point) @@ -65,27 +65,27 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } } - var plane = Plane.WorldXY; - var tolerance = doc.ModelAbsoluteTolerance; - var regions = all + Plane plane = Plane.WorldXY; + double tolerance = doc.ModelAbsoluteTolerance; + CurveBooleanRegions regions = all ? Curve.CreateBooleanRegions(curves, plane, combine, tolerance) : Curve.CreateBooleanRegions(curves, plane, points, combine, tolerance); if (null == regions) return Result.Failure; - for (var i = 0; i < regions.RegionCount; i++) + for (int i = 0; i < regions.RegionCount; i++) { - var boundaries = regions.RegionCurves(i); - foreach (var boundary in boundaries) + Curve[] boundaries = regions.RegionCurves(i); + foreach (Curve boundary in boundaries) doc.Objects.AddCurve(boundary); } if (!all) { - for (var i = 0; i < regions.PointCount; i++) + for (int i = 0; i < regions.PointCount; i++) { - var point_index = regions.RegionPointIndex(i); + int point_index = regions.RegionPointIndex(i); if (point_index >= 0) doc.Objects.AddPoint(points[point_index]); } @@ -93,7 +93,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) regions.Dispose(); - foreach (var obj_ref in go.Objects()) + foreach (ObjRef obj_ref in go.Objects()) doc.Objects.Delete(obj_ref, false, false); doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCreateNestedBlock.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCreateNestedBlock.cs index 98efbb4a..3c218387 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCreateNestedBlock.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCreateNestedBlock.cs @@ -11,31 +11,31 @@ public class SampleCsCreateNestedBlock : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Create a circle curve - var circle = new Circle(Plane.WorldXY, 5.0); - var curve0 = new ArcCurve(circle); + Circle circle = new Circle(Plane.WorldXY, 5.0); + ArcCurve curve0 = new ArcCurve(circle); // Add an instance defintion that uses the circle curve - var attrib = doc.CreateDefaultAttributes(); - var idef0_index = doc.InstanceDefinitions.Add("Circle", "Circle", Point3d.Origin, curve0, attrib); + Rhino.DocObjects.ObjectAttributes attrib = doc.CreateDefaultAttributes(); + int idef0_index = doc.InstanceDefinitions.Add("Circle", "Circle", Point3d.Origin, curve0, attrib); // Create a reference to the instance definition - var idef0_id = doc.InstanceDefinitions[idef0_index].Id; - var iref0 = new InstanceReferenceGeometry(idef0_id, Transform.Identity); + System.Guid idef0_id = doc.InstanceDefinitions[idef0_index].Id; + InstanceReferenceGeometry iref0 = new InstanceReferenceGeometry(idef0_id, Transform.Identity); // Create a polyline curve - var rect = new Point3d[5]; + Point3d[] rect = new Point3d[5]; rect[0] = new Point3d(-5.0, -5.0, 0.0); rect[1] = new Point3d(5.0, -5.0, 0.0); rect[2] = new Point3d(5.0, 5.0, 0.0); rect[3] = new Point3d(-5.0, 5.0, 0.0); rect[4] = rect[0]; - var curve1 = new PolylineCurve(rect); + PolylineCurve curve1 = new PolylineCurve(rect); // Add another instance definition that uses the polyline curve // and the instance reference - var geometry = new GeometryBase[] { curve1, iref0 }; - var attributes = new[] { attrib, attrib }; - var idef1_index = doc.InstanceDefinitions.Add("Rectangle and Circle", "Rectangle and Circle", Point3d.Origin, geometry, attributes); + GeometryBase[] geometry = new GeometryBase[] { curve1, iref0 }; + Rhino.DocObjects.ObjectAttributes[] attributes = new[] { attrib, attrib }; + int idef1_index = doc.InstanceDefinitions.Add("Rectangle and Circle", "Rectangle and Circle", Point3d.Origin, geometry, attributes); // Add an instace of the new defintion to the document and redraw doc.Objects.AddInstanceObject(idef1_index, Transform.Identity); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCreateUVCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCreateUVCurve.cs index 02247b9d..9fc55207 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCreateUVCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCreateUVCurve.cs @@ -11,20 +11,20 @@ public class SampleCsCreateUVCurve : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select surface to create UV curve"); go.GeometryFilter = ObjectType.Surface; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var brep_face = go.Object(0).Face(); + Rhino.Geometry.BrepFace brep_face = go.Object(0).Face(); if (null == brep_face) return Result.Failure; - foreach (var loop in brep_face.Loops) + foreach (Rhino.Geometry.BrepLoop loop in brep_face.Loops) { - var loop_curve = loop.To2dCurve(); + Rhino.Geometry.Curve loop_curve = loop.To2dCurve(); loop_curve.ChangeDimension(3); doc.Objects.AddCurve(loop_curve); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCurveDirection.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCurveDirection.cs index 9881020d..cc025e4b 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCurveDirection.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCurveDirection.cs @@ -1,10 +1,9 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.Geometry; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -61,7 +60,7 @@ public class SampleCsCurveDirectionConduit : Rhino.Display.DisplayConduit public SampleCsCurveDirectionConduit(GetObject go) { m_curves = new List(go.ObjectCount); - + for (int i = 0; i < go.ObjectCount; i++) { Curve curve = go.Object(i).Curve(); @@ -79,7 +78,7 @@ protected override void DrawOverlay(DrawEventArgs e) if (null == curve) continue; - for (double j = 0.0; j < CURVE_ARROW_COUNT; j += 1.0 ) + for (double j = 0.0; j < CURVE_ARROW_COUNT; j += 1.0) { double d = j / (CURVE_ARROW_COUNT - 1.0); double t = curve.Domain.ParameterAt(d); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCurveDiscontinuity.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCurveDiscontinuity.cs index f22effb8..1357679e 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCurveDiscontinuity.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCurveDiscontinuity.cs @@ -1,12 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System; +using System.Collections.Generic; +using System.Linq; namespace SampleCsCommands { @@ -16,45 +16,45 @@ public class SampleCsCurveDiscontinuity : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select curves"); go.GeometryFilter = ObjectType.Curve; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var curve = go.Object(0).Curve(); + Curve curve = go.Object(0).Curve(); if (null == curve) return Result.Failure; - var continuity = Continuity.G1_continuous; + Continuity continuity = Continuity.G1_continuous; - var gd = new GetOption(); + GetOption gd = new GetOption(); gd.SetCommandPrompt("Discontinuity to search"); gd.AddOptionEnumList("Discontinuity", continuity); gd.AcceptNothing(true); - var res = gd.Get(); + GetResult res = gd.Get(); if (res == GetResult.Option) { - var option = gd.Option(); + CommandLineOption option = gd.Option(); if (null == option) return Result.Failure; - var list = Enum.GetValues(typeof (Continuity)).Cast().ToList(); + List list = Enum.GetValues(typeof(Continuity)).Cast().ToList(); continuity = list[option.CurrentListOptionIndex]; } else if (res != GetResult.Nothing) return Result.Cancel; - var t0 = curve.Domain.Min; - var t1 = curve.Domain.Max; + double t0 = curve.Domain.Min; + double t1 = curve.Domain.Max; - var parameters = new List(); + List parameters = new List(); parameters.Add(t0); for (; ; ) { double t; - var rc = curve.GetNextDiscontinuity(continuity, t0, t1, out t); + bool rc = curve.GetNextDiscontinuity(continuity, t0, t1, out t); if (rc) { parameters.Add(t); @@ -67,12 +67,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (parameters.Count > 2) { - for (var i = 0; i < parameters.Count - 1; i++) + for (int i = 0; i < parameters.Count - 1; i++) { t0 = parameters[i]; - t1 = parameters[i+1]; - var dom = new Interval(t0, t1); - var new_curve = curve.Trim(dom); + t1 = parameters[i + 1]; + Interval dom = new Interval(t0, t1); + Curve new_curve = curve.Trim(dom); if (null != new_curve) doc.Objects.AddCurve(new_curve); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCurveEditPoints.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCurveEditPoints.cs index 0e2634f2..efb4c8ad 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCurveEditPoints.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCurveEditPoints.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Collections; using Rhino.Commands; using Rhino.DocObjects; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCurveGetter.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCurveGetter.cs index d8773d32..5da41944 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCurveGetter.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCurveGetter.cs @@ -12,16 +12,16 @@ public class SampleCsCurveGetter : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select curves"); go.GeometryFilter = ObjectType.Curve; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var curve = go.Object(i).Curve(); + Curve curve = go.Object(i).Curve(); if (null == curve) return Result.Failure; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCurvePoints.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCurvePoints.cs index 4f731c7b..e44a2861 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCurvePoints.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCurvePoints.cs @@ -12,14 +12,14 @@ public class SampleCsCurvePoints : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select curve"); go.GeometryFilter = ObjectType.Curve; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var curve = go.Object(0).Curve(); + Curve curve = go.Object(0).Curve(); if (null == curve) return Result.Failure; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCurveSeam.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCurveSeam.cs index b1286c3a..b6041103 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCurveSeam.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCurveSeam.cs @@ -1,9 +1,9 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; -using Rhino.Input.Custom; using Rhino.Geometry; +using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -19,7 +19,7 @@ public class SampleCsCurveSeam : Command /// protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject + GetObject go = new GetObject { GeometryFilter = ObjectType.Curve, GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve, @@ -31,27 +31,27 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var objref = go.Object(0); - var curve = objref.Curve(); + ObjRef objref = go.Object(0); + Curve curve = objref.Curve(); if (null == curve) return Result.Failure; - var snapToKnots = true; + bool snapToKnots = true; - var gp = new SampleCsCurveSeamPoint(curve, snapToKnots); + SampleCsCurveSeamPoint gp = new SampleCsCurveSeamPoint(curve, snapToKnots); gp.SetCommandPrompt("New seam point"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var point = gp.Point(); + Point3d point = gp.Point(); if (gp.GetSeamPoint(point)) { - var t = gp.SeamParameter; - var p = curve.PointAt(t); + double t = gp.SeamParameter; + Point3d p = curve.PointAt(t); if (p.DistanceTo(curve.PointAtStart) > 0.00001) // some minimum distance { - var new_curve = curve.DuplicateCurve(); + Curve new_curve = curve.DuplicateCurve(); new_curve.ChangeClosedCurveSeam(t); doc.Objects.Replace(objref, new_curve); } @@ -105,9 +105,9 @@ protected override void OnDynamicDraw(GetPointDrawEventArgs e) e.Display.DrawPoint(m_curve.PointAtStart); if (RhinoMath.IsValidDouble(m_seam_t)) { - var p = m_curve.PointAt(m_seam_t); + Point3d p = m_curve.PointAt(m_seam_t); e.Display.DrawPoint(p); - var v = m_curve.TangentAt(m_seam_t); + Vector3d v = m_curve.TangentAt(m_seam_t); e.Display.DrawDirectionArrow(p, v, Rhino.ApplicationSettings.AppearanceSettings.FeedbackColor); } } @@ -118,7 +118,7 @@ protected override void OnDynamicDraw(GetPointDrawEventArgs e) public bool GetSeamPoint(Point3d point) { m_seam_t = RhinoMath.UnsetValue; - var rc = m_curve.ClosestPoint(point, out var t); + bool rc = m_curve.ClosestPoint(point, out double t); if (rc) { if (m_snap_to_knots) @@ -134,15 +134,15 @@ public bool GetSeamPoint(Point3d point) /// private double SnapToClosestKnot(double t) { - var nc = m_curve as NurbsCurve; + NurbsCurve nc = m_curve as NurbsCurve; if (null == nc) return t; - var kcount = nc.Knots.Count; + int kcount = nc.Knots.Count; for (int i = 1; i < kcount; i++) { - var k0 = nc.Knots[i - 1]; - var k1 = nc.Knots[i]; + double k0 = nc.Knots[i - 1]; + double k1 = nc.Knots[i]; if (Math.Abs(k0 - t) < RhinoMath.ZeroTolerance) return k0; @@ -151,9 +151,9 @@ private double SnapToClosestKnot(double t) if (k0 < t && k1 > t) { - var p = nc.PointAt(t); - var p0 = nc.PointAt(k0); - var p1 = nc.PointAt(k1); + Point3d p = nc.PointAt(t); + Point3d p0 = nc.PointAt(k0); + Point3d p1 = nc.PointAt(k1); if (p.DistanceTo(p0) > p.DistanceTo(p1)) return k1; else diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCustomLine.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCustomLine.cs index 62a6ea00..cb680d26 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCustomLine.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCustomLine.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCustomRenderMeshSettings.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCustomRenderMeshSettings.cs index c57065b3..1d2383b9 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCustomRenderMeshSettings.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCustomRenderMeshSettings.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands @@ -38,7 +37,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (doc.MeshingParameterStyle == Rhino.Geometry.MeshingParameterStyle.Custom) doc.MeshingParameterStyle = Rhino.Geometry.MeshingParameterStyle.Fast; doc.MeshingParameterStyle = Rhino.Geometry.MeshingParameterStyle.Custom; - + doc.Views.Redraw(); return Result.Success; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsCylinderTest.cs b/rhinocommon/cs/SampleCsCommands/SampleCsCylinderTest.cs index ca4e4b23..54d669cc 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsCylinderTest.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsCylinderTest.cs @@ -1,9 +1,8 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; -using Rhino.Input.Custom; using Rhino.Geometry; +using Rhino.Input.Custom; namespace SampleCsCommands { @@ -14,15 +13,15 @@ public class SampleCsCylinderTest : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Select surface that look like a cylinder - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select surface that look like a cylinder"); go.GeometryFilter = ObjectType.Surface; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var obj = go.Object(0).Object(); - var surface = go.Object(0).Surface(); + RhinoObject obj = go.Object(0).Object(); + Surface surface = go.Object(0).Surface(); if (null == obj || null == surface) return Result.Failure; @@ -34,38 +33,38 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Success; } - var circle = cylinder.CircleAt(0.0); - var plane = circle.Plane; - var origin = plane.Origin; + Circle circle = cylinder.CircleAt(0.0); + Plane plane = circle.Plane; + Point3d origin = plane.Origin; // Calculate a plane-aligned bounding box. // Calculating the bounding box from the runtime object, instead // of a copy of the geometry, will produce a more accurate result. - var world_to_plane = Transform.ChangeBasis(Plane.WorldXY, plane); - var bbox = obj.Geometry.GetBoundingBox(world_to_plane); + Transform world_to_plane = Transform.ChangeBasis(Plane.WorldXY, plane); + BoundingBox bbox = obj.Geometry.GetBoundingBox(world_to_plane); // Move the cylinder's plane to the base of the bounding box. // Create a plane through the base of the bounding box. - var bbox_plane = new Plane( + Plane bbox_plane = new Plane( bbox.Corner(true, true, true), bbox.Corner(false, true, true), bbox.Corner(true, false, true) ); // Transform the plane to the world xy-plane - var plane_to_world = Transform.ChangeBasis(plane, Plane.WorldXY); + Transform plane_to_world = Transform.ChangeBasis(plane, Plane.WorldXY); bbox_plane.Transform(plane_to_world); // Project the cylinder plane's origin onto the bounding box plane plane.Origin = bbox_plane.ClosestPoint(origin); // Cylinder height is bounding box height - var pt0 = bbox.Corner(true, true, true); - var pt1 = bbox.Corner(true, true, false); - var height = pt0.DistanceTo(pt1); + Point3d pt0 = bbox.Corner(true, true, true); + Point3d pt1 = bbox.Corner(true, true, false); + double height = pt0.DistanceTo(pt1); // Create a new cylinder - var new_circle = new Circle(plane, circle.Radius); - var new_cylinder = new Cylinder(new_circle, height); - var rev_surface = new_cylinder.ToRevSurface(); + Circle new_circle = new Circle(plane, circle.Radius); + Cylinder new_cylinder = new Cylinder(new_circle, height); + RevSurface rev_surface = new_cylinder.ToRevSurface(); doc.Objects.AddSurface(rev_surface); doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDeleteMeshFace.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDeleteMeshFace.cs index 604d0039..27996034 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDeleteMeshFace.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDeleteMeshFace.cs @@ -1,11 +1,9 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; -using Rhino.Input; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -62,7 +60,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) face_indices.Add(face_list[0].FaceIndex); while (idx < face_list.Count) { - var next_obj = face_list[idx].MeshObject; + MeshObject next_obj = face_list[idx].MeshObject; if (curr_obj.RuntimeSerialNumber == next_obj.RuntimeSerialNumber) { face_indices.Add(face_list[idx].FaceIndex); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDeleteSubCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDeleteSubCurve.cs index 6bbdc847..d2b7bda3 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDeleteSubCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDeleteSubCurve.cs @@ -1,10 +1,10 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -51,7 +51,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (Math.Abs(t1 - t0) < RhinoMath.ZeroTolerance) return Result.Nothing; - + Interval range = new Interval(t0, t1); if (!crv.IsClosed && range.IsDecreasing) range.Swap(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDetailLock.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDetailLock.cs index 9bd611b5..a4642fc4 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDetailLock.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDetailLock.cs @@ -10,7 +10,7 @@ public class SampleCsDetailLock : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var gd = new GetDetailViewObject(); + GetDetailViewObject gd = new GetDetailViewObject(); gd.SetCommandPrompt("Select detail view"); gd.EnablePreSelect(false, true); gd.DeselectAllBeforePostSelect = false; @@ -18,11 +18,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gd.CommandResult() != Result.Success) return gd.CommandResult(); - var detail_obj = gd.Object(0).Object() as DetailViewObject; + DetailViewObject detail_obj = gd.Object(0).Object() as DetailViewObject; if (null == detail_obj) return Result.Failure; - var detail = detail_obj.DetailGeometry; + Rhino.Geometry.DetailView detail = detail_obj.DetailGeometry; if (null == detail) return Result.Failure; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDrawArrow.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDrawArrow.cs index ee34ae0c..e9d4371a 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDrawArrow.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDrawArrow.cs @@ -1,9 +1,9 @@ -using System.Drawing; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.DocObjects; using Rhino.Geometry; +using System.Drawing; namespace SampleCsCommands { @@ -25,24 +25,24 @@ internal class SampleCsArrowConduit : DisplayConduit { protected override void PostDrawObjects(DrawEventArgs e) { - var points = new[] { new Point3d(2, 2, 0), new Point3d(2, -6, 0), new Point3d(5, -6, 0), new Point3d(5, 2, 0) }; + Point3d[] points = new[] { new Point3d(2, 2, 0), new Point3d(2, -6, 0), new Point3d(5, -6, 0), new Point3d(5, 2, 0) }; e.Display.DrawPolygon(points, Color.Black, false); - var fill = Color.FromArgb(250, Color.White); - var center = new Point3d(2, 2, 0); - var off_x = new Point3d(3, 2, 0); - var off_y = new Point3d(2, 3, 0); - var radius = 3; + Color fill = Color.FromArgb(250, Color.White); + Point3d center = new Point3d(2, 2, 0); + Point3d off_x = new Point3d(3, 2, 0); + Point3d off_y = new Point3d(2, 3, 0); + int radius = 3; e.Display.DrawPoint(center, PointStyle.RoundControlPoint, Color.Black, fill, radius, 1, 0, 0, true, true); - var world_to_screen = e.Viewport.GetTransform(CoordinateSystem.World, CoordinateSystem.Screen); - var center_screen = center; + Transform world_to_screen = e.Viewport.GetTransform(CoordinateSystem.World, CoordinateSystem.Screen); + Point3d center_screen = center; center_screen.Transform(world_to_screen); - var off_screen = off_x; + Point3d off_screen = off_x; off_screen.Transform(world_to_screen); - var xaxis = new Vector3d(off_screen.X - center_screen.X, off_screen.Y - center_screen.Y, 0); - var angle = Vector3d.VectorAngle(Vector3d.XAxis, xaxis); + Vector3d xaxis = new Vector3d(off_screen.X - center_screen.X, off_screen.Y - center_screen.Y, 0); + double angle = Vector3d.VectorAngle(Vector3d.XAxis, xaxis); if (xaxis.Y > 0) angle = -angle; e.Display.DrawPoint(center, PointStyle.ArrowTail, Color.Black, fill, 6, 1, 3, (float)angle, true, true); @@ -50,7 +50,7 @@ protected override void PostDrawObjects(DrawEventArgs e) off_screen = off_y; off_screen.Transform(world_to_screen); - var yaxis = new Vector3d(off_screen.X - center_screen.X, off_screen.Y - center_screen.Y, 0); + Vector3d yaxis = new Vector3d(off_screen.X - center_screen.X, off_screen.Y - center_screen.Y, 0); angle = Vector3d.VectorAngle(Vector3d.YAxis, yaxis); if (yaxis.X < 0) angle = -angle; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDrawDistance.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDrawDistance.cs index f038658b..fffd07ec 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDrawDistance.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDrawDistance.cs @@ -1,10 +1,10 @@ -using System; -using System.Drawing; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System; +using System.Drawing; namespace SampleCsCommands { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDrawGrayscale.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDrawGrayscale.cs index b6921f3a..ae2068e4 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDrawGrayscale.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDrawGrayscale.cs @@ -1,9 +1,9 @@ -using System; -using System.Drawing; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.Input; +using System; +using System.Drawing; namespace SampleCsCommands { @@ -13,11 +13,11 @@ public class SampleCsDrawGrayscale : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var view = doc.Views.ActiveView; + RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; - var conduit = new SampleCsDrawGrayscaleConduit(view.ActiveViewportID) + SampleCsDrawGrayscaleConduit conduit = new SampleCsDrawGrayscaleConduit(view.ActiveViewportID) { Enabled = true }; @@ -58,8 +58,8 @@ protected override void PreDrawObject(DrawObjectEventArgs e) { if (e.Display.Viewport.Id == ViewportId) { - var old_color = e.Display.DisplayPipelineAttributes.ObjectColor; - var new_color = ConvertToGrayscale(old_color); + Color old_color = e.Display.DisplayPipelineAttributes.ObjectColor; + Color new_color = ConvertToGrayscale(old_color); // Works for curves e.Display.DisplayPipelineAttributes.ObjectColor = new_color; } @@ -70,11 +70,11 @@ protected override void PreDrawObject(DrawObjectEventArgs e) /// static Color ConvertToGrayscale(Color color) { - var r = color.R; - var g = color.G; - var b = color.B; - var luma = (int)(r * 0.3 + g * 0.59 + b * 0.11); - var gray = Color.FromArgb(luma, luma, luma); + byte r = color.R; + byte g = color.G; + byte b = color.B; + int luma = (int)(r * 0.3 + g * 0.59 + b * 0.11); + Color gray = Color.FromArgb(luma, luma, luma); return gray; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDrawMesh.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDrawMesh.cs index 5a99a459..dc1949d8 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDrawMesh.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDrawMesh.cs @@ -11,7 +11,7 @@ public class SampleCsDrawMeshConduit : Rhino.Display.DisplayConduit { public Mesh Mesh { get; private set; } public DisplayMaterial Material { get; private set; } - + public SampleCsDrawMeshConduit(Mesh mesh, Material material) { Mesh = mesh; @@ -42,15 +42,15 @@ public class SampleCsDrawMesh : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var sphere = new Sphere(Plane.WorldXY, 10.0); - var mesh = Mesh.CreateFromSphere(sphere, 10, 10); + Sphere sphere = new Sphere(Plane.WorldXY, 10.0); + Mesh mesh = Mesh.CreateFromSphere(sphere, 10, 10); - var mat = new Material + Material mat = new Material { DiffuseColor = System.Drawing.Color.Red }; - var conduit = new SampleCsDrawMeshConduit(mesh, mat) + SampleCsDrawMeshConduit conduit = new SampleCsDrawMeshConduit(mesh, mat) { Enabled = true }; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDrawPin.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDrawPin.cs index 4c2db17b..e675a360 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDrawPin.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDrawPin.cs @@ -1,11 +1,11 @@ -using System.Drawing; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.DocObjects; -using Rhino.Input; using Rhino.Geometry; +using Rhino.Input; +using System.Collections.Generic; +using System.Drawing; namespace SampleCsCommands { @@ -23,22 +23,22 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else { - if (RhinoGet.GetOneObject("Select surface", false, ObjectType.Surface, out var obj) == Result.Success) + if (RhinoGet.GetOneObject("Select surface", false, ObjectType.Surface, out ObjRef obj) == Result.Success) { m_conduit.Points.Clear(); - var surface = obj.Surface(); - var u_domain = surface.Domain(0); + Surface surface = obj.Surface(); + Interval u_domain = surface.Domain(0); u_domain.MakeIncreasing(); - var v_domain = surface.Domain(1); + Interval v_domain = surface.Domain(1); v_domain.MakeIncreasing(); const int count = 10; - for (var i = 0; i < count + 1; i++) + for (int i = 0; i < count + 1; i++) { - for (var j = 0; j < count + 1; j++) + for (int j = 0; j < count + 1; j++) { - var u = u_domain.Min + u_domain.Length * i / count; - var v = v_domain.Min + v_domain.Length * j / count; - var point = surface.PointAt(u, v); + double u = u_domain.Min + u_domain.Length * i / count; + double v = v_domain.Min + v_domain.Length * j / count; + Point3d point = surface.PointAt(u, v); m_conduit.Points.Add(point); } } @@ -58,7 +58,7 @@ internal class SampleCsPinConduit : DisplayConduit protected override void PostDrawObjects(DrawEventArgs e) { - foreach (var point in Points) + foreach (Point3d point in Points) e.Display.DrawPoint(point, PointStyle.Pin, Color.Lavender, Color.Blue, 1, .1f, .4f, 0, false, false); } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDrawRightAlignedText.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDrawRightAlignedText.cs index 9b732179..0300b9ab 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDrawRightAlignedText.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDrawRightAlignedText.cs @@ -1,9 +1,9 @@ -using System.Drawing; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.Geometry; using Rhino.Input.Custom; +using System.Drawing; namespace SampleCsCommands { @@ -27,12 +27,12 @@ protected override void DrawForeground(DrawEventArgs e) { if (e.Viewport.GetScreenPort(out int left, out int right, out int bottom, out int top, out int near, out int far)) { - for (var i = m_strings.Length - 1; i >= 0; i--) + for (int i = m_strings.Length - 1; i >= 0; i--) { - var rect = e.Display.Measure2dText(m_strings[i], new Point2d(0, 0), false, 0.0, 12, "Arial"); - var width = System.Math.Abs(rect.Width); - var height = System.Math.Abs(rect.Height); - var point = new Point2d(right - width - X_GAP, bottom - height - Y_GAP); + Rectangle rect = e.Display.Measure2dText(m_strings[i], new Point2d(0, 0), false, 0.0, 12, "Arial"); + int width = System.Math.Abs(rect.Width); + int height = System.Math.Abs(rect.Height); + Point2d point = new Point2d(right - width - X_GAP, bottom - height - Y_GAP); e.Display.Draw2dText(m_strings[i], Color.Black, point, false, 12, "Arial"); bottom = bottom - height - Y_GAP; } @@ -46,11 +46,11 @@ public class SampleCsDrawRightAlignedText : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var conduit = new SampleCsDrawRightAlignedTextConduit(); + SampleCsDrawRightAlignedTextConduit conduit = new SampleCsDrawRightAlignedTextConduit(); conduit.Enabled = true; doc.Views.Redraw(); - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Press to continue"); gs.AcceptNothing(true); gs.Get(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDrawText.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDrawText.cs index 6246cace..d8ea6127 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDrawText.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDrawText.cs @@ -1,10 +1,9 @@ -using System.Drawing; -using System.Drawing.Drawing2D; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.Geometry; using Rhino.Input.Custom; +using System.Drawing; namespace SampleCsCommands { @@ -28,7 +27,7 @@ protected override void DrawForeground(DrawEventArgs e) string str = "Hello Rhino!"; Rectangle rect = e.Display.Measure2dText(str, new Point2d(0, 0), false, 0.0, 12, "Arial"); - if (rect.Width + (2*X_GAP) < width || rect.Height + (2*Y_GAP) < height) + if (rect.Width + (2 * X_GAP) < width || rect.Height + (2 * Y_GAP) < height) { // Cook up text location (lower right corner of viewport) Point2d point = new Point2d(right - rect.Width - X_GAP, bottom - Y_GAP); @@ -46,11 +45,11 @@ public class SampleCsDrawText : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var conduit = new SampleCsDrawTextConduit(); + SampleCsDrawTextConduit conduit = new SampleCsDrawTextConduit(); conduit.Enabled = true; doc.Views.Redraw(); - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Press to continue"); gs.AcceptNothing(true); gs.Get(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDumpBlockTree.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDumpBlockTree.cs index b2eadca5..cd84ca26 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDumpBlockTree.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDumpBlockTree.cs @@ -10,16 +10,16 @@ public class SampleCsDumpBlockTree : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var idef_table = doc.InstanceDefinitions; - var idef_count = idef_table.ActiveCount; + Rhino.DocObjects.Tables.InstanceDefinitionTable idef_table = doc.InstanceDefinitions; + int idef_count = idef_table.ActiveCount; if (0 == idef_count) { RhinoApp.WriteLine("SampleDumpBlockTree"); return Result.Success; } - var indent = 0; - for (var i = 0; i < idef_count; i++) + int indent = 0; + for (int i = 0; i < idef_count; i++) DumpInstanceDefinition(idef_table[i], ref indent); return Result.Success; @@ -35,18 +35,18 @@ protected void DumpInstanceDefinition(InstanceDefinition idef, ref int indent) const string line = "\u2500"; const string corner = "\u2514"; - var node = (0 == indent) ? line : corner; - var str = new string(' ', indent * 2); + string node = (0 == indent) ? line : corner; + string str = new string(' ', indent * 2); RhinoApp.WriteLine($"{str}{node} Instance definition {idef.Index} = {idef.Name}"); - var idef_object_count = idef.ObjectCount; + int idef_object_count = idef.ObjectCount; if (idef_object_count > 0) { indent++; str = new string(' ', indent * 2); - for (var i = 0; i < idef_object_count; i++) + for (int i = 0; i < idef_object_count; i++) { - var obj = idef.Object(i); + RhinoObject obj = idef.Object(i); if (null != obj) { if (obj is InstanceObject iref) @@ -57,7 +57,7 @@ protected void DumpInstanceDefinition(InstanceDefinition idef, ref int indent) } indent--; } - } + } } } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateBorder.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateBorder.cs index 52fb531a..083d4e43 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateBorder.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateBorder.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; -using Rhino.Input; using Rhino.Geometry; +using Rhino.Input; +using System.Collections.Generic; namespace SampleCsCommands { @@ -13,37 +13,37 @@ public class SampleCsDuplicateBorder : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var filter = ObjectType.Surface | ObjectType.PolysrfFilter; + ObjectType filter = ObjectType.Surface | ObjectType.PolysrfFilter; ObjRef objref; - var rc = RhinoGet.GetOneObject("Select surface or polysurface", false, filter, out objref); + Result rc = RhinoGet.GetOneObject("Select surface or polysurface", false, filter, out objref); if (rc != Result.Success || objref == null) return rc; - var rhobj = objref.Object(); - var brep = objref.Brep(); + RhinoObject rhobj = objref.Object(); + Brep brep = objref.Brep(); if (rhobj == null || brep == null) return Result.Failure; rhobj.Select(false); - var curves = new List(); - foreach (var edge in brep.Edges) + List curves = new List(); + foreach (BrepEdge edge in brep.Edges) { // Find only the naked edges if (edge.Valence == EdgeAdjacency.Naked) { - var crv = edge.DuplicateCurve(); + Curve crv = edge.DuplicateCurve(); if (crv.IsLinear()) crv = new LineCurve(crv.PointAtStart, crv.PointAtEnd); curves.Add(crv); } } - var tol = 2.1 * doc.ModelAbsoluteTolerance; - var output = Curve.JoinCurves(curves, tol); - for (var i = 0; i < output.Length; i++) + double tol = 2.1 * doc.ModelAbsoluteTolerance; + Curve[] output = Curve.JoinCurves(curves, tol); + for (int i = 0; i < output.Length; i++) { - var id = doc.Objects.AddCurve(output[i]); + System.Guid id = doc.Objects.AddCurve(output[i]); doc.Objects.Select(id); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateMeshBorder.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateMeshBorder.cs index 756b32af..2d357cb8 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateMeshBorder.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateMeshBorder.cs @@ -1,7 +1,7 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; +using System; namespace SampleCsCommands { @@ -17,7 +17,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return rc; if (null == objref) return Result.Failure; - + Rhino.Geometry.Mesh mesh = objref.Mesh(); if (null == mesh) return Result.Failure; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateObjectFromNameTag.cs b/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateObjectFromNameTag.cs index 1ed6e787..272ff53c 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateObjectFromNameTag.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsDuplicateObjectFromNameTag.cs @@ -1,12 +1,12 @@ -using System; -using System.Linq; -using System.Text.RegularExpressions; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System; +using System.Linq; +using System.Text.RegularExpressions; namespace SampleCsCommands { @@ -21,7 +21,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) //indexes the copy name as Object A > Object B > Object C. //Ask for a text object that's being used as a name tag - var go = new GetObject() { GeometryFilter = ObjectType.Annotation }; + GetObject go = new GetObject() { GeometryFilter = ObjectType.Annotation }; go.GeometryFilter = ObjectType.Annotation; go.SetCommandPrompt("Select Text with Object Name Function Applied"); go.EnablePreSelect(false, true); @@ -32,7 +32,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) - foreach (var ro in go.Objects().Select(ob => ob.Object()).ToList()) + foreach (RhinoObject ro in go.Objects().Select(ob => ob.Object()).ToList()) { //Deselect our input object and filter out anything that isnt a text annotation @@ -41,33 +41,33 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (!(ro.Geometry is TextEntity te)) continue; //See if the annotation contains the ingredients of a function - var fx = te.RichText; + string fx = te.RichText; if (!fx.Contains("%<") && !fx.Contains(">%")) continue; //Find the original doc object guid that tag function is linked to - var object_id = ExtractGuidFromString(fx); - var isguid = Guid.TryParse(object_id, out Guid obj_guid); + string object_id = ExtractGuidFromString(fx); + bool isguid = Guid.TryParse(object_id, out Guid obj_guid); if (!isguid) continue; //Create a duplicate of the linked text object - var copy_obj = doc.Objects.Find(obj_guid); + RhinoObject copy_obj = doc.Objects.Find(obj_guid); if (copy_obj == null) continue; //Duplicate the original objects geometry and attributes - var duplicate = copy_obj.DuplicateGeometry(); - var attributes = copy_obj.Attributes.Duplicate(); + GeometryBase duplicate = copy_obj.DuplicateGeometry(); + ObjectAttributes attributes = copy_obj.Attributes.Duplicate(); attributes.Name = $"{copy_obj.Name} {GetNextIndexName(obj_guid, ref doc)}"; //Tag the copy with a reference to the original so that we can figure out the next letter index easier attributes.SetUserString(".Dup", obj_guid.ToString()); //Create a duplicate of the object in the doc - var copied_obj_guid = doc.Objects.Add(duplicate, attributes); + Guid copied_obj_guid = doc.Objects.Add(duplicate, attributes); //Create a new tag for the duplicate with updated functions if (!(ro.DuplicateGeometry() is TextEntity dup_text)) continue; dup_text.RichText = ReplaceGuid(dup_text.RichText, copied_obj_guid); - var tag_guid = doc.Objects.Add(dup_text); + Guid tag_guid = doc.Objects.Add(dup_text); //Select the new objects to make moving them easier Guid[] selection = { tag_guid, copied_obj_guid }; @@ -82,8 +82,8 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) private static string GetNextIndexName(Guid originalGuid, ref RhinoDoc doc) { //Search for document objects that have an attribute value that matches the original object id - var count = doc.Objects.Where(c => c.Attributes.GetUserString(".Dup") == originalGuid.ToString()).ToList().Count; - var id = IntToLetters(count + 1); + int count = doc.Objects.Where(c => c.Attributes.GetUserString(".Dup") == originalGuid.ToString()).ToList().Count; + string id = IntToLetters(count + 1); return id; } @@ -91,7 +91,7 @@ private static string GetNextIndexName(Guid originalGuid, ref RhinoDoc doc) private static string IntToLetters(int value) { //Convert an int based index to A B C D index - var result = string.Empty; + string result = string.Empty; while (--value >= 0) { result = (char)('A' + value % 26) + result; @@ -103,28 +103,28 @@ private static string IntToLetters(int value) private static string ExtractGuidFromString(string inputstring) { //Find the frist GUID nestled within a string - var guids = Regex + System.Collections.Generic.IEnumerable guids = Regex .Matches(inputstring, @"(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}") .Cast().Select(m => m.Value); - var enumerable = guids as string[] ?? guids.ToArray(); + string[] enumerable = guids as string[] ?? guids.ToArray(); return !enumerable.Any() ? string.Empty : enumerable.First(); } private static string ReplaceGuid(string inputstring, Guid replacementguid) { //Replace a GUID or GUIDS within a string - var guids = Regex + System.Collections.Generic.IEnumerable guids = Regex .Matches(inputstring, @"(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}") .Cast().Select(m => m.Value); - var enumerable = guids as string[] ?? guids.ToArray(); + string[] enumerable = guids as string[] ?? guids.ToArray(); if (!enumerable.Any()) { return inputstring; } - var replace = inputstring; - foreach (var match in enumerable) + string replace = inputstring; + foreach (string match in enumerable) replace = inputstring.Replace(match, replacementguid.ToString()); return replace; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsEditPolyline.cs b/rhinocommon/cs/SampleCsCommands/SampleCsEditPolyline.cs index ffd822b0..cb35f263 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsEditPolyline.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsEditPolyline.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; @@ -13,7 +12,7 @@ public class SampleCsEditPolyline : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetPolylineCurve(); + GetPolylineCurve go = new GetPolylineCurve(); go.SetCommandPrompt("Select polyline"); go.GeometryFilter = ObjectType.Curve; go.SubObjectSelect = false; @@ -22,20 +21,20 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return go.CommandResult(); // Get underlying curve geometry - var polyline_curve = go.Object(0).Geometry() as PolylineCurve; + PolylineCurve polyline_curve = go.Object(0).Geometry() as PolylineCurve; if (null == polyline_curve) return Result.Failure; // Make a copy of the geometry - var new_polyline_curve = polyline_curve.DuplicateCurve() as PolylineCurve; + PolylineCurve new_polyline_curve = polyline_curve.DuplicateCurve() as PolylineCurve; if (null == new_polyline_curve) return Result.Failure; // Modify the geometry in some way - for (var i = 0; i < new_polyline_curve.PointCount; i++) + for (int i = 0; i < new_polyline_curve.PointCount; i++) { - var point = new_polyline_curve.Point(i); - if (i%2 != 0) + Point3d point = new_polyline_curve.Point(i); + if (i % 2 != 0) { point.X += 1; point.Y += 1; @@ -63,7 +62,7 @@ internal class GetPolylineCurve : GetObject { public override bool CustomGeometryFilter(RhinoObject obj, GeometryBase geom, ComponentIndex ci) { - var polyline_curve = geom as PolylineCurve; + PolylineCurve polyline_curve = geom as PolylineCurve; return polyline_curve != null; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsEmbedTextFile.cs b/rhinocommon/cs/SampleCsCommands/SampleCsEmbedTextFile.cs index 5e92b468..ca6ffd9e 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsEmbedTextFile.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsEmbedTextFile.cs @@ -1,9 +1,9 @@ -using System; -using System.IO; -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Input; +using System; +using System.IO; +using System.Windows.Forms; namespace SampleCsCommands { @@ -19,7 +19,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) string path = null; if (mode == RunMode.Interactive) { - var dialog = new OpenFileDialog + OpenFileDialog dialog = new OpenFileDialog { Title = EnglishName, Filter = @"Text Documents|*.txt" @@ -32,7 +32,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else { - var rc = RhinoGet.GetString("Name of file to embed", false, ref path); + Result rc = RhinoGet.GetString("Name of file to embed", false, ref path); if (rc != Result.Success) return rc; } @@ -64,7 +64,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Nothing; } - var fname = Path.GetFileName(path); + string fname = Path.GetFileName(path); doc.Strings.SetString(fname, text); RhinoApp.Write("Embedded {0} ({1} characters)", fname, text.Length); @@ -83,7 +83,7 @@ public class SampleCsExtractTextFile : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { string fname = null; - var rc = RhinoGet.GetString("Name of file to extract", false, ref fname); + Result rc = RhinoGet.GetString("Name of file to extract", false, ref fname); if (rc != Result.Success) return rc; @@ -91,7 +91,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (string.IsNullOrEmpty(fname)) return Result.Nothing; - var text = doc.Strings.GetValue(fname); + string text = doc.Strings.GetValue(fname); if (string.IsNullOrEmpty(text)) { RhinoApp.WriteLine("File not found."); @@ -101,7 +101,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) string path = null; if (mode == RunMode.Interactive) { - var dialog = new SaveFileDialog + SaveFileDialog dialog = new SaveFileDialog { Title = EnglishName, Filter = @"Text Documents|*.txt", diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsEscapeKey.cs b/rhinocommon/cs/SampleCsCommands/SampleCsEscapeKey.cs index 8c93ba83..67515d9f 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsEscapeKey.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsEscapeKey.cs @@ -1,6 +1,6 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; +using System; namespace SampleCsCommands { @@ -27,7 +27,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Add our escape key event handler RhinoApp.EscapeKeyPressed += RhinoApp_EscapeKeyPressed; - for (var i = 0; i < 10000; i++) + for (int i = 0; i < 10000; i++) { // Pauses to keep Windows message pump alive RhinoApp.Wait(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsEscapeKey2.cs b/rhinocommon/cs/SampleCsCommands/SampleCsEscapeKey2.cs index 1e946d58..b92903d3 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsEscapeKey2.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsEscapeKey2.cs @@ -1,6 +1,6 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; +using System; namespace SampleCsCommands { @@ -50,9 +50,9 @@ public SampleCsEscapeKey2() protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var handler = new EscapeKeyEventHandler("Press to cancel"); + EscapeKeyEventHandler handler = new EscapeKeyEventHandler("Press to cancel"); - for (var i = 0; i < 1000; i++) + for (int i = 0; i < 1000; i++) { if (handler.EscapeKeyPressed) { @@ -60,10 +60,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) break; } - var x = (double)m_random.Next(0, 100); - var y = (double)m_random.Next(0, 100); - var z = (double)m_random.Next(0, 100); - var pt = new Rhino.Geometry.Point3d(x, y, z); + double x = (double)m_random.Next(0, 100); + double y = (double)m_random.Next(0, 100); + double z = (double)m_random.Next(0, 100); + Rhino.Geometry.Point3d pt = new Rhino.Geometry.Point3d(x, y, z); doc.Objects.AddPoint(pt); doc.Views.Redraw(); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsExplodeBlock.cs b/rhinocommon/cs/SampleCsCommands/SampleCsExplodeBlock.cs index 7c9a7cdc..c5d986e6 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsExplodeBlock.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsExplodeBlock.cs @@ -1,19 +1,19 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { public class SampleCsExplodeBlock : Command { - public override string EnglishName => "SampleCsExplodeBlock"; + public override string EnglishName => "SampleCsExplodeBlock"; protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select block to explode"); go.GeometryFilter = ObjectType.InstanceReference; go.Get(); @@ -23,8 +23,8 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (!(go.Object(0).Object() is InstanceObject iref)) return Result.Failure; - var xform = Transform.Identity; - var rc = ExplodeBlockHelper(doc, iref, xform); + Transform xform = Transform.Identity; + bool rc = ExplodeBlockHelper(doc, iref, xform); if (rc) { doc.Objects.Delete(go.Object(0), false); @@ -36,18 +36,18 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) protected bool ExplodeBlockHelper(RhinoDoc doc, InstanceObject iref, Transform xf) { - var idef = iref?.InstanceDefinition; + InstanceDefinition idef = iref?.InstanceDefinition; if (idef == null) return false; - var xform = xf * iref.InstanceXform; - var do_xform = (xform.IsValid && !xform.Equals(Transform.Identity)); + Transform xform = xf * iref.InstanceXform; + bool do_xform = (xform.IsValid && !xform.Equals(Transform.Identity)); - var atts = iref.Attributes.Duplicate(); + ObjectAttributes atts = iref.Attributes.Duplicate(); atts.ObjectId = Guid.Empty; - var objects = idef.GetObjects(); - foreach (var obj in objects) + RhinoObject[] objects = idef.GetObjects(); + foreach (RhinoObject obj in objects) { if (null == obj) continue; @@ -59,7 +59,7 @@ protected bool ExplodeBlockHelper(RhinoDoc doc, InstanceObject iref, Transform x continue; } - var geom = obj.DuplicateGeometry(); + GeometryBase geom = obj.DuplicateGeometry(); if (do_xform) { // Check for non-uniform scaling @@ -79,12 +79,12 @@ protected bool ExplodeBlockHelper(RhinoDoc doc, InstanceObject iref, Transform x { if (geom.ObjectType == ObjectType.Brep) { - var brep = geom as Brep; + Brep brep = geom as Brep; brep?.Flip(); } else if (geom.ObjectType == ObjectType.Mesh) { - var mesh = geom as Mesh; + Mesh mesh = geom as Mesh; mesh?.Flip(true, true, true); } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsExplodeHatch.cs b/rhinocommon/cs/SampleCsCommands/SampleCsExplodeHatch.cs index 4c8dd7d5..f71dc28d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsExplodeHatch.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsExplodeHatch.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsExplodePolyCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsExplodePolyCurve.cs index e4f6976d..502efc12 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsExplodePolyCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsExplodePolyCurve.cs @@ -1,6 +1,4 @@ -using System; -using System.Text; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; @@ -46,7 +44,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) Curve curve = go.Object(0).Curve(); if (null == curve) return Result.Failure; - + PolyCurve poly_curve = curve as PolyCurve; if (null == poly_curve) return Result.Failure; @@ -58,7 +56,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) doc.Objects.Delete(go.Object(0), false); doc.Views.Redraw(); - + return Result.Success; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsExportDXF.cs b/rhinocommon/cs/SampleCsCommands/SampleCsExportDXF.cs index e8308c53..fde4cf44 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsExportDXF.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsExportDXF.cs @@ -1,8 +1,8 @@ -using System.IO; -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Input.Custom; +using System.IO; +using System.Windows.Forms; namespace SampleCsCommands { @@ -14,7 +14,7 @@ public class SampleCsExportDXF : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects to export"); go.GroupSelect = true; go.GetMultiple(1, 0); @@ -24,7 +24,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) string path; if (mode == RunMode.Interactive) { - var savefile = new SaveFileDialog + SaveFileDialog savefile = new SaveFileDialog { FileName = @"Untitled.dxf", Filter = @"AutoCAD Drawing Exchange (*.dxf)|*.dxf||" @@ -36,7 +36,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else { - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Name of AutoCAD Drawing Exchange file to save"); gs.Get(); if (gs.CommandResult() != Result.Success) @@ -56,7 +56,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // string contains spaces, we will want to surround the string // with double-quote characters so the command line parser // will deal with it property. - var script = $"_-Export \"{path}\" _Enter"; + string script = $"_-Export \"{path}\" _Enter"; RhinoApp.RunScript(script, false); return Result.Success; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsExportSvgWithDialog.cs b/rhinocommon/cs/SampleCsCommands/SampleCsExportSvgWithDialog.cs index 1ad084e8..60b69c44 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsExportSvgWithDialog.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsExportSvgWithDialog.cs @@ -1,9 +1,9 @@ -using System; -using Eto.Forms; +using Eto.Forms; using Rhino; using Rhino.Commands; -using Rhino.UI.Forms; using Rhino.UI; +using Rhino.UI.Forms; +using System; using Command = Rhino.Commands.Command; namespace SampleCsCommands @@ -18,9 +18,9 @@ public class SampleCsExportSvgWithDialog : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - + //Create an ETO file save dialog - var save_dialog = new Eto.Forms.SaveFileDialog() + Eto.Forms.SaveFileDialog save_dialog = new Eto.Forms.SaveFileDialog() { CheckFileExists = false, Title = "Export SVG" @@ -31,21 +31,21 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) save_dialog.CurrentFilter = save_dialog.Filters[0]; //Show the file save dialog - var result = save_dialog.ShowDialog(RhinoEtoApp.MainWindow); + DialogResult result = save_dialog.ShowDialog(RhinoEtoApp.MainWindow); if (result != DialogResult.Ok) return Result.Cancel; //The previous Print dialog settings are stored in the Commands.rhp plug-in. We can get its previous settings directly from the plug-in. - Guid.TryParse("02bf604d-799c-4cc2-830e-8d72f21b14b7", out var commands_id); - + Guid.TryParse("02bf604d-799c-4cc2-830e-8d72f21b14b7", out Guid commands_id); + //Show the Print Dialog configured for SVG export. - var svg_export_view_capture_settings = PrintDialogUi.EtoExportSvg(doc.RuntimeSerialNumber, PersistentSettings.FromPlugInId(commands_id)); + Rhino.Display.ViewCaptureSettings svg_export_view_capture_settings = PrintDialogUi.EtoExportSvg(doc.RuntimeSerialNumber, PersistentSettings.FromPlugInId(commands_id)); if (svg_export_view_capture_settings == null) return Result.Cancel; //Get the SVG Xml settings from the ViewCapture. - var capture_to_svg = Rhino.Display.ViewCapture.CaptureToSvg(svg_export_view_capture_settings); + System.Xml.XmlDocument capture_to_svg = Rhino.Display.ViewCapture.CaptureToSvg(svg_export_view_capture_settings); if (capture_to_svg == null) return Result.Cancel; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsExtractInflectionPoints.cs b/rhinocommon/cs/SampleCsCommands/SampleCsExtractInflectionPoints.cs index 7707ef51..a52f6bc5 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsExtractInflectionPoints.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsExtractInflectionPoints.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -13,19 +13,19 @@ public class SampleCsExtractInflectionPoints : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select curves to extract inflection points"); go.GeometryFilter = ObjectType.Curve; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var curve = go.Object(i).Curve(); + Curve curve = go.Object(i).Curve(); if (null != curve) { - var points = new List(); + List points = new List(); if (GetInflectionPoints(curve, points)) doc.Objects.AddPoints(points); } @@ -40,23 +40,23 @@ public static bool GetInflectionPoints(Curve curve, List points) { const double on_zero_tolerance = 2.3283064365386962890625e-10; - var nurb = curve?.ToNurbsCurve(); + NurbsCurve nurb = curve?.ToNurbsCurve(); if (nurb == null) return false; - var count = nurb.Points.Count * 4; - var mul = 1.0 / count; - var epsilon = nurb.Domain.Length > 1.0 + int count = nurb.Points.Count * 4; + double mul = 1.0 / count; + double epsilon = nurb.Domain.Length > 1.0 ? on_zero_tolerance : nurb.Domain.Length * on_zero_tolerance; - var t0 = 0.0; + double t0 = 0.0; Vector3d k0 = Vector3d.Unset; - var start_set = false; - for (var i = 0; i <= count; i++) + bool start_set = false; + for (int i = 0; i <= count; i++) { - var t1 = nurb.Domain.ParameterAt(i * mul); - var k1 = nurb.CurvatureAt(t1); + double t1 = nurb.Domain.ParameterAt(i * mul); + Vector3d k1 = nurb.CurvatureAt(t1); if (k1.IsValid) { if (k1.IsTiny()) @@ -72,7 +72,7 @@ public static bool GetInflectionPoints(Curve curve, List points) if (k0 * k1 < 0.0) { - if (FindInflection(nurb, t0, t1, k0, k1, epsilon, out var pt)) + if (FindInflection(nurb, t0, t1, k0, k1, epsilon, out Point3d pt)) points.Add(pt); } @@ -91,11 +91,11 @@ private static bool FindInflection(NurbsCurve nurb, double t0, double t1, Vector if (null == nurb) return false; - var rc = false; + bool rc = false; for (; ; ) { - var t = (t0 + t1) * 0.5; - var k = nurb.CurvatureAt(t); + double t = (t0 + t1) * 0.5; + Vector3d k = nurb.CurvatureAt(t); if (!k.IsValid) break; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsExtractMinMaxRadiusPoints.cs b/rhinocommon/cs/SampleCsCommands/SampleCsExtractMinMaxRadiusPoints.cs index 4bd546ca..8d08101e 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsExtractMinMaxRadiusPoints.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsExtractMinMaxRadiusPoints.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -13,19 +13,19 @@ public class SampleCsExtractMinMaxRadiusPoints : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select curves to extract min/max radius points"); go.GeometryFilter = ObjectType.Curve; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var curve = go.Object(i).Curve(); + Curve curve = go.Object(i).Curve(); if (null != curve) { - var points = new List(); + List points = new List(); if (GetMinMaxRadiusPoints(curve, points)) doc.Objects.AddPoints(points); } @@ -38,60 +38,60 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) public static bool GetMinMaxRadiusPoints(Curve curve, List points) { - var nurb = curve?.ToNurbsCurve(); + NurbsCurve nurb = curve?.ToNurbsCurve(); if (nurb == null) return false; - var start_count = points.Count; - var count = nurb.Points.Count * 8; - var mul = 1.0 / count; - var epsilon = nurb.Domain.Length > 1.0 - ? RhinoMath.ZeroTolerance + int start_count = points.Count; + int count = nurb.Points.Count * 8; + double mul = 1.0 / count; + double epsilon = nurb.Domain.Length > 1.0 + ? RhinoMath.ZeroTolerance : nurb.Domain.Length * RhinoMath.ZeroTolerance; - var t0 = 0.0; - var t1 = 0.0; - var kk0 = 0.0; - var kk1 = 0.0; - for (var i = 0; i <= count; i++) + double t0 = 0.0; + double t1 = 0.0; + double kk0 = 0.0; + double kk1 = 0.0; + for (int i = 0; i <= count; i++) { - var t2 = nurb.Domain.ParameterAt(i * mul); - var k = nurb.CurvatureAt(t2); + double t2 = nurb.Domain.ParameterAt(i * mul); + Vector3d k = nurb.CurvatureAt(t2); if (k.IsValid) { - var kk2 = k * k; - var bLeft = kk0 < kk1 - RhinoMath.ZeroTolerance; - var bRight = kk2 < kk1 - RhinoMath.ZeroTolerance; + double kk2 = k * k; + bool bLeft = kk0 < kk1 - RhinoMath.ZeroTolerance; + bool bRight = kk2 < kk1 - RhinoMath.ZeroTolerance; if (bLeft && bRight) { - if (FindMinRadius(nurb, t0, t2, kk1, epsilon, out var pt)) + if (FindMinRadius(nurb, t0, t2, kk1, epsilon, out Point3d pt)) points.Add(pt); } else if (bLeft && kk2 < kk1 + RhinoMath.ZeroTolerance) { - var t = nurb.Domain.ParameterAt((t1 + t2) * 0.5); + double t = nurb.Domain.ParameterAt((t1 + t2) * 0.5); k = nurb.CurvatureAt(t); if (k.IsValid) { double kk = k * k; if (kk1 < kk - RhinoMath.ZeroTolerance) { - if (FindMinRadius(nurb, t1, t2, kk, epsilon, out var pt)) + if (FindMinRadius(nurb, t1, t2, kk, epsilon, out Point3d pt)) points.Add(pt); } } } else if (bRight && kk0 < kk1 + RhinoMath.ZeroTolerance) { - var t = nurb.Domain.ParameterAt((t0 + t1) * 0.5); + double t = nurb.Domain.ParameterAt((t0 + t1) * 0.5); k = nurb.CurvatureAt(t); if (k.IsValid) { - var kk = k * k; + double kk = k * k; if (kk1 < kk - RhinoMath.ZeroTolerance) { - if (FindMinRadius(nurb, t0, t1, kk, epsilon, out var pt)) + if (FindMinRadius(nurb, t0, t1, kk, epsilon, out Point3d pt)) points.Add(pt); } } @@ -112,35 +112,35 @@ private static bool FindMinRadius(NurbsCurve nurb, double t0, double t1, double { pt = Point3d.Unset; - var done = false; + bool done = false; if (null == nurb) return false; - for (var i = 0; i < 1000; i++) + for (int i = 0; i < 1000; i++) { Vector3d k; if (done || t1 - t0 < epsilon) { - var t = (t0 + t1) * 0.5; + double t = (t0 + t1) * 0.5; k = nurb.CurvatureAt(t); pt = nurb.PointAt(t); return k.IsValid; } - var tl = t0 * 0.75 + t1 * 0.25; + double tl = t0 * 0.75 + t1 * 0.25; k = nurb.CurvatureAt(tl); if (!k.IsValid) break; done = tl == t0; - var kkl = k * k; + double kkl = k * k; - var tr = t0 * 0.25 + t1 * 0.75; + double tr = t0 * 0.25 + t1 * 0.75; k = nurb.CurvatureAt(tr); if (!k.IsValid) break; done = tr == t1; - var kkr = k * k; + double kkr = k * k; if (kkl > kkr && kkl > kk) { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsExtractPreview.cs b/rhinocommon/cs/SampleCsCommands/SampleCsExtractPreview.cs index 968d5201..41ebdc04 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsExtractPreview.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsExtractPreview.cs @@ -1,9 +1,7 @@ -using System; +using Rhino; +using Rhino.Commands; using System.IO; -using System.Windows; using System.Windows.Forms; -using Rhino; -using Rhino.Commands; namespace SampleCsCommands { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsExtrudeMeshFace.cs b/rhinocommon/cs/SampleCsCommands/SampleCsExtrudeMeshFace.cs index fcd6f7eb..8b9bdd77 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsExtrudeMeshFace.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsExtrudeMeshFace.cs @@ -13,7 +13,7 @@ public class SampleCsExtrudeMeshFace : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Select a mesh - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select mesh face to extrude"); go.GeometryFilter = ObjectType.MeshFace; go.Get(); @@ -21,23 +21,23 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return go.CommandResult(); // Get the selected object reference - var objref = go.Object(0); - var rh_obj = objref.Object(); + ObjRef objref = go.Object(0); + RhinoObject rh_obj = objref.Object(); if (null == rh_obj) return Result.Failure; // Get the base mesh - var mesh = objref.Mesh(); + Mesh mesh = objref.Mesh(); if (null == mesh) return Result.Failure; // Get the selected component - var ci = objref.GeometryComponentIndex; + ComponentIndex ci = objref.GeometryComponentIndex; if (ComponentIndexType.MeshFace != ci.ComponentIndexType) return Result.Failure; // Copy the mesh geometry - var mesh_copy = mesh.DuplicateMesh(); + Mesh mesh_copy = mesh.DuplicateMesh(); // Make sure the mesh has normals if (mesh_copy.FaceNormals.Count != mesh_copy.Faces.Count) @@ -46,33 +46,33 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) mesh_copy.Normals.ComputeNormals(); // Get the mesh face - var face = mesh_copy.Faces[ci.Index]; + MeshFace face = mesh_copy.Faces[ci.Index]; // Get the mesh face vertices - var base_vertices = new Point3d[4]; - for (var i = 0; i < 4; i++) + Point3d[] base_vertices = new Point3d[4]; + for (int i = 0; i < 4; i++) base_vertices[i] = mesh_copy.Vertices[face[i]]; // Get the face normal and scale it by 5.0 - var offset = mesh_copy.FaceNormals[ci.Index] * (float)5.0; + Vector3f offset = mesh_copy.FaceNormals[ci.Index] * (float)5.0; // Calculate the offset vertices - var offset_vertices = new Point3d[4]; - for (var i = 0; i < 4; i++) + Point3d[] offset_vertices = new Point3d[4]; + for (int i = 0; i < 4; i++) offset_vertices[i] = base_vertices[i] + offset; // Delete the mesh face - var faces_indices = new int[] { ci.Index }; + int[] faces_indices = new int[] { ci.Index }; mesh_copy.Faces.DeleteFaces(faces_indices); // Add the base mesh face vertices - var base_indices = new int[4]; - for (var i = 0; i < 4; i++) + int[] base_indices = new int[4]; + for (int i = 0; i < 4; i++) base_indices[i] = mesh_copy.Vertices.Add(base_vertices[i]); // Add the offset mesh face vertices - var offset_indices = new int[4]; - for (var i = 0; i < 4; i++) + int[] offset_indices = new int[4]; + for (int i = 0; i < 4; i++) offset_indices[i] = mesh_copy.Vertices.Add(offset_vertices[i]); // Add the new mesh faces diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsExtrusion.cs b/rhinocommon/cs/SampleCsCommands/SampleCsExtrusion.cs index 8d5c6a1d..5543367b 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsExtrusion.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsExtrusion.cs @@ -1,9 +1,9 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -13,7 +13,7 @@ public class SampleCsExtrusion : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var get_outer = new GetObject(); + GetObject get_outer = new GetObject(); get_outer.SetCommandPrompt("Outer profile curve"); get_outer.GeometryFilter = ObjectType.Curve; get_outer.SubObjectSelect = false; @@ -21,11 +21,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (get_outer.CommandResult() != Result.Success) return get_outer.CommandResult(); - var outer = get_outer.Object(0).Curve(); + Curve outer = get_outer.Object(0).Curve(); if (null == outer) return Result.Failure; - var get_inner = new GetObject(); + GetObject get_inner = new GetObject(); get_inner.SetCommandPrompt("Inner profile curve"); get_inner.GeometryFilter = ObjectType.Curve; get_inner.SubObjectSelect = false; @@ -35,16 +35,16 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (get_inner.CommandResult() != Result.Success) return get_outer.CommandResult(); - var inners = new Curve[get_inner.ObjectCount]; - for (var i = 0; i < get_inner.ObjectCount; i++) + Curve[] inners = new Curve[get_inner.ObjectCount]; + for (int i = 0; i < get_inner.ObjectCount; i++) { - var inner = get_inner.Object(i).Curve(); + Curve inner = get_inner.Object(i).Curve(); if (null == inner) return Result.Failure; inners[i] = inner; } - var extrusion = CreateExtrusion(outer, inners, 10); + Extrusion extrusion = CreateExtrusion(outer, inners, 10); if (null != extrusion) { doc.Objects.AddExtrusion(extrusion); @@ -63,7 +63,7 @@ protected Extrusion CreateExtrusion(Curve outerProfile, Curve[] innerProfiles, d if (!outerProfile.TryGetPlane(out plane)) return null; - var path = new Line + Line path = new Line { From = plane.PointAt(0.0, 0.0, 0.0), To = plane.PointAt(0.0, 0.0, height) @@ -71,22 +71,22 @@ protected Extrusion CreateExtrusion(Curve outerProfile, Curve[] innerProfiles, d if (!path.IsValid || !(path.Length > RhinoMath.ZeroTolerance)) return null; - var up = plane.YAxis; - var tangent = path.To - path.From; + Vector3d up = plane.YAxis; + Vector3d tangent = path.To - path.From; tangent.Unitize(); if (!up.IsValid || !up.IsUnitVector || Math.Abs(up * tangent) > RhinoMath.SqrtEpsilon) return null; - var xform = Transform.ChangeBasis(Plane.WorldXY, plane); + Transform xform = Transform.ChangeBasis(Plane.WorldXY, plane); - var curve = outerProfile.DuplicateCurve(); + Curve curve = outerProfile.DuplicateCurve(); curve.Transform(xform); curve.ChangeDimension(2); - var extrusion = new Extrusion(); + Extrusion extrusion = new Extrusion(); extrusion.SetOuterProfile(curve, true); - foreach (var profile in innerProfiles) + foreach (Curve profile in innerProfiles) { Plane curve_plane; if (profile.TryGetPlane(out curve_plane)) @@ -120,8 +120,8 @@ public static bool IsCoplanar(this Plane plane, Plane testPlane, double toleranc if (tolerance < RhinoMath.ZeroTolerance) tolerance = RhinoMath.ZeroTolerance; - var eq0 = plane.GetPlaneEquation(); - var eq1 = testPlane.GetPlaneEquation(); + double[] eq0 = plane.GetPlaneEquation(); + double[] eq1 = testPlane.GetPlaneEquation(); return Math.Abs(eq0[0] - eq1[0]) < tolerance && Math.Abs(eq0[1] - eq1[1]) < tolerance && diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsFaceWithHole.cs b/rhinocommon/cs/SampleCsCommands/SampleCsFaceWithHole.cs index e2897373..1665b97a 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsFaceWithHole.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsFaceWithHole.cs @@ -10,7 +10,7 @@ public class SampleCsFaceWithHole : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var brep = MakeBrepFace(); + Brep brep = MakeBrepFace(); if (null == brep) return Result.Failure; @@ -47,7 +47,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) public static Brep MakeBrepFace() { // Define the vertices - var points = new Point3d[8]; + Point3d[] points = new Point3d[8]; points[A] = new Point3d(0.0, 0.0, 0.0); // point A = geometry for vertex 0 points[B] = new Point3d(10.0, 0.0, 0.0); // point B = geometry for vertex 1 points[C] = new Point3d(10.0, 10.0, 0.0); // point C = geometry for vertex 2 @@ -59,10 +59,10 @@ public static Brep MakeBrepFace() points[H] = new Point3d(8.0, 8.0, 0.0); // point H = geometry for vertex 7 // Create the Brep - var brep = new Brep(); + Brep brep = new Brep(); // Create four vertices of the outer edges - for (var vi = 0; vi < 8; vi++) + for (int vi = 0; vi < 8; vi++) { // This simple example is exact - for models with // non-exact data, set tolerance as explained in @@ -96,7 +96,7 @@ public static Brep MakeBrepFace() #if DEBUG string tlog; - var rc = brep.IsValidTopology(out tlog); + bool rc = brep.IsValidTopology(out tlog); if (!rc) { RhinoApp.WriteLine(tlog); @@ -154,7 +154,7 @@ public static Brep MakeBrepFace() private static Curve CreateLinearCurve(Point3d start, Point3d end) { // Creates a 3d line segment to be used as a 3d curve in a Brep - var curve = new LineCurve(start, end) { Domain = new Interval(0.0, 10.0) }; + LineCurve curve = new LineCurve(start, end) { Domain = new Interval(0.0, 10.0) }; return curve; } @@ -168,7 +168,7 @@ private static Curve CreateLinearCurve(Point3d start, Point3d end) /// The surface if successful, null otherwise private static Surface CreateNurbsSurface(Point3d sw, Point3d se, Point3d ne, Point3d nw) { - var nurb = NurbsSurface.Create( + NurbsSurface nurb = NurbsSurface.Create( 3, // dimension (>= 1) false, // not rational 2, // "u" order (>= 2) @@ -203,8 +203,8 @@ private static Surface CreateNurbsSurface(Point3d sw, Point3d se, Point3d ne, Po /// Index of the 3d curve private static void CreateOneEdge(Brep brep, int vi0, int vi1, int c3i) { - var start_vertex = brep.Vertices[vi0]; - var end_vertex = brep.Vertices[vi1]; + BrepVertex start_vertex = brep.Vertices[vi0]; + BrepVertex end_vertex = brep.Vertices[vi1]; // This simple example is exact - for models with // non-exact data, set tolerance as explained in @@ -273,11 +273,11 @@ private static Curve CreateOuterTrimmingCurve(Surface surface, int side) // In this case, trim curves lie on the four edges of the surface - var domain_u = surface.Domain(0); - var domain_v = surface.Domain(1); + Interval domain_u = surface.Domain(0); + Interval domain_v = surface.Domain(1); - var start = new Point2d(); - var end = new Point2d(); + Point2d start = new Point2d(); + Point2d end = new Point2d(); switch (side) { @@ -309,7 +309,7 @@ private static Curve CreateOuterTrimmingCurve(Surface surface, int side) return null; } - var curve = new LineCurve(start, end) { Domain = new Interval(0.0, 1.0) }; + LineCurve curve = new LineCurve(start, end) { Domain = new Interval(0.0, 1.0) }; return curve; } @@ -341,10 +341,10 @@ private static int MakeOuterTrimmingLoop( int eWDir ) { - var surface = brep.Surfaces[face.SurfaceIndex]; + Surface surface = brep.Surfaces[face.SurfaceIndex]; // Create new loop - var loop = brep.Loops.Add(BrepLoopType.Outer, face); + BrepLoop loop = brep.Loops.Add(BrepLoopType.Outer, face); // Create trimming curves running counter clockwise around the // surface's domain. Note that trims of outer loops run counter @@ -356,17 +356,17 @@ int eWDir // y_iso and x_iso respectfully. // Start at the south side - for (var side = 0; side < 4; side++) + for (int side = 0; side < 4; side++) { // side: 0=south, 1=east, 2=north, 3=west - var curve = CreateOuterTrimmingCurve(surface, side); + Curve curve = CreateOuterTrimmingCurve(surface, side); // Add trimming curve to brep trimming curves array - var c2i = brep.Curves2D.Add(curve); + int c2i = brep.Curves2D.Add(curve); - var ei = 0; - var reverse = false; - var iso = IsoStatus.None; + int ei = 0; + bool reverse = false; + IsoStatus iso = IsoStatus.None; switch (side) { @@ -394,7 +394,7 @@ int eWDir // Create new trim topology that references edge, direction // reletive to edge, loop and trim curve geometry - var trim = brep.Trims.Add(brep.Edges[ei], reverse, loop, c2i); + BrepTrim trim = brep.Trims.Add(brep.Edges[ei], reverse, loop, c2i); trim.IsoStatus = iso; // This one Brep face, so all trims are boundary ones. @@ -423,19 +423,19 @@ private static Curve CreateInnerTrimmingCurve(Surface surface, int side) // clockwise around the region the hole. // In this case, trim curves lie with 0.2 domain distance from surface edge - var domain_u = surface.Domain(0); - var domain_v = surface.Domain(1); + Interval domain_u = surface.Domain(0); + Interval domain_v = surface.Domain(1); - var du = 0.2 * (domain_u.T1 - domain_u.T0); - var dv = 0.2 * (domain_v.T1 - domain_v.T0); + double du = 0.2 * (domain_u.T1 - domain_u.T0); + double dv = 0.2 * (domain_v.T1 - domain_v.T0); domain_u.T0 += du; domain_u.T1 -= du; domain_v.T0 += dv; domain_v.T1 -= dv; - var start = new Point2d(); - var end = new Point2d(); + Point2d start = new Point2d(); + Point2d end = new Point2d(); switch (side) { @@ -467,7 +467,7 @@ private static Curve CreateInnerTrimmingCurve(Surface surface, int side) return null; } - var curve = new LineCurve(start, end) { Domain = new Interval(0.0, 1.0) }; + LineCurve curve = new LineCurve(start, end) { Domain = new Interval(0.0, 1.0) }; return curve; } @@ -499,10 +499,10 @@ private static int MakeInnerTrimmingLoop( int eWDir ) { - var surface = brep.Surfaces[face.SurfaceIndex]; + Surface surface = brep.Surfaces[face.SurfaceIndex]; // Create new inner loop - var loop = brep.Loops.Add(BrepLoopType.Inner, face); + BrepLoop loop = brep.Loops.Add(BrepLoopType.Inner, face); // Create trimming curves running counter clockwise around the // surface's domain. Note that trims of outer loops run counter @@ -514,19 +514,19 @@ int eWDir // y_iso and x_iso respectfully. // Start near the south side - for (var side = 0; side < 4; side++) + for (int side = 0; side < 4; side++) { // side: 0=near south(y_iso), 1=near west(x_iso), 2=near north(y_iso), 3=near east(x_iso) // Create trim 2d curve - var curve = CreateInnerTrimmingCurve(surface, side); + Curve curve = CreateInnerTrimmingCurve(surface, side); // Add trimming curve to brep trimming curves array - var c2i = brep.Curves2D.Add(curve); + int c2i = brep.Curves2D.Add(curve); - var ei = 0; - var reverse = false; - var iso = IsoStatus.None; + int ei = 0; + bool reverse = false; + IsoStatus iso = IsoStatus.None; switch (side) { @@ -554,7 +554,7 @@ int eWDir // Create new trim topology that references edge, direction // reletive to edge, loop and trim curve geometry - var trim = brep.Trims.Add(brep.Edges[ei], reverse, loop, c2i); + BrepTrim trim = brep.Trims.Add(brep.Edges[ei], reverse, loop, c2i); trim.IsoStatus = iso; // This one Brep face, so all trims are boundary ones. @@ -577,31 +577,31 @@ int eWDir private static void CreateFace(Brep brep, int si) { // Add new face to brep - var face = brep.Faces.Add(si); + BrepFace face = brep.Faces.Add(si); // Create outer loop and trims for the face MakeOuterTrimmingLoop(brep, face, AB, +1, // South side edge and its orientation with respect to - // to the trimming curve. (AB) + // to the trimming curve. (AB) BC, +1, // East side edge and its orientation with respect to - // to the trimming curve. (BC) + // to the trimming curve. (BC) CD, +1, // North side edge and its orientation with respect to - // to the trimming curve (CD) + // to the trimming curve (CD) AD, -1 // West side edge and its orientation with respect to - // to the trimming curve (AD) + // to the trimming curve (AD) ); // Create loop and trims for the face MakeInnerTrimmingLoop(brep, face, EF, +1, // Parallel to south side edge and its orientation with respect to - // to the trimming curve. (EF) + // to the trimming curve. (EF) FG, +1, // Parallel to east side edge and its orientation with respect to - // to the trimming curve. (FG) + // to the trimming curve. (FG) GH, +1, // Parallel to north side edge and its orientation with respect to - // to the trimming curve (GH) + // to the trimming curve (GH) EH, -1 // Parallel to west side edge and its orientation with respect to - // to the trimming curve (EH) + // to the trimming curve (EH) ); // Set face direction relative to surface direction diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsFairCurves.cs b/rhinocommon/cs/SampleCsCommands/SampleCsFairCurves.cs index 72d2f561..fff5c804 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsFairCurves.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsFairCurves.cs @@ -31,7 +31,7 @@ public SampleCsFairCurves() protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select curves to fair"); go.GeometryFilter = ObjectType.Curve; go.GroupSelect = true; @@ -40,20 +40,20 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - foreach (var objref in go.Objects()) + foreach (ObjRef objref in go.Objects()) { - var curve = objref.Curve(); + Curve curve = objref.Curve(); if (null == curve) return Result.Failure; - var nurb = curve.ToNurbsCurve(); + NurbsCurve nurb = curve.ToNurbsCurve(); if (null == nurb) return Result.Failure; if (1 == nurb.Degree) { RhinoApp.WriteLine("Cannot fair degree 1 curves."); - var obj = objref.Object(); + RhinoObject obj = objref.Object(); if (null != obj) { obj.Select(false); @@ -64,28 +64,28 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } } - var rc = GetTolerance(ref m_dist_tol); + Result rc = GetTolerance(ref m_dist_tol); if (rc != Result.Success) return rc; // Divide tolerance by 4 as part of getting Fair to stay within stated tolerance - var dist_tol = m_dist_tol * 0.25; - var faired_count = 0; - var degree3_count = 0; + double dist_tol = m_dist_tol * 0.25; + int faired_count = 0; + int degree3_count = 0; - foreach (var objref in go.Objects()) + foreach (ObjRef objref in go.Objects()) { - var curve = objref.Curve(); + Curve curve = objref.Curve(); if (null == curve) return Result.Failure; - var nurb = curve.ToNurbsCurve(); + NurbsCurve nurb = curve.ToNurbsCurve(); if (null == nurb) return Result.Failure; - var curve_degree = nurb.Degree; + int curve_degree = nurb.Degree; - var fair = nurb.Fair(dist_tol, m_ang_tol, (int)FairClamp.None, (int)FairClamp.None, m_iterations); + Curve fair = nurb.Fair(dist_tol, m_ang_tol, (int)FairClamp.None, (int)FairClamp.None, m_iterations); if (null != fair && fair.IsValid) { if (curve_degree != fair.Degree) @@ -118,18 +118,18 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) private static Result GetTolerance(ref double tolerance) { - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Tolerance"); gp.SetDefaultNumber(tolerance); gp.AcceptNumber(true, false); for (; ; ) { - var res = gp.Get(); + GetResult res = gp.Get(); if (res == GetResult.Number) { - var d = gp.Number(); + double d = gp.Number(); if (d < 0.0) { RhinoApp.WriteLine("Tolerance must be greater than 0."); @@ -147,7 +147,7 @@ private static Result GetTolerance(ref double tolerance) break; } - var base_point = gp.Point(); + Point3d base_point = gp.Point(); gp.SetBasePoint(base_point, true); gp.DrawLineFromPoint(base_point, true); @@ -155,11 +155,11 @@ private static Result GetTolerance(ref double tolerance) for (; ; ) { - var res = gp.Get(); + GetResult res = gp.Get(); if (res == GetResult.Number) { - var d = gp.Number(); + double d = gp.Number(); if (d < 0.0) { RhinoApp.WriteLine("Tolerance must be greater than 0."); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsFilletSrf.cs b/rhinocommon/cs/SampleCsCommands/SampleCsFilletSrf.cs index 9340d6cb..94e0a0f5 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsFilletSrf.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsFilletSrf.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; @@ -22,15 +21,15 @@ public SampleCsFilletSrf() protected override Result RunCommand(RhinoDoc doc, RunMode mode) { double tolerance = doc.ModelAbsoluteTolerance; - var opt_double = new OptionDouble(Radius, true, tolerance); + OptionDouble opt_double = new OptionDouble(Radius, true, tolerance); // Select first surface to fillet - var go0 = new GetObject(); + GetObject go0 = new GetObject(); go0.SetCommandPrompt("Select first surface to fillet"); go0.AddOptionDouble("Radius", ref opt_double, "Fillet radius"); go0.GeometryFilter = ObjectType.Surface; go0.EnablePreSelect(false, true); - for (;;) + for (; ; ) { GetResult res = go0.Get(); if (res == GetResult.Option) @@ -40,7 +39,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) break; } - var obj_ref0 = go0.Object(0); + ObjRef obj_ref0 = go0.Object(0); BrepFace face0 = obj_ref0.Face(); if (null == face0) return Result.Failure; @@ -48,7 +47,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) double u0, v0; if (null == obj_ref0.SurfaceParameter(out u0, out v0)) { - var pt = obj_ref0.SelectionPoint(); + Point3d pt = obj_ref0.SelectionPoint(); if (!pt.IsValid || !face0.ClosestPoint(pt, out u0, out v0)) { // Make surface selection scriptable @@ -65,13 +64,13 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) v0 = 0.99 * v0 + 0.01 * face0.Domain(1).Mid; // Select second surface to fillet - var go1 = new GetObject(); + GetObject go1 = new GetObject(); go1.SetCommandPrompt("Select second surface to fillet"); go1.AddOptionDouble("Radius", ref opt_double, "Fillet radius"); go1.GeometryFilter = ObjectType.Surface; go1.EnablePreSelect(false, true); go1.DeselectAllBeforePostSelect = false; - for (;;) + for (; ; ) { GetResult res = go1.Get(); if (res == GetResult.Option) @@ -81,7 +80,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) break; } - var obj_ref1 = go1.Object(0); + ObjRef obj_ref1 = go1.Object(0); BrepFace face1 = obj_ref1.Face(); if (null == face1) return Result.Failure; @@ -89,7 +88,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) double u1, v1; if (null == obj_ref1.SurfaceParameter(out u1, out v1)) { - var pt = obj_ref1.SelectionPoint(); + Point3d pt = obj_ref1.SelectionPoint(); if (!pt.IsValid || !face1.ClosestPoint(pt, out u1, out v1)) { // Make surface selection scriptable @@ -105,11 +104,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (v1 == face1.Domain(1).Min || v1 == face1.Domain(1).Max) v1 = 0.99 * v0 + 0.01 * face1.Domain(1).Mid; - var p0 = new Point2d(u0, v0); - var p1 = new Point2d(u1, v1); - var fillets = Surface.CreateRollingBallFillet(face0, p0, face1, p1, Radius, tolerance); + Point2d p0 = new Point2d(u0, v0); + Point2d p1 = new Point2d(u1, v1); + Surface[] fillets = Surface.CreateRollingBallFillet(face0, p0, face1, p1, Radius, tolerance); - foreach (var f in fillets) + foreach (Surface f in fillets) doc.Objects.AddSurface(f); doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsFindUnweldedEdges.cs b/rhinocommon/cs/SampleCsCommands/SampleCsFindUnweldedEdges.cs index 09d7779d..519c325b 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsFindUnweldedEdges.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsFindUnweldedEdges.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System; +using System.Collections.Generic; namespace SampleCsCommands { @@ -14,19 +14,19 @@ public class SampleCsFindUnweldedEdges : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select mesh"); go.GeometryFilter = ObjectType.Mesh; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var mesh = go.Object(0).Mesh(); + Mesh mesh = go.Object(0).Mesh(); if (null == mesh) return Result.Failure; - var unwelded_count = 0; - for (var topei = 0; topei < mesh.TopologyEdges.Count; topei++) + int unwelded_count = 0; + for (int topei = 0; topei < mesh.TopologyEdges.Count; topei++) { if (IsUweldedMeshEdge(mesh, topei)) { @@ -57,30 +57,30 @@ public static bool IsUweldedMeshEdge(Mesh mesh, int topei) if (topei < 0 || topei >= mesh.TopologyEdges.Count) throw new IndexOutOfRangeException(nameof(topei)); - var topfi = mesh.TopologyEdges.GetConnectedFaces(topei); + int[] topfi = mesh.TopologyEdges.GetConnectedFaces(topei); if (1 == topfi.Length) return true; - var topvi = mesh.TopologyEdges.GetTopologyVertices(topei); - var topvi0 = mesh.TopologyVertices.MeshVertexIndices(topvi.I); - var topvi1 = mesh.TopologyVertices.MeshVertexIndices(topvi.J); + IndexPair topvi = mesh.TopologyEdges.GetTopologyVertices(topei); + int[] topvi0 = mesh.TopologyVertices.MeshVertexIndices(topvi.I); + int[] topvi1 = mesh.TopologyVertices.MeshVertexIndices(topvi.J); // Both ends of the edge must have more than 1 mesh vertex or they are welded. // However, having more than 1 vertex at both ends does not necessarily mean it is unwelded. if (1 == topvi0.Length || 1 == topvi1.Length) return false; - var pta = mesh.Vertices[topvi0[0]]; - var ptb = mesh.Vertices[topvi1[0]]; - var pta_indexes = new List(topvi0.Length); - var ptb_indexes = new List(topvi1.Length); + Point3f pta = mesh.Vertices[topvi0[0]]; + Point3f ptb = mesh.Vertices[topvi1[0]]; + List pta_indexes = new List(topvi0.Length); + List ptb_indexes = new List(topvi1.Length); - var ict = topfi.Length; - for (var i = 0; ict > i; i++) + int ict = topfi.Length; + for (int i = 0; ict > i; i++) { - var face = mesh.Faces[topfi[i]]; - var jct = face.IsQuad ? 4 : 3; - for (var j = 0; j < jct; j++) + MeshFace face = mesh.Faces[topfi[i]]; + int jct = face.IsQuad ? 4 : 3; + for (int j = 0; j < jct; j++) { if (pta == mesh.Vertices[face[j]]) { @@ -90,8 +90,8 @@ public static bool IsUweldedMeshEdge(Mesh mesh, int topei) } else { - var kct = pta_indexes.Count; - for (var k = 0; k < kct; k++) + int kct = pta_indexes.Count; + for (int k = 0; k < kct; k++) { if (pta_indexes[k] == face[j]) return false; @@ -108,8 +108,8 @@ public static bool IsUweldedMeshEdge(Mesh mesh, int topei) } else { - var kct = ptb_indexes.Count; - for (var k = 0; k < kct; k++) + int kct = ptb_indexes.Count; + for (int k = 0; k < kct; k++) { if (ptb_indexes[k] == face[j]) return false; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsGetDirection.cs b/rhinocommon/cs/SampleCsCommands/SampleCsGetDirection.cs index b411cddf..964d797b 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsGetDirection.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsGetDirection.cs @@ -11,15 +11,15 @@ public class SampleCsGetDirection : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Point to draw from"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var pt = gp.Point(); + Point3d pt = gp.Point(); - var gd = new GetDirection(); + GetDirection gd = new GetDirection(); gd.SetCommandPrompt("Point to draw to"); gd.SetBasePoint(pt, true); gd.DrawArrowFromPoint(pt, true, true); @@ -88,12 +88,12 @@ protected override void OnDynamicDraw(GetPointDrawEventArgs e) { if (m_draw_arrow && m_draw_arrow_point.IsValid) { - var line = new Line(m_draw_arrow_point, e.CurrentPoint); + Line line = new Line(m_draw_arrow_point, e.CurrentPoint); if (line.IsValid) { if (m_show_simple_arrow) { - var direction = line.To - line.From; + Vector3d direction = line.To - line.From; direction.Unitize(); e.Display.DrawLine(line, DynamicDrawColor); e.Display.DrawDirectionArrow(line.To, direction, DynamicDrawColor); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsGetMultiplePoints.cs b/rhinocommon/cs/SampleCsCommands/SampleCsGetMultiplePoints.cs index 1988012f..212f08d0 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsGetMultiplePoints.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsGetMultiplePoints.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.ApplicationSettings; using Rhino.Commands; using Rhino.Display; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -32,7 +32,7 @@ public void AddPoint(Point3d point) public void RemoveLastPoint() { - var point_count = m_points.Count; + int point_count = m_points.Count; if (point_count > 0) m_points.RemoveAt(point_count - 1); } @@ -43,7 +43,7 @@ public void RemoveLastPoint() protected override void CalculateBoundingBox(CalculateBoundingBoxEventArgs e) { - var bbox = new BoundingBox(m_points); + BoundingBox bbox = new BoundingBox(m_points); e.IncludeBoundingBox(bbox); } @@ -67,11 +67,11 @@ public class SampleCsGetMultiplePoints : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var conduit = new SampleCsGetMultiplePointsConduit { Enabled = true }; + SampleCsGetMultiplePointsConduit conduit = new SampleCsGetMultiplePointsConduit { Enabled = true }; Result rc; - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); while (true) { if (0 == conduit.PointCount) @@ -87,7 +87,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) gp.AcceptUndo(true); } - var res = gp.Get(); + GetResult res = gp.Get(); if (res == GetResult.Point) { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsGetPoint.cs b/rhinocommon/cs/SampleCsCommands/SampleCsGetPoint.cs index 167269b5..c85fd264 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsGetPoint.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsGetPoint.cs @@ -1,9 +1,8 @@ -using System; -using System.Globalization; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; using Rhino.Input.Custom; +using System.Globalization; namespace SampleCsCommands { @@ -13,28 +12,28 @@ public class SampleCsGetPoint : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Pick a point"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var point = gp.Point(); + Point3d point = gp.Point(); - var format = string.Format("F{0}", doc.DistanceDisplayPrecision); - var provider = CultureInfo.InvariantCulture; + string format = string.Format("F{0}", doc.DistanceDisplayPrecision); + CultureInfo provider = CultureInfo.InvariantCulture; - var x = point.X.ToString(format, provider); - var y = point.Y.ToString(format, provider); - var z = point.Z.ToString(format, provider); + string x = point.X.ToString(format, provider); + string y = point.Y.ToString(format, provider); + string z = point.Z.ToString(format, provider); RhinoApp.WriteLine("World coordinates: {0},{1},{2}", x, y, z); - var view = gp.View(); + Rhino.Display.RhinoView view = gp.View(); if (null != view) { - var plane = view.ActiveViewport.ConstructionPlane(); - var xform = Transform.ChangeBasis(Plane.WorldXY, plane); - + Plane plane = view.ActiveViewport.ConstructionPlane(); + Transform xform = Transform.ChangeBasis(Plane.WorldXY, plane); + point.Transform(xform); x = point.X.ToString(format, provider); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsGetPointOnBreps.cs b/rhinocommon/cs/SampleCsCommands/SampleCsGetPointOnBreps.cs index f6017648..d0e19885 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsGetPointOnBreps.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsGetPointOnBreps.cs @@ -1,12 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms.VisualStyles; -using Rhino; +using Rhino; using Rhino.ApplicationSettings; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System; +using System.Collections.Generic; namespace SampleCsCommands { @@ -19,7 +18,7 @@ public class SampleCsGetPointOnBreps : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select surfaces and polysurfaces"); go.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go.SubObjectSelect = false; @@ -27,20 +26,20 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var gp = new GetPointOnBreps(); + GetPointOnBreps gp = new GetPointOnBreps(); gp.SetCommandPrompt("Point on surface or polysurface"); - foreach (var obj_ref in go.Objects()) + foreach (ObjRef obj_ref in go.Objects()) gp.Breps.Add(obj_ref.Brep()); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var point = gp.Point(); + Point3d point = gp.Point(); // One final calculation - var closest_point = gp.CalculateClosestPoint(point); + Point3d closest_point = gp.CalculateClosestPoint(point); if (closest_point.IsValid) { doc.Objects.AddPoint(closest_point); @@ -68,16 +67,16 @@ public GetPointOnBreps() public Point3d CalculateClosestPoint(Point3d point) { - var closest_point = Point3d.Unset; - var minimum_distance = Double.MaxValue; - foreach (var brep in Breps) + Point3d closest_point = Point3d.Unset; + double minimum_distance = Double.MaxValue; + foreach (Brep brep in Breps) { - foreach (var face in brep.Faces) + foreach (BrepFace face in brep.Faces) { double u, v; if (face.ClosestPoint(point, out u, out v)) { - var face_point = face.PointAt(u, v); + Point3d face_point = face.PointAt(u, v); double distance = face_point.DistanceTo(point); if (distance < minimum_distance) { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsGroup.cs b/rhinocommon/cs/SampleCsCommands/SampleCsGroup.cs index cce6b3ad..96b61f82 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsGroup.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsGroup.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Input; +using System; +using System.Collections.Generic; +using System.Linq; namespace SampleCsCommands { @@ -15,18 +15,18 @@ public class SampleCsGroup : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { ObjRef[] objrefs; - var rc = RhinoGet.GetMultipleObjects("Select objects to group", false, ObjectType.AnyObject, out objrefs); + Result rc = RhinoGet.GetMultipleObjects("Select objects to group", false, ObjectType.AnyObject, out objrefs); if (rc != Rhino.Commands.Result.Success) return rc; if (objrefs == null || objrefs.Length < 1) return Result.Failure; - var guids = new List(objrefs.Length); + List guids = new List(objrefs.Length); guids.AddRange(objrefs.Select(objref => objref.ObjectId)); doc.Groups.Add(guids); doc.Views.Redraw(); - + return Result.Success; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsGuilloche.cs b/rhinocommon/cs/SampleCsCommands/SampleCsGuilloche.cs index 850fd540..986fb398 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsGuilloche.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsGuilloche.cs @@ -1,10 +1,10 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -127,18 +127,18 @@ public double Amplitude public Curve Calculate() { - var points = new Point3d[m_steps + 1]; - var theta = 0.0; - var theta_step = 2.0 * Math.PI / m_steps; + Point3d[] points = new Point3d[m_steps + 1]; + double theta = 0.0; + double theta_step = 2.0 * Math.PI / m_steps; - var s = (m_major_ripple + m_minor_ripple) / m_minor_ripple; - var rr = m_minor_ripple + m_major_ripple; - var rp = m_minor_ripple + m_radius; + double s = (m_major_ripple + m_minor_ripple) / m_minor_ripple; + double rr = m_minor_ripple + m_major_ripple; + double rp = m_minor_ripple + m_radius; - for (var t = 0; t < m_steps + 1; t++) + for (int t = 0; t < m_steps + 1; t++) { - var x = rr * Math.Cos(m_multiplier * theta) + rp * Math.Cos(s * m_multiplier * theta); - var y = rr * Math.Sin(m_multiplier * theta) + rp * Math.Sin(s * m_multiplier * theta); + double x = rr * Math.Cos(m_multiplier * theta) + rp * Math.Cos(s * m_multiplier * theta); + double y = rr * Math.Sin(m_multiplier * theta) + rp * Math.Sin(s * m_multiplier * theta); x *= m_amplitude; y *= m_amplitude; @@ -171,7 +171,7 @@ public GuillocheConduit() public void UpdateCurve() { m_curve = null; - var curve = Args.Calculate(); + Curve curve = Args.Calculate(); if (null != curve && curve.IsValid) m_curve = curve; } @@ -188,7 +188,7 @@ protected override void DrawOverlay(DrawEventArgs e) { if (null != m_curve && m_curve.IsValid) { - var color = Rhino.ApplicationSettings.AppearanceSettings.DefaultLayerColor; + System.Drawing.Color color = Rhino.ApplicationSettings.AppearanceSettings.DefaultLayerColor; e.Display.DrawCurve(m_curve, color); } } @@ -204,35 +204,35 @@ public class SampleCsGuilloche : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var conduit = new GuillocheConduit { Enabled = true }; + GuillocheConduit conduit = new GuillocheConduit { Enabled = true }; doc.Views.Redraw(); - var opt_amplitude = new OptionDouble(conduit.Args.Amplitude, Guilloche.MinAmplitude, Guilloche.MaxAmplitude); - var opt_major_ripple = new OptionDouble(conduit.Args.MajorRipple, Guilloche.MinMajorRipple, Guilloche.MinMinorRipple); - var opt_minor_ripple = new OptionDouble(conduit.Args.MinorRipple, Guilloche.MinMinorRipple, Guilloche.MaxMinorRipple); - var opt_multiplier = new OptionDouble(conduit.Args.Multiplier, Guilloche.MinMultiplier, Guilloche.MaxMultiplier); - var opt_radius = new OptionDouble(conduit.Args.Radius, Guilloche.MinRadius, Guilloche.MaxRadius); - var opt_steps = new OptionInteger(conduit.Args.Steps, Guilloche.MinSteps, Guilloche.MaxSteps); + OptionDouble opt_amplitude = new OptionDouble(conduit.Args.Amplitude, Guilloche.MinAmplitude, Guilloche.MaxAmplitude); + OptionDouble opt_major_ripple = new OptionDouble(conduit.Args.MajorRipple, Guilloche.MinMajorRipple, Guilloche.MinMinorRipple); + OptionDouble opt_minor_ripple = new OptionDouble(conduit.Args.MinorRipple, Guilloche.MinMinorRipple, Guilloche.MaxMinorRipple); + OptionDouble opt_multiplier = new OptionDouble(conduit.Args.Multiplier, Guilloche.MinMultiplier, Guilloche.MaxMultiplier); + OptionDouble opt_radius = new OptionDouble(conduit.Args.Radius, Guilloche.MinRadius, Guilloche.MaxRadius); + OptionInteger opt_steps = new OptionInteger(conduit.Args.Steps, Guilloche.MinSteps, Guilloche.MaxSteps); - var go = new GetOption(); + GetOption go = new GetOption(); go.SetCommandPrompt("Guilloché pattern options"); go.AcceptNothing(true); for (; ; ) { go.ClearCommandOptions(); - var idx_amplitude = go.AddOptionDouble("Amplitude", ref opt_amplitude); - var idx_major_ripple = go.AddOptionDouble("MajorRipple", ref opt_major_ripple); - var idx_minor_ripple = go.AddOptionDouble("MinorRipple", ref opt_minor_ripple); - var idx_multiplier = go.AddOptionDouble("Multiplier", ref opt_multiplier); - var idx_radius = go.AddOptionDouble("Radius", ref opt_radius); - var idx_steps = go.AddOptionInteger("Steps", ref opt_steps); + int idx_amplitude = go.AddOptionDouble("Amplitude", ref opt_amplitude); + int idx_major_ripple = go.AddOptionDouble("MajorRipple", ref opt_major_ripple); + int idx_minor_ripple = go.AddOptionDouble("MinorRipple", ref opt_minor_ripple); + int idx_multiplier = go.AddOptionDouble("Multiplier", ref opt_multiplier); + int idx_radius = go.AddOptionDouble("Radius", ref opt_radius); + int idx_steps = go.AddOptionInteger("Steps", ref opt_steps); - var res = go.Get(); + GetResult res = go.Get(); if (res == GetResult.Option) { - var option = go.Option(); + CommandLineOption option = go.Option(); if (null != option) { if (idx_amplitude == option.Index) @@ -261,7 +261,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) break; } - var curve = conduit.Args.Calculate(); + Curve curve = conduit.Args.Calculate(); if (null != curve && curve.IsValid) { doc.Objects.AddCurve(curve); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsGumballCylinder.cs b/rhinocommon/cs/SampleCsCommands/SampleCsGumballCylinder.cs index 156f408b..49b29408 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsGumballCylinder.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsGumballCylinder.cs @@ -1,9 +1,9 @@ using Rhino; using Rhino.Commands; using Rhino.Display; +using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; -using Rhino.Geometry; using Rhino.UI.Gumball; namespace SampleCsCommands @@ -36,16 +36,16 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) plane = view.ActiveViewport.ConstructionPlane(); plane.Origin = center; - var cylinder = new SampleCsGumballCylinder(plane, m_radius, m_height); + SampleCsGumballCylinder cylinder = new SampleCsGumballCylinder(plane, m_radius, m_height); - var radius_go = new GumballObject(); - var height_go = new GumballObject(); + GumballObject radius_go = new GumballObject(); + GumballObject height_go = new GumballObject(); - var radius_dc = new GumballDisplayConduit(Rhino.DocObjects.ActiveSpace.ModelSpace); - var height_dc = new GumballDisplayConduit(Rhino.DocObjects.ActiveSpace.ModelSpace); + GumballDisplayConduit radius_dc = new GumballDisplayConduit(Rhino.DocObjects.ActiveSpace.ModelSpace); + GumballDisplayConduit height_dc = new GumballDisplayConduit(Rhino.DocObjects.ActiveSpace.ModelSpace); - var radius_gas = RadiusGumballAppearanceSettings(); - var height_gas = HeightGumballAppearanceSettings(); + GumballAppearanceSettings radius_gas = RadiusGumballAppearanceSettings(); + GumballAppearanceSettings height_gas = HeightGumballAppearanceSettings(); while (true) { @@ -58,7 +58,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) radius_dc.Enabled = true; height_dc.Enabled = true; - var gx = new SampleCsGumballCylinderGetPoint(cylinder, radius_dc, height_dc); + SampleCsGumballCylinderGetPoint gx = new SampleCsGumballCylinderGetPoint(cylinder, radius_dc, height_dc); gx.SetCommandPrompt("Drag gumball. Press Enter when done"); gx.AcceptNothing(true); gx.MoveGumball(); @@ -69,11 +69,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gx.CommandResult() != Result.Success) break; - var res = gx.Result(); + GetResult res = gx.Result(); if (res == GetResult.Point) { - var radius = cylinder.Radius; - var height = cylinder.Height; + double radius = cylinder.Radius; + double height = cylinder.Height; cylinder = new SampleCsGumballCylinder(plane, radius, height); continue; } @@ -82,7 +82,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) m_radius = cylinder.Radius; m_height = cylinder.Height; cylinder = new SampleCsGumballCylinder(plane, m_radius, m_height); - var brep = cylinder.ToBrep; + Brep brep = cylinder.ToBrep; if (null != brep) doc.Objects.AddBrep(brep); } @@ -97,7 +97,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) private GumballAppearanceSettings RadiusGumballAppearanceSettings() { - var gas = new GumballAppearanceSettings + GumballAppearanceSettings gas = new GumballAppearanceSettings { RelocateEnabled = false, RotateXEnabled = false, @@ -119,7 +119,7 @@ private GumballAppearanceSettings RadiusGumballAppearanceSettings() private GumballAppearanceSettings HeightGumballAppearanceSettings() { - var gas = new GumballAppearanceSettings + GumballAppearanceSettings gas = new GumballAppearanceSettings { RelocateEnabled = false, RotateXEnabled = false, @@ -172,7 +172,7 @@ public SampleCsGumballCylinder(Plane plane, double radius, double height) public bool Create(Plane plane, double radius, double height) { - var rc = false; + bool rc = false; if (radius > 0.0 && height > 0.0) { m_circle = new Circle(plane, radius); @@ -205,10 +205,10 @@ public Plane RadiusPlane { get { - var center = m_circle.PointAt(0.0); - var xaxis = m_circle.TangentAt(0.0); + Point3d center = m_circle.PointAt(0.0); + Vector3d xaxis = m_circle.TangentAt(0.0); xaxis.Unitize(); - var zaxis = m_circle.Normal; + Vector3d zaxis = m_circle.Normal; zaxis.Unitize(); return new Plane(center, xaxis, zaxis); } @@ -218,10 +218,10 @@ public Plane HeightPlane { get { - var dir = m_circle.Normal; + Vector3d dir = m_circle.Normal; dir.Unitize(); dir *= m_cylinder.TotalHeight; - var center = Point3d.Add(m_circle.Center, dir); + Point3d center = Point3d.Add(m_circle.Center, dir); return new Plane(center, m_circle.Plane.XAxis, m_circle.Plane.YAxis); } } @@ -279,13 +279,13 @@ protected override void OnMouseDown(GetPointMouseEventArgs e) m_radius_dc.PickResult.SetToDefault(); m_height_dc.PickResult.SetToDefault(); - var pick_context = new PickContext + PickContext pick_context = new PickContext { View = e.Viewport.ParentView, PickStyle = PickStyle.PointPick }; - var xform = e.Viewport.GetPickTransform(e.WindowPoint); + Transform xform = e.Viewport.GetPickTransform(e.WindowPoint); pick_context.SetPickTransform(xform); Line pick_line; @@ -314,8 +314,8 @@ protected override void OnMouseMove(GetPointMouseEventArgs e) Line world_line; if (e.Viewport.GetFrustumLine(e.WindowPoint.X, e.WindowPoint.Y, out world_line)) { - var dir = e.Point - m_base_point; - var len = dir.Length; + Vector3d dir = e.Point - m_base_point; + double len = dir.Length; if (m_base_origin.DistanceTo(e.Point) < m_base_origin.DistanceTo(m_base_point)) len = -len; @@ -351,7 +351,7 @@ protected override void OnDynamicDraw(GetPointDrawEventArgs e) public GetResult MoveGumball() { - var rc = Get(true); + GetResult rc = Get(true); return rc; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsHatch.cs b/rhinocommon/cs/SampleCsCommands/SampleCsHatch.cs index 77f0bdc1..464cd228 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsHatch.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsHatch.cs @@ -73,7 +73,7 @@ private static HatchPattern FindOrAddHatchPattern(HatchPatternTable table, Hatch if (null != pattern) { rc = table.FindName(pattern.Name); - var index = rc?.Index ?? table.Add(pattern); + int index = rc?.Index ?? table.Add(pattern); rc = table[index]; } return rc; @@ -89,12 +89,12 @@ public class SampleCsHatch : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var circle = new Circle(Plane.WorldXY, 5.0); - var curve = circle.ToNurbsCurve(); + Circle circle = new Circle(Plane.WorldXY, 5.0); + NurbsCurve curve = circle.ToNurbsCurve(); - var pattern = doc.HatchPatterns.DashPattern(); + HatchPattern pattern = doc.HatchPatterns.DashPattern(); - var hatch = Hatch.Create(curve, pattern.Index, 0.0, 1.0, doc.ModelAbsoluteTolerance); + Hatch[] hatch = Hatch.Create(curve, pattern.Index, 0.0, 1.0, doc.ModelAbsoluteTolerance); doc.Objects.AddHatch(hatch[0]); doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsHideInDetail.cs b/rhinocommon/cs/SampleCsCommands/SampleCsHideInDetail.cs index 169ebafe..a0b8d454 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsHideInDetail.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsHideInDetail.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.Input; using Rhino.Input.Custom; +using System; +using System.Collections.Generic; namespace SampleCsCommands { @@ -16,7 +16,7 @@ public class SampleCsHideInDetail : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var view = doc.Views.ActiveView; + RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; @@ -26,9 +26,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Cancel; } - var active_option = new OptionToggle(m_bActive, "Inactive", "Active"); + OptionToggle active_option = new OptionToggle(m_bActive, "Inactive", "Active"); - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects to hide"); go.GroupSelect = true; for (; ; ) @@ -36,7 +36,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) go.ClearCommandOptions(); go.AddOptionToggle("Detail", ref active_option); - var res = go.GetMultiple(1, 0); + GetResult res = go.GetMultiple(1, 0); if (res == GetResult.Option) continue; @@ -63,7 +63,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Cancel; } - var viewport_id_list = new List(16); + List viewport_id_list = new List(16); if (m_bActive) { viewport_id_list.Add(view.ActiveViewportID); @@ -72,10 +72,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { if (view is RhinoPageView page_view) { - var detail_views = page_view.GetDetailViews(); + Rhino.DocObjects.DetailViewObject[] detail_views = page_view.GetDetailViews(); if (null != detail_views) { - foreach (var detail in detail_views) + foreach (Rhino.DocObjects.DetailViewObject detail in detail_views) { if (detail.Viewport.Id != view.ActiveViewportID) viewport_id_list.Add(detail.Viewport.Id); @@ -87,13 +87,13 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (0 == viewport_id_list.Count) return Result.Nothing; - foreach (var objref in go.Objects()) + foreach (Rhino.DocObjects.ObjRef objref in go.Objects()) { - var obj = objref.Object(); + Rhino.DocObjects.RhinoObject obj = objref.Object(); if (null != obj) { - var attributes = obj.Attributes.Duplicate(); - foreach (var viewport_id in viewport_id_list) + Rhino.DocObjects.ObjectAttributes attributes = obj.Attributes.Duplicate(); + foreach (Guid viewport_id in viewport_id_list) attributes.AddHideInDetailOverride(viewport_id); doc.Objects.ModifyAttributes(objref, attributes, true); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsHistory.cs b/rhinocommon/cs/SampleCsCommands/SampleCsHistory.cs index 4b19ca72..8286d084 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsHistory.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsHistory.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsHistoryDivide.cs b/rhinocommon/cs/SampleCsCommands/SampleCsHistoryDivide.cs index 174d26c2..22967fd8 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsHistoryDivide.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsHistoryDivide.cs @@ -1,12 +1,11 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands { public class SampleCsHistoryDivide : Command { - static int _historyVersion = 20121101; + static int _historyVersion = 20121101; public override string EnglishName => "SampleCsHistoryDivide"; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsImportNamedViews.cs b/rhinocommon/cs/SampleCsCommands/SampleCsImportNamedViews.cs index f166c6c7..bf1a19da 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsImportNamedViews.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsImportNamedViews.cs @@ -1,8 +1,8 @@ -using System.IO; -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.FileIO; +using System.IO; +using System.Windows.Forms; namespace SampleCsCommands { @@ -12,27 +12,27 @@ public class SampleCsImportNamedViews : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var dialog = new OpenFileDialog + OpenFileDialog dialog = new OpenFileDialog { Filter = @"Rhino 3D Models (*.3dm)|*.3dm", DefaultExt = "3dm" }; - var rc = dialog.ShowDialog(); + DialogResult rc = dialog.ShowDialog(); if (rc != DialogResult.OK) return Result.Cancel; - var filename = dialog.FileName; + string filename = dialog.FileName; if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) return Result.Failure; - var f = File3dm.Read(filename); + File3dm f = File3dm.Read(filename); if (0 == f.NamedViews.Count) { RhinoApp.WriteLine("No named views to import."); return Result.Nothing; } - foreach (var vi in f.NamedViews) + foreach (Rhino.DocObjects.ViewInfo vi in f.NamedViews) doc.NamedViews.Add(vi); RhinoApp.WriteLine($"{f.NamedViews.Count + 1} named view(s) imported."); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectBreps.cs b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectBreps.cs index a738782c..d3306fe9 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectBreps.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectBreps.cs @@ -1,10 +1,10 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Geometry.Intersect; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -14,7 +14,7 @@ public class SampleCsIntersectBreps : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select two surfaces or polysurfaces to intersect"); go.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go.SubObjectSelect = false; @@ -22,29 +22,29 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var brep0 = go.Object(0).Brep(); - var brep1 = go.Object(1).Brep(); + Brep brep0 = go.Object(0).Brep(); + Brep brep1 = go.Object(1).Brep(); if (null == brep0 || null == brep1) return Result.Failure; - var rc = Intersection.BrepBrep(brep0, brep1, doc.ModelAbsoluteTolerance, out Curve[] curves, out Point3d[] points); + bool rc = Intersection.BrepBrep(brep0, brep1, doc.ModelAbsoluteTolerance, out Curve[] curves, out Point3d[] points); if (!rc) { RhinoApp.WriteLine("Unable to intersect two Breps."); return Result.Cancel; } - foreach (var curve in curves) + foreach (Curve curve in curves) { - var object_id = doc.Objects.AddCurve(curve); - var rhino_object = doc.Objects.Find(object_id); + Guid object_id = doc.Objects.AddCurve(curve); + RhinoObject rhino_object = doc.Objects.Find(object_id); rhino_object?.Select(true); } - foreach (var point in points) + foreach (Point3d point in points) { - var object_id = doc.Objects.AddPoint(point); - var rhino_object = doc.Objects.Find(object_id); + Guid object_id = doc.Objects.AddPoint(point); + RhinoObject rhino_object = doc.Objects.Find(object_id); rhino_object?.Select(true); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCircles.cs b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCircles.cs index 9a6f49f0..55ec90f6 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCircles.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCircles.cs @@ -1,7 +1,7 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; +using System; namespace SampleCsCommands { @@ -40,7 +40,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } doc.Views.Redraw(); - + return Result.Success; } @@ -109,14 +109,14 @@ private bool CircleCircleIntersection(Circle c0, Circle c1, ref Point3d p0, ref /// private double Hypot(double x, double y) { - double r; - if (x == 0) return y; - if (y == 0) return x; - if (x < 0) x = -x; - if (y < 0) y = -y; - if (x < y) {r = x; x = y; y = r;} - r = y / x; - return x * Math.Sqrt(1 + r * r); + double r; + if (x == 0) return y; + if (y == 0) return x; + if (x < 0) x = -x; + if (y < 0) y = -y; + if (x < y) { r = x; x = y; y = r; } + r = y / x; + return x * Math.Sqrt(1 + r * r); } } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveBrepFace.cs b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveBrepFace.cs index b49b0685..ba57c0f6 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveBrepFace.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveBrepFace.cs @@ -12,7 +12,7 @@ public class SampleCsIntersectCurveBrepFace : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var gs = new GetObject(); + GetObject gs = new GetObject(); gs.SetCommandPrompt("Select surface"); gs.GeometryFilter = Rhino.DocObjects.ObjectType.Surface; gs.SubObjectSelect = true; @@ -20,11 +20,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gs.CommandResult() != Result.Success) return gs.CommandResult(); - var face = gs.Object(0).Face(); + BrepFace face = gs.Object(0).Face(); if (null == face) return Result.Failure; - var gc = new GetObject(); + GetObject gc = new GetObject(); gc.SetCommandPrompt("Select curve"); gc.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; gc.EnablePreSelect(false, true); @@ -33,18 +33,18 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gc.CommandResult() != Result.Success) return gc.CommandResult(); - var curve = gc.Object(0).Curve(); + Curve curve = gc.Object(0).Curve(); if (null == curve) return Result.Failure; - var tol = doc.ModelAbsoluteTolerance; - var rc = Intersection.CurveBrepFace(curve, face, tol, out Curve[] outCurves, out Point3d[] outPoints); + double tol = doc.ModelAbsoluteTolerance; + bool rc = Intersection.CurveBrepFace(curve, face, tol, out Curve[] outCurves, out Point3d[] outPoints); if (rc) { - foreach (var c in outCurves) + foreach (Curve c in outCurves) doc.Objects.AddCurve(c); - foreach (var pt in outPoints) + foreach (Point3d pt in outPoints) doc.Objects.AddPoint(pt); doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveLine.cs b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveLine.cs index 64424278..e79b0941 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveLine.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveLine.cs @@ -11,24 +11,24 @@ public class SampleCsIntersectCurveLine : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select curve to intersect"); go.GeometryFilter = ObjectType.Curve; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var curve = go.Object(0).Curve(); + Rhino.Geometry.Curve curve = go.Object(0).Curve(); if (null == curve) return Result.Failure; - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("First point of infinite intersecting line"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var from = gp.Point(); + Rhino.Geometry.Point3d from = gp.Point(); gp.SetCommandPrompt("Second point of infinite intersecting line"); gp.SetBasePoint(from, true); @@ -37,14 +37,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var line = new Rhino.Geometry.Line(from, gp.Point()); + Rhino.Geometry.Line line = new Rhino.Geometry.Line(from, gp.Point()); if (!line.IsValid || line.Length < Rhino.RhinoMath.SqrtEpsilon) return Result.Nothing; - var ccx = IntersectCurveLine(curve, line, doc.ModelAbsoluteTolerance, doc.ModelAbsoluteTolerance); + Rhino.Geometry.Intersect.CurveIntersections ccx = IntersectCurveLine(curve, line, doc.ModelAbsoluteTolerance, doc.ModelAbsoluteTolerance); if (null != ccx) { - foreach (var x in ccx) + foreach (Rhino.Geometry.Intersect.IntersectionEvent x in ccx) { if (x.IsPoint) doc.Objects.AddPoint(x.PointA); @@ -70,9 +70,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) /// then tolerance * 2.0 is used. /// A collection of intersection events. public static Rhino.Geometry.Intersect.CurveIntersections IntersectCurveLine( - Rhino.Geometry.Curve curve, - Rhino.Geometry.Line line, - double tolerance, + Rhino.Geometry.Curve curve, + Rhino.Geometry.Line line, + double tolerance, double overlapTolerance ) { @@ -80,21 +80,21 @@ double overlapTolerance return null; // Extend the line through the curve's bounding box - var bbox = curve.GetBoundingBox(false); + Rhino.Geometry.BoundingBox bbox = curve.GetBoundingBox(false); if (!bbox.IsValid) return null; - var dir = line.Direction; + Rhino.Geometry.Vector3d dir = line.Direction; dir.Unitize(); - var points = bbox.GetCorners(); - var plane = new Rhino.Geometry.Plane(line.From, dir); + Rhino.Geometry.Point3d[] points = bbox.GetCorners(); + Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(line.From, dir); double max_dist; - var min_dist = max_dist = plane.DistanceTo(points[0]); - for (var i = 1; i < points.Length; i++) + double min_dist = max_dist = plane.DistanceTo(points[0]); + for (int i = 1; i < points.Length; i++) { - var dist = plane.DistanceTo(points[i]); + double dist = plane.DistanceTo(points[i]); if (dist < min_dist) min_dist = dist; if (dist > max_dist) @@ -106,7 +106,7 @@ double overlapTolerance line.To = line.From + dir * (max_dist + 1.0); // Calculate curve-curve intersection - var line_curve = new Rhino.Geometry.LineCurve(line); + Rhino.Geometry.LineCurve line_curve = new Rhino.Geometry.LineCurve(line); return Rhino.Geometry.Intersect.Intersection.CurveCurve(curve, line_curve, tolerance, overlapTolerance); } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveSelf.cs b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveSelf.cs index a675f3a9..5647a7be 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveSelf.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurveSelf.cs @@ -1,9 +1,9 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry.Intersect; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -13,35 +13,35 @@ public class SampleCsIntersectCurveSelf : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select curve for self-intersection test"); go.GeometryFilter = ObjectType.Curve; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var curve = go.Object(0).Curve(); + Rhino.Geometry.Curve curve = go.Object(0).Curve(); if (null == curve) return Result.Failure; - var tolerance = doc.ModelAbsoluteTolerance; - var ccx_events = Intersection.CurveSelf(curve, tolerance); + double tolerance = doc.ModelAbsoluteTolerance; + CurveIntersections ccx_events = Intersection.CurveSelf(curve, tolerance); - foreach (var ccx in ccx_events) + foreach (IntersectionEvent ccx in ccx_events) { - var rhobject_id = Guid.Empty; + Guid rhobject_id = Guid.Empty; if (ccx.IsPoint) rhobject_id = doc.Objects.AddPoint(ccx.PointA); else if (ccx.IsOverlap) { - var trim_curve = curve.Trim(ccx.OverlapA); + Rhino.Geometry.Curve trim_curve = curve.Trim(ccx.OverlapA); if (null != trim_curve) rhobject_id = doc.Objects.AddCurve(trim_curve); } if (rhobject_id != Guid.Empty) { - var rhobject = doc.Objects.Find(rhobject_id); + RhinoObject rhobject = doc.Objects.Find(rhobject_id); if (null != rhobject) rhobject.Select(true); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurves.cs b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurves.cs index cfa81218..cecd814d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurves.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectCurves.cs @@ -1,9 +1,9 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry.Intersect; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -13,42 +13,42 @@ public class SampleCsIntersectCurves : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select two curves for intersection test"); go.GeometryFilter = ObjectType.Curve; go.GetMultiple(2, 2); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var curve0 = go.Object(0).Curve(); - var curve1 = go.Object(1).Curve(); + Rhino.Geometry.Curve curve0 = go.Object(0).Curve(); + Rhino.Geometry.Curve curve1 = go.Object(1).Curve(); if (null == curve0 || null == curve1) return Result.Failure; - var tolerance = doc.ModelAbsoluteTolerance; - var ccx_events = Intersection.CurveCurve(curve0, curve1, tolerance, tolerance); - foreach (var ccx in ccx_events) + double tolerance = doc.ModelAbsoluteTolerance; + CurveIntersections ccx_events = Intersection.CurveCurve(curve0, curve1, tolerance, tolerance); + foreach (IntersectionEvent ccx in ccx_events) { - var rhobject_id = Guid.Empty; + Guid rhobject_id = Guid.Empty; if (ccx.IsPoint) rhobject_id = doc.Objects.AddPoint(ccx.PointA); else if (ccx.IsOverlap) { - var curve = curve0.Trim(ccx.OverlapA); + Rhino.Geometry.Curve curve = curve0.Trim(ccx.OverlapA); if (null != curve) rhobject_id = doc.Objects.AddCurve(curve); } if (rhobject_id != Guid.Empty) { - var rhobject = doc.Objects.Find(rhobject_id); + RhinoObject rhobject = doc.Objects.Find(rhobject_id); if (null != rhobject) rhobject.Select(true); } } doc.Views.Redraw(); - + return Result.Success; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectionMeshPolyline.cs b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectionMeshPolyline.cs index 1201472f..70f87c0a 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsIntersectionMeshPolyline.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsIntersectionMeshPolyline.cs @@ -12,14 +12,14 @@ public class SampleCsIntersectionMeshPolyline : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var gm = new GetObject(); + GetObject gm = new GetObject(); gm.SetCommandPrompt("Select mesh"); gm.GeometryFilter = ObjectType.Mesh; gm.Get(); if (gm.CommandResult() != Result.Success) return gm.CommandResult(); - var gp = new GetObject(); + GetObject gp = new GetObject(); gp.SetCommandPrompt("Select polyline"); gp.GeometryFilter = ObjectType.Curve; gp.EnablePreSelect(false, true); @@ -28,15 +28,15 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gm.CommandResult() != Result.Success) return gp.CommandResult(); - var mesh = gm.Object(0).Mesh(); + Mesh mesh = gm.Object(0).Mesh(); if (null == mesh) return Result.Failure; - var curve = gp.Object(0).Curve(); + Curve curve = gp.Object(0).Curve(); if (null == curve) return Result.Failure; - var polyline_curve = curve as PolylineCurve; + PolylineCurve polyline_curve = curve as PolylineCurve; if (null == polyline_curve) { RhinoApp.Write("Curve is not a polyline"); @@ -44,10 +44,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } int[] face_ids; - var points = Rhino.Geometry.Intersect.Intersection.MeshPolyline(mesh, polyline_curve, out face_ids); + Point3d[] points = Rhino.Geometry.Intersect.Intersection.MeshPolyline(mesh, polyline_curve, out face_ids); if (points.Length > 0) { - foreach (var pt in points) + foreach (Point3d pt in points) doc.Objects.AddPoint(pt); doc.Views.Redraw(); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsInvertSelected.cs b/rhinocommon/cs/SampleCsCommands/SampleCsInvertSelected.cs index baac95ee..ed3d2ddf 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsInvertSelected.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsInvertSelected.cs @@ -1,6 +1,4 @@ -using System; -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; @@ -12,7 +10,7 @@ public class SampleCsInvertSelected : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var filter = new ObjectEnumeratorSettings + ObjectEnumeratorSettings filter = new ObjectEnumeratorSettings { NormalObjects = true, LockedObjects = false, @@ -21,10 +19,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) ReferenceObjects = true }; - var rh_objects = doc.Objects.FindByFilter(filter); - foreach (var rh_obj in rh_objects) + RhinoObject[] rh_objects = doc.Objects.FindByFilter(filter); + foreach (RhinoObject rh_obj in rh_objects) { - var select = 0 == rh_obj.IsSelected(false) && rh_obj.IsSelectable(); + bool select = 0 == rh_obj.IsSelected(false) && rh_obj.IsSelectable(); rh_obj.Select(select); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsIsolate.cs b/rhinocommon/cs/SampleCsCommands/SampleCsIsolate.cs index 40a449a8..f273546e 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsIsolate.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsIsolate.cs @@ -1,5 +1,4 @@ -using System.Runtime.InteropServices; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Input.Custom; @@ -12,7 +11,7 @@ public class SampleCsIsolate : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects to isolate"); go.GroupSelect = true; go.SubObjectSelect = false; @@ -22,7 +21,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) for (int i = 0; i < go.ObjectCount; i++) { - var obj = go.Object(i).Object(); + RhinoObject obj = go.Object(i).Object(); if (null != obj) obj.Select(true); } @@ -40,7 +39,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { for (int i = 0; i < go.ObjectCount; i++) { - var obj = go.Object(i).Object(); + RhinoObject obj = go.Object(i).Object(); if (null != obj) obj.Select(true); } @@ -48,7 +47,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) doc.Views.RedrawEnabled = true; - return Result.Success; + return Result.Success; } } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsLastCreatedObjects.cs b/rhinocommon/cs/SampleCsCommands/SampleCsLastCreatedObjects.cs index 1f1f324b..c109b087 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsLastCreatedObjects.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsLastCreatedObjects.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; +using System.Collections.Generic; namespace SampleCsCommands { @@ -17,23 +17,23 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // 1.) Get the runtime serial number that will be assigned to the // next Rhino Object that is created. - var sn_start = RhinoObject.NextRuntimeSerialNumber; + uint sn_start = RhinoObject.NextRuntimeSerialNumber; // 2.) Script the Rhino command here using Rhino.RhinoApp.RunScript. // http://developer.rhino3d.com/guides/rhinocommon/run_rhino_command_from_plugin/ // 3.) Get the runtime serial number that will be assigned to the // next Rhino Object that is created. - var sn_end = RhinoObject.NextRuntimeSerialNumber; + uint sn_end = RhinoObject.NextRuntimeSerialNumber; // 4.) If the scripted command completed successfully and new objects were // added to the document, sn_end will be greater than sn_start. So all // that's left to do is find the newly added objects. - var objects = new List(); - for (var sn = sn_start; sn < sn_end; sn++) + List objects = new List(); + for (uint sn = sn_start; sn < sn_end; sn++) { - var obj = doc.Objects.Find(sn); + RhinoObject obj = doc.Objects.Find(sn); if (null != obj) objects.Add(obj); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsLayerOff.cs b/rhinocommon/cs/SampleCsCommands/SampleCsLayerOff.cs index a64def16..bcc391ef 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsLayerOff.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsLayerOff.cs @@ -1,6 +1,6 @@ -using System.Linq; -using Rhino; +using Rhino; using Rhino.Commands; +using System.Linq; namespace SampleCsCommands { @@ -10,9 +10,9 @@ public class SampleCsLayerOff : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var layer_index = doc.Layers.CurrentLayerIndex; - var current_state = false; - var res = Rhino.UI.Dialogs.ShowSelectLayerDialog(ref layer_index, "Select Layer", false, false, ref current_state); + int layer_index = doc.Layers.CurrentLayerIndex; + bool current_state = false; + bool res = Rhino.UI.Dialogs.ShowSelectLayerDialog(ref layer_index, "Select Layer", false, false, ref current_state); if (!res) return Result.Cancel; @@ -22,7 +22,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (layer_index == doc.Layers.CurrentLayerIndex) return Result.Nothing; // Cannot hide the current layer - var layer = doc.Layers[layer_index]; + Rhino.DocObjects.Layer layer = doc.Layers[layer_index]; layer.IsVisible = false; layer.SetPersistentVisibility(false); @@ -39,12 +39,12 @@ public class SampleCsLayerOffInDetails : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Find the layer index by full path name - var layer_index = doc.Layers.FindByFullPath("TO-DRAW", -1); + int layer_index = doc.Layers.FindByFullPath("TO-DRAW", -1); if (-1 == layer_index) return Result.Cancel; // Get the layer object - var layer = doc.Layers[layer_index]; + Rhino.DocObjects.Layer layer = doc.Layers[layer_index]; if (null == layer) return Result.Failure; @@ -53,7 +53,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Cancel; // Find the page view - var page_view = doc.Views.GetPageViews().First( + Rhino.Display.RhinoPageView page_view = doc.Views.GetPageViews().First( item => item.PageName.Equals("PANEL_01", System.StringComparison.OrdinalIgnoreCase) ); @@ -61,9 +61,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Cancel; // Process each detail - foreach (var detail in page_view.GetDetailViews()) + foreach (Rhino.DocObjects.DetailViewObject detail in page_view.GetDetailViews()) { - var viewport_id = detail.Viewport.Id; + System.Guid viewport_id = detail.Viewport.Id; // Re-acquire the layer object, as the underlying // object may have been modified @@ -80,7 +80,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } // Redraw if needed - var view = doc.Views.ActiveView; + Rhino.Display.RhinoView view = doc.Views.ActiveView; if (null != view && view.ActiveViewportID == page_view.ActiveViewportID) doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsLayerPathName.cs b/rhinocommon/cs/SampleCsCommands/SampleCsLayerPathName.cs index 318c8855..372b356c 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsLayerPathName.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsLayerPathName.cs @@ -1,9 +1,9 @@ -using System; -using System.IO; -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.FileIO; +using System; +using System.IO; +using System.Windows.Forms; namespace SampleCsCommands { @@ -13,21 +13,21 @@ public class SampleCsLayerPathName : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var dialog = new OpenFileDialog + OpenFileDialog dialog = new OpenFileDialog { Filter = @"Rhino 3D Models (*.3dm)|*.3dm", DefaultExt = "3dm" }; - var rc = dialog.ShowDialog(); + DialogResult rc = dialog.ShowDialog(); if (rc != DialogResult.OK) return Result.Cancel; - var filename = dialog.FileName; + string filename = dialog.FileName; if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) return Result.Failure; - var file = File3dm.Read(filename); + File3dm file = File3dm.Read(filename); if (null == file) return Result.Failure; @@ -41,7 +41,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // to generate full layer path names from layers in in File3dm, you need to write your // own function. - for (var i = 0; i < file.AllLayers.Count; i++) + for (int i = 0; i < file.AllLayers.Count; i++) { string full_name = null; if (GetLayerPathName(file, i, ref full_name)) @@ -68,17 +68,17 @@ private bool GetLayerPathName(File3dm file, int layerIndex, string delimeter, re return false; string name = null; - for (var i = 0; i < file.AllLayers.Count; i++) + for (int i = 0; i < file.AllLayers.Count; i++) { - var layer = file.AllLayers.FindIndex(layerIndex); - var layer_name = layer.Name; + Rhino.DocObjects.Layer layer = file.AllLayers.FindIndex(layerIndex); + string layer_name = layer.Name; if (string.IsNullOrEmpty(name)) { name = layer_name; } else { - var child_name = name; + string child_name = name; name = layer_name; if (!string.IsNullOrEmpty(delimeter)) name += delimeter; @@ -105,7 +105,7 @@ private int FindLayerFromId(File3dm file, Guid id) { if (null != file && id != Guid.Empty) { - for (var i = 0; i < file.AllLayers.Count; i++) + for (int i = 0; i < file.AllLayers.Count; i++) { if (file.AllLayers.FindIndex(i).Id == id) return i; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsMake2D.cs b/rhinocommon/cs/SampleCsCommands/SampleCsMake2D.cs index ddf2a2e7..a6b44d03 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsMake2D.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsMake2D.cs @@ -12,7 +12,7 @@ public class SampleCsMake2D : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects to test Make2D Points"); go.GeometryFilter = ObjectType.Point | ObjectType.Surface | ObjectType.PolysrfFilter; go.GroupSelect = true; @@ -20,13 +20,13 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var view = doc.Views.ActiveView; + Rhino.Display.RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; - var obj_refs = go.Objects(); + ObjRef[] obj_refs = go.Objects(); - var hld_params = new HiddenLineDrawingParameters + HiddenLineDrawingParameters hld_params = new HiddenLineDrawingParameters { AbsoluteTolerance = doc.ModelAbsoluteTolerance, IncludeTangentEdges = false, @@ -35,33 +35,33 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) hld_params.SetViewport(view.ActiveViewport); - foreach (var obj_ref in obj_refs) + foreach (ObjRef obj_ref in obj_refs) { - var obj = obj_ref?.Object(); + RhinoObject obj = obj_ref?.Object(); if (obj != null) hld_params.AddGeometry(obj.Geometry, Transform.Identity, obj.Id); } - var hld = HiddenLineDrawing.Compute(hld_params, true); + HiddenLineDrawing hld = HiddenLineDrawing.Compute(hld_params, true); if (hld != null) { - var flatten = Transform.PlanarProjection(Plane.WorldXY); + Transform flatten = Transform.PlanarProjection(Plane.WorldXY); BoundingBox page_box = hld.BoundingBox(true); - var delta_2d = new Vector2d(0, 0); + Vector2d delta_2d = new Vector2d(0, 0); delta_2d = delta_2d - new Vector2d(page_box.Min.X, page_box.Min.Y); - var delta_3d = Transform.Translation(new Vector3d(delta_2d.X, delta_2d.Y, 0.0)); + Transform delta_3d = Transform.Translation(new Vector3d(delta_2d.X, delta_2d.Y, 0.0)); flatten = delta_3d * flatten; - var h_attribs = new ObjectAttributes { Name = "H" }; - var v_attribs = new ObjectAttributes { Name = "V" }; + ObjectAttributes h_attribs = new ObjectAttributes { Name = "H" }; + ObjectAttributes v_attribs = new ObjectAttributes { Name = "V" }; - foreach (var hld_curve in hld.Segments) + foreach (HiddenLineDrawingSegment hld_curve in hld.Segments) { if (hld_curve?.ParentCurve == null || hld_curve.ParentCurve.SilhouetteType == SilhouetteType.None) continue; - var crv = hld_curve.CurveGeometry.DuplicateCurve(); + Curve crv = hld_curve.CurveGeometry.DuplicateCurve(); if (crv != null) { crv.Transform(flatten); @@ -77,12 +77,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } } - foreach (var hld_pt in hld.Points) + foreach (HiddenLineDrawingPoint hld_pt in hld.Points) { if (hld_pt == null) continue; - var pt = hld_pt.Location; + Point3d pt = hld_pt.Location; if (pt.IsValid) { pt.Transform(flatten); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsMeshBox.cs b/rhinocommon/cs/SampleCsCommands/SampleCsMeshBox.cs index 0b05e1b8..a31511c0 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsMeshBox.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsMeshBox.cs @@ -1,11 +1,8 @@ -using System; -using System.Drawing; -using System.Text; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; -using Rhino.FileIO; using Rhino.Geometry; +using System.Drawing; namespace SampleCsCommands { @@ -15,7 +12,7 @@ public class SampleCsMeshBox : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var vertices = new Point3d[8]; + Point3d[] vertices = new Point3d[8]; vertices[0] = new Point3d(10.0, 10.0, 10.0); vertices[1] = new Point3d(10.0, 10.0, -10.0); vertices[2] = new Point3d(10.0, -10.0, 10.0); @@ -25,21 +22,21 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) vertices[6] = new Point3d(-10.0, -10.0, 10.0); vertices[7] = new Point3d(-10.0, -10.0, -10.0); - var indices = new int[,] + int[,] indices = new int[,] { - { 0, 1, 5, 4 }, - { 0, 4, 6, 2 }, - { 0, 2, 3, 1 }, - { 7, 3, 2, 6}, - { 7, 6, 4, 5}, + { 0, 1, 5, 4 }, + { 0, 4, 6, 2 }, + { 0, 2, 3, 1 }, + { 7, 3, 2, 6}, + { 7, 6, 4, 5}, { 7, 5, 1, 3} }; - var meshes = new Mesh[6]; - for (var mi = 0; mi < 6; mi++) + Mesh[] meshes = new Mesh[6]; + for (int mi = 0; mi < 6; mi++) { - var mesh = new Mesh(); - for (var vi = 0; vi < 4; vi++) + Mesh mesh = new Mesh(); + for (int vi = 0; vi < 4; vi++) mesh.Vertices.Add(vertices[indices[mi, vi]]); mesh.Faces.AddFace(0, 1, 2, 3); mesh.FaceNormals.ComputeFaceNormals(); @@ -48,7 +45,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) meshes[mi] = mesh; } - var colors = new Color[] + Color[] colors = new Color[] { Color.Red, Color.Orange, @@ -58,12 +55,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) Color.Purple }; - var gi = doc.Groups.Add(); + int gi = doc.Groups.Add(); - var atts = new ObjectAttributes {ColorSource = ObjectColorSource.ColorFromObject}; + ObjectAttributes atts = new ObjectAttributes { ColorSource = ObjectColorSource.ColorFromObject }; atts.AddToGroup(gi); - for (var mi = 0; mi < 6; mi++) + for (int mi = 0; mi < 6; mi++) { atts.ObjectColor = colors[mi]; doc.Objects.AddMesh(meshes[mi], atts); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsMeshBrep.cs b/rhinocommon/cs/SampleCsCommands/SampleCsMeshBrep.cs index 00ba047a..b2c74845 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsMeshBrep.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsMeshBrep.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsMeshOutline.cs b/rhinocommon/cs/SampleCsCommands/SampleCsMeshOutline.cs index 4ab264bf..dd4b333c 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsMeshOutline.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsMeshOutline.cs @@ -1,12 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System; +using System.Collections.Generic; +using System.Linq; namespace SampleCsCommands { @@ -44,10 +44,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (InObjects.Count > 0) { - var flags = Rhino.Render.CustomRenderMeshes.RenderMeshProvider.Flags.Recursive; + Rhino.Render.CustomRenderMeshes.RenderMeshProvider.Flags flags = Rhino.Render.CustomRenderMeshes.RenderMeshProvider.Flags.Recursive; foreach (RhinoObject obj in InObjects) { - var meshRefs = obj.RenderMeshes(MeshType.Render, null, null, ref flags, null, null).ToArray(); + Rhino.Render.CustomRenderMeshes.Instance[] meshRefs = obj.RenderMeshes(MeshType.Render, null, null, ref flags, null, null).ToArray(); if (null != meshRefs) { for (int i = 0; i < meshRefs.Length; i++) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsModifySphereRadius.cs b/rhinocommon/cs/SampleCsCommands/SampleCsModifySphereRadius.cs index 7e711eed..65dbc8a0 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsModifySphereRadius.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsModifySphereRadius.cs @@ -46,8 +46,8 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Sometimes, Surface.TryGetSphere() will return a sphere with a left-handed // plane. So, ensure the plane is right-handed. Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane( - sphere.EquatorialPlane.Origin, - sphere.EquatorialPlane.XAxis, + sphere.EquatorialPlane.Origin, + sphere.EquatorialPlane.XAxis, sphere.EquatorialPlane.YAxis ); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsMove.cs b/rhinocommon/cs/SampleCsCommands/SampleCsMove.cs index c2cfa42d..d296e09d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsMove.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsMove.cs @@ -13,7 +13,7 @@ public class SampleCsMove : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var rc = RhinoGet.GetOneObject("Select object to move", false, ObjectType.AnyObject, out ObjRef objref); + Result rc = RhinoGet.GetOneObject("Select object to move", false, ObjectType.AnyObject, out ObjRef objref); if (rc != Result.Success) return rc; if (null == objref) @@ -23,7 +23,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (rc != Result.Success) return rc; - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Point to move to"); gp.SetBasePoint(first_point, true); gp.DrawLineFromPoint(first_point, true); @@ -32,12 +32,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (rc != Result.Success) return rc; - var second_point = gp.Point(); + Point3d second_point = gp.Point(); - var dir = second_point - first_point; + Vector3d dir = second_point - first_point; if (dir.Length > RhinoMath.ZeroTolerance) { - var xform = Transform.Translation(dir); + Transform xform = Transform.Translation(dir); doc.Objects.Transform(objref, xform, true); doc.Views.Redraw(); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsMoveGrips.cs b/rhinocommon/cs/SampleCsCommands/SampleCsMoveGrips.cs index b9071146..191d251d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsMoveGrips.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsMoveGrips.cs @@ -13,24 +13,24 @@ public class SampleCsMoveGrips : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select grips to move"); go.GeometryFilter = ObjectType.Grip; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - using (var object_list = new TransformObjectList()) + using (TransformObjectList object_list = new TransformObjectList()) { object_list.AddObjects(go, true); - var dir = new Vector3d(5, 0, 0); // 5 units in world x-axis direction - var xform = Transform.Translation(dir); + Vector3d dir = new Vector3d(5, 0, 0); // 5 units in world x-axis direction + Transform xform = Transform.Translation(dir); - foreach (var grip in object_list.GripArray()) + foreach (GripObject grip in object_list.GripArray()) grip.Move(xform); - foreach (var owner in object_list.GripOwnerArray()) + foreach (RhinoObject owner in object_list.GripOwnerArray()) doc.Objects.GripUpdate(owner, true); doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsMoveNormal.cs b/rhinocommon/cs/SampleCsCommands/SampleCsMoveNormal.cs index 3963b0e1..34d7d0cc 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsMoveNormal.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsMoveNormal.cs @@ -1,6 +1,5 @@ using Rhino; using Rhino.Commands; -using Rhino.Display; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; @@ -14,11 +13,11 @@ public class SampleCsMoveNormal : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var rc = RhinoGet.GetMultipleObjects("Select objects to move", false, ObjectType.AnyObject, out var objrefs); + Result rc = RhinoGet.GetMultipleObjects("Select objects to move", false, ObjectType.AnyObject, out ObjRef[] objrefs); if (rc != Result.Success) return rc; - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select surface, polysurface, or SubD for normal direction"); go.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go.EnablePreSelect(false, true); @@ -27,26 +26,26 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var rh_obj = go.Object(0).Object(); - var brep = go.Object(0).Brep(); + RhinoObject rh_obj = go.Object(0).Object(); + Brep brep = go.Object(0).Brep(); if (null == rh_obj || null == brep) return Result.Failure; - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Point to move normal from"); gp.Constrain(brep, rh_obj.Attributes.WireDensity, -1, false); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var res = brep.ClosestPoint( - gp.Point(), - out var base_pt, - out var ci, - out var s, - out var t, - doc.ModelAbsoluteTolerance, - out var normal + bool res = brep.ClosestPoint( + gp.Point(), + out Point3d base_pt, + out ComponentIndex ci, + out double s, + out double t, + doc.ModelAbsoluteTolerance, + out Vector3d normal ); if (!res || ci.ComponentIndexType != ComponentIndexType.BrepFace) @@ -61,14 +60,14 @@ out var normal if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var dir = gp.Point() - base_pt; + Vector3d dir = gp.Point() - base_pt; if (!dir.IsTiny()) { - var xform = Transform.Translation(dir); + Transform xform = Transform.Translation(dir); - foreach (var objref in objrefs) + foreach (ObjRef objref in objrefs) { - var obj = objref.Object(); + RhinoObject obj = objref.Object(); if (null != obj) doc.Objects.Transform(objref, xform, true); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsNamedPlaneSurface.cs b/rhinocommon/cs/SampleCsCommands/SampleCsNamedPlaneSurface.cs index 51b6b3fd..856697eb 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsNamedPlaneSurface.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsNamedPlaneSurface.cs @@ -12,13 +12,13 @@ public class SampleCsNamedPlaneSurface : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Point3d[] corners; - var rc = RhinoGet.GetRectangle(out corners); + Result rc = RhinoGet.GetRectangle(out corners); if (rc != Result.Success) return rc; - var plane = new Plane(corners[0], corners[1], corners[2]); + Plane plane = new Plane(corners[0], corners[1], corners[2]); - var plane_surface = new PlaneSurface( + PlaneSurface plane_surface = new PlaneSurface( plane, new Interval(0, corners[0].DistanceTo(corners[1])), new Interval(0, corners[1].DistanceTo(corners[2])) @@ -27,17 +27,17 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) rc = Result.Cancel; if (plane_surface.IsValid) { - var layer_name = doc.Layers.GetUnusedLayerName(); + string layer_name = doc.Layers.GetUnusedLayerName(); rc = RhinoGet.GetString("Name of layer to create", true, ref layer_name); if (rc == Result.Success && !string.IsNullOrEmpty(layer_name)) { - var layer_index = doc.Layers.FindByFullPath(layer_name, -1); + int layer_index = doc.Layers.FindByFullPath(layer_name, -1); if (-1 == layer_index) layer_index = doc.Layers.Add(layer_name, System.Drawing.Color.Black); if (layer_index >= 0) { - var attribs = doc.CreateDefaultAttributes(); + Rhino.DocObjects.ObjectAttributes attribs = doc.CreateDefaultAttributes(); attribs.LayerIndex = layer_index; attribs.Name = layer_name; doc.Objects.AddSurface(plane_surface, attribs); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs b/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs index d891188d..70a950a8 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsNurbsCircle.cs @@ -20,7 +20,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) const int knot_count = cv_count + degree - 1; // Define the "Euclidean" (world 3-D) locations for the control points. - var points = new Point3d[cv_count]; + Point3d[] points = new Point3d[cv_count]; points[0] = new Point3d(2.500, 0.000, 0.000); points[1] = new Point3d(5.000, 0.000, 0.000); points[2] = new Point3d(3.750, 2.165, 0.000); @@ -32,7 +32,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Define the weights // Weights must be > 0. // In general you should set the first and last weight to 1. - var weights = new double[cv_count]; + double[] weights = new double[cv_count]; weights[0] = 1.0; weights[1] = 0.5; weights[2] = 1.0; @@ -47,7 +47,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // In this example the first three knots are 0 and the last three knots are 3. // The interior knots can have multiplicity from 1 (a "simple" knot) // to degree (a "full multiplicity") - var knots = new double[knot_count]; + double[] knots = new double[knot_count]; // Start with a full multiplicity knot knots[0] = 0.000; knots[1] = 0.000; @@ -62,30 +62,30 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) knots[7] = 1.000; // Create a rational NURBS curve - var curve = new NurbsCurve(3, true, order, cv_count); + NurbsCurve curve = new NurbsCurve(3, true, order, cv_count); // Set the control points and weights. // Since our curve is rational, we need homogeneous points (4-D - for (var ci = 0; ci < cv_count; ci++) + for (int ci = 0; ci < cv_count; ci++) { - var cv = new Point4d(points[ci].X * weights[ci], points[ci].Y * weights[ci], points[ci].Z * weights[ci], weights[ci]); + Point4d cv = new Point4d(points[ci].X * weights[ci], points[ci].Y * weights[ci], points[ci].Z * weights[ci], weights[ci]); curve.Points.SetPoint(ci, cv); } // Set the knots - for (var ki = 0; ki < knot_count; ki++) + for (int ki = 0; ki < knot_count; ki++) curve.Knots[ki] = knots[ki]; if (curve.IsValid) { // Parameterization should match the length of a curve - var length = curve.GetLength(); - var domain = new Interval(0.0, length); + double length = curve.GetLength(); + Interval domain = new Interval(0.0, length); curve.Domain = domain; doc.Objects.AddCurve(curve); doc.Views.Redraw(); - } + } return Result.Success; } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsObjectEnumerator.cs b/rhinocommon/cs/SampleCsCommands/SampleCsObjectEnumerator.cs index 0f38de1d..07d3fc2a 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsObjectEnumerator.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsObjectEnumerator.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Input; @@ -22,37 +21,37 @@ public class SampleCsObjectEnumerator : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Get persistent settings - var bNormal = Settings.GetBool(Normal, true); - var bLocked = Settings.GetBool(Locked, true); - var bHidden = Settings.GetBool(Hidden, true); - var bActive = Settings.GetBool(Active, true); - var bReference = Settings.GetBool(Reference, true); + bool bNormal = Settings.GetBool(Normal, true); + bool bLocked = Settings.GetBool(Locked, true); + bool bHidden = Settings.GetBool(Hidden, true); + bool bActive = Settings.GetBool(Active, true); + bool bReference = Settings.GetBool(Reference, true); // Create command line options - var optNormal = new OptionToggle(bNormal, OffValue, OnValue); - var optLocked = new OptionToggle(bLocked, OffValue, OnValue); - var optHidden = new OptionToggle(bHidden, OffValue, OnValue); - var optActive = new OptionToggle(bActive, OffValue, OnValue); - var optReference = new OptionToggle(bReference, OffValue, OnValue); + OptionToggle optNormal = new OptionToggle(bNormal, OffValue, OnValue); + OptionToggle optLocked = new OptionToggle(bLocked, OffValue, OnValue); + OptionToggle optHidden = new OptionToggle(bHidden, OffValue, OnValue); + OptionToggle optActive = new OptionToggle(bActive, OffValue, OnValue); + OptionToggle optReference = new OptionToggle(bReference, OffValue, OnValue); - var go = new GetOption(); + GetOption go = new GetOption(); go.SetCommandPrompt("Object enumerator options"); go.AcceptNothing(true); while (true) { go.ClearCommandOptions(); - var idxNormal = go.AddOptionToggle(Normal, ref optNormal); - var idxLocked = go.AddOptionToggle(Locked, ref optLocked); - var idxHidden = go.AddOptionToggle(Hidden, ref optHidden); - var idxActive = go.AddOptionToggle(Active, ref optActive); - var idxReference = go.AddOptionToggle(Reference, ref optReference); + int idxNormal = go.AddOptionToggle(Normal, ref optNormal); + int idxLocked = go.AddOptionToggle(Locked, ref optLocked); + int idxHidden = go.AddOptionToggle(Hidden, ref optHidden); + int idxActive = go.AddOptionToggle(Active, ref optActive); + int idxReference = go.AddOptionToggle(Reference, ref optReference); // Get the options - var res = go.Get(); + GetResult res = go.Get(); if (res == GetResult.Option) { - var index = go.Option().Index; + int index = go.Option().Index; if (index == idxNormal) bNormal = optNormal.CurrentValue; else if (index == idxLocked) @@ -71,9 +70,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (!bNormal && !bLocked && !bHidden) { - var msg = string.Format("Either \"{0}\" or \"{1}\" or \"{2}\" must be \"{3}\"", - Normal, - Locked, + string msg = string.Format("Either \"{0}\" or \"{1}\" or \"{2}\" must be \"{3}\"", + Normal, + Locked, Hidden, OnValue ); @@ -83,9 +82,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (!bActive && !bReference) { - var msg = string.Format("Either \"{0}\" or \"{1}\" must be \"{2}\"", - Active, - Reference, + string msg = string.Format("Either \"{0}\" or \"{1}\" must be \"{2}\"", + Active, + Reference, OnValue ); RhinoApp.WriteLine(msg); @@ -95,7 +94,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) break; } - var settings = new ObjectEnumeratorSettings + ObjectEnumeratorSettings settings = new ObjectEnumeratorSettings { NormalObjects = bNormal, LockedObjects = bLocked, @@ -106,12 +105,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) IncludeGrips = false }; - var objects = doc.Objects.GetObjectList(settings); - foreach (var obj in objects) + System.Collections.Generic.IEnumerable objects = doc.Objects.GetObjectList(settings); + foreach (RhinoObject obj in objects) { - var msg = string.Format("{0}, {1}, {2}, {3}", + string msg = string.Format("{0}, {1}, {2}, {3}", obj.Id, - obj.ShortDescription(false), + obj.ShortDescription(false), obj.IsNormal ? Normal : obj.IsLocked ? Locked : Hidden, obj.IsReference ? Reference : Active ); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsOpen3dm.cs b/rhinocommon/cs/SampleCsCommands/SampleCsOpen3dm.cs index a280049f..d16ad3ff 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsOpen3dm.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsOpen3dm.cs @@ -13,7 +13,7 @@ public class SampleCsOpen3dm : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var filename = string.Empty; + string filename = string.Empty; if (mode == Rhino.Commands.RunMode.Interactive) filename = RhinoGet.GetFileName(GetFileNameMode.OpenRhinoOnly, null, "Open", RhinoApp.MainWindowHandle()); else @@ -31,7 +31,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Make sure to surround filename string with double-quote characters // in case the path contains spaces. - var script = string.Format("_-Open \"{0}\"", filename); + string script = string.Format("_-Open \"{0}\"", filename); RhinoApp.RunScript(script, false); return Result.Success; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsOpenDwg.cs b/rhinocommon/cs/SampleCsCommands/SampleCsOpenDwg.cs index 6d2f56d5..0014a8bc 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsOpenDwg.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsOpenDwg.cs @@ -1,8 +1,8 @@ -using System; -using System.IO; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Input; +using System; +using System.IO; namespace SampleCsCommands { @@ -14,7 +14,7 @@ public class SampleCsOpenDwg : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { string filename = null; - var rc = RhinoGet.GetString("Name of AutoCAD DWG file to open", false, ref filename); + Result rc = RhinoGet.GetString("Name of AutoCAD DWG file to open", false, ref filename); if (rc != Result.Success) return rc; @@ -28,7 +28,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Failure; } - var extension = Path.GetExtension(filename); + string extension = Path.GetExtension(filename); if (string.IsNullOrEmpty(extension)) return Result.Nothing; @@ -40,7 +40,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Make sure to surround filename string with double-quote characters // in case the path contains spaces. - var script = string.Format("_-Open \"{0}\" _Enter", filename); + string script = string.Format("_-Open \"{0}\" _Enter", filename); RhinoApp.RunScript(script, false); return Result.Success; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsOptionsList.cs b/rhinocommon/cs/SampleCsCommands/SampleCsOptionsList.cs index bd7df19e..f4ed6961 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsOptionsList.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsOptionsList.cs @@ -10,29 +10,29 @@ public class SampleCsOptionsList : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var fruit_list = new[] { "Apple", "Bannana", "Grape", "Mango", "Orange", "Pear" }; - var nut_list = new[] { "Almonds", "Cashews", "Hazelnuts", "Pecans", "Pistachios", "Walnuts" }; - var vegetable_list = new[] { "Asparagus", "Broccoli", "Carrot", "Corn", "Lettuce", "Onion" }; + string[] fruit_list = new[] { "Apple", "Bannana", "Grape", "Mango", "Orange", "Pear" }; + string[] nut_list = new[] { "Almonds", "Cashews", "Hazelnuts", "Pecans", "Pistachios", "Walnuts" }; + string[] vegetable_list = new[] { "Asparagus", "Broccoli", "Carrot", "Corn", "Lettuce", "Onion" }; // Get persistent settings - var fruit_value = Settings.GetInteger("Fruit", 0); - var nut_value = Settings.GetInteger("Nut", 0); - var vegetable_value = Settings.GetInteger("Vegetable", 0); + int fruit_value = Settings.GetInteger("Fruit", 0); + int nut_value = Settings.GetInteger("Nut", 0); + int vegetable_value = Settings.GetInteger("Vegetable", 0); - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("GetPoint with options"); - var rc = Result.Cancel; + Result rc = Result.Cancel; while (true) { gp.ClearCommandOptions(); - var fruit_index = gp.AddOptionList("Fruit", fruit_list, fruit_value); - var nut_index = gp.AddOptionList("Nut", nut_list, nut_value); - var vegetable_index = gp.AddOptionList("Vegetable", vegetable_list, vegetable_value); + int fruit_index = gp.AddOptionList("Fruit", fruit_list, fruit_value); + int nut_index = gp.AddOptionList("Nut", nut_list, nut_value); + int vegetable_index = gp.AddOptionList("Vegetable", vegetable_list, vegetable_value); - var res = gp.Get(); + Rhino.Input.GetResult res = gp.Get(); if (res == Rhino.Input.GetResult.Point) { @@ -42,7 +42,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else if (res == Rhino.Input.GetResult.Option) { - var option = gp.Option(); + CommandLineOption option = gp.Option(); if (null != option) { if (option.Index == fruit_index) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsOrientOnMesh.cs b/rhinocommon/cs/SampleCsCommands/SampleCsOrientOnMesh.cs index dfe3427c..21393968 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsOrientOnMesh.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsOrientOnMesh.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -21,7 +21,7 @@ public class SampleCsOrientOnMesh : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Select objects to orient - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects to orient"); go.SubObjectSelect = false; go.EnableIgnoreGrips(true); @@ -30,18 +30,18 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return go.CommandResult(); // Point to move from - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Point to move from"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); // Calculate source plane - var plane = gp.View().ActiveViewport.ConstructionPlane(); + Plane plane = gp.View().ActiveViewport.ConstructionPlane(); plane.Origin = gp.Point(); // Mesh to orient on - var gm = new GetObject(); + GetObject gm = new GetObject(); gm.SetCommandPrompt("Mesh to orient on"); gm.GeometryFilter = ObjectType.Mesh; gm.EnablePreSelect(false, true); @@ -50,12 +50,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gm.CommandResult() != Result.Success) return gm.CommandResult(); - var mesh = gm.Object(0).Mesh(); + Mesh mesh = gm.Object(0).Mesh(); if (null == mesh) return Result.Failure; // Point on mesh to orient to - var gpm = new GetPointOnMesh(mesh, plane); + GetPointOnMesh gpm = new GetPointOnMesh(mesh, plane); gpm.SetCommandPrompt("Point on mesh to orient to"); gpm.AppendObjects(go); gpm.Get(); @@ -63,12 +63,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return gpm.CommandResult(); // One final calculation - var xform = new Transform(1); + Transform xform = new Transform(1); if (gpm.CalculateTransform(gpm.View().ActiveViewport, gpm.Point(), ref xform)) { - foreach (var objRef in go.Objects()) + foreach (ObjRef objRef in go.Objects()) { - var obj = objRef.Object(); + RhinoObject obj = objRef.Object(); if (null != obj) doc.Objects.Transform(obj, xform, true); } @@ -91,7 +91,7 @@ class GetPointOnMesh : GetPoint private List m_objects; // Mesh face plane cache - private readonly Dictionary m_face_planes; + private readonly Dictionary m_face_planes; /// /// Public constructor @@ -116,9 +116,9 @@ public void AppendObjects(GetObject go) if (null == m_objects) m_objects = new List(); - foreach (var objRef in go.Objects()) + foreach (ObjRef objRef in go.Objects()) { - var obj = objRef.Object(); + RhinoObject obj = objRef.Object(); if (null != obj) m_objects.Add(obj); } @@ -130,8 +130,8 @@ public void AppendObjects(GetObject go) /// public bool CalculateTransform(RhinoViewport vp, Point3d pt, ref Transform xform) { - var rc = false; - var mp = m_mesh.ClosestMeshPoint(pt, 0.0); + bool rc = false; + MeshPoint mp = m_mesh.ClosestMeshPoint(pt, 0.0); if (null != mp) { Plane meshPlane; @@ -160,7 +160,7 @@ protected override void OnDynamicDraw(GetPointDrawEventArgs e) { if (m_draw) { - foreach (var obj in m_objects) + foreach (RhinoObject obj in m_objects) e.Display.DrawObject(obj, m_xform); } } @@ -171,10 +171,10 @@ protected override void OnDynamicDraw(GetPointDrawEventArgs e) private bool MeshFacePlane(MeshPoint mp, out Plane plane) { plane = new Plane(); - var rc = false; + bool rc = false; if (null != mp && mp.ComponentIndex.ComponentIndexType == ComponentIndexType.MeshFace) { - var mesh = mp.Mesh; + Mesh mesh = mp.Mesh; if (null != mesh && 0 <= mp.FaceIndex && mp.FaceIndex < mesh.Faces.Count) { if (m_face_planes.ContainsKey(mp.FaceIndex)) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsOrientPerpendicularToCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsOrientPerpendicularToCurve.cs index 8edf8bc1..85e62e63 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsOrientPerpendicularToCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsOrientPerpendicularToCurve.cs @@ -1,9 +1,9 @@ using Rhino; using Rhino.Commands; -using Rhino.DocObjects; using Rhino.Display; -using Rhino.Input.Custom; +using Rhino.DocObjects; using Rhino.Geometry; +using Rhino.Input.Custom; namespace SampleCsCommands { @@ -20,7 +20,7 @@ public class SampleCsOrientPerpendicularToCurve : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Select objects to orient - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects to orient"); go.SubObjectSelect = false; go.GroupSelect = true; @@ -29,14 +29,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return go.CommandResult(); // Point to orient from - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Point to orient from"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); // Define source plane - var view = gp.View(); + RhinoView view = gp.View(); if (view == null) { view = doc.Views.ActiveView; @@ -44,11 +44,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Failure; } - var plane = view.ActiveViewport.ConstructionPlane(); + Plane plane = view.ActiveViewport.ConstructionPlane(); plane.Origin = gp.Point(); // Curve to orient on - var gc = new GetObject(); + GetObject gc = new GetObject(); gc.SetCommandPrompt("Curve to orient on"); gc.GeometryFilter = ObjectType.Curve; gc.EnablePreSelect(false, true); @@ -57,9 +57,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gc.CommandResult() != Result.Success) return gc.CommandResult(); - var objref = gc.Object(0); - var obj = objref.Object(); - var curve = objref.Curve(); + ObjRef objref = gc.Object(0); + RhinoObject obj = objref.Object(); + Curve curve = objref.Curve(); if (obj == null || curve == null) return Result.Failure; @@ -67,14 +67,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) obj.Select(false); // Point on surface to orient to - var gx = new GetOrientPerpendicularPoint(curve, plane, go.Object(0).Object()); + GetOrientPerpendicularPoint gx = new GetOrientPerpendicularPoint(curve, plane, go.Object(0).Object()); gx.SetCommandPrompt("New base point on curve"); gx.Get(); if (gx.CommandResult() != Result.Success) return gx.CommandResult(); // One final calculation - var xform = new Transform(1); + Transform xform = new Transform(1); if (gx.CalculateTransform(gx.View().ActiveViewport, gx.Point(), ref xform)) { doc.Objects.Transform(go.Object(0).Object(), xform, true); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsOverCut.cs b/rhinocommon/cs/SampleCsCommands/SampleCsOverCut.cs index ff6d057b..faec6471 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsOverCut.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsOverCut.cs @@ -1,14 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; namespace SampleCsCommands { @@ -42,20 +42,20 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) Tolerance = doc.ModelAbsoluteTolerance; // Get persistent settings - var settings = Settings; - var radius = settings.GetDouble("Radius", RADIUS); - var cut_type = settings.GetEnumValue("CutType", CUTTYPE); + PersistentSettings settings = Settings; + double radius = settings.GetDouble("Radius", RADIUS); + CutType cut_type = settings.GetEnumValue("CutType", CUTTYPE); // Select closed,planar curve - var go = new GetClosedPlanarPolyline(Tolerance); + GetClosedPlanarPolyline go = new GetClosedPlanarPolyline(Tolerance); go.SetCommandPrompt("Select closed, planar polyline"); go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); // Get curve - var obj_ref = go.Object(0); - var curve = obj_ref.Curve(); + ObjRef obj_ref = go.Object(0); + Curve curve = obj_ref.Curve(); if (null == curve || !curve.IsClosed || !curve.IsPlanar()) return Result.Failure; @@ -73,7 +73,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Failure; // Get corner point indices - var indices = FindInnerCornerPoints(curve, polyline, plane); + int[] indices = FindInnerCornerPoints(curve, polyline, plane); if (0 == indices.Length) { RhinoApp.WriteLine("No inner corners found."); @@ -81,7 +81,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } // Show preview conduit - var conduit = new SampleCsOverCutConduit + SampleCsOverCutConduit conduit = new SampleCsOverCutConduit { Circles = CalculateCuttingCircles(curve, polyline, indices, plane, radius, cut_type), Enabled = true @@ -91,25 +91,25 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) Result rc; // Choose overcut options - var gp = new GetOption(); + GetOption gp = new GetOption(); gp.SetCommandPrompt("Choose overcut option"); gp.AcceptNothing(true); - for (;;) + for (; ; ) { gp.ClearCommandOptions(); - var cut_type_index = gp.AddOptionEnumList("CutType", cut_type); - var radius_option = new OptionDouble(radius, true, Tolerance); - var radius_index = gp.AddOptionDouble("Radius", ref radius_option); - var res = gp.Get(); + int cut_type_index = gp.AddOptionEnumList("CutType", cut_type); + OptionDouble radius_option = new OptionDouble(radius, true, Tolerance); + int radius_index = gp.AddOptionDouble("Radius", ref radius_option); + GetResult res = gp.Get(); if (res == GetResult.Option) { - var option = gp.Option(); + CommandLineOption option = gp.Option(); if (null != option) { if (option.Index == cut_type_index) { - var list = Enum.GetValues(typeof (CutType)).Cast().ToList(); + List list = Enum.GetValues(typeof(CutType)).Cast().ToList(); cut_type = list[option.CurrentListOptionIndex]; } else if (option.Index == radius_index) @@ -138,11 +138,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (rc == Result.Success) { // Try differencing circles from curve - var success = true; - var new_curve = curve; - for (var i = 0; i < conduit.Circles.Count && success; i++) + bool success = true; + Curve new_curve = curve; + for (int i = 0; i < conduit.Circles.Count && success; i++) { - var new_curves = Curve.CreateBooleanDifference(new_curve, new ArcCurve(conduit.Circles[i]), doc.ModelAbsoluteTolerance); + Curve[] new_curves = Curve.CreateBooleanDifference(new_curve, new ArcCurve(conduit.Circles[i]), doc.ModelAbsoluteTolerance); if (1 == new_curves.Length && null != new_curves[0]) new_curve = new_curves[0]; else @@ -156,7 +156,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else { - for (var i = 0; i < conduit.Circles.Count; i++) + for (int i = 0; i < conduit.Circles.Count; i++) doc.Objects.AddCircle(conduit.Circles[i]); } @@ -178,15 +178,15 @@ private int[] FindInnerCornerPoints(Curve curve, Polyline polyline, Plane plane) if (null == curve || null == polyline) return new int[0]; - var indices = new List(); + List indices = new List(); - for (var current = 0; current < polyline.Count; current++) + for (int current = 0; current < polyline.Count; current++) { - var prev = (current == 0) ? polyline.Count - 1 : current - 1; - var dir = polyline[current] - polyline[prev]; + int prev = (current == 0) ? polyline.Count - 1 : current - 1; + Vector3d dir = polyline[current] - polyline[prev]; dir.Unitize(); - dir *= 2.1*Tolerance; - var point = polyline[current] + dir; + dir *= 2.1 * Tolerance; + Point3d point = polyline[current] + dir; if (PointContainment.Inside == curve.Contains(point, plane, Tolerance)) indices.Add(current); } @@ -199,14 +199,14 @@ private int[] FindInnerCornerPoints(Curve curve, Polyline polyline, Plane plane) /// private List CalculateCuttingCircles(Curve curve, Polyline polyline, int[] indices, Plane plane, double radius, CutType cutType) { - var circles = new List(); + List circles = new List(); if (null == curve || null == polyline || null == indices) return circles; - for (var i = 0; i < indices.Length; i++) + for (int i = 0; i < indices.Length; i++) { - var current = indices[i]; + int current = indices[i]; int prev, next; if (current == 0) { @@ -224,23 +224,23 @@ private List CalculateCuttingCircles(Curve curve, Polyline polyline, int next = current + 1; } - var dir0 = polyline[prev] - polyline[current]; - var dir1 = polyline[next] - polyline[current]; + Vector3d dir0 = polyline[prev] - polyline[current]; + Vector3d dir1 = polyline[next] - polyline[current]; if (cutType == CutType.Corner) { dir0.Unitize(); dir1.Unitize(); - var dir = 0.5 * (dir0 + dir1); + Vector3d dir = 0.5 * (dir0 + dir1); dir.Unitize(); dir *= radius; - var circle_plane = plane; + Plane circle_plane = plane; circle_plane.Origin = polyline[current]; - var circle = new Circle(circle_plane, radius); + Circle circle = new Circle(circle_plane, radius); - var xform = Transform.Translation(dir); + Transform xform = Transform.Translation(dir); circle.Transform(xform); circles.Add(circle); @@ -251,10 +251,10 @@ private List CalculateCuttingCircles(Curve curve, Polyline polyline, int dir0.Unitize(); dir1.Unitize(); - var dir = Vector3d.Unset; + Vector3d dir = Vector3d.Unset; dir0 *= 2.1 * Tolerance; - var point = polyline[prev] + dir0; + Point3d point = polyline[prev] + dir0; if (PointContainment.Inside == curve.Contains(point, plane, Tolerance)) dir = dir0; else @@ -270,11 +270,11 @@ private List CalculateCuttingCircles(Curve curve, Polyline polyline, int dir.Unitize(); dir *= radius; - var circle_plane = plane; + Plane circle_plane = plane; circle_plane.Origin = polyline[current]; - var circle = new Circle(circle_plane, radius); + Circle circle = new Circle(circle_plane, radius); - var xform = Transform.Translation(dir); + Transform xform = Transform.Translation(dir); circle.Transform(xform); circles.Add(circle); @@ -286,10 +286,10 @@ private List CalculateCuttingCircles(Curve curve, Polyline polyline, int dir0.Unitize(); dir1.Unitize(); - var dir = Vector3d.Unset; + Vector3d dir = Vector3d.Unset; dir0 *= 2.1 * Tolerance; - var point = polyline[prev] + dir0; + Point3d point = polyline[prev] + dir0; if (PointContainment.Inside != curve.Contains(point, plane, Tolerance)) dir = dir0; else @@ -305,11 +305,11 @@ private List CalculateCuttingCircles(Curve curve, Polyline polyline, int dir.Unitize(); dir *= radius; - var circle_plane = plane; + Plane circle_plane = plane; circle_plane.Origin = polyline[current]; - var circle = new Circle(circle_plane, radius); + Circle circle = new Circle(circle_plane, radius); - var xform = Transform.Translation(dir); + Transform xform = Transform.Translation(dir); circle.Transform(xform); circles.Add(circle); @@ -329,7 +329,7 @@ private List CalculateCuttingCircles(Curve curve, Polyline polyline, int /// The concave points if successful. private static Point3d[] FindConcaveCornerPoints(Curve curve, double tolerance) { - var rc = new Point3d[0]; + Point3d[] rc = new Point3d[0]; // Make sure we have a curve and it's closed. if (null == curve || !curve.IsClosed) @@ -350,22 +350,22 @@ private static Point3d[] FindConcaveCornerPoints(Curve curve, double tolerance) polyline.RemoveAt(polyline.Count - 1); // Find the concave corner points... - var points = new List(); - for (var current = 0; current < polyline.Count; current++) + List points = new List(); + for (int current = 0; current < polyline.Count; current++) { - var prev = current == 0 ? polyline.Count - 1 : current - 1; - var next = current == polyline.Count - 1 ? 0 : current + 1; + int prev = current == 0 ? polyline.Count - 1 : current - 1; + int next = current == polyline.Count - 1 ? 0 : current + 1; - var dir0 = polyline[current] - polyline[prev]; + Vector3d dir0 = polyline[current] - polyline[prev]; dir0.Unitize(); - var dir1 = polyline[next] - polyline[current]; + Vector3d dir1 = polyline[next] - polyline[current]; dir1.Unitize(); - var dir2 = Vector3d.CrossProduct(dir0, dir1); + Vector3d dir2 = Vector3d.CrossProduct(dir0, dir1); dir2.Unitize(); - var dot = dir2 * plane.Normal; // dot product + double dot = dir2 * plane.Normal; // dot product if (dot < 0.0) points.Add(polyline[current]); } @@ -382,7 +382,7 @@ private static Point3d[] FindConcaveCornerPoints(Curve curve, double tolerance) internal class SampleCsOverCutConduit : DisplayConduit { private Color TrackingColor { get; } - public List Circles { get; set; } + public List Circles { get; set; } /// /// Constructor @@ -400,7 +400,7 @@ protected override void DrawOverlay(DrawEventArgs e) { if (null != Circles) { - for (var i = 0; i < Circles.Count; i++) + for (int i = 0; i < Circles.Count; i++) { e.Display.DrawCircle(Circles[i], TrackingColor); } @@ -429,7 +429,7 @@ public GetClosedPlanarPolyline(double tolerance) /// public override bool CustomGeometryFilter(RhinoObject rhinoObject, GeometryBase geometry, ComponentIndex componentIndex) { - var curve = geometry as Curve; + Curve curve = geometry as Curve; if (null == curve || !curve.IsClosed || !curve.IsPlanar(Tolerance)) return false; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPerFaceMaterial.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPerFaceMaterial.cs index a8d2b4c5..c79c8086 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPerFaceMaterial.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPerFaceMaterial.cs @@ -1,9 +1,8 @@ -using System; -using System.Security.Cryptography; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -13,10 +12,10 @@ public class SampleCsPerFaceMaterial : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var render_plugin_id = Rhino.Render.Utilities.DefaultRenderPlugInId; - var idi = new GuidIndex(); + Guid render_plugin_id = Rhino.Render.Utilities.DefaultRenderPlugInId; + GuidIndex idi = new GuidIndex(); - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select object with the rendering material you want to assign"); go.EnablePreSelect(false, true); go.EnablePostSelect(true); @@ -24,11 +23,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var obj = go.Object(0).Object(); + RhinoObject obj = go.Object(0).Object(); if (null == obj) return Result.Failure; - var att = obj.Attributes; + ObjectAttributes att = obj.Attributes; if ((idi.Index = att.MaterialIndex) >= 0) { idi.Id = doc.Materials[idi.Index].Id; @@ -39,7 +38,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (att.MaterialRefs.ContainsKey(idi.Id)) mat_ref = att.MaterialRefs[render_plugin_id]; if (null == mat_ref) - mat_ref = att.MaterialRefs[Guid.Empty]; + mat_ref = att.MaterialRefs[Guid.Empty]; if (null != mat_ref) { idi.Id = mat_ref.FrontFaceMaterialId; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPersistentSettings.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPersistentSettings.cs index acbd6a92..5ee9aade 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPersistentSettings.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPersistentSettings.cs @@ -22,32 +22,32 @@ public class SampleCsPersistentSettings : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Get persistent settings (from Registry) - var bool_value = Settings.GetBool("BoolValue", BOOL_DEFAULT); - var int_value = Settings.GetInteger("IntValue", INT_DEFAULT); - var dbl_value = Settings.GetDouble("DblValue", DBL_DEFAULT); - var list_value = Settings.GetInteger("ListValue", LIST_DEFAULT); + bool bool_value = Settings.GetBool("BoolValue", BOOL_DEFAULT); + int int_value = Settings.GetInteger("IntValue", INT_DEFAULT); + double dbl_value = Settings.GetDouble("DblValue", DBL_DEFAULT); + int list_value = Settings.GetInteger("ListValue", LIST_DEFAULT); - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("GetPoint with options"); - var rc = Result.Cancel; + Result rc = Result.Cancel; while (true) { gp.ClearCommandOptions(); - var bool_option = new OptionToggle(bool_value, "Off", "On"); - var int_option = new OptionInteger(int_value, 1, 99); - var dbl_option = new OptionDouble(dbl_value, 0, 99.9); - var list_items = new[] { "Item0", "Item1", "Item2", "Item3", "Item4" }; + OptionToggle bool_option = new OptionToggle(bool_value, "Off", "On"); + OptionInteger int_option = new OptionInteger(int_value, 1, 99); + OptionDouble dbl_option = new OptionDouble(dbl_value, 0, 99.9); + string[] list_items = new[] { "Item0", "Item1", "Item2", "Item3", "Item4" }; - var bool_index = gp.AddOptionToggle("Boolean", ref bool_option); - var int_index = gp.AddOptionInteger("Integer", ref int_option); - var dbl_index = gp.AddOptionDouble("Double", ref dbl_option); - var list_index = gp.AddOptionList("List", list_items, list_value); - var reset_index = gp.AddOption("Reset"); + int bool_index = gp.AddOptionToggle("Boolean", ref bool_option); + int int_index = gp.AddOptionInteger("Integer", ref int_option); + int dbl_index = gp.AddOptionDouble("Double", ref dbl_option); + int list_index = gp.AddOptionList("List", list_items, list_value); + int reset_index = gp.AddOption("Reset"); - var res = gp.Get(); + Rhino.Input.GetResult res = gp.Get(); if (res == Rhino.Input.GetResult.Point) { @@ -57,7 +57,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else if (res == Rhino.Input.GetResult.Option) { - var option = gp.Option(); + CommandLineOption option = gp.Option(); if (null != option) { if (option.Index == bool_index) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPickHole.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPickHole.cs index 5a95e89b..cdb4412d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPickHole.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPickHole.cs @@ -12,40 +12,40 @@ public class SampleCsPickHole : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select holes"); go.GeometryFilter = ObjectType.BrepLoop; go.GeometryAttributeFilter = GeometryAttributeFilter.InnerLoop; go.GetMultiple(1, 0); if (go.CommandResult() == Result.Success) { - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var obj_ref = go.Object(i); - var ci = obj_ref.GeometryComponentIndex; + ObjRef obj_ref = go.Object(i); + ComponentIndex ci = obj_ref.GeometryComponentIndex; if (ci.ComponentIndexType != ComponentIndexType.BrepLoop) return Result.Failure; - var brep = obj_ref.Brep(); + Brep brep = obj_ref.Brep(); if (null == brep) return Result.Failure; - var loop = brep.Loops[ci.Index]; + BrepLoop loop = brep.Loops[ci.Index]; if (null == loop) return Result.Failure; - for (var lti = 0; lti < loop.Trims.Count; lti++) + for (int lti = 0; lti < loop.Trims.Count; lti++) { - var ti = loop.Trims[lti].TrimIndex; - var trim = brep.Trims[ti]; - if (null != trim ) + int ti = loop.Trims[lti].TrimIndex; + BrepTrim trim = brep.Trims[ti]; + if (null != trim) { - var edge = brep.Edges[trim.Edge.EdgeIndex]; + BrepEdge edge = brep.Edges[trim.Edge.EdgeIndex]; if (null != edge) { // TODO: do somethign with edge curve. // In this case, we'll just add a copy to the document. - var curve = edge.DuplicateCurve(); + Curve curve = edge.DuplicateCurve(); if (null != curve) doc.Objects.AddCurve(curve); } @@ -55,7 +55,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } doc.Views.Redraw(); - + return Result.Success; } } @@ -79,96 +79,96 @@ public override bool CustomGeometryFilter(RhinoObject rhObject, GeometryBase geo if (ComponentIndexType.BrepLoop != componentIndex.ComponentIndexType) return false; - var loop = geometry as BrepLoop; - if (null == loop) - return false; + BrepLoop loop = geometry as BrepLoop; + if (null == loop) + return false; - var brep = loop.Brep; - if (null == brep) - return false; + Brep brep = loop.Brep; + if (null == brep) + return false; return IsHoleLoop(brep, loop.LoopIndex, true, false, m_tolerance); } public static bool IsHoleLoop(Brep brep, int loopIndex, bool bPlanarCheck, bool bBoundaryCheck, double tolerance) { - var loop = (null != brep) ? brep.Loops[loopIndex] : null; - if (null == loop ) + BrepLoop loop = (null != brep) ? brep.Loops[loopIndex] : null; + if (null == loop) return false; if (BrepLoopType.Inner != loop.LoopType) return false; - var face = brep.Faces[loop.Face.FaceIndex]; + BrepFace face = brep.Faces[loop.Face.FaceIndex]; if (null == face) return false; - var srf = face.UnderlyingSurface(); + Surface srf = face.UnderlyingSurface(); if (null == srf) return false; if (bPlanarCheck) { - if ((1 != srf.Degree(0) && 1 != srf.Degree(1)) || - (1 != srf.SpanCount(0) && 1 != srf.SpanCount(1)) || + if ((1 != srf.Degree(0) && 1 != srf.Degree(1)) || + (1 != srf.SpanCount(0) && 1 != srf.SpanCount(1)) || !srf.IsPlanar(tolerance)) - return false; + return false; } - - for (var lti = 0; lti < loop.Trims.Count; lti++) + + for (int lti = 0; lti < loop.Trims.Count; lti++) { - var ti = loop.Trims[lti].TrimIndex; - var trim = brep.Trims[ti]; - if (null == trim ) + int ti = loop.Trims[lti].TrimIndex; + BrepTrim trim = brep.Trims[ti]; + if (null == trim) return false; - var edge = brep.Edges[trim.Edge.EdgeIndex]; + BrepEdge edge = brep.Edges[trim.Edge.EdgeIndex]; if (null == edge) return false; - var edge_ti = edge.TrimIndices(); + int[] edge_ti = edge.TrimIndices(); if (0 == edge_ti.Length) return false; switch (edge.TrimCount) { - case 1: - { - if (ti != edge_ti[0]) - return false; - } - break; - case 2: - { - if (bBoundaryCheck ) - return false; - - int other_ti; - if (ti == edge_ti[0]) - other_ti = edge_ti[1]; - else if (ti == edge_ti[1]) - other_ti = edge_ti[0]; - else - return false; - - var other_trim = brep.Trims[other_ti]; - if (null == other_trim) - return false; - - var other_loop = brep.Loops[other_trim.Loop.LoopIndex]; - if (null == other_loop) - return false; - - if (BrepLoopType.Outer != other_loop.LoopType) - return false; - - if (other_loop.Face.FaceIndex == loop.Face.FaceIndex) - return false; - } - break; + case 1: + { + if (ti != edge_ti[0]) + return false; + } + break; + case 2: + { + if (bBoundaryCheck) + return false; + + int other_ti; + if (ti == edge_ti[0]) + other_ti = edge_ti[1]; + else if (ti == edge_ti[1]) + other_ti = edge_ti[0]; + else + return false; + + BrepTrim other_trim = brep.Trims[other_ti]; + if (null == other_trim) + return false; + + BrepLoop other_loop = brep.Loops[other_trim.Loop.LoopIndex]; + if (null == other_loop) + return false; + + if (BrepLoopType.Outer != other_loop.LoopType) + return false; + + if (other_loop.Face.FaceIndex == loop.Face.FaceIndex) + return false; + } + break; - default: - return false; + default: + return false; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPictureFrame.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPictureFrame.cs index 7e2b6aa5..cdd75b87 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPictureFrame.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPictureFrame.cs @@ -1,8 +1,7 @@ -using System; -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; +using System.Windows.Forms; namespace SampleCsCommands { @@ -24,7 +23,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) Result res = Rhino.Input.RhinoGet.GetRectangle(out corners); if (res != Result.Success) return res; - + Point3d p0 = corners[0]; Point3d p1 = corners[1]; Point3d p3 = corners[3]; @@ -35,7 +34,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) doc.Objects.AddPictureFrame(plane, filename, false, width, height, true, false); doc.Views.Redraw(); - + return Result.Success; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPlanarClosedCurveRelationship.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPlanarClosedCurveRelationship.cs index 384f58a7..cbac0642 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPlanarClosedCurveRelationship.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPlanarClosedCurveRelationship.cs @@ -12,7 +12,7 @@ public class SampleCsPlanarClosedCurveRelationship : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select closed, planar curves for containment test"); go.GeometryFilter = ObjectType.Curve; go.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve; @@ -20,14 +20,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var plane = go.View().ActiveViewport.ConstructionPlane(); - var tol = doc.ModelAbsoluteTolerance; + Plane plane = go.View().ActiveViewport.ConstructionPlane(); + double tol = doc.ModelAbsoluteTolerance; - var crvs = new Curve[2]; - for (var i = 0; i < 2; i++) + Curve[] crvs = new Curve[2]; + for (int i = 0; i < 2; i++) { - var rh_ref = go.Object(i); - var rh_obj = rh_ref.Object(); + ObjRef rh_ref = go.Object(i); + RhinoObject rh_obj = rh_ref.Object(); crvs[i] = rh_ref.Curve(); if (null == rh_obj || null == crvs[i]) return Result.Failure; @@ -41,7 +41,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } } - var result = Curve.PlanarClosedCurveRelationship(crvs[0], crvs[1], plane, tol); + RegionContainment result = Curve.PlanarClosedCurveRelationship(crvs[0], crvs[1], plane, tol); switch (result) { case RegionContainment.Disjoint: diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPlanarFaceLoops.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPlanarFaceLoops.cs index b425cdc1..327838c7 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPlanarFaceLoops.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPlanarFaceLoops.cs @@ -13,7 +13,7 @@ public class SampleCsPlanarFaceLoops : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Select planar surface - var gs = new GetObject(); + GetObject gs = new GetObject(); gs.SetCommandPrompt("Select planar surface"); gs.GeometryFilter = ObjectType.Surface; gs.SubObjectSelect = false; @@ -21,18 +21,18 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gs.CommandResult() != Result.Success) return gs.CommandResult(); - var brep_ref = gs.Object(0); - var brep = brep_ref.Brep(); + ObjRef brep_ref = gs.Object(0); + Brep brep = brep_ref.Brep(); if (null == brep) return Result.Failure; // Verify underlying surface is a PlaneSurface - var plane_surface = brep.Faces[0].UnderlyingSurface() as PlaneSurface; + PlaneSurface plane_surface = brep.Faces[0].UnderlyingSurface() as PlaneSurface; if (null == plane_surface) return Result.Nothing; // Select trimming curves on planar surface - var gc = new GetObject(); + GetObject gc = new GetObject(); gc.SetCommandPrompt("Select trimming curves on planar surface"); gc.GeometryFilter = ObjectType.Curve; gc.GroupSelect = true; @@ -44,14 +44,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return gc.CommandResult(); // Make a copy of the selected Brep - var new_brep = new Brep(); + Brep new_brep = new Brep(); new_brep.Append(brep); // Add each selected curve a a inner planar face loop - var boundary = new Curve[1]; - for (var i = 0; i < gc.ObjectCount; i++) + Curve[] boundary = new Curve[1]; + for (int i = 0; i < gc.ObjectCount; i++) { - var curve = gc.Object(i).Curve(); + Curve curve = gc.Object(i).Curve(); if (null != curve) { boundary[0] = curve; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPointCloudPoints.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPointCloudPoints.cs index 24c62c22..746d75df 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPointCloudPoints.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPointCloudPoints.cs @@ -1,9 +1,9 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -13,27 +13,27 @@ public class SampleCsPointCloudPoints : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select point cloud"); go.GeometryFilter = ObjectType.PointSet; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var point_cloud_object = go.Object(0).Object() as PointCloudObject; + PointCloudObject point_cloud_object = go.Object(0).Object() as PointCloudObject; if (null == point_cloud_object) return Result.Failure; - var gp = new GetPointCloudPoints(point_cloud_object.Id); + GetPointCloudPoints gp = new GetPointCloudPoints(point_cloud_object.Id); gp.SetCommandPrompt("Select point cloud points"); gp.GetMultiple(1, 0); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - foreach (var objref in gp.Objects()) + foreach (ObjRef objref in gp.Objects()) { - var ci = objref.GeometryComponentIndex; - var pt = point_cloud_object.PointCloudGeometry[ci.Index].Location; + ComponentIndex ci = objref.GeometryComponentIndex; + Point3d pt = point_cloud_object.PointCloudGeometry[ci.Index].Location; RhinoApp.WriteLine(string.Format("Index {0}: {1}", ci.Index, pt.ToString())); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPointOnMesh.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPointOnMesh.cs index 5fc7dbdd..d603c164 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPointOnMesh.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPointOnMesh.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; @@ -23,7 +22,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) Rhino.Geometry.Mesh mesh = obj_ref.Mesh(); if (null == mesh) return Result.Failure; - + // Pick a point that is contrained to the mesh GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Pick point on mesh"); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPrePostSelect.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPrePostSelect.cs index df1dd1b3..df029e76 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPrePostSelect.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPrePostSelect.cs @@ -11,16 +11,16 @@ public class SampleCsPrePostSelect : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var have_preselected_objects = false; + bool have_preselected_objects = false; - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects"); go.GeometryFilter = ObjectType.AnyObject; go.GroupSelect = true; go.SubObjectSelect = false; while (true) - { + { go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) @@ -42,9 +42,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (have_preselected_objects) { - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var obj = go.Object(i).Object(); + RhinoObject obj = go.Object(i).Object(); obj?.Select(false); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPrintViewList.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPrintViewList.cs index 0e4246c0..a6e1dd2d 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPrintViewList.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPrintViewList.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsProjectCurvesToBrep.cs b/rhinocommon/cs/SampleCsCommands/SampleCsProjectCurvesToBrep.cs index e8225efb..84bf05ea 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsProjectCurvesToBrep.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsProjectCurvesToBrep.cs @@ -1,10 +1,9 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -15,7 +14,7 @@ public class SampleCsProjectCurvesToBrep : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Select curves to project - var gc = new GetObject(); + GetObject gc = new GetObject(); gc.SetCommandPrompt("Select curves to project"); gc.GeometryFilter = ObjectType.Curve; gc.GetMultiple(1, 0); @@ -23,7 +22,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return gc.CommandResult(); // Select planar surface to project onto - var gs = new GetObject(); + GetObject gs = new GetObject(); gs.SetCommandPrompt("Select planar surface to project onto"); gs.GeometryFilter = ObjectType.Surface; gs.EnablePreSelect(false, true); @@ -33,12 +32,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return gs.CommandResult(); // Get the Brep face - var brep_face = gs.Object(0).Face(); + BrepFace brep_face = gs.Object(0).Face(); if (null == brep_face) return Result.Failure; // Verify the Brep face is planar - var tolerance = doc.ModelAbsoluteTolerance; + double tolerance = doc.ModelAbsoluteTolerance; if (!brep_face.IsPlanar(tolerance)) { RhinoApp.WriteLine("Surface is not planar."); @@ -46,9 +45,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } // Get normal direction of Brep face - var u = brep_face.Domain(0).Min; - var v = brep_face.Domain(1).Min; - var normal = brep_face.NormalAt(u, v); + double u = brep_face.Domain(0).Min; + double v = brep_face.Domain(1).Min; + Vector3d normal = brep_face.NormalAt(u, v); // If the Brep face's orientation is opposite of natural surface orientation, // then reverse the normal vector. if (brep_face.OrientationIsReversed) @@ -58,23 +57,23 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) normal.Reverse(); // Create a array of Breps to project onto - var breps = new Brep[1]; + Brep[] breps = new Brep[1]; breps[0] = brep_face.DuplicateFace(true); // Create a single Brep, including trims // Create a collection of curves to project - var curves = new List(gc.ObjectCount); - for (var i = 0; i < gc.ObjectCount; i++) + List curves = new List(gc.ObjectCount); + for (int i = 0; i < gc.ObjectCount; i++) { - var curve = gc.Object(i).Curve(); + Curve curve = gc.Object(i).Curve(); if (null != curve) curves.Add(curve); } // Do the projection - var projected_curves = Curve.ProjectToBrep(curves, breps, normal, tolerance); + Curve[] projected_curves = Curve.ProjectToBrep(curves, breps, normal, tolerance); // Add the results to the document - foreach (var crv in projected_curves) + foreach (Curve crv in projected_curves) doc.Objects.AddCurve(crv); doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsProjectPointToMesh.cs b/rhinocommon/cs/SampleCsCommands/SampleCsProjectPointToMesh.cs index 8766def9..614f7a84 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsProjectPointToMesh.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsProjectPointToMesh.cs @@ -1,11 +1,10 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Geometry.Intersect; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -15,14 +14,14 @@ public class SampleCsProjectPointToMesh : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var gp = new GetObject(); + GetObject gp = new GetObject(); gp.SetCommandPrompt("Select points to project"); gp.GeometryFilter = ObjectType.Point; gp.GetMultiple(1, 0); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var gm = new GetObject(); + GetObject gm = new GetObject(); gm.SetCommandPrompt("Select mesh to project onto"); gm.GeometryFilter = ObjectType.Mesh; gm.SubObjectSelect = false; @@ -32,25 +31,25 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gm.CommandResult() != Result.Success) return gm.CommandResult(); - var mesh = gm.Object(0).Mesh(); + Mesh mesh = gm.Object(0).Mesh(); if (null == mesh) return Result.Failure; - var meshes = new List(1) {mesh}; + List meshes = new List(1) { mesh }; - var points = new List(gp.ObjectCount); - for (var i = 0; i < gp.ObjectCount; i++) + List points = new List(gp.ObjectCount); + for (int i = 0; i < gp.ObjectCount; i++) { - var point = gp.Object(i).Point(); - if (null != point) + Point point = gp.Object(i).Point(); + if (null != point) points.Add(point.Location); } - var dir = -Vector3d.ZAxis; - var tol = doc.ModelAbsoluteTolerance; + Vector3d dir = -Vector3d.ZAxis; + double tol = doc.ModelAbsoluteTolerance; int[] indices; - var project_points = Intersection.ProjectPointsToMeshesEx(meshes, points, dir, tol, out indices); + Point3d[] project_points = Intersection.ProjectPointsToMeshesEx(meshes, points, dir, tol, out indices); if (null != project_points) { for (int i = 0; i < project_points.Length; i++) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsPullGripsToMesh.cs b/rhinocommon/cs/SampleCsCommands/SampleCsPullGripsToMesh.cs index 4844a58b..8879cf76 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsPullGripsToMesh.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsPullGripsToMesh.cs @@ -14,21 +14,21 @@ public class SampleCsPullGripsToMesh : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var get_grips = new GetObject(); + GetObject get_grips = new GetObject(); get_grips.SetCommandPrompt("Select grips to pull to mesh"); get_grips.GeometryFilter = ObjectType.Grip; get_grips.GetMultiple(1, 0); if (get_grips.CommandResult() != Result.Success) return get_grips.CommandResult(); - var object_list = new TransformObjectList(); + TransformObjectList object_list = new TransformObjectList(); object_list.AddObjects(get_grips, true); - var grip_count = object_list.GripCount; + int grip_count = object_list.GripCount; if (0 == grip_count) return Result.Failure; - var get_mesh = new GetObject(); + GetObject get_mesh = new GetObject(); get_mesh.SetCommandPrompt("Select mesh that pulls"); get_mesh.GeometryFilter = ObjectType.Mesh; get_mesh.EnablePreSelect(false, true); @@ -37,28 +37,28 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (get_mesh.CommandResult() != Result.Success) return get_mesh.CommandResult(); - var mesh = get_mesh.Object(0).Mesh(); + Mesh mesh = get_mesh.Object(0).Mesh(); if (null == mesh) return Result.Failure; - var grips = object_list.GripArray(); - var locations = grips.Select(grip => grip.CurrentLocation).ToArray(); + GripObject[] grips = object_list.GripArray(); + Point3d[] locations = grips.Select(grip => grip.CurrentLocation).ToArray(); if (locations.Length != grip_count) return Result.Failure; - var points = mesh.PullPointsToMesh(locations); + Point3d[] points = mesh.PullPointsToMesh(locations); if (null == points || points.Length != grip_count) return Result.Failure; - for (var i = 0; i < grip_count; i++) + for (int i = 0; i < grip_count; i++) { - var dir = points[i] - grips[i].CurrentLocation; - var xform = Transform.Translation(dir); + Vector3d dir = points[i] - grips[i].CurrentLocation; + Transform xform = Transform.Translation(dir); if (xform.IsValid) grips[i].Move(xform); } - foreach (var owner in object_list.GripOwnerArray()) + foreach (RhinoObject owner in object_list.GripOwnerArray()) doc.Objects.GripUpdate(owner, true); doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsRTree.cs b/rhinocommon/cs/SampleCsCommands/SampleCsRTree.cs index 10657687..6b2933b2 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsRTree.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsRTree.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; namespace SampleCsCommands { @@ -15,7 +15,7 @@ public class SampleCsRTree : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go0 = new GetObject(); + GetObject go0 = new GetObject(); go0.SetCommandPrompt("Select first set of meshes for interference check"); go0.GeometryFilter = ObjectType.Mesh; go0.SubObjectSelect = false; @@ -25,16 +25,16 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go0.CommandResult() != Result.Success) return go0.CommandResult(); - var mesh_list0 = new List(go0.ObjectCount); - foreach (var obj_ref in go0.Objects()) + List mesh_list0 = new List(go0.ObjectCount); + foreach (ObjRef obj_ref in go0.Objects()) { - var mesh = obj_ref.Mesh(); + Mesh mesh = obj_ref.Mesh(); if (null == mesh) return Result.Failure; mesh_list0.Add(mesh); } - var go1 = new GetObject(); + GetObject go1 = new GetObject(); go1.SetCommandPrompt("Select second set of meshes for interference check"); go1.GeometryFilter = ObjectType.Mesh; go1.SubObjectSelect = false; @@ -45,19 +45,19 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go1.CommandResult() != Result.Success) return go1.CommandResult(); - var mesh_list1 = new List(go1.ObjectCount); - foreach (var obj_ref in go1.Objects()) + List mesh_list1 = new List(go1.ObjectCount); + foreach (ObjRef obj_ref in go1.Objects()) { - var mesh = obj_ref.Mesh(); + Mesh mesh = obj_ref.Mesh(); if (null == mesh) return Result.Failure; mesh_list1.Add(mesh); } - var check = new SampleInterferenceCheck(mesh_list0.ToArray(), mesh_list1.ToArray()); - var rc = check.BoxCheck(doc.ModelAbsoluteTolerance); + SampleInterferenceCheck check = new SampleInterferenceCheck(mesh_list0.ToArray(), mesh_list1.ToArray()); + bool rc = check.BoxCheck(doc.ModelAbsoluteTolerance); - var count = check.EventCount; + int count = check.EventCount; if (0 == count) RhinoApp.WriteLine("0 interference events."); else if (1 == count) @@ -69,7 +69,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { doc.Objects.UnselectAll(true); - foreach (var result in check.EventResults) + foreach (Tuple result in check.EventResults) { go0.Object(result.Item1).Object().Select(true, true); go1.Object(result.Item2).Object().Select(true, true); @@ -113,13 +113,13 @@ public bool BoxCheck(double tolerance) if (tolerance <= 0) tolerance = RhinoMath.SqrtEpsilon; - var box_tree = new RTree[2]; + RTree[] box_tree = new RTree[2]; box_tree[0] = new RTree(); box_tree[1] = new RTree(); - var ok = new bool[] { false, false }; + bool[] ok = new bool[] { false, false }; Parallel.For(0, m_mesh_list.Length, i => { ok[i] = MakeBoxTree(m_mesh_list[i].ToArray(), box_tree[i]); }); - var rc = ok[0] && ok[1]; + bool rc = ok[0] && ok[1]; if (rc) rc = RTree.SearchOverlaps(box_tree[0], box_tree[1], tolerance, SearchCallback); @@ -145,13 +145,13 @@ private bool MakeBoxTree(IEnumerable meshes, RTree tree) if (null == meshes || null == tree) return false; - var rc = false; - var element = 0; - foreach (var mesh in meshes) + bool rc = false; + int element = 0; + foreach (Mesh mesh in meshes) { if (null == mesh) continue; - var bbox = mesh.GetBoundingBox(false); + BoundingBox bbox = mesh.GetBoundingBox(false); if (bbox.IsValid) { tree.Insert(bbox, element++); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsRenderBackground.cs b/rhinocommon/cs/SampleCsCommands/SampleCsRenderBackground.cs index 066b06da..388f97f1 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsRenderBackground.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsRenderBackground.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsRestoreNamedView.cs b/rhinocommon/cs/SampleCsCommands/SampleCsRestoreNamedView.cs index 3bab5b03..6de36d96 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsRestoreNamedView.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsRestoreNamedView.cs @@ -10,16 +10,16 @@ public class SampleCsRestoreNamedView : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var view = doc.Views.ActiveView; + Rhino.Display.RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; string name = null; - var rc = RhinoGet.GetString("Named view to restore", false, ref name); + Result rc = RhinoGet.GetString("Named view to restore", false, ref name); if (rc != Result.Success || string.IsNullOrEmpty(name)) return Result.Cancel; - var index = doc.NamedViews.FindByName(name); + int index = doc.NamedViews.FindByName(name); if (index < 0 || index >= doc.NamedViews.Count) { RhinoApp.WriteLine("Named view not found"); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsRotate.cs b/rhinocommon/cs/SampleCsCommands/SampleCsRotate.cs index c1591c45..ca3da747 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsRotate.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsRotate.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.ApplicationSettings; using Rhino.Collections; using Rhino.Commands; @@ -7,6 +6,7 @@ using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -84,16 +84,16 @@ protected override void OnDynamicDraw(GetPointDrawEventArgs e) { if (Transform.IsValid && m_arc.IsValid) { - var color = Rhino.ApplicationSettings.AppearanceSettings.DefaultObjectColor; + System.Drawing.Color color = Rhino.ApplicationSettings.AppearanceSettings.DefaultObjectColor; e.Display.DrawArc(m_arc, color); - var v0 = m_arc.StartPoint - m_arc.Center; + Vector3d v0 = m_arc.StartPoint - m_arc.Center; v0 *= 1.5; e.Display.DrawLine(m_arc.Center, m_arc.Center + v0, color); v0 = m_arc.EndPoint - m_arc.Center; v0 *= 1.5; - var v1 = (e.CurrentPoint - m_arc.Center); + Vector3d v1 = (e.CurrentPoint - m_arc.Center); if (v1.SquareLength > v0.SquareLength) v0 = v1; e.Display.DrawLine(m_arc.Center, m_arc.Center + v0, color); @@ -113,21 +113,21 @@ protected override void OnDynamicDraw(GetPointDrawEventArgs e) private bool CalculatePlaneAngle(Point3d point) { - var plane_point = m_plane.ClosestPoint(point); + Point3d plane_point = m_plane.ClosestPoint(point); - var dir0 = plane_point - m_plane.Origin; - var cos_angle = dir0 * m_plane.XAxis; - var sin_angle = dir0 * m_plane.YAxis; + Vector3d dir0 = plane_point - m_plane.Origin; + double cos_angle = dir0 * m_plane.XAxis; + double sin_angle = dir0 * m_plane.YAxis; dir0.Unitize(); if (0.0 != cos_angle || 0.0 != sin_angle) { - var angle = Math.Atan2(sin_angle, cos_angle); - var a0 = Math.IEEERemainder(0.5 * m_angle / Math.PI, 1.0); - var a1 = Math.IEEERemainder(0.5 * angle / Math.PI, 1.0); + double angle = Math.Atan2(sin_angle, cos_angle); + double a0 = Math.IEEERemainder(0.5 * m_angle / Math.PI, 1.0); + double a1 = Math.IEEERemainder(0.5 * angle / Math.PI, 1.0); if (a0 != a1) { - var da = a1 - a0; + double da = a1 - a0; while (da < -0.5) da += 1.0; while (da > 0.5) @@ -141,15 +141,15 @@ private bool CalculatePlaneAngle(Point3d point) m_angle -= two_pi; } - var dir1 = m_ref_point - m_base_point; - var radius = dir1.Length; + Vector3d dir1 = m_ref_point - m_base_point; + double radius = dir1.Length; dir1.Unitize(); - var x_dir = m_angle < 0.0 ? dir0 : dir1; - var y_dir = Vector3d.CrossProduct(m_plane.Normal, x_dir); + Vector3d x_dir = m_angle < 0.0 ? dir0 : dir1; + Vector3d y_dir = Vector3d.CrossProduct(m_plane.Normal, x_dir); y_dir.Unitize(); - var arc_plane = new Plane(m_plane.Origin, x_dir, y_dir); + Plane arc_plane = new Plane(m_plane.Origin, x_dir, y_dir); m_arc = new Arc(arc_plane, radius, Math.Abs(m_angle)); return m_arc.IsValid; @@ -174,32 +174,32 @@ public class SampleCsRotate : TransformCommand protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Select objects to rotate - var list = new TransformObjectList(); - var rc = SelectObjects("Select objects to rotate", list); + TransformObjectList list = new TransformObjectList(); + Result rc = SelectObjects("Select objects to rotate", list); if (rc != Result.Success) return rc; - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Center of rotation"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); - var view = gp.View(); + RhinoView view = gp.View(); if (null == view) return Result.Failure; - var base_point = gp.Point(); - var plane = view.ActiveViewport.ConstructionPlane(); + Point3d base_point = gp.Point(); + Plane plane = view.ActiveViewport.ConstructionPlane(); plane.Origin = base_point; - var ref_point = Point3d.Unset; + Point3d ref_point = Point3d.Unset; // Angle or first reference point - var gr = new GetReferencePoint(base_point); + GetReferencePoint gr = new GetReferencePoint(base_point); gr.SetCommandPrompt("Angle or first reference point"); - var res = gr.Get(); + GetResult res = gr.Get(); if (res == GetResult.Point) { view = gr.View(); @@ -217,7 +217,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else if (res == GetResult.Number) { - var xform = Transform.Rotation(Rhino.RhinoMath.ToRadians(gr.Number()), plane.Normal, base_point); + Transform xform = Transform.Rotation(Rhino.RhinoMath.ToRadians(gr.Number()), plane.Normal, base_point); rc = xform.IsValid ? Result.Success : Result.Failure; if (rc == Result.Success) { @@ -233,7 +233,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Second reference point - var gx = new GetRotationTransform(plane, base_point, ref_point); + GetRotationTransform gx = new GetRotationTransform(plane, base_point, ref_point); gx.SetCommandPrompt("Second reference point"); gx.AddTransformObjects(list); res = gx.GetXform(); @@ -243,7 +243,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) rc = null != view ? Result.Success : Result.Failure; if (rc == Result.Success) { - var xform = gx.CalculateTransform(view.ActiveViewport, gx.Point()); + Transform xform = gx.CalculateTransform(view.ActiveViewport, gx.Point()); rc = xform.IsValid ? Result.Success : Result.Failure; if (rc == Result.Success) { @@ -254,7 +254,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else if (res == GetResult.Number) { - var xform = Transform.Rotation(Rhino.RhinoMath.ToRadians(gx.Number()), plane.Normal, base_point); + Transform xform = Transform.Rotation(Rhino.RhinoMath.ToRadians(gx.Number()), plane.Normal, base_point); rc = xform.IsValid ? Result.Success : Result.Failure; if (rc == Result.Success) { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSave3DS.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSave3DS.cs index 427a1234..d2af08e9 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSave3DS.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSave3DS.cs @@ -1,8 +1,8 @@ -using System.IO; -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Input.Custom; +using System.IO; +using System.Windows.Forms; namespace SampleCsCommands { @@ -17,7 +17,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) string path; if (mode == RunMode.Interactive) { - var savefile = new SaveFileDialog + SaveFileDialog savefile = new SaveFileDialog { FileName = "Untitled.3ds", Filter = @"3D Studio (*.3ds)|*.3ds||" @@ -29,7 +29,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else { - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Name of 3D Studio file to save"); gs.Get(); if (gs.CommandResult() != Result.Success) @@ -49,7 +49,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // string contains spaces, we will want to surround the string // with double-quote characters so the command line parser // will deal with it property. - var script = $"_-SaveAs \"{path}\" _Enter"; + string script = $"_-SaveAs \"{path}\" _Enter"; RhinoApp.RunScript(script, false); return Result.Success; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSaveAs.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSaveAs.cs index 6645df10..2fe5137a 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSaveAs.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSaveAs.cs @@ -1,7 +1,7 @@ -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Input.Custom; +using System.Windows.Forms; namespace SampleCsCommands { @@ -15,7 +15,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (mode == RunMode.Interactive) { - var savefile = new SaveFileDialog + SaveFileDialog savefile = new SaveFileDialog { FileName = "Untitled.txt", Filter = @"Text files (*.txt)|*.txt|All files (*.*)|*.*" @@ -27,7 +27,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else { - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Name of text file to save"); gs.Get(); if (gs.CommandResult() != Result.Success) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsScriptedSweep2.cs b/rhinocommon/cs/SampleCsCommands/SampleCsScriptedSweep2.cs index 83c17ac1..6cfe3729 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsScriptedSweep2.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsScriptedSweep2.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Input.Custom; +using System; +using System.Collections.Generic; +using System.Text; namespace SampleCsCommands { @@ -15,9 +15,9 @@ public class SampleCsScriptedSweep2 : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var rails = new Guid[2]; + Guid[] rails = new Guid[2]; - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select first rail"); go.GeometryFilter = ObjectType.Curve; go.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve; @@ -27,7 +27,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var obj = go.Object(0).Object(); + RhinoObject obj = go.Object(0).Object(); if (null == obj) return Result.Failure; rails[0] = obj.Id; @@ -43,7 +43,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Failure; rails[1] = obj.Id; - var gc = new GetObject(); + GetObject gc = new GetObject(); gc.SetCommandPrompt("Select cross section curves"); gc.GeometryFilter = ObjectType.Curve; gc.GeometryAttributeFilter = GeometryAttributeFilter.OpenCurve; @@ -54,8 +54,8 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gc.CommandResult() != Result.Success) return gc.CommandResult(); - var curves = new Guid[gc.ObjectCount]; - for (var i = 0; i < gc.ObjectCount; i++) + Guid[] curves = new Guid[gc.ObjectCount]; + for (int i = 0; i < gc.ObjectCount; i++) { obj = gc.Object(i).Object(); if (null == obj) @@ -63,7 +63,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) curves[i] = obj.Id; } - var object_ids = ScriptedSweep2(doc, rails[0], rails[1], curves); + Guid[] object_ids = ScriptedSweep2(doc, rails[0], rails[1], curves); doc.Views.Redraw(); return Result.Success; @@ -73,24 +73,24 @@ private Guid[] ScriptedSweep2(RhinoDoc doc, Guid rail1, Guid rail2, IEnumerable< { doc.Objects.UnselectAll(true); - var sb = new StringBuilder("_-Sweep2 "); + StringBuilder sb = new StringBuilder("_-Sweep2 "); sb.Append(string.Format("_SelID {0} ", rail1)); sb.Append(string.Format("_SelID {0} ", rail2)); - foreach (var shape in shapes) + foreach (Guid shape in shapes) sb.Append(string.Format("_SelID {0} ", shape)); sb.Append(string.Format("_Enter ")); sb.Append(string.Format("_Simplify=_None _Closed=_Yes _MaintainHeight=_Yes _Enter")); - var start_sn = Rhino.DocObjects.RhinoObject.NextRuntimeSerialNumber; + uint start_sn = Rhino.DocObjects.RhinoObject.NextRuntimeSerialNumber; RhinoApp.RunScript(sb.ToString(), false); - var end_sn = Rhino.DocObjects.RhinoObject.NextRuntimeSerialNumber; + uint end_sn = Rhino.DocObjects.RhinoObject.NextRuntimeSerialNumber; if (start_sn == end_sn) return new Guid[0]; - var object_ids = new List(); - for (var sn = start_sn; sn < end_sn; sn++) + List object_ids = new List(); + for (uint sn = start_sn; sn < end_sn; sn++) { - var obj = doc.Objects.Find(sn); + RhinoObject obj = doc.Objects.Find(sn); if (null != obj) object_ids.Add(obj.Id); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSelCircle.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSelCircle.cs index 59d3572c..4867e879 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSelCircle.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSelCircle.cs @@ -14,12 +14,12 @@ public class SampleCsSelCircle : SelCommand protected override bool SelFilter(RhinoObject rhObj) { if (null != rhObj) - { - var curve_obj = rhObj as CurveObject; + { + CurveObject curve_obj = rhObj as CurveObject; if (null != curve_obj) { - var doc = rhObj.Document; - var curve = curve_obj.CurveGeometry; + Rhino.RhinoDoc doc = rhObj.Document; + Curve curve = curve_obj.CurveGeometry; if (null != doc && null != curve) return curve.TryGetCircle(out Circle circle, doc.ModelAbsoluteTolerance); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSelectHoles.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSelectHoles.cs index d5445b3b..ce6e53c8 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSelectHoles.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSelectHoles.cs @@ -21,7 +21,7 @@ public override bool CustomGeometryFilter(RhinoObject rhObject, GeometryBase geo return false; if (!(geometry is BrepLoop loop)) return false; - var brep = loop.Brep; + Brep brep = loop.Brep; return null != brep && IsHoleLoop(brep, componentIndex.Index, true, false, m_tolerance); } @@ -49,15 +49,15 @@ public bool IsHoleLoop(Brep brep, int loopIndex, bool bPlanarCheck, bool bBounda return false; if (loopIndex < 0 || loopIndex >= brep.Loops.Count) return false; - var loop = brep.Loops[loopIndex]; + BrepLoop loop = brep.Loops[loopIndex]; if (null == loop) return false; if (loop.LoopType != BrepLoopType.Inner) return false; - var face = loop.Face; + BrepFace face = loop.Face; if (null == face) return false; - var srf = face.UnderlyingSurface(); + Surface srf = face.UnderlyingSurface(); if (null == srf) return false; @@ -71,13 +71,13 @@ public bool IsHoleLoop(Brep brep, int loopIndex, bool bPlanarCheck, bool bBounda return false; } - for (var lti = 0; lti < loop.Trims.Count; lti++) + for (int lti = 0; lti < loop.Trims.Count; lti++) { - var trim = loop.Trims[lti]; + BrepTrim trim = loop.Trims[lti]; if (null == trim) return false; - var ti = trim.TrimIndex; - var edge = trim.Edge; + int ti = trim.TrimIndex; + BrepEdge edge = trim.Edge; if (null == edge) return false; @@ -91,17 +91,17 @@ public bool IsHoleLoop(Brep brep, int loopIndex, bool bPlanarCheck, bool bBounda { if (bBoundaryCheck) return false; - var other_ti = -1; + int other_ti = -1; if (edge.TrimIndices()[0] == ti) other_ti = edge.TrimIndices()[1]; else if (edge.TrimIndices()[1] == ti) other_ti = edge.TrimIndices()[0]; else return false; - var other_trim = brep.Trims[other_ti]; + BrepTrim other_trim = brep.Trims[other_ti]; if (null == other_trim) return false; - var other_loop = brep.Loops[other_trim.Loop.LoopIndex]; + BrepLoop other_loop = brep.Loops[other_trim.Loop.LoopIndex]; if (null == other_loop) return false; if (other_loop.LoopType != BrepLoopType.Outer) @@ -125,7 +125,7 @@ public class SampleCsSelectHoles : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new SampleGetHole(doc.ModelAbsoluteTolerance); + SampleGetHole go = new SampleGetHole(doc.ModelAbsoluteTolerance); go.SetCommandPrompt("Select holes in one planar surface"); go.GeometryFilter = ObjectType.BrepLoop; go.GetMultiple(1, 0); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSelectLayerObjects.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSelectLayerObjects.cs index 02af5fa1..3505c5b6 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSelectLayerObjects.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSelectLayerObjects.cs @@ -10,15 +10,15 @@ public class SampleCsSelectLayerObjects : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var layer_index = -1; - var current_state = false; - var rc = Rhino.UI.Dialogs.ShowSelectLayerDialog(ref layer_index, "Select Layer Objects", false, false, ref current_state); + int layer_index = -1; + bool current_state = false; + bool rc = Rhino.UI.Dialogs.ShowSelectLayerDialog(ref layer_index, "Select Layer Objects", false, false, ref current_state); if (!rc) return Result.Cancel; if (layer_index >= 0 && layer_index < doc.Layers.Count) { - var layer = doc.Layers[layer_index]; + Layer layer = doc.Layers[layer_index]; if (layer.IsDeleted) return Result.Nothing; @@ -29,7 +29,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } RhinoObject[] rh_objects = doc.Objects.FindByLayer(layer); - foreach (var rh_object in rh_objects) + foreach (RhinoObject rh_object in rh_objects) { if (rh_object.IsSelectable()) rh_object.Select(true); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSetCameraTarget.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSetCameraTarget.cs index 881b0f11..f58d532b 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSetCameraTarget.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSetCameraTarget.cs @@ -9,13 +9,13 @@ public class SampleCsSetCameraTarget : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var view = doc.Views.ActiveView; - var vp = view.ActiveViewport; + Rhino.Display.RhinoView view = doc.Views.ActiveView; + Rhino.Display.RhinoViewport vp = view.ActiveViewport; - var target = vp.CameraTarget; - var camera = vp.CameraLocation; + Rhino.Geometry.Point3d target = vp.CameraTarget; + Rhino.Geometry.Point3d camera = vp.CameraLocation; - var gp = new Rhino.Input.Custom.GetPoint(); + Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint(); gp.SetCommandPrompt("New target location"); gp.SetDefaultPoint(target); gp.Get(); @@ -35,7 +35,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) camera = gp.Point(); - var camdir = target - camera; + Rhino.Geometry.Vector3d camdir = target - camera; camdir.Unitize(); if (camdir.IsTiny()) return Result.Cancel; @@ -43,7 +43,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) vp.SetCameraLocations(target, camera); view.Redraw(); - return Result.Success; + return Result.Success; } } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSetDisplayMode.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSetDisplayMode.cs index 3678a98a..a5fe3935 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSetDisplayMode.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSetDisplayMode.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands @@ -34,7 +33,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) Rhino.Display.DisplayModeDescription currentDisplayMode = viewport.DisplayMode; Rhino.RhinoApp.WriteLine("Viewport in {0} display.", currentDisplayMode.EnglishName); - Rhino.Display.DisplayModeDescription[] displayModes = Rhino.Display.DisplayModeDescription.GetDisplayModes(); + Rhino.Display.DisplayModeDescription[] displayModes = Rhino.Display.DisplayModeDescription.GetDisplayModes(); Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption(); go.SetCommandPrompt("Select new display mode"); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSetDocumentUserText.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSetDocumentUserText.cs index e5c75e9a..203e7ce1 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSetDocumentUserText.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSetDocumentUserText.cs @@ -26,7 +26,7 @@ public class SampleCsGetDocumentUserText : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var value = doc.Strings.GetValue(SampleCsDocStringData.Key); + string value = doc.Strings.GetValue(SampleCsDocStringData.Key); if (!string.IsNullOrEmpty(value)) RhinoApp.WriteLine($"<{SampleCsDocStringData.Key}> {value}"); return Result.Success; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSetObjectName.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSetObjectName.cs index a3ba9e56..197bf155 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSetObjectName.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSetObjectName.cs @@ -10,7 +10,7 @@ public class SampleCsSetObjectName : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects"); go.SubObjectSelect = false; go.ReferenceObjectSelect = false; @@ -19,9 +19,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return go.CommandResult(); string defaultName = null; - foreach (var objRef in go.Objects()) + foreach (Rhino.DocObjects.ObjRef objRef in go.Objects()) { - var rhObj = objRef.Object(); + Rhino.DocObjects.RhinoObject rhObj = objRef.Object(); if (null == rhObj) return Result.Failure; @@ -34,28 +34,28 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } } - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Object name"); gs.SetDefaultString(defaultName); gs.Get(); if (gs.CommandResult() != Result.Success) return gs.CommandResult(); - var newName = gs.StringResult(); + string newName = gs.StringResult(); newName = newName.Trim(); if (defaultName.Equals(newName)) return Result.Nothing; - foreach (var objRef in go.Objects()) + foreach (Rhino.DocObjects.ObjRef objRef in go.Objects()) { - var rhObj = objRef.Object(); + Rhino.DocObjects.RhinoObject rhObj = objRef.Object(); if (null == rhObj) return Result.Failure; if (!newName.Equals(rhObj.Attributes.Name)) { - var attributes = rhObj.Attributes.Duplicate(); + Rhino.DocObjects.ObjectAttributes attributes = rhObj.Attributes.Duplicate(); attributes.Name = newName; doc.Objects.ModifyAttributes(rhObj, attributes, false); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSetPoint.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSetPoint.cs index 42e0cd46..871fa650 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSetPoint.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSetPoint.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Collections; using Rhino.Commands; using Rhino.Display; @@ -79,14 +78,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) GetSetPointTransform gx = new GetSetPointTransform(true, true, true); gx.SetCommandPrompt("Location for points"); gx.AddTransformObjects(list); - for (;;) + for (; ; ) { gx.ClearCommandOptions(); gx.AddOptionToggle("XSet", ref opt_xset); gx.AddOptionToggle("YSet", ref opt_yset); gx.AddOptionToggle("ZSet", ref opt_zset); - var res = gx.GetXform(); + GetResult res = gx.GetXform(); if (res == GetResult.Point) { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSetUserText.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSetUserText.cs index ddef549b..4d191482 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSetUserText.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSetUserText.cs @@ -19,17 +19,17 @@ public class SampleCsSetUserText : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects"); go.GroupSelect = true; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var obj_ref = go.Object(i); - var obj = obj_ref.Object(); + Rhino.DocObjects.ObjRef obj_ref = go.Object(i); + Rhino.DocObjects.RhinoObject obj = obj_ref.Object(); if (null != obj) obj.Attributes.SetUserString(SampleCsUserStringData.Key, SampleCsUserStringData.Value); } @@ -47,20 +47,20 @@ public class SampleCsGetUserText : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects"); go.GroupSelect = true; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var obj_ref = go.Object(i); - var obj = obj_ref.Object(); + Rhino.DocObjects.ObjRef obj_ref = go.Object(i); + Rhino.DocObjects.RhinoObject obj = obj_ref.Object(); if (null != obj) { - var value = obj.Attributes.GetUserString(SampleCsUserStringData.Key); + string value = obj.Attributes.GetUserString(SampleCsUserStringData.Key); if (!string.IsNullOrEmpty(value)) RhinoApp.WriteLine(string.Format("<{0}> {1}", SampleCsUserStringData.Key, value)); } @@ -79,23 +79,23 @@ public class SampleCsClearUserText : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects"); go.GroupSelect = true; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var obj_ref = go.Object(i); - var obj = obj_ref.Object(); + Rhino.DocObjects.ObjRef obj_ref = go.Object(i); + Rhino.DocObjects.RhinoObject obj = obj_ref.Object(); if (null != obj) obj.Attributes.SetUserString(SampleCsUserStringData.Key, null); } return Result.Success; - } + } } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsShadedBrep.cs b/rhinocommon/cs/SampleCsCommands/SampleCsShadedBrep.cs index ac938e25..38ba1b43 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsShadedBrep.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsShadedBrep.cs @@ -1,10 +1,9 @@ -using System; -using System.Drawing; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.Geometry; using Rhino.Input; +using System.Drawing; namespace SampleCsCommands { @@ -23,8 +22,8 @@ public SampleCsShadedBrepConduit() public Brep BrepGeometry { get => m_brep; - set - { + set + { m_brep = value; if (null != m_brep && m_brep.IsValid) { @@ -55,7 +54,7 @@ protected override void PostDrawObjects(DrawEventArgs e) DisplayMaterial material = new DisplayMaterial(); material.Diffuse = Color.RoyalBlue; e.Display.DrawBrepShaded(m_brep, material); - } + } } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsShadedView.cs b/rhinocommon/cs/SampleCsCommands/SampleCsShadedView.cs index 92439080..cd32f13c 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsShadedView.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsShadedView.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; @@ -14,7 +13,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; - + const string englishName = @"Shaded"; DisplayModeDescription display_mode_description = DisplayModeDescription.FindByName(englishName); if (null != display_mode_description) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSineWaveLoft.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSineWaveLoft.cs index 9c269c0d..023abf53 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSineWaveLoft.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSineWaveLoft.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; +using System; +using System.Collections.Generic; namespace SampleCsCommands { @@ -15,21 +15,21 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) const int u_count = 25; const int v_count = 25; - var curves = new List(); - var points = new List(); + List curves = new List(); + List points = new List(); - for (var u = 0; u <= u_count; u++) + for (int u = 0; u <= u_count; u++) { points.Clear(); - for (var v = 0; v <= v_count; v++) + for (int v = 0; v <= v_count; v++) points.Add(new Point3d(u, v, Math.Sin(u) + Math.Sin(v))); curves.Add(Curve.CreateInterpolatedCurve(points, 3)); } - var breps = Brep.CreateFromLoft(curves, Point3d.Unset, Point3d.Unset, LoftType.Normal, false); + Brep[] breps = Brep.CreateFromLoft(curves, Point3d.Unset, Point3d.Unset, LoftType.Normal, false); if (null != breps) { - foreach (var brep in breps) + foreach (Brep brep in breps) doc.Objects.AddBrep(brep); doc.Views.Redraw(); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSketch.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSketch.cs index eddf5236..1b6e5601 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSketch.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSketch.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System.Collections.Generic; namespace SampleCsCommands { @@ -18,7 +18,7 @@ internal class GetSketchPoints : GetPoint public GetResult GetPoints() { - var rc = Get(true); + GetResult rc = Get(true); if (rc == GetResult.Point) Points.Add(Point()); return rc; @@ -55,7 +55,7 @@ protected override void OnDynamicDraw(GetPointDrawEventArgs e) { if (Points.Count > 0) { - for (var i = 1; i < Points.Count; i++ ) + for (int i = 1; i < Points.Count; i++) e.Display.DrawLine(Points[i - 1], Points[i], DynamicDrawColor); } else @@ -74,27 +74,27 @@ public class SampleCsSketch : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var old_snap_on = Rhino.ApplicationSettings.ModelAidSettings.GridSnap; + bool old_snap_on = Rhino.ApplicationSettings.ModelAidSettings.GridSnap; if (old_snap_on) Rhino.ApplicationSettings.ModelAidSettings.GridSnap = false; - var gp = new GetSketchPoints(); + GetSketchPoints gp = new GetSketchPoints(); gp.SetCommandPrompt("Click and drag to sketch. Press Enter when done"); gp.PermitOrthoSnap(false); gp.AcceptNothing(true); - var res = gp.GetPoints(); + GetResult res = gp.GetPoints(); if (res == GetResult.Point) { - var points = gp.Points; + List points = gp.Points; if (points.Count > 2) { - var p0 = points[0]; - var p1 = points[points.Count - 1]; + Point3d p0 = points[0]; + Point3d p1 = points[points.Count - 1]; if (p0.DistanceTo(p1) < doc.ModelAbsoluteTolerance) points.Add(p0); - var pline_curve = new PolylineCurve(points); + PolylineCurve pline_curve = new PolylineCurve(points); doc.Objects.AddCurve(pline_curve); doc.Views.Redraw(); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSmash.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSmash.cs index b052b5ef..789c16a0 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSmash.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSmash.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSmooth.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSmooth.cs index d096ab68..edef22b3 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSmooth.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSmooth.cs @@ -1,7 +1,6 @@ -using System; -using System.Text; -using Rhino; +using Rhino; using Rhino.Commands; +using System.Text; namespace SampleCsCommands { diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSpiral.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSpiral.cs index 5060d188..9880c902 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSpiral.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSpiral.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands @@ -25,23 +24,23 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) private static Rhino.Geometry.NurbsCurve GetSpirial0() { - var axisStart = new Rhino.Geometry.Point3d(0, 0, 0); - var axisDir = new Rhino.Geometry.Vector3d(1, 0, 0); - var radiusPoint = new Rhino.Geometry.Point3d(0, 1, 0); + Rhino.Geometry.Point3d axisStart = new Rhino.Geometry.Point3d(0, 0, 0); + Rhino.Geometry.Vector3d axisDir = new Rhino.Geometry.Vector3d(1, 0, 0); + Rhino.Geometry.Point3d radiusPoint = new Rhino.Geometry.Point3d(0, 1, 0); return Rhino.Geometry.NurbsCurve.CreateSpiral(axisStart, axisDir, radiusPoint, 1, 10, 1.0, 1.0); } private static Rhino.Geometry.NurbsCurve GetSpirial1() { - var railStart = new Rhino.Geometry.Point3d(0, 0, 0); - var railEnd = new Rhino.Geometry.Point3d(0, 0, 10); - var railCurve = new Rhino.Geometry.LineCurve(railStart, railEnd); + Rhino.Geometry.Point3d railStart = new Rhino.Geometry.Point3d(0, 0, 0); + Rhino.Geometry.Point3d railEnd = new Rhino.Geometry.Point3d(0, 0, 10); + Rhino.Geometry.LineCurve railCurve = new Rhino.Geometry.LineCurve(railStart, railEnd); double t0 = railCurve.Domain.Min; double t1 = railCurve.Domain.Max; - var radiusPoint = new Rhino.Geometry.Point3d(1, 0, 0); + Rhino.Geometry.Point3d radiusPoint = new Rhino.Geometry.Point3d(1, 0, 0); return Rhino.Geometry.NurbsCurve.CreateSpiral(railCurve, t0, t1, radiusPoint, 1, 10, 1.0, 1.0, 12); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSplitCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSplitCurve.cs index ebd75b57..de150f25 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSplitCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSplitCurve.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System; +using System.Collections.Generic; +using System.Linq; namespace SampleCsCommands { @@ -57,7 +57,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) for (int i = 0; i < culled_t.Count - 1; i++) { - Interval domain = new Interval(culled_t[i], culled_t[i+1]); + Interval domain = new Interval(culled_t[i], culled_t[i + 1]); if (curve.Domain.IncludesInterval(domain)) { Curve trim = curve.Trim(domain); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsStackedControlPointsCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsStackedControlPointsCurve.cs index b2653298..8edf8f07 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsStackedControlPointsCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsStackedControlPointsCurve.cs @@ -13,18 +13,18 @@ public class SampleCsStackedControlPointsCurve : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { ObjRef object_ref; - var rc = RhinoGet.GetOneObject("Select curve for stacked control point test", false, ObjectType.Curve, out object_ref); + Result rc = RhinoGet.GetOneObject("Select curve for stacked control point test", false, ObjectType.Curve, out object_ref); if (rc != Result.Success) return rc; - var nc = object_ref.Curve() as NurbsCurve; + NurbsCurve nc = object_ref.Curve() as NurbsCurve; if (null == nc) { RhinoApp.WriteLine("Curve is not a NURBS curve."); return Result.Success; } - var b = IsStackedControlPointsCurve(nc); + bool b = IsStackedControlPointsCurve(nc); if (b) RhinoApp.WriteLine("NURBS curve has stacked control points."); else @@ -35,14 +35,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) public static bool IsStackedControlPointsCurve(NurbsCurve nc) { - var rc = false; + bool rc = false; if (null != nc && nc.IsValid) { - for (var i = 0; i < nc.Points.Count - 1; i++) + for (int i = 0; i < nc.Points.Count - 1; i++) { - var cv0 = nc.Points[i]; - var cv1 = nc.Points[i + 1]; - var dist = cv0.Location.DistanceTo(cv1.Location); + ControlPoint cv0 = nc.Points[i]; + ControlPoint cv1 = nc.Points[i + 1]; + double dist = cv0.Location.DistanceTo(cv1.Location); if (dist < RhinoMath.ZeroTolerance) { rc = true; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSubCurve.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSubCurve.cs index f9e3c28a..58c6ef96 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSubCurve.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSubCurve.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands @@ -48,13 +47,13 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (null == gp.PointOnCurve(out t1)) return Result.Failure; - if (System.Math.Abs(t1-t0) < Rhino.RhinoMath.ZeroTolerance) + if (System.Math.Abs(t1 - t0) < Rhino.RhinoMath.ZeroTolerance) return Result.Failure; if (crv.IsClosed || (!crv.IsClosed && t0 > t1)) { - double t = t0; - t0 = t1; + double t = t0; + t0 = t1; t1 = t; } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSubDEditPts.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSubDEditPts.cs index f076b70e..a98eac44 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSubDEditPts.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSubDEditPts.cs @@ -8,96 +8,96 @@ namespace SampleCsCommands { - public class SampleCsSubDEditPts : Command + public class SampleCsSubDEditPts : Command + { + public SampleCsSubDEditPts() { - public SampleCsSubDEditPts() - { - // Rhino only creates one instance of each command class defined in a - // plug-in, so it is safe to store a refence in a static property. - Instance = this; - } + // Rhino only creates one instance of each command class defined in a + // plug-in, so it is safe to store a refence in a static property. + Instance = this; + } - ///The only instance of this command. - public static SampleCsSubDEditPts Instance - { - get; private set; - } + ///The only instance of this command. + public static SampleCsSubDEditPts Instance + { + get; private set; + } + + ///The command name as it appears on the Rhino command line. + public override string EnglishName + { + get { return "SampleCsSubDEditPts"; } + } - ///The command name as it appears on the Rhino command line. - public override string EnglishName + protected override Result RunCommand(RhinoDoc doc, RunMode mode) + { + GetObject go = new GetObject(); + go.SetCommandPrompt("Select SubD points"); + go.GeometryFilter = ObjectType.Grip; + go.SubObjectSelect = true; + go.GetMultiple(1, 0); + if (go.CommandResult() != Result.Success) + return go.CommandResult(); + + Dictionary> objectVertexIndices = new Dictionary>(); + foreach (ObjRef objRef in go.Objects()) + { + if (objRef.Object() is GripObject gripObj) { - get { return "SampleCsSubDEditPts"; } + if (doc.Objects.FindId(gripObj.OwnerId) is SubDObject subdObj) + { + if (!objectVertexIndices.TryGetValue(gripObj.OwnerId, out List vis)) + { + vis = new List(); + objectVertexIndices.Add(gripObj.OwnerId, vis); + } + vis.Add(gripObj.Index); + } } + } - protected override Result RunCommand(RhinoDoc doc, RunMode mode) + foreach (KeyValuePair> item in objectVertexIndices) + { + Guid objectId = item.Key; + List vertexIndices = item.Value; + if (doc.Objects.FindId(objectId) is SubDObject subdObj) { - var go = new GetObject(); - go.SetCommandPrompt("Select SubD points"); - go.GeometryFilter = ObjectType.Grip; - go.SubObjectSelect = true; - go.GetMultiple(1, 0); - if (go.CommandResult() != Result.Success) - return go.CommandResult(); - - Dictionary> objectVertexIndices = new Dictionary>(); - foreach (var objRef in go.Objects()) + if (subdObj.Geometry is SubD subD) + { + SubD newSubD = subD.Duplicate() as SubD; + if (newSubD != null) { - if (objRef.Object() is GripObject gripObj) + Point3d offset = new Point3d(0.0, 0.0, 1.0); + List surfacePts = new List(); + int vi = 0; + SubDVertex vert = newSubD.Vertices.First; + while (vert != null) + { + if (vertexIndices.Contains(vi)) { - if (doc.Objects.FindId(gripObj.OwnerId) is SubDObject subdObj) - { - if (!objectVertexIndices.TryGetValue(gripObj.OwnerId, out List vis)) - { - vis = new List(); - objectVertexIndices.Add(gripObj.OwnerId, vis); - } - vis.Add(gripObj.Index); - } + surfacePts.Add(vert.SurfacePoint() + offset); } - } - - foreach (var item in objectVertexIndices) - { - var objectId = item.Key; - var vertexIndices = item.Value; - if (doc.Objects.FindId(objectId) is SubDObject subdObj) + else { - if (subdObj.Geometry is SubD subD) - { - SubD newSubD = subD.Duplicate() as SubD; - if (newSubD != null) - { - Point3d offset = new Point3d(0.0, 0.0, 1.0); - List surfacePts = new List(); - int vi = 0; - SubDVertex vert = newSubD.Vertices.First; - while (vert != null) - { - if (vertexIndices.Contains(vi)) - { - surfacePts.Add(vert.SurfacePoint() + offset); - } - else - { - surfacePts.Add(vert.SurfacePoint()); - } - vert = vert.Next; - vi++; - } - if (newSubD.InterpolateSurfacePoints(surfacePts.ToArray())) - { - doc.Objects.Replace(subdObj.Id, newSubD); - } - else - { - return Result.Failure; - } - } - } + surfacePts.Add(vert.SurfacePoint()); } + vert = vert.Next; + vi++; + } + if (newSubD.InterpolateSurfacePoints(surfacePts.ToArray())) + { + doc.Objects.Replace(subdObj.Id, newSubD); + } + else + { + return Result.Failure; + } } - - return Result.Success; + } } + } + + return Result.Success; } + } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsSweep1.cs b/rhinocommon/cs/SampleCsCommands/SampleCsSweep1.cs index f9f1d1b5..7e0b7dc0 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsSweep1.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsSweep1.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; @@ -20,7 +19,7 @@ public class SampleCsSweep1 : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - const ObjectType geometryFilter = ObjectType.Curve; + const ObjectType geometryFilter = ObjectType.Curve; GetObject get_rail = new GetObject(); get_rail.SetCommandPrompt("Select rail curve"); @@ -66,7 +65,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) doc.Objects.AddBrep(brep[i], null, history, false); doc.Views.Redraw(); - + return Result.Success; } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsTestPlanarCurveContainment.cs b/rhinocommon/cs/SampleCsCommands/SampleCsTestPlanarCurveContainment.cs index a4a5a485..9656c295 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsTestPlanarCurveContainment.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsTestPlanarCurveContainment.cs @@ -21,20 +21,20 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var curve_a = go.Object(0).Curve(); - var curve_b = go.Object(1).Curve(); + Curve curve_a = go.Object(0).Curve(); + Curve curve_b = go.Object(1).Curve(); if (null == curve_a || null == curve_b) return Result.Failure; - var tol = doc.ModelAbsoluteTolerance; + double tol = doc.ModelAbsoluteTolerance; - if (!curve_a.TryGetPlane(out var plane_a, tol)) + if (!curve_a.TryGetPlane(out Plane plane_a, tol)) { RhinoApp.WriteLine("The first curve is not planar."); return Result.Success; } - if (!curve_b.TryGetPlane(out var plane_b, tol)) + if (!curve_b.TryGetPlane(out Plane plane_b, tol)) { RhinoApp.WriteLine("The second curve is not planar."); return Result.Success; @@ -46,7 +46,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Success; } - var rc = Curve.PlanarClosedCurveRelationship(curve_a, curve_b, plane_a, tol); + RegionContainment rc = Curve.PlanarClosedCurveRelationship(curve_a, curve_b, plane_a, tol); switch (rc) { case RegionContainment.Disjoint: diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsText.cs b/rhinocommon/cs/SampleCsCommands/SampleCsText.cs index d13dfd46..71077194 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsText.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsText.cs @@ -1,12 +1,12 @@ -using System; -using System.Drawing; -using System.Linq; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; +using System; +using System.Drawing; +using System.Linq; namespace SampleCsCommands { @@ -18,19 +18,19 @@ public class SampleCsText : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var gp = new GetPoint(); + GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Start point"); gp.AddOptionEnumList("Justification", m_justification); gp.ConstrainToConstructionPlane(false); - for (;;) + for (; ; ) { - var res = gp.Get(); + GetResult res = gp.Get(); if (res == GetResult.Option) { - var option = gp.Option(); + CommandLineOption option = gp.Option(); if (null != option) { - var list = Enum.GetValues(typeof(TextJustification)).Cast().ToList(); + System.Collections.Generic.List list = Enum.GetValues(typeof(TextJustification)).Cast().ToList(); m_justification = list[option.CurrentListOptionIndex]; } continue; @@ -42,27 +42,27 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) break; } - var point = gp.Point(); + Point3d point = gp.Point(); - var plane = gp.View().ActiveViewport.ConstructionPlane(); + Plane plane = gp.View().ActiveViewport.ConstructionPlane(); plane.Origin = point; - var text = new TextEntity + TextEntity text = new TextEntity { Plane = plane, Justification = m_justification }; text.PlainText = text.Justification.ToString(); - var attr = new ObjectAttributes + ObjectAttributes attr = new ObjectAttributes { ColorSource = ObjectColorSource.ColorFromObject, ObjectColor = Color.FromArgb(0, 0, 255) }; - var object_id = doc.Objects.AddText(text, attr); + Guid object_id = doc.Objects.AddText(text, attr); RhinoApp.WriteLine("{0}", object_id.ToString()); - + doc.Views.Redraw(); return Result.Success; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsTextEntityBoundingBox.cs b/rhinocommon/cs/SampleCsCommands/SampleCsTextEntityBoundingBox.cs index 180156bd..34e1cf2e 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsTextEntityBoundingBox.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsTextEntityBoundingBox.cs @@ -11,13 +11,13 @@ public class SampleCsTextEntityBoundingBox : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var view = doc.Views.ActiveView; + Rhino.Display.RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; - var plane = view.ActiveViewport.ConstructionPlane(); + Plane plane = view.ActiveViewport.ConstructionPlane(); - var dimstyle = doc.DimStyles.FindName("TestDimStyle"); + DimensionStyle dimstyle = doc.DimStyles.FindName("TestDimStyle"); if (null == dimstyle) { dimstyle = new DimensionStyle @@ -30,21 +30,21 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) Font = new Rhino.DocObjects.Font("Book Antiqua") }; - var dimstyle_index = doc.DimStyles.Add(dimstyle, false); + int dimstyle_index = doc.DimStyles.Add(dimstyle, false); if (dimstyle_index >= 0 && dimstyle_index < doc.DimStyles.Count) dimstyle = doc.DimStyles[dimstyle_index]; else return Result.Failure; } - var text_entity = TextEntity.Create("Hello Rhino!", plane, dimstyle, false, 0, 0.0); - text_entity.GetBoundingBox(plane, out var box); - var corners = box.GetCorners(); + TextEntity text_entity = TextEntity.Create("Hello Rhino!", plane, dimstyle, false, 0, 0.0); + text_entity.GetBoundingBox(plane, out Box box); + Point3d[] corners = box.GetCorners(); - var points = new Point3d[] { corners[0], corners[1], corners[2], corners[3], corners[0] }; + Point3d[] points = new Point3d[] { corners[0], corners[1], corners[2], corners[3], corners[0] }; doc.Objects.AddPolyline(points); - text_entity.IsValidWithLog(out var log); + text_entity.IsValidWithLog(out string log); doc.Objects.AddText(text_entity); doc.Views.Redraw(); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsTrimSurface.cs b/rhinocommon/cs/SampleCsCommands/SampleCsTrimSurface.cs index 949c6b2a..906d2d30 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsTrimSurface.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsTrimSurface.cs @@ -1,8 +1,6 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; -using Rhino.FileIO; using Rhino.Geometry; using Rhino.Input.Custom; @@ -15,7 +13,7 @@ public class SampleCsTrimSurface : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Select cutting surface - var gc = new GetObject(); + GetObject gc = new GetObject(); gc.SetCommandPrompt("Select cutting surface"); gc.GeometryFilter = ObjectType.Surface; gc.SubObjectSelect = false; @@ -23,12 +21,12 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gc.CommandResult() != Result.Success) return gc.CommandResult(); - var splitter = gc.Object(0).Brep(); + Brep splitter = gc.Object(0).Brep(); if (null == splitter) return Result.Failure; // Select surface to trim - var gs = new GetObject(); + GetObject gs = new GetObject(); gs.SetCommandPrompt("Select surface to trim"); gs.GeometryFilter = ObjectType.Surface; gs.SubObjectSelect = false; @@ -38,24 +36,24 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gs.CommandResult() != Result.Success) return gs.CommandResult(); - var brep_ref = gs.Object(0); - var brep = brep_ref.Brep(); + ObjRef brep_ref = gs.Object(0); + Brep brep = brep_ref.Brep(); if (null == brep) return Result.Failure; - var pick_pt = brep_ref.SelectionPoint(); + Point3d pick_pt = brep_ref.SelectionPoint(); if (!pick_pt.IsValid) { // The user didn't "pick" the object, but rather // selected the object using the SelID command. // So, make up some pick location. - var dom_u = brep.Faces[0].Domain(0); - var dom_v = brep.Faces[0].Domain(1); + Interval dom_u = brep.Faces[0].Domain(0); + Interval dom_v = brep.Faces[0].Domain(1); pick_pt = brep.Faces[0].PointAt(dom_u.Min, dom_v.Min); } // Do the splitting - var trims = brep.Split(splitter, doc.ModelAbsoluteTolerance); + Brep[] trims = brep.Split(splitter, doc.ModelAbsoluteTolerance); if (null == trims || 1 == trims.Length) { RhinoApp.WriteLine("Unable to trim surface."); @@ -63,11 +61,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } // Figure out which piece the user wanted trimmed away - var dist = RhinoMath.UnsetValue; + double dist = RhinoMath.UnsetValue; int picked_index = -1; for (int i = 0; i < trims.Length; i++) { - var pt = trims[i].ClosestPoint(pick_pt); + Point3d pt = trims[i].ClosestPoint(pick_pt); if (pt.IsValid) { double d = pt.DistanceTo(pick_pt); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsTrimmedPlane.cs b/rhinocommon/cs/SampleCsCommands/SampleCsTrimmedPlane.cs index d1f321de..90fc180c 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsTrimmedPlane.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsTrimmedPlane.cs @@ -10,7 +10,7 @@ public class SampleCsTrimmedPlane : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var brep = MakeTrimmedPlane(); + Brep brep = MakeTrimmedPlane(); if (null == brep) return Result.Failure; @@ -47,7 +47,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) public static Brep MakeTrimmedPlane() { // Define the vertices - var points = new Point3d[5]; + Point3d[] points = new Point3d[5]; points[A] = new Point3d(0.0, 0.0, 0.0); // point A = geometry for vertex 0 (and surface SW corner) points[B] = new Point3d(10.0, 0.0, 0.0); // point B = geometry for vertex 1 (and surface SE corner) points[C] = new Point3d(5.0, 10.0, 0.0); // point C = geometry for vertex 2 @@ -55,10 +55,10 @@ public static Brep MakeTrimmedPlane() points[E] = new Point3d(0.0, 10.0, 0.0); // point E (surface NW corner) // Create the Brep - var brep = new Brep(); + Brep brep = new Brep(); // Create three vertices located at the three points - for (var vi = 0; vi < 3; vi++) + for (int vi = 0; vi < 3; vi++) { // This simple example is exact - for models with // non-exact data, set tolerance as explained in @@ -84,7 +84,7 @@ public static Brep MakeTrimmedPlane() #if DEBUG string tlog; - var rc = brep.IsValidTopology(out tlog); + bool rc = brep.IsValidTopology(out tlog); if (!rc) { RhinoApp.WriteLine(tlog); @@ -141,11 +141,11 @@ private static Curve CreateTrimmingCurve(Surface surface, int side) // An inner trimming loop consists of a simple closed curve running // clockwise around the region the hole. - var domain_u = surface.Domain(0); - var domain_v = surface.Domain(1); + Interval domain_u = surface.Domain(0); + Interval domain_v = surface.Domain(1); - var start = new Point2d(); - var end = new Point2d(); + Point2d start = new Point2d(); + Point2d end = new Point2d(); switch (side) { @@ -171,7 +171,7 @@ private static Curve CreateTrimmingCurve(Surface surface, int side) return null; } - var curve = new LineCurve(start, end) { Domain = new Interval(0.0, 1.0) }; + LineCurve curve = new LineCurve(start, end) { Domain = new Interval(0.0, 1.0) }; return curve; } @@ -185,7 +185,7 @@ private static Curve CreateTrimmingCurve(Surface surface, int side) private static Curve CreateLinearCurve(Point3d start, Point3d end) { // Creates a 3d line segment to be used as a 3d curve in a Brep - var curve = new LineCurve(start, end) { Domain = new Interval(0.0, 1.0) }; + LineCurve curve = new LineCurve(start, end) { Domain = new Interval(0.0, 1.0) }; return curve; } @@ -199,7 +199,7 @@ private static Curve CreateLinearCurve(Point3d start, Point3d end) /// The surface if successful, null otherwise private static Surface CreatePlanarSurface(Point3d sw, Point3d se, Point3d ne, Point3d nw) { - var nurb = NurbsSurface.Create( + NurbsSurface nurb = NurbsSurface.Create( 3, // dimension (>= 1) false, // not rational 2, // "u" order (>= 2) @@ -234,8 +234,8 @@ private static Surface CreatePlanarSurface(Point3d sw, Point3d se, Point3d ne, P /// Index of the 3d curve private static void CreateOneEdge(Brep brep, int vi0, int vi1, int c3i) { - var start_vertex = brep.Vertices[vi0]; - var end_vertex = brep.Vertices[vi1]; + BrepVertex start_vertex = brep.Vertices[vi0]; + BrepVertex end_vertex = brep.Vertices[vi1]; // This simple example is exact - for models with // non-exact data, set tolerance as explained in @@ -289,8 +289,8 @@ private static int MakeTrimmingLoop( int e2Dir ) { - var surface = brep.Surfaces[face.SurfaceIndex]; - var loop = brep.Loops.Add(BrepLoopType.Outer, face); + Surface surface = brep.Surfaces[face.SurfaceIndex]; + BrepLoop loop = brep.Loops.Add(BrepLoopType.Outer, face); // Create trimming curves running counter clockwise. // Note that trims of outer loops run counter clockwise @@ -302,16 +302,16 @@ int e2Dir // y_iso and x_iso respectfully, the rest are not_iso. // Start at the south side - for (var side = 0; side < 3; side++) + for (int side = 0; side < 3; side++) { - var curve = CreateTrimmingCurve(surface, side); + Curve curve = CreateTrimmingCurve(surface, side); // Add trimming curve to brep trim curves array - var c2i = brep.Curves2D.Add(curve); + int c2i = brep.Curves2D.Add(curve); - var ei = 0; - var reverse = false; - var iso = IsoStatus.None; + int ei = 0; + bool reverse = false; + IsoStatus iso = IsoStatus.None; switch (side) { @@ -334,7 +334,7 @@ int e2Dir // Create new trim topology that references edge, direction // reletive to edge, loop and trim curve geometry - var trim = brep.Trims.Add(brep.Edges[ei], reverse, loop, c2i); + BrepTrim trim = brep.Trims.Add(brep.Edges[ei], reverse, loop, c2i); trim.IsoStatus = iso; // This one Brep face, so all trims are boundary ones. @@ -368,7 +368,7 @@ private static void MakeTrimmedFace( Brep brep, int si, int sDir, - int v0, + int v0, int v1, int v2, int e0, @@ -380,7 +380,7 @@ int e2Dir ) { // Add new face to brep - var face = brep.Faces.Add(si); + BrepFace face = brep.Faces.Add(si); // Create loop and trims for the face MakeTrimmingLoop( diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsUnisolate.cs b/rhinocommon/cs/SampleCsCommands/SampleCsUnisolate.cs index c6b91962..947e0648 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsUnisolate.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsUnisolate.cs @@ -1,5 +1,4 @@ -using System.Runtime.InteropServices; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Input.Custom; @@ -19,7 +18,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Nothing; } - var go = new GetOption(); + GetOption go = new GetOption(); go.SetCommandPrompt("Choose unisolate option"); int a_opt = go.AddOption("All"); int p_opt = go.AddOption("Previous"); @@ -27,7 +26,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var opt = go.Option(); + CommandLineOption opt = go.Option(); if (null == opt) return Result.Failure; @@ -45,8 +44,8 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) else return Result.Failure; - RhinoApp.RunScript(script, false); - + RhinoApp.RunScript(script, false); + return Result.Success; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsUnweldAll.cs b/rhinocommon/cs/SampleCsCommands/SampleCsUnweldAll.cs index d864c627..cd10abea 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsUnweldAll.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsUnweldAll.cs @@ -1,9 +1,9 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input.Custom; +using System; namespace SampleCsCommands { @@ -13,19 +13,19 @@ public class SampleCsUnweldAll : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select polygon meshes to unweld"); go.GeometryFilter = ObjectType.Mesh; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - foreach (var obj_ref in go.Objects()) + foreach (ObjRef obj_ref in go.Objects()) { - var old_mesh = obj_ref.Mesh(); + Mesh old_mesh = obj_ref.Mesh(); if (null != old_mesh) { - var new_mesh = UnweldMesh(old_mesh); + Mesh new_mesh = UnweldMesh(old_mesh); if (null != new_mesh && new_mesh.IsValid) doc.Objects.Replace(go.Object(0), new_mesh); } @@ -40,14 +40,14 @@ private static Mesh UnweldMesh(Mesh src) { if (null == src) throw new ArgumentNullException(nameof(src)); - var mesh = src.DuplicateMesh(); - for (var i = 0; i < mesh.Faces.Count; i++) + Mesh mesh = src.DuplicateMesh(); + for (int i = 0; i < mesh.Faces.Count; i++) { - var face = mesh.Faces[i]; - var a = mesh.Vertices.Add(mesh.Vertices[face.A]); - var b = mesh.Vertices.Add(mesh.Vertices[face.B]); - var c = mesh.Vertices.Add(mesh.Vertices[face.C]); - var d = face.IsQuad ? mesh.Vertices.Add(mesh.Vertices[face.D]) : c; + MeshFace face = mesh.Faces[i]; + int a = mesh.Vertices.Add(mesh.Vertices[face.A]); + int b = mesh.Vertices.Add(mesh.Vertices[face.B]); + int c = mesh.Vertices.Add(mesh.Vertices[face.C]); + int d = face.IsQuad ? mesh.Vertices.Add(mesh.Vertices[face.D]) : c; mesh.Faces.SetFace(i, a, b, c, d); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsUtilities.cs b/rhinocommon/cs/SampleCsCommands/SampleCsUtilities.cs index 023f1fde..b4bdd5c5 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsUtilities.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsUtilities.cs @@ -1,8 +1,8 @@ -using System; +using Rhino; +using Rhino.Geometry; +using System; using System.Collections.Generic; using System.Linq; -using Rhino; -using Rhino.Geometry; namespace SampleCsCommands { @@ -20,18 +20,18 @@ public static class SampleCsUtilities /// public static Guid[] RunCommandScript(RhinoDoc doc, string script, bool echo) { - var rc = new Guid[0]; + Guid[] rc = new Guid[0]; try { - var start_sn = Rhino.DocObjects.RhinoObject.NextRuntimeSerialNumber; + uint start_sn = Rhino.DocObjects.RhinoObject.NextRuntimeSerialNumber; RhinoApp.RunScript(script, false); - var end_sn = Rhino.DocObjects.RhinoObject.NextRuntimeSerialNumber; + uint end_sn = Rhino.DocObjects.RhinoObject.NextRuntimeSerialNumber; if (start_sn < end_sn) { - var object_ids = new List(); - for (var sn = start_sn; sn < end_sn; sn++) + List object_ids = new List(); + for (uint sn = start_sn; sn < end_sn; sn++) { - var obj = doc.Objects.Find(sn); + Rhino.DocObjects.RhinoObject obj = doc.Objects.Find(sn); if (null != obj) object_ids.Add(obj.Id); } @@ -53,9 +53,9 @@ public static Guid[] RunCommandScript(RhinoDoc doc, string script, bool echo) /// True if the Brep is box, false otherwise. public static bool IsBrepBox(Brep brep, double tolerance) { - var normals = new Vector3d[6]; + Vector3d[] normals = new Vector3d[6]; - var rc = null != brep; + bool rc = null != brep; if (rc) rc = brep.IsSolid; @@ -65,9 +65,9 @@ public static bool IsBrepBox(Brep brep, double tolerance) if (rc) { - for (var i = 0; rc && i < 6; i++) + for (int i = 0; rc && i < 6; i++) { - if (brep.Faces[i].TryGetPlane(out var plane, tolerance)) + if (brep.Faces[i].TryGetPlane(out Plane plane, tolerance)) { normals[i] = plane.Normal; normals[i].Unitize(); @@ -81,12 +81,12 @@ public static bool IsBrepBox(Brep brep, double tolerance) if (rc) { - for (var i = 0; rc && i < 6; i++) + for (int i = 0; rc && i < 6; i++) { - var count = 0; - for (var j = 0; rc && j < 6; j++) + int count = 0; + for (int j = 0; rc && j < 6; j++) { - var dot = Math.Abs(normals[i] * normals[j]); + double dot = Math.Abs(normals[i] * normals[j]); if (Math.Abs(dot) <= tolerance) continue; if (Math.Abs(dot - 1.0) <= tolerance) @@ -122,10 +122,10 @@ out Vector3d nDir ) { uDir = vDir = nDir = Vector3d.Unset; - var rc = false; + bool rc = false; if (null != nurb && cvIndex >= 0 && cvIndex < nurb.Points.Count) { - var t = nurb.GrevilleParameter(cvIndex); + double t = nurb.GrevilleParameter(cvIndex); if (RhinoMath.IsValidDouble(t)) { if (t < nurb.Domain.Min) @@ -133,7 +133,7 @@ out Vector3d nDir uDir = nurb.TangentAt(t); - var kappa = nurb.CurvatureAt(t); + Vector3d kappa = nurb.CurvatureAt(t); if (nurb.TryGetPlane(out Plane plane)) { nDir = plane.ZAxis; @@ -203,14 +203,14 @@ public static bool MakeSurfaceUniform(NurbsSurface srf, int direction = 2) else if (dir == 1 && direction == 0) continue; - var index = 0.0; - var srf_knots = (dir == 0) ? srf.KnotsU : srf.KnotsV; - var old_knot = srf_knots[0]; + double index = 0.0; + Rhino.Geometry.Collections.NurbsSurfaceKnotList srf_knots = (dir == 0) ? srf.KnotsU : srf.KnotsV; + double old_knot = srf_knots[0]; srf_knots[0] = index; - for (var ki = 1; ki < srf_knots.Count; ki++) + for (int ki = 1; ki < srf_knots.Count; ki++) { - var knot = srf_knots[ki]; + double knot = srf_knots[ki]; if (Math.Abs(knot - old_knot) < RhinoMath.ZeroTolerance) { if (ki < srf.Degree(dir) || ki >= srf_knots.Count - srf.Degree(dir)) diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsViewBoundingBox.cs b/rhinocommon/cs/SampleCsCommands/SampleCsViewBoundingBox.cs index bef1bec8..0ca93386 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsViewBoundingBox.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsViewBoundingBox.cs @@ -22,7 +22,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Success; } - var rc = RhinoGet.GetBox(out Box box); + Result rc = RhinoGet.GetBox(out Box box); if (rc != Result.Success) return rc; @@ -46,7 +46,7 @@ protected override void PreDrawObject(DrawObjectEventArgs args) { if (null != args && null != args.RhinoObject && BoundingBox.IsValid) { - var bbox = args.RhinoObject.Geometry.GetBoundingBox(true); + BoundingBox bbox = args.RhinoObject.Geometry.GetBoundingBox(true); if (!BoundingBox.Contains(bbox)) args.DrawObject = false; } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsViewCapture.cs b/rhinocommon/cs/SampleCsCommands/SampleCsViewCapture.cs index 6d7cfb83..24d672c0 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsViewCapture.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsViewCapture.cs @@ -1,8 +1,8 @@ -using System; -using System.IO; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; +using System; +using System.IO; namespace SampleCsCommands { @@ -12,11 +12,11 @@ public class SampleCsViewCapture : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var view = doc.Views.ActiveView; + RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; - var view_capture = new ViewCapture + ViewCapture view_capture = new ViewCapture { Width = view.ActiveViewport.Size.Width, Height = view.ActiveViewport.Size.Height, @@ -27,11 +27,11 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) TransparentBackground = true }; - var bitmap = view_capture.CaptureToBitmap(view); + System.Drawing.Bitmap bitmap = view_capture.CaptureToBitmap(view); if (null != bitmap) { - var path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); - var filename = Path.Combine(path, "SampleCsViewCapture.png"); + string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + string filename = Path.Combine(path, "SampleCsViewCapture.png"); bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Png); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsViewCaptureBoundingBox.cs b/rhinocommon/cs/SampleCsCommands/SampleCsViewCaptureBoundingBox.cs index 0842c1e5..17cc3d33 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsViewCaptureBoundingBox.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsViewCaptureBoundingBox.cs @@ -1,12 +1,12 @@ -using System.Drawing; -using System.Linq; -using Eto.Forms; +using Eto.Forms; using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.Geometry; using Rhino.UI; using Rhino.UI.Forms; +using System.Drawing; +using System.Linq; using Command = Rhino.Commands.Command; namespace SampleCsCommands @@ -32,17 +32,17 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - + //Grab a bounding box off of the scenes normal objects.. - var normal_objects = doc.Objects.Where(c => c.IsNormal).ToList(); + System.Collections.Generic.List normal_objects = doc.Objects.Where(c => c.IsNormal).ToList(); if (!normal_objects.Any()) return Result.Cancel; //Figure out the bounding box of the normal objects in the scene. - var scene_bounding_box = BoundingBox.Unset; - foreach (var ro in normal_objects) + BoundingBox scene_bounding_box = BoundingBox.Unset; + foreach (Rhino.DocObjects.RhinoObject ro in normal_objects) scene_bounding_box.Union(ro.Geometry.GetBoundingBox(true)); - - if (!scene_bounding_box.IsValid) {return Result.Cancel;} + + if (!scene_bounding_box.IsValid) { return Result.Cancel; } //By default Zoom commands have a 1.1 padding around them. //We can temporarily override this padding by setting it to 0 @@ -54,48 +54,48 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) //Find a view to base our grab off of and establish a scale. - var top_view = doc.Views.Find("top", false); - top_view.ActiveViewport.GetWorldToScreenScale(scene_bounding_box.Center, out var screen_scale); - + RhinoView top_view = doc.Views.Find("top", false); + top_view.ActiveViewport.GetWorldToScreenScale(scene_bounding_box.Center, out double screen_scale); + //figure out the width and height - var width_x = scene_bounding_box.Min.DistanceTo(scene_bounding_box.Corner(false,true,true)) * screen_scale; - var height_y = scene_bounding_box.Min.DistanceTo(scene_bounding_box.Corner(true, false, true)) * screen_scale; + double width_x = scene_bounding_box.Min.DistanceTo(scene_bounding_box.Corner(false, true, true)) * screen_scale; + double height_y = scene_bounding_box.Min.DistanceTo(scene_bounding_box.Corner(true, false, true)) * screen_scale; //create the size of our view - var bb_size = new Size((int) width_x, (int) height_y); - + Size bb_size = new Size((int)width_x, (int)height_y); + //Create a temporary view for the capture - var bb_view = doc.Views.Add("bbview", DefinedViewportProjection.Top, new Rectangle(new System.Drawing.Point(0, 0), bb_size), true); - + RhinoView bb_view = doc.Views.Add("bbview", DefinedViewportProjection.Top, new Rectangle(new System.Drawing.Point(0, 0), bb_size), true); + //Setting the size again will snug up the camera. bb_view.Size = bb_size; - + //pull the camera as tight as possible bb_view.ActiveViewport.ZoomBoundingBox(scene_bounding_box); - + //create a bitmap view capture - var bmp = bb_view.CaptureToBitmap(DisplayModeDescription.FindByName("Shaded")); - + Bitmap bmp = bb_view.CaptureToBitmap(DisplayModeDescription.FindByName("Shaded")); + //close the temp view bb_view.Close(); - + //Reset the zoom padding Rhino.ApplicationSettings.ViewSettings.ZoomExtentsParallelViewBorder = 1.1; - + //Re-enable view drawing doc.Views.RedrawEnabled = true; //Make a simple eto dialog to show the bitmap - var dlg = new CommandDialog + CommandDialog dlg = new CommandDialog { - Size = new Eto.Drawing.Size(800,600), - Content = new ImageView() {Image = bmp.ToEto()}, + Size = new Eto.Drawing.Size(800, 600), + Content = new ImageView() { Image = bmp.ToEto() }, ShowHelpButton = false, Resizable = true, }; dlg.ShowModal(RhinoEtoApp.MainWindow); - - + + //fin return Result.Success; } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsViewSize.cs b/rhinocommon/cs/SampleCsCommands/SampleCsViewSize.cs index e957f2e3..ec827fb6 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsViewSize.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsViewSize.cs @@ -1,10 +1,8 @@ -using System; -using System.Drawing; -using System.Linq.Expressions; -using System.Runtime.InteropServices; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; +using System; +using System.Drawing; namespace SampleCsCommands { @@ -14,26 +12,26 @@ public class SampleCsViewSize : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var view = doc.Views.ActiveView; + RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; - var rect = view.ScreenRectangle; - var width_in_pixels = rect.Width; - var height_in_pixels = rect.Height; + Rectangle rect = view.ScreenRectangle; + int width_in_pixels = rect.Width; + int height_in_pixels = rect.Height; - var graphics = Graphics.FromHwnd(IntPtr.Zero); - var pixels_per_inch_x = graphics.DpiX; - var pixels_per_inch_y = graphics.DpiY; + Graphics graphics = Graphics.FromHwnd(IntPtr.Zero); + float pixels_per_inch_x = graphics.DpiX; + float pixels_per_inch_y = graphics.DpiY; - var width_in_inches = width_in_pixels / pixels_per_inch_x; - var height_in_inches = height_in_pixels / pixels_per_inch_y; + float width_in_inches = width_in_pixels / pixels_per_inch_x; + float height_in_inches = height_in_pixels / pixels_per_inch_y; const double mm_per_inch = 25.4; - var width_in_mm = width_in_inches * mm_per_inch; - var height_in_mm = height_in_inches * mm_per_inch; + double width_in_mm = width_in_inches * mm_per_inch; + double height_in_mm = height_in_inches * mm_per_inch; - var name = view.ActiveViewport.Name; + string name = view.ActiveViewport.Name; RhinoApp.WriteLine(string.Format("{0} view width: {1} mm", name, width_in_mm)); RhinoApp.WriteLine(string.Format("{0} view height: {1} mm", name, height_in_mm)); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsViewportSize.cs b/rhinocommon/cs/SampleCsCommands/SampleCsViewportSize.cs index 2efbc5d6..8950d61e 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsViewportSize.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsViewportSize.cs @@ -1,5 +1,4 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; namespace SampleCsCommands @@ -12,13 +11,13 @@ public class SampleCsViewportSize : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var view = doc.Views.ActiveView; + Rhino.Display.RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; - var size = view.ActiveViewport.Size; + System.Drawing.Size size = view.ActiveViewport.Size; - var get = new Rhino.Input.Custom.GetInteger(); + Rhino.Input.Custom.GetInteger get = new Rhino.Input.Custom.GetInteger(); get.SetCommandPrompt("Viewport width in pixels"); get.SetDefaultInteger(size.Width); get.SetLowerLimit(10, true); @@ -37,7 +36,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) size.Height = get.Number(); - var script = $"_-ViewportProperties _Size {size.Width} {size.Height} _Enter"; + string script = $"_-ViewportProperties _Size {size.Width} {size.Height} _Enter"; RhinoApp.RunScript(script, false); return Result.Success; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsWorldToPageTransform.cs b/rhinocommon/cs/SampleCsCommands/SampleCsWorldToPageTransform.cs index 51f08282..a1ff43f6 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsWorldToPageTransform.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsWorldToPageTransform.cs @@ -13,31 +13,31 @@ public class SampleCsWorldToPageTransform : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var view = doc.Views.ActiveView; + RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; - var page_view = view as RhinoPageView; + RhinoPageView page_view = view as RhinoPageView; if (null == page_view) { RhinoApp.WriteLine("The active view is neither a layout nor a detail view."); return Result.Failure; } - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select point object"); go.GeometryFilter = ObjectType.Point; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var point_obj = go.Object(0).Point(); + Point point_obj = go.Object(0).Point(); if (null == point_obj) return Result.Failure; if (page_view.PageIsActive) { - var gd = new GetDetailViewObject(); + GetDetailViewObject gd = new GetDetailViewObject(); gd.SetCommandPrompt("Select target detail view"); gd.EnablePreSelect(false, true); gd.DeselectAllBeforePostSelect = false; @@ -45,10 +45,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (gd.CommandResult() != Result.Success) return gd.CommandResult(); - var detail = gd.Object(0).Object() as DetailViewObject; + DetailViewObject detail = gd.Object(0).Object() as DetailViewObject; if (null != detail) { - var point = point_obj.Location; + Point3d point = point_obj.Location; RhinoApp.WriteLine("Page location: {0}", point.ToString()); point.Transform(detail.PageToWorldTransform); RhinoApp.WriteLine("World location: {0}", point.ToString()); @@ -56,10 +56,10 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else { - var detail = FindActiveDetailObject(page_view); + DetailViewObject detail = FindActiveDetailObject(page_view); if (null != detail) { - var point = point_obj.Location; + Point3d point = point_obj.Location; RhinoApp.WriteLine("World location: {0}", point.ToString()); point.Transform(detail.WorldToPageTransform); RhinoApp.WriteLine("Page location: {0}", point.ToString()); @@ -77,11 +77,11 @@ protected DetailViewObject FindActiveDetailObject(RhinoPageView pageView) if (null == pageView || pageView.PageIsActive) return null; - var details = pageView.GetDetailViews(); + DetailViewObject[] details = pageView.GetDetailViews(); if (null == details) return null; - foreach (var detail in details) + foreach (DetailViewObject detail in details) { if (detail.IsActive) return detail; @@ -98,7 +98,7 @@ public class GetDetailViewObject : GetObject { public override bool CustomGeometryFilter(RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex) { - var detail = rhObject as DetailViewObject; + DetailViewObject detail = rhObject as DetailViewObject; return detail != null; } } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsWrite3dmFile.cs b/rhinocommon/cs/SampleCsCommands/SampleCsWrite3dmFile.cs index c35bdfb5..c3fe4888 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsWrite3dmFile.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsWrite3dmFile.cs @@ -1,10 +1,10 @@ -using System.Drawing; -using System.IO; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.FileIO; using Rhino.Geometry; +using System.Drawing; +using System.IO; namespace SampleCsCommands { @@ -14,22 +14,22 @@ public class SampleCsWrite3dmFile : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop); - var filename = Path.Combine(path, "SampleCsWrite3dmFile.3dm"); + string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop); + string filename = Path.Combine(path, "SampleCsWrite3dmFile.3dm"); Result rc; - using (var file = new File3dm()) + using (File3dm file = new File3dm()) { - var layer = new Layer { Name = "Default", Color = Color.Black }; + Layer layer = new Layer { Name = "Default", Color = Color.Black }; file.AllLayers.Add(layer); - var layer_index = file.AllLayers.Count - 1; - var attributes = new ObjectAttributes { LayerIndex = layer_index }; + int layer_index = file.AllLayers.Count - 1; + ObjectAttributes attributes = new ObjectAttributes { LayerIndex = layer_index }; - for (var x = 0; x < 100; x++) + for (int x = 0; x < 100; x++) { - var line_curve = new LineCurve(new Point3d(x, 0, 0), new Point3d(x, 1, 0)); + LineCurve line_curve = new LineCurve(new Point3d(x, 0, 0), new Point3d(x, 1, 0)); if (line_curve.IsValid) file.Objects.AddCurve(line_curve, attributes); } diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsWriteStl.cs b/rhinocommon/cs/SampleCsCommands/SampleCsWriteStl.cs index b45ff9e7..866d7ae3 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsWriteStl.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsWriteStl.cs @@ -1,10 +1,10 @@ -using System; +using Rhino; +using Rhino.Commands; +using Rhino.Geometry; +using System; using System.Collections.Generic; using System.IO; using System.Text; -using Rhino; -using Rhino.Commands; -using Rhino.Geometry; namespace SampleCsCommands { @@ -36,8 +36,8 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) mesh.Normals.ComputeNormals(); mesh.Compact(); - var folder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); - var path = Path.Combine(folder, "SampleCsWriteStl.stl"); + string folder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + string path = Path.Combine(folder, "SampleCsWriteStl.stl"); FileStl.WriteFile(mesh, path); return Result.Success; @@ -64,7 +64,7 @@ public static bool WriteFile(IList meshes, string path) { try { - var model = WriteString(meshes); + string model = WriteString(meshes); File.WriteAllText(path, model); } catch (Exception) @@ -87,31 +87,31 @@ public static string WriteString(Mesh mesh) /// public static string WriteString(IList meshes) { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); - var name = meshes.Count == 1 ? "Mesh" : "Composite Mesh"; + string name = meshes.Count == 1 ? "Mesh" : "Composite Mesh"; sb.AppendLine(string.Format("solid {0}", name)); - foreach (var mesh in meshes) + foreach (Mesh mesh in meshes) { // STL files contain triangle meshes - var m = mesh.DuplicateMesh(); + Mesh m = mesh.DuplicateMesh(); m.Faces.ConvertQuadsToTriangles(); m.FaceNormals.ComputeFaceNormals(); m.Normals.ComputeNormals(); m.Compact(); - for (var i = 0; i < m.Faces.Count; i++) + for (int i = 0; i < m.Faces.Count; i++) { - var f = m.Faces[i]; + MeshFace f = m.Faces[i]; - var n = m.FaceNormals[i]; + Vector3f n = m.FaceNormals[i]; sb.AppendLine($"facet normal {n.X} {n.Y} {n.Z}"); sb.AppendLine("outer loop"); - var a = m.Vertices[f.A]; - var b = m.Vertices[f.B]; - var c = m.Vertices[f.C]; + Point3f a = m.Vertices[f.A]; + Point3f b = m.Vertices[f.B]; + Point3f c = m.Vertices[f.C]; sb.AppendLine($"\tvertex {a.X} {a.Y} {a.Z}"); sb.AppendLine($"\tvertex {b.X} {b.Y} {b.Z}"); diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsZAnalysis.cs b/rhinocommon/cs/SampleCsCommands/SampleCsZAnalysis.cs index ef596c76..b5fa4d81 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsZAnalysis.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsZAnalysis.cs @@ -1,12 +1,12 @@ -using System; -using System.Drawing; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; using Rhino.Render; +using System; +using System.Drawing; namespace SampleCsCommands { @@ -19,7 +19,7 @@ public class SampleCsZAnalysisOn : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var analysis_mode = VisualAnalysisMode.Find(typeof(SampleCsZAnalysisMode)); + VisualAnalysisMode analysis_mode = VisualAnalysisMode.Find(typeof(SampleCsZAnalysisMode)); if (null == analysis_mode) analysis_mode = VisualAnalysisMode.Register(typeof(SampleCsZAnalysisMode)); if (null == analysis_mode) @@ -29,14 +29,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } const ObjectType filter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Mesh; - var rc = RhinoGet.GetMultipleObjects("Select objects for Z analysis", false, filter, out var obj_refs); + Result rc = RhinoGet.GetMultipleObjects("Select objects for Z analysis", false, filter, out ObjRef[] obj_refs); if (rc != Result.Success) return rc; - var count = 0; - foreach (var obj_ref in obj_refs) + int count = 0; + foreach (ObjRef obj_ref in obj_refs) { - var obj = obj_ref.Object(); + RhinoObject obj = obj_ref.Object(); // see if this object is already in Z-Analysis mode if (obj.InVisualAnalysisMode(analysis_mode)) @@ -62,10 +62,10 @@ public class SampleCsZAnalysisOff : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var analysis_mode = VisualAnalysisMode.Find(typeof(SampleCsZAnalysisMode)); + VisualAnalysisMode analysis_mode = VisualAnalysisMode.Find(typeof(SampleCsZAnalysisMode)); if (analysis_mode != null) { - foreach (var obj in doc.Objects) + foreach (RhinoObject obj in doc.Objects) obj.EnableVisualAnalysisMode(analysis_mode, false); doc.Views.Redraw(); } @@ -110,9 +110,9 @@ public override bool ObjectSupportsAnalysisMode(RhinoObject obj) protected override void UpdateVertexColors(RhinoObject obj, Mesh[] meshes) { // A "mapping tag" is used to determine if the colors need to be set - var mt = GetMappingTag(); + MappingTag mt = GetMappingTag(); - foreach (var mesh in meshes) + foreach (Mesh mesh in meshes) { if (mesh.VertexColors.Tag.Id != Id) { @@ -121,8 +121,8 @@ protected override void UpdateVertexColors(RhinoObject obj, Mesh[] meshes) // false colors set using different m_z_range[]/m_hue_range[] values, or // the mesh has been moved. In any case, we need to set the false // colors to the ones we want. - var colors = new Color[mesh.Vertices.Count]; - for (var i = 0; i < mesh.Vertices.Count; i++) + Color[] colors = new Color[mesh.Vertices.Count]; + for (int i = 0; i < mesh.Vertices.Count; i++) { double z = mesh.Vertices[i].Z; colors[i] = FalseColor(z); @@ -142,7 +142,7 @@ protected override void UpdateVertexColors(RhinoObject obj, Mesh[] meshes) /// private MappingTag GetMappingTag() { - var mt = new MappingTag(); + MappingTag mt = new MappingTag(); // Since the false colors that are shown will change if // the mesh is transformed, we have to initialize the @@ -178,9 +178,9 @@ private Color FalseColor(double z) { // Simple example of one way to change a number // into a color. - var s = m_z_range.NormalizedParameterAt(z); + double s = m_z_range.NormalizedParameterAt(z); s = RhinoMath.Clamp(s, 0.0, 1.0); - var hue = m_hue_range.ParameterAt(s); + double hue = m_hue_range.ParameterAt(s); return ColorFromHsv(hue, 1.0, 1.0); } @@ -203,7 +203,7 @@ private static Color ColorFromHsv(double hue, double saturation, double value) else { hue *= 3.0 / Math.PI; // (6.0 / 2.0 * ON_PI); - var i = (int)Math.Floor(hue); + int i = (int)Math.Floor(hue); if (i < 0 || i > 5) { hue = hue % 6.0; @@ -211,10 +211,10 @@ private static Color ColorFromHsv(double hue, double saturation, double value) hue += 6.0; i = (int)Math.Floor(hue); } - var f = hue - i; - var p = value * (1.0 - saturation); - var q = value * (1.0 - (saturation * f)); - var t = value * (1.0 - (saturation * (1.0 - f))); + double f = hue - i; + double p = value * (1.0 - saturation); + double q = value * (1.0 - (saturation * f)); + double t = value * (1.0 - (saturation * (1.0 - f))); switch (i) { case 0: @@ -251,10 +251,10 @@ private static Color ColorFromFractionalArgb(double alpha, double red, double gr blue *= 255.0; alpha *= 255.0; - var r = (int)red; - var g = (int)green; - var b = (int)blue; - var a = (int)alpha; + int r = (int)red; + int g = (int)green; + int b = (int)blue; + int a = (int)alpha; if (red - r >= 0.5) r++; if (green - g >= 0.5) g++; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsZebraAnalysis.cs b/rhinocommon/cs/SampleCsCommands/SampleCsZebraAnalysis.cs index 11523607..21513067 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsZebraAnalysis.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsZebraAnalysis.cs @@ -12,12 +12,12 @@ public class SampleCsZebraAnalysis : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var zebra_id = VisualAnalysisMode.RhinoZebraStripeAnalysisModeId; - var analysis_mode = VisualAnalysisMode.Find(zebra_id); + System.Guid zebra_id = VisualAnalysisMode.RhinoZebraStripeAnalysisModeId; + VisualAnalysisMode analysis_mode = VisualAnalysisMode.Find(zebra_id); if (null == analysis_mode) return Result.Failure; - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select surfaces or polysurfaces for Zebra analysis"); go.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go.SubObjectSelect = false; @@ -25,9 +25,9 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - foreach (var obj_ref in go.Objects()) + foreach (ObjRef obj_ref in go.Objects()) { - var obj = obj_ref.Object(); + RhinoObject obj = obj_ref.Object(); if (null == obj) return Result.Failure; diff --git a/rhinocommon/cs/SampleCsCommands/SampleCsZoom.cs b/rhinocommon/cs/SampleCsCommands/SampleCsZoom.cs index aea40ea3..a633bfbb 100644 --- a/rhinocommon/cs/SampleCsCommands/SampleCsZoom.cs +++ b/rhinocommon/cs/SampleCsCommands/SampleCsZoom.cs @@ -11,39 +11,39 @@ public class SampleCsZoom : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var view = doc.Views.ActiveView; + Rhino.Display.RhinoView view = doc.Views.ActiveView; if (null == view) return Result.Failure; - var gz = new GetOption(); + GetOption gz = new GetOption(); gz.SetCommandPrompt("Zoom option"); - var b_opt = gz.AddOption("BoundingBox"); - var e_opt = gz.AddOption("Extents"); - var s_opt = gz.AddOption("Selected"); + int b_opt = gz.AddOption("BoundingBox"); + int e_opt = gz.AddOption("Extents"); + int s_opt = gz.AddOption("Selected"); gz.Get(); if (gz.CommandResult() != Result.Success) return gz.CommandResult(); - var option = gz.Option(); + CommandLineOption option = gz.Option(); if (null == option) return Result.Failure; if (option.Index == b_opt) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select objects"); go.SubObjectSelect = false; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var bbox = new BoundingBox(); - for (var i = 0; i < go.ObjectCount; i++) + BoundingBox bbox = new BoundingBox(); + for (int i = 0; i < go.ObjectCount; i++) { - var geom = go.Object(i).Geometry(); + GeometryBase geom = go.Object(i).Geometry(); if (null != geom) { - var b = geom.GetBoundingBox(true); + BoundingBox b = geom.GetBoundingBox(true); if (b.IsValid) { if (0 == i) diff --git a/rhinocommon/cs/SampleCsCustomLightManager/CustomLightManager.cs b/rhinocommon/cs/SampleCsCustomLightManager/CustomLightManager.cs index fdfff3ca..05e54b5d 100644 --- a/rhinocommon/cs/SampleCsCustomLightManager/CustomLightManager.cs +++ b/rhinocommon/cs/SampleCsCustomLightManager/CustomLightManager.cs @@ -1,7 +1,7 @@ -using System; -using Rhino; +using Rhino; using Rhino.Geometry; using Rhino.Render; +using System; using System.Collections.Generic; namespace SampleCustomLightManager @@ -243,9 +243,9 @@ public override int ObjectSerialNumberFromLight(RhinoDoc doc, ref Light light) public override bool OnEditLight(RhinoDoc doc, ref LightArray light_array) { #pragma warning disable CS0162 // Unreachable code detected - for (int i = 0; i < light_array.Count(); i++) + for (int i = 0; i < light_array.Count(); i++) #pragma warning restore CS0162 // Unreachable code detected - { + { Rhino.Geometry.Light light = light_array.ElementAt(i); int index = doc.Lights.Find(light.Id, true); if (index > -1) @@ -293,12 +293,12 @@ public override int LightsInSoloStorage(RhinoDoc doc) public override void GroupLights(RhinoDoc doc, ref LightArray light_array) { - + } public override void UnGroup(RhinoDoc doc, ref LightArray light_array) { - + } } diff --git a/rhinocommon/cs/SampleCsCustomLightManager/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsCustomLightManager/Properties/AssemblyInfo.cs index 513c8390..fc0235a5 100644 --- a/rhinocommon/cs/SampleCsCustomLightManager/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsCustomLightManager/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsCustomLightManager/SampleCustomLightManagerCommand.cs b/rhinocommon/cs/SampleCsCustomLightManager/SampleCustomLightManagerCommand.cs index 83e91d3f..ae4379ab 100644 --- a/rhinocommon/cs/SampleCsCustomLightManager/SampleCustomLightManagerCommand.cs +++ b/rhinocommon/cs/SampleCsCustomLightManager/SampleCustomLightManagerCommand.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; -using Rhino.Geometry; -using Rhino.Input; -using Rhino.Input.Custom; namespace SampleCustomLightManager { diff --git a/rhinocommon/cs/SampleCsCustomMeshMapping/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsCustomMeshMapping/Properties/AssemblyInfo.cs index 482f11d9..e20f7fc8 100644 --- a/rhinocommon/cs/SampleCsCustomMeshMapping/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsCustomMeshMapping/Properties/AssemblyInfo.cs @@ -1,7 +1,6 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional. // These will show in Rhino's option dialog, in the tab Plug-ins. diff --git a/rhinocommon/cs/SampleCsCustomMeshMapping/SampleCsCustomMeshMappingCommand.cs b/rhinocommon/cs/SampleCsCustomMeshMapping/SampleCsCustomMeshMappingCommand.cs index 744fddf3..71f2ac2c 100644 --- a/rhinocommon/cs/SampleCsCustomMeshMapping/SampleCsCustomMeshMappingCommand.cs +++ b/rhinocommon/cs/SampleCsCustomMeshMapping/SampleCsCustomMeshMappingCommand.cs @@ -1,11 +1,9 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; +using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; -using Rhino.DocObjects; using Rhino.Render; namespace SampleCsCustomMeshMapping @@ -40,7 +38,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { go.SetCommandPrompt("Select object to apply custom mesh mapping to"); go.GeometryFilter = ObjectType.Brep | ObjectType.Extrusion | ObjectType.Mesh; - var goRes = go.Get(); + GetResult goRes = go.Get(); if (goRes != GetResult.Object) { return go.CommandResult(); @@ -52,13 +50,13 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Get render meshes from the object - var renderMeshes = rhinoObject.GetMeshes(Rhino.Geometry.MeshType.Render); + Mesh[] renderMeshes = rhinoObject.GetMeshes(Rhino.Geometry.MeshType.Render); if (renderMeshes != null && renderMeshes.Length > 0 && renderMeshes[0] != null) { // Create mapping mesh from render meshes Mesh mappingMesh = new Mesh(); - foreach (var renderMesh in renderMeshes) + foreach (Mesh renderMesh in renderMeshes) { if (renderMesh != null) { diff --git a/rhinocommon/cs/SampleCsCustomMeshMapping/SampleCsCustomMeshMappingPlugIn.cs b/rhinocommon/cs/SampleCsCustomMeshMapping/SampleCsCustomMeshMappingPlugIn.cs index 75a0bf8d..a7d22326 100644 --- a/rhinocommon/cs/SampleCsCustomMeshMapping/SampleCsCustomMeshMappingPlugIn.cs +++ b/rhinocommon/cs/SampleCsCustomMeshMapping/SampleCsCustomMeshMappingPlugIn.cs @@ -1,29 +1,29 @@ namespace SampleCsCustomMeshMapping { - /// - /// Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived - /// class. DO NOT create instances of this class yourself. It is the - /// responsibility of Rhino to create an instance of this class. - /// To complete plug-in information, please also see all PlugInDescription - /// attributes in AssemblyInfo.cs (you might need to click "Project" -> - /// "Show All Files" to see it in the "Solution Explorer" window). - /// - public class SampleCsCustomMeshMappingPlugIn : Rhino.PlugIns.PlugIn + /// + /// Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived + /// class. DO NOT create instances of this class yourself. It is the + /// responsibility of Rhino to create an instance of this class. + /// To complete plug-in information, please also see all PlugInDescription + /// attributes in AssemblyInfo.cs (you might need to click "Project" -> + /// "Show All Files" to see it in the "Solution Explorer" window). + /// + public class SampleCsCustomMeshMappingPlugIn : Rhino.PlugIns.PlugIn + { + public SampleCsCustomMeshMappingPlugIn() { - public SampleCsCustomMeshMappingPlugIn() - { - Instance = this; - } - - ///Gets the only instance of the SampleCsCustomMeshMappingPlugIn plug-in. - public static SampleCsCustomMeshMappingPlugIn Instance - { - get; private set; - } + Instance = this; + } - // You can override methods here to change the plug-in behavior on - // loading and shut down, add options pages to the Rhino _Option command - // and maintain plug-in wide options in a document. + ///Gets the only instance of the SampleCsCustomMeshMappingPlugIn plug-in. + public static SampleCsCustomMeshMappingPlugIn Instance + { + get; private set; } + + // You can override methods here to change the plug-in behavior on + // loading and shut down, add options pages to the Rhino _Option command + // and maintain plug-in wide options in a document. + } } \ No newline at end of file diff --git a/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSection1.cs b/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSection1.cs index a7d44095..22945b2a 100644 --- a/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSection1.cs +++ b/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSection1.cs @@ -1,6 +1,6 @@ -using System; -using Eto.Forms; +using Eto.Forms; using Rhino.UI; +using System; namespace SampleCustomRenderSettingsSections { @@ -172,7 +172,7 @@ private void DisplayData() private void OnCheckedChanged(object sender, EventArgs e) { m_checkbox_lb.Text = m_checkbox.Checked.ToString(); - + if (m_checkbox.Checked != null) { bool checked_state = (bool)m_checkbox.Checked; diff --git a/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSettingsSectionsPlugIn.cs b/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSettingsSectionsPlugIn.cs index 2da2b999..b2a4ce66 100644 --- a/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSettingsSectionsPlugIn.cs +++ b/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSettingsSectionsPlugIn.cs @@ -1,10 +1,9 @@ -using Rhino.UI.Controls; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Runtime; - +using Rhino.UI.Controls; using System; +using System.Collections.Generic; namespace SampleCustomRenderSettingsSections { @@ -41,7 +40,7 @@ public CustomRenderSettingsSectionsPlugIn() m_uuidRenderSettingsSection_ColorAdjustment = new Guid("26126531-70c2-42bc-b50c-3368260dc0b4"); } - if(HostUtils.RunningOnOSX) + if (HostUtils.RunningOnOSX) { m_uuidRenderSettingsSection_CurrentRenderer = new Guid("5B1FAC38-CE66-4319-A05F-88185FC757EE"); m_uuidRenderSettingsSection_Resolution = new Guid("C3CF2B4A-5F0F-499E-8E95-364F8767B8DA"); diff --git a/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSettingsViewModel.cs b/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSettingsViewModel.cs index 711909de..589d8f75 100644 --- a/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSettingsViewModel.cs +++ b/rhinocommon/cs/SampleCsCustomRenderSettingsSections/CustomRenderSettingsViewModel.cs @@ -1,8 +1,7 @@ -using System.ComponentModel; -using System.Runtime.CompilerServices; +using Rhino.Collections; using Rhino.UI.Controls; -using Rhino.Render; -using Rhino.Collections; +using System.ComponentModel; +using System.Runtime.CompilerServices; namespace SampleCustomRenderSettingsSections @@ -32,7 +31,7 @@ public bool? CheckBoxValue { get { - var rs = RenderSettingsForRead(); + Rhino.Render.DataSources.RhinoSettings rs = RenderSettingsForRead(); bool value = false; @@ -50,9 +49,9 @@ public bool? CheckBoxValue { if (value != null) { - using (var u = UndoHelper("Custom Render Section 1 BoolValue changed")) + using (UndoRecord u = UndoHelper("Custom Render Section 1 BoolValue changed")) { - var rs = RenderSettingsForWrite(); + Rhino.Render.DataSources.RhinoSettings rs = RenderSettingsForWrite(); Rhino.Render.RenderSettings render_settings = rs.GetRenderSettings(); ArchivableDictionary userdata = render_settings.UserDictionary; diff --git a/rhinocommon/cs/SampleCsCustomRenderSettingsSections/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsCustomRenderSettingsSections/Properties/AssemblyInfo.cs index 2863a77d..6702993a 100644 --- a/rhinocommon/cs/SampleCsCustomRenderSettingsSections/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsCustomRenderSettingsSections/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSection1.cs b/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSection1.cs index b138ebf8..f0d63611 100644 --- a/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSection1.cs +++ b/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSection1.cs @@ -1,7 +1,6 @@ -using System; -using Rhino.UI.Controls; -using Eto.Forms; +using Eto.Forms; using Rhino.UI; +using System; namespace CustomSunSections { diff --git a/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSection2.cs b/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSection2.cs index 6d286c05..21ba1ab2 100644 --- a/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSection2.cs +++ b/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSection2.cs @@ -1,6 +1,4 @@ -using System; -using Rhino.UI.Controls; -using Eto.Forms; +using Eto.Forms; using Rhino.UI; namespace CustomSunSections diff --git a/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSectionsCommand.cs b/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSectionsCommand.cs index 29691e99..b00f373e 100644 --- a/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSectionsCommand.cs +++ b/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSectionsCommand.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; -using Rhino.Geometry; -using Rhino.Input; -using Rhino.Input.Custom; namespace CustomSunSections { diff --git a/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSectionsPlugIn.cs b/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSectionsPlugIn.cs index 542e3f8e..49e81c41 100644 --- a/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSectionsPlugIn.cs +++ b/rhinocommon/cs/SampleCsCustomSunSections/CustomSunSectionsPlugIn.cs @@ -1,8 +1,7 @@ -using Rhino.UI.Controls; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; -using System; +using Rhino.UI.Controls; +using System.Collections.Generic; namespace CustomSunSections { diff --git a/rhinocommon/cs/SampleCsCustomSunSections/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsCustomSunSections/Properties/AssemblyInfo.cs index 188b82b7..72560a2e 100644 --- a/rhinocommon/cs/SampleCsCustomSunSections/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsCustomSunSections/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Commands/SampleCsDeserializeEmbeddedResourceCommand.cs b/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Commands/SampleCsDeserializeEmbeddedResourceCommand.cs index b8f939f3..70c4f3ce 100644 --- a/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Commands/SampleCsDeserializeEmbeddedResourceCommand.cs +++ b/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Commands/SampleCsDeserializeEmbeddedResourceCommand.cs @@ -12,11 +12,11 @@ public class SampleCsDeserializeEmbeddedResource : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var geometry = SampleCsGeometryHelper.ReadFromEmbeddedResource(RESOURCE); + GeometryBase geometry = SampleCsGeometryHelper.ReadFromEmbeddedResource(RESOURCE); if (null == geometry) return Result.Failure; - var brep = geometry as Brep; + Brep brep = geometry as Brep; if (null != brep) { doc.Objects.AddBrep(brep); diff --git a/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Commands/SampleCsSerializeBrepToFileCommand.cs b/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Commands/SampleCsSerializeBrepToFileCommand.cs index ef832844..de44cf1d 100644 --- a/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Commands/SampleCsSerializeBrepToFileCommand.cs +++ b/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Commands/SampleCsSerializeBrepToFileCommand.cs @@ -1,10 +1,10 @@ -using System.IO; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.DocObjects; using Rhino.Input; using Rhino.Input.Custom; using Rhino.UI; +using System.IO; namespace SampleCsDeserializeEmbeddedResource.Commands { @@ -18,7 +18,7 @@ public class SampleCsSerializeBrepToFileCommand : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Selet surface or polysurface to serialize to a file."); go.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go.SubObjectSelect = false; @@ -26,14 +26,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var brep = go.Object(0).Brep(); + Rhino.Geometry.Brep brep = go.Object(0).Brep(); if (null == brep) return Result.Failure; string path = null; if (mode == RunMode.Interactive) { - var dialog = new SaveFileDialog + SaveFileDialog dialog = new SaveFileDialog { Title = EnglishName, Filter = @"Bin Files (*.bin)|*.bin||", @@ -47,7 +47,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } else { - var result = RhinoGet.GetString("Save file name", false, ref path); + Result result = RhinoGet.GetString("Save file name", false, ref path); if (result != Result.Success) return result; } @@ -59,7 +59,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (!Path.HasExtension(path)) path = Path.ChangeExtension(path, ".bin"); - var rc = SampleCsGeometryHelper.WriteToFile(path, brep); + bool rc = SampleCsGeometryHelper.WriteToFile(path, brep); return rc ? Result.Success : Result.Failure; } diff --git a/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Properties/AssemblyInfo.cs index d04dc7dc..b4f6b2d0 100644 --- a/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; [assembly: PlugInDescription(DescriptionType.Address, "3670 Woodland Park Avenue North\r\nSeattle, WA 98103")] [assembly: PlugInDescription(DescriptionType.Country, "United States")] diff --git a/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/SampleCsGeometryHelper.cs b/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/SampleCsGeometryHelper.cs index c4b10fe2..7ff90512 100644 --- a/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/SampleCsGeometryHelper.cs +++ b/rhinocommon/cs/SampleCsDeserializeEmbeddedResource/SampleCsGeometryHelper.cs @@ -1,9 +1,9 @@ -using System; +using Rhino.Geometry; +using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.Serialization.Formatters.Binary; -using Rhino.Geometry; namespace SampleCsDeserializeEmbeddedResource { @@ -20,14 +20,14 @@ public static bool WriteToFile(string path, GeometryBase geometry) if (null == geometry) return false; - var bytes = ToBytes(geometry); + byte[] bytes = ToBytes(geometry); if (null == bytes || 0 == bytes.Length) return false; bool rc; try { - using (var stream = new FileStream(path, FileMode.Create, FileAccess.Write)) + using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write)) { stream.Write(bytes, 0, bytes.Length); rc = true; @@ -52,19 +52,19 @@ public static GeometryBase ReadFromEmbeddedResource(string resource) try { - var assembly = Assembly.GetExecutingAssembly(); - using (var stream = assembly.GetManifestResourceStream(resource)) + Assembly assembly = Assembly.GetExecutingAssembly(); + using (Stream stream = assembly.GetManifestResourceStream(resource)) { if (null != stream) { - var bytes_to_read = (int)stream.Length; + int bytes_to_read = (int)stream.Length; if (bytes_to_read > 0) { - var bytes = new byte[bytes_to_read]; - var bytes_read = stream.Read(bytes, 0, bytes_to_read); + byte[] bytes = new byte[bytes_to_read]; + int bytes_read = stream.Read(bytes, 0, bytes_to_read); if (bytes_read == bytes_to_read) { - var geometry = ToGeometryBase(bytes); + GeometryBase geometry = ToGeometryBase(bytes); return geometry; } } @@ -84,15 +84,15 @@ public static GeometryBase ReadFromEmbeddedResource(string resource) /// private static byte[] ToBytes(GeometryBase src) { - var rc = new byte[0]; + byte[] rc = new byte[0]; if (null == src) return rc; try { - var formatter = new BinaryFormatter(); - using (var stream = new MemoryStream()) + BinaryFormatter formatter = new BinaryFormatter(); + using (MemoryStream stream = new MemoryStream()) { formatter.Serialize(stream, src); rc = stream.ToArray(); @@ -117,12 +117,12 @@ private static GeometryBase ToGeometryBase(byte[] bytes) GeometryBase rc = null; try { - using (var stream = new MemoryStream()) + using (MemoryStream stream = new MemoryStream()) { - var formatter = new BinaryFormatter(); + BinaryFormatter formatter = new BinaryFormatter(); stream.Write(bytes, 0, bytes.Length); stream.Seek(0, SeekOrigin.Begin); - var geometry = formatter.Deserialize(stream) as GeometryBase; + GeometryBase geometry = formatter.Deserialize(stream) as GeometryBase; if (null != geometry && geometry.IsValid) rc = geometry; } diff --git a/rhinocommon/cs/SampleCsDockBar/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsDockBar/Properties/AssemblyInfo.cs index 56c2b097..9f7ea3eb 100644 --- a/rhinocommon/cs/SampleCsDockBar/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsDockBar/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional. // These will show in Rhino's option dialog, in the tab Plug-ins. diff --git a/rhinocommon/cs/SampleCsDockBar/SampleCsDockbarCommand.cs b/rhinocommon/cs/SampleCsDockBar/SampleCsDockbarCommand.cs index c26fb44b..d27330d0 100644 --- a/rhinocommon/cs/SampleCsDockBar/SampleCsDockbarCommand.cs +++ b/rhinocommon/cs/SampleCsDockBar/SampleCsDockbarCommand.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; -using Rhino.Geometry; -using Rhino.Input; -using Rhino.Input.Custom; namespace SampleCsDockBar { diff --git a/rhinocommon/cs/SampleCsDockBar/SampleCsDocklBarPlugIn.cs b/rhinocommon/cs/SampleCsDockBar/SampleCsDocklBarPlugIn.cs index 93f94548..b5488cdf 100644 --- a/rhinocommon/cs/SampleCsDockBar/SampleCsDocklBarPlugIn.cs +++ b/rhinocommon/cs/SampleCsDockBar/SampleCsDocklBarPlugIn.cs @@ -1,6 +1,6 @@ -using System; -using Rhino.PlugIns; +using Rhino.PlugIns; using RhinoWindows.Controls; +using System; namespace SampleCsDockBar { @@ -37,10 +37,10 @@ protected override LoadReturnCode OnLoad(ref string errorMessage) CreateMyDockBar(); return base.OnLoad(ref errorMessage); } - + private void CreateMyDockBar() { - var create_options = new DockBarCreateOptions + DockBarCreateOptions create_options = new DockBarCreateOptions { DockLocation = DockBarDockLocation.Right, Visible = false, diff --git a/rhinocommon/cs/SampleCsDockBar/SampleCsWinFormPanel.cs b/rhinocommon/cs/SampleCsDockBar/SampleCsWinFormPanel.cs index 29d40228..eaf6038a 100644 --- a/rhinocommon/cs/SampleCsDockBar/SampleCsWinFormPanel.cs +++ b/rhinocommon/cs/SampleCsDockBar/SampleCsWinFormPanel.cs @@ -1,12 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +using System.Windows.Forms; namespace SampleCsDockBar { diff --git a/rhinocommon/cs/SampleCsDragDrop/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsDragDrop/Properties/AssemblyInfo.cs index e443abd3..76a1006d 100644 --- a/rhinocommon/cs/SampleCsDragDrop/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsDragDrop/Properties/AssemblyInfo.cs @@ -1,7 +1,6 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional. // These will show in Rhino's option dialog, in the tab Plug-ins. diff --git a/rhinocommon/cs/SampleCsDragDrop/SampleCsDragDropCommand.cs b/rhinocommon/cs/SampleCsDragDrop/SampleCsDragDropCommand.cs index 94b41bb9..182166fd 100644 --- a/rhinocommon/cs/SampleCsDragDrop/SampleCsDragDropCommand.cs +++ b/rhinocommon/cs/SampleCsDragDrop/SampleCsDragDropCommand.cs @@ -11,28 +11,28 @@ public class SampleCsDragDropCommand : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var panel_id = SampleCsUserControl.PanelId; - var visible = Panels.IsPanelVisible(panel_id); + System.Guid panel_id = SampleCsUserControl.PanelId; + bool visible = Panels.IsPanelVisible(panel_id); - var prompt = visible + string prompt = visible ? "Sample panel is visible. New value" : "Sample Manager panel is hidden. New value"; - var go = new GetOption(); + GetOption go = new GetOption(); go.SetCommandPrompt(prompt); - var hide_index = go.AddOption("Hide"); - var show_index = go.AddOption("Show"); - var toggle_index = go.AddOption("Toggle"); + int hide_index = go.AddOption("Hide"); + int show_index = go.AddOption("Show"); + int toggle_index = go.AddOption("Toggle"); go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var option = go.Option(); + CommandLineOption option = go.Option(); if (null == option) return Result.Failure; - var index = option.Index; + int index = option.Index; if (index == hide_index) { diff --git a/rhinocommon/cs/SampleCsDragDrop/SampleCsDropTarget.cs b/rhinocommon/cs/SampleCsDragDrop/SampleCsDropTarget.cs index 292eee56..d06a2838 100644 --- a/rhinocommon/cs/SampleCsDragDrop/SampleCsDropTarget.cs +++ b/rhinocommon/cs/SampleCsDragDrop/SampleCsDropTarget.cs @@ -1,9 +1,9 @@ -using System.Drawing; -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Display; using Rhino.DocObjects; using RhinoWindows.Forms; +using System.Drawing; +using System.Windows.Forms; namespace SampleCsDragDrop { @@ -20,7 +20,7 @@ public SampleCsDropTarget() protected override bool SupportDataObject(DataObject data) { - var str = DropString(data); + string str = DropString(data); RhinoApp.WriteLine($"SampleCsDropTarget.SupportDataObject({str})"); return !string.IsNullOrEmpty(str); } @@ -45,7 +45,7 @@ protected override bool OnDropOnObject(ObjRef objRef, RhinoView rhinoView, DataO private string DropString(DataObject dataObject) { - var control = dataObject?.GetData(typeof(SampleCsUserControl)) as SampleCsUserControl; + SampleCsUserControl control = dataObject?.GetData(typeof(SampleCsUserControl)) as SampleCsUserControl; return control?.DropString; } } diff --git a/rhinocommon/cs/SampleCsDragDrop/SampleCsUserControl.cs b/rhinocommon/cs/SampleCsDragDrop/SampleCsUserControl.cs index 1a101570..3c8a8ef1 100644 --- a/rhinocommon/cs/SampleCsDragDrop/SampleCsUserControl.cs +++ b/rhinocommon/cs/SampleCsDragDrop/SampleCsUserControl.cs @@ -29,14 +29,14 @@ private void OnListBoxMouseDown(object sender, MouseEventArgs e) private void OnListBoxMouseMove(object sender, MouseEventArgs e) { - var item_index = m_listbox.IndexFromPoint(e.Location); + int item_index = m_listbox.IndexFromPoint(e.Location); if (m_drag_item_index < 0 || m_dragging || item_index == m_drag_item_index) return; m_dragging = true; Rhino.RhinoApp.WriteLine("DoDragDrop..."); - var result = m_listbox.DoDragDrop(this, DragDropEffects.All); + DragDropEffects result = m_listbox.DoDragDrop(this, DragDropEffects.All); Rhino.RhinoApp.WriteLine($"...DoneDragDrop({result})"); m_dragging = false; diff --git a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoCoffee.cs b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoCoffee.cs index a95c01b9..c64e9c64 100644 --- a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoCoffee.cs +++ b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoCoffee.cs @@ -1,8 +1,8 @@ -using Rhino; -using Rhino.UI; -using Eto.Drawing; +using Eto.Drawing; using Eto.Forms; +using Rhino; using Rhino.Commands; +using Rhino.UI; namespace SampleCsEto.Commands { @@ -12,8 +12,8 @@ public class SampleCsEtoCoffee : Rhino.Commands.Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var form = new CoffeeDialog(); - var rc = form.ShowModal(RhinoEtoApp.MainWindow); + CoffeeDialog form = new CoffeeDialog(); + Result rc = form.ShowModal(RhinoEtoApp.MainWindow); return rc; } } @@ -25,21 +25,21 @@ public CoffeeDialog() Title = "Coffee"; Resizable = true; - var sep0 = new TestSeparator { Text = "Roast" }; - var chk0 = new CheckBox { Text = "Light roast" }; - var chk1 = new CheckBox { Text = "Medium roast" }; - var chk2 = new CheckBox { Text = "Medium-Dark roast" }; - var chk3 = new CheckBox { Text = "Dark roast" }; + TestSeparator sep0 = new TestSeparator { Text = "Roast" }; + CheckBox chk0 = new CheckBox { Text = "Light roast" }; + CheckBox chk1 = new CheckBox { Text = "Medium roast" }; + CheckBox chk2 = new CheckBox { Text = "Medium-Dark roast" }; + CheckBox chk3 = new CheckBox { Text = "Dark roast" }; - var sep1 = new TestSeparator { Text = "Flavor" }; - var chk4 = new CheckBox { Text = "Mild" }; - var chk5 = new CheckBox { Text = "Bold" }; - var chk6 = new CheckBox { Text = "Extra bold" }; + TestSeparator sep1 = new TestSeparator { Text = "Flavor" }; + CheckBox chk4 = new CheckBox { Text = "Mild" }; + CheckBox chk5 = new CheckBox { Text = "Bold" }; + CheckBox chk6 = new CheckBox { Text = "Extra bold" }; - var sep2 = new TestSeparator { Text = "Temperature" }; - var chk7 = new CheckBox { Text = "Cold" }; - var chk8 = new CheckBox { Text = "Warm" }; - var chk9 = new CheckBox { Text = "Hot" }; + TestSeparator sep2 = new TestSeparator { Text = "Temperature" }; + CheckBox chk7 = new CheckBox { Text = "Cold" }; + CheckBox chk8 = new CheckBox { Text = "Warm" }; + CheckBox chk9 = new CheckBox { Text = "Hot" }; DefaultButton = new Button { Text = "OK" }; DefaultButton.Click += (sender, e) => Close(Rhino.Commands.Result.Success); @@ -47,7 +47,7 @@ public CoffeeDialog() AbortButton = new Button { Text = "C&ancel" }; AbortButton.Click += (sender, e) => Close(Rhino.Commands.Result.Cancel); - var buttons = new StackLayout + StackLayout buttons = new StackLayout { Orientation = Orientation.Horizontal, Spacing = 5, @@ -168,7 +168,7 @@ protected override void OnLoadComplete(System.EventArgs e) protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); - var middle = new PointF(Size / 2); + PointF middle = new PointF(Size / 2); e.Graphics.FillRectangle( Color, Orientation == Orientation.Horizontal diff --git a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoModalDialogCommand.cs b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoModalDialogCommand.cs index c6ad4c16..72a7dabc 100644 --- a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoModalDialogCommand.cs +++ b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoModalDialogCommand.cs @@ -13,18 +13,18 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var rc = Result.Cancel; + Result rc = Result.Cancel; if (mode == RunMode.Interactive) { - var dialog = new Views.SampleCsEtoModalDialog(); - var dialog_rc = dialog.ShowModal(RhinoEtoApp.MainWindow); + Views.SampleCsEtoModalDialog dialog = new Views.SampleCsEtoModalDialog(); + Eto.Forms.DialogResult dialog_rc = dialog.ShowModal(RhinoEtoApp.MainWindow); if (dialog_rc == Eto.Forms.DialogResult.Ok) rc = Result.Success; } else { - var msg = string.Format("Scriptable version of {0} command not implemented.", EnglishName); + string msg = string.Format("Scriptable version of {0} command not implemented.", EnglishName); RhinoApp.WriteLine(msg); } diff --git a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoModelessFormCommand.cs b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoModelessFormCommand.cs index 1cfa55c2..94229143 100644 --- a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoModelessFormCommand.cs +++ b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoModelessFormCommand.cs @@ -1,7 +1,7 @@ -using System; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.UI; +using System; namespace SampleCsEto.Commands { diff --git a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoOrderCurvesCommand.cs b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoOrderCurvesCommand.cs index e007de92..9fcd1c0d 100644 --- a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoOrderCurvesCommand.cs +++ b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoOrderCurvesCommand.cs @@ -1,13 +1,13 @@ -using System; -using System.Collections.ObjectModel; -using System.Collections.Generic; -using System.Linq; +using Eto.Drawing; +using Eto.Forms; using Rhino; using Rhino.Commands; using Rhino.DocObjects; -using Eto.Drawing; -using Eto.Forms; using Rhino.Input.Custom; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; namespace SampleCsEto.Commands { @@ -20,7 +20,7 @@ public class SampleCsEtoOrderCurvesCommand : Rhino.Commands.Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select curves"); go.GeometryFilter = ObjectType.Curve; go.SubObjectSelect = false; @@ -28,25 +28,25 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (go.CommandResult() != Result.Success) return go.CommandResult(); - var curves = new ObservableCollection(); - foreach (var objref in go.Objects()) + ObservableCollection curves = new ObservableCollection(); + foreach (ObjRef objref in go.Objects()) { - var rhinoObj = objref.Object(); + RhinoObject rhinoObj = objref.Object(); if (null == rhinoObj) return Result.Failure; if (rhinoObj is CurveObject curveObj) { - var curveItem = new CurveItem(curveObj); + CurveItem curveItem = new CurveItem(curveObj); curves.Add(curveItem); } } - var dialog = new OrderCurvesDialog(curves); + OrderCurvesDialog dialog = new OrderCurvesDialog(curves); dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow); if (dialog.Result == Result.Success) { - foreach (var id in dialog.OrderedIds) + foreach (Guid id in dialog.OrderedIds) { RhinoApp.WriteLine(id.ToString()); } @@ -91,12 +91,12 @@ public Guid[] OrderedIds /// private TableLayout CreateLayout() { - var label = new Label { Text = "Drag curves to reorder:" }; - var gridRow = CreateGridTableRow(); + Label label = new Label { Text = "Drag curves to reorder:" }; + TableRow gridRow = CreateGridTableRow(); return new TableLayout { - Padding = new Padding(8), - Spacing = new Size(5, 5), + Padding = new Padding(8), + Spacing = new Size(5, 5), Rows = { label, gridRow } }; } @@ -134,7 +134,7 @@ private TableRow CreateGridTableRow() m_grid.DragOver += OnGridViewDragOver; m_grid.DragDrop += OnGridViewDragDrop; - var tableRow = new TableRow(m_grid) { ScaleHeight = true }; + TableRow tableRow = new TableRow(m_grid) { ScaleHeight = true }; return tableRow; } @@ -159,10 +159,10 @@ private void OnGridViewMouseMove(object sender, MouseEventArgs e) && m_mousedown_point != null && m_mousedown_point.Value.Distance(e.Location) >= g_drag_offset) { - var cell = m_grid.GetCellAt(e.Location); + GridCell cell = m_grid.GetCellAt(e.Location); if (cell.Item != null) { - var data = new DataObject(); + DataObject data = new DataObject(); data.SetObject(m_grid.SelectedRows.ToArray(), g_drag_type); m_grid.DoDragDrop(data, DragEffects.Move); m_dragging = true; @@ -197,7 +197,7 @@ private void OnGridViewDragEnter(object sender, DragEventArgs e) private void OnGridViewDragOver(object sender, DragEventArgs e) { base.OnDragOver(e); - var info = m_grid.GetDragInfo(e); + GridViewDragInfo info = m_grid.GetDragInfo(e); if (info != null && e.Data.Contains(g_drag_type)) { info.RestrictToInsert(); @@ -211,24 +211,24 @@ private void OnGridViewDragOver(object sender, DragEventArgs e) private void OnGridViewDragDrop(object sender, DragEventArgs e) { base.OnDragDrop(e); - var info = m_grid.GetDragInfo(e); + GridViewDragInfo info = m_grid.GetDragInfo(e); if (info != null && e.Data.Contains(g_drag_type)) { - var index = info.InsertIndex; + int index = info.InsertIndex; if (index >= 0 && e.Data.GetObject(g_drag_type) is int[] source_rows) { - var data = new List(); - foreach (var row in source_rows.OrderByDescending(r => r)) + List data = new List(); + foreach (int row in source_rows.OrderByDescending(r => r)) { - var item = m_curves[row]; + CurveItem item = m_curves[row]; data.Add(item); m_curves.RemoveAt(row); if (row < index) index--; } - var selectedIndex = index; - foreach (var item in data) + int selectedIndex = index; + foreach (CurveItem item in data) m_curves.Insert(index++, item); m_grid.SelectedRow = selectedIndex; diff --git a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoPanelCommand.cs b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoPanelCommand.cs index 4c53cd3d..61cf915e 100644 --- a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoPanelCommand.cs +++ b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoPanelCommand.cs @@ -26,27 +26,27 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var panel_id = Views.SampleCsEtoPanel.PanelId; - var visible = Panels.IsPanelVisible(panel_id); + System.Guid panel_id = Views.SampleCsEtoPanel.PanelId; + bool visible = Panels.IsPanelVisible(panel_id); - var prompt = (visible) + string prompt = (visible) ? "Sample panel is visible. New value" : "Sample panel is hidden. New value"; - var go = new GetOption(); + GetOption go = new GetOption(); go.SetCommandPrompt(prompt); - var hide_index = go.AddOption("Hide"); - var show_index = go.AddOption("Show"); - var toggle_index = go.AddOption("Toggle"); + int hide_index = go.AddOption("Hide"); + int show_index = go.AddOption("Show"); + int toggle_index = go.AddOption("Toggle"); go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var option = go.Option(); + CommandLineOption option = go.Option(); if (null == option) return Result.Failure; - var index = option.Index; + int index = option.Index; if (index == hide_index) { if (visible) diff --git a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoRebuildCurve.cs b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoRebuildCurve.cs index 02776fb3..14575774 100644 --- a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoRebuildCurve.cs +++ b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoRebuildCurve.cs @@ -50,7 +50,7 @@ public RebuildCurveDialog(RebuildCurveArgs args) Title = "Rebuild"; Padding = new Eto.Drawing.Padding(5); - var layout = new Eto.Forms.DynamicLayout + Eto.Forms.DynamicLayout layout = new Eto.Forms.DynamicLayout { Padding = new Eto.Drawing.Padding(5), Spacing = new Eto.Drawing.Size(5, 5) @@ -69,10 +69,10 @@ public RebuildCurveDialog(RebuildCurveArgs args) private Eto.Forms.DynamicLayout CreateSteppers() { - var label0 = new Eto.Forms.Label { Text = "Point count:" }; - var label1 = new Eto.Forms.Label { Text = "Degree:" }; - var label2 = new Eto.Forms.Label { Text = $"({m_args.PointCount})" }; - var label3 = new Eto.Forms.Label { Text = $"({m_args.Degree})" }; + Eto.Forms.Label label0 = new Eto.Forms.Label { Text = "Point count:" }; + Eto.Forms.Label label1 = new Eto.Forms.Label { Text = "Degree:" }; + Eto.Forms.Label label2 = new Eto.Forms.Label { Text = $"({m_args.PointCount})" }; + Eto.Forms.Label label3 = new Eto.Forms.Label { Text = $"({m_args.Degree})" }; m_point_count_stepper = new Eto.Forms.NumericStepper { @@ -88,7 +88,7 @@ private Eto.Forms.DynamicLayout CreateSteppers() MaxValue = 11 }; - var layout = new Eto.Forms.DynamicLayout { Spacing = new Eto.Drawing.Size(5, 5) }; + Eto.Forms.DynamicLayout layout = new Eto.Forms.DynamicLayout { Spacing = new Eto.Drawing.Size(5, 5) }; layout.AddRow(label0, label2, m_point_count_stepper); layout.AddRow(label1, label3, m_degree_stepper); return layout; @@ -110,7 +110,7 @@ private Eto.Forms.DynamicLayout CreateCheckBoxes() ThreeState = false }; - var layout = new Eto.Forms.DynamicLayout { Spacing = new Eto.Drawing.Size(5, 5) }; + Eto.Forms.DynamicLayout layout = new Eto.Forms.DynamicLayout { Spacing = new Eto.Drawing.Size(5, 5) }; layout.AddRow(m_delete_input_checkbox); layout.AddRow(m_preserve_tangents_checkbox); return layout; @@ -124,17 +124,17 @@ private Eto.Forms.DynamicLayout CreateButtons() AbortButton = new Eto.Forms.Button { Text = "Cancel" }; AbortButton.Click += AbortButton_Click; - var layout = new Eto.Forms.DynamicLayout { Spacing = new Eto.Drawing.Size(5, 5) }; + Eto.Forms.DynamicLayout layout = new Eto.Forms.DynamicLayout { Spacing = new Eto.Drawing.Size(5, 5) }; layout.AddRow(null, DefaultButton, AbortButton, null); return layout; } private void DefaultButton_Click(object sender, EventArgs e) { - m_args.PointCount = (int) m_point_count_stepper.Value; - m_args.Degree = (int) m_degree_stepper.Value; - m_args.DeleteInput = (bool) m_delete_input_checkbox.Checked; - m_args.PreserveTangents = (bool) m_preserve_tangents_checkbox.Checked; + m_args.PointCount = (int)m_point_count_stepper.Value; + m_args.Degree = (int)m_degree_stepper.Value; + m_args.DeleteInput = (bool)m_delete_input_checkbox.Checked; + m_args.PreserveTangents = (bool)m_preserve_tangents_checkbox.Checked; Close(true); } @@ -156,19 +156,19 @@ public class SampleCsEtoRebuildCurve : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var rc = RhinoGet.GetOneObject("Select curve to rebuild", true, ObjectType.Curve, out var objref); + Result rc = RhinoGet.GetOneObject("Select curve to rebuild", true, ObjectType.Curve, out ObjRef objref); if (rc != Rhino.Commands.Result.Success) return rc; - var curve = objref.Curve(); + Rhino.Geometry.Curve curve = objref.Curve(); if (null == curve) return Result.Failure; - var nurb = curve.ToNurbsCurve(); + Rhino.Geometry.NurbsCurve nurb = curve.ToNurbsCurve(); if (null == nurb) return Result.Failure; - var args = new RebuildCurveArgs + RebuildCurveArgs args = new RebuildCurveArgs { PointCount = nurb.Points.Count, Degree = nurb.Degree, @@ -176,8 +176,8 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) PreserveTangents = PreserveTangents }; - var dlg = new RebuildCurveDialog(args); - var res = dlg.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow); + RebuildCurveDialog dlg = new RebuildCurveDialog(args); + bool res = dlg.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow); if (res) { args = dlg.Results; diff --git a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoSemiModalDialogCommand.cs b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoSemiModalDialogCommand.cs index 6a4a6579..8572cd28 100644 --- a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoSemiModalDialogCommand.cs +++ b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoSemiModalDialogCommand.cs @@ -13,18 +13,18 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var rc = Result.Cancel; + Result rc = Result.Cancel; if (mode == RunMode.Interactive) { - var dialog = new Views.SampleCsEtoSemiModalDialog(); - var dialog_rc = dialog.ShowSemiModal(doc, RhinoEtoApp.MainWindow); + Views.SampleCsEtoSemiModalDialog dialog = new Views.SampleCsEtoSemiModalDialog(); + Eto.Forms.DialogResult dialog_rc = dialog.ShowSemiModal(doc, RhinoEtoApp.MainWindow); if (dialog_rc == Eto.Forms.DialogResult.Ok) rc = Result.Success; } else { - var msg = string.Format("Scriptable version of {0} command not implemented.", EnglishName); + string msg = string.Format("Scriptable version of {0} command not implemented.", EnglishName); RhinoApp.WriteLine(msg); } diff --git a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoViewportCommand.cs b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoViewportCommand.cs index 5997140d..80eae9ab 100644 --- a/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoViewportCommand.cs +++ b/rhinocommon/cs/SampleCsEto/Commands/SampleCsEtoViewportCommand.cs @@ -1,8 +1,8 @@ -using Rhino; +using Eto.Drawing; +using Eto.Forms; +using Rhino; using Rhino.Commands; using Rhino.UI; -using Eto.Forms; -using Eto.Drawing; namespace SampleCsEto.Commands { @@ -12,7 +12,7 @@ public class SampleCsEtoViewportCommand : Rhino.Commands.Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var f = new SampleCsViewportForm(); + SampleCsViewportForm f = new SampleCsViewportForm(); f.ShowModal(RhinoEtoApp.MainWindow); return Result.Success; } @@ -24,7 +24,7 @@ public SampleCsViewportForm() { Title = "Rhino Viewport in an Eto Control"; Resizable = true; - var viewport_control = new[] + Rhino.UI.Controls.ViewportControl[] viewport_control = new[] { new Rhino.UI.Controls.ViewportControl {Size = new Size(400, 200)}, new Rhino.UI.Controls.ViewportControl {Size = new Size(400, 200)} diff --git a/rhinocommon/cs/SampleCsEto/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsEto/Properties/AssemblyInfo.cs index 25963142..25ad9bf6 100755 --- a/rhinocommon/cs/SampleCsEto/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsEto/Properties/AssemblyInfo.cs @@ -1,6 +1,5 @@ -using System.Reflection; +using Rhino.PlugIns; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsEto/SampleCsEtoPlugIn.cs b/rhinocommon/cs/SampleCsEto/SampleCsEtoPlugIn.cs index 2abf5188..0d30aa8d 100644 --- a/rhinocommon/cs/SampleCsEto/SampleCsEtoPlugIn.cs +++ b/rhinocommon/cs/SampleCsEto/SampleCsEtoPlugIn.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.UI; +using System.Collections.Generic; namespace SampleCsEto { @@ -19,19 +19,19 @@ public static SampleCsEtoPlugIn Instance protected override void DocumentPropertiesDialogPages(RhinoDoc doc, List pages) { - var page = new Views.SampleCsEtoOptionsPage(); + Views.SampleCsEtoOptionsPage page = new Views.SampleCsEtoOptionsPage(); pages.Add(page); } protected override void OptionsDialogPages(List pages) { - var page = new Views.SampleCsEtoOptionsPage(); + Views.SampleCsEtoOptionsPage page = new Views.SampleCsEtoOptionsPage(); pages.Add(page); } protected override void ObjectPropertiesPages(ObjectPropertiesPageCollection collection) { - var page = new Views.SampleCsEtoPropertiesPage(); + Views.SampleCsEtoPropertiesPage page = new Views.SampleCsEtoPropertiesPage(); collection.Add(page); } } diff --git a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoModalDialog.cs b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoModalDialog.cs index 7f55c726..54083781 100644 --- a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoModalDialog.cs +++ b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoModalDialog.cs @@ -16,7 +16,7 @@ public SampleCsEtoModalDialog() Title = GetType().Name; WindowStyle = WindowStyle.Default; - var hello_button = new Button { Text = "Hello" }; + Button hello_button = new Button { Text = "Hello" }; hello_button.Click += (sender, e) => OnHelloButton(); DefaultButton = new Button { Text = "OK" }; @@ -25,14 +25,14 @@ public SampleCsEtoModalDialog() AbortButton = new Button { Text = "Cancel" }; AbortButton.Click += (sender, e) => Close(DialogResult.Cancel); - var button_layout = new TableLayout + TableLayout button_layout = new TableLayout { Padding = new Padding(5, 10, 5, 5), Spacing = new Size(5, 5), Rows = { new TableRow(null, hello_button, null) } }; - var defaults_layout = new TableLayout + TableLayout defaults_layout = new TableLayout { Padding = new Padding(5, 10, 5, 5), Spacing = new Size(5, 5), @@ -56,7 +56,7 @@ protected override void OnLoadComplete(EventArgs e) base.OnLoadComplete(e); this.RestorePosition(); } - + protected override void OnClosing(CancelEventArgs e) { this.SavePosition(); diff --git a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoModelessForm.cs b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoModelessForm.cs index 2bcec56b..4ebb01d7 100644 --- a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoModelessForm.cs +++ b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoModelessForm.cs @@ -22,20 +22,20 @@ public SampleCsEtoModelessForm() Title = GetType().Name; WindowStyle = WindowStyle.Default; - var hello_button = new Button { Text = "Hello" }; + Button hello_button = new Button { Text = "Hello" }; hello_button.Click += (sender, e) => OnHelloButton(); - var close_button = new Button { Text = "OK" }; + Button close_button = new Button { Text = "OK" }; close_button.Click += (sender, e) => Close(); - var hello_layout = new TableLayout + TableLayout hello_layout = new TableLayout { Padding = new Padding(5, 10, 5, 5), Spacing = new Size(5, 5), Rows = { new TableRow(null, hello_button, null) } }; - var close_layout = new TableLayout + TableLayout close_layout = new TableLayout { Padding = new Padding(5, 10, 5, 5), Spacing = new Size(5, 5), diff --git a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoOptionsPage.cs b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoOptionsPage.cs index 7acb1570..d6dcfac0 100644 --- a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoOptionsPage.cs +++ b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoOptionsPage.cs @@ -1,7 +1,7 @@ -using System.Diagnostics; -using Eto.Drawing; +using Eto.Drawing; using Eto.Forms; using Rhino.UI; +using System.Diagnostics; namespace SampleCsEto.Views { @@ -45,13 +45,13 @@ class SampleCsEtoOptionsPageControl : Panel { public SampleCsEtoOptionsPageControl() { - var hello_button = new Button { Text = "Hello" }; + Button hello_button = new Button { Text = "Hello" }; hello_button.Click += (sender, e) => OnHelloButton(); - var child_button = new Button { Text = "Child Dialog..." }; + Button child_button = new Button { Text = "Child Dialog..." }; child_button.Click += (sender, e) => OnChildButton(); - var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; + DynamicLayout layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; layout.AddSeparateRow(hello_button, null); layout.AddSeparateRow(child_button, null); layout.Add(null); @@ -93,7 +93,7 @@ protected void OnHelloButton() /// protected void OnChildButton() { - var dialog = new SampleCsEtoHelloWorld(); + SampleCsEtoHelloWorld dialog = new SampleCsEtoHelloWorld(); dialog.ShowModal(this); } } diff --git a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoPanel.cs b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoPanel.cs index 0bdc1f64..7e558e3c 100644 --- a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoPanel.cs +++ b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoPanel.cs @@ -1,5 +1,4 @@ -using System; -using Eto.Drawing; +using Eto.Drawing; using Eto.Forms; using Rhino.UI; @@ -27,15 +26,15 @@ public SampleCsEtoPanel(uint documentSerialNumber) Title = GetType().Name; - var hello_button = new Button { Text = "Hello..." }; + Button hello_button = new Button { Text = "Hello..." }; hello_button.Click += (sender, e) => OnHelloButton(); - var child_button = new Button { Text = "Child Dialog..." }; + Button child_button = new Button { Text = "Child Dialog..." }; child_button.Click += (sender, e) => OnChildButton(); - var document_sn_label = new Label() { Text = $"Document serial number: {documentSerialNumber}" }; + Label document_sn_label = new Label() { Text = $"Document serial number: {documentSerialNumber}" }; - var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; + DynamicLayout layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; layout.AddSeparateRow(hello_button, null); layout.AddSeparateRow(child_button, null); layout.AddSeparateRow(document_sn_label, null); @@ -64,7 +63,7 @@ protected void OnHelloButton() /// protected void OnChildButton() { - var dialog = new SampleCsEtoHelloWorld(); + SampleCsEtoHelloWorld dialog = new SampleCsEtoHelloWorld(); dialog.ShowModal(this); } diff --git a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoPropertiesPage.cs b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoPropertiesPage.cs index 777ba153..46202cc0 100644 --- a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoPropertiesPage.cs +++ b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoPropertiesPage.cs @@ -1,9 +1,7 @@ -using System.Diagnostics; -using System.Reflection; -using Eto.Drawing; +using Eto.Drawing; using Eto.Forms; -using Rhino.DocObjects; using Rhino.UI; +using System.Diagnostics; namespace SampleCsEto.Views { @@ -15,8 +13,8 @@ class SampleCsEtoPropertiesPage : ObjectPropertiesPage public override System.Drawing.Icon PageIcon(System.Drawing.Size sizeInPixels) { - var icon = Rhino.UI.DrawingUtilities.LoadIconWithScaleDown( - "SampleCsEto.Resources.SampleCsEtoPanel.ico", + System.Drawing.Icon icon = Rhino.UI.DrawingUtilities.LoadIconWithScaleDown( + "SampleCsEto.Resources.SampleCsEtoPanel.ico", sizeInPixels.Width, GetType().Assembly); return icon; @@ -40,13 +38,13 @@ class SampleCsEtoPropertiesPageControl : Panel { public SampleCsEtoPropertiesPageControl() { - var hello_button = new Button { Text = "Hello..." }; + Button hello_button = new Button { Text = "Hello..." }; hello_button.Click += (sender, e) => OnHelloButton(); - var child_button = new Button { Text = "Child Dialog..." }; + Button child_button = new Button { Text = "Child Dialog..." }; child_button.Click += (sender, e) => OnChildButton(); - var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; + DynamicLayout layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; layout.AddSeparateRow(hello_button, null); layout.AddSeparateRow(child_button, null); layout.Add(null); @@ -71,7 +69,7 @@ protected void OnHelloButton() /// protected void OnChildButton() { - var dialog = new SampleCsEtoHelloWorld(); + SampleCsEtoHelloWorld dialog = new SampleCsEtoHelloWorld(); dialog.ShowModal(this); } } diff --git a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoSemiModalDialog.cs b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoSemiModalDialog.cs index 136a03a8..f438047e 100644 --- a/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoSemiModalDialog.cs +++ b/rhinocommon/cs/SampleCsEto/Views/SampleCsEtoSemiModalDialog.cs @@ -18,7 +18,7 @@ public SampleCsEtoSemiModalDialog() Title = GetType().Name; WindowStyle = WindowStyle.Default; - var hello_button = new Button { Text = "Pick" }; + Button hello_button = new Button { Text = "Pick" }; hello_button.Click += (sender, e) => this.PushPickButton((s, e2) => PickFunction()); DefaultButton = new Button { Text = "OK" }; @@ -27,14 +27,14 @@ public SampleCsEtoSemiModalDialog() AbortButton = new Button { Text = "Cancel" }; AbortButton.Click += (sender, e) => Close(DialogResult.Cancel); - var button_layout = new TableLayout + TableLayout button_layout = new TableLayout { Padding = new Padding(5, 10, 5, 5), Spacing = new Size(5, 5), Rows = { new TableRow(null, hello_button, null) } }; - var defaults_layout = new TableLayout + TableLayout defaults_layout = new TableLayout { Padding = new Padding(5, 10, 5, 5), Spacing = new Size(5, 5), diff --git a/rhinocommon/cs/SampleCsEventWatcher/SampleCsEventHandlers.cs b/rhinocommon/cs/SampleCsEventWatcher/SampleCsEventHandlers.cs index 0d797b91..b9b81efa 100644 --- a/rhinocommon/cs/SampleCsEventWatcher/SampleCsEventHandlers.cs +++ b/rhinocommon/cs/SampleCsEventWatcher/SampleCsEventHandlers.cs @@ -1,8 +1,8 @@ -using System; -using System.Diagnostics; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Display; +using System; +using System.Diagnostics; namespace SampleCsEventWatcher { @@ -517,7 +517,7 @@ private static void DebugWriteMethod() { try { - var method_name = new StackTrace().GetFrame(1).GetMethod().Name; + string method_name = new StackTrace().GetFrame(1).GetMethod().Name; RhinoApp.WriteLine("> {0}", method_name); } catch diff --git a/rhinocommon/cs/SampleCsEventWatcher/SampleCsEventWatcherCommand.cs b/rhinocommon/cs/SampleCsEventWatcher/SampleCsEventWatcherCommand.cs index 9c164a93..d1522ac9 100644 --- a/rhinocommon/cs/SampleCsEventWatcher/SampleCsEventWatcherCommand.cs +++ b/rhinocommon/cs/SampleCsEventWatcher/SampleCsEventWatcherCommand.cs @@ -42,24 +42,24 @@ public override string EnglishName /// protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var enabled = SampleCsEventHandlers.Instance.IsEnabled; - var prompt = enabled ? "Event watcher is enabled. New value" : "Event watcher is disabled. New value"; + bool enabled = SampleCsEventHandlers.Instance.IsEnabled; + string prompt = enabled ? "Event watcher is enabled. New value" : "Event watcher is disabled. New value"; - var go = new GetOption(); + GetOption go = new GetOption(); go.SetCommandPrompt(prompt); go.AcceptNothing(true); - var d_option = go.AddOption("Disable"); - var e_option = go.AddOption("Enable"); - var t_option = go.AddOption("Toggle"); + int d_option = go.AddOption("Disable"); + int e_option = go.AddOption("Enable"); + int t_option = go.AddOption("Toggle"); - var res = go.Get(); + GetResult res = go.Get(); if (res == GetResult.Nothing) return Result.Success; if (res != GetResult.Option) return Result.Cancel; - var option = go.Option(); + CommandLineOption option = go.Option(); if (null == option) return Result.Failure; diff --git a/rhinocommon/cs/SampleCsMobilePlane/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsMobilePlane/Properties/AssemblyInfo.cs index 0df3b351..5c212e25 100644 --- a/rhinocommon/cs/SampleCsMobilePlane/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsMobilePlane/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsMobilePlane/SampleCsMobilePlaneCommand.cs b/rhinocommon/cs/SampleCsMobilePlane/SampleCsMobilePlaneCommand.cs index 1ab810a2..d8b60a2e 100644 --- a/rhinocommon/cs/SampleCsMobilePlane/SampleCsMobilePlaneCommand.cs +++ b/rhinocommon/cs/SampleCsMobilePlane/SampleCsMobilePlaneCommand.cs @@ -23,39 +23,39 @@ public override string EnglishName /// protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select object"); go.SubObjectSelect = false; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var obj_ref = go.Object(0); - var obj = obj_ref.Object(); + ObjRef obj_ref = go.Object(0); + RhinoObject obj = obj_ref.Object(); if (null == obj) return Result.Failure; - var pre_selected = go.ObjectsWerePreselected; + bool pre_selected = go.ObjectsWerePreselected; obj.Select(true); - var gt = new GetOption(); + GetOption gt = new GetOption(); gt.SetCommandPrompt("Choose mobile plane option"); gt.AcceptNothing(true); - var attach_index = gt.AddOption("Attach"); - var detach_index = gt.AddOption("Detach"); - var enable_index = gt.AddOption("Enable"); - var refresh_index = gt.AddOption("Refresh"); - var show_index = gt.AddOption("Show"); + int attach_index = gt.AddOption("Attach"); + int detach_index = gt.AddOption("Detach"); + int enable_index = gt.AddOption("Enable"); + int refresh_index = gt.AddOption("Refresh"); + int show_index = gt.AddOption("Show"); - for (;;) + for (; ; ) { - var res = gt.Get(); + GetResult res = gt.Get(); if (res != GetResult.Option) break; - var rc = Result.Cancel; - var index = gt.OptionIndex(); + Result rc = Result.Cancel; + int index = gt.OptionIndex(); if (index == attach_index) rc = AttachOption(doc, obj); @@ -88,14 +88,14 @@ private Result AttachOption(RhinoDoc doc, RhinoObject obj) if (null == doc || null == obj) return Result.Failure; - var viewport_id = doc.Views.ActiveView.ActiveViewportID; - + System.Guid viewport_id = doc.Views.ActiveView.ActiveViewportID; + Plane plane; - var res = RhinoGet.GetPlane(out plane); + Result res = RhinoGet.GetPlane(out plane); if (res != Result.Success) return res; - var rc = SampleCsMobilePlaneUserData.Attach(obj, plane, viewport_id); + bool rc = SampleCsMobilePlaneUserData.Attach(obj, plane, viewport_id); return rc ? Result.Success : Result.Failure; } @@ -113,7 +113,7 @@ private Result DetachOption(RhinoDoc doc, RhinoObject obj) return Result.Success; } - var rc = SampleCsMobilePlaneUserData.Detach(obj); + bool rc = SampleCsMobilePlaneUserData.Detach(obj); return rc ? Result.Success : Result.Failure; } @@ -131,12 +131,12 @@ private Result EnableOption(RhinoDoc doc, RhinoObject obj) return Result.Success; } - var enable = SampleCsMobilePlaneUserData.IsEnabled(obj); - var res = RhinoGet.GetBool("Enable object mobile plane", true, "Disable", "Enable", ref enable); + bool enable = SampleCsMobilePlaneUserData.IsEnabled(obj); + Result res = RhinoGet.GetBool("Enable object mobile plane", true, "Disable", "Enable", ref enable); if (res != Result.Success) return res; - var rc = SampleCsMobilePlaneUserData.Enable(obj, enable); + bool rc = SampleCsMobilePlaneUserData.Enable(obj, enable); return rc ? Result.Success : Result.Failure; } @@ -154,7 +154,7 @@ private Result RefreshOption(RhinoDoc doc, RhinoObject obj) return Result.Success; } - var rc = SampleCsMobilePlaneUserData.Refresh(obj, true); + bool rc = SampleCsMobilePlaneUserData.Refresh(obj, true); return rc ? Result.Success : Result.Failure; } @@ -166,17 +166,17 @@ private Result ShowOption(RhinoDoc doc, RhinoObject obj) if (null == doc || null == obj) return Result.Failure; - var data = SampleCsMobilePlaneUserData.DataFromObject(obj); + SampleCsMobilePlaneUserData data = SampleCsMobilePlaneUserData.DataFromObject(obj); if (null == data) { RhinoApp.WriteLine("No mobile plane attached."); return Result.Success; } - var conduit = new SampleCsMobilePlaneConduit(data.Plane); + SampleCsMobilePlaneConduit conduit = new SampleCsMobilePlaneConduit(data.Plane); doc.Views.Redraw(); - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Press when done."); gs.Get(); diff --git a/rhinocommon/cs/SampleCsMobilePlane/SampleCsMobilePlaneUserData.cs b/rhinocommon/cs/SampleCsMobilePlane/SampleCsMobilePlaneUserData.cs index ea6c681d..97b07247 100644 --- a/rhinocommon/cs/SampleCsMobilePlane/SampleCsMobilePlaneUserData.cs +++ b/rhinocommon/cs/SampleCsMobilePlane/SampleCsMobilePlaneUserData.cs @@ -1,8 +1,8 @@ -using System; -using Rhino.DocObjects; +using Rhino.DocObjects; using Rhino.DocObjects.Custom; using Rhino.FileIO; using Rhino.Geometry; +using System; namespace SampleCsMobilePlane { @@ -50,7 +50,7 @@ protected override void OnDuplicate(UserData source) /// protected override bool Read(BinaryArchiveReader archive) { - archive.Read3dmChunkVersion(out var major, out var minor); + archive.Read3dmChunkVersion(out int major, out int minor); if (1 == major && 0 == minor) { Plane = archive.ReadPlane(); @@ -79,7 +79,7 @@ protected override void OnTransform(Transform xform) { base.OnTransform(xform); - var p = Plane; + Plane p = Plane; p.Transform(xform); Plane = p; @@ -96,10 +96,10 @@ protected override void OnTransform(Transform xform) /// public void UpdateConstructionPlane() { - var doc = Rhino.RhinoDoc.ActiveDoc; + Rhino.RhinoDoc doc = Rhino.RhinoDoc.ActiveDoc; if (null != doc) { - var view = doc.Views.Find(ViewportId); + Rhino.Display.RhinoView view = doc.Views.Find(ViewportId); if (null != view) { view.ActiveViewport.SetConstructionPlane(Plane); @@ -117,10 +117,10 @@ public void UpdateConstructionPlane() /// public static bool IsAttached(RhinoObject obj) { - var rc = false; + bool rc = false; if (null != obj) { - var data = DataFromObject(obj); + SampleCsMobilePlaneUserData data = DataFromObject(obj); rc = null != data; } return rc; @@ -131,10 +131,10 @@ public static bool IsAttached(RhinoObject obj) /// public static bool Attach(RhinoObject obj, Plane plane, Guid viewportId) { - var rc = false; + bool rc = false; if (null != obj) { - var data = DataFromObject(obj); + SampleCsMobilePlaneUserData data = DataFromObject(obj); if (null != data) { data.Plane = plane; @@ -160,10 +160,10 @@ public static bool Attach(RhinoObject obj, Plane plane, Guid viewportId) /// public static bool Detach(RhinoObject obj) { - var rc = false; + bool rc = false; if (null != obj) { - var data = DataFromObject(obj); + SampleCsMobilePlaneUserData data = DataFromObject(obj); if (null != data) rc = obj.Geometry.UserData.Remove(data); } @@ -175,10 +175,10 @@ public static bool Detach(RhinoObject obj) /// public static bool IsEnabled(RhinoObject obj) { - var rc = false; + bool rc = false; if (null != obj) { - var data = DataFromObject(obj); + SampleCsMobilePlaneUserData data = DataFromObject(obj); if (null != data) rc = data.Enabled; } @@ -190,10 +190,10 @@ public static bool IsEnabled(RhinoObject obj) /// public static bool Enable(RhinoObject obj, bool bEnable) { - var rc = false; + bool rc = false; if (null != obj) { - var data = DataFromObject(obj); + SampleCsMobilePlaneUserData data = DataFromObject(obj); if (null != data) { data.Enabled = bEnable; @@ -208,10 +208,10 @@ public static bool Enable(RhinoObject obj, bool bEnable) /// public static bool Refresh(RhinoObject obj, bool bIgnoreEnabled) { - var rc = false; + bool rc = false; if (null != obj) { - var data = DataFromObject(obj); + SampleCsMobilePlaneUserData data = DataFromObject(obj); if (null != data) { if (bIgnoreEnabled || data.Enabled) diff --git a/rhinocommon/cs/SampleCsMouseCallback/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsMouseCallback/Properties/AssemblyInfo.cs index e4df3ac2..80033c94 100644 --- a/rhinocommon/cs/SampleCsMouseCallback/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsMouseCallback/Properties/AssemblyInfo.cs @@ -1,7 +1,6 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional. // These will show in Rhino's option dialog, in the tab Plug-ins. diff --git a/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackCommand.cs b/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackCommand.cs index 6c364fb8..477aaf61 100644 --- a/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackCommand.cs +++ b/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackCommand.cs @@ -1,39 +1,34 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; -using Rhino.Geometry; -using Rhino.Input; -using Rhino.Input.Custom; namespace SampleCsMouseCallback { - public class SampleCsMouseCallbackCommand : Command - { - readonly SampleMouseCallback smcb = new SampleMouseCallback(); - public SampleCsMouseCallbackCommand() - { - // Rhino only creates one instance of each command class defined in a - // plug-in, so it is safe to store a refence in a static property. - Instance = this; - } + public class SampleCsMouseCallbackCommand : Command + { + readonly SampleMouseCallback smcb = new SampleMouseCallback(); + public SampleCsMouseCallbackCommand() + { + // Rhino only creates one instance of each command class defined in a + // plug-in, so it is safe to store a refence in a static property. + Instance = this; + } - ///The only instance of this command. - public static SampleCsMouseCallbackCommand Instance - { - get; private set; - } + ///The only instance of this command. + public static SampleCsMouseCallbackCommand Instance + { + get; private set; + } - ///The command name as it appears on the Rhino command line. - public override string EnglishName - { - get { return "SampleCsMouseCallbackCommand"; } - } + ///The command name as it appears on the Rhino command line. + public override string EnglishName + { + get { return "SampleCsMouseCallbackCommand"; } + } - protected override Result RunCommand(RhinoDoc doc, RunMode mode) - { - smcb.Enabled = !smcb.Enabled; - return Result.Success; - } - } + protected override Result RunCommand(RhinoDoc doc, RunMode mode) + { + smcb.Enabled = !smcb.Enabled; + return Result.Success; + } + } } diff --git a/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackPlugIn.cs b/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackPlugIn.cs index e6dcc2fb..76ac3461 100644 --- a/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackPlugIn.cs +++ b/rhinocommon/cs/SampleCsMouseCallback/SampleCsMouseCallbackPlugIn.cs @@ -1,29 +1,29 @@ namespace SampleCsMouseCallback { - /// - /// Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived - /// class. DO NOT create instances of this class yourself. It is the - /// responsibility of Rhino to create an instance of this class. - /// To complete plug-in information, please also see all PlugInDescription - /// attributes in AssemblyInfo.cs (you might need to click "Project" -> - /// "Show All Files" to see it in the "Solution Explorer" window). - /// - public class SampleCsMouseCallbackPlugIn : Rhino.PlugIns.PlugIn + /// + /// Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived + /// class. DO NOT create instances of this class yourself. It is the + /// responsibility of Rhino to create an instance of this class. + /// To complete plug-in information, please also see all PlugInDescription + /// attributes in AssemblyInfo.cs (you might need to click "Project" -> + /// "Show All Files" to see it in the "Solution Explorer" window). + /// + public class SampleCsMouseCallbackPlugIn : Rhino.PlugIns.PlugIn - { - public SampleCsMouseCallbackPlugIn() - { - Instance = this; - } + { + public SampleCsMouseCallbackPlugIn() + { + Instance = this; + } - ///Gets the only instance of the SampleCsMouseCallbackPlugIn plug-in. - public static SampleCsMouseCallbackPlugIn Instance - { - get; private set; - } + ///Gets the only instance of the SampleCsMouseCallbackPlugIn plug-in. + public static SampleCsMouseCallbackPlugIn Instance + { + get; private set; + } - // You can override methods here to change the plug-in behavior on - // loading and shut down, add options pages to the Rhino _Option command - // and maintain plug-in wide options in a document. - } + // You can override methods here to change the plug-in behavior on + // loading and shut down, add options pages to the Rhino _Option command + // and maintain plug-in wide options in a document. + } } \ No newline at end of file diff --git a/rhinocommon/cs/SampleCsMouseCallback/SampleMouseCallback.cs b/rhinocommon/cs/SampleCsMouseCallback/SampleMouseCallback.cs index 8af4d15a..e46149af 100644 --- a/rhinocommon/cs/SampleCsMouseCallback/SampleMouseCallback.cs +++ b/rhinocommon/cs/SampleCsMouseCallback/SampleMouseCallback.cs @@ -3,29 +3,29 @@ namespace SampleCsMouseCallback { - public class SampleMouseCallback : MouseCallback - { - protected override void OnMouseEnter(MouseCallbackEventArgs e) - { - RhinoApp.WriteLine($"Entering view {e.View?.ActiveViewport?.Name}"); - } + public class SampleMouseCallback : MouseCallback + { + protected override void OnMouseEnter(MouseCallbackEventArgs e) + { + RhinoApp.WriteLine($"Entering view {e.View?.ActiveViewport?.Name}"); + } - protected override void OnMouseHover(MouseCallbackEventArgs e) - { - RhinoApp.WriteLine($"Hovering on view {e.View?.ActiveViewport?.Name}"); - base.OnMouseHover(e); - } + protected override void OnMouseHover(MouseCallbackEventArgs e) + { + RhinoApp.WriteLine($"Hovering on view {e.View?.ActiveViewport?.Name}"); + base.OnMouseHover(e); + } - protected override void OnMouseLeave(MouseCallbackEventArgs e) - { - RhinoApp.WriteLine($"Leaving view {e.View?.ActiveViewport?.Name}"); - base.OnMouseLeave(e); - } + protected override void OnMouseLeave(MouseCallbackEventArgs e) + { + RhinoApp.WriteLine($"Leaving view {e.View?.ActiveViewport?.Name}"); + base.OnMouseLeave(e); + } - protected override void OnMouseMove(MouseCallbackEventArgs e) - { - RhinoApp.WriteLine($"Moving over view {e.View?.ActiveViewport?.Name}"); - base.OnMouseMove(e); - } - } + protected override void OnMouseMove(MouseCallbackEventArgs e) + { + RhinoApp.WriteLine($"Moving over view {e.View?.ActiveViewport?.Name}"); + base.OnMouseMove(e); + } + } } diff --git a/rhinocommon/cs/SampleCsRdk/BufferedTreeView.cs b/rhinocommon/cs/SampleCsRdk/BufferedTreeView.cs index 51fed44c..d22c46f0 100644 --- a/rhinocommon/cs/SampleCsRdk/BufferedTreeView.cs +++ b/rhinocommon/cs/SampleCsRdk/BufferedTreeView.cs @@ -1,23 +1,23 @@ using System; -using System.Windows.Forms; using System.Runtime.InteropServices; +using System.Windows.Forms; namespace SampleCsRdk { - public class BufferedTreeView : TreeView + public class BufferedTreeView : TreeView + { + protected override void OnHandleCreated(EventArgs e) { - protected override void OnHandleCreated(EventArgs e) - { - SendMessage(this.Handle, TVM_SETEXTENDEDSTYLE, (IntPtr)TVS_EX_DOUBLEBUFFER, (IntPtr)TVS_EX_DOUBLEBUFFER); - base.OnHandleCreated(e); - } - - // Pinvoke: - private const int TVM_SETEXTENDEDSTYLE = 0x1100 + 44; - private const int TVM_GETEXTENDEDSTYLE = 0x1100 + 45; - private const int TVS_EX_DOUBLEBUFFER = 0x0004; - [DllImport("user32.dll")] - private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); + SendMessage(this.Handle, TVM_SETEXTENDEDSTYLE, (IntPtr)TVS_EX_DOUBLEBUFFER, (IntPtr)TVS_EX_DOUBLEBUFFER); + base.OnHandleCreated(e); } + + // Pinvoke: + private const int TVM_SETEXTENDEDSTYLE = 0x1100 + 44; + private const int TVM_GETEXTENDEDSTYLE = 0x1100 + 45; + private const int TVS_EX_DOUBLEBUFFER = 0x0004; + [DllImport("user32.dll")] + private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); + } } diff --git a/rhinocommon/cs/SampleCsRdk/CustomContentIo.cs b/rhinocommon/cs/SampleCsRdk/CustomContentIo.cs index 847308d7..b16acdda 100644 --- a/rhinocommon/cs/SampleCsRdk/CustomContentIo.cs +++ b/rhinocommon/cs/SampleCsRdk/CustomContentIo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Rhino.Render; -/* +/* namespace rdktest_cs { [CustomRenderContentIo("myext", RenderContentKind.Material, true, false)] diff --git a/rhinocommon/cs/SampleCsRdk/CustomEnvironment.cs b/rhinocommon/cs/SampleCsRdk/CustomEnvironment.cs index 4df6c01c..f7d00685 100644 --- a/rhinocommon/cs/SampleCsRdk/CustomEnvironment.cs +++ b/rhinocommon/cs/SampleCsRdk/CustomEnvironment.cs @@ -1,35 +1,33 @@ -using System; -using System.Collections.Generic; using Rhino.Render; namespace SampleCsRdk { [System.Runtime.InteropServices.Guid("5F97DC31-9750-491E-9FE3-060B8BFD1FA6")] public class CustomEnvironment : RenderEnvironment - { - public override string TypeName { get { return "C# Custom Environment"; } } - public override string TypeDescription { get { return "My first custom .NET environment"; } } - - public CustomEnvironment() - { - Fields.Add("background", Rhino.Display.Color4f.Black, "Background"); - } + { + public override string TypeName { get { return "C# Custom Environment"; } } + public override string TypeDescription { get { return "My first custom .NET environment"; } } - protected override void OnAddUserInterfaceSections() - { - AddAutomaticUserInterfaceSection("Parameters", 0); - } + public CustomEnvironment() + { + Fields.Add("background", Rhino.Display.Color4f.Black, "Background"); + } - public override void SimulateEnvironment(ref SimulatedEnvironment sim, bool forDataOnly) - { - //if( TryGetAutomticUiField("background", out background) ) - Rhino.Display.Color4f color; - if (Fields.TryGetValue("background", out color) ) - sim.BackgroundColor = color.AsSystemColor(); + protected override void OnAddUserInterfaceSections() + { + AddAutomaticUserInterfaceSection("Parameters", 0); + } - base.SimulateEnvironment(ref sim, forDataOnly); - } + public override void SimulateEnvironment(ref SimulatedEnvironment sim, bool forDataOnly) + { + //if( TryGetAutomticUiField("background", out background) ) + Rhino.Display.Color4f color; + if (Fields.TryGetValue("background", out color)) + sim.BackgroundColor = color.AsSystemColor(); - //ColorField m_color = new ColorField("background", "Background", Rhino.Display.Color4f.Black); + base.SimulateEnvironment(ref sim, forDataOnly); } + + //ColorField m_color = new ColorField("background", "Background", Rhino.Display.Color4f.Black); + } } diff --git a/rhinocommon/cs/SampleCsRdk/CustomEtoUiSectionMaterial.cs b/rhinocommon/cs/SampleCsRdk/CustomEtoUiSectionMaterial.cs index a36c8cf7..c74519f1 100644 --- a/rhinocommon/cs/SampleCsRdk/CustomEtoUiSectionMaterial.cs +++ b/rhinocommon/cs/SampleCsRdk/CustomEtoUiSectionMaterial.cs @@ -1,16 +1,16 @@ -using System.ComponentModel; -using System.Globalization; -using System.Runtime.InteropServices; -using System; -using System.Collections.Generic; -using Eto.Drawing; +using Eto.Drawing; using Eto.Forms; using Rhino; using Rhino.Display; using Rhino.Render; +using Rhino.UI; using Rhino.UI.Controls; using RhinoWindows.ViewModels; -using Rhino.UI; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Runtime.InteropServices; namespace SampleCsRdk { @@ -31,14 +31,14 @@ public string ColorAsString { try { - var floats = value; + string floats = value; floats = floats.Trim(); floats = floats.Replace(" ", " "); floats = floats.Replace(",", "."); - var fs = floats.Split(' '); - var realfloats = new float[fs.Length]; - for (var i = 0; i < fs.Length; i++) + string[] fs = floats.Split(' '); + float[] realfloats = new float[fs.Length]; + for (int i = 0; i < fs.Length; i++) { realfloats[i] = float.Parse(fs[i], NumberFormatInfo); } @@ -76,7 +76,7 @@ public CustomEtoCyclesUISection() } }; - var cob = new ColorObject { ColorAsString = "1.0 2.0 3.0" }; + ColorObject cob = new ColorObject { ColorAsString = "1.0 2.0 3.0" }; cob.PropertyChanged += CustomEtoCyclesUISection_PropertyChanged; DataContext = cob; } @@ -85,14 +85,14 @@ void CustomEtoCyclesUISection_PropertyChanged(object sender, PropertyChangedEven { if (DataContext is ColorObject cob) { - var c = cob.Color; + Color4f c = cob.Color; RhinoApp.WriteLine(String.Format("Custom Eto Section property changed: {0} {1},{2},{3}", e.PropertyName, c.R, c.G, c.B)); } } private TextBox DataContextBinding() { - var label = new TextBox + TextBox label = new TextBox { Enabled = true }; @@ -109,7 +109,7 @@ private TextBox DataContextBinding() [Guid("2FEE12AE-1D16-4338-9D28-0BBD6EFE763D")] public class CustomEtoUiSectionMaterial : RenderMaterial { - public override string TypeName { get { return "Test Eto Section Material"; } } + public override string TypeName { get { return "Test Eto Section Material"; } } public override string TypeDescription { get { return "Test Eto Section Material"; } } public CustomEtoUiSectionMaterial() @@ -123,7 +123,7 @@ protected override void OnAddUserInterfaceSections() { AddAutomaticUserInterfaceSection("Parameters", 0); - var s1 = new CustomEtoCyclesUISection(); + CustomEtoCyclesUISection s1 = new CustomEtoCyclesUISection(); //This line and the list will be unnecessary after Rhino 6.9 m_sections_to_keep_alive.Add(s1); diff --git a/rhinocommon/cs/SampleCsRdk/CustomMaterial.cs b/rhinocommon/cs/SampleCsRdk/CustomMaterial.cs index 7da81c43..5ca2596e 100644 --- a/rhinocommon/cs/SampleCsRdk/CustomMaterial.cs +++ b/rhinocommon/cs/SampleCsRdk/CustomMaterial.cs @@ -1,9 +1,9 @@ -using System.Drawing; -using System.Drawing.Imaging; using Rhino.Render; using Rhino.Render.Fields; using Rhino.UI.Controls; using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; namespace SampleCsRdk { @@ -23,7 +23,7 @@ public CustomMaterial() //Non visible fields to store texture on-ness and amount Field field = Fields.Add("color-texture-on", true); BindParameterToField("color", "texture-on", field, ChangeContexts.UI); - + field = Fields.Add("color-texture-amount", 100.0); BindParameterToField("color", "texture-amount", field, ChangeContexts.UI); } @@ -38,14 +38,14 @@ public override void SimulateMaterial(ref Rhino.DocObjects.Material simulatedMat base.SimulateMaterial(ref simulatedMaterial, forDataOnly); Rhino.Display.Color4f color; - if( Fields.TryGetValue("color", out color) ) + if (Fields.TryGetValue("color", out color)) simulatedMaterial.DiffuseColor = color.AsSystemColor(); } public override bool Icon(System.Drawing.Size size, out System.Drawing.Bitmap bitmap) { bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format24bppRgb); - using (var g = Graphics.FromImage(bitmap)) + using (Graphics g = Graphics.FromImage(bitmap)) g.Clear(Color.Red); return true; } @@ -86,9 +86,9 @@ public CustomMaterialWithUserControl() protected override void OnAddUserInterfaceSections() { - var s1 = new CustomMaterialWpfUserInterfaceSectionHost(); - var s2 = new CustomMaterialUserInterfaceSection(); - var s3 = new CustomMaterialUserInterfaceSection2(); + CustomMaterialWpfUserInterfaceSectionHost s1 = new CustomMaterialWpfUserInterfaceSectionHost(); + CustomMaterialUserInterfaceSection s2 = new CustomMaterialUserInterfaceSection(); + CustomMaterialUserInterfaceSection2 s3 = new CustomMaterialUserInterfaceSection2(); //These next three lines will be unnecessary from Rhino 6.9 onwards. m_sections_to_keep_alive.Add(s1); diff --git a/rhinocommon/cs/SampleCsRdk/CustomMaterialUserInterfaceSection.cs b/rhinocommon/cs/SampleCsRdk/CustomMaterialUserInterfaceSection.cs index dca440ca..e38bacc1 100644 --- a/rhinocommon/cs/SampleCsRdk/CustomMaterialUserInterfaceSection.cs +++ b/rhinocommon/cs/SampleCsRdk/CustomMaterialUserInterfaceSection.cs @@ -1,15 +1,9 @@ -using System; -using System.Windows.Forms; -using System.Drawing; -using Rhino.Display; -using Rhino.Render; -using Rhino.Render.UI; -using System.Collections.Generic; +using Rhino.Display; using Rhino.UI; -using Rhino.UI.Controls; -using Rhino.UI.Controls.DataSource; -using System.Diagnostics; using RhinoWindows.Forms; +using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms; namespace SampleCsRdk { @@ -88,7 +82,7 @@ public void UserInterfaceDisplayData(object sender, Rhino.UI.Controls.DataSource subNodeControl.ParentInstanceList = m_view_model.SelectedMaterialIdList; int? tbPos = m_view_model.TrackBarPositionVaries; - if(tbPos!=null) + if (tbPos != null) { trackPositionLabel.Text = $"{tbPos.Value}"; } diff --git a/rhinocommon/cs/SampleCsRdk/CustomMaterialUserInterfaceSection2.cs b/rhinocommon/cs/SampleCsRdk/CustomMaterialUserInterfaceSection2.cs index 341ba090..caf42f72 100644 --- a/rhinocommon/cs/SampleCsRdk/CustomMaterialUserInterfaceSection2.cs +++ b/rhinocommon/cs/SampleCsRdk/CustomMaterialUserInterfaceSection2.cs @@ -1,7 +1,4 @@ -using System.Windows.Forms; -using Rhino.Render; -using Rhino.Render.UI; -using Rhino.UI; +using Rhino.UI; namespace SampleCsRdk { @@ -15,7 +12,7 @@ public CustomMaterialUserInterfaceSection2() m_view_model = new CustomMaterialViewModel(this); } - + public override bool Hidden { diff --git a/rhinocommon/cs/SampleCsRdk/CustomMaterialViewModel.cs b/rhinocommon/cs/SampleCsRdk/CustomMaterialViewModel.cs index 70f22ebd..d9e7de01 100644 --- a/rhinocommon/cs/SampleCsRdk/CustomMaterialViewModel.cs +++ b/rhinocommon/cs/SampleCsRdk/CustomMaterialViewModel.cs @@ -1,18 +1,12 @@ -using System; -using System.Drawing; -using System.Collections.Generic; -using System.Diagnostics; - -using Rhino.Render.UI; +using Rhino.Display; using Rhino.Render; -using RhinoWindows.ViewModels; - -using Rhino.UI.Controls; - -using Rhino.Display; using Rhino.UI; -using System.ComponentModel; -using System.Runtime.CompilerServices; +using Rhino.UI.Controls; +using RhinoWindows.ViewModels; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; namespace SampleCsRdk { @@ -56,7 +50,7 @@ public Color Color { get { - var vc = VariesColor; + Color4f? vc = VariesColor; if (null != vc) { return vc.Value.AsSystemColor(); @@ -82,7 +76,7 @@ public Color4f? VariesColor if (sel == null) return null; - foreach (var item in sel) + foreach (object item in sel) { if (item is RenderMaterial material) { @@ -114,9 +108,9 @@ public Color4f? VariesColor if (sel == null) return; - var undo = Rhino.RhinoDoc.ActiveDoc.BeginUndoRecord("Set material Color value"); + uint undo = Rhino.RhinoDoc.ActiveDoc.BeginUndoRecord("Set material Color value"); - foreach (var item in sel) + foreach (object item in sel) { if (item is RenderMaterial material) { @@ -145,7 +139,7 @@ public bool ShowSection2 { get { - var vc = VariesShowSection2; + bool? vc = VariesShowSection2; if (null != vc) { return vc.Value; @@ -162,8 +156,9 @@ public int TrackBarPosition { get { - var vc = TrackBarPositionVaries; - if (null != vc) { + int? vc = TrackBarPositionVaries; + if (null != vc) + { return vc.Value; } return int.MinValue; @@ -176,7 +171,8 @@ public int TrackBarPosition public int? TrackBarPositionVaries { - get { + get + { bool bVaries = false; int? i = null; @@ -184,7 +180,7 @@ public int? TrackBarPositionVaries if (sel == null) return null; - foreach (var item in sel) + foreach (object item in sel) { if (item is RenderMaterial material) @@ -210,14 +206,15 @@ public int? TrackBarPositionVaries return bVaries ? null : i; } - set { + set + { RenderContentCollection sel = Selection; if (sel == null) return; - var undo = Rhino.RhinoDoc.ActiveDoc.BeginUndoRecord("Set material TrackBarPosition value"); + uint undo = Rhino.RhinoDoc.ActiveDoc.BeginUndoRecord("Set material TrackBarPosition value"); - foreach (var item in sel) + foreach (object item in sel) { if (item is RenderMaterial material) { @@ -254,7 +251,7 @@ public bool? VariesShowSection2 if (sel == null) return null; - foreach (var item in sel) + foreach (object item in sel) { if (item is RenderMaterial material) @@ -287,9 +284,9 @@ public bool? VariesShowSection2 if (sel == null) return; - var undo = Rhino.RhinoDoc.ActiveDoc.BeginUndoRecord("Set material ShowSectionKey value"); + uint undo = Rhino.RhinoDoc.ActiveDoc.BeginUndoRecord("Set material ShowSectionKey value"); - foreach (var item in sel) + foreach (object item in sel) { if (item is RenderMaterial material) { @@ -318,12 +315,12 @@ public Guid[] SelectedMaterialIdList { get { - var list = new List(); + List list = new List(); RenderContentCollection sel = Selection; if (sel != null) { - foreach (var item in sel) + foreach (object item in sel) { if (item is RenderMaterial material) { @@ -384,7 +381,7 @@ public class CustomMaterialWpfUserInterfaceSectionHost : RenderContentWpfCollaps public CustomMaterialWpfUserInterfaceSectionHost() : base(new CustomMaterialWpfUserInterfaceSection(), null) { - var vm = WpfViewModel as CustomMaterialViewModel; + CustomMaterialViewModel vm = WpfViewModel as CustomMaterialViewModel; vm.Section = this; DataChanged += UserInterfaceDisplayData; @@ -392,7 +389,7 @@ public CustomMaterialWpfUserInterfaceSectionHost() public void UserInterfaceDisplayData(object sender, Rhino.UI.Controls.DataSource.EventArgs e) { - var vm = WpfViewModel as CustomMaterialViewModel; + CustomMaterialViewModel vm = WpfViewModel as CustomMaterialViewModel; vm.RaisePropertyChanged(e); } diff --git a/rhinocommon/cs/SampleCsRdk/CustomTexture.cs b/rhinocommon/cs/SampleCsRdk/CustomTexture.cs index 09c12282..a61bff5f 100644 --- a/rhinocommon/cs/SampleCsRdk/CustomTexture.cs +++ b/rhinocommon/cs/SampleCsRdk/CustomTexture.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using Rhino.Render; namespace SampleCsRdk @@ -33,68 +31,68 @@ public CustomTexture() public override TextureEvaluator CreateEvaluator(TextureEvaluatorFlags evaluatorFlags) { - return new CustomTextureEvaluator(this, evaluatorFlags); + return new CustomTextureEvaluator(this, evaluatorFlags); } //Used for testing only //public override void SimulateTexture(SimulatedTexture sim, bool bForDataOnly) //{ // sim.Filename = "C:\\Users\\Omistaja\\Desktop\\_Images\\AtoZ.bmp"; - //base.SimulateTexture(sim, bForDataOnly); + //base.SimulateTexture(sim, bForDataOnly); //} - protected override void AddAdditionalUISections() - { - AddAutomaticUserInterfaceSection("Parameters", 0); - //AddAutomaticUISection("Parameters", 0); - } + protected override void AddAdditionalUISections() + { + AddAutomaticUserInterfaceSection("Parameters", 0); + //AddAutomaticUISection("Parameters", 0); + } } class CustomTextureEvaluator : TextureEvaluator { - public CustomTextureEvaluator(CustomTexture tex, RenderTexture.TextureEvaluatorFlags evaluatorFlags) - : base(evaluatorFlags) + public CustomTextureEvaluator(CustomTexture tex, RenderTexture.TextureEvaluatorFlags evaluatorFlags) + : base(evaluatorFlags) + { + m_color1 = new Rhino.Display.Color4f(tex.Color1); + m_color2 = new Rhino.Display.Color4f(tex.Color2); + m_mapping = tex.LocalMappingTransform; //TODO - evaluator flags needs to be checked for efDisableLocalMapping + m_bSwapColors = tex.SwapColors; + + m_bTexture1On = tex.Texture1On && tex.Texture1Amount > 0.0; + m_bTexture2On = tex.Texture2On && tex.Texture2Amount > 0.0; + + m_dTexture1Amount = tex.Texture1Amount; + m_dTexture2Amount = tex.Texture2Amount; + + if (m_bTexture1On) { - m_color1 = new Rhino.Display.Color4f(tex.Color1); - m_color2 = new Rhino.Display.Color4f(tex.Color2); - m_mapping = tex.LocalMappingTransform; //TODO - evaluator flags needs to be checked for efDisableLocalMapping - m_bSwapColors = tex.SwapColors; - - m_bTexture1On = tex.Texture1On && tex.Texture1Amount > 0.0; - m_bTexture2On = tex.Texture2On && tex.Texture2Amount > 0.0; - - m_dTexture1Amount = tex.Texture1Amount; - m_dTexture2Amount = tex.Texture2Amount; - - if (m_bTexture1On) - { - RenderTexture child = tex.FindChild(tex.ChildSlotNameFromParamName("color-one")) as RenderTexture; - if (child != null) - { - textureEvaluatorOne = child.CreateEvaluator(evaluatorFlags); - } - } - - if (m_bTexture2On) - { - RenderTexture child = tex.FindChild(tex.ChildSlotNameFromParamName("color-two")) as RenderTexture; - if (child != null) - { - textureEvaluatorTwo = child.CreateEvaluator(evaluatorFlags); - } - } + RenderTexture child = tex.FindChild(tex.ChildSlotNameFromParamName("color-one")) as RenderTexture; + if (child != null) + { + textureEvaluatorOne = child.CreateEvaluator(evaluatorFlags); + } } - private Rhino.Display.Color4f m_color1; - private Rhino.Display.Color4f m_color2; - private Rhino.Geometry.Transform m_mapping; - private bool m_bSwapColors; - private TextureEvaluator textureEvaluatorOne; - private TextureEvaluator textureEvaluatorTwo; - private bool m_bTexture1On; - private bool m_bTexture2On; - private double m_dTexture1Amount; - private double m_dTexture2Amount; + if (m_bTexture2On) + { + RenderTexture child = tex.FindChild(tex.ChildSlotNameFromParamName("color-two")) as RenderTexture; + if (child != null) + { + textureEvaluatorTwo = child.CreateEvaluator(evaluatorFlags); + } + } + } + + private Rhino.Display.Color4f m_color1; + private Rhino.Display.Color4f m_color2; + private Rhino.Geometry.Transform m_mapping; + private bool m_bSwapColors; + private TextureEvaluator textureEvaluatorOne; + private TextureEvaluator textureEvaluatorTwo; + private bool m_bTexture1On; + private bool m_bTexture2On; + private double m_dTexture1Amount; + private double m_dTexture2Amount; static Rhino.Runtime.PythonScript m_python_script; @@ -117,29 +115,29 @@ public override Rhino.Display.Color4f GetColor(Rhino.Geometry.Point3d _uvw, Rhin bool useColorOne = false; if (i % 2 == 0) { - useColorOne = true; + useColorOne = true; } else { - d = uvw.Y * 20; - i = (int)d; - if (i % 2 == 0) - useColorOne = true; + d = uvw.Y * 20; + i = (int)d; + if (i % 2 == 0) + useColorOne = true; } if (m_bSwapColors) - useColorOne = !useColorOne; + useColorOne = !useColorOne; bool textureOn = useColorOne ? m_bTexture1On : m_bTexture2On; double textureAmount = useColorOne ? m_dTexture1Amount : m_dTexture2Amount; - TextureEvaluator texEval = useColorOne ? textureEvaluatorOne : textureEvaluatorTwo; + TextureEvaluator texEval = useColorOne ? textureEvaluatorOne : textureEvaluatorTwo; Rhino.Display.Color4f color = useColorOne ? m_color1 : m_color2; if (textureOn && texEval != null) { - //Ensure that the original UVW is passed into the child texture evaluator - color = color.BlendTo((float)textureAmount, texEval.GetColor(_uvw, duvwdx, duvwdy)); + //Ensure that the original UVW is passed into the child texture evaluator + color = color.BlendTo((float)textureAmount, texEval.GetColor(_uvw, duvwdx, duvwdy)); } return new Rhino.Display.Color4f(color); diff --git a/rhinocommon/cs/SampleCsRdk/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsRdk/Properties/AssemblyInfo.cs index c2ae4503..0fbf9501 100644 --- a/rhinocommon/cs/SampleCsRdk/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsRdk/Properties/AssemblyInfo.cs @@ -1,7 +1,6 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-In title and Guid are extracted from the following two attributes [assembly: AssemblyTitle("C# Test Render Plug-In (RDK)")] diff --git a/rhinocommon/cs/SampleCsRdk/TestCustomMeshProvider.cs b/rhinocommon/cs/SampleCsRdk/TestCustomMeshProvider.cs index 7d9daad3..d1daaab5 100644 --- a/rhinocommon/cs/SampleCsRdk/TestCustomMeshProvider.cs +++ b/rhinocommon/cs/SampleCsRdk/TestCustomMeshProvider.cs @@ -1,90 +1,89 @@ -using System; - +using Rhino; +using Rhino.Display; using Rhino.DocObjects; using Rhino.Geometry; using Rhino.Render; -using Rhino; -using Rhino.Display; +using System; namespace SampleCsRdk { - /// - /// Make this class public to test. If it is public and the plug-in is - /// loaded then any viewports that are in rendered mode will display a - /// sphere with a center at the center of the objects bounding box and a - /// radius of 1/4 the bounding box diagonal vector length. - /// - public class TestCustomMeshProvider : CustomRenderMeshProvider2 - { - Guid PluginId { get; set; } - public TestCustomMeshProvider() - { - PluginId = rdktest_csPlugIn.IdFromName("C# Test Render Plug-In (RDK)"); - Rhino.RhinoDoc.ReplaceRhinoObject += RhinoDocReplaceRhinoObject; - } + /// + /// Make this class public to test. If it is public and the plug-in is + /// loaded then any viewports that are in rendered mode will display a + /// sphere with a center at the center of the objects bounding box and a + /// radius of 1/4 the bounding box diagonal vector length. + /// + public class TestCustomMeshProvider : CustomRenderMeshProvider2 + { + Guid PluginId { get; set; } + public TestCustomMeshProvider() + { + PluginId = rdktest_csPlugIn.IdFromName("C# Test Render Plug-In (RDK)"); + Rhino.RhinoDoc.ReplaceRhinoObject += RhinoDocReplaceRhinoObject; + } - void RhinoDocReplaceRhinoObject(object sender, RhinoReplaceObjectEventArgs e) - { - ObjectChanged(e.Document, e.NewRhinoObject); - } + void RhinoDocReplaceRhinoObject(object sender, RhinoReplaceObjectEventArgs e) + { + ObjectChanged(e.Document, e.NewRhinoObject); + } - public override string Name - { - get { return "Test Custom Mesh Provider"; } - } + public override string Name + { + get { return "Test Custom Mesh Provider"; } + } - public override BoundingBox BoundingBox(ViewportInfo vp, RhinoObject obj, RhinoDoc doc, Guid requestingPlugIn, DisplayPipelineAttributes attrs) - { - var bbox = base.BoundingBox(vp, obj, doc, requestingPlugIn, attrs); + public override BoundingBox BoundingBox(ViewportInfo vp, RhinoObject obj, RhinoDoc doc, Guid requestingPlugIn, DisplayPipelineAttributes attrs) + { + BoundingBox bbox = base.BoundingBox(vp, obj, doc, requestingPlugIn, attrs); - if (obj == null) - { - var sphere = new Sphere(new Point3d(0.0, 0.0, 0.0), 10.0); - bbox.Union(sphere.BoundingBox); - } - else - { - var sphere = SphereFromObject(obj); - bbox.Union(sphere.BoundingBox); - } + if (obj == null) + { + Sphere sphere = new Sphere(new Point3d(0.0, 0.0, 0.0), 10.0); + bbox.Union(sphere.BoundingBox); + } + else + { + Sphere sphere = SphereFromObject(obj); + bbox.Union(sphere.BoundingBox); + } - return bbox; - } + return bbox; + } - Sphere SphereFromObject(RhinoObject obj) - { - var bbox = obj.Geometry.GetBoundingBox(false); - var radius = bbox.Diagonal.Length * 0.25; - radius = radius < 0.1 ? 0.1 : radius; - var sphere = new Sphere(bbox.Center, radius); - return sphere; - } + Sphere SphereFromObject(RhinoObject obj) + { + BoundingBox bbox = obj.Geometry.GetBoundingBox(false); + double radius = bbox.Diagonal.Length * 0.25; + radius = radius < 0.1 ? 0.1 : radius; + Sphere sphere = new Sphere(bbox.Center, radius); + return sphere; + } - public override bool WillBuildCustomMeshes(ViewportInfo vp, RhinoObject obj, RhinoDoc doc, Guid requestingPlugIn, DisplayPipelineAttributes attrs) - { - return true; - } + public override bool WillBuildCustomMeshes(ViewportInfo vp, RhinoObject obj, RhinoDoc doc, Guid requestingPlugIn, DisplayPipelineAttributes attrs) + { + return true; + } - public override bool BuildCustomMeshes(ViewportInfo vp, RhinoDoc doc, RenderPrimitiveList objMeshes, Guid requestingPlugIn, DisplayPipelineAttributes attrs) - { - if (!WillBuildCustomMeshes(vp, objMeshes.RhinoObject, doc, requestingPlugIn, attrs)) - return false; + public override bool BuildCustomMeshes(ViewportInfo vp, RhinoDoc doc, RenderPrimitiveList objMeshes, Guid requestingPlugIn, DisplayPipelineAttributes attrs) + { + if (!WillBuildCustomMeshes(vp, objMeshes.RhinoObject, doc, requestingPlugIn, attrs)) + return false; - var obj = objMeshes.RhinoObject; + RhinoObject obj = objMeshes.RhinoObject; - if (obj == null) - { - Sphere sphere = new Sphere(new Point3d(0.0, 0.0, 0.0), 10.0); - objMeshes.Add(Rhino.Geometry.Mesh.CreateFromSphere(sphere, 100, 100), RenderMaterial.CreateBasicMaterial(Rhino.DocObjects.Material.DefaultMaterial, doc)); - } - else - { - var sphere = SphereFromObject(obj); - objMeshes.Add(Mesh.CreateFromSphere(sphere, 100, 100), obj.RenderMaterial); - } + if (obj == null) + { + Sphere sphere = new Sphere(new Point3d(0.0, 0.0, 0.0), 10.0); + objMeshes.Add(Rhino.Geometry.Mesh.CreateFromSphere(sphere, 100, 100), RenderMaterial.CreateBasicMaterial(Rhino.DocObjects.Material.DefaultMaterial, doc)); + } + else + { + Sphere sphere = SphereFromObject(obj); + objMeshes.Add(Mesh.CreateFromSphere(sphere, 100, 100), obj.RenderMaterial); + } - return true; - } - } + return true; + } + } } diff --git a/rhinocommon/cs/SampleCsRdk/rdktest_csCommand.cs b/rhinocommon/cs/SampleCsRdk/rdktest_csCommand.cs index 2d6a9c97..eac3c0bc 100644 --- a/rhinocommon/cs/SampleCsRdk/rdktest_csCommand.cs +++ b/rhinocommon/cs/SampleCsRdk/rdktest_csCommand.cs @@ -1,4 +1,3 @@ -using System; using Rhino; namespace SampleCsRdk diff --git a/rhinocommon/cs/SampleCsRdk/rdktest_csPlugIn.cs b/rhinocommon/cs/SampleCsRdk/rdktest_csPlugIn.cs index 577fe691..b1f4200c 100644 --- a/rhinocommon/cs/SampleCsRdk/rdktest_csPlugIn.cs +++ b/rhinocommon/cs/SampleCsRdk/rdktest_csPlugIn.cs @@ -1,17 +1,14 @@ -using System; -using System.Drawing; -using System.Drawing.Imaging; -using System.Runtime.Remoting.Activation; using Rhino; -using Rhino.Display; -using Rhino.Render; -using System.Threading; -using System.Collections.Generic; -using System.Runtime.InteropServices; using Rhino.Commands; +using Rhino.Display; using Rhino.DocObjects; -using Rhino.Render.ChangeQueue; using Rhino.PlugIns; +using Rhino.Render; +using Rhino.Render.ChangeQueue; +using System; +using System.Drawing; +using System.Drawing.Imaging; +using System.Threading; namespace SampleCsRdk { @@ -121,7 +118,7 @@ private void Cq_ViewChanged(object sender, NewSizeArgs e) { lock (uselock) { - var sp = e.ViewInfo.Viewport.ScreenPort; + Rectangle sp = e.ViewInfo.Viewport.ScreenPort; rs = new Size(sp.Width, sp.Height); if (rw.Size() != rs) { @@ -140,11 +137,11 @@ public void RenderIt() { lock (uselock) { - using (var ch = rw.OpenChannel(RenderWindow.StandardChannels.RGBA)) + using (RenderWindow.Channel ch = rw.OpenChannel(RenderWindow.StandardChannels.RGBA)) { - for (var x = 0; x < rs.Width; x++) + for (int x = 0; x < rs.Width; x++) { - for (var y = 0; y < rs.Height; y++) + for (int y = 0; y < rs.Height; y++) { ch.SetValue(x, y, new Color4f((float)rnd.NextDouble(), (float)rnd.NextDouble(), (float)rnd.NextDouble(), 1.0f)); } @@ -171,7 +168,7 @@ public override bool IsRendererStarted() } public override bool IsFrameBufferAvailable(ViewInfo view) { - var yes = cq.AreViewsEqual(GetView(), view); + bool yes = cq.AreViewsEqual(GetView(), view); return yes; } @@ -311,7 +308,7 @@ public MyRenderPipeline(RhinoDoc doc, Rhino.Commands.RunMode mode, Rhino.PlugIns : base(doc, mode, plugin, RenderPipeline.RenderSize(doc), "RdkTest", Rhino.Render.RenderWindow.StandardChannels.RGBA, false, false, ref aRC) { - m_asyncRenderContext = (MyAsyncRenderContext)aRC; + m_asyncRenderContext = (MyAsyncRenderContext)aRC; } public bool Cancel() { return m_bStopFlag; } @@ -366,8 +363,8 @@ static void RhinoDocNewDocument(object sender, DocumentEventArgs e) static void AddDefaultCustomEnvironment(RhinoDoc rhinoDoc) { // There is no default environment so add one now - var type = typeof(CustomEnvironment); - var content = RenderContent.Create(type, RenderContent.ShowContentChooserFlags.None, rhinoDoc) as CustomEnvironment; + Type type = typeof(CustomEnvironment); + CustomEnvironment content = RenderContent.Create(type, RenderContent.ShowContentChooserFlags.None, rhinoDoc) as CustomEnvironment; if (content == null) return; rhinoDoc.CurrentEnvironment.ForBackground = content; rhinoDoc.RenderSettings.BackgroundStyle = BackgroundStyle.Environment; @@ -375,13 +372,13 @@ static void AddDefaultCustomEnvironment(RhinoDoc rhinoDoc) protected override void RegisterRenderPanels(RenderPanels panels) { - var type = typeof (CustomRenderPanel); + Type type = typeof(CustomRenderPanel); panels.RegisterPanel(this, RenderPanelType.RenderWindow, type, this.Id, "Custom Panel", true, true); } protected override void RegisterRenderTabs(RenderTabs tabs) { - var type = typeof(CustomRenderPanel); + Type type = typeof(CustomRenderPanel); tabs.RegisterTab(this, type, this.Id, "Custom Panel", SystemIcons.Exclamation); } @@ -395,7 +392,7 @@ protected override void CreatePreview(CreatePreviewEventArgs scene) if (scene.Quality == PreviewSceneQuality.Low) { // Use built in image for quick preview so we don't slow the UI down. - scene.PreviewImage = new Bitmap(Properties.Resources.AtoZ, scene.PreviewImageSize); + scene.PreviewImage = new Bitmap(Properties.Resources.AtoZ, scene.PreviewImageSize); return; } // New preview bitmap @@ -413,7 +410,7 @@ protected override void CreatePreview(CreatePreviewEventArgs scene) { // Make sure the content is a material RenderMaterial render_material = null; - foreach (var obj in scene.Objects) + foreach (CreatePreviewEventArgs.SceneObject obj in scene.Objects) { render_material = obj.Material; if (render_material != null) break; @@ -435,9 +432,9 @@ protected override void CreatePreview(CreatePreviewEventArgs scene) Bitmap BitmapForScene(CreatePreviewEventArgs scene, Color4f color) { - var bitmap = new Bitmap(scene.PreviewImageSize.Width, scene.PreviewImageSize.Height, PixelFormat.Format24bppRgb); + Bitmap bitmap = new Bitmap(scene.PreviewImageSize.Width, scene.PreviewImageSize.Height, PixelFormat.Format24bppRgb); // Fill the bitmap using the computed color - using (var g = Graphics.FromImage(bitmap)) + using (Graphics g = Graphics.FromImage(bitmap)) { g.Clear(Color.FromArgb(255, color.AsSystemColor())); g.DrawRectangle(Pens.Black, 0, 0, bitmap.Width - 1, bitmap.Height - 1); diff --git a/rhinocommon/cs/SampleCsRdkMaterialAutoUI/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsRdkMaterialAutoUI/Properties/AssemblyInfo.cs index 7cb5caff..79248d55 100644 --- a/rhinocommon/cs/SampleCsRdkMaterialAutoUI/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsRdkMaterialAutoUI/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterial.cs b/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterial.cs index 0b9ea041..d3eee3ba 100644 --- a/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterial.cs +++ b/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterial.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Rhino.Render; +using Rhino.Render; using Rhino.Render.Fields; using System.Drawing; using System.Drawing.Imaging; @@ -41,7 +36,7 @@ public override bool Icon(System.Drawing.Size size, out System.Drawing.Bitmap bi { // The icon is a red square bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format24bppRgb); - using (var g = Graphics.FromImage(bitmap)) + using (Graphics g = Graphics.FromImage(bitmap)) g.Clear(Color.Red); return true; } diff --git a/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterialAutoUICommand.cs b/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterialAutoUICommand.cs index 8953d520..10397d97 100644 --- a/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterialAutoUICommand.cs +++ b/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterialAutoUICommand.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Geometry; using Rhino.Input; diff --git a/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterialAutoUIPlugIn.cs b/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterialAutoUIPlugIn.cs index 36cecea9..5e1bbe9a 100644 --- a/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterialAutoUIPlugIn.cs +++ b/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRdkMaterialAutoUIPlugIn.cs @@ -1,11 +1,6 @@ -using Rhino; +using Rhino.PlugIns; using Rhino.Render; -using Rhino.Commands; using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using Rhino.PlugIns; namespace SampleRdkMaterialAutoUI { @@ -43,7 +38,7 @@ public static SampleRdkMaterialAutoUIPlugIn Instance // You can override methods here to change the plug-in behavior on // loading and shut down, add options pages to the Rhino _Option command // and mantain plug-in wide options in a document. - + protected override LoadReturnCode OnLoad(ref string errorMessage) { base.OnLoad(ref errorMessage); diff --git a/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRenderContentSerializer.cs b/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRenderContentSerializer.cs index 3bda2325..c498a802 100644 --- a/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRenderContentSerializer.cs +++ b/rhinocommon/cs/SampleCsRdkMaterialAutoUI/SampleRenderContentSerializer.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; -using Rhino.Render; +using Rhino.Render; using Rhino.Render.Fields; +using System; +using System.Collections.Generic; namespace SampleRdkMaterialAutoUI { @@ -35,11 +35,11 @@ public override RenderContent Read(string pathToFile) // Create new Sample Material without fields. // We will read the fields from the file and // add them to the material - var material = new SampleRdkMaterial(); + SampleRdkMaterial material = new SampleRdkMaterial(); // Read values from file and set values string line; - var file = new System.IO.StreamReader(pathToFile); + System.IO.StreamReader file = new System.IO.StreamReader(pathToFile); while ((line = file.ReadLine()) != null) { string[] type_prompt_key_and_value = line.Split(','); @@ -92,11 +92,11 @@ public override RenderContent Read(string pathToFile) // Write sample material to .sample file (only bool values) public override bool Write(string pathToFile, RenderContent renderContent, CreatePreviewEventArgs previewArgs) { - var lines = new List(); + List lines = new List(); - foreach (var field in renderContent.Fields) + foreach (Field field in renderContent.Fields) { - var type = field.GetType(); + Type type = field.GetType(); // Bool fields if (type == typeof(BoolField)) @@ -110,7 +110,7 @@ public override bool Write(string pathToFile, RenderContent renderContent, Creat } // Write all lines to .sample file - using (var file = new System.IO.StreamWriter(pathToFile)) + using (System.IO.StreamWriter file = new System.IO.StreamWriter(pathToFile)) { foreach (string line in lines) { diff --git a/rhinocommon/cs/SampleCsRectangleGrips/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsRectangleGrips/Properties/AssemblyInfo.cs index 3a0cbda9..332ec824 100644 --- a/rhinocommon/cs/SampleCsRectangleGrips/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsRectangleGrips/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGrips.cs b/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGrips.cs index 8fa628ad..805c6eee 100644 --- a/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGrips.cs +++ b/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGrips.cs @@ -1,6 +1,6 @@ -using System; -using Rhino.DocObjects.Custom; +using Rhino.DocObjects.Custom; using Rhino.Geometry; +using System; namespace SampleCsRectangleGrips { @@ -19,7 +19,7 @@ public SampleCsRectangleGrips() { m_draw_rectangle = false; m_sample_cs_rectangle_grips = new SampleCsRectangleGrip[8]; - for (var i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) m_sample_cs_rectangle_grips[i] = new SampleCsRectangleGrip(); } @@ -40,16 +40,16 @@ public bool CreateGrips(PolylineCurve polylineCurve) m_plane = plane; m_active_rectangle = new Point3d[5]; - for (var i = 0; i < polylineCurve.PointCount; i++) + for (int i = 0; i < polylineCurve.PointCount; i++) m_active_rectangle[i] = polylineCurve.Point(i); m_original_rectangle = new Point3d[5]; Array.Copy(m_active_rectangle, m_original_rectangle, 5); - var line = new Line(); - for (var i = 0; i < 4; i++) + Line line = new Line(); + for (int i = 0; i < 4; i++) { - var gi = 2 * i; + int gi = 2 * i; line.From = m_active_rectangle[i]; line.To = m_active_rectangle[i + 1]; m_sample_cs_rectangle_grips[gi].OriginalLocation = line.From; @@ -58,7 +58,7 @@ public bool CreateGrips(PolylineCurve polylineCurve) m_sample_cs_rectangle_grips[gi + 1].Active = true; } - for (var i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) AddGrip(m_sample_cs_rectangle_grips[i]); return true; @@ -73,11 +73,11 @@ private void UpdateGrips() { // If anything moved this time, the ones that didn't move will // be inactive for the rest of the drag - for (var i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { if (m_sample_cs_rectangle_grips[i].Active && m_sample_cs_rectangle_grips[i].Moved) { - for (var j = 0; j < 8; j++) + for (int j = 0; j < 8; j++) { if (!m_sample_cs_rectangle_grips[j].Moved) m_sample_cs_rectangle_grips[j].Active = false; @@ -87,7 +87,7 @@ private void UpdateGrips() } // First check corners - for (var i = 0; i < 8; i += 2) + for (int i = 0; i < 8; i += 2) { if (m_sample_cs_rectangle_grips[i].Active && m_sample_cs_rectangle_grips[i].Moved) { @@ -98,7 +98,7 @@ private void UpdateGrips() } // Second check middles - for (var i = 1; i < 8; i += 2) + for (int i = 1; i < 8; i += 2) { if (m_sample_cs_rectangle_grips[i].Active && m_sample_cs_rectangle_grips[i].Moved) { @@ -109,25 +109,25 @@ private void UpdateGrips() } // Set up transforms - var world_to_plane = Transform.ChangeBasis(Plane.WorldXY, m_plane); - var plane_to_world = Transform.ChangeBasis(m_plane, Plane.WorldXY); + Transform world_to_plane = Transform.ChangeBasis(Plane.WorldXY, m_plane); + Transform plane_to_world = Transform.ChangeBasis(m_plane, Plane.WorldXY); // Copy and transform active rectangle points - var rectangle = new Point3d[5]; + Point3d[] rectangle = new Point3d[5]; Array.Copy(m_active_rectangle, rectangle, 5); - for (var i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) rectangle[i].Transform(world_to_plane); // Copy and transform current grip locations - var locations = new Point3d[8]; - for (var i = 0; i < 8; i++) + Point3d[] locations = new Point3d[8]; + for (int i = 0; i < 8; i++) { locations[i] = m_sample_cs_rectangle_grips[i].CurrentLocation; locations[i].Transform(world_to_plane); } // Figure out which x, y coordinates have been changed - var x0 = rectangle[0].X; + double x0 = rectangle[0].X; if (m_sample_cs_rectangle_grips[0].Active && m_sample_cs_rectangle_grips[0].Moved) x0 = locations[0].X; else if (m_sample_cs_rectangle_grips[6].Active && m_sample_cs_rectangle_grips[6].Moved) @@ -135,7 +135,7 @@ private void UpdateGrips() else if (m_sample_cs_rectangle_grips[7].Active && m_sample_cs_rectangle_grips[7].Moved) x0 = locations[7].X; - var x1 = rectangle[2].X; + double x1 = rectangle[2].X; if (m_sample_cs_rectangle_grips[4].Active && m_sample_cs_rectangle_grips[4].Moved) x1 = locations[4].X; else if (m_sample_cs_rectangle_grips[2].Active && m_sample_cs_rectangle_grips[2].Moved) @@ -143,7 +143,7 @@ private void UpdateGrips() else if (m_sample_cs_rectangle_grips[3].Active && m_sample_cs_rectangle_grips[3].Moved) x1 = locations[3].X; - var y0 = rectangle[0].Y; + double y0 = rectangle[0].Y; if (m_sample_cs_rectangle_grips[0].Active && m_sample_cs_rectangle_grips[0].Moved) y0 = locations[0].Y; else if (m_sample_cs_rectangle_grips[2].Active && m_sample_cs_rectangle_grips[2].Moved) @@ -151,7 +151,7 @@ private void UpdateGrips() else if (m_sample_cs_rectangle_grips[1].Active && m_sample_cs_rectangle_grips[1].Moved) y0 = locations[1].Y; - var y1 = rectangle[2].Y; + double y1 = rectangle[2].Y; if (m_sample_cs_rectangle_grips[4].Active && m_sample_cs_rectangle_grips[4].Moved) y1 = locations[4].Y; else if (m_sample_cs_rectangle_grips[6].Active && m_sample_cs_rectangle_grips[6].Moved) @@ -167,14 +167,14 @@ private void UpdateGrips() // Copy and transform updated rectangle points Array.Copy(rectangle, m_active_rectangle, 5); - for (var i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) m_active_rectangle[i].Transform(plane_to_world); // Apply rectangular constraints to grip locations - var line = new Line(); - for (var i = 0; i < 4; i++) + Line line = new Line(); + for (int i = 0; i < 4; i++) { - var gi = 2 * i; + int gi = 2 * i; line.From = m_active_rectangle[i]; line.To = m_active_rectangle[i + 1]; m_sample_cs_rectangle_grips[gi].Move(line.From); @@ -215,10 +215,10 @@ protected override void OnDraw(GripsDrawEventArgs args) UpdateGrips(); if (m_draw_rectangle && args.DrawDynamicStuff) { - for (var i = 1; i < 5; i++) + for (int i = 1; i < 5; i++) { - var start = i - 1; - var end = i; + int start = i - 1; + int end = i; args.DrawControlPolygonLine(m_active_rectangle[start], m_active_rectangle[end], start, end); } } diff --git a/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGripsCommand.cs b/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGripsCommand.cs index e1fd4fe2..b35836c5 100644 --- a/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGripsCommand.cs +++ b/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGripsCommand.cs @@ -29,15 +29,15 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) CustomObjectGrips.RegisterGripsEnabler(m_grip_enabler.TurnOnGrips, typeof(SampleCsRectangleGrips)); } - var go = new SampleCsGetRectangleCurve(); + SampleCsGetRectangleCurve go = new SampleCsGetRectangleCurve(); go.SetCommandPrompt("Select rectangles for point display"); go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) return go.CommandResult(); - for (var i = 0; i < go.ObjectCount; i++) + for (int i = 0; i < go.ObjectCount; i++) { - var rh_object = go.Object(i).Object(); + Rhino.DocObjects.RhinoObject rh_object = go.Object(i).Object(); if (null != rh_object) { if (rh_object.GripsOn) diff --git a/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGripsEnabler.cs b/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGripsEnabler.cs index 4e4cbd0f..cc726972 100644 --- a/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGripsEnabler.cs +++ b/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleGripsEnabler.cs @@ -13,14 +13,14 @@ public void TurnOnGrips(RhinoObject rhObject) if (rhObject == null) return; - var polyline_curve = rhObject.Geometry as PolylineCurve; + PolylineCurve polyline_curve = rhObject.Geometry as PolylineCurve; if (polyline_curve == null) return; if (!SampleCsRectangleHelper.IsRectangle(polyline_curve)) return; - var rectangle_grips = new SampleCsRectangleGrips(); + SampleCsRectangleGrips rectangle_grips = new SampleCsRectangleGrips(); if (!rectangle_grips.CreateGrips(polyline_curve)) return; diff --git a/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleHelper.cs b/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleHelper.cs index 80195b8d..c6087352 100644 --- a/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleHelper.cs +++ b/rhinocommon/cs/SampleCsRectangleGrips/SampleCsRectangleHelper.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Geometry; +using System; +using System.Collections.Generic; namespace SampleCsRectangleGrips { @@ -12,7 +12,7 @@ internal static class SampleCsRectangleHelper /// public static bool IsRectangle(IEnumerable points) { - var curve = new PolylineCurve(points); + PolylineCurve curve = new PolylineCurve(points); return curve.IsValid && IsRectangle(curve); } @@ -24,7 +24,7 @@ public static bool IsRectangle(Polyline polyline) if (polyline == null) return false; - var curve = new PolylineCurve(polyline); + PolylineCurve curve = new PolylineCurve(polyline); return curve.IsValid && IsRectangle(curve); } @@ -39,19 +39,19 @@ public static bool IsRectangle(PolylineCurve curve) // Angle between each segment should be 90 degrees const double angle = 90.0 * (Math.PI / 180.0); - for (var i = 1; i < curve.PointCount - 1; i++) + for (int i = 1; i < curve.PointCount - 1; i++) { - var p0 = curve.Point(i - 1); - var p1 = curve.Point(i); - var p2 = curve.Point(i + 1); + Point3d p0 = curve.Point(i - 1); + Point3d p1 = curve.Point(i); + Point3d p2 = curve.Point(i + 1); - var v0 = p1 - p0; + Vector3d v0 = p1 - p0; v0.Unitize(); - var v1 = p1 - p2; + Vector3d v1 = p1 - p2; v1.Unitize(); - var a = Vector3d.VectorAngle(v0, v1); + double a = Vector3d.VectorAngle(v0, v1); if (Math.Abs(angle - a) >= RhinoMath.DefaultAngleTolerance) return false; } @@ -64,7 +64,7 @@ public static bool IsRectangle(PolylineCurve curve) /// public static bool IsRectangle(GeometryBase geometry) { - var polyline_curve = geometry as PolylineCurve; + PolylineCurve polyline_curve = geometry as PolylineCurve; return polyline_curve != null && IsRectangle(polyline_curve); } } diff --git a/rhinocommon/cs/SampleCsRenderContentMenu/CommandPluginCommand.cs b/rhinocommon/cs/SampleCsRenderContentMenu/CommandPluginCommand.cs index 400789ad..d5501d0f 100644 --- a/rhinocommon/cs/SampleCsRenderContentMenu/CommandPluginCommand.cs +++ b/rhinocommon/cs/SampleCsRenderContentMenu/CommandPluginCommand.cs @@ -3,72 +3,70 @@ using Rhino.Geometry; using Rhino.Input; using Rhino.Input.Custom; -using System; -using System.Collections.Generic; namespace CommandPlugin { - public class CommandPluginCommand : Command + public class CommandPluginCommand : Command + { + public CommandPluginCommand() { - public CommandPluginCommand() - { - // Rhino only creates one instance of each command class defined in a - // plug-in, so it is safe to store a refence in a static property. - Instance = this; - } + // Rhino only creates one instance of each command class defined in a + // plug-in, so it is safe to store a refence in a static property. + Instance = this; + } - ///The only instance of this command. - public static CommandPluginCommand Instance - { - get; private set; - } + ///The only instance of this command. + public static CommandPluginCommand Instance + { + get; private set; + } + + ///The command name as it appears on the Rhino command line. + public override string EnglishName + { + get { return "CommandPluginCommand"; } + } + + protected override Result RunCommand(RhinoDoc doc, RunMode mode) + { + // TODO: start here modifying the behaviour of your command. + // --- + RhinoApp.WriteLine("The {0} command will add a line right now.", EnglishName); - ///The command name as it appears on the Rhino command line. - public override string EnglishName + Point3d pt0; + using (GetPoint getPointAction = new GetPoint()) + { + getPointAction.SetCommandPrompt("Please select the start point"); + if (getPointAction.Get() != GetResult.Point) { - get { return "CommandPluginCommand"; } + RhinoApp.WriteLine("No start point was selected."); + return getPointAction.CommandResult(); } + pt0 = getPointAction.Point(); + } - protected override Result RunCommand(RhinoDoc doc, RunMode mode) + Point3d pt1; + using (GetPoint getPointAction = new GetPoint()) + { + getPointAction.SetCommandPrompt("Please select the end point"); + getPointAction.SetBasePoint(pt0, true); + getPointAction.DynamicDraw += + (sender, e) => e.Display.DrawLine(pt0, e.CurrentPoint, System.Drawing.Color.DarkRed); + if (getPointAction.Get() != GetResult.Point) { - // TODO: start here modifying the behaviour of your command. - // --- - RhinoApp.WriteLine("The {0} command will add a line right now.", EnglishName); - - Point3d pt0; - using (GetPoint getPointAction = new GetPoint()) - { - getPointAction.SetCommandPrompt("Please select the start point"); - if (getPointAction.Get() != GetResult.Point) - { - RhinoApp.WriteLine("No start point was selected."); - return getPointAction.CommandResult(); - } - pt0 = getPointAction.Point(); - } - - Point3d pt1; - using (GetPoint getPointAction = new GetPoint()) - { - getPointAction.SetCommandPrompt("Please select the end point"); - getPointAction.SetBasePoint(pt0, true); - getPointAction.DynamicDraw += - (sender, e) => e.Display.DrawLine(pt0, e.CurrentPoint, System.Drawing.Color.DarkRed); - if (getPointAction.Get() != GetResult.Point) - { - RhinoApp.WriteLine("No end point was selected."); - return getPointAction.CommandResult(); - } - pt1 = getPointAction.Point(); - } + RhinoApp.WriteLine("No end point was selected."); + return getPointAction.CommandResult(); + } + pt1 = getPointAction.Point(); + } - doc.Objects.AddLine(pt0, pt1); - doc.Views.Redraw(); - RhinoApp.WriteLine("The {0} command added one line to the document.", EnglishName); + doc.Objects.AddLine(pt0, pt1); + doc.Views.Redraw(); + RhinoApp.WriteLine("The {0} command added one line to the document.", EnglishName); - // --- + // --- - return Result.Success; - } + return Result.Success; } + } } diff --git a/rhinocommon/cs/SampleCsRenderContentMenu/CommandPluginPlugIn.cs b/rhinocommon/cs/SampleCsRenderContentMenu/CommandPluginPlugIn.cs index a7399dc7..ab012081 100644 --- a/rhinocommon/cs/SampleCsRenderContentMenu/CommandPluginPlugIn.cs +++ b/rhinocommon/cs/SampleCsRenderContentMenu/CommandPluginPlugIn.cs @@ -3,134 +3,134 @@ namespace CommandPlugin { - /// - /// Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived - /// class. DO NOT create instances of this class yourself. It is the - /// responsibility of Rhino to create an instance of this class. - /// To complete plug-in information, please also see all PlugInDescription - /// attributes in AssemblyInfo.cs (you might need to click "Project" -> - /// "Show All Files" to see it in the "Solution Explorer" window). - /// - public class CommandPluginPlugIn : Rhino.PlugIns.PlugIn + /// + /// Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived + /// class. DO NOT create instances of this class yourself. It is the + /// responsibility of Rhino to create an instance of this class. + /// To complete plug-in information, please also see all PlugInDescription + /// attributes in AssemblyInfo.cs (you might need to click "Project" -> + /// "Show All Files" to see it in the "Solution Explorer" window). + /// + public class CommandPluginPlugIn : Rhino.PlugIns.PlugIn + { + public CommandPluginPlugIn() { - public CommandPluginPlugIn() - { - Instance = this; - } + Instance = this; + } - ///Gets the only instance of the CommandPluginPlugIn plug-in. - public static CommandPluginPlugIn Instance - { - get; private set; - } + ///Gets the only instance of the CommandPluginPlugIn plug-in. + public static CommandPluginPlugIn Instance + { + get; private set; + } - // You can override methods here to change the plug-in behavior on - // loading and shut down, add options pages to the Rhino _Option command - // and maintain plug-in wide options in a document. - protected override LoadReturnCode OnLoad(ref string errorMessage) + // You can override methods here to change the plug-in behavior on + // loading and shut down, add options pages to the Rhino _Option command + // and maintain plug-in wide options in a document. + protected override LoadReturnCode OnLoad(ref string errorMessage) + { + LoadReturnCode result = base.OnLoad(ref errorMessage); + if (result == LoadReturnCode.Success) + { + // Create a red icon for the command + System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(16, 16, System.Drawing.Imaging.PixelFormat.Format24bppRgb); + using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) { - var result = base.OnLoad(ref errorMessage); - if (result == LoadReturnCode.Success) - { - // Create a red icon for the command - System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(16, 16, System.Drawing.Imaging.PixelFormat.Format24bppRgb); - using (var g = System.Drawing.Graphics.FromImage(bitmap)) - { - g.Clear(System.Drawing.Color.Red); - } - - // Add a UI command - RenderContentMenu.AddMenuItem(this.Id, "Test UI Command", 5, RenderContentMenu.SeparatorStyle.None, true, System.Drawing.Icon.FromHandle(bitmap.GetHicon()), CommandAction, CommandEnabled); - } - return result; + g.Clear(System.Drawing.Color.Red); } - // Function that will be called when the command is executed - private Rhino.Commands.Result CommandAction(Rhino.Render.RenderContentCollection collection) - { - - if (collection.Count() > 0) - { - Rhino.Render.ContentCollectionIterator iterator = collection.Iterator(); - Rhino.Render.RenderContent content = iterator.First(); + // Add a UI command + RenderContentMenu.AddMenuItem(this.Id, "Test UI Command", 5, RenderContentMenu.SeparatorStyle.None, true, System.Drawing.Icon.FromHandle(bitmap.GetHicon()), CommandAction, CommandEnabled); + } + return result; + } - if (content != null) - { - Eto.Forms.MessageBox.Show(content.Xml, "C#", Eto.Forms.MessageBoxType.Information); + // Function that will be called when the command is executed + private Rhino.Commands.Result CommandAction(Rhino.Render.RenderContentCollection collection) + { - iterator.DeleteThis(); - return Rhino.Commands.Result.Success; - } + if (collection.Count() > 0) + { + Rhino.Render.ContentCollectionIterator iterator = collection.Iterator(); + Rhino.Render.RenderContent content = iterator.First(); - iterator.DeleteThis(); - } + if (content != null) + { + Eto.Forms.MessageBox.Show(content.Xml, "C#", Eto.Forms.MessageBoxType.Information); - return Rhino.Commands.Result.Failure; + iterator.DeleteThis(); + return Rhino.Commands.Result.Success; } - // Function that will be called to check if the command should be visible. - private bool CommandEnabled(Rhino.Render.RenderContentCollection collection, RenderContentMenu.Context control) - { - // Unknown control - if (control == RenderContentMenu.Context.Unknown) - return true; - // The main content editor thumbnail list. - else if (control == RenderContentMenu.Context.MainThumbnailList) - return true; - // The main content editor tree control. - else if (control == RenderContentMenu.Context.MainTree) - return false; - // The content editor preview thumbnail list. - else if (control == RenderContentMenu.Context.EditorPreview) - return true; - // A sub-node control. - else if (control == RenderContentMenu.Context.SubNodeControl) - return true; - // A 'Create New' button - AKA [+] button. - else if (control == RenderContentMenu.Context.ColorButton) - return true; - // An old-style content control. - else if (control == RenderContentMenu.Context.CreateNewButton) - return true; - // A new-style content control. - else if (control == RenderContentMenu.Context.ContentControl) - return true; - // A new-style content control's drop-down thumbnail list. - else if (control == RenderContentMenu.Context.NewContentControl) - return true; - // A breadcrumb control. - else if (control == RenderContentMenu.Context.NewContentControlDropDown) - return true; - // A floating preview. - else if (control == RenderContentMenu.Context.BreadcrumbControl) - return true; - // Spanner menu. - else if (control == RenderContentMenu.Context.FloatingPreview) - return true; - // Spanner menu in modal editor. - else if (control == RenderContentMenu.Context.Spanner) - return true; - // Content type section. - else if (control == RenderContentMenu.Context.SpannerModal) - return true; - // Content type browser 'new' page. - else if (control == RenderContentMenu.Context.ContentTypeSection) - return true; - // Content type browser 'existing' page. - else if (control == RenderContentMenu.Context.ContentTypeBrowserNew) - return true; - // Content instance browser. - else if (control == RenderContentMenu.Context.ContentTypeBrowserExisting) - return true; - // Tool-tip preview. - else if (control == RenderContentMenu.Context.ContentInstanceBrowser) - return true; - // Spanner menu. - else if (control == RenderContentMenu.Context.ToolTipPreview) - return true; - else - return true; - } + iterator.DeleteThis(); + } + + return Rhino.Commands.Result.Failure; + } + + // Function that will be called to check if the command should be visible. + private bool CommandEnabled(Rhino.Render.RenderContentCollection collection, RenderContentMenu.Context control) + { + // Unknown control + if (control == RenderContentMenu.Context.Unknown) + return true; + // The main content editor thumbnail list. + else if (control == RenderContentMenu.Context.MainThumbnailList) + return true; + // The main content editor tree control. + else if (control == RenderContentMenu.Context.MainTree) + return false; + // The content editor preview thumbnail list. + else if (control == RenderContentMenu.Context.EditorPreview) + return true; + // A sub-node control. + else if (control == RenderContentMenu.Context.SubNodeControl) + return true; + // A 'Create New' button - AKA [+] button. + else if (control == RenderContentMenu.Context.ColorButton) + return true; + // An old-style content control. + else if (control == RenderContentMenu.Context.CreateNewButton) + return true; + // A new-style content control. + else if (control == RenderContentMenu.Context.ContentControl) + return true; + // A new-style content control's drop-down thumbnail list. + else if (control == RenderContentMenu.Context.NewContentControl) + return true; + // A breadcrumb control. + else if (control == RenderContentMenu.Context.NewContentControlDropDown) + return true; + // A floating preview. + else if (control == RenderContentMenu.Context.BreadcrumbControl) + return true; + // Spanner menu. + else if (control == RenderContentMenu.Context.FloatingPreview) + return true; + // Spanner menu in modal editor. + else if (control == RenderContentMenu.Context.Spanner) + return true; + // Content type section. + else if (control == RenderContentMenu.Context.SpannerModal) + return true; + // Content type browser 'new' page. + else if (control == RenderContentMenu.Context.ContentTypeSection) + return true; + // Content type browser 'existing' page. + else if (control == RenderContentMenu.Context.ContentTypeBrowserNew) + return true; + // Content instance browser. + else if (control == RenderContentMenu.Context.ContentTypeBrowserExisting) + return true; + // Tool-tip preview. + else if (control == RenderContentMenu.Context.ContentInstanceBrowser) + return true; + // Spanner menu. + else if (control == RenderContentMenu.Context.ToolTipPreview) + return true; + else + return true; } + } } \ No newline at end of file diff --git a/rhinocommon/cs/SampleCsRenderContentMenu/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsRenderContentMenu/Properties/AssemblyInfo.cs index 2baeefe4..28af1f7a 100644 --- a/rhinocommon/cs/SampleCsRenderContentMenu/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsRenderContentMenu/Properties/AssemblyInfo.cs @@ -1,6 +1,5 @@ using Rhino.PlugIns; using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // Plug-in Description Attributes - all of these are optional. diff --git a/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/Properties/AssemblyInfo.cs index c469afbc..a3baa7fd 100644 --- a/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/SampleCsStringTable.cs b/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/SampleCsStringTable.cs index 56d843b5..39d1dd99 100644 --- a/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/SampleCsStringTable.cs +++ b/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/SampleCsStringTable.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using Rhino; +using Rhino; using Rhino.FileIO; +using System.Collections.Generic; +using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("SampleCsMain")] namespace SampleCsCommon @@ -172,11 +172,11 @@ public void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOp /// public void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options) { - archive.Read3dmChunkVersion(out var major, out var minor); + archive.Read3dmChunkVersion(out int major, out int minor); if (MAJOR == major && MINOR == minor) { // Always read user data even though you might not use it... - var strings = archive.ReadStringArray(); + string[] strings = archive.ReadStringArray(); if (null != strings && !options.ImportMode && !options.ImportReferenceMode) m_strings.AddRange(strings); } diff --git a/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/SampleCsStringTableHelpers.cs b/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/SampleCsStringTableHelpers.cs index b67c72c6..f83020cd 100644 --- a/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/SampleCsStringTableHelpers.cs +++ b/rhinocommon/cs/SampleCsSharedData/SampleCsCommon/SampleCsStringTableHelpers.cs @@ -1,6 +1,4 @@ -using System; - -namespace SampleCsCommon +namespace SampleCsCommon { public class SampleCsStringTableHelpers { diff --git a/rhinocommon/cs/SampleCsSharedData/SampleCsMain/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsSharedData/SampleCsMain/Properties/AssemblyInfo.cs index b2eb2d6c..bf17d5b4 100644 --- a/rhinocommon/cs/SampleCsSharedData/SampleCsMain/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsSharedData/SampleCsMain/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainCommand.cs b/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainCommand.cs index ff3d3a7c..e6fcd703 100644 --- a/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainCommand.cs +++ b/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainCommand.cs @@ -36,7 +36,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) int list_index = go.AddOption("List"); go.Get(); - if (go.CommandResult() !=Result.Success) + if (go.CommandResult() != Result.Success) return go.CommandResult(); CommandLineOption option = go.Option(); diff --git a/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainPanel.cs b/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainPanel.cs index 140aa266..af7a5f16 100644 --- a/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainPanel.cs +++ b/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainPanel.cs @@ -1,6 +1,6 @@ -using System; +using SampleCsCommon; +using System; using System.Windows.Forms; -using SampleCsCommon; namespace SampleCsMain { diff --git a/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainPlugIn.cs b/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainPlugIn.cs index 60a36f10..b6915f3e 100644 --- a/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainPlugIn.cs +++ b/rhinocommon/cs/SampleCsSharedData/SampleCsMain/SampleCsMainPlugIn.cs @@ -1,9 +1,9 @@ -using System; -using Rhino; +using Rhino; using Rhino.FileIO; using Rhino.PlugIns; using Rhino.UI; using SampleCsCommon; +using System; namespace SampleCsMain { @@ -63,7 +63,7 @@ protected override LoadReturnCode OnLoad(ref string errorMessage) // Add an event handler so we know when documents are closed. RhinoDoc.CloseDocument += new EventHandler(OnCloseDocument); - + return LoadReturnCode.Success; } @@ -116,7 +116,7 @@ protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, /// protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options) { - archive.Read3dmChunkVersion(out var major, out var minor); + archive.Read3dmChunkVersion(out int major, out int minor); if (MAJOR == major && MINOR == minor) { SampleCsStringTable string_table = SampleCsStringTable.Instance; diff --git a/rhinocommon/cs/SampleCsSharedData/SampleCsTest1/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsSharedData/SampleCsTest1/Properties/AssemblyInfo.cs index cef3dcfd..83f136a7 100644 --- a/rhinocommon/cs/SampleCsSharedData/SampleCsTest1/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsSharedData/SampleCsTest1/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsSharedData/SampleCsTest2/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsSharedData/SampleCsTest2/Properties/AssemblyInfo.cs index 1d9de6de..86650a1a 100644 --- a/rhinocommon/cs/SampleCsSharedData/SampleCsTest2/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsSharedData/SampleCsTest2/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings1/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings1/Properties/AssemblyInfo.cs index 2d7823d8..635ff98e 100644 --- a/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings1/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings1/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings1/SampleCsSettings1Command.cs b/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings1/SampleCsSettings1Command.cs index ca14620b..bed1104b 100644 --- a/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings1/SampleCsSettings1Command.cs +++ b/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings1/SampleCsSettings1Command.cs @@ -9,8 +9,8 @@ public class SampleCsSettings1Command : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var plugin = SampleCsSettings1PlugIn.Instance; - var value = plugin.Settings.GetInteger("SomeSetting"); + SampleCsSettings1PlugIn plugin = SampleCsSettings1PlugIn.Instance; + int value = plugin.Settings.GetInteger("SomeSetting"); plugin.Settings.SetInteger("SomeSetting", ++value); RhinoApp.WriteLine($"SomeSetting is now {PlugIn.Settings.GetInteger("SomeSetting", -2)}"); plugin.SaveSettings(); diff --git a/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/Properties/AssemblyInfo.cs index 475b9119..051c057a 100644 --- a/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/SampleCsSettings2Command.cs b/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/SampleCsSettings2Command.cs index e23fa443..746bb9f2 100644 --- a/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/SampleCsSettings2Command.cs +++ b/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/SampleCsSettings2Command.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; -using Rhino.Geometry; -using Rhino.Input; -using Rhino.Input.Custom; namespace SampleCsSettings2 { diff --git a/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/SampleCsSettings2PlugIn.cs b/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/SampleCsSettings2PlugIn.cs index 4a06e660..944970c7 100644 --- a/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/SampleCsSettings2PlugIn.cs +++ b/rhinocommon/cs/SampleCsSharedSettings/SampleCsSettings2/SampleCsSettings2PlugIn.cs @@ -1,5 +1,5 @@ -using System; -using Rhino.PlugIns; +using Rhino.PlugIns; +using System; namespace SampleCsSettings2 { @@ -23,7 +23,7 @@ public static SampleCsSettings2PlugIn Instance protected override LoadReturnCode OnLoad(ref string errorMessage) { - var thread = new System.Threading.Thread(LoadAndRegister) { Name = "Registering thread" }; + System.Threading.Thread thread = new System.Threading.Thread(LoadAndRegister) { Name = "Registering thread" }; Rhino.RhinoApp.Initialized += OnRhinoAppInitialized; thread.Start(); return LoadReturnCode.Success; @@ -40,8 +40,8 @@ private void LoadAndRegister() System.Threading.Thread.Sleep(10); // Find SampleCsSettings1 plug-in - var plugin_id = SampleCsSettings1PlugInId; - var plugin = Find(SampleCsSettings1PlugInId); + Guid plugin_id = SampleCsSettings1PlugInId; + PlugIn plugin = Find(SampleCsSettings1PlugInId); if (plugin == null) { if (LoadPlugIn(plugin_id)) @@ -61,10 +61,10 @@ private void OnPlugInSettingsSaved(object sender, Rhino.PersistentSettingsSavedE public void ReadSetting() { // Find SampleCsSettings1 plug-in - var plugin = Find(SampleCsSettings1PlugInId); + PlugIn plugin = Find(SampleCsSettings1PlugInId); if (plugin != null) { - var value = plugin.Settings.GetInteger("SomeSetting", -1); + int value = plugin.Settings.GetInteger("SomeSetting", -1); Rhino.RhinoApp.WriteLine($"Setting from SampleCsSettings1 > {value}"); } } diff --git a/rhinocommon/cs/SampleCsSkin/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsSkin/Properties/AssemblyInfo.cs index 9e766fb2..40214d1a 100644 --- a/rhinocommon/cs/SampleCsSkin/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsSkin/Properties/AssemblyInfo.cs @@ -1,7 +1,6 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional diff --git a/rhinocommon/cs/SampleCsSkin/SampleCsSkinObject.cs b/rhinocommon/cs/SampleCsSkin/SampleCsSkinObject.cs index 9c1d0a5d..02debbe9 100644 --- a/rhinocommon/cs/SampleCsSkin/SampleCsSkinObject.cs +++ b/rhinocommon/cs/SampleCsSkin/SampleCsSkinObject.cs @@ -25,7 +25,7 @@ protected override Bitmap MainRhinoIcon { get { - var icon = new Icon(Properties.Resources.SampleCsSkin, new Size(32, 32)); + Icon icon = new Icon(Properties.Resources.SampleCsSkin, new Size(32, 32)); return icon.ToBitmap(); } } @@ -34,13 +34,13 @@ protected override void ShowSplash() { m_splash = new SampleCsSplashScreen(); - var thread = new Thread(ShowSplashScreen); + Thread thread = new Thread(ShowSplashScreen); thread.Start(); - var worker = new SampleCsSplashScreenWorker(); + SampleCsSplashScreenWorker worker = new SampleCsSplashScreenWorker(); worker.ProgressChanged += (o, ex) => { - if (null != m_splash) + if (null != m_splash) m_splash.UpdateProgress(ex.Progress); }; @@ -55,7 +55,7 @@ protected override void ShowSplash() private void ShowSplashScreen() { m_splash.Show(); - + while (!m_done) { Application.DoEvents(); diff --git a/rhinocommon/cs/SampleCsSkin/SampleCsSplashScreenWorker.cs b/rhinocommon/cs/SampleCsSkin/SampleCsSplashScreenWorker.cs index 68e4eeef..2da3e53f 100644 --- a/rhinocommon/cs/SampleCsSkin/SampleCsSplashScreenWorker.cs +++ b/rhinocommon/cs/SampleCsSkin/SampleCsSplashScreenWorker.cs @@ -11,9 +11,9 @@ public class SampleCsSplashScreenWorker public void DoHardWork() { // Do something time consuming... - for (var i = 1; i <= 100; i++) + for (int i = 1; i <= 100; i++) { - for (var j = 1; j <= 100000; j++) + for (int j = 1; j <= 100000; j++) { Thread.Sleep(0); } @@ -25,7 +25,7 @@ public void DoHardWork() private void OnProgressChanged(int progress) { - var handler = ProgressChanged; + EventHandler handler = ProgressChanged; if (handler != null) { handler(this, new SplashScreenWorkerArgs(progress)); @@ -34,7 +34,7 @@ private void OnProgressChanged(int progress) private void OnWorkerDone() { - var handler = HardWorkDone; + EventHandler handler = HardWorkDone; if (handler != null) { handler(this, EventArgs.Empty); diff --git a/rhinocommon/cs/SampleCsSnapshotsClient/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsSnapshotsClient/Properties/AssemblyInfo.cs index 2862deb2..151aacc0 100644 --- a/rhinocommon/cs/SampleCsSnapshotsClient/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsSnapshotsClient/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsSnapshotsClient/SampleCsSnapshotsClientCommand.cs b/rhinocommon/cs/SampleCsSnapshotsClient/SampleCsSnapshotsClientCommand.cs index 6cc65f21..17415345 100644 --- a/rhinocommon/cs/SampleCsSnapshotsClient/SampleCsSnapshotsClientCommand.cs +++ b/rhinocommon/cs/SampleCsSnapshotsClient/SampleCsSnapshotsClientCommand.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.Commands; -using Rhino.Geometry; -using Rhino.Input; -using Rhino.Input.Custom; namespace SampleCsSnapshotsClient { diff --git a/rhinocommon/cs/SampleCsSnapshotsClient/SampleCsSnapshotsClientPlugIn.cs b/rhinocommon/cs/SampleCsSnapshotsClient/SampleCsSnapshotsClientPlugIn.cs index 09fa1975..3b0df652 100644 --- a/rhinocommon/cs/SampleCsSnapshotsClient/SampleCsSnapshotsClientPlugIn.cs +++ b/rhinocommon/cs/SampleCsSnapshotsClient/SampleCsSnapshotsClientPlugIn.cs @@ -27,6 +27,6 @@ public static SampleCsSnapshotsClientPlugIn Instance // You can override methods here to change the plug-in behavior on // loading and shut down, add options pages to the Rhino _Option command // and maintain plug-in wide options in a document. - + } } \ No newline at end of file diff --git a/rhinocommon/cs/SampleCsSnapshotsClient/SampleSnapShotClient.cs b/rhinocommon/cs/SampleCsSnapshotsClient/SampleSnapShotClient.cs index a6df10d9..143adbd1 100644 --- a/rhinocommon/cs/SampleCsSnapshotsClient/SampleSnapShotClient.cs +++ b/rhinocommon/cs/SampleCsSnapshotsClient/SampleSnapShotClient.cs @@ -1,9 +1,9 @@ -using System; -using Rhino; +using Rhino; using Rhino.DocObjects; using Rhino.FileIO; using Rhino.Geometry; using Rhino.Runtime.InteropWrappers; +using System; namespace SampleCsSnapshotsClient { @@ -144,10 +144,10 @@ public override bool IsCurrentModelStateInAnySnapshot(RhinoDoc doc, BinaryArchiv { throw new NotImplementedException(); } - + public override bool IsCurrentModelStateInAnySnapshot(RhinoDoc doc, RhinoObject doc_object, BinaryArchiveReader archive, SimpleArrayBinaryArchiveReader archive_array, TextLog text_log = null) { - var userdata = archive.ReadDictionary(); + Rhino.Collections.ArchivableDictionary userdata = archive.ReadDictionary(); string name = ""; if (!userdata.TryGetString("ObjName", out name)) @@ -155,8 +155,8 @@ public override bool IsCurrentModelStateInAnySnapshot(RhinoDoc doc, RhinoObject for (int i = 0; i < archive_array.Count; i++) { - var ba = archive_array.Get(i); - var ud = ba.ReadDictionary(); + BinaryArchiveReader ba = archive_array.Get(i); + Rhino.Collections.ArchivableDictionary ud = ba.ReadDictionary(); string s = ""; diff --git a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddBrepFaceUserData.cs b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddBrepFaceUserData.cs index f7d36b46..b72441e9 100644 --- a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddBrepFaceUserData.cs +++ b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddBrepFaceUserData.cs @@ -15,7 +15,7 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Allow for picking of either a surface or a brep face - var go = new GetObject(); + GetObject go = new GetObject(); go.SetCommandPrompt("Select surface to attach data"); go.GeometryFilter = ObjectType.Surface; go.SubObjectSelect = true; @@ -25,32 +25,32 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) // Get first object reference. Note, this reference represents the picked // surface or face, not the top level brep. - var obj_ref = go.Object(0); + ObjRef obj_ref = go.Object(0); // Get brep face that was picked - var face = obj_ref.Face(); + Rhino.Geometry.BrepFace face = obj_ref.Face(); if (null == face) return Result.Failure; // Since the object reference only represents the picked surface or face, // we need to get the owning brep from the Rhino object. - var brep_object = obj_ref.Object() as BrepObject; + BrepObject brep_object = obj_ref.Object() as BrepObject; if (null == brep_object) return Result.Failure; // Get the brep object's brep geometry - var brep = brep_object.BrepGeometry; + Rhino.Geometry.Brep brep = brep_object.BrepGeometry; if (null == brep) return Result.Failure; // Get the brep face's underlying surface - var surface_index = face.SurfaceIndex; - var srf = brep.Surfaces[surface_index]; + int surface_index = face.SurfaceIndex; + Rhino.Geometry.Surface srf = brep.Surfaces[surface_index]; if (null == srf) return Result.Failure; // Query the surface for user data - var ud = srf.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; + SampleCsUserDataObject ud = srf.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; if (null != ud) { RhinoApp.WriteLine("{0} = {1}", ud.Description, ud.Notes); @@ -58,14 +58,14 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) } // Prompt for a string - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Surface notes"); gs.GetLiteralString(); if (gs.CommandResult() != Result.Success) return gs.CommandResult(); // Duplicate the brep - var new_brep = brep.DuplicateBrep(); + Rhino.Geometry.Brep new_brep = brep.DuplicateBrep(); if (null != new_brep) { // Get the brep face's underlying surface diff --git a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddGroupUserData.cs b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddGroupUserData.cs index 0cb66841..85a5cc92 100644 --- a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddGroupUserData.cs +++ b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddGroupUserData.cs @@ -9,14 +9,14 @@ public class SampleCsAddGroupUserData : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var group = doc.Groups.FindIndex(0); + Rhino.DocObjects.Group group = doc.Groups.FindIndex(0); if (null == group) { RhinoApp.WriteLine("No groups found in the document."); return Result.Success; } - var ud = group.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; + SampleCsUserDataObject ud = group.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; if (null == ud) { ud = new SampleCsUserDataObject { Notes = "Hello Rhino Group!" }; diff --git a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddLayerUserData.cs b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddLayerUserData.cs index 974e532c..f09ad038 100644 --- a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddLayerUserData.cs +++ b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddLayerUserData.cs @@ -13,21 +13,21 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var layer_index = doc.Layers.FindByFullPath("Default", Rhino.RhinoMath.UnsetIntIndex); + int layer_index = doc.Layers.FindByFullPath("Default", Rhino.RhinoMath.UnsetIntIndex); if (layer_index < 0) { RhinoApp.WriteLine("Default layer not found."); return Result.Nothing; } - var layer = doc.Layers[layer_index]; + Rhino.DocObjects.Layer layer = doc.Layers[layer_index]; if (null == layer) return Result.Failure; - var ud = layer.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; + SampleCsUserDataObject ud = layer.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; if (null == ud) { - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Layer notes"); gs.GetLiteralString(); if (gs.CommandResult() != Result.Success) diff --git a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddSimpleDocumentData.cs b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddSimpleDocumentData.cs index e1a4a303..a31099a9 100644 --- a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddSimpleDocumentData.cs +++ b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddSimpleDocumentData.cs @@ -13,19 +13,19 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var data_table = SampleCsUserDataPlugIn.Instance.SimpleDocumentDataTable; + SampleCsSimpleDocumentDataTable data_table = SampleCsUserDataPlugIn.Instance.SimpleDocumentDataTable; if (0 == data_table.Count) { - var number = 6; - var rc = RhinoGet.GetInteger("Number of data objects to create", true, ref number, 1, 100); + int number = 6; + Result rc = RhinoGet.GetInteger("Number of data objects to create", true, ref number, 1, 100); if (rc != Result.Success) return rc; - for (var i = 0; i < number; i++) + for (int i = 0; i < number; i++) data_table.Add(new SampleCsSimpleDocumentData()); } - for (var i = 0; i < data_table.Count; i++) + for (int i = 0; i < data_table.Count; i++) RhinoApp.WriteLine("Data[{0}] = {1}", i, data_table[i].Value); return Result.Success; diff --git a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddUserData.cs b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddUserData.cs index d2f05fad..7019e7a4 100644 --- a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddUserData.cs +++ b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsAddUserData.cs @@ -14,24 +14,24 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { const ObjectType filter = ObjectType.AnyObject; ObjRef objref; - var rc = RhinoGet.GetOneObject("Select object", false, filter, out objref); + Result rc = RhinoGet.GetOneObject("Select object", false, filter, out objref); if (rc != Result.Success || null == objref) return rc; - var obj = objref.Object(); + RhinoObject obj = objref.Object(); if (null == obj) return Result.Failure; - var ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; + SampleCsUserDataObject ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; if (null == ud) { - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Object notes"); gs.GetLiteralString(); if (gs.CommandResult() != Result.Success) return gs.CommandResult(); - ud = new SampleCsUserDataObject + ud = new SampleCsUserDataObject { Notes = gs.StringResult() }; diff --git a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsModifyUserData.cs b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsModifyUserData.cs index 9944c3cf..086f0366 100644 --- a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsModifyUserData.cs +++ b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsModifyUserData.cs @@ -17,18 +17,18 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { const ObjectType filter = ObjectType.AnyObject; ObjRef objref; - var rc = RhinoGet.GetOneObject("Select object", false, filter, out objref); + Result rc = RhinoGet.GetOneObject("Select object", false, filter, out objref); if (rc != Result.Success || null == objref) return rc; - var obj = objref.Object(); + RhinoObject obj = objref.Object(); if (null == obj) return Result.Failure; - var ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; + SampleCsUserDataObject ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; if (null != ud) { - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("Modify object notes"); gs.GetLiteralString(); if (gs.CommandResult() != Result.Success) diff --git a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsQueryLayerUserData.cs b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsQueryLayerUserData.cs index 5ad958dc..eb3279c3 100644 --- a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsQueryLayerUserData.cs +++ b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsQueryLayerUserData.cs @@ -12,18 +12,18 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var layer_index = doc.Layers.FindByFullPath("Default", Rhino.RhinoMath.UnsetIntIndex); + int layer_index = doc.Layers.FindByFullPath("Default", Rhino.RhinoMath.UnsetIntIndex); if (layer_index < 0) { RhinoApp.WriteLine("Default layer not found."); return Result.Nothing; } - var layer = doc.Layers[layer_index]; + Rhino.DocObjects.Layer layer = doc.Layers[layer_index]; if (null == layer) return Result.Failure; - var ud = layer.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; + SampleCsUserDataObject ud = layer.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; if (null != ud) RhinoApp.WriteLine("{0} = {1}", ud.Description, ud.Notes); else diff --git a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsQueryUserData.cs b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsQueryUserData.cs index 0b64def6..85c9fb56 100644 --- a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsQueryUserData.cs +++ b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsQueryUserData.cs @@ -16,7 +16,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { const ObjectType filter = ObjectType.AnyObject; ObjRef objref; - var rc = RhinoGet.GetOneObject("Select object", false, filter, out objref); + Result rc = RhinoGet.GetOneObject("Select object", false, filter, out objref); if (rc != Result.Success || null == objref) return rc; @@ -24,7 +24,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) if (null == obj) return Result.Failure; - var ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; + SampleCsUserDataObject ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; if (null != ud) RhinoApp.WriteLine("{0} = {1}", ud.Description, ud.Notes); else diff --git a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsRemoveUserData.cs b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsRemoveUserData.cs index ec72a026..a146dfa4 100644 --- a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsRemoveUserData.cs +++ b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsRemoveUserData.cs @@ -16,15 +16,15 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) { const ObjectType filter = ObjectType.AnyObject; ObjRef objref; - var rc = RhinoGet.GetOneObject("Select object", false, filter, out objref); + Result rc = RhinoGet.GetOneObject("Select object", false, filter, out objref); if (rc != Result.Success || null == objref) return rc; - var obj = objref.Object(); + RhinoObject obj = objref.Object(); if (null == obj) return Result.Failure; - var ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; + SampleCsUserDataObject ud = obj.Attributes.UserData.Find(typeof(SampleCsUserDataObject)) as SampleCsUserDataObject; if (null != ud) obj.Attributes.UserData.Remove(ud); diff --git a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsStringTable.cs b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsStringTable.cs index 8e6fcede..8fca0482 100644 --- a/rhinocommon/cs/SampleCsUserData/Commands/SampleCsStringTable.cs +++ b/rhinocommon/cs/SampleCsUserData/Commands/SampleCsStringTable.cs @@ -21,27 +21,27 @@ private enum OptionIndex protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var go = new GetOption(); + GetOption go = new GetOption(); go.SetCommandPrompt("Choose an option"); go.AddOption("Add"); go.AddOption("Delete"); go.AddOption("List"); go.AcceptNothing(true); - var res = go.Get(); + GetResult res = go.Get(); Result rc; switch (res) { - case GetResult.Option: - rc = CommandOption(go.Option()); - break; - case GetResult.Nothing: - rc = Result.Success; - break; - default: - rc = Result.Cancel; - break; + case GetResult.Option: + rc = CommandOption(go.Option()); + break; + case GetResult.Nothing: + rc = Result.Success; + break; + default: + rc = Result.Cancel; + break; } return rc; @@ -67,7 +67,7 @@ protected Result CommandOption(CommandLineOption option) protected Result AddOption() { - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("String to add"); gs.AcceptNothing(true); switch (gs.Get()) @@ -80,11 +80,11 @@ protected Result AddOption() return Result.Cancel; } - var str = gs.StringResult().Trim(); + string str = gs.StringResult().Trim(); if (string.IsNullOrEmpty(str)) return Result.Nothing; - var plugin = SampleCsUserDataPlugIn.Instance; + SampleCsUserDataPlugIn plugin = SampleCsUserDataPlugIn.Instance; if (plugin.StringDocumentDataTable.Add(str) < 0) RhinoApp.WriteLine("Unable to add string."); @@ -93,7 +93,7 @@ protected Result AddOption() protected Result DeleteOption() { - var gs = new GetString(); + GetString gs = new GetString(); gs.SetCommandPrompt("String to delete"); switch (gs.Get()) { @@ -105,11 +105,11 @@ protected Result DeleteOption() return Result.Cancel; } - var str = gs.StringResult().Trim(); + string str = gs.StringResult().Trim(); if (string.IsNullOrEmpty(str)) return Result.Nothing; - var plugin = SampleCsUserDataPlugIn.Instance; + SampleCsUserDataPlugIn plugin = SampleCsUserDataPlugIn.Instance; if (!plugin.StringDocumentDataTable.Delete(str)) RhinoApp.WriteLine("Unable to delete string."); @@ -118,8 +118,8 @@ protected Result DeleteOption() protected Result ListOption() { - var plugin = SampleCsUserDataPlugIn.Instance; - for (var i = 0; i < plugin.StringDocumentDataTable.Count; i++) + SampleCsUserDataPlugIn plugin = SampleCsUserDataPlugIn.Instance; + for (int i = 0; i < plugin.StringDocumentDataTable.Count; i++) RhinoApp.WriteLine(plugin.StringDocumentDataTable.Item(i)); return Result.Success; } diff --git a/rhinocommon/cs/SampleCsUserData/SampleCsSimpleDocumentData.cs b/rhinocommon/cs/SampleCsUserData/SampleCsSimpleDocumentData.cs index 4889abdd..83ea3116 100644 --- a/rhinocommon/cs/SampleCsUserData/SampleCsSimpleDocumentData.cs +++ b/rhinocommon/cs/SampleCsUserData/SampleCsSimpleDocumentData.cs @@ -1,6 +1,6 @@ -using System; +using Rhino.FileIO; +using System; using System.Collections.Generic; -using Rhino.FileIO; namespace SampleCsUserData { @@ -33,7 +33,7 @@ public SampleCsSimpleDocumentData() /// public bool Write(BinaryArchiveWriter archive) { - var rc = false; + bool rc = false; if (null != archive) { try @@ -55,12 +55,12 @@ public bool Write(BinaryArchiveWriter archive) /// public bool Read(BinaryArchiveReader archive) { - var rc = false; + bool rc = false; if (null != archive) { try { - archive.Read3dmChunkVersion(out var major, out var minor); + archive.Read3dmChunkVersion(out int major, out int minor); if (major == MAJOR && minor == MINOR) { Value = archive.ReadInt(); @@ -92,14 +92,14 @@ public class SampleCsSimpleDocumentDataTable : List /// public bool WriteDocument(BinaryArchiveWriter archive) { - var rc = false; + bool rc = false; if (null != archive) { try { archive.Write3dmChunkVersion(MAJOR, MINOR); archive.WriteInt(Count); - for (var i = 0; i < Count; i++) + for (int i = 0; i < Count; i++) this[i].Write(archive); rc = archive.WriteErrorOccured; } @@ -116,18 +116,18 @@ public bool WriteDocument(BinaryArchiveWriter archive) /// public bool ReadDocument(BinaryArchiveReader archive) { - var rc = false; + bool rc = false; if (null != archive) { try { - archive.Read3dmChunkVersion(out var major, out var minor); + archive.Read3dmChunkVersion(out int major, out int minor); if (major == MAJOR && minor == MINOR) { - var count = archive.ReadInt(); - for (var i = 0; i < count; i++) + int count = archive.ReadInt(); + for (int i = 0; i < count; i++) { - var data = new SampleCsSimpleDocumentData(); + SampleCsSimpleDocumentData data = new SampleCsSimpleDocumentData(); if (data.Read(archive)) Add(data); } diff --git a/rhinocommon/cs/SampleCsUserData/SampleCsStringDocumentData.cs b/rhinocommon/cs/SampleCsUserData/SampleCsStringDocumentData.cs index e0faf1a3..07171332 100644 --- a/rhinocommon/cs/SampleCsUserData/SampleCsStringDocumentData.cs +++ b/rhinocommon/cs/SampleCsUserData/SampleCsStringDocumentData.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using Rhino.FileIO; +using Rhino.FileIO; +using System.Collections.Generic; namespace SampleCsUserData { @@ -131,10 +131,10 @@ public void WriteDocument(BinaryArchiveWriter archive) /// public void ReadDocument(BinaryArchiveReader archive) { - archive.Read3dmChunkVersion(out var major, out var minor); + archive.Read3dmChunkVersion(out int major, out int minor); if (MAJOR == major && MINOR == minor) { - var string_table = archive.ReadStringArray(); + string[] string_table = archive.ReadStringArray(); if (null != string_table) m_string_table.AddRange(string_table); } diff --git a/rhinocommon/cs/SampleCsUserData/SampleCsUserDataObject.cs b/rhinocommon/cs/SampleCsUserData/SampleCsUserDataObject.cs index c014f98c..202b4ed8 100644 --- a/rhinocommon/cs/SampleCsUserData/SampleCsUserDataObject.cs +++ b/rhinocommon/cs/SampleCsUserData/SampleCsUserDataObject.cs @@ -69,7 +69,7 @@ protected override void OnDuplicate(UserData source) protected override bool Read(BinaryArchiveReader archive) { // Read the chuck version - archive.Read3dmChunkVersion(out var major, out var minor); + archive.Read3dmChunkVersion(out int major, out int minor); if (major == MAJOR_VERSION) { // Read 1.0 fields here diff --git a/rhinocommon/cs/SampleCsUserData/SampleCsUserDataPlugIn.cs b/rhinocommon/cs/SampleCsUserData/SampleCsUserDataPlugIn.cs index 4fe8e72c..3885e3ff 100644 --- a/rhinocommon/cs/SampleCsUserData/SampleCsUserDataPlugIn.cs +++ b/rhinocommon/cs/SampleCsUserData/SampleCsUserDataPlugIn.cs @@ -90,18 +90,18 @@ protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, /// protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options) { - archive.Read3dmChunkVersion(out var major, out var minor); + archive.Read3dmChunkVersion(out int major, out int minor); if (MAJOR == major && MINOR == minor) { // Always read user data even though you might not use it. - var string_table = new SampleCsStringDocumentData(); + SampleCsStringDocumentData string_table = new SampleCsStringDocumentData(); string_table.ReadDocument(archive); - var simple_table = new SampleCsSimpleDocumentDataTable(); + SampleCsSimpleDocumentDataTable simple_table = new SampleCsSimpleDocumentDataTable(); simple_table.ReadDocument(archive); - var dictionary = archive.ReadDictionary(); + ArchivableDictionary dictionary = archive.ReadDictionary(); if (!options.ImportMode && !options.ImportReferenceMode) { diff --git a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/CollapsibleSectionUIPanel.cs b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/CollapsibleSectionUIPanel.cs index 2496a9e5..0247c517 100644 --- a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/CollapsibleSectionUIPanel.cs +++ b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/CollapsibleSectionUIPanel.cs @@ -1,5 +1,5 @@ -using Rhino.UI.Controls; -using Eto.Forms; +using Eto.Forms; +using Rhino.UI.Controls; namespace SampleViewportPropertiesETOUI { diff --git a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/Properties/AssemblyInfo.cs index cf995aa6..f0b4d33f 100644 --- a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional diff --git a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SampleViewportPropertiesETOUIPlugIn.cs b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SampleViewportPropertiesETOUIPlugIn.cs index 33592d78..9a9dfbd3 100644 --- a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SampleViewportPropertiesETOUIPlugIn.cs +++ b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SampleViewportPropertiesETOUIPlugIn.cs @@ -1,7 +1,6 @@ using Rhino; using Rhino.Commands; using Rhino.UI; -using System.Collections.Generic; namespace SampleViewportPropertiesETOUI { diff --git a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SectionOne.cs b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SectionOne.cs index 9f7207f3..bf521d13 100644 --- a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SectionOne.cs +++ b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SectionOne.cs @@ -1,6 +1,6 @@ -using System; -using Eto.Forms; +using Eto.Forms; using Rhino.UI; +using System; namespace SampleViewportPropertiesETOUI { diff --git a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SectionTwo.cs b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SectionTwo.cs index aabb4326..ab77a04c 100644 --- a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SectionTwo.cs +++ b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/SectionTwo.cs @@ -1,6 +1,6 @@ -using System; -using Eto.Forms; +using Eto.Forms; using Rhino.UI; +using System; namespace SampleViewportPropertiesETOUI { diff --git a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/ViewportPropertiesPage.cs b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/ViewportPropertiesPage.cs index 81a520ca..876260f1 100644 --- a/rhinocommon/cs/SampleCsViewportPropertiesETOUI/ViewportPropertiesPage.cs +++ b/rhinocommon/cs/SampleCsViewportPropertiesETOUI/ViewportPropertiesPage.cs @@ -1,83 +1,77 @@ -using System; -using Rhino; -using Rhino.Commands; -using Rhino.UI.Controls; -using Eto.Forms; +using Rhino.DocObjects; using Rhino.UI; using System.Drawing; -using Rhino.Display; -using Rhino.DocObjects; namespace SampleViewportPropertiesETOUI { - public class ViewportPropertiesPage : ObjectPropertiesPage - { + public class ViewportPropertiesPage : ObjectPropertiesPage + { - public ViewportPropertiesPage() - { + public ViewportPropertiesPage() + { - } + } - public override string EnglishPageTitle => "Viewport"; + public override string EnglishPageTitle => "Viewport"; - // If no icon then the Title will be displayed in the Tab - public override System.Drawing.Icon PageIcon(Size size) - { - return null; - } + // If no icon then the Title will be displayed in the Tab + public override System.Drawing.Icon PageIcon(Size size) + { + return null; + } - public override PropertyPageType PageType => PropertyPageType.View; + public override PropertyPageType PageType => PropertyPageType.View; - public sealed override object PageControl + public sealed override object PageControl + { + get + { + if (CollapsibleSectionHolder == null) { - get - { - if (CollapsibleSectionHolder == null) - { - CollapsibleSectionHolder = NewPanel(); - } - return CollapsibleSectionHolder; - } + CollapsibleSectionHolder = NewPanel(); } + return CollapsibleSectionHolder; + } + } - public override bool ShouldDisplay(ObjectPropertiesPageEventArgs e) - { - if (e.View == null) - { - if (CollapsibleSectionHolder == null) - return false; + public override bool ShouldDisplay(ObjectPropertiesPageEventArgs e) + { + if (e.View == null) + { + if (CollapsibleSectionHolder == null) + return false; - // Update page here and tell it no view - // is selected. + // Update page here and tell it no view + // is selected. - return false; - } + return false; + } - return true; - } + return true; + } - public override void UpdatePage(ObjectPropertiesPageEventArgs e) - { - if (CollapsibleSectionHolder == null) - return; - - ViewInfo vi = new ViewInfo(e.Viewport); - - if (vi != null) - { - // Pass the view info to the page - } - else - { - // Tell the ui that there is no view. - } - } + public override void UpdatePage(ObjectPropertiesPageEventArgs e) + { + if (CollapsibleSectionHolder == null) + return; + + ViewInfo vi = new ViewInfo(e.Viewport); + + if (vi != null) + { + // Pass the view info to the page + } + else + { + // Tell the ui that there is no view. + } + } - private uint[] m_selected_serial_numbers = { }; - private CollapsibleSectionUIPanel m_page; - private CollapsibleSectionUIPanel CollapsibleSectionHolder { get { return m_page; } set { m_page = value; } } + private uint[] m_selected_serial_numbers = { }; + private CollapsibleSectionUIPanel m_page; + private CollapsibleSectionUIPanel CollapsibleSectionHolder { get { return m_page; } set { m_page = value; } } - private CollapsibleSectionUIPanel NewPanel() => new CollapsibleSectionUIPanel(); - } + private CollapsibleSectionUIPanel NewPanel() => new CollapsibleSectionUIPanel(); + } } diff --git a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsFibonacciCommand.cs b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsFibonacciCommand.cs index e7570dbe..4f7d2097 100644 --- a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsFibonacciCommand.cs +++ b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsFibonacciCommand.cs @@ -1,7 +1,7 @@ -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using SampleCsWinForms.Forms; +using System.Windows.Forms; namespace SampleCsWinForms.Commands { @@ -15,7 +15,7 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var form = new SampleCsFibonacciForm {StartPosition = FormStartPosition.CenterParent}; + SampleCsFibonacciForm form = new SampleCsFibonacciForm { StartPosition = FormStartPosition.CenterParent }; form.ShowDialog(); return Result.Success; } diff --git a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModalFormCommand.cs b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModalFormCommand.cs index a3197154..47448e37 100644 --- a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModalFormCommand.cs +++ b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModalFormCommand.cs @@ -1,7 +1,7 @@ -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using RhinoWindows; +using System.Windows.Forms; namespace SampleCsWinForms.Commands { @@ -15,18 +15,18 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var rc = Result.Cancel; + Result rc = Result.Cancel; if (mode == RunMode.Interactive) { - var form = new Forms.SampleCsModalForm { StartPosition = FormStartPosition.CenterParent }; - var dialog_result = form.ShowDialog(RhinoWinApp.MainWindow); + Forms.SampleCsModalForm form = new Forms.SampleCsModalForm { StartPosition = FormStartPosition.CenterParent }; + DialogResult dialog_result = form.ShowDialog(RhinoWinApp.MainWindow); if (dialog_result == DialogResult.OK) rc = Result.Success; } else { - var msg = string.Format("Scriptable version of {0} command not implemented.", EnglishName); + string msg = string.Format("Scriptable version of {0} command not implemented.", EnglishName); RhinoApp.WriteLine(msg); } diff --git a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModelessFormCommand.cs b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModelessFormCommand.cs index eaaecede..c955b518 100644 --- a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModelessFormCommand.cs +++ b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModelessFormCommand.cs @@ -1,7 +1,7 @@ -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using RhinoWindows; +using System.Windows.Forms; namespace SampleCsWinForms.Commands { diff --git a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModelessTabFormCommand.cs b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModelessTabFormCommand.cs index ddfe7746..215ca862 100644 --- a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModelessTabFormCommand.cs +++ b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsModelessTabFormCommand.cs @@ -1,7 +1,7 @@ -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using RhinoWindows; +using System.Windows.Forms; namespace SampleCsWinForms.Commands { diff --git a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsPanelCommand.cs b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsPanelCommand.cs index d857dbb8..709d7660 100644 --- a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsPanelCommand.cs +++ b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsPanelCommand.cs @@ -12,28 +12,28 @@ public class SampleCsPanelCommand : Command protected override Result RunCommand(Rhino.RhinoDoc doc, RunMode mode) { - var panel_id = SampleCsPanelUserControl.PanelId; - var visible = Panels.IsPanelVisible(panel_id); + System.Guid panel_id = SampleCsPanelUserControl.PanelId; + bool visible = Panels.IsPanelVisible(panel_id); - var prompt = visible + string prompt = visible ? "Sample panel is visible. New value" : "Sample Manager panel is hidden. New value"; - var go = new GetOption(); + GetOption go = new GetOption(); go.SetCommandPrompt(prompt); - var hide_index = go.AddOption("Hide"); - var show_index = go.AddOption("Show"); - var toggle_index = go.AddOption("Toggle"); + int hide_index = go.AddOption("Hide"); + int show_index = go.AddOption("Show"); + int toggle_index = go.AddOption("Toggle"); go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var option = go.Option(); + CommandLineOption option = go.Option(); if (null == option) return Result.Failure; - var index = option.Index; + int index = option.Index; if (index == hide_index) { diff --git a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsSemiModalFormCommand.cs b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsSemiModalFormCommand.cs index 68031c89..76c6a215 100644 --- a/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsSemiModalFormCommand.cs +++ b/rhinocommon/cs/SampleCsWinForms/Commands/SampleCsSemiModalFormCommand.cs @@ -1,8 +1,8 @@ -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.Commands; using RhinoWindows; using RhinoWindows.Forms; +using System.Windows.Forms; namespace SampleCsWinForms.Commands { @@ -16,18 +16,18 @@ public override string EnglishName protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var result = Result.Cancel; + Result result = Result.Cancel; if (mode == RunMode.Interactive) { - var form = new Forms.SampleCsModalForm { StartPosition = FormStartPosition.CenterParent }; - var dialog_result = form.ShowSemiModal(RhinoWinApp.MainWindow); + Forms.SampleCsModalForm form = new Forms.SampleCsModalForm { StartPosition = FormStartPosition.CenterParent }; + DialogResult dialog_result = form.ShowSemiModal(RhinoWinApp.MainWindow); if (dialog_result == DialogResult.OK) result = Result.Success; } else { - var msg = string.Format("Scriptable version of {0} command not implemented.", EnglishName); + string msg = string.Format("Scriptable version of {0} command not implemented.", EnglishName); RhinoApp.WriteLine(msg); } diff --git a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsDocPropertiesPage.cs b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsDocPropertiesPage.cs index 2da1a000..31b6b8be 100644 --- a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsDocPropertiesPage.cs +++ b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsDocPropertiesPage.cs @@ -1,5 +1,4 @@ -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.UI; namespace SampleCsWinForms.Forms diff --git a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsDocPropertiesUserControl.cs b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsDocPropertiesUserControl.cs index c665e3e8..c11fc8ff 100644 --- a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsDocPropertiesUserControl.cs +++ b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsDocPropertiesUserControl.cs @@ -1,5 +1,5 @@ -using System.Windows.Forms; -using Rhino; +using Rhino; +using System.Windows.Forms; namespace SampleCsWinForms.Forms { diff --git a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsFibonacciForm.cs b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsFibonacciForm.cs index 6101babd..5f81db8b 100644 --- a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsFibonacciForm.cs +++ b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsFibonacciForm.cs @@ -67,7 +67,7 @@ private void OnCancelButtonClick(System.Object sender, System.EventArgs e) private void DoWork(object sender, DoWorkEventArgs e) { // Get the BackgroundWorker that raised this event. - var worker = sender as BackgroundWorker; + BackgroundWorker worker = sender as BackgroundWorker; // Assign the result of the computation to the Result property of the DoWorkEventArgs // object. This is will be available to the RunWorkerCompleted eventhandler. @@ -148,7 +148,7 @@ private long ComputeFibonacci(int n, BackgroundWorker worker, DoWorkEventArgs e) result = ComputeFibonacci(n - 1, worker, e) + ComputeFibonacci(n - 2, worker, e); // Report progress as a percentage of the total task. - var percent_complete = (int)(n / (float)m_number_to_compute * 100); + int percent_complete = (int)(n / (float)m_number_to_compute * 100); if (percent_complete > m_highest_percentage_reached) { m_highest_percentage_reached = percent_complete; diff --git a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsModalForm.cs b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsModalForm.cs index c1d9f3a0..d8ffb81a 100644 --- a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsModalForm.cs +++ b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsModalForm.cs @@ -1,8 +1,8 @@ -using System; +using Rhino; +using Rhino.Geometry; +using System; using System.Runtime.InteropServices; using System.Windows.Forms; -using Rhino; -using Rhino.Geometry; namespace SampleCsWinForms.Forms { diff --git a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsModelessTabFix.cs b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsModelessTabFix.cs index ea330dda..0bfb2b69 100644 --- a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsModelessTabFix.cs +++ b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsModelessTabFix.cs @@ -68,7 +68,7 @@ private bool LoadControlsTabIndices(IEnumerable controls) { if (!(ctrl is ContainerControl) && !(ctrl is GroupBox) && !(ctrl is Panel)) { - var index = ctrl.TabIndex; + int index = ctrl.TabIndex; while (m_controls.ContainsKey(index)) ++index; m_controls.Add(index, ctrl); @@ -92,7 +92,7 @@ private Control GetActiveControl() { if (null != m_form.ActiveControl) { - var ctrl = m_form.ActiveControl; + Control ctrl = m_form.ActiveControl; while (ctrl is ContainerControl container) ctrl = container.ActiveControl; return ctrl; @@ -126,7 +126,7 @@ private Control NextControl { get { - var ctrl = GetActiveControl(); + Control ctrl = GetActiveControl(); if (m_enumerator.Current.Value != ctrl) InitializeControlEnumerator(ctrl); diff --git a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsObjectPropertiesPage.cs b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsObjectPropertiesPage.cs index c467a853..07408cde 100644 --- a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsObjectPropertiesPage.cs +++ b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsObjectPropertiesPage.cs @@ -1,7 +1,6 @@ -using System.Drawing; -using System.Windows.Forms; -using Rhino.DocObjects; +using Rhino.DocObjects; using Rhino.UI; +using System.Drawing; namespace SampleCsWinForms.Forms { @@ -11,7 +10,7 @@ class SampleCsObjectPropertiesPage : ObjectPropertiesPage public override System.Drawing.Icon PageIcon(System.Drawing.Size sizeInPixels) { - var icon = Rhino.UI.DrawingUtilities.LoadIconWithScaleDown( + Icon icon = Rhino.UI.DrawingUtilities.LoadIconWithScaleDown( "SampleCsWinForms.Resources.Property.ico", sizeInPixels.Width, GetType().Assembly); @@ -24,7 +23,7 @@ public override System.Drawing.Icon PageIcon(System.Drawing.Size sizeInPixels) public override bool ShouldDisplay(ObjectPropertiesPageEventArgs e) { - var rc = false; + bool rc = false; // One object selected if (1 == e.ObjectCount) { @@ -33,7 +32,7 @@ public override bool ShouldDisplay(ObjectPropertiesPageEventArgs e) else { // Multiple objects selected - foreach (var rh_obj in e.Objects) + foreach (RhinoObject rh_obj in e.Objects) { rc = true; break; diff --git a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsOptionsPage.cs b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsOptionsPage.cs index d8203865..dd801d6d 100644 --- a/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsOptionsPage.cs +++ b/rhinocommon/cs/SampleCsWinForms/Forms/SampleCsOptionsPage.cs @@ -1,5 +1,4 @@ -using System.Windows.Forms; -using Rhino; +using Rhino; using Rhino.UI; namespace SampleCsWinForms.Forms diff --git a/rhinocommon/cs/SampleCsWinForms/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsWinForms/Properties/AssemblyInfo.cs index 35e3948b..7955489e 100644 --- a/rhinocommon/cs/SampleCsWinForms/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsWinForms/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsWinForms/SampleCsWinFormsPlugIn.cs b/rhinocommon/cs/SampleCsWinForms/SampleCsWinFormsPlugIn.cs index cb519547..d14951ea 100644 --- a/rhinocommon/cs/SampleCsWinForms/SampleCsWinFormsPlugIn.cs +++ b/rhinocommon/cs/SampleCsWinForms/SampleCsWinFormsPlugIn.cs @@ -1,8 +1,8 @@ -using System.Collections.Generic; -using Rhino; +using Rhino; using Rhino.PlugIns; using Rhino.UI; using SampleCsWinForms.Forms; +using System.Collections.Generic; namespace SampleCsWinForms { @@ -28,26 +28,26 @@ public SampleCsWinFormsPlugIn() /// protected override LoadReturnCode OnLoad(ref string errorMessage) { - var type = typeof(SampleCsPanelUserControl); + System.Type type = typeof(SampleCsPanelUserControl); Panels.RegisterPanel(this, type, "SampleWinForms", SampleCsWinForms.Properties.Resources.Panel, PanelType.System); return LoadReturnCode.Success; } protected override void OptionsDialogPages(List pages) { - var sample_page = new SampleCsOptionsPage(); + SampleCsOptionsPage sample_page = new SampleCsOptionsPage(); pages.Add(sample_page); } protected override void DocumentPropertiesDialogPages(RhinoDoc doc, List pages) { - var sample_page = new SampleCsDocPropertiesPage(doc); + SampleCsDocPropertiesPage sample_page = new SampleCsDocPropertiesPage(doc); pages.Add(sample_page); } protected override void ObjectPropertiesPages(ObjectPropertiesPageCollection collection) { - var sample_page = new SampleCsObjectPropertiesPage(); + SampleCsObjectPropertiesPage sample_page = new SampleCsObjectPropertiesPage(); collection.Add(sample_page); } diff --git a/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs b/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs index 674063e0..006d0bfd 100644 --- a/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs +++ b/rhinocommon/cs/SampleCsWithLicense/SampleCsWithLicensePlugIn.cs @@ -1,6 +1,6 @@ -using System; -using Rhino.PlugIns; +using Rhino.PlugIns; using Rhino.UI; +using System; namespace SampleCsWithLicense { @@ -39,7 +39,7 @@ public static SampleCsWithLicensePlugIn Instance /// protected override LoadReturnCode OnLoad(ref string errorMessage) { - var rc = GetLicense(Capabilities, TextMask, OnValidateProductKey, OnLeaseChanged); + bool rc = GetLicense(Capabilities, TextMask, OnValidateProductKey, OnLeaseChanged); if (!rc) return LoadReturnCode.ErrorNoDialog; @@ -55,7 +55,7 @@ private static System.Drawing.Icon ProductIcon { get { - var size = RhinoWindows.Forms.Dpi.ScaleInt(32); + int size = RhinoWindows.Forms.Dpi.ScaleInt(32); return DrawingUtilities.LoadIconWithScaleDown("SampleCsWithLicense.Resources.SampleCs.ico", size); } } @@ -104,7 +104,7 @@ private static ValidateResult OnValidateProductKey(string licenseKey, out Licens RequiresOnlineValidation = false // This sample current does not support Rhino accounts. }; - var evaluation = false; + bool evaluation = false; if (string.IsNullOrEmpty(licenseKey)) { licenseKey = EvalLicenseKey; @@ -147,12 +147,12 @@ private static ValidateResult OnValidateProductKey(string licenseKey, out Licens // then just this value to null. if (evaluation) { - var today = DateTime.UtcNow; - var expire = today.AddDays(90); + DateTime today = DateTime.UtcNow; + DateTime expire = today.AddDays(90); licenseData.DateToExpire = expire; } - var rc = licenseData.IsValid(); + bool rc = licenseData.IsValid(); return ValidateResult.Success; } diff --git a/rhinocommon/cs/SampleCsWizardPanel/EtoPanel0.cs b/rhinocommon/cs/SampleCsWizardPanel/EtoPanel0.cs index fe698a59..2a44176c 100644 --- a/rhinocommon/cs/SampleCsWizardPanel/EtoPanel0.cs +++ b/rhinocommon/cs/SampleCsWizardPanel/EtoPanel0.cs @@ -14,7 +14,7 @@ public EtoPanel0(SampleCsWizardPanelViewModel dataContext) : base(dataContext) /// private void InitializeComponent() { - var textbox = new TextBox(); + TextBox textbox = new TextBox(); Content = new TableLayout { Spacing = SpacingSize, diff --git a/rhinocommon/cs/SampleCsWizardPanel/MainPanel.cs b/rhinocommon/cs/SampleCsWizardPanel/MainPanel.cs index 424efc0c..b2df4dfe 100644 --- a/rhinocommon/cs/SampleCsWizardPanel/MainPanel.cs +++ b/rhinocommon/cs/SampleCsWizardPanel/MainPanel.cs @@ -1,5 +1,5 @@ -using System.Runtime.InteropServices; -using Eto.Forms; +using Eto.Forms; +using System.Runtime.InteropServices; namespace SampleCsWizardPanel { @@ -22,7 +22,7 @@ public MainPanel(uint documentRuntimeSerialNumber) // of 0 Padding = 6; // ViewModel associated with a specific RhinoDoc.RuntimeSerialNumber - var view = new SampleCsWizardPanelViewModel(documentRuntimeSerialNumber); + SampleCsWizardPanelViewModel view = new SampleCsWizardPanelViewModel(documentRuntimeSerialNumber); // Set this panels DataContext, Page... panels will inherit this // DeviceContext DataContext = view; diff --git a/rhinocommon/cs/SampleCsWizardPanel/Properties/AssemblyInfo.cs b/rhinocommon/cs/SampleCsWizardPanel/Properties/AssemblyInfo.cs index 67025735..76a17272 100644 --- a/rhinocommon/cs/SampleCsWizardPanel/Properties/AssemblyInfo.cs +++ b/rhinocommon/cs/SampleCsWizardPanel/Properties/AssemblyInfo.cs @@ -1,6 +1,6 @@ -using System.Reflection; +using Rhino.PlugIns; +using System.Reflection; using System.Runtime.InteropServices; -using Rhino.PlugIns; // Plug-in Description Attributes - all of these are optional // These will show in Rhino's option dialog, in the tab Plug-ins diff --git a/rhinocommon/cs/SampleCsWizardPanel/SampleCsWizardPanelViewModel.cs b/rhinocommon/cs/SampleCsWizardPanel/SampleCsWizardPanelViewModel.cs index cc38937c..fc4194fb 100644 --- a/rhinocommon/cs/SampleCsWizardPanel/SampleCsWizardPanelViewModel.cs +++ b/rhinocommon/cs/SampleCsWizardPanel/SampleCsWizardPanelViewModel.cs @@ -1,6 +1,6 @@ -using System.Windows.Input; -using Eto.Forms; +using Eto.Forms; using Rhino; +using System.Windows.Input; namespace SampleCsWizardPanel { @@ -20,7 +20,7 @@ public SampleCsWizardPanelViewModel(uint documentRuntimeSerialNumber) // Read-only property initialization DocumentRuntimeSerialNumber = documentRuntimeSerialNumber; - + // List of wizard panels in the order displayed m_panels = new SampleCsWizardEtoPanel[] { diff --git a/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfPanelCommand.cs b/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfPanelCommand.cs index 2d827823..ded613b0 100644 --- a/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfPanelCommand.cs +++ b/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfPanelCommand.cs @@ -1,9 +1,9 @@ -using System.Runtime.InteropServices; -using Rhino; +using Rhino; using Rhino.Commands; using Rhino.Input.Custom; using Rhino.UI; using SampleCsWpf.Views; +using System.Runtime.InteropServices; namespace SampleCsWpf.Commands { @@ -22,9 +22,9 @@ public SampleCsWpfPanelCommand() { Instance = this; Panels.RegisterPanel( - SampleCsWpfPlugIn.Instance, - typeof(SampleCsWpfPanelHost), - "SampleWpfPanel", + SampleCsWpfPlugIn.Instance, + typeof(SampleCsWpfPanelHost), + "SampleWpfPanel", System.Drawing.SystemIcons.WinLogo, PanelType.System ); @@ -39,7 +39,7 @@ public static SampleCsWpfPanelCommand Instance protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var panel_id = typeof(SampleCsWpfPanelHost).GUID; + System.Guid panel_id = typeof(SampleCsWpfPanelHost).GUID; if (mode == RunMode.Interactive) { @@ -47,27 +47,27 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) return Result.Success; } - var panel_visible = Panels.IsPanelVisible(panel_id); + bool panel_visible = Panels.IsPanelVisible(panel_id); - var prompt = (panel_visible) + string prompt = (panel_visible) ? "Sample panel is visible. New value" : "Sample Manager panel is hidden. New value"; - var go = new GetOption(); + GetOption go = new GetOption(); go.SetCommandPrompt(prompt); - var hide_index = go.AddOption("Hide"); - var show_index = go.AddOption("Show"); - var toggle_index = go.AddOption("Toggle"); + int hide_index = go.AddOption("Hide"); + int show_index = go.AddOption("Show"); + int toggle_index = go.AddOption("Toggle"); go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); - var option = go.Option(); + CommandLineOption option = go.Option(); if (null == option) return Result.Failure; - var index = option.Index; + int index = option.Index; if (index == hide_index) { if (panel_visible) diff --git a/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfSemiModalDialogCommand.cs b/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfSemiModalDialogCommand.cs index a17ad70c..b71bcd04 100644 --- a/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfSemiModalDialogCommand.cs +++ b/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfSemiModalDialogCommand.cs @@ -10,7 +10,7 @@ public class SampleCsWpfSemiModalDialogCommand : Command protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var dialog = new Views.SampleCsWpfDialog(); + Views.SampleCsWpfDialog dialog = new Views.SampleCsWpfDialog(); dialog.ShowSemiModal(RhinoApp.MainWindowHandle()); return Result.Success; diff --git a/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfViewportCommand.cs b/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfViewportCommand.cs index f42a3d1a..474b954d 100644 --- a/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfViewportCommand.cs +++ b/rhinocommon/cs/SampleCsWpf/Commands/SampleCsWpfViewportCommand.cs @@ -22,7 +22,7 @@ public class SampleCsWpfViewportCommand : Command /// protected override Result RunCommand(RhinoDoc doc, RunMode mode) { - var dialog = new Views.SampleCsWpfViewportDialog(); + Views.SampleCsWpfViewportDialog dialog = new Views.SampleCsWpfViewportDialog(); dialog.ShowSemiModal(RhinoApp.MainWindowHandle()); return Result.Success; } diff --git a/rhinocommon/cs/SampleCsWpf/ViewModels/SampleCsWpfPaneViewModel.cs b/rhinocommon/cs/SampleCsWpf/ViewModels/SampleCsWpfPaneViewModel.cs index f88ed73b..4f0103e0 100644 --- a/rhinocommon/cs/SampleCsWpf/ViewModels/SampleCsWpfPaneViewModel.cs +++ b/rhinocommon/cs/SampleCsWpf/ViewModels/SampleCsWpfPaneViewModel.cs @@ -14,7 +14,7 @@ public SampleCsWpfPaneViewModel(uint documentSerialNumber) private void OnShowPanel(object sender, Rhino.UI.ShowPanelEventArgs e) { - var sn = e.DocumentSerialNumber; + uint sn = e.DocumentSerialNumber; // TOOD... } diff --git a/rhinocommon/cs/SampleCsWpf/Views/SampleCsWpfDialog.xaml.cs b/rhinocommon/cs/SampleCsWpf/Views/SampleCsWpfDialog.xaml.cs index fd60060d..314b874e 100644 --- a/rhinocommon/cs/SampleCsWpf/Views/SampleCsWpfDialog.xaml.cs +++ b/rhinocommon/cs/SampleCsWpf/Views/SampleCsWpfDialog.xaml.cs @@ -1,19 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace SampleCsWpf.Views +namespace SampleCsWpf.Views { /// /// Interaction logic for SampleCsWpfDialog.xaml diff --git a/rhinocommon/cs/SampleCsWpf/Views/SampleCsWpfPanel.xaml.cs b/rhinocommon/cs/SampleCsWpf/Views/SampleCsWpfPanel.xaml.cs index c805e07e..c5d66994 100644 --- a/rhinocommon/cs/SampleCsWpf/Views/SampleCsWpfPanel.xaml.cs +++ b/rhinocommon/cs/SampleCsWpf/Views/SampleCsWpfPanel.xaml.cs @@ -1,6 +1,6 @@ using Rhino; -using System.Windows; using SampleCsWpf.ViewModels; +using System.Windows; namespace SampleCsWpf.Views { @@ -19,21 +19,21 @@ public SampleCsWpfPanel(uint documentSerialNumber) private void Button1_Click(object sender, System.Windows.RoutedEventArgs e) { - var vm = ViewModel; + SampleCsWpfPaneViewModel vm = ViewModel; if (vm == null) return; - for (var i = 0; i < 20; i++) + for (int i = 0; i < 20; i++) { // Keep changing the same setting to make sure it only writes the file // one time when this loop is done vm.IncrementCounter(); - + // Change a different settings each time which should reset the save // settings timer if (vm.UseMultipleCounters == true) vm.IncrementCounter(i); - + // The save timer fires every 500ms, this is here to make sure we go past // that a couple of times. This is useful when testing the settings auto // writing function, it should only get called once when this loop is