public int[] Sort(Geometry.Vector3d cameraDirection) { DirectedOrder d = null; var node = m_order.First; while (node != null) { if (node.Value.Direction.IsParallelTo(cameraDirection, SortAngleTolerance) == 1) { // move node to head to keep at top of MRU cache m_order.Remove(node); m_order.AddFirst(node); return(node.Value.Indices); } d = node.Value; node = node.Next; } if (d == null || m_order.Count < MaximumCachedSortLists) { d = new DirectedOrder(m_points.Length); } m_camera_vector = cameraDirection; int[] indices = d.Indices; Array.Sort(indices, IndexComparison); d.Direction = cameraDirection; m_order.AddFirst(d); if (m_order.Count > MaximumCachedSortLists) { m_order.RemoveLast(); } return(indices); }
public static Rhino.Geometry.Vector3d SunDirection(double latitude, double longitude, DateTime when) { Rhino.Geometry.Vector3d rc = new Geometry.Vector3d(); bool local = (when.Kind == DateTimeKind.Local || when.Kind == DateTimeKind.Unspecified); UnsafeNativeMethods.Rdk_Sun_SunDirection(latitude, longitude, local, when.Year, when.Month, when.Day, when.Hour, when.Minute, when.Second, ref rc); return rc; }
public static Rhino.Geometry.Vector3d SunDirection(double latitude, double longitude, DateTime when) { Rhino.Geometry.Vector3d rc = new Geometry.Vector3d(); bool local = (when.Kind == DateTimeKind.Local || when.Kind == DateTimeKind.Unspecified); UnsafeNativeMethods.Rdk_Sun_SunDirection(latitude, longitude, local, when.Year, when.Month, when.Day, when.Hour, when.Minute, when.Second, ref rc); return(rc); }
internal static void WriteIntoSerializationInfo(IntPtr pRhCmnProfileContext, System.Runtime.Serialization.SerializationInfo info, string prefixStrip) { const int _string = 1; const int _multistring = 2; const int _uuid = 3; const int _color = 4; const int _int = 5; const int _double = 6; const int _rect = 7; const int _point = 8; const int _3dpoint = 9; const int _xform = 10; const int _3dvector = 11; const int _meshparams = 12; const int _buffer = 13; const int _bool = 14; int count = UnsafeNativeMethods.CRhCmnProfileContext_Count(pRhCmnProfileContext); using (StringHolder sectionholder = new StringHolder()) using (StringHolder entryholder = new StringHolder()) { IntPtr pStringSection = sectionholder.NonConstPointer(); IntPtr pStringEntry = entryholder.NonConstPointer(); for (int i = 0; i < count; i++) { int pctype = 0; UnsafeNativeMethods.CRhCmnProfileContext_Item(pRhCmnProfileContext, i, pStringSection, pStringEntry, ref pctype); string section = sectionholder.ToString(); string entry = entryholder.ToString(); if (string.IsNullOrEmpty(entry)) continue; string name = string.IsNullOrEmpty(section) ? entry : section + "\\" + entry; if (name.StartsWith(prefixStrip + "\\")) name = name.Substring(prefixStrip.Length + 1); name = name.Replace("\\", "::"); switch (pctype) { case _string: { UnsafeNativeMethods.CRhinoProfileContext_LoadString(pRhCmnProfileContext, section, entry, pStringEntry); string val = entryholder.ToString(); info.AddValue(name, val); } break; case _multistring: { IntPtr pStrings = UnsafeNativeMethods.ON_StringArray_New(); int array_count = UnsafeNativeMethods.CRhinoProfileContext_LoadStrings(pRhCmnProfileContext, section, entry, pStrings); string[] s = new string[array_count]; for( int j=0; j<array_count; j++ ) { UnsafeNativeMethods.ON_StringArray_Get(pStrings, j, pStringEntry); s[j] = entryholder.ToString(); } info.AddValue(name, s); } break; case _uuid: { Guid id = Guid.Empty; UnsafeNativeMethods.CRhinoProfileContext_LoadGuid(pRhCmnProfileContext, section, entry, ref id); info.AddValue(name, id); } break; case _color: { int abgr = 0; UnsafeNativeMethods.CRhinoProfileContext_LoadColor(pRhCmnProfileContext, section, entry, ref abgr); System.Drawing.Color c = System.Drawing.ColorTranslator.FromWin32(abgr); //string s = System.Drawing.ColorTranslator.ToHtml(c); info.AddValue(name, c); } break; case _int: { int ival = 0; UnsafeNativeMethods.CRhinoProfileContext_LoadInt(pRhCmnProfileContext, section, entry, ref ival); info.AddValue(name, ival); } break; case _double: { double dval = 0; UnsafeNativeMethods.CRhinoProfileContext_LoadDouble(pRhCmnProfileContext, section, entry, ref dval); info.AddValue(name, dval); } break; case _rect: { int left = 0, top = 0, right = 0, bottom = 0; UnsafeNativeMethods.CRhinoProfileContext_LoadRect(pRhCmnProfileContext, section, entry, ref left, ref top, ref right, ref bottom); System.Drawing.Rectangle r = System.Drawing.Rectangle.FromLTRB(left, top, right, bottom); info.AddValue(name, r); } break; case _point: { int x = 0, y = 0; UnsafeNativeMethods.CRhinoProfileContext_LoadPoint(pRhCmnProfileContext, section, entry, ref x, ref y); System.Drawing.Point pt = new System.Drawing.Point(x, y); info.AddValue(name, pt); } break; case _3dpoint: { Rhino.Geometry.Point3d pt = new Geometry.Point3d(); UnsafeNativeMethods.CRhinoProfileContext_LoadPoint3d(pRhCmnProfileContext, section, entry, ref pt); info.AddValue(name, pt); } break; case _xform: { Rhino.Geometry.Transform xf = new Geometry.Transform(); UnsafeNativeMethods.CRhinoProfileContext_LoadXform(pRhCmnProfileContext, section, entry, ref xf); info.AddValue(name, xf); } break; case _3dvector: { Rhino.Geometry.Vector3d vec = new Geometry.Vector3d(); UnsafeNativeMethods.CRhinoProfileContext_LoadVector3d(pRhCmnProfileContext, section, entry, ref vec); info.AddValue(name, vec); } break; case _meshparams: { Rhino.Geometry.MeshingParameters mp = new Geometry.MeshingParameters(); UnsafeNativeMethods.CRhinoProfileContext_LoadMeshParameters(pRhCmnProfileContext, section, entry, mp.NonConstPointer()); info.AddValue(name, mp); mp.Dispose(); } break; case _buffer: { //not supported yet //int buffer_length = UnsafeNativeMethods.CRhinoProfileContext_BufferLength(pRhCmnProfileContext, section, entry); //byte[] buffer = new byte[buffer_length]; //UnsafeNativeMethods.CRhinoProfileContext_LoadBuffer(pRhCmnProfileContext, section, entry, buffer_length, buffer); //info.AddValue(name, buffer); } break; case _bool: { bool b = false; UnsafeNativeMethods.CRhinoProfileContext_LoadBool(pRhCmnProfileContext, section, entry, ref b); info.AddValue(name, b); } break; } } } }
public void SetValue(Rhino.Geometry.Point3d p) { var value = new Geometry.Vector3d(p.X, p.Y, p.Z); UnsafeNativeMethods.Rdk_Variant_Set3dVectorValue(NonConstPointer(), value); }
public bool TryGetVector3d(int id, out Geometry.Vector3d value) { value = new Geometry.Vector3d(); return UnsafeNativeMethods.CRhinoHistoryRecord_GetVector3d(m_pConstRhinoHistoryRecord, id, ref value); }
internal static void WriteIntoSerializationInfo(IntPtr pRhCmnProfileContext, System.Runtime.Serialization.SerializationInfo info, string prefixStrip) { const int _string = 1; const int _multistring = 2; const int _uuid = 3; const int _color = 4; const int _int = 5; const int _double = 6; const int _rect = 7; const int _point = 8; const int _3dpoint = 9; const int _xform = 10; const int _3dvector = 11; const int _meshparams = 12; const int _buffer = 13; const int _bool = 14; int count = UnsafeNativeMethods.CRhCmnProfileContext_Count(pRhCmnProfileContext); using (StringHolder sectionholder = new StringHolder()) using (StringHolder entryholder = new StringHolder()) { IntPtr pStringSection = sectionholder.NonConstPointer(); IntPtr pStringEntry = entryholder.NonConstPointer(); for (int i = 0; i < count; i++) { int pctype = 0; UnsafeNativeMethods.CRhCmnProfileContext_Item(pRhCmnProfileContext, i, pStringSection, pStringEntry, ref pctype); string section = sectionholder.ToString(); string entry = entryholder.ToString(); if (string.IsNullOrEmpty(entry)) continue; string name = string.IsNullOrEmpty(section) ? entry : section + "\\" + entry; if (name.StartsWith(prefixStrip + "\\")) name = name.Substring(prefixStrip.Length + 1); name = name.Replace("\\", "::"); switch (pctype) { case _string: { UnsafeNativeMethods.CRhinoProfileContext_LoadString(pRhCmnProfileContext, section, entry, pStringEntry); string val = entryholder.ToString(); info.AddValue(name, val); } break; case _multistring: { IntPtr pStrings = UnsafeNativeMethods.ON_StringArray_New(); int array_count = UnsafeNativeMethods.CRhinoProfileContext_LoadStrings(pRhCmnProfileContext, section, entry, pStrings); string[] s = new string[array_count]; for( int j=0; j<array_count; j++ ) { UnsafeNativeMethods.ON_StringArray_Get(pStrings, j, pStringEntry); s[j] = entryholder.ToString(); } info.AddValue(name, s); } break; case _uuid: { Guid id = Guid.Empty; UnsafeNativeMethods.CRhinoProfileContext_LoadGuid(pRhCmnProfileContext, section, entry, ref id); info.AddValue(name, id); } break; case _color: { int abgr = 0; UnsafeNativeMethods.CRhinoProfileContext_LoadColor(pRhCmnProfileContext, section, entry, ref abgr); System.Drawing.Color c = Interop.ColorFromWin32(abgr); //string s = System.Drawing.ColorTranslator.ToHtml(c); info.AddValue(name, c); } break; case _int: { int ival = 0; UnsafeNativeMethods.CRhinoProfileContext_LoadInt(pRhCmnProfileContext, section, entry, ref ival); info.AddValue(name, ival); } break; case _double: { double dval = 0; UnsafeNativeMethods.CRhinoProfileContext_LoadDouble(pRhCmnProfileContext, section, entry, ref dval); info.AddValue(name, dval); } break; case _rect: { int left = 0, top = 0, right = 0, bottom = 0; UnsafeNativeMethods.CRhinoProfileContext_LoadRect(pRhCmnProfileContext, section, entry, ref left, ref top, ref right, ref bottom); System.Drawing.Rectangle r = System.Drawing.Rectangle.FromLTRB(left, top, right, bottom); info.AddValue(name, r); } break; case _point: { int x = 0, y = 0; UnsafeNativeMethods.CRhinoProfileContext_LoadPoint(pRhCmnProfileContext, section, entry, ref x, ref y); System.Drawing.Point pt = new System.Drawing.Point(x, y); info.AddValue(name, pt); } break; case _3dpoint: { Rhino.Geometry.Point3d pt = new Geometry.Point3d(); UnsafeNativeMethods.CRhinoProfileContext_LoadPoint3d(pRhCmnProfileContext, section, entry, ref pt); info.AddValue(name, pt); } break; case _xform: { Rhino.Geometry.Transform xf = new Geometry.Transform(); UnsafeNativeMethods.CRhinoProfileContext_LoadXform(pRhCmnProfileContext, section, entry, ref xf); info.AddValue(name, xf); } break; case _3dvector: { Rhino.Geometry.Vector3d vec = new Geometry.Vector3d(); UnsafeNativeMethods.CRhinoProfileContext_LoadVector3d(pRhCmnProfileContext, section, entry, ref vec); info.AddValue(name, vec); } break; case _meshparams: { Rhino.Geometry.MeshingParameters mp = new Geometry.MeshingParameters(); UnsafeNativeMethods.CRhinoProfileContext_LoadMeshParameters(pRhCmnProfileContext, section, entry, mp.NonConstPointer()); info.AddValue(name, mp); mp.Dispose(); } break; case _buffer: { //not supported yet //int buffer_length = UnsafeNativeMethods.CRhinoProfileContext_BufferLength(pRhCmnProfileContext, section, entry); //byte[] buffer = new byte[buffer_length]; //UnsafeNativeMethods.CRhinoProfileContext_LoadBuffer(pRhCmnProfileContext, section, entry, buffer_length, buffer); //info.AddValue(name, buffer); } break; case _bool: { bool b = false; UnsafeNativeMethods.CRhinoProfileContext_LoadBool(pRhCmnProfileContext, section, entry, ref b); info.AddValue(name, b); } break; } } } }
public override RGBColor Rho(ShadeRec shadeRec, Geometry.Vector3d wo) { return(CD * KD); }
public override RGBColor F(ShadeRec shadeRec, Geometry.Vector3d wi, Geometry.Vector3d wo) { return(CD * KD * 1 / Math.PI); }