Пример #1
0
        /// <summary>
        /// Load from BCF 2.0 as BCF 1.0
        /// </summary>
        /// <param name="bcf2">BCF 2.0 file</param>
        /// <returns></returns>
        public static IssueBCF LoadBcf1IssueFromBcf2(BCF2.Markup bcf2Markup, BCF2.VisualizationInfo bcf2Viewpoint)
        {
            // Convert headers
            List <HeaderFile> bcf1Headers = new List <HeaderFile>();

            foreach (BCF2.HeaderFile bcf2Header in bcf2Markup.Header)
            {
                HeaderFile bcf1Header = new HeaderFile()
                {
                    Filename   = bcf2Header.Filename,
                    Date       = bcf2Header.Date,
                    IfcProject = bcf2Header.IfcProject,
                    IfcSpatialStructureElement = bcf2Header.IfcSpatialStructureElement
                };
                bcf1Headers.Add(bcf1Header);
            }

            // Convert topic
            Topic bcf1Topic = new Topic();

            if (bcf2Markup.Topic != null)
            {
                bcf1Topic.Guid          = bcf2Markup.Topic.Guid;
                bcf1Topic.ReferenceLink = bcf2Markup.Topic.ReferenceLink;
                bcf1Topic.Title         = bcf2Markup.Topic.Title;
            }
            ;

            // Convert comments
            ObservableCollection <CommentBCF> bcf1Comments = new ObservableCollection <CommentBCF>();

            foreach (BCF2.Comment bcf2Comment in bcf2Markup.Comment)
            {
                CommentBCF bcf1Comment = new CommentBCF()
                {
                    Author   = bcf2Comment.Author,
                    Comment1 = bcf2Comment.Comment1,
                    Date     = bcf2Comment.Date,
                    Guid     = bcf2Comment.Guid,
                    Status   = CommentStatus.Unknown,  // default unknown for now
                    Topic    = new CommentTopic()
                    {
                        Guid = bcf2Markup.Topic == null?Guid.NewGuid().ToString() : bcf2Markup.Topic.Guid
                    },
                    VerbalStatus = bcf2Comment.VerbalStatus
                };
                bcf1Comments.Add(bcf1Comment);
            }

            // Convert markups/issues
            Markup bcf1Markup = new Markup()
            {
                Header  = bcf1Headers.ToArray(),
                Topic   = bcf1Topic,
                Comment = bcf1Comments
            };

            // Convert ClippingPlane
            List <ClippingPlane> bcf1ClippingPlanes = new List <ClippingPlane>();

            if (bcf2Viewpoint.ClippingPlanes != null)
            {
                foreach (BCF2.ClippingPlane bcf2ClippingPlane in bcf2Viewpoint.ClippingPlanes)
                {
                    if (bcf2ClippingPlane != null)
                    {
                        bcf1ClippingPlanes.Add(new ClippingPlane()
                        {
                            Direction = new Direction()
                            {
                                X = bcf2ClippingPlane.Direction.X,
                                Y = bcf2ClippingPlane.Direction.Y,
                                Z = bcf2ClippingPlane.Direction.Z
                            },
                            Location = new Point()
                            {
                                X = bcf2ClippingPlane.Location.X,
                                Y = bcf2ClippingPlane.Location.Y,
                                Z = bcf2ClippingPlane.Location.Z
                            }
                        });
                    }
                }
            }

            // Convert Components
            List <Component> bcf1Components = new List <Component>();

            if (bcf2Viewpoint.Components != null)
            {
                foreach (BCF2.Component bcf2Component in bcf2Viewpoint.Components)
                {
                    if (bcf2Component != null)
                    {
                        bcf1Components.Add(new Component()
                        {
                            AuthoringToolId   = bcf2Component.AuthoringToolId,
                            IfcGuid           = bcf2Component.IfcGuid,
                            OriginatingSystem = bcf2Component.OriginatingSystem
                        });
                    }
                }
            }

            // Convert Lines
            List <Line> bcf1Lines = new List <Line>();

            if (bcf2Viewpoint.Lines != null)
            {
                foreach (BCF2.Line bcf2Line in bcf2Viewpoint.Lines)
                {
                    if (bcf2Line != null)
                    {
                        bcf1Lines.Add(new Line()
                        {
                            StartPoint = new Point()
                            {
                                X = bcf2Line.StartPoint.X,
                                Y = bcf2Line.StartPoint.Y,
                                Z = bcf2Line.StartPoint.Z
                            },
                            EndPoint = new Point()
                            {
                                X = bcf2Line.EndPoint.X,
                                Y = bcf2Line.EndPoint.Y,
                                Z = bcf2Line.EndPoint.Z
                            }
                        });
                    }
                }
            }

            // Convert viewpoints
            VisualizationInfo bcf1Viewpoint = new VisualizationInfo()
            {
                ClippingPlanes   = bcf1ClippingPlanes.ToArray(),
                Components       = bcf1Components.ToArray(),
                Lines            = bcf1Lines.ToArray(),
                OrthogonalCamera = bcf2Viewpoint.OrthogonalCamera == null ? null : new OrthogonalCamera()
                {
                    CameraDirection = new Direction()
                    {
                        X = bcf2Viewpoint.OrthogonalCamera.CameraDirection.X,
                        Y = bcf2Viewpoint.OrthogonalCamera.CameraDirection.Y,
                        Z = bcf2Viewpoint.OrthogonalCamera.CameraDirection.Z
                    },
                    CameraUpVector = new Direction()
                    {
                        X = bcf2Viewpoint.OrthogonalCamera.CameraUpVector.X,
                        Y = bcf2Viewpoint.OrthogonalCamera.CameraUpVector.Y,
                        Z = bcf2Viewpoint.OrthogonalCamera.CameraUpVector.Z
                    },
                    CameraViewPoint = new Point()
                    {
                        X = bcf2Viewpoint.OrthogonalCamera.CameraViewPoint.X,
                        Y = bcf2Viewpoint.OrthogonalCamera.CameraViewPoint.Y,
                        Z = bcf2Viewpoint.OrthogonalCamera.CameraViewPoint.Z
                    },
                    ViewToWorldScale = bcf2Viewpoint.OrthogonalCamera.ViewToWorldScale
                },
                PerspectiveCamera = bcf2Viewpoint.PerspectiveCamera == null ? null : new PerspectiveCamera()
                {
                    CameraDirection = new Direction()
                    {
                        X = bcf2Viewpoint.PerspectiveCamera.CameraDirection.X,
                        Y = bcf2Viewpoint.PerspectiveCamera.CameraDirection.Y,
                        Z = bcf2Viewpoint.PerspectiveCamera.CameraDirection.Z
                    },
                    CameraUpVector = new Direction()
                    {
                        X = bcf2Viewpoint.PerspectiveCamera.CameraUpVector.X,
                        Y = bcf2Viewpoint.PerspectiveCamera.CameraUpVector.Y,
                        Z = bcf2Viewpoint.PerspectiveCamera.CameraUpVector.Z
                    },
                    CameraViewPoint = new Point()
                    {
                        X = bcf2Viewpoint.PerspectiveCamera.CameraViewPoint.X,
                        Y = bcf2Viewpoint.PerspectiveCamera.CameraViewPoint.Y,
                        Z = bcf2Viewpoint.PerspectiveCamera.CameraViewPoint.Z
                    },
                    FieldOfView = bcf2Viewpoint.PerspectiveCamera.FieldOfView
                },
                SheetCamera = bcf2Viewpoint.SheetCamera == null ? null : new SheetCamera()
                {
                    SheetID = bcf2Viewpoint.SheetCamera.SheetID,
                    TopLeft = new Point()
                    {
                        X = bcf2Viewpoint.SheetCamera.TopLeft.X,
                        Y = bcf2Viewpoint.SheetCamera.TopLeft.Y,
                        Z = bcf2Viewpoint.SheetCamera.TopLeft.Z
                    },
                    BottomRight = new Point()
                    {
                        X = bcf2Viewpoint.SheetCamera.BottomRight.X,
                        Y = bcf2Viewpoint.SheetCamera.BottomRight.Y,
                        Z = bcf2Viewpoint.SheetCamera.BottomRight.Z
                    }
                }
            };

            // Create a new BCF 1.0 issue
            IssueBCF bcf1 = new IssueBCF()
            {
                markup    = bcf1Markup,
                viewpoint = bcf1Viewpoint
            };

            return(bcf1);
        }
Пример #2
0
        /// <summary>
        /// Add Issue
        /// </summary>
        /// <param name="path"></param>
        /// <param name="isBcf"></param>
        /// <returns></returns>
        private Tuple<IssueBCF, Issue> AddIssue(string path, bool isBcf)
        {
            try
              {
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document doc = uidoc.Document;

            if (!(uidoc.ActiveView is View3D || uidoc.ActiveView is ViewSheet || uidoc.ActiveView is ViewPlan || uidoc.ActiveView is ViewSection || uidoc.ActiveView is ViewDrafting))
            {
              MessageBox.Show("I'm sorry,\nonly 3D and 2D views are supported.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
              return null;
            }
            IssueBCF issue = new IssueBCF();

            string folderIssue = Path.Combine(path, issue.guid.ToString());
            if (!Directory.Exists(folderIssue))
              Directory.CreateDirectory(folderIssue);

            var types = new ObservableCollection<Issuetype>();
            var assignees = new List<User>();
            var components = new ObservableCollection<IssueTracker.Data.Component>();
            var priorities = new ObservableCollection<Priority>();
            var noCom = true;
            var noPrior = true;
            var noAssign = true;

            if (!isBcf)
            {
              types = mainPan.jira.TypesCollection;
              assignees = mainPan.getAssigneesIssue();
              components = mainPan.jira.ComponentsCollection;
              priorities = mainPan.jira.PrioritiesCollection;
              noCom =
              mainPan.jira.ProjectsCollection[mainPan.jiraPan.projIndex].issuetypes[0].fields.components ==
              null;
              noPrior =
              mainPan.jira.ProjectsCollection[mainPan.jiraPan.projIndex].issuetypes[0].fields.priority ==
              null;
              noAssign =
              mainPan.jira.ProjectsCollection[mainPan.jiraPan.projIndex].issuetypes[0].fields.assignee ==
              null;

            }

            AddIssueRevit air = new AddIssueRevit(uidoc, folderIssue, types, assignees, components, priorities, noCom, noPrior, noAssign);
            air.Title = "Add Jira Issue";
            if (!isBcf)
              air.VerbalStatus.Visibility = System.Windows.Visibility.Collapsed;
            else
              air.JiraFieldsBox.Visibility = System.Windows.Visibility.Collapsed;
            air.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            air.ShowDialog();
            if (air.DialogResult.HasValue && air.DialogResult.Value)
            {
              issue.snapshot = Path.Combine(folderIssue, "snapshot.png");
              int elemCheck = 2;
              if (air.all.IsChecked.Value)
            elemCheck = 0;
              else if (air.selected.IsChecked.Value)
            elemCheck = 1;

              Issue issueJira = new Issue();
              if (!isBcf)
              {
            issueJira.fields = new Fields();
            issueJira.fields.issuetype = (Issuetype)air.issueTypeCombo.SelectedItem;
            issueJira.fields.priority = (Priority)air.priorityCombo.SelectedItem;
            if (!string.IsNullOrEmpty(air.ChangeAssign.Content.ToString()) &&
                air.ChangeAssign.Content.ToString() != "none")
            {
              issueJira.fields.assignee = new User();
              issueJira.fields.assignee.name = air.ChangeAssign.Content.ToString();
            }

            if (air.SelectedComponents != null && air.SelectedComponents.Any())
            {
              issueJira.fields.components = air.SelectedComponents;
            }
              }
              issue.viewpoint = generateViewpoint(elemCheck);
              issue.markup.Topic.Title = air.TitleBox.Text;
              issue.markup.Header[0].IfcProject = ExporterIFCUtils.CreateProjectLevelGUID(doc,
              Autodesk.Revit.DB.IFC.IFCProjectLevelGUIDType.Project);
              string projFilename = (doc.PathName != null && doc.PathName != "")
              ? System.IO.Path.GetFileName(doc.PathName)
              : "";
              issue.markup.Header[0].Filename = projFilename;
              issue.markup.Header[0].Date = DateTime.Now;

              //comment
              if (!string.IsNullOrWhiteSpace(air.CommentBox.Text))
              {
            CommentBCF c = new CommentBCF();
            c.Comment1 = air.CommentBox.Text;
            c.Topic = new CommentTopic();
            c.Topic.Guid = issue.guid.ToString();
            ;
            c.Date = DateTime.Now;
            c.VerbalStatus = air.VerbalStatus.Text;
            c.Status = CommentStatus.Unknown;
            c.Author = (string.IsNullOrWhiteSpace(mainPan.jira.Self.displayName))
                ? UserSettings.Get("BCFusername")
                : mainPan.jira.Self.displayName;
            issue.markup.Comment.Add(c);
              }

              return new Tuple<IssueBCF, Issue>(issue, issueJira);

            }
            else
            {
              mainPan.DeleteDirectory(folderIssue);
            }

              }

              catch (System.Exception ex1)
              {
            MessageBox.Show("exception: " + ex1);
              }
              return null;
        }
Пример #3
0
        private Tuple<List<IssueBCF>, List<Issue>> AddIssue(string path, bool isBcf)
        {
            try
              {
            // set image export settings
            ComApi.InwOaPropertyVec options = ComBridge.State.GetIOPluginOptions("lcodpimage");
            // configure the option "export.image.format" to export png and image size
            foreach (ComApi.InwOaProperty opt in options.Properties())
            {
              if (opt.name == "export.image.format")
            opt.value = "lcodpexpng";
              if (opt.name == "export.image.width")
            opt.value = 1600;
              if (opt.name == "export.image.height")
            opt.value = 900;

            }

            _savedViewpoints = new List<SavedViewpoint>();

            foreach (SavedItem oSI in _oDoc.SavedViewpoints.ToSavedItemCollection())
            {
              RecurseItems(oSI);
            }

            var types = new ObservableCollection<Issuetype>();
            var assignees = new List<User>();
            var components = new ObservableCollection<Component>();
            var priorities = new ObservableCollection<Priority>();
            var noCom = true;
            var noPrior = true;
            var noAssign = true;

            if (!isBcf)
            {
              types = mainPan.jira.TypesCollection;
              assignees = mainPan.getAssigneesProj();
              components = mainPan.jira.ComponentsCollection;
              priorities = mainPan.jira.PrioritiesCollection;
              noCom =
              mainPan.jira.ProjectsCollection[mainPan.jiraPan.projIndex].issuetypes[0].fields.components ==
              null;
              noPrior =
              mainPan.jira.ProjectsCollection[mainPan.jiraPan.projIndex].issuetypes[0].fields.priority ==
              null;
              noAssign =
              mainPan.jira.ProjectsCollection[mainPan.jiraPan.projIndex].issuetypes[0].fields.assignee ==
              null;

            }

            AddIssueNavis ain = new AddIssueNavis(_savedViewpoints, types, assignees, components, priorities, noCom, noPrior, noAssign);
            if (isBcf)
              ain.JiraFieldsBox.Visibility = System.Windows.Visibility.Collapsed;
            ain.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            ain.ShowDialog();
            if (ain.DialogResult.HasValue && ain.DialogResult.Value)
            {
              int elemCheck = 2;
              if (ain.all.IsChecked.Value)
            elemCheck = 0;
              else if (ain.selected.IsChecked.Value)
            elemCheck = 1;

              List<SavedViewpoint> savedViewpointsImport = new List<SavedViewpoint>();

              for (int i = 0; i < ain.issueList.SelectedItems.Count; i++)
              {
            int index = ain.issueList.Items.IndexOf(ain.issueList.SelectedItems[i]);
            savedViewpointsImport.Add(_savedViewpoints[index]);
              }
              if (!savedViewpointsImport.Any())
            return null;
              //get selection only once!
              if (elemCheck == 1)
            _elementList = _oDoc.CurrentSelection.SelectedItems.Where(o => o.InstanceGuid != Guid.Empty).ToList<ModelItem>();

              List<IssueBCF> issues = new List<IssueBCF>();
              List<Issue> issuesJira = new List<Issue>();
              foreach (var sv in savedViewpointsImport)
              {
            Issue issueJira = new Issue();
            if (!isBcf)
            {
              issueJira.fields = new Fields();
              issueJira.fields.issuetype = (Issuetype)ain.issueTypeCombo.SelectedItem;
              issueJira.fields.priority = (Priority)ain.priorityCombo.SelectedItem;
              if (!string.IsNullOrEmpty(ain.ChangeAssign.Content.ToString()) &&
                  ain.ChangeAssign.Content.ToString() != "none")
              {
                issueJira.fields.assignee = new User();
                issueJira.fields.assignee.name = ain.ChangeAssign.Content.ToString();
              }

              if (ain.SelectedComponents != null && ain.SelectedComponents.Any())
              {
                issueJira.fields.components = ain.SelectedComponents;
              }
            }

            IssueBCF issue = new IssueBCF();
            string folderIssue = Path.Combine(path, issue.guid.ToString());
            if (!Directory.Exists(folderIssue))
              Directory.CreateDirectory(folderIssue);

            issue.snapshot = Path.Combine(folderIssue, "snapshot.png");
            // set the currtent saved viewpoint and then generate sna and BCF viewpoint
            _oDoc.SavedViewpoints.CurrentSavedViewpoint = sv;
            issue.viewpoint = generateViewpoint(sv.Viewpoint, elemCheck);
            generateSnapshot(folderIssue);

            issue.markup.Topic.Title = sv.DisplayName;
            issue.markup.Header[0].IfcProject = "";
            string projFilename = !string.IsNullOrEmpty(_oDoc.FileName) ? System.IO.Path.GetFileName(_oDoc.FileName) : "";
            issue.markup.Header[0].Filename = projFilename;
            issue.markup.Header[0].Date = DateTime.Now;

            //comment
            if (sv.Comments.Any())
            {

              foreach (var comm in sv.Comments)
              {
                var c = new CommentBCF
                {
                  Comment1 = comm.Body,
                  Topic = new CommentTopic { Guid = issue.guid.ToString() }
                };
                ;
                c.Date = DateTime.Now;
                c.VerbalStatus = comm.Status.ToString();
                c.Author = (string.IsNullOrWhiteSpace(mainPan.jira.Self.displayName)) ? UserSettings.Get("BCFusername") : mainPan.jira.Self.displayName;
                issue.markup.Comment.Add(c);
              }
            }
            issues.Add(issue);
            issuesJira.Add(issueJira);
              } // end foreach
              return new Tuple<List<IssueBCF>, List<Issue>>(issues, issuesJira);
            }
              }

              catch (Exception ex)
              {
            MessageBox.Show(ex.ToString());
              }
              return null;
        }
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = (BackgroundWorker)sender;

            XmlSerializer serializerV = new XmlSerializer(typeof(VisualizationInfo));

            for (int i = 0; i < issues.Count(); i++)
            {
                try
                {
                    IssueBCF issue = issues[i];
                    worker.ReportProgress((100 * i + 1) / issues.Count(), getProgressString(i + 1)); // HAS TO BE OUT OF THE DISPATCHER!
                                                                                                     // check status on each step
                    if (worker.CancellationPending == true)
                    {
                        e.Cancel = true;
                        return; // abort work, if it's cancelled
                    }

                    //CHECK IF ALREADY EXISTING
                    // could use the expression: cf[11600] ~ "aaaa"
                    // = operator not supported
                    string fields = " AND  GUID~" + issue.guid.ToString() + "&fields=key,comment";
                    string query  = "search?jql=project=" + projectKey + fields;

                    var request4 = new RestRequest(query, Method.GET);
                    request4.AddHeader("Content-Type", "application/json");
                    request4.RequestFormat = RestSharp.DataFormat.Json;
                    var response4 = JiraClient.Client.Execute <Issues>(request4);

                    if (!RestCallback.Check(response4))
                    {
                        break;
                    }

                    //DOESN'T exist already
                    if (!response4.Data.issues.Any())
                    {
                        string snapshot  = Path.Combine(path, issue.guid.ToString(), "snapshot.png");
                        string viewpoint = Path.Combine(path, issue.guid.ToString(), "viewpoint.bcfv");
                        string key       = "";


                        //update view - it might be a new issue
                        // Serialize the object, and close the TextWriter
                        Stream writerV = new FileStream(viewpoint, FileMode.Create);
                        serializerV.Serialize(writerV, issue.viewpoint);
                        writerV.Close();


                        var request = new RestRequest("issue", Method.POST);
                        request.AddHeader("Content-Type", "application/json");
                        request.RequestFormat = RestSharp.DataFormat.Json;


                        var newissue =
                            new
                        {
                            fields = new Dictionary <string, object>()
                        };
                        newissue.fields.Add("project", new { key = projectKey });
                        newissue.fields.Add("summary", (string.IsNullOrWhiteSpace(issue.markup.Topic.Title)) ? "no title" : issue.markup.Topic.Title);
                        newissue.fields.Add("issuetype", new { id = issuesJira[i].fields.issuetype.id });
                        newissue.fields.Add(UserSettings.Get("guidfield"), issue.guid.ToString());

                        if (issuesJira[i].fields.assignee != null)
                        {
                            newissue.fields.Add("assignee", new { name = issuesJira[i].fields.assignee.name });
                        }

                        if (issuesJira[i].fields.priority != null)
                        {
                            newissue.fields.Add("priority", new { id = issuesJira[i].fields.priority.id });
                        }

                        if (issuesJira[i].fields.components != null && issuesJira[i].fields.components.Any())
                        {
                            newissue.fields.Add("components", issuesJira[i].fields.components);
                        }


                        request.AddBody(newissue);
                        var response = JiraClient.Client.Execute(request);

                        var responseIssue = new Issue();
                        if (RestCallback.Check(response))
                        {
                            responseIssue = RestSharp.SimpleJson.DeserializeObject <Issue>(response.Content);
                            key           = responseIssue.key;//attach and comment sent to the new issue
                        }
                        else
                        {
                            uploadErrors++;
                            break;
                        }

                        //upload viewpoint and snapshot
                        var request2 = new RestRequest("issue/" + key + "/attachments", Method.POST);
                        request2.AddHeader("X-Atlassian-Token", "nocheck");
                        request2.RequestFormat = RestSharp.DataFormat.Json;
                        request2.AddFile("file", File.ReadAllBytes(snapshot), "snapshot.png");
                        request2.AddFile("file", File.ReadAllBytes(viewpoint), "viewpoint.bcfv");
                        var response2 = JiraClient.Client.Execute(request2);
                        RestCallback.Check(response2);

                        //ADD COMMENTS
                        if (issue.markup.Comment.Any())
                        {
                            issue.markup.Comment = new System.Collections.ObjectModel.ObservableCollection <CommentBCF>(issue.markup.Comment.Reverse());
                            foreach (var c in issue.markup.Comment)
                            {
                                var request3 = new RestRequest("issue/" + key + "/comment", Method.POST);
                                request3.AddHeader("Content-Type", "application/json");
                                request3.RequestFormat = RestSharp.DataFormat.Json;
                                var newcomment = new { body = c.Comment1 };
                                request3.AddBody(newcomment);
                                var response3 = JiraClient.Client.Execute <Comment2>(request3);
                                if (!RestCallback.Check(response3))
                                {
                                    break;
                                }
                            }
                        }
                        if (i == issues.Count() - 1)
                        {
                            worker.ReportProgress(100, getProgressString(i + 1));
                        }
                    }
                    else //UPDATE ISSUE
                    {
                        var oldIssue = response4.Data.issues.First();
                        if (issue.markup.Comment.Any())
                        {
                            issue.markup.Comment = new System.Collections.ObjectModel.ObservableCollection <CommentBCF>(issue.markup.Comment.Reverse());
                            foreach (var c in issue.markup.Comment)
                            {
                                string normalized1 = Regex.Replace(c.Comment1, @"\s", "");
                                if (oldIssue.fields.comment.comments.Any(o => Regex.Replace(o.body, @"\s", "").Equals(normalized1, StringComparison.OrdinalIgnoreCase)))
                                {
                                    continue;
                                }

                                var request3 = new RestRequest("issue/" + oldIssue.key + "/comment", Method.POST);
                                request3.AddHeader("Content-Type", "application/json");
                                request3.RequestFormat = RestSharp.DataFormat.Json;
                                var newcomment = new { body = c.Comment1 };
                                request3.AddBody(newcomment);
                                var response3 = JiraClient.Client.Execute <Comment2>(request3);
                                if (!RestCallback.Check(response3))
                                {
                                    break;
                                }
                            }
                        }
                    }
                } // END TRY


                catch (System.Exception ex1)
                {
                    MessageBox.Show("exception: " + ex1);
                }
            }// END LOOP
        }
Пример #5
0
        /// <summary>
        /// Load from BCF 2.0 as BCF 1.0
        /// </summary>
        /// <param name="bcf2">BCF 2.0 file</param>
        /// <returns></returns>
        public static IssueBCF LoadBcf1IssueFromBcf2(BCF2.Markup bcf2Markup, BCF2.VisualizationInfo bcf2Viewpoint)
        {
            // Convert headers
            List<HeaderFile> bcf1Headers = new List<HeaderFile>();
            foreach (BCF2.HeaderFile bcf2Header in bcf2Markup.Header)
            {
                HeaderFile bcf1Header = new HeaderFile()
                {
                    Filename = bcf2Header.Filename,
                    Date = bcf2Header.Date,
                    IfcProject = bcf2Header.IfcProject,
                    IfcSpatialStructureElement = bcf2Header.IfcSpatialStructureElement
                };
                bcf1Headers.Add(bcf1Header);
            }

            // Convert topic
            Topic bcf1Topic = new Topic();
            if (bcf2Markup.Topic != null)
            {
                bcf1Topic.Guid = bcf2Markup.Topic.Guid;
                bcf1Topic.ReferenceLink = bcf2Markup.Topic.ReferenceLink;
                bcf1Topic.Title = bcf2Markup.Topic.Title;
            };

            // Convert comments
            ObservableCollection<CommentBCF> bcf1Comments = new ObservableCollection<CommentBCF>();
            foreach(BCF2.Comment bcf2Comment in bcf2Markup.Comment)
            {
                CommentBCF bcf1Comment = new CommentBCF()
                {
                    Author = bcf2Comment.Author,
                    Comment1 = bcf2Comment.Comment1,
                    Date = bcf2Comment.Date,
                    Guid = bcf2Comment.Guid,
                    Status = CommentStatus.Unknown,    // default unknown for now
                    Topic = new CommentTopic() { Guid = bcf2Markup.Topic == null ? Guid.NewGuid().ToString() : bcf2Markup.Topic.Guid },
                    VerbalStatus = bcf2Comment.VerbalStatus
                };
                bcf1Comments.Add(bcf1Comment);
            }

            // Convert markups/issues
            Markup bcf1Markup = new Markup()
            {
                Header = bcf1Headers.ToArray(),
                Topic = bcf1Topic,
                Comment = bcf1Comments
            };

            // Convert ClippingPlane
            List<ClippingPlane> bcf1ClippingPlanes = new List<ClippingPlane>();
            if (bcf2Viewpoint.ClippingPlanes != null)
            {
                foreach (BCF2.ClippingPlane bcf2ClippingPlane in bcf2Viewpoint.ClippingPlanes)
                {
                    if (bcf2ClippingPlane != null)
                    {
                        bcf1ClippingPlanes.Add(new ClippingPlane()
                        {
                            Direction = new Direction()
                            {
                                X = bcf2ClippingPlane.Direction.X,
                                Y = bcf2ClippingPlane.Direction.Y,
                                Z = bcf2ClippingPlane.Direction.Z
                            },
                            Location = new Point()
                            {
                                X = bcf2ClippingPlane.Location.X,
                                Y = bcf2ClippingPlane.Location.Y,
                                Z = bcf2ClippingPlane.Location.Z
                            }
                        });
                    }
                }
            }

            // Convert Components
            List<Component> bcf1Components = new List<Component>();
            if (bcf2Viewpoint.Components != null)
            {
                foreach (BCF2.Component bcf2Component in bcf2Viewpoint.Components)
                {
                    if (bcf2Component != null)
                    {
                        bcf1Components.Add(new Component()
                        {
                            AuthoringToolId = bcf2Component.AuthoringToolId,
                            IfcGuid = bcf2Component.IfcGuid,
                            OriginatingSystem = bcf2Component.OriginatingSystem
                        });
                    }
                }
            }

            // Convert Lines
            List<Line> bcf1Lines = new List<Line>();
            if (bcf2Viewpoint.Lines != null)
            {
                foreach (BCF2.Line bcf2Line in bcf2Viewpoint.Lines)
                {
                    if (bcf2Line != null)
                    {
                        bcf1Lines.Add(new Line()
                        {
                            StartPoint = new Point()
                            {
                                X = bcf2Line.StartPoint.X,
                                Y = bcf2Line.StartPoint.Y,
                                Z = bcf2Line.StartPoint.Z
                            },
                            EndPoint = new Point()
                            {
                                X = bcf2Line.EndPoint.X,
                                Y = bcf2Line.EndPoint.Y,
                                Z = bcf2Line.EndPoint.Z
                            }
                        });
                    }
                }
            }

            // Convert viewpoints
            VisualizationInfo bcf1Viewpoint = new VisualizationInfo()
            {
                ClippingPlanes = bcf1ClippingPlanes.ToArray(),
                Components = bcf1Components.ToArray(),
                Lines = bcf1Lines.ToArray(),
                OrthogonalCamera = bcf2Viewpoint.OrthogonalCamera == null ? null : new OrthogonalCamera()
                {
                    CameraDirection = new Direction()
                    {
                        X = bcf2Viewpoint.OrthogonalCamera.CameraDirection.X,
                        Y = bcf2Viewpoint.OrthogonalCamera.CameraDirection.Y,
                        Z = bcf2Viewpoint.OrthogonalCamera.CameraDirection.Z
                    },
                    CameraUpVector = new Direction()
                    {
                        X = bcf2Viewpoint.OrthogonalCamera.CameraUpVector.X,
                        Y = bcf2Viewpoint.OrthogonalCamera.CameraUpVector.Y,
                        Z = bcf2Viewpoint.OrthogonalCamera.CameraUpVector.Z
                    },
                    CameraViewPoint = new Point()
                    {
                        X = bcf2Viewpoint.OrthogonalCamera.CameraViewPoint.X,
                        Y = bcf2Viewpoint.OrthogonalCamera.CameraViewPoint.Y,
                        Z = bcf2Viewpoint.OrthogonalCamera.CameraViewPoint.Z
                    },
                    ViewToWorldScale = bcf2Viewpoint.OrthogonalCamera.ViewToWorldScale
                },
                PerspectiveCamera = bcf2Viewpoint.PerspectiveCamera == null ? null : new PerspectiveCamera()
                {
                    CameraDirection = new Direction()
                    {
                        X = bcf2Viewpoint.PerspectiveCamera.CameraDirection.X,
                        Y = bcf2Viewpoint.PerspectiveCamera.CameraDirection.Y,
                        Z = bcf2Viewpoint.PerspectiveCamera.CameraDirection.Z
                    },
                    CameraUpVector = new Direction()
                    {
                        X = bcf2Viewpoint.PerspectiveCamera.CameraUpVector.X,
                        Y = bcf2Viewpoint.PerspectiveCamera.CameraUpVector.Y,
                        Z = bcf2Viewpoint.PerspectiveCamera.CameraUpVector.Z
                    },
                    CameraViewPoint = new Point()
                    {
                        X = bcf2Viewpoint.PerspectiveCamera.CameraViewPoint.X,
                        Y = bcf2Viewpoint.PerspectiveCamera.CameraViewPoint.Y,
                        Z = bcf2Viewpoint.PerspectiveCamera.CameraViewPoint.Z
                    },
                    FieldOfView = bcf2Viewpoint.PerspectiveCamera.FieldOfView
                },
                SheetCamera = bcf2Viewpoint.SheetCamera == null ? null : new SheetCamera()
                {
                    SheetID = bcf2Viewpoint.SheetCamera.SheetID,
                    TopLeft = new Point()
                    {
                        X = bcf2Viewpoint.SheetCamera.TopLeft.X,
                        Y = bcf2Viewpoint.SheetCamera.TopLeft.Y,
                        Z = bcf2Viewpoint.SheetCamera.TopLeft.Z
                    },
                    BottomRight = new Point()
                    {
                        X = bcf2Viewpoint.SheetCamera.BottomRight.X,
                        Y = bcf2Viewpoint.SheetCamera.BottomRight.Y,
                        Z = bcf2Viewpoint.SheetCamera.BottomRight.Z
                    }
                }
            };

            // Create a new BCF 1.0 issue
            IssueBCF bcf1 = new IssueBCF()
            {
                markup = bcf1Markup,
                viewpoint = bcf1Viewpoint
            };

            return bcf1;
        }