public void AdjustScaleTest() { List <SegmentMeshInfo> ms = new List <SegmentMeshInfo>(); var path1 = Util.circlePoints(100, 100, 40, 20); var path2 = Util.circlePoints(200, 200, 30, 20); var r1 = new CharacterRange(0, 5); var r2 = new CharacterRange(10, 5); var section1 = path1.Skip(r1.First).Take(r1.Length).ToList(); var section2 = path2.Skip(r2.First).Take(r2.Length).ToList(); var curves1 = SegmentConnector_Accessor.SectionToCurves(path1, r1, 5, 30); var curves2 = SegmentConnector_Accessor.SectionToCurves(path2, r2, 5, 30); var an = new SkeletonAnnotation(null); an.joints.Add(new JointAnnotation("0", new PointF(100, 100))); an.joints.Add(new JointAnnotation("1", new PointF(200, 200))); an.bones.Add(new BoneAnnotation(an.joints[0], an.joints[1])); ms.Add(new SegmentMeshInfo(path1, null, section1, an, false)); ms.Add(new SegmentMeshInfo(path2, null, section2, an, false)); var pairs = new List <SegmentConnector.ConnectPair>(); pairs.Add(new SegmentConnector.ConnectPair(an.bones[0], ms[0], r1, ms[1], r2)); var w1 = SegmentConnector_Accessor.GetSectionWidth(ms[0].GetPath(), curves1, an.bones[0]); var w2 = SegmentConnector_Accessor.GetSectionWidth(ms[1].GetPath(), curves2, an.bones[0]); Assert.AreNotEqual(w1, w2, 1e-4); SegmentConnector_Accessor.AdjustScale(ms, an, pairs); w1 = SegmentConnector_Accessor.GetSectionWidth(ms[0].GetPath(), curves1, an.bones[0]); w2 = SegmentConnector_Accessor.GetSectionWidth(ms[1].GetPath(), curves2, an.bones[0]); Assert.AreEqual(w1, w2, 1e-4); }
public void GetSectionWidthTest() { List <PointF> path = new List <PointF>(); for (int i = 0; i < 10; i++) { path.Add(new PointF(10 * i, -10 * i)); } for (int i = 0; i < 10; i++) { path.Add(new PointF(10 * (9 - i), 10 * (9 - i))); } var curves = new Tuple <CharacterRange, CharacterRange>(new CharacterRange(1, 2), new CharacterRange(-3, 2)); BoneAnnotation b = new BoneAnnotation(new JointAnnotation("", new PointF(0, 0)), new JointAnnotation("", new PointF(100, 0))); Assert.AreEqual(SegmentConnector_Accessor.GetSectionWidth(path, curves, b), 30, 1e-4f); }