public void ConstructBeamResultMesh(eColorMode colorMode, ref List <sMesh> meshes, out sRange dataRange, sRange threshold = null, double du = 0.0)
        {
            if (colorMode != eColorMode.NONE)
            {
                sRange resultRange = GetSystemBeamResultRange(colorMode);

                foreach (IFrameSet bs in this.frameSets)
                {
                    foreach (sFrame b in bs.frames)
                    {
                        sMesh sm = b.ConstructBeamColorMesh(resultRange, colorMode, threshold, du);
                        meshes.Add(sm);
                    }
                }

                dataRange = resultRange;
            }
            else
            {
                foreach (IFrameSet bs in this.frameSets)
                {
                    foreach (sFrame b in bs.frames)
                    {
                        sMesh sm = b.ConstructBeamColorMesh(new sRange(0.0, 0.0), colorMode, new sRange(0.0, 0.0), 0.0);
                        meshes.Add(sm);
                    }
                }
                dataRange = null;
            }
        }
示例#2
0
        public double GetFrameSetDemand(eColorMode forceType, int round = -2)
        {
            double maxDemand = 0.0;
            sRange dataRange = this.GetFrameSetResultRange(forceType);

            maxDemand = Math.Max(Math.Abs(dataRange.min), Math.Abs(dataRange.max));
            //Here everything should be SI Unit!!!

            //if ((int)forceType > 6)
            //{
            //    if (forceType.ToString().Contains("Moment"))
            //    {
            //        //N.m > kip.in
            //        maxDemand *= 0.28476439306;
            //    }
            //    else if (forceType.ToString().Contains("Force"))
            //    {
            //
            //    }
            //    else if (forceType.ToString().Contains("Deflection"))
            //    {
            //        //mm to in
            //        maxDemand *= 0.0393701;
            //    }
            //}

            if (round > -1)
            {
                maxDemand = Math.Round(maxDemand, round);
            }

            return(maxDemand);
        }
示例#3
0
        public static object To_DynamoMeshData(sSystem sghSystem, double colorThreshold = 0.0, double deformation = 0.0)
        {
            List <List <Dyn.Point> > vertice    = null;
            List <List <int> >       faceIndice = null;
            List <List <int> >       Rs         = null;
            List <List <int> >       Gs         = null;
            List <List <int> >       Bs         = null;

            if (sghSystem != null)
            {
                sDynamoConverter dyncon = new sDynamoConverter();

                sRange th = null;
                if (colorThreshold > 0.0)
                {
                    th = new sRange(0.0, colorThreshold);
                }
                dyncon.ToDynamoToolKitMeshData(sghSystem, eColorMode.Stress_Combined_Absolute, out vertice, out faceIndice, out Rs, out Gs, out Bs, deformation, th);
            }

            return(new Dictionary <string, object>
            {
                { "vertice", vertice },
                { "indice", faceIndice },
                { "R", Rs },
                { "G", Gs },
                { "B", Bs }
            });
        }
示例#4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            ISystem sghSystem = null;
            double  du        = 0.0;
            double  the       = -1.0;

            if (!DA.GetData(0, ref sghSystem))
            {
                return;
            }
            if (!DA.GetData(1, ref du))
            {
                return;
            }
            if (!DA.GetData(2, ref the))
            {
                return;
            }

            Mesh   m   = new Mesh();
            string mss = "";

            string          modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString();
            sRhinoConverter rhcon     = new sRhinoConverter("Meters", modelUnit);

            if (sghSystem != null)
            {
                ISystem sys = sghSystem as ISystem;

                sRange th = null;
                if (the > 0.0)
                {
                    if (colMode.ToString().Contains("Stress"))
                    {
                        the *= 1.0E6;
                    }
                    th = new sRange(0.0, rhcon.EnsureUnit(the, colMode));
                }

                List <sMesh> mms = new List <sMesh>();
                sRange       resultRange;
                sys.ConstructBeamResultMesh(colMode, ref mms, out resultRange, th, du);
                mss += "Color Mode\n" + colMode.ToString();


                Interval reRangeRh = rhcon.EnsureUnit_DataRange(rhcon.ToRhinoInterval(resultRange), colMode, true); //true means Pa > MPa
                mss += "\nData Range: " + Math.Round(reRangeRh.Min, 2) + " to " + Math.Round(reRangeRh.Max, 2);

                foreach (sMesh sm in mms)
                {
                    Mesh rm = rhcon.ToRhinoMesh(sm);
                    m.Append(rhcon.EnsureUnit(rm) as Mesh);
                }
            }
            this.Message = mss;

            DA.SetData(0, m);
        }
示例#5
0
        private string [] GetSystemMesh(IsSystem sys, eAreaResultType resultType, string caseName, double threshold)
        {
            sSEScenario sc = new sSEScenario();

            sc.areaThreshold = threshold;
            sc.areaType      = resultType;
            sc.loadCase      = caseName;
            sBoundingBox bx;

            string json = sys.ConstructSystemPreviewMesh(sc, false, out bx).Jsonify(true);

            sRange dataRange = sys.GetAreaResultRange(caseName, resultType);
            string min       = dataRange.min.ToString();
            string max       = dataRange.max.ToString();

            string[] data = new string[3] {
                min, max, json
            };

            return(data);
        }
        public sRange GetSystemBeamResultRange(eColorMode colorMode)
        {
            double minV = double.MaxValue;
            double maxV = double.MinValue;

            foreach (IFrameSet bs in this.frameSets)
            {
                foreach (sFrame b in bs.frames)
                {
                    sRange bRange = b.GetBeamResultRange(colorMode);
                    if (bRange.min < minV)
                    {
                        minV = bRange.min;
                    }
                    if (bRange.max > maxV)
                    {
                        maxV = bRange.max;
                    }
                }
            }
            return(new sRange(minV, maxV));
        }
示例#7
0
        internal void ToDynamoToolKitMeshData(sSystem ssys, eColorMode colorMode, out List <List <Dyn.Point> > vpts, out List <List <int> > findice, out List <List <int> > colorsR, out List <List <int> > colorsG, out List <List <int> > colorsB, double du = 0.0, sRange th = null)
        {
            List <sMesh> sms = new List <sMesh>();
            sRange       dataRange;

            ssys.ConstructBeamResultMesh(colorMode, ref sms, out dataRange, th, du);

            List <List <Dyn.Point> > ppp = new List <List <Dyn.Point> >();
            List <List <int> >       iii = new List <List <int> >();
            List <List <int> >       rrr = new List <List <int> >();
            List <List <int> >       ggg = new List <List <int> >();
            List <List <int> >       bbb = new List <List <int> >();

            foreach (sMesh sm in sms)
            {
                List <int>       ii = new List <int>();
                List <int>       rr = new List <int>();
                List <int>       gg = new List <int>();
                List <int>       bb = new List <int>();
                List <Dyn.Point> pp = new List <Autodesk.DesignScript.Geometry.Point>();

                ToDynamoToolKitMeshData(sm, ref pp, ref ii, ref rr, ref gg, ref bb);

                ppp.Add(pp);
                iii.Add(ii);
                rrr.Add(rr);
                ggg.Add(gg);
                bbb.Add(bb);
            }
            vpts    = ppp;
            findice = iii;
            colorsR = rrr;
            colorsG = ggg;
            colorsB = bbb;
        }
示例#8
0
        internal List <Dyn.Mesh> ToDynamoMesh(sSystem ssys, eColorMode colorMode, out List <List <Color> > verticeColor, double du = 0.0, sRange th = null)
        {
            List <sMesh> sms = new List <sMesh>();
            sRange       dataRange;

            ssys.ConstructBeamResultMesh(colorMode, ref sms, out dataRange, th, du);

            List <List <Color> > allcols = new List <List <Color> >();
            List <Dyn.Mesh>      dms     = new List <Autodesk.DesignScript.Geometry.Mesh>();

            foreach (sMesh sm in sms)
            {
                List <Color> cols;
                dms.Add(ToDynamoMesh(sm, out cols));
                allcols.Add(cols);
            }
            verticeColor = allcols;
            return(dms);
        }
 public Interval ToRhinoInterval(sRange sran)
 {
     return(new Interval(sran.min, sran.max));
 }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            sFrame sb = null;

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

            string          modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString();
            sRhinoConverter rhcon     = new sRhinoConverter("Meters", modelUnit);

            this.Message = "Beam Result\n" + colMode.ToString();

            sRange ran = sb.GetBeamResultRange(colMode);

            Point3d  cp = rhcon.EnsureUnit(rhcon.ToRhinoPoint3d(sb.axis.PointAt(0.5)));
            Vector3d x  = rhcon.ToRhinoVector3d(sb.localPlane.Xaxis);
            Vector3d y  = rhcon.ToRhinoVector3d(sb.localPlane.Yaxis);

            Plane pl = new Plane(cp, x, -y);


            double max  = 0.0;
            double min  = 0.0;
            string unit = "";

            if (colMode == eColorMode.Deflection)
            {
                max = rhcon.EnsureUnit_Deflection(ran.max);
                min = rhcon.EnsureUnit_Deflection(ran.min);
                if (modelUnit == "Meters")
                {
                    unit = "mm";
                }
                else if (modelUnit == "Feet")
                {
                    unit = "in";
                }
            }
            else if (colMode.ToString().Contains("Stress"))
            {
                max = rhcon.EnsureUnit_Stress(ran.max);
                min = rhcon.EnsureUnit_Stress(ran.min);
                if (modelUnit == "Meters")
                {
                    max *= 1.0E-6;
                    min *= 1.0E-6;
                    unit = "MPa";
                }
                else if (modelUnit == "Feet")
                {
                    unit = "ksi";
                }
            }
            else if (colMode.ToString().Contains("Force"))
            {
                max = rhcon.EnsureUnit_Force(ran.max);
                min = rhcon.EnsureUnit_Force(ran.min);
                if (modelUnit == "Meters")
                {
                    unit = "N";
                }
                else if (modelUnit == "Feet")
                {
                    unit = "lbf";
                }
            }
            else if (colMode.ToString().Contains("Moment"))
            {
                max = rhcon.EnsureUnit_Moment(ran.max);
                min = rhcon.EnsureUnit_Moment(ran.min);
                if (modelUnit == "Meters")
                {
                    unit = "N.m";
                }
                else if (modelUnit == "Feet")
                {
                    unit = "lbf.ft";
                }
            }

            DA.SetData(0, pl);
            DA.SetData(1, "(" + Math.Round(min, 2) + ") - (" + Math.Round(max, 2) + ") " + unit);
            DA.SetData(2, max);
            DA.SetData(3, min);
        }
示例#11
0
        public sRange GetFrameSetResultRange(eColorMode colMode)
        {
            ///
            // Deflection_Local is Z only??????????????
            ///
            sRange ran = new sRange();

            if (colMode == eColorMode.Deflection_Local)
            {
                ran.min = 0.0;
                ran.max = this.results_Max.deflectionLocalMax_Abs_mm.Z;
            }
            else if (colMode == eColorMode.Deflection)
            {
                ran.min = 0.0;
                ran.max = this.results_Max.deflectionMax_Abs_mm.GetLength();
            }
            else if (colMode == eColorMode.Force_X)
            {
                ran.min = this.results_Max.forceMax_Negative.X;
                ran.max = this.results_Max.forceMax_Positive.X;
            }
            else if (colMode == eColorMode.Force_Y)
            {
                ran.min = this.results_Max.forceMax_Negative.Y;
                ran.max = this.results_Max.forceMax_Positive.Y;
            }
            else if (colMode == eColorMode.Force_Z)
            {
                ran.min = this.results_Max.forceMax_Negative.Z;
                ran.max = this.results_Max.forceMax_Positive.Z;
            }
            else if (colMode == eColorMode.Moment_X)
            {
                ran.min = this.results_Max.momentMax_Negative.X;
                ran.max = this.results_Max.momentMax_Positive.X;
            }
            else if (colMode == eColorMode.Moment_Y)
            {
                ran.min = this.results_Max.momentMax_Negative.Y;
                ran.max = this.results_Max.momentMax_Positive.Y;
            }
            else if (colMode == eColorMode.Moment_Z)
            {
                ran.min = this.results_Max.momentMax_Negative.Z;
                ran.max = this.results_Max.momentMax_Positive.Z;
            }
            else if (colMode == eColorMode.Stress_Combined_Absolute)
            {
                ran.min = 0.0;
                ran.max = this.results_Max.stressCombinedAbs;
            }
            else
            {
                throw new NotImplementedException();
            }

            if (ran.min == double.MaxValue)
            {
                ran.min = 0.0;
            }
            if (ran.max == double.MinValue)
            {
                ran.max = 0.0;
            }

            return(ran);
        }
示例#12
0
        public sColor GetBeamResultColor(sRange dataRange, eColorMode colorMode, int resultIndex, int sectionIndex, int alpha, sRange threshold = null)
        {
            sColor         col = new sColor();
            sColorGradient cg  = null;

            if (colorMode == eColorMode.Force_X)
            {
                double valThis = this.results[resultIndex].force.X;
                cg = sColorGradient.GetCyanRedGradient(dataRange, threshold);
                double remapped = dataRange.GetOriginBasedNormalizedAt(valThis);
                col = cg.ColorAt(remapped);
            }
            else if (colorMode == eColorMode.Force_Y)
            {
                double valThis = this.results[resultIndex].force.Y;
                cg = sColorGradient.GetCyanRedGradient(dataRange, threshold);
                double remapped = dataRange.GetOriginBasedNormalizedAt(valThis);
                col = cg.ColorAt(remapped);
            }
            else if (colorMode == eColorMode.Force_Z)
            {
                double valThis = this.results[resultIndex].force.Z;
                cg = sColorGradient.GetCyanRedGradient(dataRange, threshold);
                double remapped = dataRange.GetOriginBasedNormalizedAt(valThis);
                col = cg.ColorAt(remapped);
            }
            else if (colorMode == eColorMode.Moment_X)
            {
                double valThis = this.results[resultIndex].moment.X;
                cg = sColorGradient.GetCyanRedGradient(dataRange, threshold);
                double remapped = dataRange.GetOriginBasedNormalizedAt(valThis);
                col = cg.ColorAt(remapped);
            }
            else if (colorMode == eColorMode.Moment_Y)
            {
                double valThis = this.results[resultIndex].moment.Y;
                cg = sColorGradient.GetCyanRedGradient(dataRange, threshold);
                double remapped = dataRange.GetOriginBasedNormalizedAt(valThis);
                col = cg.ColorAt(remapped);
            }
            else if (colorMode == eColorMode.Moment_Z)
            {
                double valThis = this.results[resultIndex].moment.Z;
                cg = sColorGradient.GetCyanRedGradient(dataRange, threshold);
                double remapped = dataRange.GetOriginBasedNormalizedAt(valThis);
                col = cg.ColorAt(remapped);
            }
            else if (colorMode == eColorMode.Stress_Combined_Absolute)
            {
                double valThis = this.results[resultIndex].sectionResults[sectionIndex].stress_Combined;
                cg = sColorGradient.GetRainbowLikeGradient(dataRange, threshold);
                double remapped = dataRange.GetNormalizedAt(valThis);//dataRange.GetOriginBasedNormalizedAt(valThis);

                col = cg.ColorAt(remapped);
            }
            else if (colorMode == eColorMode.Stress_Axial_X)
            {
            }
            else if (colorMode == eColorMode.Stress_Moment_Y)
            {
                double valThis = this.results[resultIndex].sectionResults[sectionIndex].stress_Moment_Y;
                cg = sColorGradient.GetCyanRedGradient(dataRange, threshold);
                double remapped = dataRange.GetOriginBasedNormalizedAt(valThis);
                //double remapped = dataRange.GetNormalizedAt(valThis);
                col = cg.ColorAt(remapped);
            }
            else if (colorMode == eColorMode.Stress_Moment_Z)
            {
                double valThis = this.results[resultIndex].sectionResults[sectionIndex].stress_Moment_Z;
                cg = sColorGradient.GetCyanRedGradient(dataRange, threshold);
                double remapped = dataRange.GetOriginBasedNormalizedAt(valThis);
                //double remapped = dataRange.GetNormalizedAt(valThis);
                col = cg.ColorAt(remapped);
            }
            else if (colorMode == eColorMode.Deflection)
            {
                double valThis = this.results[resultIndex].sectionResults[sectionIndex].deflection_mm.GetLength();
                cg = sColorGradient.GetRainbowLikeGradient(dataRange, threshold);
                double remapped = dataRange.GetNormalizedAt(valThis);//dataRange.GetOriginBasedNormalizedAt(valThis);

                col = cg.ColorAt(remapped);
            }
            else if (colorMode == eColorMode.NONE)
            {
                col = new sColor(200, 200, 200);
            }
            return(col);
        }
示例#13
0
        public sRange GetBeamResultRange(eColorMode colorMode)
        {
            double minV = double.MaxValue;
            double maxV = double.MinValue;

            foreach (sFrameResult br in this.results)
            {
                if (colorMode == eColorMode.Force_X)
                {
                    if (br.force.X < minV)
                    {
                        minV = br.force.X;
                    }
                    if (br.force.X > maxV)
                    {
                        maxV = br.force.X;
                    }
                }
                else if (colorMode == eColorMode.Force_Y)
                {
                    if (br.force.Y < minV)
                    {
                        minV = br.force.Y;
                    }
                    if (br.force.Y > maxV)
                    {
                        maxV = br.force.Y;
                    }
                }
                else if (colorMode == eColorMode.Force_Z)
                {
                    if (br.force.Z < minV)
                    {
                        minV = br.force.Z;
                    }
                    if (br.force.Z > maxV)
                    {
                        maxV = br.force.Z;
                    }
                }
                else if (colorMode == eColorMode.Moment_X)
                {
                    if (br.moment.X < minV)
                    {
                        minV = br.moment.X;
                    }
                    if (br.moment.X > maxV)
                    {
                        maxV = br.moment.X;
                    }
                }
                else if (colorMode == eColorMode.Moment_Y)
                {
                    if (br.moment.Y < minV)
                    {
                        minV = br.moment.Y;
                    }
                    if (br.moment.Y > maxV)
                    {
                        maxV = br.moment.Y;
                    }
                }
                else if (colorMode == eColorMode.Moment_Z)
                {
                    if (br.moment.Z < minV)
                    {
                        minV = br.moment.Z;
                    }
                    if (br.moment.Z > maxV)
                    {
                        maxV = br.moment.Z;
                    }
                }
                else if (colorMode == eColorMode.Stress_Combined_Absolute)
                {
                    foreach (sFrameSectionResult secRe in br.sectionResults)
                    {
                        double absStress = Math.Abs(secRe.stress_Combined);
                        if (absStress < minV)
                        {
                            minV = absStress;
                        }
                        if (absStress > maxV)
                        {
                            maxV = absStress;
                        }
                    }
                }
                else if (colorMode == eColorMode.Stress_Axial_X)
                {
                    foreach (sFrameSectionResult secRe in br.sectionResults)
                    {
                        if (secRe.stress_Axial_X < minV)
                        {
                            minV = secRe.stress_Axial_X;
                        }
                        if (secRe.stress_Axial_X > maxV)
                        {
                            maxV = secRe.stress_Axial_X;
                        }
                    }
                }
                else if (colorMode == eColorMode.Stress_Moment_Y)
                {
                    foreach (sFrameSectionResult secRe in br.sectionResults)
                    {
                        if (secRe.stress_Moment_Y < minV)
                        {
                            minV = secRe.stress_Moment_Y;
                        }
                        if (secRe.stress_Moment_Y > maxV)
                        {
                            maxV = secRe.stress_Moment_Y;
                        }
                    }
                }
                else if (colorMode == eColorMode.Stress_Moment_Z)
                {
                    foreach (sFrameSectionResult secRe in br.sectionResults)
                    {
                        if (secRe.stress_Moment_Z < minV)
                        {
                            minV = secRe.stress_Moment_Z;
                        }
                        if (secRe.stress_Moment_Z > maxV)
                        {
                            maxV = secRe.stress_Moment_Z;
                        }
                    }
                }
                else if (colorMode == eColorMode.Deflection)
                {
                    foreach (sFrameSectionResult secRe in br.sectionResults)
                    {
                        double def = secRe.deflection_mm.GetLength();
                        if (secRe.stress_Moment_Z < minV)
                        {
                            minV = def;
                        }
                        if (secRe.stress_Moment_Z > maxV)
                        {
                            maxV = def;
                        }
                    }
                }
            }
            sRange ran = new sRange(minV, maxV);

            return(ran);
        }
示例#14
0
        public sMesh ConstructBeamColorMesh(sRange dataRange, eColorMode colorMode, sRange threshold, double du)
        {
            sMesh sm = new sMesh();

            int vertexID = 0;

            for (int i = 0; i < this.results.Count; ++i)
            {
                sFrameResult br = this.results[i];

                for (int j = 0; j < br.sectionResults.Count; ++j)
                {
                    sFrameSectionResult sr = br.sectionResults[j];
                    sColor vcol            = this.GetBeamResultColor(dataRange, colorMode, i, j, 255, threshold);
                    sXYZ   deflectionVec   = du * (sr.deflection_mm * 0.001);
                    sXYZ   deflectedPt     = sr.location + deflectionVec;
                    sm.SetVertex(vertexID, deflectedPt, vcol);
                    //or
                    //sm.SetVertex(vertexID, sr.point, vcol);

                    sr.ID = vertexID;

                    vertexID++;
                }
            }

            int vertexCountPerFace = this.results[0].sectionResults.Count;
            int faceIndex          = 0;

            for (int i = 0; i < this.results.Count - 1; ++i)
            {
                sFrameResult br_this = this.results[i];
                sFrameResult br_next = this.results[i + 1];

                for (int j = 0; j < br_this.sectionResults.Count; ++j)
                {
                    int id0 = 0;
                    int id1 = 0;
                    int id2 = 0;
                    int id3 = 0;
                    if (j < br_this.sectionResults.Count - 1)
                    {
                        id0 = br_this.sectionResults[j].ID;
                        id1 = br_next.sectionResults[j].ID;
                        id2 = br_next.sectionResults[j + 1].ID;
                        id3 = br_this.sectionResults[j + 1].ID;
                    }
                    else
                    {
                        id0 = br_this.sectionResults[j].ID;
                        id1 = br_next.sectionResults[j].ID;
                        id2 = br_next.sectionResults[0].ID;
                        id3 = br_this.sectionResults[0].ID;
                    }

                    sm.SetFace(faceIndex, faceIndex + 1, id0, id1, id2, id3);
                    faceIndex += 2;
                }
            }

            sm.ComputeNormals();
            return(sm);
        }