コード例 #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            BeamProperties prop = null;
            Line ln = Line.Unset;
            Vector3d norm = Vector3d.Unset;

            if (!DA.GetData(0, ref ln)) { return; }
            if (!DA.GetData(1, ref prop)) { return; }
            if (!DA.GetData(2, ref norm)) { return; }

            norm.Unitize();

            //Check if angle between tangent and normal is less than 1 degree
            if(Vector3d.VectorAngle(norm, ln.UnitTangent) < 0.0174 || Vector3d.VectorAngle(-norm, ln.UnitTangent) < 0.0174)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The given normal is within 1 degree of the tangent of the centre line. Please adjust normal");
                return;
            }

            double factor = Utilities.GetScalingFactorFromRhino();

            WR_Vector wrNorm = new WR_Vector(norm.X, norm.Y, norm.Z);
            WR_XYZ st = new WR_XYZ(ln.FromX* factor, ln.FromY* factor, ln.FromZ* factor);
            WR_XYZ en = new WR_XYZ(ln.ToX* factor, ln.ToY* factor, ln.ToZ* factor);

            WR_Elem3dRcp beam = new WR_Elem3dRcp(st, en, prop.StartRelease, prop.EndRelease, prop.CrossSection, prop.Material, wrNorm, prop.OptimizationProperties);

            DA.SetData(0, beam);
        }
コード例 #2
0
        /// <summary>
        /// Takes a WR_Vector and creates a Rhino Vector3d
        /// </summary>
        /// <param name="vec"></param>
        /// <param name="scaleToRhinoUnits"></param>
        /// <returns></returns>
        private Rhino.Geometry.Vector3d CreateRhinoVector(WR_Vector vec, bool scaleToRhinoUnits)
        {
            double factor = 1;

            if (scaleToRhinoUnits)
            {
                factor = Utilities.GetScalingFactorFromRhino();
            }

            return(new Rhino.Geometry.Vector3d(vec.X / factor, vec.Y / factor, vec.Z / factor));
        }
コード例 #3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            ///// INPUTS /////
            Point3d     pt   = Point3d.Unset;
            List <bool> rels = new List <bool>();
            Plane       pl   = Plane.Unset;

            if (!DA.GetData(0, ref pt))
            {
                return;
            }

            if (!DA.GetDataList <bool>(1, rels))
            {
                //Set as unrestrained if no release information is provided
                for (int i = 0; i < 6; i++)
                {
                    rels.Add(false);
                }
            }

            if (rels.Count != 6)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Number of bools in input should be 6");
                return;
            }

            if (!DA.GetData(2, ref pl))
            {
                // If no plane submitted, use global XY plane
                pl = new Rhino.Geometry.Plane(new Rhino.Geometry.Point3d(0, 0, 0),
                                              new Rhino.Geometry.Vector3d(1, 0, 0), new Rhino.Geometry.Vector3d(0, 1, 0));
            }


            ///// SOLVE /////

            double factor = Utilities.GetScalingFactorFromRhino();

            WR_XYZ    wrXYZ = new WR_XYZ(pt.X * factor, pt.Y * factor, pt.Z * factor);
            WR_Vector wrX   = GetUnitizedWR_Vector(pl.XAxis);
            WR_Vector wrY   = GetUnitizedWR_Vector(pl.YAxis);
            WR_Vector wrZ   = GetUnitizedWR_Vector(pl.ZAxis);

            WR_Plane     wrPl = new WR_Plane(wrX, wrY, wrZ, wrXYZ);
            WR_Restraint rest = new WR_Restraint(wrPl, rels[0], rels[1], rels[2], rels[3], rels[4], rels[5]);

            WR_INode node = new WR_Node3d(pt.X * factor, pt.Y * factor, pt.Z * factor, rest);

            ///// OUTPUTS /////
            DA.SetData(0, node);
        }
コード例 #4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            BeamProperties prop = null;
            Line           ln   = Line.Unset;
            Vector3d       norm = Vector3d.Unset;

            if (!DA.GetData(0, ref ln))
            {
                return;
            }
            if (!DA.GetData(1, ref prop))
            {
                return;
            }
            if (!DA.GetData(2, ref norm))
            {
                return;
            }

            norm.Unitize();

            //Check if angle between tangent and normal is less than 1 degree
            if (Vector3d.VectorAngle(norm, ln.UnitTangent) < 0.0174 || Vector3d.VectorAngle(-norm, ln.UnitTangent) < 0.0174)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The given normal is within 1 degree of the tangent of the centre line. Please adjust normal");
                return;
            }

            double factor = Utilities.GetScalingFactorFromRhino();

            WR_Vector wrNorm = new WR_Vector(norm.X, norm.Y, norm.Z);
            WR_XYZ    st     = new WR_XYZ(ln.FromX * factor, ln.FromY * factor, ln.FromZ * factor);
            WR_XYZ    en     = new WR_XYZ(ln.ToX * factor, ln.ToY * factor, ln.ToZ * factor);

            WR_Elem3dRcp beam = new WR_Elem3dRcp(st, en, prop.StartRelease, prop.EndRelease, prop.CrossSection, prop.Material, wrNorm, prop.OptimizationProperties);

            DA.SetData(0, beam);
        }
コード例 #5
0
ファイル: Utilities.cs プロジェクト: IsakNaslund/MasterThesis
        static public List <Brep> CreateSectionSweeps(WR_Elem3dRcp er)
        {
            List <Curve> crvs;
            List <Brep>  eSBreps = new List <Brep>();

            // Start and end caps
            List <Curve> sCap = new List <Curve>();
            List <Curve> eCap = new List <Curve>();

            if (CrossSectionCasts.GetSectionPropertyCrvs(er.GetSectionString(), out crvs))
            {
                // Get x vector
                Point3d  sPos     = er.GetStartPos().ConvertToRhinoPoint();
                Point3d  ePos     = er.GetEndPos().ConvertToRhinoPoint();
                Vector3d elX      = new Vector3d(ePos.X - sPos.X, ePos.Y - sPos.Y, ePos.Z - sPos.Z);
                double   elLength = elX.Length;
                elX.Unitize();
                Vector3d move = elX * elLength;

                // Get normal (z vector)
                WR_Vector elWrZ = er.GetElementNormal();
                Vector3d  elZ   = new Vector3d(elWrZ.X, elWrZ.Y, elWrZ.Z);

                // Get y vector
                Vector3d elY = Vector3d.CrossProduct(elZ, elX);

                // Rotation to local coordinates
                Transform rotTrans = Transform.Rotation(Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, elX, elY, elZ);

                // Add start and end point to a list
                List <Point3d> endPts = new List <Point3d> {
                    sPos, ePos
                };

                foreach (Curve crv in crvs)
                {
                    // Rotate to local coordinates
                    crv.Transform(rotTrans);
                    crv.Translate((Vector3d)sPos);

                    // Create and add extrusion
                    Brep extrusion = Extrusion.CreateExtrusion(crv, move).ToBrep();
                    eSBreps.Add(extrusion);

                    // Add curve to cap list
                    sCap.Add(crv);

                    // Move to end and add
                    Curve eCrv = (Curve)crv.Duplicate();
                    eCrv.Translate(move);
                    eCap.Add(eCrv);
                }

                // Cap sections
                eSBreps.Add(CapSections(sCap));
                eSBreps.Add(CapSections(eCap));
            }


            return(eSBreps);
        }
コード例 #6
0
        /// <summary>
        /// Takes a WR_Vector and creates a Rhino Vector3d
        /// </summary>
        /// <param name="vec"></param>
        /// <param name="scaleToRhinoUnits"></param>
        /// <returns></returns>
        private Rhino.Geometry.Vector3d CreateRhinoVector(WR_Vector vec, bool scaleToRhinoUnits)
        {
            double factor = 1;
            if (scaleToRhinoUnits)
                factor = Utilities.GetScalingFactorFromRhino();

            return new Rhino.Geometry.Vector3d(vec.X / factor, vec.Y / factor, vec.Z / factor);
        }