Skip to content

Commit

Permalink
Fixing meshing issues with uniform frame
Browse files Browse the repository at this point in the history
- Increased plane tolerance for convex hulls
- Fixed trimming tolerance issues by changing/adding parameters to
UniformDS component
  • Loading branch information
dnkrtz committed Jan 11, 2016
1 parent 5787b2d commit cd06fae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
11 changes: 7 additions & 4 deletions src/IntraLattice/CORE/Components/Frame/UniformDSComponent.cs
Expand Up @@ -50,8 +50,9 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM
pManager.AddNumberParameter("Cell Size ( x )", "CSx", "Size of unit cell (x)", GH_ParamAccess.item, 5); // default is 5
pManager.AddNumberParameter("Cell Size ( y )", "CSy", "Size of unit cell (y)", GH_ParamAccess.item, 5);
pManager.AddNumberParameter("Cell Size ( z )", "CSz", "Size of unit cell (z)", GH_ParamAccess.item, 5);
pManager.AddNumberParameter("Tolerance", "Tol", "Smallest allowed strut length", GH_ParamAccess.item, 0.2);
pManager.AddBooleanParameter("Strict tolerance", "Strict", "Specifies if we use a strict tolerance.", GH_ParamAccess.item, false);
pManager.AddNumberParameter("Min Strut Length", "MinL", "Minimum allowable strut length for trimmed struts.", GH_ParamAccess.item);
pManager.AddNumberParameter("Max Strut Length", "MaxL", "Maxmimum allowable strut length for trimmed struts.", GH_ParamAccess.item);
pManager.AddBooleanParameter("Strict tolerance", "Strict", "Specifies if we use a strict tolerance (i.e. strictly inside design space).", GH_ParamAccess.item, false);
}

/// <summary>
Expand All @@ -76,6 +77,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
double yCellSize = 0;
double zCellSize = 0;
double minLength = 0; // the trim tolerance (i.e. minimum strut length)
double maxLength = 0;
bool strictlyIn = false;

if (!DA.GetData(0, ref cell)) { return; }
Expand All @@ -85,7 +87,8 @@ protected override void SolveInstance(IGH_DataAccess DA)
if (!DA.GetData(4, ref yCellSize)) { return; }
if (!DA.GetData(5, ref zCellSize)) { return; }
if (!DA.GetData(6, ref minLength)) { return; }
if (!DA.GetData(7, ref strictlyIn)) { return; }
if (!DA.GetData(7, ref maxLength)) { return; }
if (!DA.GetData(8, ref strictlyIn)) { return; }

if (!cell.isValid) { return; }
if (!designSpace.IsValid) { return; }
Expand Down Expand Up @@ -195,7 +198,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
}

// 9. Map struts to the node tree
lattice.UniformMapping(cell, designSpace, spaceType, N, minLength);
lattice.UniformMapping(cell, designSpace, spaceType, N, minLength, maxLength);

// 10. Set output
DA.SetDataList(0, lattice.Struts);
Expand Down
4 changes: 2 additions & 2 deletions src/IntraLattice/CORE/Data/ExoMesh.cs
Expand Up @@ -251,7 +251,7 @@ public void FixSharpNodes(int nodeIndex, int sides)
}
foreach (int plateIndex in node.PlateIndices)
{
if (Vector3d.VectorAngle(-extraNormal, this.Plates[plateIndex].Normal) < Math.PI / 2)
if (Vector3d.VectorAngle(-extraNormal, this.Plates[plateIndex].Normal) < Math.PI / 4)
{
isSharp = false;
}
Expand Down Expand Up @@ -370,7 +370,7 @@ public Mesh MakeConvexHull(int nodeIndex, int sides, double tol, bool cleanPlate
ExoHull node = this.Hulls[nodeIndex];
double radius = node.AvgRadius;

double planeTolerance = tol * radius / 10;
double planeTolerance = tol * radius / 25;

// Collect all hull points (i.e. all plate points at the node)
List<Point3d> pts = new List<Point3d>();
Expand Down
10 changes: 5 additions & 5 deletions src/IntraLattice/CORE/Data/Lattice.cs
Expand Up @@ -260,7 +260,7 @@ public void MorphMapping(UnitCell cell, DataTree<GeometryBase> spaceTree, float[
/// <summary>
/// Maps cell topology to the node grid and trims to the design space.
/// </summary>
public void UniformMapping(UnitCell cell, GeometryBase designSpace, int spaceType, float[] N, double minStrutLength)
public void UniformMapping(UnitCell cell, GeometryBase designSpace, int spaceType, float[] N, double minStrutLength, double maxStrutLength)
{
double tol = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;

Expand Down Expand Up @@ -341,7 +341,7 @@ public void UniformMapping(UnitCell cell, GeometryBase designSpace, int spaceTyp
// Now, if an intersection point was found, trim the strut
if (intersectionPts.Length > 0)
{
testLine = AddTrimmedStrut(node1, node2, intersectionPts[0], minStrutLength);
testLine = AddTrimmedStrut(node1, node2, intersectionPts[0], minStrutLength, maxStrutLength);
// If the strut was succesfully trimmed, add it to the list
if (testLine != null)
{
Expand All @@ -364,15 +364,15 @@ public void UniformMapping(UnitCell cell, GeometryBase designSpace, int spaceTyp
/// <summary>
/// Trims strut with known intersection point, returning the trimmed LineCurve which is inside the space.
/// </summary>
public LineCurve AddTrimmedStrut(LatticeNode node1, LatticeNode node2, Point3d intersectionPt, double minStrutLength)
public LineCurve AddTrimmedStrut(LatticeNode node1, LatticeNode node2, Point3d intersectionPt, double minLength, double maxLength)
{

LineCurve testStrut = new LineCurve(new Line(node1.Point3d, node2.Point3d), 0, 1); // set line, with curve parameter domain [0,1]

if (node1.IsInside)
{
double trimmedLength = intersectionPt.DistanceTo(node1.Point3d);
if (trimmedLength > minStrutLength)
if (trimmedLength > minLength && trimmedLength < maxLength)
{
Nodes.Add(new LatticeNode(intersectionPt, LatticeNodeState.Boundary));
return new LineCurve(node1.Point3d, intersectionPt);
Expand All @@ -386,7 +386,7 @@ public LineCurve AddTrimmedStrut(LatticeNode node1, LatticeNode node2, Point3d i
if (node2.IsInside)
{
double trimmedLength = intersectionPt.DistanceTo(node2.Point3d);
if (trimmedLength > minStrutLength)
if (trimmedLength > minLength && trimmedLength < maxLength)
{
Nodes.Add(new LatticeNode(intersectionPt, LatticeNodeState.Boundary));
return new LineCurve(node2.Point3d, intersectionPt);
Expand Down

0 comments on commit cd06fae

Please sign in to comment.