/// <summary> /// Computes draft curve silhouettes of a shape. /// </summary> /// <param name="geometry">Geometry whose silhouettes need to be computed. Can be Brep, BrepFace, Mesh, or Extrusion.</param> /// <param name="draftAngle">The draft angle in radians. Draft angle can be a positive or negative value.</param> /// <param name="pullDirection">3d direction for the mold to be pulled in, directed away from the object.</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="cancelToken">Computation cancellation token.</param> /// <returns>Array of silhouette curves.</returns> /// <since>7.0</since> public static Silhouette[] ComputeDraftCurve( GeometryBase geometry, double draftAngle, Vector3d pullDirection, double tolerance, double angleToleranceRadians, System.Threading.CancellationToken cancelToken ) { IntPtr const_ptr_geometry = geometry.ConstPointer(); ThreadTerminator terminator = null; if (cancelToken != System.Threading.CancellationToken.None) { terminator = new ThreadTerminator(); cancelToken.Register(terminator.RequestCancel); } IntPtr ptr_terminator = terminator == null ? IntPtr.Zero : terminator.NonConstPointer(); IntPtr ptr_silhouettes = UnsafeNativeMethods.TLC_Sillhouette3(const_ptr_geometry, draftAngle, pullDirection, tolerance, angleToleranceRadians, ptr_terminator); Silhouette[] rc = FromClassArray(ptr_silhouettes); UnsafeNativeMethods.TLC_SilhouetteArrayDelete(ptr_silhouettes); if (terminator != null) { terminator.Dispose(); } GC.KeepAlive(geometry); return(rc); }
internal override IntPtr _InternalGetConstPointer() { if (null != m_shallow_parent) { return(m_shallow_parent.ConstPointer()); } #if RHINO_SDK ObjRef obj_ref = m__parent as ObjRef; if (null != obj_ref) { return(obj_ref.GetGeometryConstPointer(this)); } RhinoObject parent_object = ParentRhinoObject(); if (parent_object == null) { FileIO.File3dmObject fileobject = m__parent as FileIO.File3dmObject; if (null != fileobject) { return(fileobject.GetGeometryConstPointer()); } } uint serial_number = 0; IntPtr ptr_parent_rhinoobject = IntPtr.Zero; if (null != parent_object) { serial_number = parent_object.m_rhinoobject_serial_number; ptr_parent_rhinoobject = parent_object.m_pRhinoObject; if (IntPtr.Zero == ptr_parent_rhinoobject && parent_object.m__parent != null && parent_object.m__parent is ObjRef) { ObjRef objref = parent_object.m__parent as ObjRef; IntPtr constPtrObjRef = objref.ConstPointer(); ptr_parent_rhinoobject = UnsafeNativeMethods.CRhinoObjRef_Object(constPtrObjRef); } } ComponentIndex ci = new ComponentIndex(); // There are a few cases (like in ReplaceObject callback) where the parent // rhino object temporarily holds onto the CRhinoObject* because the object // is not officially in the document yet. if (ptr_parent_rhinoobject != IntPtr.Zero) { return(UnsafeNativeMethods.CRhinoObject_Geometry(ptr_parent_rhinoobject, ci)); } return(UnsafeNativeMethods.CRhinoObject_Geometry2(serial_number, ci)); #else var fileobject = m__parent as Pixel.Rhino.FileIO.File3dmObject; if (null != fileobject) { return(fileobject.GetGeometryConstPointer()); } return(IntPtr.Zero); #endif }
/// <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> /// <since>6.0</since> 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); }
/// <summary> /// Determines if two geometries equal one another, in pure geometrical shape. /// This version only compares the geometry itself and does not include any user /// data comparisons. /// This is a comparison by value: for two identical items it will be true, no matter /// where in memory they may be stored. /// </summary> /// <param name="first">The first geometry</param> /// <param name="second">The second geometry</param> /// <returns>The indication of equality</returns> /// <since>6.0</since> public static bool GeometryEquals(GeometryBase first, GeometryBase second) { if (first == null && second == null) { return(true); } if (first == null || second == null) { return(false); } IntPtr first_ptr = first.ConstPointer(); IntPtr second_ptr = second.ConstPointer(); bool rc = UnsafeNativeMethods.RH_RhinoCompareGeometry(first_ptr, second_ptr); Runtime.CommonObject.GcProtect(first, second); return(rc); }