示例#1
0
文件: Load.cs 项目: PawelBee/Guanaco
        /***************************************************/

        // Clone.
        public override GuanacoObject Clone(bool newID = false)
        {
            InfillLoad il = this.ShallowClone(newID) as InfillLoad;

            il._infills = this._infills.Select(i => i.Clone(newID) as Infill).ToList();
            return(il);
        }
示例#2
0
        /***************************************************/

        // Apply infill load to the adjoining elements.
        private void ApplyLoad(InfillLoad load)
        {
            foreach (Element e in this._mesh.Elements)
            {
                // Check if the element is 2D.
                Element2D el = e as Element2D;
                if (el == null)
                {
                    continue;
                }

                Point3d  elC = el.GetCentroid();
                Vector3d elN = el.GetNormal();
                foreach (Infill i in load.Infills)
                {
                    // Check if the element is adjoining to the infill (if all its vertices lie within tolerance).
                    bool broken = false;
                    foreach (Point3d v in el.GetVertices())
                    {
                        if (v.DistanceTo(i.Volume.ClosestPoint(v)) > this._tolerance)
                        {
                            broken = true;
                            break;
                        }
                    }

                    // If the element is adjoining to the infill, apply the load based on location of the element and load function of the infill.
                    if (!broken)
                    {
                        // Flip normal of the element if it points outside the infill.
                        Point3d cpt = Point3d.Add(elC, elN * this._tolerance);
                        if (!i.Volume.IsPointInside(cpt, Rhino.RhinoMath.SqrtEpsilon, true))
                        {
                            el.FlipNormal();
                        }

                        // Check if the element is not surrounded by the infill from both sides - if it is then do nothing (no hydrostatic pressure).
                        else
                        {
                            cpt = Point3d.Add(elC, -elN * this._tolerance);
                            if (i.Volume.IsPointInside(cpt, Rhino.RhinoMath.SqrtEpsilon, true))
                            {
                                continue;
                            }
                        }

                        // Apply the load based on location of the element and load function of the infill.
                        string g = load.InfillDensity.ToString(GuanacoUtil.Invariant);
                        string x = (i.MaxZ - elC.Z).ToString(GuanacoUtil.Invariant);
                        string z = (i.MaxZ - i.MinZ).ToString(GuanacoUtil.Invariant);
                        string f = load.LoadFunction.Replace("g", g).Replace("x", x).Replace("z", z);
                        double p = GuanacoUtil.Evaluate(f);
                        el.AddPressure(-p);
                    }
                }
            }
        }