Beispiel #1
0
        /// <summary>
        /// Cleans up FindSurface, custom point cloud engines, DirectShapeManager instances before Revit is terminated.
        /// </summary>
        public static void OnPluginShutdown()
        {
            // clean up FindSurface
            FindSurface.CleanUp();

            // clean up XYZPointCloudEngine
            List <string> engine_names = PointCloudEngineRegistry.GetSupportedEngines() as List <string>;

            foreach (string engine_name in engine_names)
            {
                if (engine_name == S_OUTLIER_PC_ENGINE_IDENTIFIER || engine_name == S_INLIER_PC_ENGINE_IDENTIFIER)
                {
                    PointCloudEngineRegistry.UnregisterPointCloudEngine(engine_name);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a point cloud and send the data to FindSurface when users imported a point cloud file using Open button in FindSurface tab.
        /// </summary>
        /// <param name="doc">The active document that Revit uses</param>
        /// <param name="file_full_name">The name of imported file</param>
        /// <param name="xyz_array">Imported xyz data</param>
        /// <param name="color_array">Imported color data</param>
        /// <param name="subdivision">Subdivision number</param>
        /// <param name="unit">The base unit of when the inspector displays information</param>
        public static void OnOpenCommand(Document doc, string file_full_name, float[] xyz_array, int[] color_array, int subdivision, Units unit)
        {
            s_file_full_name  = file_full_name;
            s_xyz             = xyz_array;
            s_color           = color_array;
            s_subdivision     = subdivision;
            s_measurementUnit = unit;

            CloudPoint[] points;
            FindSurfaceRevitPluginUtils.Pack(xyz_array, color_array, out points);
            s_temporary_outlier_deletion = true;
            OutlierPointCloudEngine.CreatePointCloud(doc, file_full_name, points, Transform.Identity, subdivision);

            FindSurface.CleanUp();
            FindSurface.SetPointCloud(xyz_array);
        }
Beispiel #3
0
        /// <summary>
        /// Resets the plugin to the state of when users imported a point cloud file.
        /// </summary>
        /// <returns>false if any point cloud file has been opened or true otherwise</returns>
        public static bool OnResetCommand(Document document)
        {
            OnCleanUpCommand();

            CloudPoint[] points;
            if (s_xyz == null || s_xyz.Length == 0)
            {
                return(false);
            }
            FindSurfaceRevitPluginUtils.Pack(s_xyz, s_color, out points);
            OutlierPointCloudEngine.CreatePointCloud(document, s_file_full_name, points, Transform.Identity, s_subdivision);

            FindSurface.CleanUp();
            FindSurface.SetPointCloud(s_xyz);
            return(true);
        }
        private static void ExtractInlierPointCloud(Document doc, string inlier_identifier, int highlight_color)
        {
            CloudPoint[] original_points = OutlierPointCloudEngine.GetCloudPoint();

            List <CloudPoint> inlier_point_list  = new List <CloudPoint>();
            List <CloudPoint> outlier_point_list = new List <CloudPoint>();
            List <float>      outlier_xyz        = new List <float>();

            // this is a flag array of which each element is set when the point of its corresponding location is in outlier.
            bool[] outlier_flags = FindSurface.GetInOutlierFlags();
            for (int k = 0; k < outlier_flags.Length; k++)
            {
                float x     = original_points[k].X;
                float y     = original_points[k].Y;
                float z     = original_points[k].Z;
                int   color = original_points[k].Color;

                if (outlier_flags[k])                  // outlier
                {
                    outlier_point_list.Add(new CloudPoint(x, y, z, color));
                    outlier_xyz.AddRange(new float[] { x, y, z });
                }
                else                 // inlier
                {
                    color = FindSurfaceRevitPluginUtils.MixARGB(color, highlight_color);
                    inlier_point_list.Add(new CloudPoint(x, y, z, color));
                }
            }

            Transform outlier_transform = OutlierPointCloudEngine.GetPointCloudTransform();

            // replace outlier (or original one) to new outlier points.
            s_temporary_outlier_deletion = true;
            OutlierPointCloudEngine.CreatePointCloud(doc, "Outlier", outlier_point_list.ToArray(), outlier_transform, s_subdivision);

            // give new outlier points to FindSurface.
            FindSurface.CleanUp();
            FindSurface.SetPointCloud(outlier_xyz.ToArray());

            // create inlier point cloud.
            InlierPointCloudEngine.CreatePointCloud(doc, inlier_identifier, inlier_point_list.ToArray(), outlier_transform);
        }