public void CustomSec3_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(CustomSec3_Test));

            sec.SolutionSettings = new SolutionSettings(0.002);

            sec.Contours.Add(new SectionContour(helper.CreateRectangle(300, 180), false, defaultMat));

            var c1 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c1.ShiftPoints(30, 30);
            var c2 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c2.ShiftPoints(150, 30);
            var c3 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c3.ShiftPoints(150, 270);
            var c4 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c4.ShiftPoints(30, 270);

            sec.Contours.Add(c1);
            sec.Contours.Add(c2);
            sec.Contours.Add(c3);
            sec.Contours.Add(c4);

            _solver.Solve(sec);
            Compare(nameof(CustomSec3_Test), sec);
        }
        public void CompundSec_Test()
        {
            SectionDefinition sec = new SectionDefinition(nameof(CompundSec_Test));

            sec.SolutionSettings = new SolutionSettings(0.01);

            (List <Point2D> outer, List <Point2D> inner) = helper.CreateRhsShape(150, 100, 6, 15, 8);
            sec.Contours.Add(new SectionContour(outer, false, defaultMat));
            sec.Contours.Add(new SectionContour(inner, true, defaultMat));

            List <Point2D> points = new List <Point2D>();

            points.Add(new Point2D(0, 0));
            points.Add(new Point2D(50, 0));
            points.Add(new Point2D(25, 50));
            var triangle = new SectionContour(points, false, defaultMat);

            triangle.ShiftPoints(25, 150);
            sec.Contours.Add(triangle);

            var angle = new SectionContour(helper.CreateAngleShape(100, 100, 6, 8, 5, 8), false, defaultMat);

            angle.ShiftPoints(100, 25);
            sec.Contours.Add(angle);

            _solver.Solve(sec);
            Compare(nameof(CompundSec_Test), sec);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting...");


            Stopwatch sw = new Stopwatch();

            sw.Start();

            Solver _solver = new Solver();
            ShapeGeneratorHelper helper = new ShapeGeneratorHelper();

            SectionMaterial defaultMat = new SectionMaterial("dummy", 1, 1.0, 0.0, 1.0);

            SectionDefinition sec = new SectionDefinition();

            sec.SolutionSettings = new SolutionSettings(0.002);

            sec.Contours.Add(new SectionContour(helper.CreateRectangle(300, 180), false, defaultMat));

            var c1 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c1.ShiftPoints(30, 30);
            var c2 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c2.ShiftPoints(150, 30);
            var c3 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c3.ShiftPoints(150, 270);
            var c4 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat);

            c4.ShiftPoints(30, 270);

            sec.Contours.Add(c1);
            sec.Contours.Add(c2);
            sec.Contours.Add(c3);
            sec.Contours.Add(c4);

            _solver.Solve(sec);

            Console.WriteLine(sec.Output.SectionProperties.j.ToString());

            sw.Stop();

            Console.WriteLine("Elapsed={0}", sw.Elapsed);

            Console.ReadLine();
        }
        public void CompositeSec_Test()
        {
            //Note that because of using more than one material, some output need to be mapped to eq. material (e.g. Sx output represents Mpx and Sx= Mpx/fy)

            SectionMaterial steel  = new SectionMaterial("Steel", 1, 200e3, 0.3, 500);
            var             timber = new SectionMaterial("Timber", 2, 8e3, 0.35, 20);

            SectionDefinition sec = new SectionDefinition(nameof(CompositeSec_Test));

            sec.SolutionSettings = new SolutionSettings(0.01);
            sec.Contours.Add(new SectionContour(helper.CreateIShape(304, 165, 10.2, 6.1, 11.4, 8), false, steel));
            var panel = new SectionContour(helper.CreateRectangle(50, 600), false, timber);

            panel.ShiftPoints(-217.5, 304);
            sec.Contours.Add(panel);

            _solver.Solve(sec);
            Compare(nameof(CompositeSec_Test), sec);
        }
        /// <summary>
        /// Return true if the given point is inside the polygon, or false if it is not.
        /// </summary>
        /// <param name="point">The point to check.</param>
        /// <param name="poly">The polygon (list of contour points).</param>
        /// <returns></returns>
        /// <remarks>
        /// WARNING: If the point is exactly on the edge of the polygon, then the function
        /// may return true or false.
        ///
        /// See http://alienryderflex.com/polygon/
        /// </remarks>
        public static bool IsPointInPolygon(TriangleNet.Geometry.Point point, SectionContour contour,
                                            List <SectionContour> otherContours)
        {
            bool inside = false;

            double x = point.X;
            double y = point.Y;

            List <Vertex> poly = contour.Points.Select(p => new Vertex(p.X, p.Y)).ToList();

            inside = IsPointInPolygon(point, poly);
            if (inside)
            {
                foreach (var item in otherContours)
                {
                    if (IsPointInPolygon(point, item.Points.Select(p => new Vertex(p.X, p.Y)).ToList()))
                    {
                        inside = false;
                        break;
                    }
                }
            }
            return(inside);
        }
        public static TriangleNet.Geometry.Point FindPointInPolygon(SectionContour contour, List <SectionContour> otherContours,
                                                                    int limit, double eps = 2e-5)
        {
            List <Vertex> poly   = contour.Points.Select(p => new Vertex(p.X, p.Y)).ToList();
            var           bounds = new TriangleNet.Geometry.Rectangle();

            bounds.Expand(poly);

            int length = poly.Count;

            var test = new TriangleNet.Geometry.Point();

            TriangleNet.Geometry.Point a, b, c; // Current corner points.

            double bx, by;
            double dx, dy;
            double h;

            var predicates = new RobustPredicates();

            a = poly[0];
            b = poly[1];

            for (int i = 0; i < length; i++)
            {
                c = poly[(i + 2) % length];

                // Corner point.
                bx = b.X;
                by = b.Y;

                // NOTE: if we knew the contour points were in counterclockwise order, we
                // could skip concave corners and search only in one direction.

                h = predicates.CounterClockwise(a, b, c);

                if (Math.Abs(h) < eps)
                {
                    // Points are nearly co-linear. Use perpendicular direction.
                    dx = (c.Y - a.Y) / 2;
                    dy = (a.X - c.X) / 2;
                }
                else
                {
                    // Direction [midpoint(a-c) -> corner point]
                    dx = (a.X + c.X) / 2 - bx;
                    dy = (a.Y + c.Y) / 2 - by;
                }

                // Move around the contour.
                a = b;
                b = c;

                h = 1.0;

                for (int j = 0; j < limit; j++)
                {
                    // Search in direction.
                    test.X = bx + dx * h;
                    test.Y = by + dy * h;

                    if (bounds.Contains(test) && IsPointInPolygon(test, contour, otherContours))
                    {
                        return(test);
                    }

                    // Search in opposite direction (see NOTE above).
                    test.X = bx - dx * h;
                    test.Y = by - dy * h;

                    if (bounds.Contains(test) && IsPointInPolygon(test, contour, otherContours))
                    {
                        return(test);
                    }

                    h = h / 2;
                }
            }

            throw new Exception();
        }