Beispiel #1
0
        public static bool Save(List <MeshGroup> meshGroupsToSave, string meshPathAndFileName, MeshOutputSettings outputInfo = null, ReportProgressRatio reportProgress = null)
        {
            try
            {
                if (outputInfo == null)
                {
                    outputInfo = new MeshOutputSettings();
                }
                switch (Path.GetExtension(meshPathAndFileName).ToUpper())
                {
                case ".STL":
                    Mesh mesh = DoMerge(meshGroupsToSave, outputInfo);
                    return(StlProcessing.Save(mesh, meshPathAndFileName, outputInfo));

                case ".AMF":
                    outputInfo.ReportProgress = reportProgress;
                    return(AmfProcessing.Save(meshGroupsToSave, meshPathAndFileName, outputInfo));

                default:
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #2
0
        public static long GetEstimatedMemoryUse(string fileLocation)
        {
            switch (Path.GetExtension(fileLocation).ToUpper())
            {
            case ".STL":
                return(StlProcessing.GetEstimatedMemoryUse(fileLocation));

            case ".AMF":
                return(AmfProcessing.GetEstimatedMemoryUse(fileLocation));
            }

            return(0);
        }
Beispiel #3
0
        public static List <MeshGroup> Load(Stream fileStream, string fileExtension, ReportProgressRatio reportProgress = null)
        {
            switch (fileExtension.ToUpper())
            {
            case ".STL":
                Mesh loadedMesh = StlProcessing.Load(fileStream, reportProgress);
                return((loadedMesh == null) ? null : new List <MeshGroup>(new[] { new MeshGroup(loadedMesh) }));

            case ".AMF":
                return(AmfProcessing.Load(fileStream, reportProgress));

            default:
                return(null);
            }
        }
        public void LoadMesh(string meshPathAndFileName)
        {
            backgroundWorker = new BackgroundWorker();
            backgroundWorker.WorkerReportsProgress = true;
            backgroundWorker.WorkerSupportsCancellation = true;

            backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);

            bool loadingMeshFile = false;
            switch(Path.GetExtension(meshPathAndFileName).ToUpper())
            {
                case ".STL":
                    {
                        StlProcessing stlLoader = new StlProcessing();
                        stlLoader.LoadInBackground(backgroundWorker, meshPathAndFileName);
                        loadingMeshFile = true;
                    }
                    break;

                case ".AMF":
                    {
                        AmfProcessing amfLoader = new AmfProcessing();
                        amfLoader.LoadInBackground(backgroundWorker, meshPathAndFileName);
                        loadingMeshFile = true;
                    }
                    break;

                default:
                    loadingMeshFile = false;
                    break;
            }

            if (loadingMeshFile)
            {
                meshLoadingStateInfoText = new TextWidget("Loading Mesh...");
                meshLoadingStateInfoText.HAnchor = HAnchor.ParentCenter;
                meshLoadingStateInfoText.VAnchor = VAnchor.ParentCenter;
                meshLoadingStateInfoText.AutoExpandBoundsToText = true;

                GuiWidget labelContainer = new GuiWidget();
                labelContainer.AnchorAll();
                labelContainer.AddChild(meshLoadingStateInfoText);
                labelContainer.Selectable = false;

                this.AddChild(labelContainer);
            }
            else
            {
                TextWidget no3DView = new TextWidget(string.Format("No 3D view for this file type '{0}'.", Path.GetExtension(meshPathAndFileName).ToUpper()));
                no3DView.Margin = new BorderDouble(0, 0, 0, 0);
                no3DView.VAnchor = Agg.UI.VAnchor.ParentCenter;
                no3DView.HAnchor = Agg.UI.HAnchor.ParentCenter;
                this.AddChild(no3DView);
            }
        }