Ejemplo n.º 1
0
        public BoundingBox GetBoundingBox(bool accurate)
        {
#if RHINO_SDK
            RhinoObject parent_object = ParentRhinoObject();
#endif
            if (accurate)
            {
                BoundingBox bbox = new BoundingBox();
                Transform   xf   = new Transform();
#if RHINO_SDK
                // 3 July 2018 S. Baer (RH-46926)
                // When the object is non-const there is a good chance the geometry is
                // different than what is in the original parent object' geometry. Skip
                // using the parent's bbox getter when in this situation
                if (null != parent_object && !IsNonConst)
                {
                    IntPtr ptr_parent_rhinoobject = parent_object.ConstPointer();
                    if (UnsafeNativeMethods.CRhinoObject_GetTightBoundingBox(ptr_parent_rhinoobject, ref bbox, ref xf, false))
                    {
                        return(bbox);
                    }
                }
#endif
                AnnotationBase ann = this as AnnotationBase;
                if (ann != null)
                {
                    return(ann.InternalGetBoundingBox());
                }

                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 && !IsNonConst)
                {
                    IntPtr ptr_parent_rhinoobject = parent_object.ConstPointer();
                    if (UnsafeNativeMethods.CRhinoObject_BoundingBox(ptr_parent_rhinoobject, ref rc))
                    {
                        return(rc);
                    }
                }
#endif
                AnnotationBase ann = this as AnnotationBase;
                if (ann != null)
                {
                    return(ann.InternalGetBoundingBox());
                }

                IntPtr ptr = ConstPointer();
                UnsafeNativeMethods.ON_Geometry_BoundingBox(ptr, ref rc);
                return(rc);
            }
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
        public virtual 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
            RhinoObject parent_object = ParentRhinoObject();
            if (parent_object != null)
            {
                IntPtr ptr_parent = parent_object.ConstPointer();
                if (UnsafeNativeMethods.CRhinoObject_GetTightBoundingBox(ptr_parent, 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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Finds all of the mesh faces on each of two Rhino objects that interfere within a clash distance.
        /// This function uses the object's mesh to calculate the interferences.
        /// Acceptable object types include: BrepObject, ExtrusionObject, MeshObject, and SubDObject.
        /// </summary>
        /// <param name="objA">The first Rhino object.</param>
        /// <param name="objB">The second Rhino object.</param>
        /// <param name="distance">The largest distance at which a clash can occur.</param>
        /// <param name="meshType">The type of mesh to be used for the calculation.</param>
        /// <param name="meshingParameters">The meshing parameters used to generate meshes for the calculation.</param>
        /// <returns>The resulting meshes are sub-meshes of the input meshes if successful, or an empty array on error.</returns>
        public static Mesh[] FindDetail(RhinoObject objA, RhinoObject objB, double distance, MeshType meshType, MeshingParameters meshingParameters)
        {
            if (null == objA)
            {
                throw new ArgumentNullException(nameof(objA));
            }
            if (null == objB)
            {
                throw new ArgumentNullException(nameof(objB));
            }

            using (var out_meshes = new SimpleArrayMeshPointer())
            {
                var ptr_obj_a      = objA.ConstPointer();
                var ptr_obj_b      = objB.ConstPointer();
                var ptr_mp         = meshingParameters.ConstPointer();
                var ptr_out_meshes = out_meshes.NonConstPointer();
                var count          = UnsafeNativeMethods.RHC_CRhClashDetect_FindClashDetail(ptr_obj_a, ptr_obj_b, distance, (int)meshType, ptr_mp, ptr_out_meshes);
                GC.KeepAlive(objA);
                GC.KeepAlive(objB);
                return(count > 0 ? out_meshes.ToNonConstArray() : new Mesh[0]);
            }
        }
Ejemplo n.º 5
0
        /// <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());
        }
Ejemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="obj"></param>
 public static void ObjectChanged(RhinoObject obj)
 {
     UnsafeNativeMethods.Rdk_CRMManager_EVF("ObjectChanged", obj.ConstPointer());
 }
Ejemplo n.º 7
0
 // 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());
 }