Skip to content

Commit

Permalink
Make properties of RegionPointer class pubic.
Browse files Browse the repository at this point in the history
  • Loading branch information
wo80 committed Nov 6, 2023
1 parent dc1cb8c commit 391b9fa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 35 deletions.
45 changes: 19 additions & 26 deletions src/Triangle/Geometry/RegionPointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,35 @@

namespace TriangleNet.Geometry
{
using System;

/// <summary>
/// Pointer to a region in the mesh geometry. A region is a well-defined
/// subset of the geometry (enclosed by subsegments).
/// </summary>
public class RegionPointer
{
internal Point point;
internal int id;
internal double area;
/// <summary>
/// Gets the x and y coordinates of the region pointer.
/// </summary>
public Point Point { get; private set; }

/// <summary>
/// Gets or sets a region area constraint.
/// Gets the label of the region.
/// </summary>
public double Area
{
get { return area; }
set
{
if (value < 0.0)
{
throw new ArgumentException("Area constraints must not be negative.");
}
area = value;
}
}
public int Label { get; private set; }

/// <summary>
/// Gets the area constraint of the region.
/// </summary>
public double Area { get; private set; }

/// <summary>
/// Initializes a new instance of the <see cref="RegionPointer" /> class.
/// </summary>
/// <param name="x">X coordinate of the region.</param>
/// <param name="y">Y coordinate of the region.</param>
/// <param name="id">Region id.</param>
public RegionPointer(double x, double y, int id)
: this(x, y, id, 0.0)
/// <param name="label">Region label.</param>
public RegionPointer(double x, double y, int label)
: this(x, y, label, 0.0)
{
}

Expand All @@ -50,13 +43,13 @@ public RegionPointer(double x, double y, int id)
/// </summary>
/// <param name="x">X coordinate of the region.</param>
/// <param name="y">Y coordinate of the region.</param>
/// <param name="id">Region id.</param>
/// <param name="label">Region label.</param>
/// <param name="area">Area constraint.</param>
public RegionPointer(double x, double y, int id, double area)
public RegionPointer(double x, double y, int label, double area)
{
this.point = new Point(x, y);
this.id = id;
this.area = area;
Point = new Point(x, y);
Label = label;
Area = area;
}
}
}
8 changes: 4 additions & 4 deletions src/Triangle/IO/TriangleWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ public void WritePoly(IPolygon polygon, string filename)
writer.WriteLine("{0}", polygon.Regions.Count);
foreach (var region in polygon.Regions)
{
writer.WriteLine("{0} {1} {2} {3}", j, region.point.X.ToString(nfi),
region.point.Y.ToString(nfi), region.id);
writer.WriteLine("{0} {1} {2} {3}", j, region.Point.X.ToString(nfi),
region.Point.Y.ToString(nfi), region.Label);

j++;
}
Expand Down Expand Up @@ -328,8 +328,8 @@ public void WritePoly(Mesh mesh, string filename, bool writeNodes)
writer.WriteLine("{0}", mesh.regions.Count);
foreach (var region in mesh.regions)
{
writer.WriteLine("{0} {1} {2} {3}", j, region.point.X.ToString(nfi),
region.point.Y.ToString(nfi), region.id);
writer.WriteLine("{0} {1} {2} {3}", j, region.Point.X.ToString(nfi),
region.Point.Y.ToString(nfi), region.Label);

j++;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Triangle/Meshing/ConstraintMesher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void CarveHoles()
{
regionTris[i] = dummytri;
// Ignore region points that aren't within the bounds of the mesh.
if (mesh.bounds.Contains(region.point))
if (mesh.bounds.Contains(region.Point))
{
// Start searching from some triangle on the outer boundary.
searchtri.tri = dummytri;
Expand All @@ -173,17 +173,17 @@ private void CarveHoles()
// region point falls within the starting triangle.
searchorg = searchtri.Org();
searchdest = searchtri.Dest();
if (predicates.CounterClockwise(searchorg, searchdest, region.point) > 0.0)
if (predicates.CounterClockwise(searchorg, searchdest, region.Point) > 0.0)
{
// Find a triangle that contains the region point.
intersect = mesh.locator.Locate(region.point, ref searchtri);
intersect = mesh.locator.Locate(region.Point, ref searchtri);
if ((intersect != LocateResult.Outside) && (!searchtri.IsInfected()))
{
// Record the triangle for processing after the
// holes have been carved.
regionTris[i] = searchtri.tri;
regionTris[i].label = region.id;
regionTris[i].area = region.area;
regionTris[i].label = region.Label;
regionTris[i].area = region.Area;
}
}
}
Expand Down

0 comments on commit 391b9fa

Please sign in to comment.