예제 #1
0
        public Karamba.Results.ShellSection.Retriever GetNewRetriever(PolyLine3 poly)
        {
            var info     = new RetrieverInfo_Force(_model, poly, _projectionVector, _tol, _delta, "0");
            var strategy = new RetrieverStrategy_Force();

            return(new Karamba.Results.ShellSection.Retriever(strategy, info));
        }
예제 #2
0
        public void HollowRectangleValues()
        {
            // define outline of triangle
            double b = 0.5;
            double h = 1.0;
            double t = 0.1;

            var pl1 = new PolyLine3(new List <Point3>
            {
                new Point3(0, 0, h),
                new Point3(0, 0, 0),
                new Point3(0, b, 0),
                new Point3(0, b, h)
            });

            var pl2 = new PolyLine3(new List <Point3>
            {
                new Point3(0, b - t, h - t),
                new Point3(0, b - t, 0 + t),
                new Point3(0, t, 0 + t),
                new Point3(0, t, h - t)
            });

            double bi = 0.5 - 2 * t;
            double hi = 1.0 - 2 * t;

            var props = CroSecProperties.solve(new List <PolyLine3> {
                pl1, pl2
            });
            double area_targ = b * h - bi * hi;

            Assert.AreEqual(props.A, area_targ, 1E-10);
        }
        public void FindSection_3ptpolyline_NonPlanarMesh()
        {
            PolyLine3 inputPolyline         = new PolyLine3(new Point3(0.5, -0.5, 1), new Point3(0.5, 1.5, 1));
            Vector3   inputProjectionVector = new Vector3(0, 0, -1);

            _tol = 1E-12;
            var delta      = 0.02;
            var inputModel = MakeNonConvexModel();

            var info     = new RetrieverInfo_Force(inputModel, inputPolyline, inputProjectionVector, _tol, delta, "0");
            var strategy = new RetrieverStrategy_Force();
            var sut      = new Karamba.Results.ShellSection.Retriever(strategy, info);



            sut.FindSection(out var outputPolylines, out var outputFaceIndxs);



            var expectedPolylines = new PolyLine3
                                    (
                new Point3(0.5, 0, 0.25),
                new Point3(0.5, 0.5, 0.75),
                new Point3(0.5, 1, 0.5)
                                    );
            var expectedFaceIndxs = new List <int>()
            {
                0, 1
            };


            Assert.That(outputPolylines[0], Is.EqualTo(expectedPolylines).Using <PolyLine3>(EqualityWithTol));
            Assert.That(outputFaceIndxs[0], Is.EqualTo(expectedFaceIndxs));
        }
        public void MakeComparison(PolyLine3 polylineToProject, PolyLine3 expectedPolyline, List <int> expectedfaceIndxs)
        {
            var sut = GetNewRetriever(polylineToProject);

            sut.FindSection(out var all_output_poly, out var all_output_faces);

            Assert.That(all_output_poly[0], Is.EqualTo(expectedPolyline).Using <PolyLine3>(EqualityWithTol));
            Assert.That(all_output_faces[0], Is.EqualTo(expectedfaceIndxs).Within(_tol));
        }
예제 #5
0
        /// <summary>
        /// Create rhino <see cref="PolyCurve"/> from karamba polyline.
        /// </summary>
        ///
        /// <param name="p">Polyline.</param>
        /// <returns></returns>
        public static PolylineCurve Convert(this PolyLine3 p)
        {
            var ps = new List <Point3d>();

            foreach (var pt in p.Points)
            {
                ps.Add(pt.Convert());
            }
            return(new PolylineCurve(ps));
        }
예제 #6
0
        public void RectangleValues()
        {
            // define outline of triangle
            double b = 0.5;
            double h = 1.0;

            var pl = new PolyLine3(new List <Point3>
            {
                new Point3(0, 0, h),
                new Point3(0, 0, 0),
                new Point3(0, b, 0),
                new Point3(0, b, h)
            });

            var props = CroSecProperties.solve(new List <PolyLine3> {
                pl
            });
            double area_targ = b * h;

            Assert.AreEqual(props.A, area_targ, 1E-10);
            double area_iy = b * h * h * h / 12.0;

            Assert.AreEqual(props.inertia.X, area_iy, 1E-10);
            Assert.AreEqual(props.inertia_princ.X, area_iy, 1E-10);
            double area_iz = h * b * b * b / 12.0;

            Assert.AreEqual(props.inertia.Y, area_iz, 1E-10);
            Assert.AreEqual(props.inertia_princ.Y, area_iz, 1E-10);
            double cog_z = h * 0.5;
            double cog_y = b * 0.5;

            Assert.AreEqual(props.cog.Y, cog_y, 1E-10);
            Assert.AreEqual(props.cog.Z, cog_z, 1E-10);
            double wel_y = b * h * h / 6.0;
            double wel_z = h * b * b / 6.0;

            Assert.AreEqual(props.Welz_y_pos, -wel_z, 1E-10);
            Assert.AreEqual(props.Wely_z_pos, wel_y, 1E-10);
            Assert.AreEqual(props.Welz_y_neg, wel_z, 1E-10);
            Assert.AreEqual(props.Wely_z_neg, -wel_y, 1E-10);
            double wpl_y = b * h * h / 4.0;
            double wpl_z = h * b * b / 4.0;

            Assert.AreEqual(props.Wply, wpl_y, 1E-10);
            Assert.AreEqual(props.Wplz, wpl_z, 1E-10);
        }
예제 #7
0
 public bool EqualityWithTol(PolyLine3 poly1, PolyLine3 poly2)
 {
     if (poly1.Count != poly2.Count)
     {
         return(false);
     }
     for (int i = 0; i < poly1.Count; i++)
     {
         var success = Math.Abs(poly1[i].X - poly2[i].X) < _tol &&
                       Math.Abs(poly1[i].Y - poly2[i].Y) < _tol &&
                       Math.Abs(poly1[i].Z - poly2[i].Z) < _tol;
         if (success == false)
         {
             return(false);
         }
     }
     return(true);
 }
예제 #8
0
        public void Initialize()
        {
            var k3d = new Toolkit();

            var mesh = new Mesh3();

            mesh.AddVertex(0, 0, 0);
            mesh.AddVertex(0, 1, 0);
            mesh.AddVertex(1, 0, 0);
            mesh.AddVertex(1, 1, 0);
            mesh.AddFace(0, 2, 3);
            mesh.AddFace(0, 3, 1);

            var supportConditions = new List <bool>()
            {
                true, true, true, true, true, true
            };
            var supports = new List <Support>
            {
                k3d.Support.Support(new Point3(0, 0, 0), supportConditions),
                k3d.Support.Support(new Point3(0, 1, 0), supportConditions),
            };

            var loads = new List <Load>
            {
                k3d.Load.PointLoad(new Point3(1, 1, 0), new Vector3(-5, 0, -5)),
                k3d.Load.PointLoad(new Point3(1, 0, 0), new Vector3(-5, 0, -5)),
            };

            var logger = new MessageLogger();
            var crosec = k3d.CroSec.ReinforcedConcreteStandardShellConst(1);//20, 0, null, new List<double> { 4, 4, -4, -4 }, 0);
            var shells = k3d.Part.MeshToShell(new List <Mesh3> {
                mesh
            }, null, new List <CroSec> {
                crosec
            }, logger, out var nodes);
            var model = k3d.Model.AssembleModel(shells, supports, loads, out var info, out var mass, out var cog, out var message, out var any_warning);


            model             = k3d.Algorithms.AnalyzeThI(model, out var maxDisplacements, out var gravityForce, out var elasticEnergy, out var warning);
            _model            = model;
            _inputPolyline    = new PolyLine3(new Point3(0.5, -0.5, 1), new Point3(0.5, 1.5, 1));
            _projectionVector = new Vector3(0, 0, -1);
            _tol             = 1E-12;
            _delta           = 0.02;
            _outputPolylines = new List <PolyLine3>()
            {
                new PolyLine3
                (
                    new Point3(0.5, 0, 0),
                    new Point3(0.5, 0.5, 0),
                    new Point3(0.5, 1, 0)
                )
            };
            _outputCrossedFaces = new List <List <int> >()
            {
                new List <int>()
                {
                    0, 1
                }
            };
        }