public void UpdateSkeletalControlPointsTest() { Segment seg = new Segment("seg", null); SkeletonAnnotation segmentAnnotaiton = new SkeletonAnnotation(null); segmentAnnotaiton.joints.Add(new JointAnnotation("0", new PointF(0, 0))); segmentAnnotaiton.joints.Add(new JointAnnotation("1", new PointF(100, 100))); segmentAnnotaiton.joints.Add(new JointAnnotation("2", new PointF(-500, -50))); segmentAnnotaiton.bones.Add(new BoneAnnotation(segmentAnnotaiton.joints[0], segmentAnnotaiton.joints[1])); segmentAnnotaiton.bones.Add(new BoneAnnotation(segmentAnnotaiton.joints[1], segmentAnnotaiton.joints[2])); seg.an = segmentAnnotaiton; SegmentMeshInfo target = new SegmentMeshInfo(seg, true); SkeletonAnnotation refAnnotation = new SkeletonAnnotation(null); refAnnotation.joints.Add(new JointAnnotation("0", new PointF(0, 0))); refAnnotation.joints.Add(new JointAnnotation("1", new PointF(100, 0))); refAnnotation.joints.Add(new JointAnnotation("2", new PointF(0, 50))); refAnnotation.bones.Add(new BoneAnnotation(refAnnotation.joints[0], refAnnotation.joints[1])); refAnnotation.bones.Add(new BoneAnnotation(refAnnotation.joints[1], refAnnotation.joints[2])); refAnnotation.bones.Add(new BoneAnnotation(refAnnotation.joints[0], refAnnotation.joints[2])); target.UpdateSkeletalControlPoints(refAnnotation); }
public void GetBoneSectionCrossDictTest() { var _seg1 = new Segment("seg1", null); _seg1.path = Util.circlePoints(100, 100, 30, 20); _seg1.section = _seg1.path.Take(5).ToList(); _seg1.an = new SkeletonAnnotation(null); _seg1.an.joints.Add(new JointAnnotation("0", new PointF(100, 100))); _seg1.an.joints.Add(new JointAnnotation("1", new PointF(200, 200))); _seg1.an.bones.Add(new BoneAnnotation(_seg1.an.joints[0], _seg1.an.joints[1])); var dict = SegmentMeshInfo_Accessor.GetBoneSectionCrossDict(_seg1.path, new List <CharacterRange>() { new CharacterRange(0, 5) }, _seg1.an); Assert.AreEqual(dict.Count, 1); var seg1 = new SegmentMeshInfo(_seg1, false); Assert.AreEqual(seg1.crossDict.Count, 1); }
public void GetSectionPairsTest() { var pairs = SegmentConnector_Accessor.GetSectionPairs(null, null); Assert.IsNull(pairs); pairs = SegmentConnector_Accessor.GetSectionPairs(null, new SkeletonAnnotation(null)); Assert.IsNull(pairs); pairs = SegmentConnector_Accessor.GetSectionPairs(new List <SegmentMeshInfo>(), null); Assert.IsNull(pairs); SkeletonAnnotation 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.joints.Add(new JointAnnotation("2", new PointF(300, 100))); an.bones.Add(new BoneAnnotation(an.joints[0], an.joints[1])); an.bones.Add(new BoneAnnotation(an.joints[1], an.joints[2])); var _seg1 = new Segment("seg1", null); _seg1.path = Util.circlePoints(100, 100, 30, 20); _seg1.section = _seg1.path.Take(5).ToList(); _seg1.an = new SkeletonAnnotation(null); _seg1.an.joints.Add(new JointAnnotation("0", new PointF(100, 100))); _seg1.an.joints.Add(new JointAnnotation("1", new PointF(200, 200))); _seg1.an.bones.Add(new BoneAnnotation(_seg1.an.joints[0], _seg1.an.joints[1])); var _seg2 = new Segment("seg2", null); _seg2.path = Util.circlePoints(200, 200, 60, 20); _seg2.section = _seg2.path.Skip(10).Take(4).Concat(_seg2.path.Skip(15).Take(4)).ToList(); _seg2.an = new SkeletonAnnotation(null); _seg2.an.joints.Add(new JointAnnotation("0", new PointF(100, 100))); _seg2.an.joints.Add(new JointAnnotation("1", new PointF(200, 200))); _seg2.an.joints.Add(new JointAnnotation("2", new PointF(300, 100))); _seg2.an.bones.Add(new BoneAnnotation(_seg2.an.joints[0], _seg2.an.joints[1])); _seg2.an.bones.Add(new BoneAnnotation(_seg2.an.joints[1], _seg2.an.joints[2])); var _seg3 = new Segment("seg3", null); _seg3.path = Util.circlePoints(300, 150, 90, 20); _seg3.section = _seg3.path.Skip(5).Take(5).ToList(); _seg3.an = new SkeletonAnnotation(null); _seg3.an.joints.Add(new JointAnnotation("1", new PointF(200, 200))); _seg3.an.joints.Add(new JointAnnotation("2", new PointF(300, 100))); _seg3.an.bones.Add(new BoneAnnotation(_seg3.an.joints[0], _seg3.an.joints[1])); var seg1 = new SegmentMeshInfo(_seg1, false); var seg2 = new SegmentMeshInfo(_seg2, false); var seg3 = new SegmentMeshInfo(_seg3, false); var _pairs = SegmentConnector_Accessor.GetSectionPairs(new List <SegmentMeshInfo>() { seg1, seg2, seg3 }, an); Assert.AreEqual(_pairs.Count, 2); Assert.AreEqual(_pairs[0].bone, an.bones[0]); Assert.AreEqual(_pairs[0].meshInfo1, seg1); Assert.AreEqual(_pairs[0].meshInfo2, seg2); Assert.AreEqual(_pairs[1].bone, an.bones[1]); Assert.AreEqual(_pairs[1].meshInfo1, seg2); Assert.AreEqual(_pairs[1].meshInfo2, seg3); }