From 5a5cbedd2203f4b9b7842e40e9b0bc8b929938ec Mon Sep 17 00:00:00 2001 From: Andy Ward Date: Mon, 2 Jan 2023 12:57:16 +0000 Subject: [PATCH 01/18] First pass ifc4x3 implementation. Supports loading IFC4x3 schema but latest Geometry needed Styler fixed up and multi-schema code reviewed --- Xbim.Presentation/DrawingControl3D.xaml.cs | 9 ++++++--- .../DynamicProductSelectionControl.xaml.cs | 2 +- .../FederatedModel/FederatedModelViewModel.cs | 7 ++++++- Xbim.Presentation/Xbim.Presentation.csproj | 5 +++-- Xbim.WinformsSample/Xbim.WinformsSample.csproj | 4 ++-- XbimXplorer/Commands/wdwCommands.xaml.cs | 10 +++++++--- .../Dialogs/ExcludedTypes/ExpressTypeExpander.cs | 2 +- .../ExcludedTypes/StylerConfiguration.xaml.cs | 16 +++++++++++----- XbimXplorer/Simplify/IfcSimplify.xaml.cs | 2 +- XbimXplorer/XbimXplorer.csproj | 4 ++-- XbimXplorer/XplorerMainWindow.xaml.cs | 8 +++++++- XplorerPlugin.Bcf/XplorerPlugin.Bcf.csproj | 2 +- 12 files changed, 48 insertions(+), 23 deletions(-) diff --git a/Xbim.Presentation/DrawingControl3D.xaml.cs b/Xbim.Presentation/DrawingControl3D.xaml.cs index f5268102..7052b765 100644 --- a/Xbim.Presentation/DrawingControl3D.xaml.cs +++ b/Xbim.Presentation/DrawingControl3D.xaml.cs @@ -231,9 +231,12 @@ protected void ClipPlaneHandlesHide() { typeof(Ifc2x3.ProductExtension.IfcSpace), typeof(Ifc4.ProductExtension.IfcSpace), - typeof(Ifc2x3.ProductExtension.IfcFeatureElement), - typeof(Ifc4.ProductExtension.IfcFeatureElement) - }; + typeof(Ifc4x3.ProductExtension.IfcSpace), + + typeof(Ifc2x3.ProductExtension.IfcFeatureElement), + typeof(Ifc4.ProductExtension.IfcFeatureElement), + typeof(Ifc4x3.ProductExtension.IfcFeatureElement) + }; /// /// The list of types that the engine will not consider in the generation of the scene, the exclusion code needs to be correctly implemented in the diff --git a/Xbim.Presentation/DynamicProductSelectionControl.xaml.cs b/Xbim.Presentation/DynamicProductSelectionControl.xaml.cs index c3607ae2..9d5b3053 100644 --- a/Xbim.Presentation/DynamicProductSelectionControl.xaml.cs +++ b/Xbim.Presentation/DynamicProductSelectionControl.xaml.cs @@ -199,7 +199,7 @@ private void btnPerform_Click(object sender, RoutedEventArgs e) compilerParams.ReferencedAssemblies.Add("System.Xml.dll"); compilerParams.ReferencedAssemblies.Add("System.Xml.Linq.dll"); compilerParams.ReferencedAssemblies.Add("Xbim.Common.dll"); - compilerParams.ReferencedAssemblies.Add("Xbim.Ifc2x3.dll"); + compilerParams.ReferencedAssemblies.Add("Xbim.Ifc2x3.dll"); // TODO: handle newer schemas compilerParams.ReferencedAssemblies.Add("Xbim.IO.dll"); compilerParams.ReferencedAssemblies.Add("Xbim.Ifc.Extensions.dll"); diff --git a/Xbim.Presentation/FederatedModel/FederatedModelViewModel.cs b/Xbim.Presentation/FederatedModel/FederatedModelViewModel.cs index 4209c19f..1256a333 100644 --- a/Xbim.Presentation/FederatedModel/FederatedModelViewModel.cs +++ b/Xbim.Presentation/FederatedModel/FederatedModelViewModel.cs @@ -47,7 +47,12 @@ public string Project var x4 = project as Ifc4.Kernel.IfcProject; x4.Name = value; } - + else if (project is Ifc4x3.Kernel.IfcProject) + { + var x4 = project as Ifc4.Kernel.IfcProject; + x4.Name = value; + } + txn.Commit(); } OnPropertyChanged("Project"); diff --git a/Xbim.Presentation/Xbim.Presentation.csproj b/Xbim.Presentation/Xbim.Presentation.csproj index 6c862df6..c58dd6dc 100644 --- a/Xbim.Presentation/Xbim.Presentation.csproj +++ b/Xbim.Presentation/Xbim.Presentation.csproj @@ -10,7 +10,7 @@ Now built on XBIM v5. Migrated from log4net to Microsoft.Extensions.Logging. true true - 5.1.0.0 + 5.1.0.0-develop XbimIcon.png @@ -43,7 +43,8 @@ - + + diff --git a/Xbim.WinformsSample/Xbim.WinformsSample.csproj b/Xbim.WinformsSample/Xbim.WinformsSample.csproj index 7da9346e..0d980074 100644 --- a/Xbim.WinformsSample/Xbim.WinformsSample.csproj +++ b/Xbim.WinformsSample/Xbim.WinformsSample.csproj @@ -49,8 +49,8 @@ - - + + diff --git a/XbimXplorer/Commands/wdwCommands.xaml.cs b/XbimXplorer/Commands/wdwCommands.xaml.cs index 0e9fa269..fe39f013 100644 --- a/XbimXplorer/Commands/wdwCommands.xaml.cs +++ b/XbimXplorer/Commands/wdwCommands.xaml.cs @@ -2047,6 +2047,7 @@ private IEnumerable GetRepresentationItems(IEnumerable labels, string private void PopulateFilterTypes() { // todo: these lists needs to be revised + // TODO: Add Ifc4x3 once geometry ready _surfaceOrSolidTypes = new List(); _surfaceOrSolidTypes.AddRange(SchemaMetadatas["ifc2x3"].ExpressType(typeof(Xbim.Ifc2x3.GeometryResource.IfcSurface)).NonAbstractSubTypes.Select(x => x.Type)); @@ -2322,6 +2323,8 @@ private IEnumerable MatchingTypes(string regExString) t.Namespace.StartsWith("Xbim.Ifc2x3.") || t.Namespace.StartsWith("Xbim.Ifc4.") + || + t.Namespace.StartsWith("Xbim.Ifc4x3.") )) ) { @@ -2380,7 +2383,8 @@ private string GetFriendlyTypeName(Type type) internal static Dictionary SchemaMetadatas => new Dictionary { {"ifc2x3", ExpressMetaData.GetMetadata(typeof(Xbim.Ifc2x3.SharedBldgElements.IfcWall).Module)}, - {"ifc4", ExpressMetaData.GetMetadata(typeof(Xbim.Ifc4.SharedBldgElements.IfcWall).Module)} + {"ifc4", ExpressMetaData.GetMetadata(typeof(Xbim.Ifc4.SharedBldgElements.IfcWall).Module)}, + {"ifc4x3", ExpressMetaData.GetMetadata(typeof(Xbim.Ifc4x3.SharedBldgElements.IfcWall).Module)} }; private TextHighliter ReportType(string type, int beVerbose, string indentationHeader = "") @@ -2811,9 +2815,9 @@ private static string ReportPropValue(object propVal, ref List retIds, bool ? " [#" + propLabel + "]" : "" ); - if (pe as Xbim.Ifc2x3.Interfaces.IIfcCartesianPoint != null) + if (pe as IIfcCartesianPoint != null) { - var n = pe as Xbim.Ifc2x3.Interfaces.IIfcCartesianPoint; + var n = pe as IIfcCartesianPoint; var vals = n.Coordinates.Select(x => x.Value); ret += "\t" + string.Join("\t,\t", vals); } diff --git a/XbimXplorer/Dialogs/ExcludedTypes/ExpressTypeExpander.cs b/XbimXplorer/Dialogs/ExcludedTypes/ExpressTypeExpander.cs index 4cb2d408..e4cba36f 100644 --- a/XbimXplorer/Dialogs/ExcludedTypes/ExpressTypeExpander.cs +++ b/XbimXplorer/Dialogs/ExcludedTypes/ExpressTypeExpander.cs @@ -20,7 +20,7 @@ public ExpressTypeExpander(ExpressType view, IfcStore model) IEnumerable ITreeElement.GetChildren() { - foreach (var child in ExpressType.SubTypes) + foreach (var child in ExpressType.SubTypes.OrderBy(e => e.Name)) { yield return new ObjectViewModel() { Tag = new ExpressTypeExpander(child, Model) }; } diff --git a/XbimXplorer/Dialogs/ExcludedTypes/StylerConfiguration.xaml.cs b/XbimXplorer/Dialogs/ExcludedTypes/StylerConfiguration.xaml.cs index a9c976e9..32bc279e 100644 --- a/XbimXplorer/Dialogs/ExcludedTypes/StylerConfiguration.xaml.cs +++ b/XbimXplorer/Dialogs/ExcludedTypes/StylerConfiguration.xaml.cs @@ -34,16 +34,22 @@ private void PopulateTree() TypesTree.Items.Clear(); // this is done through the metadata in order to ensure that class relationships are loaded + var module2X3 = (typeof(Xbim.Ifc2x3.Kernel.IfcProduct)).Module; + var meta2X3 = ExpressMetaData.GetMetadata(module2X3); + var product2X3 = meta2X3.ExpressType("IFCPRODUCT"); + TypesTree.Items.Add(new ObjectViewModel() { Header = "Ifc2x3.IfcProduct", Tag = new ExpressTypeExpander(product2X3, Model), IsChecked = true }); + var module4 = (typeof(Xbim.Ifc4.Kernel.IfcProduct)).Module; var meta4 = ExpressMetaData.GetMetadata(module4); var product4 = meta4.ExpressType("IFCPRODUCT"); TypesTree.Items.Add(new ObjectViewModel() { Header = "Ifc4.IfcProduct", Tag = new ExpressTypeExpander(product4, Model), IsChecked = true }); - // this is done through the metadata in order to ensure that class relationships are loaded - var module2X3 = (typeof(Xbim.Ifc2x3.Kernel.IfcProduct)).Module; - var meta2X3 = ExpressMetaData.GetMetadata(module2X3); - var product2X3 = meta2X3.ExpressType("IFCPRODUCT"); - TypesTree.Items.Add(new ObjectViewModel() { Header = "Ifc2x3.IfcProduct", Tag = new ExpressTypeExpander(product2X3, Model), IsChecked = true }); + var module4x3 = (typeof(Xbim.Ifc4x3.Kernel.IfcProduct)).Module; + var meta4x3 = ExpressMetaData.GetMetadata(module4x3); + var product4x3 = meta4x3.ExpressType("IFCPRODUCT"); + TypesTree.Items.Add(new ObjectViewModel() { Header = "Ifc4x3.IfcProduct", Tag = new ExpressTypeExpander(product4x3, Model), IsChecked = true }); + + } public List ExcludedTypes diff --git a/XbimXplorer/Simplify/IfcSimplify.xaml.cs b/XbimXplorer/Simplify/IfcSimplify.xaml.cs index 898b8e40..fc0bf89b 100644 --- a/XbimXplorer/Simplify/IfcSimplify.xaml.cs +++ b/XbimXplorer/Simplify/IfcSimplify.xaml.cs @@ -481,7 +481,7 @@ private void cmdSave_Click(object sender, RoutedEventArgs e) var max = _exportList.Max(); if (ExportContainment.IsChecked.Value) { - var newid = new Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId(); + Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId newid; // we need to ensure that the site is exported. var exportedSite = _exportList.Intersect(_ifcSites).FirstOrDefault(); if (exportedSite == 0) diff --git a/XbimXplorer/XbimXplorer.csproj b/XbimXplorer/XbimXplorer.csproj index 1cf6982e..03e4a02f 100644 --- a/XbimXplorer/XbimXplorer.csproj +++ b/XbimXplorer/XbimXplorer.csproj @@ -62,8 +62,8 @@ - - + + diff --git a/XbimXplorer/XplorerMainWindow.xaml.cs b/XbimXplorer/XplorerMainWindow.xaml.cs index 60ed50e3..97389b7f 100644 --- a/XbimXplorer/XplorerMainWindow.xaml.cs +++ b/XbimXplorer/XplorerMainWindow.xaml.cs @@ -747,6 +747,7 @@ private void FederationFromDialogbox(OpenFileDialog dlg) case ".ifczip": case ".ifcxml": // create temp file as a placeholder for the temporory xbim file + // TODO: Will this work in IFC4x? fedModel = IfcStore.Create(null, XbimSchemaVersion.Ifc2X3, XbimStoreType.InMemoryModel); using (var txn = fedModel.BeginTransaction()) { @@ -1178,11 +1179,16 @@ private void StylerIfcSpacesOnly(object sender, RoutedEventArgs e) var module4 = (typeof(Xbim.Ifc4.Kernel.IfcProduct)).Module; var meta4 = ExpressMetaData.GetMetadata(module4); var product4 = meta4.ExpressType("IFCPRODUCT"); - + + var module4x3 = (typeof(Xbim.Ifc4x3.Kernel.IfcProduct)).Module; + var meta4x3 = ExpressMetaData.GetMetadata(module4x3); + var product4x3 = meta4.ExpressType("IFCPRODUCT"); + var tpcoll = product2X3.NonAbstractSubTypes.Select(x => x.Type).ToList(); tpcoll.AddRange(product4.NonAbstractSubTypes.Select(x => x.Type).ToList()); + tpcoll.AddRange(product4x3.NonAbstractSubTypes.Select(x => x.Type).ToList()); tpcoll.RemoveAll(x => x.Name == "IfcSpace"); DrawingControl.ExcludedTypes = tpcoll; diff --git a/XplorerPlugin.Bcf/XplorerPlugin.Bcf.csproj b/XplorerPlugin.Bcf/XplorerPlugin.Bcf.csproj index df0e99d8..1c753d33 100644 --- a/XplorerPlugin.Bcf/XplorerPlugin.Bcf.csproj +++ b/XplorerPlugin.Bcf/XplorerPlugin.Bcf.csproj @@ -68,6 +68,6 @@ - + \ No newline at end of file From 857eb50e1e74e7a62306d576b7ffd39b997f2b18 Mon Sep 17 00:00:00 2001 From: Andy Ward Date: Mon, 2 Jan 2023 15:25:32 +0000 Subject: [PATCH 02/18] WIP upgrade to .net6.0 and latest netcore geometry (including 4x3). Geometry to test. Plugins disabled due to Nuget package deprecation --- Directory.Build.props | 2 +- Xbim.Presentation/DrawingControl3D.xaml.cs | 10 +++-- .../Extensions/ObservableMeshVisual3D.cs | 4 +- Xbim.Presentation/Themes/Generic.xaml | 2 +- Xbim.Presentation/Xbim.Presentation.csproj | 27 +++++------ Xbim.WindowsUI.sln | 10 ++--- .../Xbim.WinformsSample.csproj | 2 +- XbimXplorer/Commands/EmbedDoc.xaml | 2 +- XbimXplorer/Commands/EmbedDoc.xaml.cs | 5 ++- XbimXplorer/Commands/wdwCommands.xaml.cs | 2 +- XbimXplorer/Dialogs/AssemblyInformation.cs | 16 +++---- .../PluginSystem/IPackageExtensions.cs | 6 ++- XbimXplorer/PluginSystem/PluginInformation.cs | 15 ++++--- .../PluginSystem/PluginInformationVm.cs | 15 ++++--- XbimXplorer/PluginSystem/PluginManagement.cs | 6 ++- .../PluginSystem/PluginsConfig.xaml.cs | 12 ++--- XbimXplorer/Properties/Resources.Designer.cs | 2 +- XbimXplorer/Properties/Settings.Designer.cs | 2 +- XbimXplorer/XbimXplorer.csproj | 45 ++++++++++--------- XbimXplorer/XplorerMainWindow.Plugins.xaml.cs | 6 ++- XbimXplorer/XplorerMainWindow.xaml | 2 +- XbimXplorer/XplorerMainWindow.xaml.cs | 22 +++++---- XbimXplorer/app.config | 4 +- XplorerPlugin.Bcf/XplorerPlugin.Bcf.csproj | 2 +- nuget.config | 1 + 25 files changed, 120 insertions(+), 102 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 3dcc9b94..ae332a6d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -24,7 +24,7 @@ false true true - true + false ..\XbimOpenSourceKeyFile.snk false diff --git a/Xbim.Presentation/DrawingControl3D.xaml.cs b/Xbim.Presentation/DrawingControl3D.xaml.cs index 7052b765..d2797f88 100644 --- a/Xbim.Presentation/DrawingControl3D.xaml.cs +++ b/Xbim.Presentation/DrawingControl3D.xaml.cs @@ -1363,10 +1363,14 @@ private void ClearGraphics(ModelRefreshOptions options = ModelRefreshOptions.Non Materials.Clear(); OriginalOpacities.Clear(); - Opaques.Children.Clear(); - Transparents.Children.Clear(); + if(Opaques != null) + Opaques.Children.Clear(); + if(Transparents != null) + Transparents.Children.Clear(); + if(Extras != null) Extras.Children.Clear(); - Overlays.Children.Clear(); + if(Overlays != null) + Overlays.Children.Clear(); if (!options.HasFlag(ModelRefreshOptions.ViewPreserveSelection)) { diff --git a/Xbim.Presentation/Extensions/ObservableMeshVisual3D.cs b/Xbim.Presentation/Extensions/ObservableMeshVisual3D.cs index b7d4992f..0bf404d6 100644 --- a/Xbim.Presentation/Extensions/ObservableMeshVisual3D.cs +++ b/Xbim.Presentation/Extensions/ObservableMeshVisual3D.cs @@ -1,6 +1,6 @@ -using System.ComponentModel; +using HelixToolkit.Wpf; +using System.ComponentModel; using System.Windows.Media.Media3D; -using HelixToolkit.Wpf; using Xbim.Presentation.Extensions.Utility; namespace Xbim.Presentation.Extensions diff --git a/Xbim.Presentation/Themes/Generic.xaml b/Xbim.Presentation/Themes/Generic.xaml index 56bfd533..c4360193 100644 --- a/Xbim.Presentation/Themes/Generic.xaml +++ b/Xbim.Presentation/Themes/Generic.xaml @@ -1,7 +1,7 @@