-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving IFC to connectors repo (#488)
* First pass of moving IFC to connectors repo * Fix some errors and ignore others * fix namespaces and exceptions * fix namespaces * formatting * Fix namespaces and move stuff * add linux ci * more csproj changes * importer stuff will be the nuget * add pack version and to Local sln * do a nuget push on main * fix restore
- Loading branch information
1 parent
bedf363
commit d76865e
Showing
56 changed files
with
4,288 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Importers/Ifc/Speckle.Importers.Ifc.Tester/DummySendCacheManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Speckle.Sdk.SQLite; | ||
|
||
namespace Speckle.Importers.Ifc.Tester; | ||
|
||
public sealed class DummySendCacheManager(Dictionary<string, string> objects) : ISqLiteJsonCacheManager | ||
{ | ||
public void Dispose() { } | ||
|
||
public IReadOnlyCollection<(string, string)> GetAllObjects() => throw new NotImplementedException(); | ||
|
||
public void DeleteObject(string id) => throw new NotImplementedException(); | ||
|
||
public string? GetObject(string id) => null; | ||
|
||
public void SaveObject(string id, string json) => throw new NotImplementedException(); | ||
|
||
public bool HasObject(string objectId) => false; | ||
|
||
public void SaveObjects(IEnumerable<(string id, string json)> items) | ||
{ | ||
foreach (var (id, json) in items) | ||
{ | ||
objects[id] = json; | ||
} | ||
} | ||
|
||
public void UpdateObject(string id, string json) => throw new NotImplementedException(); | ||
} |
43 changes: 43 additions & 0 deletions
43
Importers/Ifc/Speckle.Importers.Ifc.Tester/DummyServerObjectManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Text; | ||
using Speckle.Sdk.Serialisation.V2; | ||
using Speckle.Sdk.Serialisation.V2.Send; | ||
using Speckle.Sdk.Transports; | ||
|
||
namespace Speckle.Importers.Ifc.Tester; | ||
|
||
public class DummyServerObjectManager : IServerObjectManager | ||
{ | ||
public IAsyncEnumerable<(string, string)> DownloadObjects( | ||
IReadOnlyCollection<string> objectIds, | ||
IProgress<ProgressArgs>? progress, | ||
CancellationToken cancellationToken | ||
) => throw new NotImplementedException(); | ||
|
||
public Task<string?> DownloadSingleObject( | ||
string objectId, | ||
IProgress<ProgressArgs>? progress, | ||
CancellationToken cancellationToken | ||
) => throw new NotImplementedException(); | ||
|
||
public Task<Dictionary<string, bool>> HasObjects( | ||
IReadOnlyCollection<string> objectIds, | ||
CancellationToken cancellationToken | ||
) => Task.FromResult(objectIds.ToDictionary(id => id, id => false)); | ||
|
||
public Task UploadObjects( | ||
IReadOnlyList<BaseItem> objects, | ||
bool compressPayloads, | ||
IProgress<ProgressArgs>? progress, | ||
CancellationToken cancellationToken | ||
) | ||
{ | ||
long totalBytes = 0; | ||
foreach (var item in objects) | ||
{ | ||
totalBytes += Encoding.Default.GetByteCount(item.Json.Value); | ||
} | ||
|
||
progress?.Report(new(ProgressEvent.UploadBytes, totalBytes, totalBytes)); | ||
return Task.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#pragma warning disable CA1506 | ||
using System.Diagnostics; | ||
using Ara3D.Utils; | ||
//using JetBrains.Profiler.SelfApi; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Speckle.Importers.Ifc; | ||
using Speckle.Importers.Ifc.Ara3D.IfcParser; | ||
using Speckle.Importers.Ifc.Converters; | ||
using Speckle.Importers.Ifc.Tester; | ||
using Speckle.Importers.Ifc.Types; | ||
using Speckle.Sdk.Serialisation.V2.Send; | ||
using Speckle.Sdk.SQLite; | ||
|
||
var serviceProvider = Import.GetServiceProvider(); | ||
|
||
//DotMemory.Init(); | ||
var filePath = new FilePath( | ||
//"C:\\Users\\adam\\Git\\speckle-server\\packages\\fileimport-service\\ifc-dotnet\\ifcs\\20210221PRIMARK.ifc" | ||
//"C:\\Users\\adam\\Git\\speckle-server\\packages\\fileimport-service\\ifc-dotnet\\ifcs\\231110ADT-FZK-Haus-2005-2006.ifc" | ||
//"C:\\Users\\adam\\Downloads\\T03PV06IMPMI01C.ifc" | ||
"C:\\Users\\adam\\Downloads\\20231128_HW_Bouwkosten.ifc" | ||
); | ||
|
||
var ifcFactory = serviceProvider.GetRequiredService<IIfcFactory>(); | ||
var stopwatch = Stopwatch.StartNew(); | ||
|
||
Console.WriteLine($"Opening with WebIFC: {filePath}"); | ||
var model = ifcFactory.Open(filePath); | ||
var ms = stopwatch.ElapsedMilliseconds; | ||
Console.WriteLine($"Opened with WebIFC: {ms} ms"); | ||
|
||
var graph = IfcGraph.Load(new FilePath(filePath)); | ||
var ms2 = stopwatch.ElapsedMilliseconds; | ||
Console.WriteLine($"Loaded with StepParser: {ms2 - ms} ms"); | ||
|
||
var converter = serviceProvider.GetRequiredService<IGraphConverter>(); | ||
var b = converter.Convert(model, graph); | ||
ms = ms2; | ||
ms2 = stopwatch.ElapsedMilliseconds; | ||
Console.WriteLine($"Converted to Speckle Bases: {ms2 - ms} ms"); | ||
|
||
var cache = $"C:\\Users\\adam\\Git\\temp\\{Guid.NewGuid()}.db"; | ||
using var sqlite = new SqLiteJsonCacheManager($"Data Source={cache};", 2); | ||
using var process2 = new SerializeProcess( | ||
new Progress(true), | ||
sqlite, | ||
new DummyServerObjectManager(), | ||
new BaseChildFinder(new BasePropertyGatherer()), | ||
new ObjectSerializerFactory(new BasePropertyGatherer()), | ||
new SerializeProcessOptions(SkipServer: true) | ||
); | ||
Console.WriteLine($"Caching to Speckle: {cache}"); | ||
|
||
/*var config = new DotMemory.Config(); | ||
config.OpenDotMemory(); | ||
config.SaveToDir("C:\\Users\\adam\\dotTraceSnapshots"); | ||
DotMemory.Attach(config); | ||
DotMemory.GetSnapshot("Before");*/ | ||
var (rootId, _) = await process2.Serialize(b, default).ConfigureAwait(false); | ||
Console.WriteLine(rootId); | ||
ms2 = stopwatch.ElapsedMilliseconds; | ||
Console.WriteLine($"Converted to JSON: {ms2 - ms} ms"); | ||
//DotMemory.GetSnapshot("After"); | ||
//DotMemory.Detach(); | ||
#pragma warning restore CA1506 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Speckle.Sdk.Transports; | ||
|
||
namespace Speckle.Importers.Ifc.Tester; | ||
|
||
public class Progress(bool write) : IProgress<ProgressArgs> | ||
{ | ||
private readonly TimeSpan _debounce = TimeSpan.FromMilliseconds(1000); | ||
private DateTime _lastTime = DateTime.UtcNow; | ||
|
||
private long _totalBytes; | ||
|
||
public void Report(ProgressArgs value) | ||
{ | ||
if (write) | ||
{ | ||
if (value.ProgressEvent == ProgressEvent.DownloadBytes) | ||
{ | ||
Interlocked.Add(ref _totalBytes, value.Count); | ||
} | ||
var now = DateTime.UtcNow; | ||
if (now - _lastTime >= _debounce) | ||
{ | ||
if (value.ProgressEvent == ProgressEvent.DownloadBytes) | ||
{ | ||
Console.WriteLine(value.ProgressEvent + " t " + _totalBytes); | ||
} | ||
else | ||
{ | ||
Console.WriteLine(value.ProgressEvent + " c " + value.Count + " t " + value.Total); | ||
} | ||
|
||
_lastTime = now; | ||
} | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Importers/Ifc/Speckle.Importers.Ifc.Tester/Speckle.Importers.Ifc.Tester.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Configurations>Debug;Release;Local</Configurations> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Speckle.Importers.Ifc\Speckle.Importers.Ifc.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.