public Vector3[] GetCurve(LineElement l, AbstractCase ac, int numPoints, float deformationScale, float paintScaleFactorTranslation, out float[] xPos)
        {
            if (l == null)
            {
                xPos = null;
                return null;
            }

            Vector3 iPos, jPos;
            iPos = new Vector3(model.Results.JointDisplacements[l.I.Id, 0],
                             model.Results.JointDisplacements[l.I.Id, 1],
                             model.Results.JointDisplacements[l.I.Id, 2]);
            iPos = deformationScale * paintScaleFactorTranslation * iPos + l.I.Position;

            jPos = new Vector3(model.Results.JointDisplacements[l.J.Id, 0],
                             model.Results.JointDisplacements[l.J.Id, 1],
                             model.Results.JointDisplacements[l.J.Id, 2]);
            jPos = deformationScale * paintScaleFactorTranslation * jPos + l.J.Position;

            float[,] local2Values = GetCurvedAxis(l, model.Results.ActiveCase.AbstractCase, Analysis.LineDeformationCalculator.DeformationAxis.Local2, numPoints);
            float[,] local3Values = GetCurvedAxis(l, model.Results.ActiveCase.AbstractCase, Analysis.LineDeformationCalculator.DeformationAxis.Local3, numPoints);

            int nVertices = local2Values.GetLength(0);
            Vector3[] curve = new Vector3[nVertices];
            xPos = new float[nVertices];
            for (int i = 0; i < nVertices; i++)
            {
                xPos[i] = local2Values[i, 0];
                curve[i] = iPos + local2Values[i, 0] * (jPos - iPos) +
                    local2Values[i, 1] * deformationScale * paintScaleFactorTranslation * l.LocalAxes[1] +
                    local3Values[i, 1] * deformationScale * paintScaleFactorTranslation * l.LocalAxes[2];
            }

            return curve;
        }
Ejemplo n.º 2
0
        // Get Load direction in Local Coordinate frame
        protected Vector3 getLocalDir(LineElement line, LineLoad.LoadDirection direction)
        {
            Vector3 dir = Vector3.Empty;
            switch (direction)
            {
                case LineLoad.LoadDirection.GlobalX:
                    dir = toLocal(line, CommonAxes.GlobalAxes[0]);
                    break;
                case LineLoad.LoadDirection.GlobalY:
                    dir = toLocal(line, CommonAxes.GlobalAxes[1]);
                    break;
                case LineLoad.LoadDirection.GlobalZ:
                    dir = toLocal(line, CommonAxes.GlobalAxes[2]);
                    break;
                case LineLoad.LoadDirection.Gravity:
                    dir = Vector3.Scale(toLocal(line, CommonAxes.GlobalAxes[2]), -1);
                    break;
                case LineLoad.LoadDirection.Local1:
                    dir = CommonAxes.GlobalAxes[0];
                    break;
                case LineLoad.LoadDirection.Local2:
                    dir = CommonAxes.GlobalAxes[1];
                    break;
                case LineLoad.LoadDirection.Local3:
                    dir = CommonAxes.GlobalAxes[2];
                    break;
                default:
                    break;
            }

            return dir;
        }
        public float[,] GetCurvedAxis(LineElement l, AbstractCase ac, DeformationAxis component, int numPoints)
        {
            if (!model.HasResults) return null;

            /// controlPoints[i, 0]: x position on Beam, controlPoints[i, 1]: 'deflection' for x position, controlPoints[i,2]: deformation angle
            float[,] controlPoints = new float[numPoints, 3];

            float[] controlPointsX = new float[1]; // requestXCtrlPts(load);
            for (int i = 0, bufi = 0; i < numPoints; i++)
            {
                controlPoints[i, 0] = i / (numPoints - 1f);

                // Adjust control points
                if ((bufi < controlPointsX.Length) && (controlPointsX[bufi] <= controlPoints[i, 0]))
                    controlPoints[i, 0] = controlPointsX[bufi++];

                controlPoints[i, 1] = 0f; // controlPoints[i, 0] * (fdJ - fdI);

                controlPoints[i, 2] = 0.0f;
            }

            getCurvedAxis(l, ac, component, controlPoints);

            return controlPoints;
        }
Ejemplo n.º 4
0
        protected Vector3 toLocal(LineElement line, Vector3 v)
        {
            Matrix r;

            line.RotationMatrix(out r);
            return Vector3.TransformCoordinate(v, Matrix.TransposeMatrix(r));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Executes the command. 
        /// Creates a series of connected Line Elements given at least 2 points. Each subsequent point given adds a new Line Element.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            LineElement line;
            Joint joint1, joint2;
            LineProps props = new StraightFrameProps();
            List<LineElement> newLines = new List<LineElement>();
            List<AreaElement> newAreas = new List<AreaElement>();

            services.GetProperties(Culture.Get("addLineProps"), props);

            joint1 = services.GetJoint(newLines);
            services.TrackingService = LineTrackingService.Instance;
            services.TrackingService.SetPoint(joint1.Position);

            try
            {
                while ((joint2 = services.GetJoint(newLines)) != null)
                {
                    if (joint2 != joint1)
                    {
                        services.Model.LineList.Add(line = new LineElement(props, joint1, joint2));
                        newLines.Add(line);
                        joint1 = joint2;
                        services.TrackingService.SetPoint(joint1.Position);
                        // Para que se refleje el cambio inmediatamente
                        services.Model.ChangeModel();
                    }
                }
            }
            catch (Canguro.Controller.CancelCommandException) { }
            if (newLines.Count == 0)
                services.Model.Undo.Rollback();
            else
                JoinCmd.Join(services.Model, new List<Joint>(), newLines, newAreas);
        }
Ejemplo n.º 6
0
        private static float cosAngle(LineElement l1, LineElement l2)
        {
            bool negative = (l1.I.Id == l2.I.Id || l1.J.Id == l2.J.Id);
            Vector3 v1 = l1.I.Position - l1.J.Position;
            Vector3 v2 = l2.I.Position - l2.J.Position;
            v1.Normalize();
            v2.Normalize();

            return (negative) ? -Vector3.Dot(v1, v2) : Vector3.Dot(v1, v2);
        }
        public void getForcesDiagram(AbstractCase ac, LineElement line, LineForceComponent component, float[,] controlPoints, out float fI, out float fJ)
        {
            Vector3 vI, vJ;
            switch (component)
            {
                case LineForceComponent.Axial:
                case LineForceComponent.Shear22:
                case LineForceComponent.Shear33:
                    vI = new Vector3(model.Results.ElementJointForces[line.Id, 0, 0],
                                     model.Results.ElementJointForces[line.Id, 0, 1],
                                     model.Results.ElementJointForces[line.Id, 0, 2]);
                    vJ = new Vector3(model.Results.ElementJointForces[line.Id, 1, 0],
                                     model.Results.ElementJointForces[line.Id, 1, 1],
                                     model.Results.ElementJointForces[line.Id, 1, 2]);
                    break;
                default:
                    vI = new Vector3(model.Results.ElementJointForces[line.Id, 0, 3],
                                     model.Results.ElementJointForces[line.Id, 0, 4],
                                     model.Results.ElementJointForces[line.Id, 0, 5]);
                    vJ = new Vector3(model.Results.ElementJointForces[line.Id, 1, 3],
                                     model.Results.ElementJointForces[line.Id, 1, 4],
                                     model.Results.ElementJointForces[line.Id, 1, 5]);
                    break;
            }

            // Transform to the line's local coordinate system
            // From the global system
            // (WARNING: This is supposed to come in the joint's local coordinate system)
            vI = toLocal(line, vI);
            vJ = toLocal(line, vJ);

            switch (component)
            {
                case LineForceComponent.Axial:
                case LineForceComponent.Torsion:
                    fI = vI.X;
                    fJ = vJ.X;
                    break;
                case LineForceComponent.Shear22:
                case LineForceComponent.Moment22:
                    fI = vI.Y;
                    fJ = vJ.Y;
                    break;
                default:
                    fI = vI.Z;
                    fJ = vJ.Z;
                    break;
            }

            //float fI = model.Results.ElementJointForces[line.Id, 0, (int)component];
            //float fJ = model.Results.ElementJointForces[line.Id, 1, (int)component];

            // Add Isostatic curves if there's a load on the LineElement
            addToShearMomentDiagram(ac, line, controlPoints, component, 1f);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Constructora de copia que inicializa el LineElement como un clon de otro.
 /// </summary>
 /// <param name="src">El LineElement a copiar</param>
 internal LineElement(LineElement src, Joint i, Joint j) : base(src)
 {
     props = (LineProps)src.Properties.Clone();
     joints = new Joint[2];
     angle = src.Angle;
     cardinalPoint = src.CardinalPoint;
     offsets = src.EndOffsets;
     dofI = src.DoFI;
     dofJ = src.DoFJ;
     joints[0] = i;
     joints[1] = j;
 }
Ejemplo n.º 9
0
        public static Joint Intersect(Canguro.Model.Model model, LineElement l1, LineElement l2)
        {
            if (l1 != null && l2 != null && l1 != l2 && l1.I != l2.I && l1.J != l2.J && l1.I != l2.J && l1.J != l2.I)
            {
                float numer, denom;
                float d1, d2, d3, d4, d5;
                Vector3 p13 = l1.I.Position - l2.I.Position;
                Vector3 p21 = l1.J.Position - l1.I.Position;
                Vector3 p43 = l2.J.Position - l2.I.Position;

                d1 = p13.X * p43.X + p13.Y * p43.Y + p13.Z * p43.Z;
                d2 = p43.X * p21.X + p43.Y * p21.Y + p43.Z * p21.Z;
                d3 = p13.X * p21.X + p13.Y * p21.Y + p13.Z * p21.Z;
                d4 = p43.X * p43.X + p43.Y * p43.Y + p43.Z * p43.Z;
                d5 = p21.X * p21.X + p21.Y * p21.Y + p21.Z * p21.Z;

                denom = d5 * d4 - d2 * d2;
                if (Math.Abs(denom) < 0.0001)
                    return null;
                numer = d1 * d2 - d3 * d4;

                float r = numer / denom;
                float s = (d1 + d2 * r) / d4;

                float scale = model.UnitSystem.FromInternational(1, Canguro.Model.UnitSystem.Units.Distance);
                Vector3 pa = Vector3.Scale(l1.I.Position, scale) + Vector3.Scale(p21, r * scale);
                Vector3 pb = Vector3.Scale(l2.I.Position, scale) + Vector3.Scale(p43, s * scale);

                if (r > (-0.001) && r < 1.001 && s > (-0.001) && s < 1.001 && (pa - pb).Length() < 0.001 &&
                    ((pa - l1.I.Position).LengthSq() > 0.000001f) && ((pa - l1.J.Position).LengthSq() > 0.000001f) &&
                    ((pa - l2.I.Position).LengthSq() > 0.000001f) && ((pa - l2.J.Position).LengthSq() > 0.000001f))
                {
                    Joint joint = new Joint(pa.X, pa.Y, pa.Z);
                    model.JointList.Add(joint);
                    return joint;
                    //SplitCmd.Split(l1, joint, model);
                    //SplitCmd.Split(l2, joint, model);
                }
                //// Create magnet
                //PointMagnet intPtMagnet = new PointMagnet(l1.Position + Vector3.Scale(l1.Direction, r),
                //    PointMagnetType.Intersection);
                //if (intPtMagnet.Snap(activeView, e.Location) < SnapViewDistance)
                //{
                //    intPtMagnet.RelatedMagnets.Add(l1);
                //    intPtMagnet.RelatedMagnets.Add(l2);
                //    return intPtMagnet;
                //}
            }

            return null;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Calculates the intersection of the given Joint and LineElement and returns the 
        /// float value corresponding to the proportion of the vector from defined by the line Joints.
        /// </summary>
        /// <param name="line">The LineElement to intersect</param>
        /// <param name="joint">The Joint to intersect with line</param>
        /// <returns>A float in [0, 1). If the joint is in the line, the proportion, 0 otherwise.</returns>
        public static float getIntersection(LineElement line, Joint joint)
        {
            Microsoft.DirectX.Vector3 i = line.I.Position;
            Microsoft.DirectX.Vector3 j = line.J.Position;
            Microsoft.DirectX.Vector3 pos = joint.Position;
            float ret, retx, rety, retz;
            float eps = 0.001f;

            //retx = (j.X != i.X) ? (pos.X - i.X) / (j.X - i.X) : (equals(pos.X, i.X, eps)) ? float.NaN : 0;
            //rety = (j.Y != i.Y) ? (pos.Y - i.Y) / (j.Y - i.Y) : (equals(pos.Y, i.Y, eps)) ? retx : 0;
            //retz = (j.Z != i.Z) ? (pos.Z - i.Z) / (j.Z - i.Z) : (equals(pos.Z, i.Z, eps)) ? rety : 0;
            //rety = (!float.IsNaN(rety)) ? rety : retz;
            //retx = (!float.IsNaN(retx)) ? retx : rety;

            //return (equals(retx, rety, eps) && equals(rety, retz, eps) && retx - eps > 0 && retx + eps < 1) ? retx : 0;

            Microsoft.DirectX.Vector3 xmp = joint.Position - line.I.Position;
            Microsoft.DirectX.Vector3 dir = line.J.Position - line.I.Position;

            ret = (Math.Abs(xmp.X) > Math.Abs(xmp.Y)) ? ((Math.Abs(xmp.X) > Math.Abs(xmp.Z)) ? xmp.X / dir.X : xmp.Z / dir.Z) : ((Math.Abs(xmp.Y) > Math.Abs(xmp.Z)) ? xmp.Y / dir.Y : xmp.Z / dir.Z);
            return (equals(ret * dir.X, xmp.X, eps) && equals(ret * dir.Y, xmp.Y, eps) && equals(ret * dir.Z, xmp.Z, eps)) ? ret : 0;
        }
        public float[] GetForceAtPoint(AbstractCase ac, LineElement line, LineForceComponent component, float xPos)
        {
            if (!model.HasResults) return null;

            float[,] controlPoints = new float[1, 2];
            controlPoints[0, 0] = xPos;
            controlPoints[0, 1] = 0f;

            float fI, fJ;
            getForcesDiagram(ac, line, component, controlPoints, out fI, out fJ);

            // Los valores en los nodos se encuentran volteados. Del lado izquierdo positivo
            // es arriba, mientras del lado derecho positivo es abajo, por lo que si se tienen
            // dos valores positivos se debería pintar una recta con pendiente negativa y si
            // se tienen dos negativos al revés. DeltaY = Y1 + Y2 (por el cambio de signo).
            controlPoints[0, 1] += controlPoints[0, 0] * (fI + fJ) - fI;

            // Copy to 1-dimensional array
            float[] ret = new float[2];
            for (int i = 0; i < 2; i++)
                ret[i] = controlPoints[0, i];

            return ret;
        }
Ejemplo n.º 12
0
 private void writeConcreteBeamAssigments(XmlTextWriter xml, LineElement obj)
 {
     LineProps props = obj.Properties;
     List<Section> exported = new List<Section>();
     if (props is StraightFrameProps) {
         FrameSection sec = ((StraightFrameProps)props).Section;
         ConcreteSectionProps concrete = sec.ConcreteProperties;
         if (concrete != null && !exported.Contains(sec) && sec.ConcreteProperties is ConcreteBeamSectionProps) {
             string mat = MaterialManager.Instance.DefaultSteel.Name;
             ConcreteBeamSectionProps concreteBeam = (ConcreteBeamSectionProps)concrete;
             xml.WriteStartElement("SectionName");
             xml.WriteAttributeString("SectionName", sec.Name);
             xml.WriteAttributeString("RebarMatL", mat);
             xml.WriteAttributeString("RebarMatC", mat);
             xml.WriteAttributeString("TopCover", concreteBeam.ConcreteCoverTop.ToString());
             xml.WriteAttributeString("BotCover", concreteBeam.ConcreteCoverBottom.ToString());
             xml.WriteAttributeString("TopLeftArea", concreteBeam.RoTopLeft.ToString());
             xml.WriteAttributeString("TopRghtArea", concreteBeam.RoTopRight.ToString());
             xml.WriteAttributeString("BotLeftArea", concreteBeam.RoBottomLeft.ToString());
             xml.WriteAttributeString("BotRghtArea", concreteBeam.RoBottomRight.ToString());
             xml.WriteEndElement();
         }
     }
 }
Ejemplo n.º 13
0
        private void writeReleaseAssignments(XmlTextWriter xml, LineElement obj)
        {
            JointDOF dofi = obj.DoFI;
            JointDOF dofj = obj.DoFJ;

            if(dofi.IsFree || dofj.IsFree || dofi.IsSpring || dofj.IsSpring){
                xml.WriteStartElement("Frame");
                xml.WriteAttributeString("Frame", obj.Id.ToString());
                xml.WriteAttributeString("PI",(dofi.T1 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("V2I", (dofi.T2 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("V3I", (dofi.T3 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("TI", (dofi.R1 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("M2I", (dofi.R2 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("M3I", (dofi.R3 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("PJ", (dofj.T1 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("V2J", (dofj.T2 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("V3J", (dofj.T3 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("TJ", (dofj.R1 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("M2J", (dofj.R2 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("M3J", (dofj.R3 != JointDOF.DofType.Restrained) ? "Yes" : "No");
                xml.WriteAttributeString("PartialFix",(dofi.IsSpring || dofj.IsSpring) ? "Yes" : "No");
                xml.WriteEndElement();
            }
        }
Ejemplo n.º 14
0
        private void writeSpringAssignments(XmlTextWriter xml, LineElement obj)
        {
            JointDOF dofi = obj.DoFI;
            JointDOF dofj = obj.DoFJ;
            string[] str = new string[] { "PI", "V2I", "V3I", "TI", "M2I", "M3I", "PJ", "V2J", "V3J", "TJ", "M2J", "M3J" };

            if(dofi.IsSpring || dofj.IsSpring){
                xml.WriteStartElement("Frame");
                float[] dofiValues = dofi.SpringValues;
                float[] dofjValues = dofj.SpringValues;

                xml.WriteAttributeString("Frame", obj.Id.ToString());

                for (int i = 0; i < 6; i++)
                    if (dofiValues[i] > 0)
                        xml.WriteAttributeString(str[i], dofiValues[i].ToString());

                for (int i = 0; i < 6; i++)
                    if (dofjValues[i] > 0)
                        xml.WriteAttributeString(str[i+6], dofjValues[i].ToString());

                 xml.WriteEndElement();
            }
        }
Ejemplo n.º 15
0
 private string getLineID(LineElement l, float xPos)
 {
     return xPos.ToString("F") + " x " +  Culture.Get("enterDataLine") + ":" + l.Id.ToString() + " (I: " + l.I.Id + ", J: " + l.J.Id + ")";
 }
Ejemplo n.º 16
0
        private string getLineForcesInfo(LineElement l, float xPos, RenderOptions.InternalForces iForces)
        {
            string force = units.UnitName(Canguro.Model.UnitSystem.Units.Force);
            string moment = units.UnitName(Canguro.Model.UnitSystem.Units.Moment);

            string unitStr = force;
            float[] diagram;
            string iForceName = string.Empty;
            int numPoints = Properties.Settings.Default.ElementForcesSegments;
            Model.Load.AbstractCase ac = model.Results.ActiveCase.AbstractCase;
            Model.Load.LineForceComponent component = Canguro.Model.Load.LineForceComponent.Axial;

            bool lastUndoEnabled = model.Undo.Enabled;
            bool lastUnitSystemEnabled = Model.UnitSystem.UnitSystemsManager.Instance.Enabled;

            try
            {
                if (model.IsLocked)
                    model.Undo.Enabled = false;

                Model.UnitSystem.UnitSystemsManager.Instance.Enabled = false;

                Analysis.LineStressCalculator calc = new Analysis.LineStressCalculator();

                // Shear forces
                switch (iForces)
                {
                    case RenderOptions.InternalForces.Sx:
                        component = Canguro.Model.Load.LineForceComponent.Axial;
                        iForceName = Culture.Get("Axial");
                        break;
                    case RenderOptions.InternalForces.Sy:
                        component = Canguro.Model.Load.LineForceComponent.Shear22;
                        iForceName = Culture.Get("Shear") + " 22";
                        break;
                    case RenderOptions.InternalForces.Sz:
                        component = Canguro.Model.Load.LineForceComponent.Shear33;
                        iForceName = Culture.Get("Shear") + " 33";
                        break;

                    // Moments
                    case RenderOptions.InternalForces.Mx:
                        component = Canguro.Model.Load.LineForceComponent.Torsion;
                        iForceName = Culture.Get("Torsion");
                        unitStr = moment;
                        break;
                    case RenderOptions.InternalForces.My:
                        component = Canguro.Model.Load.LineForceComponent.Moment22;
                        iForceName = Culture.Get("Moment") + " 22";
                        unitStr = moment;
                        break;
                    case RenderOptions.InternalForces.Mz:
                        component = Canguro.Model.Load.LineForceComponent.Moment33;
                        iForceName = Culture.Get("Moment") + " 33";
                        unitStr = moment;
                        break;
                }

                // Get Diagram
                diagram = calc.GetForceAtPoint(ac, l, component, xPos);
            }
            finally
            {
                Model.UnitSystem.UnitSystemsManager.Instance.Enabled = lastUnitSystemEnabled;
                model.Undo.Enabled = lastUndoEnabled;
            }

            return "\n" + iForceName + ": " + units.FromInternational(diagram[1], Canguro.Model.UnitSystem.Units.Force).ToString("G3") + unitStr;
        }
Ejemplo n.º 17
0
 private string getLineLayer(LineElement l)
 {
     return l.Layer.Name;
 }
Ejemplo n.º 18
0
 private void writeLineTemperatureLoads(XmlWriter xml, LineElement obj)
 {
     AssignedLoads loads = obj.Loads;
     if (loads != null)
     {
         Dictionary<string, LoadCase> cases = Canguro.Model.Model.Instance.LoadCases;
         foreach (LoadCase lCase in cases.Values)
         {
             ItemList<Canguro.Model.Load.Load> list = loads[lCase];
             if (list != null)
             {
                 foreach (Canguro.Model.Load.Load load in list)
                 {
                     if (load != null && load is TemperatureLineLoad)
                     {
                         xml.WriteStartElement("Frame");
                         xml.WriteAttributeString("Frame", obj.Id.ToString());
                         xml.WriteAttributeString("LoadCase", lCase.Name);
                         if (load is TemperatureGradientLineLoad)
                         {
                             if (((TemperatureGradientLineLoad)load).LoadType == TemperatureGradientLineLoad.GradientDirection.G33)
                             {
                                 xml.WriteAttributeString("Type", "Gradient3");
                                 xml.WriteAttributeString("TempGrad3", ((TemperatureGradientLineLoad)load).Temperature.ToString());
                             }
                             else
                             {
                                 xml.WriteAttributeString("Type", "Gradient2");
                                 xml.WriteAttributeString("TempGrad2", ((TemperatureGradientLineLoad)load).Temperature.ToString());
                             }
                         }
                         else
                         {
                             xml.WriteAttributeString("Type", "Temperature");
                             xml.WriteAttributeString("Temp", ((TemperatureLineLoad)load).Temperature.ToString());
                         }
                         xml.WriteAttributeString("JtPattern", "None");
                         xml.WriteEndElement();
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 19
0
 private void writeLinePointForces(XmlTextWriter xml, LineElement obj)
 {
     AssignedLoads loads = obj.Loads;
     if (loads != null) {
         Dictionary<string, LoadCase> cases = Canguro.Model.Model.Instance.LoadCases;
         foreach (LoadCase lCase in cases.Values) {
             ItemList<Canguro.Model.Load.Load> list = loads[lCase];
             if (list != null) {
                 foreach (Canguro.Model.Load.Load load in list) {
                     if (load != null) {
                         if (load is DirectionalLineLoad)
                         {
                             string dir = ((DirectionalLineLoad)load).Direction.ToString();
                             string dirFrame = "GLOBAL";
                             if (((DirectionalLineLoad)load).Direction != LineLoad.LoadDirection.Gravity)
                             {
                                 dirFrame = dir.Substring(0, dir.Length - 1).ToUpper();
                                 dir = dir.Substring(dir.Length - 1);
                             }
                             if (load is ConcentratedSpanLoad) {
                                 ConcentratedSpanLoad point = (ConcentratedSpanLoad)load;
                                 xml.WriteStartElement("Frame");
                                 xml.WriteAttributeString("Frame", obj.Id.ToString());
                                 xml.WriteAttributeString("LoadCase",lCase.Name );
                                 xml.WriteAttributeString("CoordSys", dirFrame);
                                 xml.WriteAttributeString("Type",point.Type.ToString());
                                 xml.WriteAttributeString("Dir", dir);
                                 xml.WriteAttributeString("DistType", "RelDist");
                                 xml.WriteAttributeString("RelDist",point.D.ToString());
                                 xml.WriteAttributeString("AbsDist","0");
                                 xml.WriteAttributeString("Force", point.LoadInt.ToString());
                                 xml.WriteEndElement();
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 20
0
        private void readLines(XmlNode node)
        {
            LineElement line = new LineElement(new StraightFrameProps());

            //Joint i = obj.I;
            //Joint j = obj.J;
            //// xml.WriteStartElement("Frame");
            uint id = uint.Parse(readAttribute(node, "Frame", "0"));
            int ji = int.Parse(readAttribute(node, "JointI", "0"));
            int jj = int.Parse(readAttribute(node, "JointJ", "0"));
            line.I = model.JointList[ji];
            line.J = model.JointList[jj];
            line.Id = id;
            model.LineList.Add(line);
            //readAttribute(node, "IsCurved", "No");
            //readAttribute(node, "Length", obj.Length.ToString());
            //readAttribute(node, "CentroidX", ((i.X + j.X) / 2.0F).ToString());
            //readAttribute(node, "CentroidY", ((i.Y + j.Y) / 2.0F).ToString());
            //readAttribute(node, "CentroidZ", ((i.Z + j.Z) / 2.0F).ToString());
        }
Ejemplo n.º 21
0
        private void writeConcreteColumnSectionProps(XmlTextWriter xml, LineElement obj)
        {
            LineProps props = obj.Properties;
            List<Section> exported = new List<Section>();
            if (props is StraightFrameProps) {
                FrameSection sec = ((StraightFrameProps)props).Section;
                ConcreteSectionProps concrete = sec.ConcreteProperties;
                if (concrete != null && !exported.Contains(sec) && sec.ConcreteProperties is ConcreteColumnSectionProps) {
                    ConcreteColumnSectionProps concreteColum = (ConcreteColumnSectionProps)concrete;
                    string mat = MaterialManager.Instance.DefaultSteel.Name;
                    string bars3, bars2, barsCirc;

                    if (sec is Rectangular) {
                        bars2 = concreteColum.NumberOfBars2Dir.ToString();
                        bars3 = concreteColum.NumberOfBars3Dir.ToString();
                        barsCirc = "0";
                    } else { //rounded
                        bars2 = "0";
                        bars3 = "0";
                        barsCirc = concreteColum.NumberOfBars.ToString();
                    }
                    string barsize = concreteColum.BarSize.ToString();

                    xml.WriteStartElement("SectionName");
                    xml.WriteAttributeString("SectionName", sec.Name);
                    xml.WriteAttributeString("RebarMatL", mat);
                    xml.WriteAttributeString("RebarMatC", mat);
                    xml.WriteAttributeString("ReinfConfig", concreteColum.RConfiguration.ToString());
                    xml.WriteAttributeString("LatReinf", concreteColum.LateralR.ToString());
                    xml.WriteAttributeString("Cover", concreteColum.CoverToRebarCenter.ToString());
                    xml.WriteAttributeString("NumBars3Dir", bars3);
                    xml.WriteAttributeString("NumBars2Dir",bars2 );
                    xml.WriteAttributeString("NumBarsCirc", barsCirc);
                    xml.WriteAttributeString("BarSize", barsize);
                    xml.WriteAttributeString("SpacingC", concreteColum.SpacingC.ToString());
                    xml.WriteAttributeString("NumCBars2", bars2);
                    xml.WriteAttributeString("NumCBars3", bars3);
                    xml.WriteAttributeString("ReinfType", "Design");
                    xml.WriteEndElement();
                   }
             }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates a Grid with frames given an origin, 3 vectors and number of bays in the 3 directions.
        /// Joints at the base are not connected and have restricted translation.
        /// </summary>
        /// <param name="model">The Model object to add the Grid to.</param>
        /// <param name="x0">X Component of the Origin point</param>
        /// <param name="y0">Y Component of the Origin point</param>
        /// <param name="z0">Z Component of the Origin point</param>
        /// <param name="ux">X Component of the U directional vector</param>
        /// <param name="uy">Y Component of the U directional vector</param>
        /// <param name="uz">Z Component of the U directional vector</param>
        /// <param name="vx">X Component of the V directional vector</param>
        /// <param name="vy">Y Component of the V directional vector</param>
        /// <param name="vz">Z Component of the V directional vector</param>
        /// <param name="wx">X Component of the W directional vector</param>
        /// <param name="wy">Y Component of the W directional vector</param>
        /// <param name="wz">Z Component of the W directional vector</param>
        /// <param name="nu">Number of bays in the U direction</param>
        /// <param name="nv">Number of bays in the V direction</param>
        /// <param name="nw">Number of bays in the W direction</param>
        /// <param name="doLines">If set to false, only the Joints are created</param>
        /// <param name="props">Frame properties to use in all the Line Elements created</param>
        private static void beamGrid3D(Canguro.Model.Model model, float x0, float y0, float z0, float ux, float uy, float uz,
                                       float vx, float vy, float vz, float wx, float wy, float wz, int nu, int nv, int nw, bool doLines, StraightFrameProps props)
        {
            Joint joint;

            Joint[]       joints  = new Joint[nu * nv * nw];
            Stack <Joint> jStack  = new Stack <Joint>();
            JointDOF      baseDoF = new JointDOF();

            baseDoF.T1 = baseDoF.T2 = baseDoF.T3 = JointDOF.DofType.Restrained;

            for (int i = 0; i < nw; i++)
            {
                for (int j = 0; j < nv; j++)
                {
                    for (int k = 0; k < nu; k++)
                    {
                        model.JointList.Add(joints[i * nu * nv + j * nu + k] =
                                                joint = new Joint(x0 + k * ux + j * vx + i * wx,
                                                                  y0 + j * uy + j * vy + i * wy,
                                                                  z0 + i * uz + i * vz + i * wz));
                        if (i == 0)
                        {
                            joints[i * nu * nv + j * nu + k].DoF = baseDoF;
                        }
                    }
                }
            }

            if (doLines)
            {
                LineElement beam;
                for (int i = 0; i < nw; i++)
                {
                    for (int j = 0; j < nv; j++)
                    {
                        for (int k = 0; k < nu; k++)
                        {
                            jStack.Push(joints[i * nu * nv + j * nu + k]);
                            if (i > 0)
                            {
                                jStack.Push(joints[(i - 1) * nu * nv + j * nu + k]);
                                model.LineList.Add(beam = new LineElement(props));
                                beam.I = jStack.Pop();
                                beam.J = jStack.Peek();
                                if (j > 0)
                                {
                                    jStack.Push(joints[i * nu * nv + (j - 1) * nu + k]);
                                    model.LineList.Add(beam = new LineElement(props));
                                    beam.I = jStack.Pop();
                                    beam.J = jStack.Peek();
                                }
                                if (k > 0)
                                {
                                    jStack.Push(joints[i * nu * nv + j * nu + k - 1]);
                                    model.LineList.Add(beam = new Canguro.Model.LineElement(props));
                                    beam.I = jStack.Pop();
                                    beam.J = jStack.Peek();
                                }
                            }
                            jStack.Pop();
                        }
                    }
                }
            }
        }
Ejemplo n.º 23
0
        private void store(OleDbConnection cn, LineElement obj)
        {
            Joint i = obj.I;
            Joint j = obj.J;
            string sql = "INSERT INTO [Connectivity - Frame] (Frame, JointI, JointJ, IsCurved, Length, CentroidX, CentroidY, CentroidZ) " +
                "VALUES (" + obj.Id + ", " + i.Id + ", " + j.Id + ",\"No\", " + obj.Length + ", " + (i.X + j.X) / 2.0F + ", " + (i.Y + j.Y) / 2.0F + ", " + (i.Z + j.Z) / 2.0F + ");";
            new OleDbCommand(sql, cn).ExecuteNonQuery();

            LineProps props = obj.Properties;
            List<Section> exported = new List<Section>();
            if (props is StraightFrameProps)
            {
                FrameSection sec = ((StraightFrameProps)props).Section;
                sql = "INSERT INTO [Frame Section Assignments] (Frame, SectionType, AutoSelect, AnalSect, DesignSect, MatProp) " +
                    "VALUES (" + obj.Id + ", \"" + secShape(sec.Shape) + "\", \"N.A.\", \"" + sec.Name + "\", \"" + sec.Name + "\", \"Default\");";
                new OleDbCommand(sql, cn).ExecuteNonQuery();
                store(cn, sec.ConcreteProperties, sec, exported);
            }
            AssignedLoads loads = obj.Loads;
            if (loads != null)
                store(cn, obj.Id, loads);
        }
Ejemplo n.º 24
0
        private string getLineSection(LineElement l)
        {
            if (l.Properties is StraightFrameProps)
            {
                Model.Section.FrameSection sec = ((StraightFrameProps)l.Properties).Section;
                return "\n" + sec.Description;
            }

            return string.Empty;
        }
Ejemplo n.º 25
0
        private string getLineLength(LineElement l)
        {
            string distance = units.UnitName(Canguro.Model.UnitSystem.Units.Distance);
            string angle = units.UnitName(Canguro.Model.UnitSystem.Units.Angle);

            string ret = "\n" + Culture.Get("lineLengthText") + l.Length.ToString("G3") + distance;
            if (l.Angle != 0)
                ret += ", " + Culture.Get("Angle") + ": " + l.Angle.ToString("G3") + angle;
            return ret;
        }
Ejemplo n.º 26
0
 private void writeLineAssigments(XmlTextWriter xml, LineElement obj)
 {
     LineProps props = obj.Properties;
     List<Section> exported = new List<Section>();
     if (props is StraightFrameProps) {
         FrameSection sec = ((StraightFrameProps)props).Section;
         xml.WriteStartElement("Frame");
         xml.WriteAttributeString("Frame", obj.Id.ToString());
         xml.WriteAttributeString("SectionType", secShape(sec.Shape));
         xml.WriteAttributeString("AutoSelect", "N.A.");
         xml.WriteAttributeString("AnalSect", sec.Name);
         xml.WriteAttributeString("DesignSect", sec.Name);
         xml.WriteAttributeString("MatProp", "Default");
         xml.WriteEndElement();
     }
 }
Ejemplo n.º 27
0
 private static void visit(List<LinkedList<LineElement>> graph, int jid, Stack<LineElement> stack, LineElement line)
 {
     LineElement minLine = null;
     float min = (float)Math.Cos(minAngle);
     if (graph[jid] != null)
     {
         foreach (LineElement adj in graph[jid])
         {
             if (adj != null && adj != line)
             {
                 float ang = cosAngle(line, adj);
                 if (ang > min)
                 {
                     min = ang;
                     minLine = adj;
                 }
             }
         }
         if (minLine != null)
             stack.Push(minLine);
     }
 }
Ejemplo n.º 28
0
 private void writeLines(XmlTextWriter xml, LineElement obj)
 {
     Joint i = obj.I;
     Joint j = obj.J;
     xml.WriteStartElement("Frame");
     xml.WriteAttributeString("Frame", obj.Id.ToString());
     xml.WriteAttributeString("JointI", i.Id.ToString());
     xml.WriteAttributeString("JointJ", j.Id.ToString());
     xml.WriteAttributeString("IsCurved", "No");
     xml.WriteAttributeString("Length", obj.Length.ToString());
     xml.WriteAttributeString("CentroidX", ((i.X + j.X) / 2.0F).ToString());
     xml.WriteAttributeString("CentroidY", ((i.Y + j.Y) / 2.0F).ToString());
     xml.WriteAttributeString("CentroidZ", ((i.Z + j.Z) / 2.0F).ToString());
     xml.WriteEndElement();
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Adds a Line Element to the given Model
 /// </summary>
 /// <param name="model">The Model object</param>
 /// <param name="ji">The initial Joint</param>
 /// <param name="jj">The final Joint</param>
 /// <param name="props">Frame properties for the Line Element</param>
 /// <param name="newJoints">List of new Joints to use in Join</param>
 /// <param name="newLines">List of new Line Elements to use in Join</param>
 private static void AddLine(Canguro.Model.Model model, Joint ji, Joint jj, StraightFrameProps props, List<Joint> newJoints, List<LineElement> newLines)
 {
     if (ji != null && jj != null)
     {
         model.JointList.Add(ji);
         model.JointList.Add(jj);
         LineElement elem = new LineElement(props, ji, jj);
         newJoints.Add(ji);
         newJoints.Add(jj);
         newLines.Add(elem);
         model.LineList.Add(elem);
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Creates a cylinder and adds it to the model.
        /// </summary>
        /// <param name="model">The Model object</param>
        /// <param name="C">The Center of the base</param>
        /// <param name="radius">The radius</param>
        /// <param name="cols">Number of columns</param>
        /// <param name="height">Height of each story</param>
        /// <param name="stories">Number of stories</param>
        /// <param name="props">Frame properties to use in all elements</param>
        protected void createCylinder(Canguro.Model.Model model, Vector3 C, float radius, int cols, float height, int stories, StraightFrameProps props)
        {
            float[,] columns = new float[cols, 3];
            int i, f, c;
            Queue<Joint> jQueue = new Queue<Joint>();
            Joint joint, first, prev;
            joint = prev = first = null;
            LineElement line;

            double angle, delta = 2 * Math.PI / (double)cols;
            float[] angles = new float[cols];

            for (i = 0, angle = 0; i < cols; angle += delta, i++)
            {
                columns[i, 0] = (float)(C.X + Math.Cos(angle) * radius);
                columns[i, 1] = (float)(C.Y + Math.Sin(angle) * radius);
                columns[i, 2] = (float)C.Z;
                angles[i] = (float)(angle * 180.0 / Math.PI);
            }

            JointDOF baseDoF = new JointDOF();
            baseDoF.T1 = baseDoF.T2 = baseDoF.T3 = JointDOF.DofType.Restrained;
            for (f = 0; f < stories; f++)
            {
                for (c = 0; c < cols; c++)
                {
                    joint = new Joint(columns[c, 0], columns[c, 1], columns[c, 2] + height * f);
                    if (c == 0) first = joint;
                    if (f == 0) joint.DoF = baseDoF;
                    model.JointList.Add(joint);
                    jQueue.Enqueue(joint);
                    if (f > 0)
                    {
                        model.LineList.Add(line = new LineElement(props));
                        line.I = jQueue.Dequeue();
                        line.J = joint;
                        line.Angle = angles[c];
                        if (c > 0)
                        {
                            model.LineList.Add(line = new LineElement(props));
                            line.I = prev;
                            line.J = joint;
                            if (c == cols - 1)
                            {
                                model.LineList.Add(line = new LineElement(props));
                                line.I = joint;
                                line.J = first;
                            }
                        }
                        prev = joint;
                    }
                }
            }
        }
Ejemplo n.º 31
0
 private void writeAngleAssignments(XmlWriter xml, LineElement obj)
 {
     if (obj.Angle != 0f)
     {
         xml.WriteStartElement("Frame");
         xml.WriteAttributeString("Frame", obj.Id.ToString());
         xml.WriteAttributeString("Angle", obj.Angle.ToString());
         xml.WriteAttributeString("MirrorAbt2", "No");
         xml.WriteAttributeString("MirrorAbt3", "No");
         xml.WriteAttributeString("AdvanceAxes", "No");
         xml.WriteEndElement();
     }
 }