Skip to content

Commit

Permalink
Solves error on curve too short when generating volume from curves
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelAl committed Aug 7, 2020
1 parent 1893f33 commit c430f06
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions DendroGH/Classes/DendroVolume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -995,12 +995,24 @@ private int GetCurveSolverMethod (int cCount, int rCount) {
/// <param name="radius">desired point radius value</param>
/// <returns>list of divided points from curve</returns>
private List<Point3d> CurveToPoints (Curve crv, double radius) {
var cParams = crv.DivideByLength (radius * 0.25, true);
List<Point3d> cPoints = new List<Point3d> ();

foreach (double param in cParams) {
Point3d pt = crv.PointAt (param);
cPoints.Add (pt);

List<Point3d> cPoints = new List<Point3d>();

// Curve longer than a 1/4 of radius
if (crv.GetLength() > radius * 0.25)
{
var cParams = crv.DivideByLength(radius * 0.25, true);
foreach (double param in cParams)
{
Point3d pt = crv.PointAt(param);
cPoints.Add(pt);
}
}
// If curve too short add endpoints to point list
else
{
cPoints.Add(crv.PointAtNormalizedLength(0));
cPoints.Add(crv.PointAtNormalizedLength(1));
}

return cPoints;
Expand Down

0 comments on commit c430f06

Please sign in to comment.