Skip to content

Commit

Permalink
add IsInPolygonPlus
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Aug 13, 2023
1 parent 9c5f6d7 commit 9b836f7
Show file tree
Hide file tree
Showing 6 changed files with 391 additions and 18 deletions.
2 changes: 1 addition & 1 deletion OpenMEPCad/OpenMEPCad.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GShark" Version="2.3.0" />
<PackageReference Include="GShark" Version="2.3.1" />
<PackageReference Include="DynamoVisualProgramming.DynamoCoreNodes" Version="$(DynVersion).*">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
Expand Down
1 change: 0 additions & 1 deletion OpenMEPRevit/OpenMEPRevit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<Reference Include="System.Net.Http" />
<PackageReference Include="GShark" Version="2.3.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
Expand Down
32 changes: 17 additions & 15 deletions OpenMEPSandbox/Geometry/Point.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,23 @@ public static bool IsOnPlane(Autodesk.DesignScript.Geometry.Point point, Autodes
};
}

// //
// // //TODO : Got some bug from G-Shark Library
// /// <summary>
// /// Tests whether a point is inside, outside, or coincident with a polygon.
// /// </summary>
// /// <returns name="double">Returns -1 if point is outside the polygon, 0 if it is coincident with a polygon edge, or 1 if it is inside the polygon.</returns>
// public static double IsInPolygon2(Autodesk.DesignScript.Geometry.Point point,
// Autodesk.DesignScript.Geometry.Polygon polygon)
// {
// if (point == null) throw new ArgumentNullException(nameof(point));
// if (polygon == null) throw new ArgumentNullException(nameof(polygon));
// Point3 point3 = point.ToGSharkType();
// Polygon polyGshark = polygon.ToGSharkType();
// return point3.InPolygon(polyGshark);
// }
/// <summary>
/// Tests whether a point is inside, outside, or coincident with a polygon.
/// </summary>
/// <returns name="double">Returns -1 if point is outside the polygon, 0 if it is coincident with a polygon edge, or 1 if it is inside the polygon.</returns>
/// <example>
/// ![](../OpenMEPPage/geometry/dyn/pic/Point.IsInPolygonPlus.png)
/// [Point.IsInPolygonPlus.dyn](../OpenMEPPage/geometry/dyn/Point.IsInPolygonPlus.dyn)
/// </example>
public static double IsInPolygonPlus(Autodesk.DesignScript.Geometry.Point point,
Autodesk.DesignScript.Geometry.Polygon polygon)
{
if (point == null) throw new ArgumentNullException(nameof(point));
if (polygon == null) throw new ArgumentNullException(nameof(polygon));
Point3 point3 = point.ToGSharkType();
GShark.Geometry.Polygon polyGshark = polygon.ToGSharkType();
return point3.InPolygon(polyGshark);
}

/// <summary>
/// Returns whether an input point is contained within the polygon. If the polygon is not planar then the point will be projected onto the best-fit plane and the containment will be computed using the projection of the polygon onto the best-fit plane. This will return a failed status if the polygon self-intersects.
Expand Down
2 changes: 1 addition & 1 deletion OpenMEPSandbox/OpenMEPSandbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GShark" Version="2.3.0" />
<PackageReference Include="GShark" Version="2.3.1" />
<PackageReference Include="DynamoVisualProgramming.DynamoCoreNodes" Version="$(DynVersion).*">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit 9b836f7

Please sign in to comment.