Пример #1
0
 private void InitSpline()
 {
     if (spline == null)
     {
         spline = new Spline2D(points, closed, curvature, lengthSamplesPerSegment);
     }
 }
Пример #2
0
        public void APWZT()
        {
            // Arrange
            Spline2D one = new Spline2D(new List <Vector2> {
                new Vector2(0, 0), new Vector2(0, 1), new Vector2(0, 2)
            });
            Spline2D two = new Spline2D(new List <Vector2> {
                new Vector2(0, 0), new Vector2(1, 1), new Vector2(2, 2)
            });

            // Act
            Vector2 positionOne   = one.InterpolateDistance(1.5f);
            Vector2 positionTwo   = two.InterpolateDistance(1.5f);
            Vector2 positionThree = one.InterpolateDistance(0.5f);
            Vector2 positionFour  = two.InterpolateDistance(0.5f);
            Vector2 positionFive  = one.InterpolateDistance(1.5f);
            Vector2 positionSix   = two.InterpolateDistance(1.5f);

            // Assert
            Assert.Multiple(() =>
            {
                Assert.AreEqual(new Vector2(0, 1.5015914f), positionOne);
                Assert.AreEqual(new Vector2(1.0576555f, 1.0576555f), positionTwo);
                Assert.AreEqual(new Vector2(0, 0.49840856f), positionThree);
                Assert.AreEqual(new Vector2(0.35238677f, 0.35238677f), positionFour);
                Assert.AreEqual(new Vector2(0, 1.5015914f), positionFive);
                Assert.AreEqual(new Vector2(1.0576555f, 1.0576555f), positionSix);
            });
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            INFITF.Application catia; //add the reference - catia v5 infiit interface...

            try
            {
                //열려 있는 catia가져오기
                catia = (INFITF.Application)Marshal.GetActiveObject("CATIA.Application");
            }
            catch (Exception)
            {
                //catia 실행하기
                catia         = (INFITF.Application)Activator.CreateInstance(Type.GetTypeFromProgID("CATIA.Application"));
                catia.Visible = true;
            }

            MECMOD.PartDocument prtDoc = (MECMOD.PartDocument)catia.Documents.Add("Part");
            MECMOD.Part         prt    = prtDoc.Part;
            MECMOD.Bodies       bdys   = prt.Bodies;
            MECMOD.Body         bdy    = bdys.Add();
            MECMOD.Sketches     skts   = bdy.Sketches;

            INFITF.Reference xypln = (INFITF.Reference)prt.OriginElements.PlaneXY;
            MECMOD.Sketch    skt   = skts.Add(xypln);

            MECMOD.Factory2D fac2d = skt.OpenEdition();

            Point2D p1 = fac2d.CreatePoint(10, 10);
            Point2D p2 = fac2d.CreatePoint(10, 40);
            Point2D p3 = fac2d.CreatePoint(40, 40);
            Point2D p4 = fac2d.CreatePoint(40, 10);
            Point2D p5 = fac2d.CreatePoint(30, 20);
            Point2D p6 = fac2d.CreatePoint(20, 5);

            Line2D linLft = fac2d.CreateLine(10, 10, 10, 40);
            Line2D linTop = fac2d.CreateLine(10, 40, 40, 40);
            Line2D linRgt = fac2d.CreateLine(40, 40, 40, 10);

            object[] parry = { p1, p6, p5, p4 };
            Spline2D spl   = fac2d.CreateSpline(parry);

            linLft.StartPoint = p1;
            linLft.EndPoint   = p2;
            linRgt.StartPoint = p3;
            linRgt.EndPoint   = p4;
            linTop.StartPoint = p2;
            linTop.EndPoint   = p3;

            MECMOD.Constraint cnst = skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeAxisPerpendicularity, (INFITF.Reference)linLft, (INFITF.Reference)linTop);

            /*
             * INFITF.Reference r1 = prt.CreateReferenceFromGeometry(linLft);
             * INFITF.Reference r2 = prt.CreateReferenceFromGeometry(linTop);
             * MECMOD.Constraint cnst1 = skt.Constraints.AddBiEltCst(CatConstraintType.catCstTypeAxisPerpendicularity, r1, r2);
             */
            skt.CloseEdition();

            prt.Update();
        }
Пример #4
0
 public bool CalcSpline()
 {
     if (Points.Count < 4)
     {
         return(false);
     }
     double[] px = new double[Points.Count];
     double[] py = new double[Points.Count];
     for (int i = 0; i < Points.Count; i++)
     {
         px[i]           = Points[i].X;
         py[i]           = Points[i].Y;
         Points[i].Index = i;
     }
     Spline = new Spline2D(px, py);
     return(true);
 }
Пример #5
0
        public void YXMWS()
        {
            // Arrange
            Spline2D one = new Spline2D(new List <Vector2> {
                new Vector2(0, 0), new Vector2(0, 1), new Vector2(0, 2)
            });
            Spline2D two = new Spline2D(new List <Vector2> {
                new Vector2(0, 0), new Vector2(1, 1), new Vector2(2, 2)
            });

            // Act
            Vector2 positionOne = one.InterpolateDistance(1.5f);
            Vector2 positionTwo = two.InterpolateDistance(1.5f);

            // Assert
            Assert.Multiple(() =>
            {
                Assert.AreEqual(new Vector2(0, 1.5015914f), positionOne);
                Assert.AreEqual(new Vector2(1.0576555f, 1.0576555f), positionTwo);
            });
        }
Пример #6
0
        public void ARRPH()
        {
            // Arrange
            Spline2D one = new Spline2D(new List <Vector2> {
                new Vector2(0, 0), new Vector2(0, 1), new Vector2(0, 2)
            });
            Spline2D two = new Spline2D(new List <Vector2> {
                new Vector2(0, 0), new Vector2(1, 1), new Vector2(2, 2)
            });

            // Act
            Vector2 positionOne = one.Interpolate(0.75f);
            Vector2 positionTwo = two.Interpolate(0.75f);

            // Assert
            Assert.Multiple(() =>
            {
                Assert.AreEqual(new Vector2(0, 1.5625f), positionOne);
                Assert.AreEqual(new Vector2(1.5625f, 1.5625f), positionTwo);
            });
        }
Пример #7
0
        public void SCMWP()
        {
            // Arrange
            Spline2D one = new Spline2D(new List <Vector2> {
                new Vector2(0, 0), new Vector2(0, 1), new Vector2(0, 2)
            });
            Spline2D two = new Spline2D(new List <Vector2> {
                new Vector2(0, 0), new Vector2(1, 1), new Vector2(2, 2)
            });

            // Act
            float lengthOne = one.Length;
            float lengthTwo = two.Length;

            // Assert
            Assert.Multiple(() =>
            {
                Assert.AreEqual(2, lengthOne);
                Assert.AreEqual(2.82842731f, lengthTwo);
            });
        }
Пример #8
0
 public static float CalculateDifference(Spline2D spline1, Spline2D spline2)
 {
     return(100f);
 }