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

Geometry_Engine: implement GeometryHash #2929

Merged
merged 48 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
90e22d9
Initial implementation
alelom Oct 19, 2022
a082ead
Update GeometryHash.cs
alelom Oct 19, 2022
1102abe
Update GeometryHash.cs
alelom Oct 25, 2022
8b774aa
Update GeometryHash.cs
alelom Oct 25, 2022
3d9bd06
Update GeometryHash.cs
alelom Oct 26, 2022
b817c2e
Update GeometryHash.cs
alelom Oct 26, 2022
ca1d296
Adding last methods
alelom Oct 26, 2022
47d1fd8
Adding translationFactors
alelom Oct 26, 2022
f2acf90
Update Geometry_Engine/Query/GeometryHash.cs
alelom Oct 27, 2022
400bfc7
Update GeometryHash.cs
alelom Oct 27, 2022
1a09fa1
Adding missing description attributes
alelom Oct 27, 2022
5b8e77a
Update Geometry_Engine/Query/GeometryHash.cs
alelom Oct 27, 2022
fa9157e
Update Geometry_Engine/Query/GeometryHash.cs
alelom Oct 27, 2022
df650ea
Update GeometryHash.cs
alelom Oct 27, 2022
52ecd70
Merge branch '#2928-GeometryHash' of https://github.com/BHoM/BHoM_Eng…
alelom Oct 27, 2022
12c5100
Update GeometryHash.cs
alelom Oct 27, 2022
a4f99ab
Update Geometry_Engine/Query/GeometryHash.cs
alelom Oct 27, 2022
68eafaa
Removed translationArray
alelom Oct 27, 2022
aa7b9a5
Merge branch '#2928-GeometryHash' of https://github.com/BHoM/BHoM_Eng…
alelom Oct 27, 2022
5e0d65a
Update FaceIndices.cs
alelom Oct 27, 2022
f06f929
Update GeometryHash.cs
alelom Nov 1, 2022
d646efe
Update GeometryHash.cs
alelom Nov 1, 2022
21a3cbc
Moved GeometryHash with IBHoMObject to BHoM_Engine
alelom Nov 4, 2022
5dfa9f4
Update GeometryHash.cs
alelom Nov 4, 2022
29a464f
Update GeometryHash.cs
alelom Nov 4, 2022
3f6438b
Adding unit tests
alelom Nov 4, 2022
088b886
Update Geometry_Engine/Query/GeometryHash.cs
alelom Nov 7, 2022
d26ecf3
Update Geometry_Engine/Query/GeometryHash.cs
alelom Nov 7, 2022
ffb00af
Update Geometry_Engine/Query/GeometryHash.cs
alelom Nov 7, 2022
2754dcb
Update GeometryHash.cs
alelom Nov 7, 2022
c63d050
Update GeometryHash.cs
alelom Nov 7, 2022
f66beae
Update GeometryHash.cs
alelom Nov 7, 2022
45ea50e
Update GeometryHash.cs
alelom Nov 7, 2022
257bee7
Update GeometryHash.cs
alelom Nov 7, 2022
0904b2d
Update GeometryHash.cs
alelom Nov 7, 2022
8ce75f1
Update GeometryHash.json
alelom Nov 7, 2022
ce98f1b
Update Geometry_Engine/Query/GeometryHash.cs
alelom Nov 8, 2022
0eadf1f
Update GeometryHash.cs
alelom Nov 8, 2022
84386ed
Update Geometry_Engine/Query/GeometryHash.cs
alelom Nov 9, 2022
4b08527
Update Geometry_Engine/Query/GeometryHash.cs
alelom Nov 9, 2022
adb6acb
Merge branch 'main' into #2928-GeometryHash
alelom Nov 9, 2022
57ad15f
Update Geometry_Engine/Query/GeometryHash.cs
alelom Nov 9, 2022
820f2d5
Merge branch '#2928-GeometryHash' of https://github.com/BHoM/BHoM_Eng…
alelom Nov 9, 2022
bd662bd
Update GeometryHash.cs
alelom Nov 9, 2022
d32c1a7
Update GeometryHash.json
alelom Nov 9, 2022
161dd6f
Update GeometryHash.cs
alelom Nov 9, 2022
ceff394
Update Geometry_Engine/Query/GeometryHash.cs
alelom Nov 9, 2022
cb2610a
Add null guards
alelom Nov 17, 2022
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
1 change: 1 addition & 0 deletions .ci/Datasets/BHoM_Engine/Query/GeometryHash.json

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions BHoM_Engine/Query/GeometryHash.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2022, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Reflection;
using BH.oM.Base.Attributes;
using System.ComponentModel;
using BH.Engine.Base;
using System.Collections;
using System.Data;
using BH.oM.Geometry;

namespace BH.Engine.Base
{
public static partial class Query
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[Description("Returns the geometrical identity of any IBHoMObject, useful for distance-based comparisons and diffing. " +
"\nThe geometrical identity is computed by extracting the geometry of the object via the IGeometry() method." +
"\nThen, the hash is computed as an array representing the coordinate of significant points taken on the geometry." +
"\nThe number of points is reduced to the minimum essential to determine uniquely any geometry." +
"\nAdditionally, the resulting points are transformed based on the source geometry type, to remove or minimize collisions." +
"\n(Any transformation so performed is translational only, in order to support geometrical tolerance, i.e. numerical distance, when comparing GeometryHashes downstream).")]
[Input("bhomObj", "Input BHoMObject whose geometry will be queried by IGeometry() and which will be used for computing a Geometry Hash.")]
[Output("geomHash","Array of numbers representing a unique signature of the input object's geometry.")]
public static double[] GeometryHash(this IBHoMObject bhomObj)
{
IGeometry igeom = bhomObj.IGeometry();

if (igeom == null)
return null;

if (m_GeomHashFunc == null)
{
MethodInfo mi = Query.ExtensionMethodToCall(igeom, "IGeometryHash");
m_GeomHashFunc = (Func<IGeometry, double[]>)Delegate.CreateDelegate(typeof(Func<IGeometry, double[]>), mi);
}

return m_GeomHashFunc(igeom);
}

private static Func<IGeometry, double[]> m_GeomHashFunc = null;
}
}


56 changes: 56 additions & 0 deletions Geometry_Engine/Query/FaceIndices.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2022, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.Geometry;
using System;
using System.ComponentModel;

using BH.oM.Base.Attributes;
using System.Collections.Generic;

namespace BH.Engine.Geometry
{
public static partial class Query
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[Description("Return the list of face indices for an input face. The last face index (D) is not added if it's equal to -1.")]
[Input("meshFace", "Mesh face to query the indices for.")]
[Output("indices", "List of indices.")]
public static List<int> FaceIndices(this Face meshFace)
{
List<int> result = new List<int>() { meshFace.A, meshFace.B, meshFace.C };

if (meshFace.D != -1)
result.Add(meshFace.D);

return result;
}

/***************************************************/

}
}


Loading