/// <summary> /// Boundingbox solver. Gets the world axis aligned boundingbox for the geometry. /// </summary> /// <param name="accurate">If true, a physically accurate boundingbox will be computed. /// If not, a boundingbox estimate will be computed. For some geometry types there is no /// difference between the estimate and the accurate boundingbox. Estimated boundingboxes /// can be computed much (much) faster than accurate (or "tight") bounding boxes. /// Estimated bounding boxes are always similar to or larger than accurate bounding boxes.</param> /// <returns> /// The boundingbox of the geometry in world coordinates or BoundingBox.Empty /// if not bounding box could be found. /// </returns> /// <example> /// <code source='examples\vbnet\ex_curveboundingbox.vb' lang='vbnet'/> /// <code source='examples\cs\ex_curveboundingbox.cs' lang='cs'/> /// <code source='examples\py\ex_curveboundingbox.py' lang='py'/> /// </example> public BoundingBox GetBoundingBox(bool accurate) { #if RHINO_SDK Rhino.DocObjects.RhinoObject parent_object = ParentRhinoObject(); #endif if (accurate) { BoundingBox bbox = new BoundingBox(); Transform xf = new Transform(); #if RHINO_SDK if (null != parent_object) { IntPtr pParentObject = parent_object.ConstPointer(); if (UnsafeNativeMethods.CRhinoObject_GetTightBoundingBox(pParentObject, ref bbox, ref xf, false)) { return(bbox); } } #endif IntPtr ptr = ConstPointer(); return(UnsafeNativeMethods.ON_Geometry_GetTightBoundingBox(ptr, ref bbox, ref xf, false) ? bbox : BoundingBox.Empty); } else { BoundingBox rc = new BoundingBox(); #if RHINO_SDK if (null != parent_object) { IntPtr pParentObject = parent_object.ConstPointer(); if (UnsafeNativeMethods.CRhinoObject_BoundingBox(pParentObject, ref rc)) { return(rc); } } #endif IntPtr ptr = ConstPointer(); UnsafeNativeMethods.ON_Geometry_BoundingBox(ptr, ref rc); return(rc); } }
/// <summary> /// Aligned Boundingbox solver. Gets the world axis aligned boundingbox for the transformed geometry. /// </summary> /// <param name="xform">Transformation to apply to object prior to the BoundingBox computation. /// The geometry itself is not modified.</param> /// <returns>The accurate boundingbox of the transformed geometry in world coordinates /// or BoundingBox.Empty if not bounding box could be found.</returns> public BoundingBox GetBoundingBox(Transform xform) { BoundingBox bbox = BoundingBox.Empty; #if RHINO_SDK // In cases like breps and curves, the CRhinoBrepObject and CRhinoCurveObject // can compute a better tight bounding box Rhino.DocObjects.RhinoObject parent_object = ParentRhinoObject(); if (parent_object != null) { IntPtr pParent = parent_object.ConstPointer(); if (UnsafeNativeMethods.CRhinoObject_GetTightBoundingBox(pParent, ref bbox, ref xform, true)) { return(bbox); } } #endif IntPtr ptr = ConstPointer(); return(UnsafeNativeMethods.ON_Geometry_GetTightBoundingBox(ptr, ref bbox, ref xform, true) ? bbox : BoundingBox.Empty); }
/// <summary> /// Returns a bounding box for the custom render meshes for the given object. /// </summary> /// <param name="vp">The viewport being rendered.</param> /// <param name="obj">The Rhino object of interest.</param> /// <param name="requestingPlugIn">UUID of the RDK plug-in requesting the meshes.</param> /// <param name="preview">Type of mesh to build.</param> /// <returns>A bounding box value.</returns> public virtual BoundingBox BoundingBox(ViewportInfo vp, RhinoObject obj, Guid requestingPlugIn, bool preview) { var min = new Point3d(); var max = new Point3d(); if (UnsafeNativeMethods.Rdk_RMPBoundingBoxImpl(m_runtime_serial_number, vp.ConstPointer(), obj.ConstPointer(), requestingPlugIn, preview ? 1 : 0, ref min, ref max)) return new BoundingBox(min, max); return new BoundingBox(); }
/// <summary> /// /// </summary> /// <param name="obj"></param> public static void ObjectChanged(RhinoObject obj) { UnsafeNativeMethods.Rdk_CRMManager_EVF("ObjectChanged", obj.ConstPointer()); }
// Marked as internal, RhinoObject.GetRenderPrimitiveList will create one // but there is currently no reason for anyone else to make one. internal RenderPrimitiveList(RhinoObject obj) { m_ptr_custom_render_meshes = UnsafeNativeMethods.Rdk_CustomMeshes_New(obj.ConstPointer()); }
/// <summary> /// Checks geometry to see if it passes the basic GeometryAttributeFilter. /// </summary> /// <param name="rhObject">parent object being considered.</param> /// <param name="geometry">geometry being considered.</param> /// <param name="componentIndex">if >= 0, geometry is a proper sub-part of object->Geometry() with componentIndex.</param> /// <returns> /// true if the geometry passes the filter returned by GeometryAttributeFilter(). /// </returns> public bool PassesGeometryAttributeFilter(RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex) { IntPtr const_ptr_rhino_object = IntPtr.Zero; if (rhObject != null) const_ptr_rhino_object = rhObject.ConstPointer(); IntPtr const_ptr_geometry = IntPtr.Zero; if (geometry != null) const_ptr_geometry = geometry.ConstPointer(); IntPtr ptr = NonConstPointer(); return UnsafeNativeMethods.CRhinoGetObject_PassesGeometryAttributeFilter(ptr, const_ptr_rhino_object, const_ptr_geometry, componentIndex); }