private Boolean TryMakeContainerSilhouette(ContainerUsefulness reason, out SilhouetteType silhouette) { switch (reason) { case ContainerUsefulness.NoWay: silhouette = SilhouetteType.Transparent; return(false); case ContainerUsefulness.Useful: silhouette = SilhouetteColors.Instance.Items; break; case ContainerUsefulness.Empty: silhouette = SilhouetteColors.Instance.NotInterested; break; case ContainerUsefulness.Locked: silhouette = SilhouetteColors.Instance.Locked; break; case ContainerUsefulness.Restricted: silhouette = SilhouetteColors.Instance.Restricted; break; default: throw new NotSupportedException(reason.ToString()); } return(true); }
private SilhouetteColors() { var currentIndex = Enum <SilhouetteType> .Count; var silhouetteColors = new List <Color>(currentIndex); var outlineColors = new List <Color>(currentIndex); MakeDefaultColors(silhouetteColors, outlineColors); // ---------------------------------------------------------------------------------------------- NotInterested = RegisterColor(Colors.LightGray.A(0.5f), Colors.DarkGray.A(0.5f)); Locked = RegisterColor(Colors.Violet.A(0.5f), Colors.DarkViolet.A(0.5f)); Warning = RegisterColor(Colors.Yellow.A(0.5f), Colors.Gold.A(0.5f)); Restricted = RegisterColor(Colors.Red.A(0.5f), Colors.DarkRed.A(0.5f)); Items = RegisterColor(Colors.Green.A(0.5f), Colors.DarkGreen.A(0.5f)); // ---------------------------------------------------------------------------------------------- CommitChanges(silhouetteColors.ToArray(), outlineColors.ToArray()); SilhouetteType RegisterColor(Color silhouette, Color outline) { SilhouetteType index = (SilhouetteType)currentIndex++; silhouetteColors.Add(silhouette); outlineColors.Add(outline); return(index); } }
/// <summary> /// Compute silhouettes of a shape for a specified projection. /// </summary> /// <param name="geometry">Geometry whose silhouettes need to be computed. Can be Brep, BrepFace, Mesh, or Extrusion.</param> /// <param name="silhouetteType">Types of silhouette to compute.</param> /// <param name="viewport">Projection.</param> /// <param name="tolerance">Tolerance to use for determining projecting relationships. /// Surfaces and curves that are closer than tolerance, may be treated as projecting. /// When in doubt use RhinoDoc.ModelAbsoluteTolerance.</param> /// <param name="angleToleranceRadians">Angular tolerance to use for determining projecting relationships. /// A surface normal N that satisfies N o cameraDirection < Sin(angleToleranceRadians) may be considered projecting. /// When in doubt use RhinoDoc.ModelAngleToleranceRadians.</param> /// <returns>Array of silhouette curves.</returns> public static Silhouette[] Compute( GeometryBase geometry, SilhouetteType silhouetteType, ViewportInfo viewport, double tolerance, double angleToleranceRadians) { return(Compute(geometry, silhouetteType, viewport, tolerance, angleToleranceRadians, null, System.Threading.CancellationToken.None)); }
/// <summary> /// Compute silhouettes of a shape for a parallel projection. /// </summary> /// <param name="geometry">Geometry whose silhouettes need to be computed. Can be Brep, BrepFace, Mesh, or Extrusion.</param> /// <param name="silhouetteType">Types of silhouette to compute.</param> /// <param name="parallelCameraDirection">Direction of parallel camera.</param> /// <param name="tolerance">Tolerance to use for determining projecting relationships. /// Surfaces and curves that are closer than tolerance, may be treated as projecting. /// When in doubt use RhinoDoc.ModelAbsoluteTolerance.</param> /// <param name="angleToleranceRadians">Angular tolerance to use for determining projecting relationships. /// A surface normal N that satisfies N o cameraDirection < Sin(angleToleranceRadians) may be considered projecting. /// When in doubt use RhinoDoc.ModelAngleToleranceRadians.</param> /// <returns>Array of silhouette curves.</returns> public static Silhouette[] Compute( GeometryBase geometry, SilhouetteType silhouetteType, Vector3d parallelCameraDirection, double tolerance, double angleToleranceRadians) { return(Compute(geometry, silhouetteType, parallelCameraDirection, tolerance, angleToleranceRadians, null, System.Threading.CancellationToken.None)); }
/// <summary> /// Compute silhouettes of a shape for a perspective projection. /// </summary> /// <param name="geometry">Geometry whose silhouettes need to be computed. Can be Brep, BrepFace, Mesh, or Extrusion.</param> /// <param name="silhouetteType">Types of silhouette to compute.</param> /// <param name="perspectiveCameraLocation">Location of perspective camera.</param> /// <param name="tolerance">Tolerance to use for determining projecting relationships. /// Surfaces and curves that are closer than tolerance, may be treated as projecting. /// When in doubt use RhinoDoc.ModelAbsoluteTolerance.</param> /// <param name="angleToleranceRadians">Angular tolerance to use for determining projecting relationships. /// A surface normal N that satisfies N o cameraDirection < Sin(angleToleranceRadians) may be considered projecting. /// When in doubt use RhinoDoc.ModelAngleToleranceRadians.</param> /// <returns>Array of silhouette curves.</returns> public static Silhouette[] Compute( GeometryBase geometry, SilhouetteType silhouetteType, Point3d perspectiveCameraLocation, double tolerance, double angleToleranceRadians) { return(Compute(geometry, silhouetteType, perspectiveCameraLocation, tolerance, angleToleranceRadians, null, System.Threading.CancellationToken.None)); }
/// <summary> /// Compute silhouettes of a shape for a specified projection. /// </summary> /// <param name="geometry">Geometry whose silhouettes need to be computed. Can be Brep, BrepFace, Mesh, or Extrusion.</param> /// <param name="silhouetteType">Types of silhouette to compute.</param> /// <param name="viewport">Projection.</param> /// <param name="tolerance">Tolerance to use for determining projecting relationships. /// Surfaces and curves that are closer than tolerance, may be treated as projecting. /// When in doubt use RhinoDoc.ModelAbsoluteTolerance.</param> /// <param name="angleToleranceRadians">Angular tolerance to use for determining projecting relationships. /// A surface normal N that satisfies N o cameraDirection < Sin(angleToleranceRadians) may be considered projecting. /// When in doubt use RhinoDoc.ModelAngleToleranceRadians.</param> /// <param name="clippingPlanes">Optional collection of clipping planes.</param> /// <param name="cancelToken">Computation cancellation token.</param> /// <returns>Array of silhouette curves.</returns> public static Silhouette[] Compute( GeometryBase geometry, SilhouetteType silhouetteType, ViewportInfo viewport, double tolerance, double angleToleranceRadians, IEnumerable <Plane> clippingPlanes, System.Threading.CancellationToken cancelToken) { if (viewport.IsParallelProjection) { return(Compute(geometry, silhouetteType, viewport.CameraDirection, tolerance, angleToleranceRadians, clippingPlanes, cancelToken)); } return(Compute(geometry, silhouetteType, viewport.CameraLocation, tolerance, angleToleranceRadians, clippingPlanes, cancelToken)); }
/// <summary> /// Compute silhouettes of a shape for a perspective projection. /// </summary> /// <param name="geometry">Geometry whose silhouettes need to be computed. Can be Brep, BrepFace, Mesh, or Extrusion.</param> /// <param name="silhouetteType">Types of silhouette to compute.</param> /// <param name="perspectiveCameraLocation">Location of perspective camera.</param> /// <param name="tolerance">Tolerance to use for determining projecting relationships. /// Surfaces and curves that are closer than tolerance, may be treated as projecting. /// When in doubt use RhinoDoc.ModelAbsoluteTolerance.</param> /// <param name="angleToleranceRadians">Angular tolerance to use for determining projecting relationships. /// A surface normal N that satisfies N o cameraDirection < Sin(angleToleranceRadians) may be considered projecting. /// When in doubt use RhinoDoc.ModelAngleToleranceRadians.</param> /// <param name="clippingPlanes">Optional collection of clipping planes.</param> /// <param name="cancelToken">Computation cancellation token.</param> /// <returns>Array of silhouette curves.</returns> public static Silhouette[] Compute( GeometryBase geometry, SilhouetteType silhouetteType, Point3d perspectiveCameraLocation, double tolerance, double angleToleranceRadians, IEnumerable <Plane> clippingPlanes, System.Threading.CancellationToken cancelToken) { IntPtr const_ptr_geometry = geometry.ConstPointer(); Plane[] planes = null; int plane_count = 0; if (clippingPlanes != null) { List <Plane> p = new List <Plane>(clippingPlanes); plane_count = p.Count; planes = p.ToArray(); } ThreadTerminator terminator = null; IntPtr ptr_terminator = IntPtr.Zero; if (cancelToken != System.Threading.CancellationToken.None) { terminator = new ThreadTerminator(); ptr_terminator = terminator.NonConstPointer(); cancelToken.Register(terminator.RequestCancel); } UnsafeNativeMethods.SilEventType s = (UnsafeNativeMethods.SilEventType)silhouetteType; IntPtr ptr_silhouettes = UnsafeNativeMethods.TLC_Sillhouette2(const_ptr_geometry, s, perspectiveCameraLocation, tolerance, angleToleranceRadians, planes, plane_count, ptr_terminator); Silhouette[] rc = FromClassArray(ptr_silhouettes); UnsafeNativeMethods.TLC_SilhouetteArrayDelete(ptr_silhouettes); if (terminator != null) { terminator.Dispose(); } GC.KeepAlive(geometry); return(rc); }