Example #1
0
        private void PointToPoint(ref MWPoint2D pi1, ref MWPoint2D pi2, ref MWPoint2D pj1, ref MWPoint2D pj2, int tol = 10)
        {
            double d11 = Points.Distance(pi1, pj1);

            if (d11 < tol)
            {
                pi1 = pj1;
            }
            double d12 = Points.Distance(pi1, pj2);

            if (d12 < tol)
            {
                pi1 = pj2;
            }
            double d21 = Points.Distance(pi2, pj1);

            if (d21 < tol)
            {
                pi2 = pj1;
            }
            double d22 = Points.Distance(pi2, pj2);

            if (d22 < tol)
            {
                pi2 = pj2;
            }
        }
Example #2
0
        public void TransformPoints()
        {
            MWPoint2D bary = this.GetBarycenter();

            for (int i = 0; i < (PicSlabs?.Count ?? 0); i++)
            {
                PicSlabs[i] = PicSlabs[i].Select(p => new MWPoint2D(-(p.X - bary.X), (p.Y - bary.Y))).ToList();
            }
            foreach (var s in PicSlabs)
            {
                s.Reverse();
            }

            for (int i = 0; i < (PicWalls?.Count ?? 0); i++)
            {
                PicWalls[i] = PicWalls[i].Select(p => new MWPoint2D(-(p.X - bary.X), (p.Y - bary.Y))).ToList();
            }

            for (int i = 0; i < (PicColumns?.Count ?? 0); i++)
            {
                PicColumns[i] = PicColumns[i].Select(p => new MWPoint2D(-(p.X - bary.X), (p.Y - bary.Y))).ToList();
            }

            for (int i = 0; i < (PicOpenings?.Count ?? 0); i++)
            {
                PicOpenings[i] = PicOpenings[i].Select(p => new MWPoint2D(-(p.X - bary.X), (p.Y - bary.Y))).ToList();
            }
        }
Example #3
0
        public List <MWPoint2D> ExpandWall(MWPoint2D p1, MWPoint2D p2)
        {
            MWVector2D v = new MWVector2D(p2.X - p1.X, p2.Y - p1.Y);

            v = v.Normalize();
            MWVector2D n = new MWVector2D(-v.Y, v.X);

            return(new List <MWPoint2D>()
            {
                new MWPoint2D(p1.X + this.WallThickness / 1e3 / 2 * (+n.X - v.X), p1.Y + this.WallThickness / 1e3 / 2 * (+n.Y - v.Y)),
                new MWPoint2D(p1.X + this.WallThickness / 1e3 / 2 * (-n.X - v.X), p1.Y + this.WallThickness / 1e3 / 2 * (-n.Y - v.Y)),
                new MWPoint2D(p2.X + this.WallThickness / 1e3 / 2 * (-n.X + v.X), p2.Y + this.WallThickness / 1e3 / 2 * (-n.Y + v.Y)),
                new MWPoint2D(p2.X + this.WallThickness / 1e3 / 2 * (+n.X + v.X), p2.Y + this.WallThickness / 1e3 / 2 * (+n.Y + v.Y)),
            });
        }
Example #4
0
        private void PointToLine(ref MWPoint2D pi1, ref MWPoint2D pi2, ref MWPoint2D pj1, ref MWPoint2D pj2, int tol = 10)
        {
            double d1 = Points.DistancePointToLine(pj1, pj2, pi1, infinite: false);

            if (d1 < tol)
            {
                pi1 = Points.PointProjOnLine(pj1, pj2, pi1);
            }

            double d2 = Points.DistancePointToLine(pj1, pj2, pi2, infinite: false);

            if (d2 < tol)
            {
                pi2 = Points.PointProjOnLine(pj1, pj2, pi1);
            }
        }
Example #5
0
        public void ProcessColumns()
        {
            for (int i = 0; i < PicColumns?.Count; i++)
            {
                RotatedRect      rect      = CvInvoke.MinAreaRect(PicColumns[i].Select(p => new PointF((float)p.X, (float)p.Y)).ToArray());
                var              corners   = rect.GetVertices().Select(p => new MWPoint2D(p.X, p.Y)).ToList();
                double           l1        = Points.Distance(corners[0], corners[1]);
                double           l2        = Points.Distance(corners[1], corners[2]);
                List <MWPoint2D> newPoints = new List <MWPoint2D>();
                MWPoint2D        center    = new MWPoint2D(0.5 * (corners[0].X + corners[2].X), 0.5 * (corners[0].Y + corners[2].Y));
                ColumnDims       cd;
                MWVector2D       v;
                if (l1 > l2)
                {
                    double ratio = l1 / l2;
                    cd = ColDims.Aggregate(ColDims[0], (closest, next) =>
                                           Math.Abs(ratio - next.Ratio) < Math.Abs(ratio - closest.Ratio) ? next : closest);
                    v = new MWVector2D(corners[1].X - corners[0].X, corners[1].Y - corners[0].Y);
                }
                else
                {
                    double ratio = l2 / l1;
                    cd = ColDims.Aggregate(ColDims[0], (closest, next) =>
                                           Math.Abs(ratio - next.Ratio) < Math.Abs(ratio - closest.Ratio) ? next : closest);
                    v = new MWVector2D(corners[2].X - corners[1].X, corners[2].Y - corners[1].Y);
                }
                double L = Math.Max(cd.D1, cd.D2) / 1e3;
                double W = Math.Min(cd.D1, cd.D2) / 1e3;

                v = v.Normalize();
                MWVector2D n = new MWVector2D(-v.Y, v.X);

                newPoints.Add(new MWPoint2D(+0.5 * L * v.X + 0.5 * W * n.X, +0.5 * L * v.Y + 0.5 * W * n.Y));
                newPoints.Add(new MWPoint2D(+0.5 * L * v.X - 0.5 * W * n.X, +0.5 * L * v.Y - 0.5 * W * n.Y));
                newPoints.Add(new MWPoint2D(-0.5 * L * v.X - 0.5 * W * n.X, -0.5 * L * v.Y - 0.5 * W * n.Y));
                newPoints.Add(new MWPoint2D(-0.5 * L * v.X + 0.5 * W * n.X, -0.5 * L * v.Y + 0.5 * W * n.Y));

                Columns.Add(new Column()
                {
                    RawCenter     = center,
                    SectionPoints = newPoints
                });
            }
            RescaleColumns();
        }
Example #6
0
        public static List <MWPoint2D> OrderInDistance(List <MWPoint2D> pts)
        {
            List <MWPoint2D> lpts = pts;
            MWPoint2D        pt   = lpts.First(p => p.X == lpts.Max(v => v.X));
            List <MWPoint2D> res  = new List <MWPoint2D> {
                pt
            };

            lpts.Remove(pt);
            while (lpts.Count > 0)
            {
                MWPoint2D p0 = lpts.Aggregate(lpts[0], (closest, next) =>
                                              Points.Distance(res[res.Count - 1], next) < Points.Distance(res[res.Count - 1], closest) ? next : closest);
                res.Add(p0);
                lpts.Remove(p0);
            }
            return(res);
        }
Example #7
0
        public void ProcessWalls()
        {
            for (int i = 0; i < PicWalls.Count; i++)
            {
                if (Points.Distance(PicWalls[i][0], PicWalls[i][1]) < 15)
                {
                    PicWalls.RemoveAt(i);
                    i--;
                }
            }
            for (int i = 0; i < PicWalls.Count; i++)
            {
                MWPoint2D pi1 = new MWPoint2D(PicWalls[i][0].X, PicWalls[i][0].Y);
                MWPoint2D pi2 = new MWPoint2D(PicWalls[i][1].X, PicWalls[i][1].Y);
                for (int j = 0; j < PicWalls.Count; j++)
                {
                    if (j != i)
                    {
                        MWPoint2D pj1 = new MWPoint2D(PicWalls[j][0].X, PicWalls[j][0].Y);
                        MWPoint2D pj2 = new MWPoint2D(PicWalls[j][1].X, PicWalls[j][1].Y);
                        if (pj1.X == pj2.X && pj1.Y == pj2.Y)
                        {
                            break;
                        }
                        PointToLine(ref pi1, ref pi2, ref pj1, ref pj2);
                        PointToPoint(ref pi1, ref pi2, ref pj1, ref pj2);
                        PointToLine(ref pi1, ref pi2, ref pj1, ref pj2);
                        PointToPoint(ref pi1, ref pi2, ref pj1, ref pj2);
                    }
                }
                PicWalls[i][0] = new MWPoint2D(pi1.X, pi1.Y);
                PicWalls[i][1] = new MWPoint2D(pi2.X, pi2.Y);
            }

            Walls = PicWalls.Select(w => new Wall()
            {
                RawPoints = w
            }).ToList();
            RescaleWalls();
        }
Example #8
0
        public void Run(ref StructuralModel structure)
        {
            FEModel.Geometry geom = new FEModel.Geometry();
            double           H    = structure.StoryHeight;

            for (int i = 0; i < structure.NumStories; i++)
            //for(int i = 0; i < 2; i++)
            {
                for (int j = 0; j < structure.Slabs.Count; j++)
                {
                    List <MWPoint2D> pts = structure.Slabs[j].Points;
                    Shell            s   = new Shell(pts.Select(p => new MWPoint3D(p.X, p.Y, (i + 1) * H)).ToList(), structure.SlabThickness, ShellType.Slab);
                    s.Holes = structure.Openings.Select(o => o.Points.Select(p => new MWPoint3D(p.X, p.Y, (i + 1) * H)).ToList()).ToList();
                    geom.Shells.Add(s);
                }
                for (int j = 0; j < structure.Columns.Count; j++)
                {
                    var              col    = structure.Columns[j];
                    MWPoint2D        center = new MWPoint2D(0.5 * (col.Points[0].X + col.Points[2].X), 0.5 * (col.Points[0].Y + col.Points[2].Y));
                    List <MWPoint2D> secPts = col.Points.Select(p => new MWPoint2D(p.X - center.X, p.Y - center.Y)).ToList();
                    geom.Beams.Add(new Beam(new MWPoint3D(center.X, center.Y, i * structure.StoryHeight),
                                            new MWPoint3D(center.X, center.Y, (i + 1) * structure.StoryHeight),
                                            secPts));
                }
                for (int j = 0; j < structure.Walls.Count; j++)
                {
                    List <MWPoint2D> wall    = structure.Walls[j].Points;
                    List <MWPoint3D> wallPts = new List <MWPoint3D>()
                    {
                        new MWPoint3D(wall[0].X, wall[0].Y, i * structure.StoryHeight),
                        new MWPoint3D(wall[1].X, wall[1].Y, i * structure.StoryHeight),
                        new MWPoint3D(wall[1].X, wall[1].Y, (i + 1) * structure.StoryHeight),
                        new MWPoint3D(wall[0].X, wall[0].Y, (i + 1) * structure.StoryHeight),
                    };
                    geom.Shells.Add(new Shell(wallPts, structure.WallThickness, ShellType.Wall));
                }
            }

            // Loads
            FEModel.Loads loads = new Loads()
            {
                LL   = structure.sLoad.LL,
                SDL  = structure.sLoad.SDL,
                CLAD = structure.sLoad.CLAD
            };

            fem = new FEModel.FEModel(geom, loads);

            Stopwatch sw = new Stopwatch();

            sw.Start();
            Results = fem.Analyze();

            TimeSpan ts = sw.Elapsed;

            Console.WriteLine("meshing time = {0}s", ts.TotalSeconds);
            BuildMesh();
            ts = sw.Elapsed;
            Console.WriteLine("display time = {0}s", ts.TotalSeconds);
            sw.Stop();
        }