Skip to content

Commit

Permalink
IApplicationPropertiesExtractorConcretization
Browse files Browse the repository at this point in the history
- Renamed GeneralPropertiesExtractor to SharedPropertiesExtractor
- Renamed EtabsClassPropertiesExtractor to ApplicationPropertiesExtractor
- Removed PropertiesExtractor file
- Enforced injection of shared properties extractor to application specific extractor
- Output of Extract() of type PropertyExtractorResult
- Application property extractor mutates dictionary
  • Loading branch information
bjoernsteinhagen committed Dec 10, 2024
1 parent 6f2993d commit 4c20b9f
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ public static IServiceCollection AddCsiConverters(this IServiceCollection servic
serviceCollection.AddScoped<CsiFramePropertiesExtractor>();
serviceCollection.AddScoped<CsiJointPropertiesExtractor>();
serviceCollection.AddScoped<CsiShellPropertiesExtractor>();
serviceCollection.AddScoped<IGeneralPropertyExtractor, CsiGeneralPropertiesExtractor>();
serviceCollection.AddScoped<SharedPropertiesExtractor>();
serviceCollection.AddScoped<DisplayValueExtractor>();
serviceCollection.AddScoped<PropertiesExtractor>();

// Settings and unit conversions
serviceCollection.AddApplicationConverters<CsiToSpeckleUnitConverter, eUnits>(converterAssembly);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\LineToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\MeshToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\PointToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Helpers\CsiGeneralPropertiesExtractor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Helpers\SharedPropertiesExtractor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Helpers\DisplayValueExtractor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Helpers\IPropertyExtractor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Helpers\PropertiesExtractor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Helpers\IApplicationPropertiesExtractor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\TopLevel\CsiObjectToSpeckleConverterBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\DictionaryUtils.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,34 @@ namespace Speckle.Converters.CSiShared.ToSpeckle.Helpers;
/// * Simpler maintenance as each method maps to one API concept
/// Integration:
/// - Part of the property extraction hierarchy
/// - Used by <see cref="CsiGeneralPropertiesExtractor"/> for delegating frame property extraction
/// - Used by <see cref="SharedPropertiesExtractor"/> for delegating frame property extraction
/// </remarks>
public sealed class CsiFramePropertiesExtractor
{
private readonly IConverterSettingsStore<CsiConversionSettings> _settingsStore;
private static readonly string[] s_releaseKeys =
[
"axial",
"minorShear",
"majorShear",
"torsion",
"minorBending",
"majorBending"
]; // Note: caching keys for better performance

public CsiFramePropertiesExtractor(IConverterSettingsStore<CsiConversionSettings> settingsStore)
{
_settingsStore = settingsStore;
}

public void ExtractProperties(CsiFrameWrapper frame, Dictionary<string, object?> properties)
public void ExtractProperties(CsiFrameWrapper frame, PropertyExtractionResult frameData)
{
properties["applicationId"] = GetApplicationId(frame);
frameData.ApplicationId = GetApplicationId(frame);

var geometry = DictionaryUtils.EnsureNestedDictionary(properties, "Geometry");
var geometry = DictionaryUtils.EnsureNestedDictionary(frameData.Properties, "Geometry");
(geometry["startJointName"], geometry["endJointName"]) = GetEndPointNames(frame);

var assignments = DictionaryUtils.EnsureNestedDictionary(properties, "Assignments");
var assignments = DictionaryUtils.EnsureNestedDictionary(frameData.Properties, "Assignments");
assignments["groups"] = new List<string>(GetGroupAssigns(frame));
assignments["materialOverwrite"] = GetMaterialOverwrite(frame);
assignments["localAxis"] = GetLocalAxes(frame);
Expand Down Expand Up @@ -104,9 +113,7 @@ private string GetMaterialOverwrite(CsiFrameWrapper frame)

_ = _settingsStore.Current.SapModel.FrameObj.GetReleases(frame.Name, ref ii, ref jj, ref startValue, ref endValue);

var releaseKeys = new[] { "axial", "minorShear", "majorShear", "torsion", "minorBending", "majorBending" };

var startNodes = releaseKeys
var startNodes = s_releaseKeys
.Select(
(key, index) =>
new KeyValuePair<string, object?>(
Expand All @@ -116,7 +123,7 @@ private string GetMaterialOverwrite(CsiFrameWrapper frame)
)
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

var endNodes = releaseKeys
var endNodes = s_releaseKeys
.Select(
(key, index) =>
new KeyValuePair<string, object?>(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Speckle.Converters.CSiShared.ToSpeckle.Helpers;
/// - Ensures consistency in property extraction logic across supported CSi products.
/// Integration:
/// - Part of the property extraction hierarchy
/// - Used by <see cref="CsiGeneralPropertiesExtractor"/> for delegating joint property extraction
/// - Used by <see cref="SharedPropertiesExtractor"/> for delegating joint property extraction
/// </remarks>
public sealed class CsiJointPropertiesExtractor
{
Expand All @@ -30,11 +30,11 @@ public CsiJointPropertiesExtractor(IConverterSettingsStore<CsiConversionSettings
_settingsStore = settingsStore;
}

public void ExtractProperties(CsiJointWrapper joint, Dictionary<string, object?> properties)
public void ExtractProperties(CsiJointWrapper joint, PropertyExtractionResult jointData)
{
properties["applicationId"] = GetApplicationId(joint);
jointData.ApplicationId = GetApplicationId(joint);

var assignments = DictionaryUtils.EnsureNestedDictionary(properties, "Assignments");
var assignments = DictionaryUtils.EnsureNestedDictionary(jointData.Properties, "Assignments");
assignments["groups"] = new List<string>(GetGroupAssigns(joint));
assignments["restraints"] = GetRestraints(joint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Speckle.Converters.CSiShared.ToSpeckle.Helpers;
/// * Simpler maintenance as each method maps to one API concept
/// Integration:
/// - Part of the property extraction hierarchy
/// - Used by <see cref="CsiGeneralPropertiesExtractor"/> for delegating shell property extraction
/// - Used by <see cref="SharedPropertiesExtractor"/> for delegating shell property extraction
/// </remarks>
public sealed class CsiShellPropertiesExtractor
{
Expand All @@ -27,14 +27,14 @@ public CsiShellPropertiesExtractor(IConverterSettingsStore<CsiConversionSettings
_settingsStore = settingsStore;
}

public void ExtractProperties(CsiShellWrapper shell, Dictionary<string, object?> properties)
public void ExtractProperties(CsiShellWrapper shell, PropertyExtractionResult shellData)
{
properties["applicationId"] = GetApplicationId(shell);
shellData.ApplicationId = GetApplicationId(shell);

var geometry = DictionaryUtils.EnsureNestedDictionary(properties, "Geometry");
var geometry = DictionaryUtils.EnsureNestedDictionary(shellData.Properties, "Geometry");
geometry["shellVerticesJointNames"] = GetPointNames(shell);

var assignments = DictionaryUtils.EnsureNestedDictionary(properties, "Assignments");
var assignments = DictionaryUtils.EnsureNestedDictionary(shellData.Properties, "Assignments");
assignments["groups"] = new List<string>(GetGroupAssigns(shell));
assignments["localAxis"] = GetLocalAxes(shell);
assignments["materialOverwrite"] = GetMaterialOverwrite(shell);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Speckle.Converters.CSiShared.ToSpeckle.Helpers;

public struct PropertyExtractionResult
{
public string Name { get; set; }
public string Type { get; set; }
public string ApplicationId { get; set; }
public Dictionary<string, object?> Properties { get; set; }
}

/// <summary>
/// Interface for extracting application-specific properties (e.g., ETABS-specific properties).
/// Implementations must compose with SharedPropertiesExtractor to ensure both shared and
/// application-specific properties are extracted.
/// </summary>
public interface IApplicationPropertiesExtractor
{
SharedPropertiesExtractor SharedPropertiesExtractor { get; }
PropertyExtractionResult ExtractProperties(ICsiWrapper wrapper);
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4c20b9f

Please sign in to comment.