示例#1
0
        static void OnEnableUiProc(Guid am_id, int enable)
        {
            VisualAnalysisMode mode = FindLocal(am_id);

            if (mode != null)
            {
                try
                {
                    mode.EnableUserInterface(enable == 1);
                }
                catch (Exception) { }
            }
        }
示例#2
0
        static int OnShowIsoCurvesProc(Guid am_id)
        {
            VisualAnalysisMode mode = FindLocal(am_id);

            if (mode != null)
            {
                try
                {
                    return(mode.ShowIsoCurves ? 1 : 0);
                }
                catch (Exception) { }
            }
            return(0);
        }
示例#3
0
        static void OnSetDisplayAttributesProc(Guid am_id, IntPtr pConstRhinoObject, IntPtr pDisplayPipelineAttributes)
        {
            VisualAnalysisMode mode = FindLocal(am_id);

            if (mode != null)
            {
                var rhobj = Rhino.DocObjects.RhinoObject.CreateRhinoObjectHelper(pConstRhinoObject);
                DisplayPipelineAttributes attr = new DisplayPipelineAttributes(pDisplayPipelineAttributes);
                try
                {
                    mode.SetUpDisplayAttributes(rhobj, attr);
                    attr.m_pAttrs = IntPtr.Zero;
                }
                catch (Exception) { }
            }
        }
示例#4
0
        static int OnObjectSupportsProc(Guid am_id, IntPtr pConstRhinoObject)
        {
            VisualAnalysisMode mode = FindLocal(am_id);

            if (mode != null)
            {
                var rhobj = Rhino.DocObjects.RhinoObject.CreateRhinoObjectHelper(pConstRhinoObject);
                try
                {
                    bool rc = mode.ObjectSupportsAnalysisMode(rhobj);
                    return(rc ? 1 : 0);
                }
                catch (Exception) { }
            }
            return(0);
        }
示例#5
0
        static void OnDrawRhinoObjectProc(Guid am_id, IntPtr pConstRhinoObject, IntPtr pRhinoDisplayPipeline)
        {
            VisualAnalysisMode mode = FindLocal(am_id);

            if (mode != null)
            {
                var             rhobj = Rhino.DocObjects.RhinoObject.CreateRhinoObjectHelper(pConstRhinoObject);
                DisplayPipeline dp    = new DisplayPipeline(pRhinoDisplayPipeline);
                try
                {
                    Rhino.DocObjects.BrepObject brep = rhobj as Rhino.DocObjects.BrepObject;
                    if (brep != null)
                    {
                        mode.DrawBrepObject(brep, dp);
                        return;
                    }
                    Rhino.DocObjects.CurveObject curve = rhobj as Rhino.DocObjects.CurveObject;
                    if (curve != null)
                    {
                        mode.DrawCurveObject(curve, dp);
                        return;
                    }
                    Rhino.DocObjects.MeshObject mesh = rhobj as Rhino.DocObjects.MeshObject;
                    if (mesh != null)
                    {
                        mode.DrawMeshObject(mesh, dp);
                        return;
                    }
                    Rhino.DocObjects.PointCloudObject pointcloud = rhobj as Rhino.DocObjects.PointCloudObject;
                    if (pointcloud != null)
                    {
                        mode.DrawPointCloudObject(pointcloud, dp);
                        return;
                    }
                    Rhino.DocObjects.PointObject pointobj = rhobj as Rhino.DocObjects.PointObject;
                    if (pointobj != null)
                    {
                        mode.DrawPointObject(pointobj, dp);
                        return;
                    }
                }
                catch (Exception) { }
            }
        }
示例#6
0
        /// <summary>
        /// Finds a visual analysis mode by guid.
        /// </summary>
        /// <param name="id">The globally unique identifier to search for.</param>
        /// <returns>The found visual analysis mode, or null if it was not found, or on error.</returns>
        public static VisualAnalysisMode Find(Guid id)
        {
            VisualAnalysisMode rc = FindLocal(id);

            if (rc != null)
            {
                return(rc);
            }

            IntPtr pMode = UnsafeNativeMethods.CRhinoVisualAnalysisMode_Mode(id);

            if (pMode != IntPtr.Zero)
            {
                if (m_registered_modes == null)
                {
                    m_registered_modes = new System.Collections.Generic.List <VisualAnalysisMode>();
                }
                var native = new NativeVisualAnalysisMode(id);
                m_registered_modes.Add(native);
                return(native);
            }
            return(null);
        }
示例#7
0
        static void OnDrawGeometryProc(Guid am_id, IntPtr pConstRhinoObject, IntPtr pConstGeometry, IntPtr pRhinoDisplayPipeline)
        {
            VisualAnalysisMode mode = FindLocal(am_id);

            if (mode != null)
            {
                var rhobj = Rhino.DocObjects.RhinoObject.CreateRhinoObjectHelper(pConstRhinoObject);
                var geom  = Rhino.Geometry.GeometryBase.CreateGeometryHelper(pConstGeometry, null);
                if (geom != null)
                {
                    geom.DoNotDestructOnDispose();
                }
                DisplayPipeline     dp   = new DisplayPipeline(pRhinoDisplayPipeline);
                Rhino.Geometry.Mesh mesh = geom as Rhino.Geometry.Mesh;
                try
                {
                    if (mesh != null)
                    {
                        mode.DrawMesh(rhobj, mesh, dp);
                        return;
                    }
                    Rhino.Geometry.NurbsCurve nurbscurve = geom as Rhino.Geometry.NurbsCurve;
                    if (nurbscurve != null)
                    {
                        mode.DrawNurbsCurve(rhobj, nurbscurve, dp);
                        return;
                    }
                    Rhino.Geometry.NurbsSurface nurbssurf = geom as Rhino.Geometry.NurbsSurface;
                    if (nurbssurf != null)
                    {
                        mode.DrawNurbsSurface(rhobj, nurbssurf, dp);
                        return;
                    }
                }
                catch (Exception) { }
            }
        }
示例#8
0
        static void OnUpdateVertexColorsProc(Guid am_id, IntPtr pConstRhinoObject, IntPtr pSimpleArrayConstMeshes, int meshCount)
        {
            VisualAnalysisMode mode = FindLocal(am_id);

            if (mode != null)
            {
                var rhobj = Rhino.DocObjects.RhinoObject.CreateRhinoObjectHelper(pConstRhinoObject);
                Rhino.Geometry.Mesh[] meshes = new Geometry.Mesh[meshCount];
                for (int i = 0; i < meshCount; i++)
                {
                    IntPtr pMesh = UnsafeNativeMethods.ON_MeshArray_Get(pSimpleArrayConstMeshes, i);
                    if (IntPtr.Zero != pMesh)
                    {
                        meshes[i] = new Geometry.Mesh(pMesh, null);
                        meshes[i].DoNotDestructOnDispose();
                    }
                }
                try
                {
                    mode.UpdateVertexColors(rhobj, meshes);
                }
                catch (Exception) { }
            }
        }