Skip to content

Commit

Permalink
feat(element): add Transform()
Browse files Browse the repository at this point in the history
  • Loading branch information
tsvilans committed Nov 19, 2020
1 parent 22a711a commit bba59dd
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion GluLamb/Structure/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ public class Element
{
public string Name;
public List<Connection> Connections;
public List<Plane> Handles;

protected Plane m_plane;
public GeometryBase Geometry;

public Element(string name = "")
{
Connections = new List<Connection>();
Handles = new List<Plane>();
Name = name;
m_plane = Plane.WorldXY;
Geometry = null;
Expand Down Expand Up @@ -75,18 +78,34 @@ public Element GetConnected(int index)
return conn.ElementB;
return conn.ElementA;
}

public virtual void Transform(Rhino.Geometry.Transform xform)
{
Geometry.Transform(xform);
m_plane.Transform(xform);

for (int i = 0; i < Handles.Count; ++i)
{
Handles[i].Transform(xform);
}
}
}

public class BeamElement : Element
{
public BeamBase Beam;

public BeamElement(BeamBase beam)
public BeamElement(BeamBase beam, string name="BeamElement") : base(name)
{
Beam = beam;
m_plane = Beam.GetPlane(Beam.Centreline.Domain.Mid);
}

public BeamElement(BeamBase beam, Plane handle, string name = "BeamElement") : base(handle, name)
{
Beam = beam;
}

public override GeometryBase Discretize(double length)
{
var t = Beam.Centreline.DivideByLength(length, false).ToList();
Expand All @@ -111,6 +130,11 @@ public override Point3d GetConnectionPoint(double t)
{
return Beam.Centreline.PointAt(t);
}
public override void Transform(Rhino.Geometry.Transform xform)
{
base.Transform(xform);
Beam.Transform(xform);
}
}

}

0 comments on commit bba59dd

Please sign in to comment.