Skip to content

Commit

Permalink
Added merging tolerance within LusasConfig to apply to both the compa…
Browse files Browse the repository at this point in the history
…rers and the software (#374)
  • Loading branch information
Fraser Greenroyd authored Nov 16, 2023
2 parents d475ce2 + 8058dd4 commit 8a25b55
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 18 deletions.
4 changes: 4 additions & 0 deletions Lusas_Adapter/AdapterActions/Execute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public bool RunCommand(NewModel command)
d_LusasData.setVerticalDir("Z");
m_LusasApplication.fileOpen("%PerMachineAppDataPlatform%\\config\\AfterNewModel");
d_LusasData.setAnalysisCategory("3D");
if (!double.IsNaN(m_mergeTolerance))
d_LusasData.getOptions().setDouble("TOLMRG", m_mergeTolerance);

string fileName = $"{m_directory}\\sections.csv";
File.Delete(fileName);
Expand Down Expand Up @@ -111,6 +113,8 @@ public bool RunCommand(Open command)
{
m_LusasApplication.openDatabase(command.FileName);
d_LusasData = m_LusasApplication.getDatabase();
if (!double.IsNaN(m_mergeTolerance))
d_LusasData.getOptions().setDouble("TOLMRG", m_mergeTolerance);
m_directory = command.FileName;

return true;
Expand Down
25 changes: 19 additions & 6 deletions Lusas_Adapter/LusasAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using BH.oM.Base.Attributes;

namespace BH.Adapter.Lusas
{
Expand All @@ -56,15 +57,20 @@ public partial class LusasV17Adapter : BHoMAdapter
/**** Constructors ****/
/***************************************************/
#if Debug18 || Release18
public LusasV18Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
[PreviousVersion("7.0", "BH.Adapter.Lusas.LusasV18Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
public LusasV18Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
#elif Debug19 || Release19
public LusasV19Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
[PreviousVersion("7.0", "BH.Adapter.Lusas.LusasV19Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
public LusasV19Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
#elif Debug191 || Release191
public LusasV191Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
[PreviousVersion("7.0", "BH.Adapter.Lusas.LusasV191Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
public LusasV191Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
#elif Debug200 || Release200
public LusasV200Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
[PreviousVersion("7.0", "BH.Adapter.Lusas.LusasV200Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
public LusasV200Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
#else
public LusasV17Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
[PreviousVersion("7.0", "BH.Adapter.Lusas.LusasV17Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
public LusasV17Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
#endif
{
if (active)
Expand Down Expand Up @@ -131,6 +137,12 @@ public LusasV17Adapter(string filePath, LusasConfig lusasConfig = null, bool act
{
throw new Exception("An exception has been flagged by Lusas, it is likely the file is from a higher version of Lusas than the adapter being used.");
}

if (lusasSettings != null && !double.IsNaN(lusasSettings.MergeTolerance))
{
m_mergeTolerance = lusasSettings.MergeTolerance;
d_LusasData.getOptions().setDouble("TOLMRG", m_mergeTolerance);
}
}
}
}
Expand All @@ -151,10 +163,11 @@ public static bool IsApplicationRunning()
//Add any comlink object as a private field here, example named:

private string m_directory;
public double m_mergeTolerance = double.NaN;
public LusasWinApp m_LusasApplication;
public IFDatabase d_LusasData;
private Dictionary<Type, Dictionary<int, HashSet<string>>> m_tags = new Dictionary<Type, Dictionary<int, HashSet<string>>>();
public LusasConfig lusasConfig;
public LusasSettings lusasSettings;


/***************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/

using BH.oM.Adapters.Lusas;
using BH.oM.Base.Attributes;
using System.ComponentModel;

namespace BH.Engine.Adapters.Lusas
{
Expand All @@ -30,13 +32,21 @@ public static partial class Create
/**** Public Constructors ****/
/***************************************************/

public static LusasConfig LusasConfig(LibrarySettings librarySettings = null)
[PreviousVersion("7.0", "BH.Engine.Adapters.Lusas.Create.LusasConfig(BH.oM.Adapters.Lusas.LibrarySettings)")]
[Description("Lusas adapter settings.")]
[Input("mergeTolerance", "Sets the merging tolerance used in Lusas.")]
[Input("librarySettings", "Sets the library settings.")]
[Output("Lusas specific adapter settings to be used by the adapter.")]
public static LusasSettings LusasSettings(double mergeTolerance, LibrarySettings librarySettings = null)
{
LusasConfig lusasConfig = new LusasConfig();
LusasSettings lusasSettings = new LusasSettings();

lusasSettings.MergeTolerance = mergeTolerance;

if (librarySettings != null)
lusasConfig.LibrarySettings = librarySettings;
lusasSettings.LibrarySettings = librarySettings;

return lusasConfig;
return lusasSettings;
}
/***************************************************/
}
Expand Down
7 changes: 3 additions & 4 deletions Lusas_Engine/Lusas_Engine.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTarget="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -185,7 +185,7 @@
<Compile Include="Query\GetDistinctEdges.cs" />
<Compile Include="Modify\RemovePrefix.cs" />
<Compile Include="Create\LibrarySettings.cs" />
<Compile Include="Create\LusasConfig.cs" />
<Compile Include="Create\LusasSettings.cs" />
<Compile Include="Create\MeshSettings2D.cs" />
<Compile Include="Objects\Equality_Comparer\BarMidPointComparer.cs" />
<Compile Include="Objects\Equality_Comparer\MeshComparer.cs" />
Expand All @@ -203,11 +203,10 @@
<Name>Lusas_oM</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition="" />
<PropertyGroup>
<PostBuildEvent>
xcopy "$(TargetDir)$(TargetFileName)" "C:\ProgramData\BHoM\Assemblies" /Y
</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>
19 changes: 16 additions & 3 deletions Lusas_oM/Lusas_oM.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -124,6 +124,11 @@
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Adapter_oM">
<HintPath>$(ProgramData)\BHoM\Assemblies\Adapter_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BHoM">
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM.dll</HintPath>
<Private>False</Private>
Expand All @@ -134,6 +139,11 @@
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Geometry_oM">
<HintPath>$(ProgramData)\BHoM\Assemblies\Geometry_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -149,14 +159,17 @@
<Compile Include="Enum\Split2D.cs" />
<Compile Include="Fragments\LusasId.cs" />
<Compile Include="Settings\LibrarySettings.cs" />
<Compile Include="Settings\LusasConfig.cs" />
<Compile Include="Settings\LusasSettings.cs" />
<Compile Include="Fragments\MeshSettings2D.cs" />
<Compile Include="Fragments\MeshSettings1D.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Structural\Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="Versioning_70.json" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
Expand All @@ -170,4 +183,4 @@ xcopy "$(TargetDir)$(TargetFileName)" "C:\ProgramData\BHoM\Assemblies" /Y
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@
*/

using BH.oM.Base;
using System.ComponentModel;
using BH.oM.Adapter;

namespace BH.oM.Adapters.Lusas
{
public class LusasConfig : BHoMObject
public class LusasSettings : AdapterSettings
{
/***************************************************/
/**** Public Properties ****/
/***************************************************/

[Description("Sets the merging tolerance used in Lusas.")]
public virtual double MergeTolerance { get; set; } = double.NaN;

[Description("Sets the library settings.")]
public virtual LibrarySettings LibrarySettings { get; set; } = new LibrarySettings();

/***************************************************/
Expand Down
25 changes: 25 additions & 0 deletions Lusas_oM/Versioning_70.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"Namespace": {
"ToNew": {
},
"ToOld": {
}
},
"Type": {
"ToNew": {
},
"ToOld": {
}
},
"Property": {
"ToNew": {
},
"ToOld": {
}
},
"MessageForDeleted": {
"BH.oM.Adapters.Lusas.LusasConfig": "This object has been replaced by the LusasSettings object. For further information, please see the pull request associated with the change: https://github.com/BHoM/Lusas_Toolkit/pull/374."
},
"MessageForNoUpgrade": {
}
}

0 comments on commit 8a25b55

Please sign in to comment.