From 405bafa31e155ca08a45af51cb6a7a97c7537d23 Mon Sep 17 00:00:00 2001 From: Uros Jovanovic Date: Fri, 2 Jun 2017 18:31:24 +0200 Subject: [PATCH 1/5] Added support for BCF 2.1 schema --- Xbim.BCF.Tests/BCFTests.cs | 24 +- Xbim.BCF.Tests/BCFTestsXMLHelper.cs | 19 +- Xbim.BCF.Tests/XML/Readme.txt | 4 +- Xbim.BCF.Tests/XML/markup.xml | 197 ++++---- Xbim.BCF.Tests/XML/visinfo.xml | 441 ++++++++++-------- Xbim.BCF.Tests/XSD/Readme.txt | 4 +- Xbim.BCF.Tests/XSD/markup.xsd | 300 ++++++------ Xbim.BCF.Tests/XSD/project.xsd | 33 +- Xbim.BCF.Tests/XSD/version.xsd | 21 +- Xbim.BCF.Tests/XSD/visinfo.xsd | 321 +++++++------ Xbim.BCF.nuspec | 4 +- Xbim.BCF/VisualizationXMLFile.cs | 49 +- Xbim.BCF/XMLNodes/BCFComment.cs | 103 +--- Xbim.BCF/XMLNodes/BCFComponent.cs | 56 +-- .../XMLNodes/BCFComponentColoringColor.cs | 67 +++ Xbim.BCF/XMLNodes/BCFComponentSelection.cs | 29 ++ Xbim.BCF/XMLNodes/BCFComponentVisibility.cs | 34 ++ Xbim.BCF/XMLNodes/BCFComponents.cs | 70 +++ Xbim.BCF/XMLNodes/BCFTopic.cs | 99 +++- Xbim.BCF/XMLNodes/BCFViewSetupHints.cs | 33 ++ Xbim.BCF/XMLNodes/BCFViewpoint.cs | 10 + Xbim.BCF/Xbim.BCF.csproj | 7 +- 22 files changed, 1116 insertions(+), 809 deletions(-) create mode 100644 Xbim.BCF/XMLNodes/BCFComponentColoringColor.cs create mode 100644 Xbim.BCF/XMLNodes/BCFComponentSelection.cs create mode 100644 Xbim.BCF/XMLNodes/BCFComponentVisibility.cs create mode 100644 Xbim.BCF/XMLNodes/BCFComponents.cs create mode 100644 Xbim.BCF/XMLNodes/BCFViewSetupHints.cs diff --git a/Xbim.BCF.Tests/BCFTests.cs b/Xbim.BCF.Tests/BCFTests.cs index af27a8f..2eb8bf8 100644 --- a/Xbim.BCF.Tests/BCFTests.cs +++ b/Xbim.BCF.Tests/BCFTests.cs @@ -29,21 +29,18 @@ public void DeserializeMarkupXML() //Comments Assert.IsTrue(xmlObj.Comments.Count > 0); Assert.IsNotNull(xmlObj.Comments[0].Guid); - Assert.IsNotNull(xmlObj.Comments[0].Topic.ID); - Assert.IsNotNull(xmlObj.Comments[0].Status); Assert.IsNotNull(xmlObj.Comments[0].Date); Assert.IsNotNull(xmlObj.Comments[0].Author); Assert.IsNotNull(xmlObj.Comments[0].Comment); Assert.IsNotNull(xmlObj.Comments[0].ModifiedAuthor); Assert.IsNotNull(xmlObj.Comments[0].ModifiedDate); - Assert.IsNotNull(xmlObj.Comments[0].ReplyToComment.ID); - Assert.IsNotNull(xmlObj.Comments[0].VerbalStatus); Assert.IsNotNull(xmlObj.Comments[0].Viewpoint.ID); //Viewpoint Assert.IsTrue(xmlObj.Viewpoints.Count > 0); Assert.IsNotNull(xmlObj.Viewpoints[0].Snapshot); Assert.IsNotNull(xmlObj.Viewpoints[0].Viewpoint); Assert.IsNotNull(xmlObj.Viewpoints[0].ID); + Assert.IsNotNull(xmlObj.Viewpoints[0].Index); //Header Assert.IsNotNull(xmlObj.Header); //Files @@ -58,7 +55,11 @@ public void DeserializeMarkupXML() Assert.IsNotNull(xmlObj.Topic); Assert.IsNotNull(xmlObj.Topic.Guid); Assert.IsNotNull(xmlObj.Topic.Title); + Assert.IsNotNull(xmlObj.Topic.TopicType); + Assert.IsNotNull(xmlObj.Topic.TopicStatus); + Assert.IsNotNull(xmlObj.Topic.DueDate); Assert.IsNotNull(xmlObj.Topic.AssignedTo); + Assert.IsNotNull(xmlObj.Topic.Stage); Assert.IsNotNull(xmlObj.Topic.BimSnippet); Assert.IsNotNull(xmlObj.Topic.BimSnippet.Reference); Assert.IsNotNull(xmlObj.Topic.BimSnippet.SnippetType); @@ -107,13 +108,14 @@ public void DeserializeVisualizationXML() Assert.IsNotNull(xmlObj.ClippingPlanes[0].Direction); Assert.IsNotNull(xmlObj.ClippingPlanes[0].Location); //Components - Assert.IsTrue(xmlObj.Components.Count > 0); - Assert.IsNotNull(xmlObj.Components[0].AuthoringToolId); - Assert.IsNotNull(xmlObj.Components[0].Color); - Assert.IsNotNull(xmlObj.Components[0].IfcGuid); - Assert.IsNotNull(xmlObj.Components[0].OriginatingSystem); - Assert.IsNotNull(xmlObj.Components[0].Selected); - Assert.IsNotNull(xmlObj.Components[0].Visible); + Assert.IsTrue(xmlObj.Components.Selection.Components.Count > 0); + Assert.IsNotNull(xmlObj.Components.Selection.Components[0].AuthoringToolId); + Assert.IsNotNull(xmlObj.Components.Colorings[0].Color); + Assert.IsNotNull(xmlObj.Components.Selection.Components[0].IfcGuid); + Assert.IsNotNull(xmlObj.Components.Selection.Components[0].OriginatingSystem); + Assert.IsNotNull(xmlObj.Components.Selection.Components[0]); + Assert.IsNotNull(xmlObj.Components.Visibility.Exceptions[0]); + Assert.IsNotNull(xmlObj.Components.ViewSetupHints); //Lines Assert.IsTrue(xmlObj.Lines.Count > 0); Assert.IsNotNull(xmlObj.Lines[0].StartPoint); diff --git a/Xbim.BCF.Tests/BCFTestsXMLHelper.cs b/Xbim.BCF.Tests/BCFTestsXMLHelper.cs index 23d6e3c..6ab8ac8 100644 --- a/Xbim.BCF.Tests/BCFTestsXMLHelper.cs +++ b/Xbim.BCF.Tests/BCFTestsXMLHelper.cs @@ -99,12 +99,10 @@ public static MarkupXMLFile BuildMarkupObject() { MarkupXMLFile xmlObj = new MarkupXMLFile(); - BCFComment comment = new BCFComment(Guid.NewGuid(), Guid.NewGuid(), "testStatus", DateTime.Now, "testAuthor", "testComment"); + BCFComment comment = new BCFComment(Guid.NewGuid(), DateTime.Now, "testAuthor", "testComment"); comment.ModifiedAuthor = "testModifiedAuthor"; comment.ModifiedDate = DateTime.Now; - comment.ReplyToComment = new AttrIDNode(Guid.NewGuid()); comment.Viewpoint = new AttrIDNode(Guid.NewGuid()); - comment.VerbalStatus = "testVerbalStatus"; xmlObj.Comments.Add(comment); BCFViewpoint viewp = new BCFViewpoint(Guid.NewGuid()); @@ -123,7 +121,7 @@ public static MarkupXMLFile BuildMarkupObject() f.Reference = "testReference"; xmlObj.Header.Files.Add(f); - xmlObj.Topic = new BCFTopic(Guid.NewGuid(), "testTitle"); + xmlObj.Topic = new BCFTopic(Guid.NewGuid(), "testTitle", DateTime.Now, "testAuthor"); xmlObj.Topic.AssignedTo = "testAssignedTo"; xmlObj.Topic.BimSnippet = new BCFBimSnippet("testSnippetType", "testReference"); xmlObj.Topic.BimSnippet.isExternal = true; @@ -156,7 +154,7 @@ public static VersionXMLFile BuildVersionObject() public static VisualizationXMLFile BuildVisualizationObject() { - VisualizationXMLFile xmlObj = new VisualizationXMLFile(); + VisualizationXMLFile xmlObj = new VisualizationXMLFile(Guid.NewGuid()); Vector testVector = new Vector(1.7976931348623157E+308, 1.7976931348623157E+308, 1.7976931348623157E+308); BCFBitmap bMap = new BCFBitmap(testVector, testVector, testVector, 1.7976931348623157E+308, "PNG", "testReference"); @@ -169,13 +167,14 @@ public static VisualizationXMLFile BuildVisualizationObject() BCFComponent c = new BCFComponent(); c.AuthoringToolId = "testAuthoringToolID"; - c.Color = "7FFFFFFF"; c.IfcGuid = "IfcGuid______________1"; c.OriginatingSystem = "testOriginatingSystem"; - c.Selected = true; - c.Visible = true; - xmlObj.Components.Add(c); - xmlObj.Components.Add(c); + if (xmlObj.Components.Selection == null) + xmlObj.Components.Selection = new BCFComponentSelection(); + xmlObj.Components.Selection.Components.Add(c); + xmlObj.Components.Colorings.Add(new BCFComponentColoringColor("7FFFFFFF")); + xmlObj.Components.Colorings[0].Components.Add(c); + xmlObj.Components.Visibility.Exceptions.Add(c); BCFLine l = new BCFLine(testVector, testVector); xmlObj.Lines.Add(l); diff --git a/Xbim.BCF.Tests/XML/Readme.txt b/Xbim.BCF.Tests/XML/Readme.txt index 9c6ef4d..6af6208 100644 --- a/Xbim.BCF.Tests/XML/Readme.txt +++ b/Xbim.BCF.Tests/XML/Readme.txt @@ -1,3 +1,3 @@ -Generated from Schemas at https://github.com/BuildingSMART/BCF/tree/master/Schemas -Correct as of 15 Dec 2014 +Generated from Schemas at https://github.com/BuildingSMART/BCF-XML/tree/master/Schemas +Correct as of 1 Jun 2017 Guids don't seem to generate properly so amend them by hand \ No newline at end of file diff --git a/Xbim.BCF.Tests/XML/markup.xml b/Xbim.BCF.Tests/XML/markup.xml index 88472ef..625c156 100644 --- a/Xbim.BCF.Tests/XML/markup.xml +++ b/Xbim.BCF.Tests/XML/markup.xml @@ -1,102 +1,97 @@ - - -
- - Filename1 - 1900-01-01T01:01:01+00:00 - Reference1 - - - Filename2 - 0001-01-01T00:00:00+00:00 - Reference2 - - - Filename3 - 9999-12-31T23:59:59.9999999+00:00 - Reference3 - -
- - ReferenceLink1 - Title1 - Priority1 - 1 - Labels1 - Labels2 - Labels3 - 1900-01-01T01:01:01+00:00 - CreationAuthor1 - 1900-01-01T01:01:01+00:00 - ModifiedAuthor1 - AssignedTo1 - Description1 - - Reference1 - ReferenceSchema1 - - - ReferencedDocument1 - Description1 - - - ReferencedDocument2 - Description2 - - - ReferencedDocument3 - Description3 - - - - - - - VerbalStatus1 - Unknown - 1900-01-01T01:01:01+00:00 - Author1 - Comment1 - - - - 1900-01-01T01:01:01+00:00 - ModifiedAuthor1 - - - VerbalStatus2 - Status1 - 2001-01-01T00:00:00+00:00 - Author2 - Comment2 - - - - 0001-01-01T00:00:00+00:00 - ModifiedAuthor2 - - - VerbalStatus3 - Status2 - 9999-12-31T23:59:59.9999999+00:00 - Author3 - Comment3 - - - - 9999-12-31T23:59:59.9999999+00:00 - ModifiedAuthor3 - - - Viewpoint1 - Snapshot1 - - - Viewpoint2 - Snapshot2 - - - Viewpoint3 - Snapshot3 - + + +
+ + Filename1 + 1900-01-01T01:01:01+01:00 + Reference1 + + + Filename2 + 0001-01-01T00:00:00+01:00 + Reference2 + + + Filename3 + 9999-12-31T23:59:59.9999999+01:00 + Reference3 + +
+ + ReferenceLink1 + ReferenceLink2 + ReferenceLink3 + Title1 + Priority1 + 1 + Labels1 + Labels2 + Labels3 + 1900-01-01T01:01:01+01:00 + CreationAuthor1 + 1900-01-01T01:01:01+01:00 + ModifiedAuthor1 + 1900-01-01T01:01:01+01:00 + AssignedTo1 + Stage1 + Description1 + + Reference1 + ReferenceSchema1 + + + ReferencedDocument1 + Description1 + + + ReferencedDocument2 + Description2 + + + ReferencedDocument3 + Description3 + + + + + + + 1900-01-01T01:01:01+01:00 + Author1 + Comment1 + + 1900-01-01T01:01:01+01:00 + ModifiedAuthor1 + + + 0001-01-01T00:00:00+01:00 + Author2 + Comment2 + + 0001-01-01T00:00:00+01:00 + ModifiedAuthor2 + + + 9999-12-31T23:59:59.9999999+01:00 + Author3 + Comment3 + + 9999-12-31T23:59:59.9999999+01:00 + ModifiedAuthor3 + + + Viewpoint1 + Snapshot1 + 1 + + + Viewpoint2 + Snapshot2 + -2147483647 + + + Viewpoint3 + Snapshot3 + 2147483647 +
\ No newline at end of file diff --git a/Xbim.BCF.Tests/XML/visinfo.xml b/Xbim.BCF.Tests/XML/visinfo.xml index 2bca020..962a78d 100644 --- a/Xbim.BCF.Tests/XML/visinfo.xml +++ b/Xbim.BCF.Tests/XML/visinfo.xml @@ -1,189 +1,252 @@ - - - - - OriginatingSystem1 - AuthoringToolId1 - - - OriginatingSystem2 - AuthoringToolId2 - - - OriginatingSystem3 - AuthoringToolId3 - - - - - 1 - 1 - 1 - - - 1 - 1 - 1 - - - 1 - 1 - 1 - - 1 - - - - 1 - 1 - 1 - - - 1 - 1 - 1 - - - 1 - 1 - 1 - - 45 - - - - - 1 - 1 - 1 - - - 1 - 1 - 1 - - - - - -1.7976931348623157E+308 - -1.7976931348623157E+308 - -1.7976931348623157E+308 - - - -1.7976931348623157E+308 - -1.7976931348623157E+308 - -1.7976931348623157E+308 - - - - - 1.7976931348623157E+308 - 1.7976931348623157E+308 - 1.7976931348623157E+308 - - - 1.7976931348623157E+308 - 1.7976931348623157E+308 - 1.7976931348623157E+308 - - - - - - - 1 - 1 - 1 - - - 1 - 1 - 1 - - - - - -1.7976931348623157E+308 - -1.7976931348623157E+308 - -1.7976931348623157E+308 - - - -1.7976931348623157E+308 - -1.7976931348623157E+308 - -1.7976931348623157E+308 - - - - - 1.7976931348623157E+308 - 1.7976931348623157E+308 - 1.7976931348623157E+308 - - - 1.7976931348623157E+308 - 1.7976931348623157E+308 - 1.7976931348623157E+308 - - - - - PNG - Reference1 - - 1 - 1 - 1 - - - 1 - 1 - 1 - - - 1 - 1 - 1 - - 1 - - - JPG - Reference2 - - -1.7976931348623157E+308 - -1.7976931348623157E+308 - -1.7976931348623157E+308 - - - -1.7976931348623157E+308 - -1.7976931348623157E+308 - -1.7976931348623157E+308 - - - -1.7976931348623157E+308 - -1.7976931348623157E+308 - -1.7976931348623157E+308 - - -1.7976931348623157E+308 - - - PNG - Reference3 - - 1.7976931348623157E+308 - 1.7976931348623157E+308 - 1.7976931348623157E+308 - - - 1.7976931348623157E+308 - 1.7976931348623157E+308 - 1.7976931348623157E+308 - - - 1.7976931348623157E+308 - 1.7976931348623157E+308 - 1.7976931348623157E+308 - - 1.7976931348623157E+308 - - + + + + + + + OriginatingSystem1 + AuthoringToolId1 + + + OriginatingSystem2 + AuthoringToolId2 + + + OriginatingSystem3 + AuthoringToolId3 + + + + + + OriginatingSystem1 + AuthoringToolId1 + + + OriginatingSystem2 + AuthoringToolId2 + + + OriginatingSystem3 + AuthoringToolId3 + + + + + + + OriginatingSystem1 + AuthoringToolId1 + + + OriginatingSystem2 + AuthoringToolId2 + + + OriginatingSystem3 + AuthoringToolId3 + + + + + OriginatingSystem4 + AuthoringToolId4 + + + OriginatingSystem5 + AuthoringToolId5 + + + OriginatingSystem6 + AuthoringToolId6 + + + + + OriginatingSystem7 + AuthoringToolId7 + + + OriginatingSystem8 + AuthoringToolId8 + + + OriginatingSystem9 + AuthoringToolId9 + + + + + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + 1 + + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + 45 + + + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + + + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + + + PNG + Reference1 + + 1 + 1 + 1 + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + 1 + + + JPG + Reference2 + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + -1.7976931348623157E+308 + + + PNG + Reference3 + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + 1.7976931348623157E+308 + + \ No newline at end of file diff --git a/Xbim.BCF.Tests/XSD/Readme.txt b/Xbim.BCF.Tests/XSD/Readme.txt index c7e2acb..8ad9ad5 100644 --- a/Xbim.BCF.Tests/XSD/Readme.txt +++ b/Xbim.BCF.Tests/XSD/Readme.txt @@ -1,2 +1,2 @@ -Schemas from https://github.com/BuildingSMART/BCF/tree/master/Schemas -Correct as of 15 Dec 2014 \ No newline at end of file +Schemas from https://github.com/BuildingSMART/BCF-XML/tree/master/Schemas +Correct as of 1 Jun 2017 \ No newline at end of file diff --git a/Xbim.BCF.Tests/XSD/markup.xsd b/Xbim.BCF.Tests/XSD/markup.xsd index 72e14c7..037464e 100644 --- a/Xbim.BCF.Tests/XSD/markup.xsd +++ b/Xbim.BCF.Tests/XSD/markup.xsd @@ -1,158 +1,154 @@ - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Xbim.BCF.Tests/XSD/project.xsd b/Xbim.BCF.Tests/XSD/project.xsd index d45281f..8203889 100644 --- a/Xbim.BCF.Tests/XSD/project.xsd +++ b/Xbim.BCF.Tests/XSD/project.xsd @@ -1,17 +1,18 @@ - + + - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + diff --git a/Xbim.BCF.Tests/XSD/version.xsd b/Xbim.BCF.Tests/XSD/version.xsd index b795886..55cbd2b 100644 --- a/Xbim.BCF.Tests/XSD/version.xsd +++ b/Xbim.BCF.Tests/XSD/version.xsd @@ -1,11 +1,12 @@ - + + - - - - - - - - - \ No newline at end of file + + + + + + + + + diff --git a/Xbim.BCF.Tests/XSD/visinfo.xsd b/Xbim.BCF.Tests/XSD/visinfo.xsd index 7ddcaa1..6507d28 100644 --- a/Xbim.BCF.Tests/XSD/visinfo.xsd +++ b/Xbim.BCF.Tests/XSD/visinfo.xsd @@ -1,132 +1,191 @@ - + + - - - visualiztioninfo documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - view's visible size in meters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + VisualizationInfo documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + view's visible size in meters + + + + + + + + + + + + + It is currently limited to a value between 45 and 60 degrees. + This limitation will be dropped in the next release and viewers + should be expect values outside this range in current implementations. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Xbim.BCF.nuspec b/Xbim.BCF.nuspec index 89eb346..e8e5899 100644 --- a/Xbim.BCF.nuspec +++ b/Xbim.BCF.nuspec @@ -2,7 +2,7 @@ Xbim.Bcf - 4.0.0 + 4.1.0 xBIM BCF xBIM team Steve Lockley @@ -22,7 +22,7 @@ IOS and Android versions are under development. BIM, IFC, IfcXml, IfcZip, COBie, .Net, C#, BuildingSmart, BCF, Bim Collaboration Format - + diff --git a/Xbim.BCF/VisualizationXMLFile.cs b/Xbim.BCF/VisualizationXMLFile.cs index 0ea3e18..d3644a9 100644 --- a/Xbim.BCF/VisualizationXMLFile.cs +++ b/Xbim.BCF/VisualizationXMLFile.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Xml.Linq; using System.Linq; using System.Xml.Serialization; @@ -9,8 +10,26 @@ namespace Xbim.BCF [XmlType("VisualizationInfo")] public class VisualizationXMLFile { - [XmlArray(Order = 1)] - public List Components; + private Guid _guid; + [XmlAttribute] + public Guid Guid + { + get { return _guid; } + set + { + if (value == null || value == System.Guid.Empty) + { + throw new ArgumentException(this.GetType().Name + " - Guid attribute is mandatory and must contain a valid Guid value"); + } + else + { + _guid = value; + } + } + } + + [XmlElement(Order = 1)] + public BCFComponents Components; [XmlElement(Order = 2)] public BCFOrthogonalCamera OrthogonalCamera { get; set; } [XmlElement(Order = 3)] @@ -19,12 +38,17 @@ public class VisualizationXMLFile public List Lines; [XmlArray(Order = 5)] public List ClippingPlanes; - [XmlElement(ElementName = "Bitmaps", Order = 6)] + [XmlElement(ElementName = "Bitmap", Order = 6)] public List Bitmaps; - public VisualizationXMLFile() + private VisualizationXMLFile() + { + } + + public VisualizationXMLFile(Guid id) { - Components = new List(); + Guid = id; + Components = new BCFComponents(); Lines = new List(); ClippingPlanes = new List(); Bitmaps = new List(); @@ -32,11 +56,13 @@ public VisualizationXMLFile() public VisualizationXMLFile(XDocument xdoc) { - Components = new List(); + Components = new BCFComponents(); Lines = new List(); ClippingPlanes = new List(); Bitmaps = new List(); + Guid = (System.Guid?)xdoc.Root.Attribute("Guid") ?? System.Guid.Empty; + var orth = xdoc.Root.Elements("OrthogonalCamera").FirstOrDefault(); if (orth != null) { @@ -47,9 +73,10 @@ public VisualizationXMLFile(XDocument xdoc) { PerspectiveCamera = new BCFPerspectiveCamera(pers); } - foreach (var comp in xdoc.Root.Element("Components").Elements("Component")) + var components = xdoc.Root.Element("Components"); + if (components != null) { - Components.Add(new BCFComponent(comp)); + Components = new BCFComponents(components); } var lines = xdoc.Root.Elements("Lines").FirstOrDefault(); if (lines != null) @@ -67,10 +94,10 @@ public VisualizationXMLFile(XDocument xdoc) ClippingPlanes.Add(new BCFClippingPlane(plane)); } } - var bitmaps = xdoc.Root.Elements("Bitmaps").FirstOrDefault(); + var bitmaps = xdoc.Root.Elements("Bitmap").FirstOrDefault(); if (bitmaps != null) { - foreach (var bmap in xdoc.Root.Elements("Bitmaps")) + foreach (var bmap in xdoc.Root.Elements("Bitmap")) { Bitmaps.Add(new BCFBitmap(bmap)); } diff --git a/Xbim.BCF/XMLNodes/BCFComment.cs b/Xbim.BCF/XMLNodes/BCFComment.cs index 7809492..058745b 100644 --- a/Xbim.BCF/XMLNodes/BCFComment.cs +++ b/Xbim.BCF/XMLNodes/BCFComment.cs @@ -8,18 +8,9 @@ namespace Xbim.BCF.XMLNodes [XmlType("Comment")] public class BCFComment { - /// - /// A free text status. The options for this can be agreed, for example, in a project. - /// - [XmlElement(Order = 1)] - public String VerbalStatus { get; set; } - public bool ShouldSerializeVerbalStatus() - { - return !string.IsNullOrEmpty(VerbalStatus); - } private Guid _guid; /// - /// Unique Identifier for this topic + /// Unique Identifier for this comment /// [XmlAttribute] public Guid Guid @@ -37,37 +28,17 @@ public Guid Guid } } } - private String _status; - /// - /// Status of the comment / topic (Predefined list in “extension.xsd”) - /// - [XmlElement(Order = 2)] - public String Status - { - get { return _status; } - set - { - if (String.IsNullOrEmpty(value)) - { - throw new ArgumentException(this.GetType().Name + " - Status is mandatory"); - } - else - { - _status = value; - } - } - } private DateTime _date; /// /// Date of the comment /// - [XmlElement(Order = 3)] + [XmlElement(Order = 1)] public DateTime Date { get { return _date; } set { - if (value == null || value == DateTime.MinValue) + if (value == null) { throw new ArgumentException(this.GetType().Name + " - Date is mandatory"); } @@ -81,7 +52,7 @@ public DateTime Date /// /// Comment author /// - [XmlElement(Order = 4)] + [XmlElement(Order = 2)] public String Author { get { return _author; } @@ -97,68 +68,24 @@ public String Author } } } - private String _comment; /// /// The comment text /// - [XmlElement(Order = 5)] - public String Comment - { - get { return _comment; } - set - { - if (String.IsNullOrEmpty(value)) - { - throw new ArgumentException(this.GetType().Name + " - Comment text is mandatory"); - } - else - { - _comment = value; - } - } - } - private AttrIDNode _topic; - /// - /// Back reference to the topic - /// - [XmlElement(Order = 6)] - public AttrIDNode Topic - { - get { return _topic; } - set - { - if (value == null) - { - throw new ArgumentException(this.GetType().Name + " - Topic is mandatory and must contain a valid Guid value"); - } - else - { - _topic = value; - } - } - } + [XmlElement(Order = 3)] + public String Comment { get; set; } /// /// Reference back to Viewpoint /// - [XmlElement(Order = 7)] + [XmlElement(Order = 4)] public AttrIDNode Viewpoint { get; set; } public bool ShouldSerializeViewpoint() { return Viewpoint != null; } /// - /// Guid of the comment to which this comment is a reply - /// - [XmlElement(Order = 8)] - public AttrIDNode ReplyToComment { get; set; } - public bool ShouldSerializeReplyToComment() - { - return ReplyToComment != null; - } - /// /// The date when comment was modified /// - [XmlElement(Order = 9)] + [XmlElement(Order = 5)] public DateTime? ModifiedDate { get; set; } public bool ShouldSerializeModifiedDate() { @@ -167,7 +94,7 @@ public bool ShouldSerializeModifiedDate() /// /// The author who modified the comment /// - [XmlElement(Order = 10)] + [XmlElement(Order = 6)] public String ModifiedAuthor { get; set; } public bool ShouldSerializeModifiedAuthor() { @@ -178,33 +105,23 @@ public bool ShouldSerializeModifiedAuthor() private BCFComment() { } - public BCFComment(Guid id, Guid topicId, String status, DateTime date, String author, String comment) + public BCFComment(Guid id, DateTime date, String author, String comment) { - Status = status; Date = date; Author = author; Comment = comment; Guid = id; - Topic = new AttrIDNode(topicId); } public BCFComment(XElement node) { this.Guid = (System.Guid?)node.Attribute("Guid") ?? System.Guid.Empty; - Status = (String)node.Element("Status") ?? ""; Date = (DateTime?)node.Element("Date") ?? DateTime.MinValue; Author = (String)node.Element("Author") ?? ""; Comment = (String)node.Element("Comment") ?? ""; ModifiedDate = (DateTime?)node.Element("ModifiedDate") ?? null; ModifiedAuthor = (String)node.Element("ModifiedAuthor") ?? ""; - VerbalStatus = (String)node.Element("VerbalStatus") ?? ""; - Topic = new AttrIDNode(node.Element("Topic")); - var reply = node.Elements("ReplyToComment").FirstOrDefault(); - if (reply != null) - { - ReplyToComment = new AttrIDNode(node.Element("ReplyToComment")); - } var viewp = node.Elements("Viewpoint").FirstOrDefault(); if (viewp != null) { diff --git a/Xbim.BCF/XMLNodes/BCFComponent.cs b/Xbim.BCF/XMLNodes/BCFComponent.cs index 6638289..ff30636 100644 --- a/Xbim.BCF/XMLNodes/BCFComponent.cs +++ b/Xbim.BCF/XMLNodes/BCFComponent.cs @@ -9,30 +9,6 @@ namespace Xbim.BCF.XMLNodes [XmlType("Component")] public class BCFComponent { - private String _color; - /// - /// Color of the component. This can be used to provide special highlighting of components in the viewpoint. The color is given in ARGB format - /// - [XmlAttribute] - public String Color - { - get { return _color; } - set - { - if (!String.IsNullOrEmpty(value) && IsHex(value)) - { - _color = value; - } - else - { - throw new ArgumentException(this.GetType().Name + " - Color - must be a valid hex sequence"); - } - } - } - public bool ShouldSerializeColor() - { - return !string.IsNullOrEmpty(Color); - } private String _ifcGuid; /// /// The id of the component selected in a BIM tool @@ -75,45 +51,15 @@ public bool ShouldSerializeAuthoringToolId() { return !string.IsNullOrEmpty(AuthoringToolId); } - /// - /// This flag is true if the component is actually involved in the topic. If the flag is false, the component is involved as reference - /// - [XmlAttribute] - public bool Selected { get; set; } - /// - /// This flag is true when the component is visible in the visualization. - /// By setting this false, you can hide components that would prevent seeing the topic from the camera position and angle of the viewpoint. - /// Default is true. - /// - [XmlAttribute] - public bool Visible { get; set; } - public BCFComponent() + public BCFComponent() { } public BCFComponent(XElement node) { IfcGuid = (String)node.Attribute("IfcGuid") ?? ""; - Visible = (bool?)node.Attribute("Visible") ?? true; - Selected = (bool?)node.Attribute("Selected") ?? false; - Color = (String)node.Attribute("Color") ?? ""; OriginatingSystem = (String)node.Element("OriginatingSystem") ?? ""; AuthoringToolId = (String)node.Element("AuthoringToolId") ?? ""; } - - private bool IsHex(IEnumerable chars) - { - bool isHex; - foreach (var c in chars) - { - isHex = ((c >= '0' && c <= '9') || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F')); - - if (!isHex) - return false; - } - return true; - } } } diff --git a/Xbim.BCF/XMLNodes/BCFComponentColoringColor.cs b/Xbim.BCF/XMLNodes/BCFComponentColoringColor.cs new file mode 100644 index 0000000..5f5b834 --- /dev/null +++ b/Xbim.BCF/XMLNodes/BCFComponentColoringColor.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml.Linq; +using System.Xml.Serialization; + +namespace Xbim.BCF.XMLNodes +{ + [XmlType("Color")] + public class BCFComponentColoringColor + { + private string _color; + [XmlAttribute] + public string Color + { + get { return _color; } + set + { + if (!string.IsNullOrEmpty(value) && IsHex(value)) + { + _color = value; + } + else + { + throw new ArgumentException(this.GetType().Name + " - Color - must be a valid hex sequence"); + } + } + } + + [XmlElement("Component")] + public List Components; + public bool ShouldSerializeComponent() + { + return Components != null && Components.Count > 0; + } + + private BCFComponentColoringColor() + { } + + public BCFComponentColoringColor(string color) + { + Color = color; + Components = new List(); + } + + public BCFComponentColoringColor(XElement node) + { + Color = (string)node.Attribute("Color"); + Components = new List(node.Elements("Component").Select(n => new BCFComponent(n))); + } + + private bool IsHex(IEnumerable chars) + { + bool isHex; + foreach (var c in chars) + { + isHex = ((c >= '0' && c <= '9') || + (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F')); + + if (!isHex) + return false; + } + return true; + } + } +} diff --git a/Xbim.BCF/XMLNodes/BCFComponentSelection.cs b/Xbim.BCF/XMLNodes/BCFComponentSelection.cs new file mode 100644 index 0000000..bf26dd2 --- /dev/null +++ b/Xbim.BCF/XMLNodes/BCFComponentSelection.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml.Linq; +using System.Xml.Serialization; + +namespace Xbim.BCF.XMLNodes +{ + [XmlType("ComponentSelection")] + public class BCFComponentSelection + { + [XmlElement(ElementName = "Component")] + public List Components; + public bool ShouldSerializeComponent() + { + return Components != null && Components.Count > 0; + } + + public BCFComponentSelection() + { + Components = new List(); + } + + public BCFComponentSelection(XElement node) + { + Components = new List(node.Elements("Component").Select(c => new BCFComponent(c))); + } + } +} diff --git a/Xbim.BCF/XMLNodes/BCFComponentVisibility.cs b/Xbim.BCF/XMLNodes/BCFComponentVisibility.cs new file mode 100644 index 0000000..a2d054e --- /dev/null +++ b/Xbim.BCF/XMLNodes/BCFComponentVisibility.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml.Linq; +using System.Xml.Serialization; + +namespace Xbim.BCF.XMLNodes +{ + [XmlType("ComponentVisibility")] + public class BCFComponentVisibility + { + [XmlAttribute] + public bool DefaultVisibility { get; set; } + + [XmlArray("Exceptions")] + public List Exceptions; + public bool ShouldSerializeExceptions() + { + return Exceptions != null && Exceptions.Count > 0; + } + + public BCFComponentVisibility() + { + DefaultVisibility = false; + Exceptions = new List(); + } + + public BCFComponentVisibility(XElement node) + { + DefaultVisibility = (bool?)node.Attribute("DefaultVisibility") ?? false; + Exceptions = new List(node.Element("Exceptions")?.Elements("Component").Select(n => new BCFComponent(n)) ?? Enumerable.Empty()); + } + } +} diff --git a/Xbim.BCF/XMLNodes/BCFComponents.cs b/Xbim.BCF/XMLNodes/BCFComponents.cs new file mode 100644 index 0000000..ca89947 --- /dev/null +++ b/Xbim.BCF/XMLNodes/BCFComponents.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml.Linq; +using System.Xml.Serialization; + +namespace Xbim.BCF.XMLNodes +{ + [XmlType("Components")] + public class BCFComponents + { + [XmlElement(ElementName ="ViewSetupHints", Order = 1)] + public BCFViewSetupHints ViewSetupHints { get; set; } + public bool ShouldSerializeViewSetupHints() + { + return ViewSetupHints != null; + } + + [XmlElement(ElementName = "Selection", Order = 2)] + public BCFComponentSelection Selection { get; set; } + public bool ShouldSerializeSelection() + { + return Selection != null; + } + + private BCFComponentVisibility _visibility; + [XmlElement(ElementName = "Visibility", Order = 3)] + public BCFComponentVisibility Visibility + { + get { return _visibility; } + set + { + if (ReferenceEquals(value, null)) + { + throw new ArgumentException(this.GetType().Name + " - Visibility is mandatory"); + } + else + { + _visibility = value; + } + } + } + + [XmlArray(ElementName = "Coloring", Order = 4)] + public List Colorings; + public bool ShouldSerializeExceptions() + { + return Colorings != null && Colorings.Count > 0; + } + + public BCFComponents() + { + Visibility = new BCFComponentVisibility(); + Colorings = new List(); + } + + public BCFComponents(XElement node) + { + var hints = node.Element("ViewSetupHints"); + ViewSetupHints = hints != null ? new BCFViewSetupHints(hints) : null; + var selection = node.Element("Selection"); + Selection = selection != null ? new BCFComponentSelection(selection) : null; + var visibility = node.Element("Visibility"); + Visibility = visibility != null ? new BCFComponentVisibility(visibility) : null; + var coloring = node.Element("Coloring"); + if (coloring != null) + Colorings = new List(coloring.Elements("Color").Select(c => new BCFComponentColoringColor(c.Attribute("Color")?.Value))); + } + } +} diff --git a/Xbim.BCF/XMLNodes/BCFTopic.cs b/Xbim.BCF/XMLNodes/BCFTopic.cs index d37d572..3f9bf4a 100644 --- a/Xbim.BCF/XMLNodes/BCFTopic.cs +++ b/Xbim.BCF/XMLNodes/BCFTopic.cs @@ -60,11 +60,11 @@ public bool ShouldSerializeTopicType() /// /// Reference to the topic in, for example, a work request management system /// - [XmlElement(Order = 2)] - public String ReferenceLink { get; set; } + [XmlElement(ElementName = "ReferenceLink", Order = 2)] + public List ReferenceLinks; public bool ShouldSerializeReferenceLink() { - return !string.IsNullOrEmpty(ReferenceLink); + return ReferenceLinks != null && ReferenceLinks.Count > 0; } /// /// Description of the topic @@ -93,25 +93,46 @@ public bool ShouldSerializeIndex() { return Index != null; } + private DateTime? _creationDate; /// /// Date when the topic was created /// [XmlElement(Order = 6)] - public DateTime? CreationDate { get; set; } - public bool ShouldSerializeCreationDate() - { - return CreationDate != null; + public DateTime? CreationDate + { + get { return _creationDate; } + set + { + if (ReferenceEquals(value, null)) + { + throw new ArgumentException(this.GetType().Name + " - CreationDate is mandatory"); + } + else + { + _creationDate = value; + } + } } + private String _creationAuthor; /// /// User who created the topic /// [XmlElement(Order = 7)] - public String CreationAuthor { get; set; } - public bool ShouldSerializeCreationAuthor() + public String CreationAuthor { - return !string.IsNullOrEmpty(CreationAuthor); + get { return _creationAuthor; } + set + { + if (String.IsNullOrEmpty(value)) + { + throw new ArgumentException(this.GetType().Name + " - CreationAuthor is mandatory"); + } + else + { + _creationAuthor = value; + } + } } - /// /// Date when the topic was last modified /// [XmlElement(Order = 8)] @@ -130,18 +151,36 @@ public bool ShouldSerializeModifiedAuthor() return !string.IsNullOrEmpty(ModifiedAuthor); } /// - /// The user to whom this topic is assigned to + /// Due date /// [XmlElement(Order = 10)] + public DateTime? DueDate { get; set; } + public bool ShouldSerializeDueDate() + { + return DueDate != null; + } + /// + /// The user to whom this topic is assigned to + /// + [XmlElement(Order = 11)] public String AssignedTo { get; set; } public bool ShouldSerializeAssignedTo() { return !string.IsNullOrEmpty(AssignedTo); + } + /// + /// Stage + /// + [XmlElement(Order = 12)] + public String Stage { get; set; } + public bool ShouldSerializeStage() + { + return !string.IsNullOrEmpty(Stage); } /// /// The status of the topic (the options can be specified in the extension schema) /// - [XmlElement(Order = 11)] + [XmlAttribute] public String TopicStatus { get; set; } public bool ShouldSerializeTopicStatus() { @@ -150,7 +189,7 @@ public bool ShouldSerializeTopicStatus() /// /// BimSnippet is an additional file containing information related to one or multiple topics. For example, it can be an IFC file containing provisions for voids. /// - [XmlElement(Order = 12)] + [XmlElement(Order = 13)] public BCFBimSnippet BimSnippet { get; set; } public bool ShouldSerializeBimSnippet() { @@ -159,7 +198,7 @@ public bool ShouldSerializeBimSnippet() /// /// DocumentReference provides a means to associate additional payloads or links with topics. The references may point to a file within the .bcfzip or to an external location. /// - [XmlElement(ElementName = "DocumentReferences", Order = 13)] + [XmlElement(ElementName = "DocumentReference", Order = 14)] public List DocumentReferences; public bool ShouldSerializeDocumentReferences() { @@ -168,7 +207,7 @@ public bool ShouldSerializeDocumentReferences() /// /// Relation between topics (Clash -> PfV -> Opening) /// - [XmlElement(ElementName = "RelatedTopics", Order = 14)] + [XmlElement(ElementName = "RelatedTopic", Order = 15)] public List RelatedTopics; public bool ShouldSerializeRelatedTopics() { @@ -179,10 +218,13 @@ public bool ShouldSerializeRelatedTopics() private BCFTopic() { } - public BCFTopic(Guid topicID, String title) + public BCFTopic(Guid topicID, String title, DateTime date, String author) { Guid = topicID; Title = title; + CreationDate = date; + CreationAuthor = author; + ReferenceLinks = new List(); DocumentReferences = new List(); RelatedTopics = new List(); } @@ -191,11 +233,11 @@ public BCFTopic(XElement node) { DocumentReferences = new List(); RelatedTopics = new List(); + ReferenceLinks = new List(); this.Guid = Guid.Parse((String)node.Attribute("Guid") ?? ""); Title = (String)node.Element("Title") ?? ""; TopicType = (String)node.Attribute("TopicType") ?? ""; - ReferenceLink = (String)node.Element("ReferenceLink") ?? ""; Description = (String)node.Element("Description") ?? ""; Priority = (String)node.Element("Priority") ?? ""; Index = (int?)node.Element("Index") ?? null; @@ -203,8 +245,19 @@ public BCFTopic(XElement node) CreationAuthor = (String)node.Element("CreationAuthor") ?? ""; ModifiedDate = (DateTime?)node.Element("ModifiedDate") ?? null; ModifiedAuthor = (String)node.Element("ModifiedAuthor") ?? ""; + DueDate = (DateTime?)node.Element("DueDate") ?? null; AssignedTo = (String)node.Element("AssignedTo") ?? ""; - TopicStatus = (String)node.Element("TopicStatus") ?? ""; + Stage = (String)node.Element("Stage") ?? ""; + TopicStatus = (String)node.Attribute("TopicStatus") ?? ""; + + var refLinks = node.Elements("ReferenceLink").FirstOrDefault(); + if (refLinks != null) + { + foreach (var refLink in node.Elements("ReferenceLink")) + { + ReferenceLinks.Add(refLink.Value); + } + } var bimSnippet = node.Elements("BimSnippet").FirstOrDefault(); if (bimSnippet != null) @@ -212,19 +265,19 @@ public BCFTopic(XElement node) BimSnippet = new BCFBimSnippet(bimSnippet); } - var docRefs = node.Elements("DocumentReferences").FirstOrDefault(); + var docRefs = node.Elements("DocumentReference").FirstOrDefault(); if (docRefs != null) { - foreach (var dref in node.Elements("DocumentReferences")) + foreach (var dref in node.Elements("DocumentReference")) { DocumentReferences.Add(new BCFDocumentReference(dref)); } } - var relTopics = node.Elements("RelatedTopics").FirstOrDefault(); + var relTopics = node.Elements("RelatedTopic").FirstOrDefault(); if (relTopics != null) { - foreach (var rt in node.Elements("RelatedTopics")) + foreach (var rt in node.Elements("RelatedTopic")) { RelatedTopics.Add(new BCFRelatedTopic(rt)); } diff --git a/Xbim.BCF/XMLNodes/BCFViewSetupHints.cs b/Xbim.BCF/XMLNodes/BCFViewSetupHints.cs new file mode 100644 index 0000000..3a7c165 --- /dev/null +++ b/Xbim.BCF/XMLNodes/BCFViewSetupHints.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using System.Xml.Serialization; + +namespace Xbim.BCF.XMLNodes +{ + [XmlType("ViewSetupHints")] + public class BCFViewSetupHints + { + [XmlAttribute] + public bool SpacesVisible { get; set; } + + [XmlAttribute] + public bool SpaceBoundariesVisible { get; set; } + + [XmlAttribute] + public bool OpeningsVisible { get; set; } + + public BCFViewSetupHints() + { } + + public BCFViewSetupHints(XElement node) + { + SpacesVisible = (bool?)node.Attribute("SpacesVisible") ?? false; + SpaceBoundariesVisible = (bool?)node.Attribute("SpaceBoundariesVisible") ?? false; + OpeningsVisible = (bool?)node.Attribute("OpeningsVisible") ?? false; + } + } +} diff --git a/Xbim.BCF/XMLNodes/BCFViewpoint.cs b/Xbim.BCF/XMLNodes/BCFViewpoint.cs index 6c3e742..8ed14d0 100644 --- a/Xbim.BCF/XMLNodes/BCFViewpoint.cs +++ b/Xbim.BCF/XMLNodes/BCFViewpoint.cs @@ -44,6 +44,15 @@ public bool ShouldSerializeSnapshot() { return !string.IsNullOrEmpty(Snapshot); } + /// + /// Index + /// + [XmlElement(Order = 3)] + public int? Index { get; set; } + public bool ShouldSerializeIndex() + { + return Index != null; + } private BCFViewpoint() { } @@ -58,6 +67,7 @@ public BCFViewpoint(XElement node) ID = (System.Guid?)node.Attribute("Guid") ?? System.Guid.Empty; Viewpoint = (String)node.Element("Viewpoint") ?? ""; Snapshot = (String)node.Element("Snapshot") ?? ""; + Index = (int?)node.Element("Index"); } } } diff --git a/Xbim.BCF/Xbim.BCF.csproj b/Xbim.BCF/Xbim.BCF.csproj index 4658230..5d16d1c 100644 --- a/Xbim.BCF/Xbim.BCF.csproj +++ b/Xbim.BCF/Xbim.BCF.csproj @@ -53,7 +53,7 @@ Properties\SharedAssemblyInfo.cs - + Properties\SharedFileVersionInfo.cs @@ -64,6 +64,11 @@ + + + + + From add9f6c43f9e4b4575d119f18b3f43132dcb4100 Mon Sep 17 00:00:00 2001 From: Luka Djuric Date: Wed, 19 Jul 2017 13:57:10 +0200 Subject: [PATCH 2/5] Support for per comment visualizations as proposed by BCF 2.1 --- Xbim.BCF.nuspec | 2 +- Xbim.BCF/BCF.cs | 21 ++++++++++++--------- Xbim.BCF/Topic.cs | 8 +++++--- Xbim.BCF/ZipArchiveEntryExtensions.cs | 13 +++++++++++++ 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Xbim.BCF.nuspec b/Xbim.BCF.nuspec index e8e5899..90cba7d 100644 --- a/Xbim.BCF.nuspec +++ b/Xbim.BCF.nuspec @@ -2,7 +2,7 @@ Xbim.Bcf - 4.1.0 + 4.1.1 xBIM BCF xBIM team Steve Lockley diff --git a/Xbim.BCF/BCF.cs b/Xbim.BCF/BCF.cs index 8511732..5e96156 100644 --- a/Xbim.BCF/BCF.cs +++ b/Xbim.BCF/BCF.cs @@ -73,7 +73,7 @@ public static BCF Deserialize(Stream BCFZipData) currentGuid = entry.ExtractGuidFolderName(); currentTopic = new Topic(); } - currentTopic.Visualization = new VisualizationXMLFile(XDocument.Load(entry.Open())); + currentTopic.Visualizations.Add(entry.ExtractFileName(), new VisualizationXMLFile(XDocument.Load(entry.Open()))); } else if (entry.FullName.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) { @@ -89,7 +89,7 @@ public static BCF Deserialize(Stream BCFZipData) using (MemoryStream ms = new MemoryStream()) { entry.Open().CopyTo(ms); - currentTopic.Snapshots.Add(new KeyValuePair(entry.FullName, ms.ToArray())); + currentTopic.Snapshots.Add(new KeyValuePair(entry.ExtractFileName(), ms.ToArray())); } } } @@ -153,14 +153,17 @@ public Stream Serialize() } } - string bcfvName = t.Markup.Topic.Guid.ToString() + "/viewpoint.bcfv"; - var bcfv = archive.CreateEntry(bcfvName); - using (var bcfvStream = bcfv.Open()) + foreach (var visualization in t.Visualizations) { - using (var bcfvWriter = new StreamWriter(bcfvStream)) - { - bcfvSerializer.Serialize(bcfvWriter, t.Visualization); - bcfvWriter.Close(); + string bcfvName = string.Format("{0}/{1}", t.Markup.Topic.Guid, visualization.Key); + var bcfv = archive.CreateEntry(bcfvName); + using (var bcfvStream = bcfv.Open()) + { + using (var bcfvWriter = new StreamWriter(bcfvStream)) + { + bcfvSerializer.Serialize(bcfvWriter, visualization.Value); + bcfvWriter.Close(); + } } } diff --git a/Xbim.BCF/Topic.cs b/Xbim.BCF/Topic.cs index 6b7602f..9579eea 100644 --- a/Xbim.BCF/Topic.cs +++ b/Xbim.BCF/Topic.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; -using System.IO; +using System.Linq; +using System.IO; using System.Xml.Linq; using System.Xml.Serialization; using Xbim.BCF.XMLNodes; @@ -14,9 +15,9 @@ public class Topic /// public MarkupXMLFile Markup { get; set; } /// - /// .bcfv File Projection + /// Collection of key/value pairs representing the (Key)name and (Value).bcfv file projection of a .bcfv file associated with the topic /// - public VisualizationXMLFile Visualization { get; set; } + public Dictionary Visualizations { get; set; } /// /// Collection of key/value pairs representing the (Key)name and (Value)Base64 String representations of a .png file associated with the topic /// @@ -25,6 +26,7 @@ public class Topic public Topic() { Snapshots = new List>(); + Visualizations = new Dictionary(); } } } diff --git a/Xbim.BCF/ZipArchiveEntryExtensions.cs b/Xbim.BCF/ZipArchiveEntryExtensions.cs index af6383c..bd4766b 100644 --- a/Xbim.BCF/ZipArchiveEntryExtensions.cs +++ b/Xbim.BCF/ZipArchiveEntryExtensions.cs @@ -17,5 +17,18 @@ public static Guid ExtractGuidFolderName(this ZipArchiveEntry entry) throw new ArgumentException("Topic folder name must be a valid Guid"); } } + + public static string ExtractFileName(this ZipArchiveEntry entry) + { + string snapshotName = entry.FullName.Substring(entry.FullName.LastIndexOf('/') + 1); + if (!string.IsNullOrWhiteSpace(snapshotName)) + { + return snapshotName; + } + else + { + throw new ArgumentException("Invalid snapshot path"); + } + } } } From c3b9fba2f5fb78637dccbd636f0bf7674e8f24b2 Mon Sep 17 00:00:00 2001 From: kaiser42 Date: Thu, 16 Nov 2017 13:11:11 +0100 Subject: [PATCH 3/5] Added backwards compatibility for BCF 2.0 --- Xbim.BCF.nuspec | 2 +- Xbim.BCF/BCF.cs | 11 +++-- Xbim.BCF/MarkupXMLFile.cs | 4 +- Xbim.BCF/VisualizationXMLFile.cs | 21 ++++++---- .../XMLNodes/BCFComponentColoringColor.cs | 6 +++ Xbim.BCF/XMLNodes/BCFComponentSelection.cs | 7 +++- Xbim.BCF/XMLNodes/BCFComponentVisibility.cs | 23 +++++++++-- Xbim.BCF/XMLNodes/BCFComponents.cs | 41 ++++++++++++++----- Xbim.BCF/XMLNodes/BCFPerspectiveCamera.cs | 12 ++++-- Xbim.BCF/XMLNodes/BCFTopic.cs | 41 ++++++++++++------- 10 files changed, 119 insertions(+), 49 deletions(-) diff --git a/Xbim.BCF.nuspec b/Xbim.BCF.nuspec index 90cba7d..a072e53 100644 --- a/Xbim.BCF.nuspec +++ b/Xbim.BCF.nuspec @@ -2,7 +2,7 @@ Xbim.Bcf - 4.1.1 + 4.1.2 xBIM BCF xBIM team Steve Lockley diff --git a/Xbim.BCF/BCF.cs b/Xbim.BCF/BCF.cs index 5e96156..3168012 100644 --- a/Xbim.BCF/BCF.cs +++ b/Xbim.BCF/BCF.cs @@ -48,8 +48,11 @@ public static BCF Deserialize(Stream BCFZipData) else if (entry.FullName.EndsWith(".version", StringComparison.OrdinalIgnoreCase)) { bcf.Version = new VersionXMLFile(XDocument.Load(entry.Open())); - } - else if (entry.FullName.EndsWith(".bcf", StringComparison.OrdinalIgnoreCase)) + } + } + foreach (ZipArchiveEntry entry in archive.Entries) + { + if (entry.FullName.EndsWith(".bcf", StringComparison.OrdinalIgnoreCase)) { if (entry.ExtractGuidFolderName() != currentGuid) { @@ -60,7 +63,7 @@ public static BCF Deserialize(Stream BCFZipData) currentGuid = entry.ExtractGuidFolderName(); currentTopic = new Topic(); } - currentTopic.Markup = new MarkupXMLFile(XDocument.Load(entry.Open())); + currentTopic.Markup = new MarkupXMLFile(XDocument.Load(entry.Open()), bcf.Version.VersionId); } else if (entry.FullName.EndsWith(".bcfv", StringComparison.OrdinalIgnoreCase)) { @@ -73,7 +76,7 @@ public static BCF Deserialize(Stream BCFZipData) currentGuid = entry.ExtractGuidFolderName(); currentTopic = new Topic(); } - currentTopic.Visualizations.Add(entry.ExtractFileName(), new VisualizationXMLFile(XDocument.Load(entry.Open()))); + currentTopic.Visualizations.Add(entry.ExtractFileName(), new VisualizationXMLFile(XDocument.Load(entry.Open()), bcf.Version.VersionId)); } else if (entry.FullName.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) { diff --git a/Xbim.BCF/MarkupXMLFile.cs b/Xbim.BCF/MarkupXMLFile.cs index 2bc8fb3..5b65db1 100644 --- a/Xbim.BCF/MarkupXMLFile.cs +++ b/Xbim.BCF/MarkupXMLFile.cs @@ -23,13 +23,13 @@ public MarkupXMLFile() Viewpoints = new List(); } - public MarkupXMLFile(XDocument xdoc) + public MarkupXMLFile(XDocument xdoc, string version) { Comments = new List(); Viewpoints = new List(); Header = new BCFHeader(xdoc.Root.Element("Header")); - Topic = new BCFTopic(xdoc.Root.Element("Topic")); + Topic = new BCFTopic(xdoc.Root.Element("Topic"), version); foreach (var comment in (xdoc.Root.Elements("Comment"))) { Comments.Add(new BCFComment(comment)); diff --git a/Xbim.BCF/VisualizationXMLFile.cs b/Xbim.BCF/VisualizationXMLFile.cs index d3644a9..a2cb27a 100644 --- a/Xbim.BCF/VisualizationXMLFile.cs +++ b/Xbim.BCF/VisualizationXMLFile.cs @@ -1,4 +1,4 @@ -using System; + using System; using System.Collections.Generic; using System.Xml.Linq; using System.Linq; @@ -54,14 +54,19 @@ public VisualizationXMLFile(Guid id) Bitmaps = new List(); } - public VisualizationXMLFile(XDocument xdoc) + public VisualizationXMLFile(XDocument xdoc, string version) { Components = new BCFComponents(); Lines = new List(); ClippingPlanes = new List(); - Bitmaps = new List(); - - Guid = (System.Guid?)xdoc.Root.Attribute("Guid") ?? System.Guid.Empty; + Bitmaps = new List(); + + string bitmapName = "Bitmap"; + if (version == "2.0") + bitmapName = "Bitmaps"; + + if (!Guid.TryParse((String)xdoc.Root.Attribute("Guid"), out this._guid)) + this.Guid = Guid.NewGuid(); var orth = xdoc.Root.Elements("OrthogonalCamera").FirstOrDefault(); if (orth != null) @@ -76,7 +81,7 @@ public VisualizationXMLFile(XDocument xdoc) var components = xdoc.Root.Element("Components"); if (components != null) { - Components = new BCFComponents(components); + Components = new BCFComponents(components, version); } var lines = xdoc.Root.Elements("Lines").FirstOrDefault(); if (lines != null) @@ -94,10 +99,10 @@ public VisualizationXMLFile(XDocument xdoc) ClippingPlanes.Add(new BCFClippingPlane(plane)); } } - var bitmaps = xdoc.Root.Elements("Bitmap").FirstOrDefault(); + var bitmaps = xdoc.Root.Elements(bitmapName).FirstOrDefault(); if (bitmaps != null) { - foreach (var bmap in xdoc.Root.Elements("Bitmap")) + foreach (var bmap in xdoc.Root.Elements(bitmapName)) { Bitmaps.Add(new BCFBitmap(bmap)); } diff --git a/Xbim.BCF/XMLNodes/BCFComponentColoringColor.cs b/Xbim.BCF/XMLNodes/BCFComponentColoringColor.cs index 5f5b834..a6b3cdb 100644 --- a/Xbim.BCF/XMLNodes/BCFComponentColoringColor.cs +++ b/Xbim.BCF/XMLNodes/BCFComponentColoringColor.cs @@ -49,6 +49,12 @@ public BCFComponentColoringColor(XElement node) Components = new List(node.Elements("Component").Select(n => new BCFComponent(n))); } + public BCFComponentColoringColor(XElement node, string color) + { + Color = color; + Components = new List(node.Elements("Component").Where(n=>((String)n.Attribute("Color")??"").Equals(color)).Select(n => new BCFComponent(n))); + } + private bool IsHex(IEnumerable chars) { bool isHex; diff --git a/Xbim.BCF/XMLNodes/BCFComponentSelection.cs b/Xbim.BCF/XMLNodes/BCFComponentSelection.cs index bf26dd2..24c73c5 100644 --- a/Xbim.BCF/XMLNodes/BCFComponentSelection.cs +++ b/Xbim.BCF/XMLNodes/BCFComponentSelection.cs @@ -21,9 +21,12 @@ public BCFComponentSelection() Components = new List(); } - public BCFComponentSelection(XElement node) + public BCFComponentSelection(XElement node, string version) { - Components = new List(node.Elements("Component").Select(c => new BCFComponent(c))); + if (version == "2.0") + Components = new List(node.Elements("Component").Where(comp => (bool?)comp.Attribute("Selected") ?? false).Select(n => new BCFComponent(n))); + else + Components = new List(node.Elements("Component").Select(c => new BCFComponent(c))); } } } diff --git a/Xbim.BCF/XMLNodes/BCFComponentVisibility.cs b/Xbim.BCF/XMLNodes/BCFComponentVisibility.cs index a2d054e..3c6fd16 100644 --- a/Xbim.BCF/XMLNodes/BCFComponentVisibility.cs +++ b/Xbim.BCF/XMLNodes/BCFComponentVisibility.cs @@ -25,10 +25,27 @@ public BCFComponentVisibility() Exceptions = new List(); } - public BCFComponentVisibility(XElement node) + public BCFComponentVisibility(XElement node, string version) { - DefaultVisibility = (bool?)node.Attribute("DefaultVisibility") ?? false; - Exceptions = new List(node.Element("Exceptions")?.Elements("Component").Select(n => new BCFComponent(n)) ?? Enumerable.Empty()); + if (version == "2.0") + { + var component = node.Elements("Component").FirstOrDefault(); + if (component == null || !((bool?)component.Attribute("Visible") ?? true)) + { + DefaultVisibility = true; + Exceptions = new List(); + } + else + { + DefaultVisibility = false; + Exceptions = new List(node.Elements("Component").Select(n => new BCFComponent(n))); + } + } + else + { + DefaultVisibility = (bool?)node.Attribute("DefaultVisibility") ?? false; + Exceptions = new List(node.Element("Exceptions")?.Elements("Component").Select(n => new BCFComponent(n)) ?? Enumerable.Empty()); + } } } } diff --git a/Xbim.BCF/XMLNodes/BCFComponents.cs b/Xbim.BCF/XMLNodes/BCFComponents.cs index ca89947..f666780 100644 --- a/Xbim.BCF/XMLNodes/BCFComponents.cs +++ b/Xbim.BCF/XMLNodes/BCFComponents.cs @@ -54,17 +54,36 @@ public BCFComponents() Colorings = new List(); } - public BCFComponents(XElement node) - { - var hints = node.Element("ViewSetupHints"); - ViewSetupHints = hints != null ? new BCFViewSetupHints(hints) : null; - var selection = node.Element("Selection"); - Selection = selection != null ? new BCFComponentSelection(selection) : null; - var visibility = node.Element("Visibility"); - Visibility = visibility != null ? new BCFComponentVisibility(visibility) : null; - var coloring = node.Element("Coloring"); - if (coloring != null) - Colorings = new List(coloring.Elements("Color").Select(c => new BCFComponentColoringColor(c.Attribute("Color")?.Value))); + public BCFComponents(XElement node, string version) + { + var hints = node.Element("ViewSetupHints"); + ViewSetupHints = hints != null ? new BCFViewSetupHints(hints) : null; + if (version == "2.0") + { + bool hasComponents = node.Elements("Component").Any(); + Selection = new BCFComponentSelection(node, version); + Visibility = new BCFComponentVisibility(node, version); + Colorings = hasComponents ? new List() : null; + var colors = new HashSet(); + foreach (var component in node.Elements("Component")) + { + var color = (String)component.Attribute("Color") ?? ""; + if (!string.IsNullOrWhiteSpace(color)) + colors.Add(color); + } + foreach (var color in colors) + Colorings.Add(new BCFComponentColoringColor(node, color)); + } + else + { + var selection = node.Element("Selection"); + Selection = selection != null ? new BCFComponentSelection(selection, version) : null; + var visibility = node.Element("Visibility"); + Visibility = new BCFComponentVisibility(visibility, version); + var coloring = node.Element("Coloring"); + if (coloring != null) + Colorings = new List(coloring.Elements("Color").Select(c => new BCFComponentColoringColor(c.Attribute("Color")?.Value))); + } } } } diff --git a/Xbim.BCF/XMLNodes/BCFPerspectiveCamera.cs b/Xbim.BCF/XMLNodes/BCFPerspectiveCamera.cs index 4620118..35c4a4a 100644 --- a/Xbim.BCF/XMLNodes/BCFPerspectiveCamera.cs +++ b/Xbim.BCF/XMLNodes/BCFPerspectiveCamera.cs @@ -71,10 +71,14 @@ public double FieldOfView get { return _fieldOfView; } set { - if (value == double.NaN || value < 45 || value > 60) + if (value == double.NaN) { throw new ArgumentException(this.GetType().Name + " - FieldOfView - must be a valid 64-bit floating-point value between 45 and 60"); } + if (value == 0) + { + _fieldOfView = 60; + } else { _fieldOfView = value; @@ -106,9 +110,9 @@ public BCFPerspectiveCamera(XElement node) CameraUpVector = new Vector((double?)node.Element("CameraUpVector").Element("X") ?? double.NaN, (double?)node.Element("CameraUpVector").Element("Y") ?? double.NaN, - (double?)node.Element("CameraUpVector").Element("Z") ?? double.NaN); - - FieldOfView = (double?)node.Element("FieldOfView") ?? double.NaN; + (double?)node.Element("CameraUpVector").Element("Z") ?? double.NaN); + + FieldOfView = (double?)node.Element("FieldOfView") ?? 60; } } } diff --git a/Xbim.BCF/XMLNodes/BCFTopic.cs b/Xbim.BCF/XMLNodes/BCFTopic.cs index 3f9bf4a..b0a0aa8 100644 --- a/Xbim.BCF/XMLNodes/BCFTopic.cs +++ b/Xbim.BCF/XMLNodes/BCFTopic.cs @@ -229,12 +229,20 @@ public BCFTopic(Guid topicID, String title, DateTime date, String author) RelatedTopics = new List(); } - public BCFTopic(XElement node) + public BCFTopic(XElement node, string version) { DocumentReferences = new List(); RelatedTopics = new List(); - ReferenceLinks = new List(); - + ReferenceLinks = new List(); + + string documentReferenceName = "DocumentReference"; + string relatedTopicName = "RelatedTopic"; + if (version == "2.0") + { + documentReferenceName = "DocumentReferences"; + relatedTopicName = "RelatedTopics"; + } + this.Guid = Guid.Parse((String)node.Attribute("Guid") ?? ""); Title = (String)node.Element("Title") ?? ""; TopicType = (String)node.Attribute("TopicType") ?? ""; @@ -250,14 +258,19 @@ public BCFTopic(XElement node) Stage = (String)node.Element("Stage") ?? ""; TopicStatus = (String)node.Attribute("TopicStatus") ?? ""; - var refLinks = node.Elements("ReferenceLink").FirstOrDefault(); - if (refLinks != null) - { - foreach (var refLink in node.Elements("ReferenceLink")) - { - ReferenceLinks.Add(refLink.Value); + if (version == "2.0") + ReferenceLinks.Add((String)node.Element("ReferenceLink") ?? ""); + else + { + var refLinks = node.Elements("ReferenceLink").FirstOrDefault(); + if (refLinks != null) + { + foreach (var refLink in node.Elements("ReferenceLink")) + { + ReferenceLinks.Add(refLink.Value); + } } - } + } var bimSnippet = node.Elements("BimSnippet").FirstOrDefault(); if (bimSnippet != null) @@ -265,19 +278,19 @@ public BCFTopic(XElement node) BimSnippet = new BCFBimSnippet(bimSnippet); } - var docRefs = node.Elements("DocumentReference").FirstOrDefault(); + var docRefs = node.Elements(documentReferenceName).FirstOrDefault(); if (docRefs != null) { - foreach (var dref in node.Elements("DocumentReference")) + foreach (var dref in node.Elements(documentReferenceName)) { DocumentReferences.Add(new BCFDocumentReference(dref)); } } - var relTopics = node.Elements("RelatedTopic").FirstOrDefault(); + var relTopics = node.Elements(relatedTopicName).FirstOrDefault(); if (relTopics != null) { - foreach (var rt in node.Elements("RelatedTopic")) + foreach (var rt in node.Elements(relatedTopicName)) { RelatedTopics.Add(new BCFRelatedTopic(rt)); } From f2d10bfe24edeec5e9f611bbdb2fd07cfdedc68a Mon Sep 17 00:00:00 2001 From: kaiser42 Date: Fri, 17 Nov 2017 12:26:30 +0100 Subject: [PATCH 4/5] Bugfix: Added tests for backwards compatibility with BCF 2.0 --- Xbim.BCF.Tests/2.0/BCF20Tests.cs | 130 ++++++++++++++++++ Xbim.BCF.Tests/2.0/XML/Readme.txt | 4 + Xbim.BCF.Tests/2.0/XML/markup20.xml | 102 +++++++++++++++ Xbim.BCF.Tests/2.0/XML/project20.xml | 7 + Xbim.BCF.Tests/2.0/XML/version20.xml | 4 + Xbim.BCF.Tests/2.0/XML/visinfo20.xml | 189 +++++++++++++++++++++++++++ Xbim.BCF.Tests/2.0/XSD/Readme.txt | 3 + Xbim.BCF.Tests/2.0/XSD/markup20.xsd | 158 ++++++++++++++++++++++ Xbim.BCF.Tests/2.0/XSD/project20.xsd | 17 +++ Xbim.BCF.Tests/2.0/XSD/version20.xsd | 11 ++ Xbim.BCF.Tests/2.0/XSD/visinfo20.xsd | 132 +++++++++++++++++++ Xbim.BCF.Tests/BCFTests.cs | 5 +- Xbim.BCF.Tests/Xbim.BCF.Tests.csproj | 30 +++++ 13 files changed, 790 insertions(+), 2 deletions(-) create mode 100644 Xbim.BCF.Tests/2.0/BCF20Tests.cs create mode 100644 Xbim.BCF.Tests/2.0/XML/Readme.txt create mode 100644 Xbim.BCF.Tests/2.0/XML/markup20.xml create mode 100644 Xbim.BCF.Tests/2.0/XML/project20.xml create mode 100644 Xbim.BCF.Tests/2.0/XML/version20.xml create mode 100644 Xbim.BCF.Tests/2.0/XML/visinfo20.xml create mode 100644 Xbim.BCF.Tests/2.0/XSD/Readme.txt create mode 100644 Xbim.BCF.Tests/2.0/XSD/markup20.xsd create mode 100644 Xbim.BCF.Tests/2.0/XSD/project20.xsd create mode 100644 Xbim.BCF.Tests/2.0/XSD/version20.xsd create mode 100644 Xbim.BCF.Tests/2.0/XSD/visinfo20.xsd diff --git a/Xbim.BCF.Tests/2.0/BCF20Tests.cs b/Xbim.BCF.Tests/2.0/BCF20Tests.cs new file mode 100644 index 0000000..0c7b3ce --- /dev/null +++ b/Xbim.BCF.Tests/2.0/BCF20Tests.cs @@ -0,0 +1,130 @@ +using System.IO; +using System.Xml; +using System.Xml.Linq; +using System.Xml.Schema; +using System.Xml.Serialization; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Xbim.BCF.Tests +{ + [TestClass] + public class BCF20Tests + { + private const string version = "2.0"; + + [TestInitialize] + public void TestInit() + { + } + + [TestMethod] + [DeploymentItem("2.0\\XML\\markup20.xml")] + public void DeserializeMarkupXML() + { + MarkupXMLFile xmlObj = new MarkupXMLFile(XDocument.Load("markup20.xml"), version); + //Comments + Assert.IsTrue(xmlObj.Comments.Count > 0); + Assert.IsNotNull(xmlObj.Comments[0].Guid); + Assert.IsNotNull(xmlObj.Comments[0].Date); + Assert.IsNotNull(xmlObj.Comments[0].Author); + Assert.IsNotNull(xmlObj.Comments[0].Comment); + Assert.IsNotNull(xmlObj.Comments[0].ModifiedAuthor); + Assert.IsNotNull(xmlObj.Comments[0].ModifiedDate); + Assert.IsNotNull(xmlObj.Comments[0].Viewpoint.ID); + //Viewpoint + Assert.IsTrue(xmlObj.Viewpoints.Count > 0); + Assert.IsNotNull(xmlObj.Viewpoints[0].Snapshot); + Assert.IsNotNull(xmlObj.Viewpoints[0].Viewpoint); + Assert.IsNotNull(xmlObj.Viewpoints[0].ID); + //Header + Assert.IsNotNull(xmlObj.Header); + //Files + Assert.IsTrue(xmlObj.Header.Files.Count > 0); + Assert.IsNotNull(xmlObj.Header.Files[0].Date); + Assert.IsNotNull(xmlObj.Header.Files[0].Filename); + Assert.IsNotNull(xmlObj.Header.Files[0].IfcProject); + Assert.IsNotNull(xmlObj.Header.Files[0].IfcSpatialStructureElement); + Assert.IsNotNull(xmlObj.Header.Files[0].isExternal); + Assert.IsNotNull(xmlObj.Header.Files[0].Reference); + //Topic + Assert.IsNotNull(xmlObj.Topic); + Assert.IsNotNull(xmlObj.Topic.Guid); + Assert.IsNotNull(xmlObj.Topic.Title); + Assert.IsNotNull(xmlObj.Topic.TopicType); + Assert.IsNotNull(xmlObj.Topic.TopicStatus); + Assert.IsNotNull(xmlObj.Topic.AssignedTo); + Assert.IsNotNull(xmlObj.Topic.Stage); + Assert.IsNotNull(xmlObj.Topic.BimSnippet); + Assert.IsNotNull(xmlObj.Topic.BimSnippet.Reference); + Assert.IsNotNull(xmlObj.Topic.BimSnippet.SnippetType); + Assert.IsNotNull(xmlObj.Topic.BimSnippet.ReferenceSchema); + Assert.IsNotNull(xmlObj.Topic.BimSnippet.isExternal); + } + + [TestMethod] + [DeploymentItem("2.0\\XML\\project20.xml")] + public void DeserializeProjectXML() + { + ProjectXMLFile xmlObj = new ProjectXMLFile(XDocument.Load("project20.xml")); + + Assert.IsNotNull(xmlObj.ExtensionSchema); + Assert.IsNotNull(xmlObj.Project); + Assert.IsNotNull(xmlObj.Project.Name); + Assert.IsNotNull(xmlObj.Project.ProjectId); + } + + [TestMethod] + [DeploymentItem("2.0\\XML\\version20.xml")] + public void DeserializeVersionXML() + { + VersionXMLFile xmlObj = new VersionXMLFile(XDocument.Load("version20.xml")); + + Assert.IsNotNull(xmlObj.VersionId); + Assert.IsNotNull(xmlObj.DetailedVersion); + } + + [TestMethod] + [DeploymentItem("2.0\\XML\\visinfo20.xml")] + public void DeserializeVisualizationXML() + { + VisualizationXMLFile xmlObj = new VisualizationXMLFile(XDocument.Load("visinfo20.xml"), version); + + //Bitmaps + Assert.IsTrue(xmlObj.Bitmaps.Count > 0); + Assert.IsNotNull(xmlObj.Bitmaps[0].Bitmap); + Assert.IsNotNull(xmlObj.Bitmaps[0].Height); + Assert.IsNotNull(xmlObj.Bitmaps[0].Location); + Assert.IsNotNull(xmlObj.Bitmaps[0].Normal); + Assert.IsNotNull(xmlObj.Bitmaps[0].Reference); + Assert.IsNotNull(xmlObj.Bitmaps[0].Up); + //ClippingPlanes + Assert.IsTrue(xmlObj.ClippingPlanes.Count > 0); + Assert.IsNotNull(xmlObj.ClippingPlanes[0].Direction); + Assert.IsNotNull(xmlObj.ClippingPlanes[0].Location); + //Components + Assert.IsTrue(xmlObj.Components.Selection.Components.Count > 0); + Assert.IsNotNull(xmlObj.Components.Selection.Components[0].AuthoringToolId); + Assert.IsNotNull(xmlObj.Components.Colorings[0].Color); + Assert.IsNotNull(xmlObj.Components.Selection.Components[0].IfcGuid); + Assert.IsNotNull(xmlObj.Components.Selection.Components[0].OriginatingSystem); + Assert.IsNotNull(xmlObj.Components.Selection.Components[0]); + Assert.IsNotNull(xmlObj.Components.Visibility.Exceptions[0]); + //Lines + Assert.IsTrue(xmlObj.Lines.Count > 0); + Assert.IsNotNull(xmlObj.Lines[0].StartPoint); + Assert.IsNotNull(xmlObj.Lines[0].EndPoint); + //Orth Camera + Assert.IsNotNull(xmlObj.OrthogonalCamera); + Assert.IsNotNull(xmlObj.OrthogonalCamera.CameraDirection); + Assert.IsNotNull(xmlObj.OrthogonalCamera.CameraUpVector); + Assert.IsNotNull(xmlObj.OrthogonalCamera.CameraViewPoint); + Assert.IsNotNull(xmlObj.OrthogonalCamera.ViewToWorldScale); + //Pers Camera + Assert.IsNotNull(xmlObj.PerspectiveCamera); + Assert.IsNotNull(xmlObj.PerspectiveCamera.CameraDirection); + Assert.IsNotNull(xmlObj.PerspectiveCamera.CameraUpVector); + Assert.IsNotNull(xmlObj.PerspectiveCamera.CameraViewPoint); + Assert.IsNotNull(xmlObj.PerspectiveCamera.FieldOfView); + } + } +} diff --git a/Xbim.BCF.Tests/2.0/XML/Readme.txt b/Xbim.BCF.Tests/2.0/XML/Readme.txt new file mode 100644 index 0000000..43cd868 --- /dev/null +++ b/Xbim.BCF.Tests/2.0/XML/Readme.txt @@ -0,0 +1,4 @@ +Generated from Schemas at https://github.com/BuildingSMART/BCF-XML/tree/master/Schemas +Added as part of backwards compatibility tests with BCF 2.0 +Correct as of 16 November 2017 +Guids don't seem to generate properly so amend them by hand \ No newline at end of file diff --git a/Xbim.BCF.Tests/2.0/XML/markup20.xml b/Xbim.BCF.Tests/2.0/XML/markup20.xml new file mode 100644 index 0000000..be761c9 --- /dev/null +++ b/Xbim.BCF.Tests/2.0/XML/markup20.xml @@ -0,0 +1,102 @@ + + +
+ + Filename1 + 1900-01-01T01:01:01+01:00 + Reference1 + + + Filename2 + 0001-01-01T00:00:00+01:00 + Reference2 + + + Filename3 + 9999-12-31T23:59:59.9999999+01:00 + Reference3 + +
+ + ReferenceLink1 + Title1 + Priority1 + 1 + Labels1 + Labels2 + Labels3 + 1900-01-01T01:01:01+01:00 + CreationAuthor1 + 1900-01-01T01:01:01+01:00 + ModifiedAuthor1 + AssignedTo1 + Description1 + + Reference1 + ReferenceSchema1 + + + ReferencedDocument1 + Description1 + + + ReferencedDocument2 + Description2 + + + ReferencedDocument3 + Description3 + + + + + + + VerbalStatus1 + Unknown + 1900-01-01T01:01:01+01:00 + Author1 + Comment1 + + + + 1900-01-01T01:01:01+01:00 + ModifiedAuthor1 + + + VerbalStatus2 + Status1 + 2001-01-01T00:00:00+01:00 + Author2 + Comment2 + + + + 0001-01-01T00:00:00+01:00 + ModifiedAuthor2 + + + VerbalStatus3 + Status2 + 9999-12-31T23:59:59.9999999+01:00 + Author3 + Comment3 + + + + 9999-12-31T23:59:59.9999999+01:00 + ModifiedAuthor3 + + + Viewpoint1 + Snapshot1 + + + Viewpoint2 + Snapshot2 + + + Viewpoint3 + Snapshot3 + +
\ No newline at end of file diff --git a/Xbim.BCF.Tests/2.0/XML/project20.xml b/Xbim.BCF.Tests/2.0/XML/project20.xml new file mode 100644 index 0000000..7c02cac --- /dev/null +++ b/Xbim.BCF.Tests/2.0/XML/project20.xml @@ -0,0 +1,7 @@ + + + + Name1 + + http://uri1 + \ No newline at end of file diff --git a/Xbim.BCF.Tests/2.0/XML/version20.xml b/Xbim.BCF.Tests/2.0/XML/version20.xml new file mode 100644 index 0000000..7d1e20c --- /dev/null +++ b/Xbim.BCF.Tests/2.0/XML/version20.xml @@ -0,0 +1,4 @@ + + + DetailedVersion1 + \ No newline at end of file diff --git a/Xbim.BCF.Tests/2.0/XML/visinfo20.xml b/Xbim.BCF.Tests/2.0/XML/visinfo20.xml new file mode 100644 index 0000000..2bca020 --- /dev/null +++ b/Xbim.BCF.Tests/2.0/XML/visinfo20.xml @@ -0,0 +1,189 @@ + + + + + OriginatingSystem1 + AuthoringToolId1 + + + OriginatingSystem2 + AuthoringToolId2 + + + OriginatingSystem3 + AuthoringToolId3 + + + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + 1 + + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + 45 + + + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + + + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + + + PNG + Reference1 + + 1 + 1 + 1 + + + 1 + 1 + 1 + + + 1 + 1 + 1 + + 1 + + + JPG + Reference2 + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + + -1.7976931348623157E+308 + -1.7976931348623157E+308 + -1.7976931348623157E+308 + + -1.7976931348623157E+308 + + + PNG + Reference3 + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + + 1.7976931348623157E+308 + 1.7976931348623157E+308 + 1.7976931348623157E+308 + + 1.7976931348623157E+308 + + diff --git a/Xbim.BCF.Tests/2.0/XSD/Readme.txt b/Xbim.BCF.Tests/2.0/XSD/Readme.txt new file mode 100644 index 0000000..05cdfa2 --- /dev/null +++ b/Xbim.BCF.Tests/2.0/XSD/Readme.txt @@ -0,0 +1,3 @@ +Schemas from https://github.com/BuildingSMART/BCF-XML/tree/master/Schemas +Added as part of backwards compatibility tests with BCF 2.0 +Correct as of 16 November 2017 \ No newline at end of file diff --git a/Xbim.BCF.Tests/2.0/XSD/markup20.xsd b/Xbim.BCF.Tests/2.0/XSD/markup20.xsd new file mode 100644 index 0000000..32ef340 --- /dev/null +++ b/Xbim.BCF.Tests/2.0/XSD/markup20.xsd @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Xbim.BCF.Tests/2.0/XSD/project20.xsd b/Xbim.BCF.Tests/2.0/XSD/project20.xsd new file mode 100644 index 0000000..15004ae --- /dev/null +++ b/Xbim.BCF.Tests/2.0/XSD/project20.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Xbim.BCF.Tests/2.0/XSD/version20.xsd b/Xbim.BCF.Tests/2.0/XSD/version20.xsd new file mode 100644 index 0000000..aa10a91 --- /dev/null +++ b/Xbim.BCF.Tests/2.0/XSD/version20.xsd @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Xbim.BCF.Tests/2.0/XSD/visinfo20.xsd b/Xbim.BCF.Tests/2.0/XSD/visinfo20.xsd new file mode 100644 index 0000000..1da57e7 --- /dev/null +++ b/Xbim.BCF.Tests/2.0/XSD/visinfo20.xsd @@ -0,0 +1,132 @@ + + + + + visualiztioninfo documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + view's visible size in meters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Xbim.BCF.Tests/BCFTests.cs b/Xbim.BCF.Tests/BCFTests.cs index 2eb8bf8..04df02a 100644 --- a/Xbim.BCF.Tests/BCFTests.cs +++ b/Xbim.BCF.Tests/BCFTests.cs @@ -13,6 +13,7 @@ namespace Xbim.BCF.Tests [TestClass] public class BCFTests { + private const string version = "2.1"; private BCFTestsXMLHelper xmlSchemaValidator; [TestInitialize] @@ -25,7 +26,7 @@ public void TestInit() [DeploymentItem("XML\\markup.xml")] public void DeserializeMarkupXML() { - MarkupXMLFile xmlObj = new MarkupXMLFile(XDocument.Load("markup.xml")); + MarkupXMLFile xmlObj = new MarkupXMLFile(XDocument.Load("markup.xml"), version); //Comments Assert.IsTrue(xmlObj.Comments.Count > 0); Assert.IsNotNull(xmlObj.Comments[0].Guid); @@ -93,7 +94,7 @@ public void DeserializeVersionXML() [DeploymentItem("XML\\visinfo.xml")] public void DeserializeVisualizationXML() { - VisualizationXMLFile xmlObj = new VisualizationXMLFile(XDocument.Load("visinfo.xml")); + VisualizationXMLFile xmlObj = new VisualizationXMLFile(XDocument.Load("visinfo.xml"), version); //Bitmaps Assert.IsTrue(xmlObj.Bitmaps.Count > 0); diff --git a/Xbim.BCF.Tests/Xbim.BCF.Tests.csproj b/Xbim.BCF.Tests/Xbim.BCF.Tests.csproj index 2cb4aed..93e69ef 100644 --- a/Xbim.BCF.Tests/Xbim.BCF.Tests.csproj +++ b/Xbim.BCF.Tests/Xbim.BCF.Tests.csproj @@ -55,11 +55,27 @@ Properties\SharedAssemblyInfo.cs + + + Always + Designer + + + Always + + + + Always + + + Always + + Designer Always @@ -99,6 +115,20 @@ + + + Designer + + + Designer + + + Designer + + + Designer + + From 401917555032db83a2443a53a788cded77bc00bd Mon Sep 17 00:00:00 2001 From: kaiser42 Date: Fri, 24 Nov 2017 10:54:54 +0100 Subject: [PATCH 5/5] Removed visibility null constraint in order to be more robust --- Xbim.BCF/XMLNodes/BCFComponents.cs | 112 ++++++++++++++--------------- 1 file changed, 53 insertions(+), 59 deletions(-) diff --git a/Xbim.BCF/XMLNodes/BCFComponents.cs b/Xbim.BCF/XMLNodes/BCFComponents.cs index f666780..64c95b8 100644 --- a/Xbim.BCF/XMLNodes/BCFComponents.cs +++ b/Xbim.BCF/XMLNodes/BCFComponents.cs @@ -1,60 +1,54 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Xml.Linq; -using System.Xml.Serialization; - -namespace Xbim.BCF.XMLNodes -{ - [XmlType("Components")] - public class BCFComponents - { - [XmlElement(ElementName ="ViewSetupHints", Order = 1)] - public BCFViewSetupHints ViewSetupHints { get; set; } - public bool ShouldSerializeViewSetupHints() - { - return ViewSetupHints != null; - } - - [XmlElement(ElementName = "Selection", Order = 2)] - public BCFComponentSelection Selection { get; set; } - public bool ShouldSerializeSelection() - { - return Selection != null; - } - - private BCFComponentVisibility _visibility; - [XmlElement(ElementName = "Visibility", Order = 3)] - public BCFComponentVisibility Visibility - { - get { return _visibility; } - set - { - if (ReferenceEquals(value, null)) - { - throw new ArgumentException(this.GetType().Name + " - Visibility is mandatory"); - } - else - { - _visibility = value; - } - } - } - - [XmlArray(ElementName = "Coloring", Order = 4)] - public List Colorings; - public bool ShouldSerializeExceptions() - { - return Colorings != null && Colorings.Count > 0; - } - - public BCFComponents() +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml.Linq; +using System.Xml.Serialization; + +namespace Xbim.BCF.XMLNodes +{ + [XmlType("Components")] + public class BCFComponents + { + [XmlElement(ElementName ="ViewSetupHints", Order = 1)] + public BCFViewSetupHints ViewSetupHints { get; set; } + public bool ShouldSerializeViewSetupHints() + { + return ViewSetupHints != null; + } + + [XmlElement(ElementName = "Selection", Order = 2)] + public BCFComponentSelection Selection { get; set; } + public bool ShouldSerializeSelection() + { + return Selection != null; + } + + private BCFComponentVisibility _visibility; + [XmlElement(ElementName = "Visibility", Order = 3)] + public BCFComponentVisibility Visibility + { + get { return _visibility; } + set { _visibility = value; } + } + public bool ShouldSerializeVisibility() + { + return Visibility != null; + } + + [XmlArray(ElementName = "Coloring", Order = 4)] + public List Colorings; + public bool ShouldSerializeExceptions() + { + return Colorings != null && Colorings.Count > 0; + } + + public BCFComponents() { Visibility = new BCFComponentVisibility(); Colorings = new List(); - } - - public BCFComponents(XElement node, string version) + } + + public BCFComponents(XElement node, string version) { var hints = node.Element("ViewSetupHints"); ViewSetupHints = hints != null ? new BCFViewSetupHints(hints) : null; @@ -79,11 +73,11 @@ public BCFComponents(XElement node, string version) var selection = node.Element("Selection"); Selection = selection != null ? new BCFComponentSelection(selection, version) : null; var visibility = node.Element("Visibility"); - Visibility = new BCFComponentVisibility(visibility, version); + Visibility = visibility != null ? new BCFComponentVisibility(visibility, version) : null; var coloring = node.Element("Coloring"); if (coloring != null) Colorings = new List(coloring.Elements("Color").Select(c => new BCFComponentColoringColor(c.Attribute("Color")?.Value))); - } - } - } -} + } + } + } +}