static bool FindCommonInsideEdges(AnalyzedTriangle a, AnalyzedTriangle b, out InsideEdgeLine a_edge, out InsideEdgeLine b_edge) { //2 contact triangles share GlyphBoneJoint. EdgeLine find_b_edge = b.e0; InsideEdgeLine matching_inside_edge_of_a = null; if ((matching_inside_edge_of_a = FindCommonInsideEdge(a, find_b_edge)) != null) { //found a_edge = matching_inside_edge_of_a; b_edge = (InsideEdgeLine)find_b_edge; return(true); } //-------------- find_b_edge = b.e1; if ((matching_inside_edge_of_a = FindCommonInsideEdge(a, find_b_edge)) != null) { //found a_edge = matching_inside_edge_of_a; b_edge = (InsideEdgeLine)find_b_edge; return(true); } find_b_edge = b.e2; if ((matching_inside_edge_of_a = FindCommonInsideEdge(a, find_b_edge)) != null) { //found a_edge = matching_inside_edge_of_a; b_edge = (InsideEdgeLine)find_b_edge; return(true); } a_edge = b_edge = null; return(false); }
static void CreateBoneJointIfNeed( InsideEdgeLine insideEdge, AnalyzedTriangle first_p_tri, Joint firstJoint, List <Bone> newlyCreatedBones, List <Bone> glyphBones) { if (insideEdge != null && insideEdge._inside_joint == null) { InsideEdgeLine mainEdge = insideEdge; EdgeLine nbEdge = null; if (FindSameCoordEdgeLine(first_p_tri.N0, mainEdge, out nbEdge) || FindSameCoordEdgeLine(first_p_tri.N1, mainEdge, out nbEdge) || FindSameCoordEdgeLine(first_p_tri.N2, mainEdge, out nbEdge)) { //confirm that nbEdge is INSIDE edge if (nbEdge.IsInside) { Joint joint = new Joint((InsideEdgeLine)nbEdge, mainEdge); Bone bone = new Bone(mainEdge._inside_joint, firstJoint); newlyCreatedBones.Add(bone); glyphBones.Add(bone); } else { //? } } else { //? } } }
static void CreateTipBoneIfNeed( InsideEdgeLine insideEdge, Joint joint, List <Bone> newlyCreatedBones, List <Bone> glyphBones) { if (insideEdge != null && insideEdge._inside_joint != null && insideEdge._inside_joint != joint) { //create connection Bone tipBone = new Bone(insideEdge._inside_joint, joint); newlyCreatedBones.Add(tipBone); glyphBones.Add(tipBone); } }
internal Joint( InsideEdgeLine p_contact_edge, InsideEdgeLine q_contact_edge) { //both p and q is INSIDE, contact edge _p_contact_edge = p_contact_edge; _q_contact_edge = q_contact_edge; //this is original x,y Vector2f midpos = p_contact_edge.GetMidPoint(); _fitX = midpos.X; _fitY = midpos.Y; #if DEBUG if (p_contact_edge._inside_joint != null || q_contact_edge._inside_joint != null) { throw new System.NotSupportedException(); } #endif p_contact_edge._inside_joint = this; q_contact_edge._inside_joint = this; }