void DrawBoneLinks(CentroidLine line) { #if DEBUG List <GlyphBone> glyphBones = line.bones; int glyphBoneCount = glyphBones.Count; int startAt = 0; int endAt = startAt + glyphBoneCount; OnBeginDrawingBoneLinks(line.GetHeadPosition(), startAt, endAt); int nn = 0; for (int i = startAt; i < endAt; ++i) { //draw line OnDrawBone(glyphBones[i], nn); nn++; } OnEndDrawingBoneLinks(); #endif ////draw link between each branch to center of hub //var brHead = branch.GetHeadPosition(); //painter.Line( // hubCenter.X * pxscale, hubCenter.Y * pxscale, // brHead.X * pxscale, brHead.Y * pxscale); ////draw a line link to centroid of target triangle //painter.Line( // (float)brHead.X * pxscale, (float)brHead.Y * pxscale, // hubCenter.X * pxscale, hubCenter.Y * pxscale, // PixelFarm.Drawing.Color.Red); }
{ //utils public static Vector2 GetHeadPosition(this CentroidLine line) { //after create bone process List <GlyphBone> bones = line.bones; if (bones.Count == 0) { return(Vector2.Zero); } else { //TODO: review here //use jointA of bone of join B of bone return(bones[0].JointA.OriginalJointPos); } }
public bool FindBoneJoint(GlyphTriangle tri, out CentroidLine foundOnBranch, out GlyphBoneJoint foundOnJoint) { foreach (CentroidLine line in _lines.Values) { if ((foundOnJoint = line.FindNearestJoint(tri)) != null) { foundOnBranch = line; return(true); } } foundOnBranch = null; foundOnJoint = null; return(false); }
/// <summary> /// set current centroid line to a centroid line that starts with triangle of centroid-line-head /// </summary> /// <param name="triOfCentroidLineHead"></param> public void SetCurrentCentroidLine(GlyphTriangle triOfCentroidLineHead) { //this method is used during centroid line hub creation if (currentBranchTri != triOfCentroidLineHead) { //check if we have already create it if (!_lines.TryGetValue(triOfCentroidLineHead, out currentLine)) { //if not found then create new currentLine = new CentroidLine(); #if DEBUG currentLine.dbugStartTri = triOfCentroidLineHead; #endif _lines.Add(triOfCentroidLineHead, currentLine); } currentBranchTri = triOfCentroidLineHead; } }
public void CollectBoneGroups(CentroidLine line) { // _tmpBoneGroups.Clear(); line.ApplyGridBox(_tmpBoneGroups, gridBoxW, gridBoxH); // for (int i = _tmpBoneGroups.Count - 1; i >= 0; --i) { //this version, we focus on horizontal bone group BoneGroup boneGroup = _tmpBoneGroups[i]; switch (boneGroup.slopeKind) { case LineSlopeKind.Horizontal: _selectedHorizontalBoneGroups.Add(boneGroup); break; case LineSlopeKind.Vertical: _selectedVerticalBoneGroups.Add(boneGroup); break; } } _tmpBoneGroups.Clear(); }
public void SetHeadConnnection(CentroidLine anotherCentroidLine, GlyphBoneJoint foundOnJoint) { this.anotherCentroidLine = anotherCentroidLine; this.foundOnJoint = foundOnJoint; }
public BoneGroup(CentroidLine ownerCentroidLine) { this.ownerCentroidLine = ownerCentroidLine; }