Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added merging tolerance within LusasConfig to apply to both the comparers and the software #374

Merged
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
107c089
Added Mergingtolerance double variable to LusasConfig. Default value …
KalleEdstroem Oct 16, 2023
8f19557
Changed name from MergingTolerance to MergeTolerance to align with Lu…
KalleEdstroem Oct 16, 2023
f8b98d3
Changed variable name for consistency
KalleEdstroem Oct 17, 2023
af75fd5
Added description of input. Changed deafult value to come from Tolera…
KalleEdstroem Oct 18, 2023
24b09f3
Added reference and changed default value
KalleEdstroem Oct 18, 2023
5610cb1
Added referance BH.oM.Geometry. Setting default value of MergeTolerance
KalleEdstroem Oct 19, 2023
be66a59
Added m_mergeTolerance. Sets the Lusas Merge Tolerance when running N…
KalleEdstroem Nov 1, 2023
eb1b37a
Changed reference code to follow rest of the project.
KalleEdstroem Nov 1, 2023
993e195
Changed default value of m_mergeTolerance. Removed if statement from …
KalleEdstroem Nov 1, 2023
3ab913f
Made mergeTolerance a mandatory input to LusasConfig.
KalleEdstroem Nov 2, 2023
0b71086
Changes to ensure correct tolerance assignment for all possible cases
KalleEdstroem Nov 2, 2023
13b3069
Changed name from LusasConfig to LusasSettings. Made LusasSettings in…
KalleEdstroem Nov 2, 2023
2da9564
Renaming for all other LusasAdapters
KalleEdstroem Nov 2, 2023
f90fb71
Versioning
KalleEdstroem Nov 2, 2023
d1881c3
Versioning updates
KalleEdstroem Nov 2, 2023
e9aeffe
Versioning update
KalleEdstroem Nov 2, 2023
cd15355
Versioning updates.
KalleEdstroem Nov 7, 2023
710d482
Versioning updates
KalleEdstroem Nov 7, 2023
02611d3
Versioning updates
KalleEdstroem Nov 8, 2023
62db780
Versioning update to have the right BHoM version.
KalleEdstroem Nov 9, 2023
4d223c9
Added json file and message for deleting LusasConfig object.
KalleEdstroem Nov 14, 2023
ff0f2ca
Versioning update.
KalleEdstroem Nov 14, 2023
8058dd4
Added descriptions and small change in reason for deletion message
KalleEdstroem Nov 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lusas_Adapter/AdapterActions/Execute.cs
KalleEdstroem marked this conversation as resolved.
Show resolved Hide resolved
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("6.3", "BH.Adapter.Lusas.LusasV18Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
KalleEdstroem marked this conversation as resolved.
Show resolved Hide resolved
public LusasV18Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
#elif Debug19 || Release19
public LusasV19Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
[PreviousVersion("6.3", "BH.Adapter.Lusas.LusasV19Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
KalleEdstroem marked this conversation as resolved.
Show resolved Hide resolved
public LusasV19Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
#elif Debug191 || Release191
public LusasV191Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
[PreviousVersion("6.3", "BH.Adapter.Lusas.LusasV191Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
KalleEdstroem marked this conversation as resolved.
Show resolved Hide resolved
public LusasV191Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
#elif Debug200 || Release200
public LusasV200Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
[PreviousVersion("6.3", "BH.Adapter.Lusas.LusasV200Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
KalleEdstroem marked this conversation as resolved.
Show resolved Hide resolved
public LusasV200Adapter(string filePath, LusasSettings lusasSettings = null, bool active = false)
#else
public LusasV17Adapter(string filePath, LusasConfig lusasConfig = null, bool active = false)
[PreviousVersion("6.3", "BH.Adapter.Lusas.LusasV17Adapter(System.String, BH.oM.Adapters.Lusas.LusasConfig, System.Boolean)")]
KalleEdstroem marked this conversation as resolved.
Show resolved Hide resolved
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,7 @@
*/

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

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

public static LusasConfig LusasConfig(LibrarySettings librarySettings = null)
[PreviousVersion("6.3", "BH.Engine.Adaters.Lusas.Create.LusasConfig(BH.oM.Adapters.Lusas.LibrarySettings)")]
KalleEdstroem marked this conversation as resolved.
Show resolved Hide resolved
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>
16 changes: 13 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,7 +159,7 @@
<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" />
Expand All @@ -170,4 +180,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,14 +21,19 @@
*/

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 in Lusas and the distance comparers used by the Lusas_Adapter.")]
KalleEdstroem marked this conversation as resolved.
Show resolved Hide resolved
public virtual double MergeTolerance { get; set; } = double.NaN;

public virtual LibrarySettings LibrarySettings { get; set; } = new LibrarySettings();

Expand Down