Skip to content

Commit

Permalink
Merge pull request #43 from oberbichler/feature/max-points
Browse files Browse the repository at this point in the history
Add Maximum Points Parameter
  • Loading branch information
oberbichler authored Mar 4, 2021
2 parents a9d0e49 + 3ada42a commit 04ee85b
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 17 deletions.
15 changes: 7 additions & 8 deletions Bowerbird/Components/PathfinderComponents/ConstructPathfinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected override void RegisterInputParams(GH_InputParamManager pManager)
pManager.AddBrepParameter("Surface", "S", "", GH_ParamAccess.item);
pManager.AddVectorParameter("Point", "P", "", GH_ParamAccess.item);
pManager.AddNumberParameter("Step Size", "H", "", GH_ParamAccess.item, 0.1);
pManager.AddIntegerParameter("Maximum number of Points", "N", "", GH_ParamAccess.item, 10000);
}

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
Expand All @@ -38,11 +39,13 @@ protected override void SolveInstance(IGH_DataAccess DA)
var brep = default(Brep);
var startingPoint = default(Vector3d);
var stepSize = default(double);
var maxPoints = default(int);

if (!DA.GetData(0, ref path)) return;
if (!DA.GetData(1, ref brep)) return;
if (!DA.GetData(2, ref startingPoint)) return;
if (!DA.GetData(3, ref stepSize)) return;
if (!DA.GetData(4, ref maxPoints)) return;

if (brep.Faces.Count > 1)
throw new Exception("Multipatches not yet supported");
Expand Down Expand Up @@ -122,24 +125,20 @@ protected override void SolveInstance(IGH_DataAccess DA)
uv = new Vector2d(u, v);
}

//var type = (path as NormalCurvaturePath)?.Type ?? (path as GeodesicTorsionPath)?.Type ?? (path as DGridPath)?.Type ?? (path as PSPath).Type;

var type = (path as NormalCurvaturePath)?.Type ?? Path.Types.Both;

var curves = new List<CurveOnSurface>(2);

if (type.HasFlag(Path.Types.First))
if (path.Type.HasFlag(Path.Types.First))
{
var pathfinder = Pathfinder.Create(path, face, uv, false, stepSize, tolerance);
var pathfinder = Pathfinder.Create(path, face, uv, false, stepSize, tolerance, maxPoints);

var curve = new PolylineCurve(pathfinder.Parameters);

curves.Add(CurveOnSurface.Create(surface, curve));
}

if (type.HasFlag(Path.Types.Second))
if (path.Type.HasFlag(Path.Types.Second))
{
var pathfinder = Pathfinder.Create(path, face, uv, true, stepSize, tolerance);
var pathfinder = Pathfinder.Create(path, face, uv, true, stepSize, tolerance, maxPoints);

var curve = new PolylineCurve(pathfinder.Parameters);

Expand Down
2 changes: 0 additions & 2 deletions Bowerbird/Curvature/DGridPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class DGridPath : Path

public Transform Material { get; private set; }

public Types Type { get; private set; }

private DGridPath(NurbsSurface refSurface, NurbsSurface actSurface, Transform material, Types type)
{
RefSurface = refSurface;
Expand Down
2 changes: 0 additions & 2 deletions Bowerbird/Curvature/GeodesicTorsionPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public class GeodesicTorsionPath : Path

public double Angle { get; private set; }

public Types Type { get; private set; }

private GeodesicTorsionPath(double value, double angle, Types type)
{
Value = value;
Expand Down
2 changes: 0 additions & 2 deletions Bowerbird/Curvature/NormalCurvaturePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public class NormalCurvaturePath : Path

public double Angle { get; private set; }

public Types Type { get; private set; }

private NormalCurvaturePath(double value, double angle, Types type)
{
Value = value;
Expand Down
2 changes: 2 additions & 0 deletions Bowerbird/Curvature/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public enum Types
Both = 3
}

public Types Type { get; protected set; }

public abstract Vector3d InitialDirection(Surface surface, Vector2d uv, bool type);

public abstract Vector2d Direction(Surface surface, Vector2d uv, Vector3d lastDirection, double stepSize);
Expand Down
2 changes: 1 addition & 1 deletion Bowerbird/Curvature/Pathfinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public Pathfinder(List<Point3d> parameters, List<Point3d> points)
Points = points;
}

public static Pathfinder Create(Path path, BrepFace face, Vector2d uv, bool type, double stepSize, double tolerance, int maxPoints = 10000)
public static Pathfinder Create(Path path, BrepFace face, Vector2d uv, bool type, double stepSize, double tolerance, int maxPoints)
{
var parameters = new List<Point3d>();
var points = new List<Point3d>();
Expand Down
2 changes: 0 additions & 2 deletions Bowerbird/Curvature/PrincipalStressPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class PrincipalStressPath : Path

public Transform Material { get; private set; }

public Types Type { get; private set; }

private PrincipalStressPath(NurbsSurface refSurface, NurbsSurface actSurface, Transform material, Types type)
{
RefSurface = refSurface;
Expand Down

0 comments on commit 04ee85b

Please sign in to comment.