// TODO : Tie up the loose ends (Hole loop) public Face Do(Vertex startV, Vertex endV, Edge prevLE, Edge prevRE, Edge nextLE, Edge nextRE, out Edge newE, out Loop oldL, out Loop newL) { newE = null; oldL = newL = null; // 分離可能なループを探す var separableL = FindSeparableLoop(prevLE, prevRE, nextLE, nextRE); if (separableL == null) { throw new System.Exception("[MEF.cs/Do] 分離可能なループが見つかりませんでした"); } oldL = separableL; var hostShell = separableL.Host.Host; newE = Archetype.NewEdge(); newE.ConnectStart(startV); newE.ConnectEnd(endV); var newF = Archetype.NewFace(); newL = Archetype.NewLoop(); // Link hostShell.Connect(newF); newF.ConnectFrame(newL); // ハーフエッジの Link を編集 EditLinksOfHalfEdges(newE, prevLE, prevRE, nextLE, nextRE); // ループの更新 (Left を新規にする) newE.Left.HostLoop = newL; newE.Right.HostLoop = separableL; UpdateNewLoopLinks(newE.Left, newL); // ホールがある場合はホールループの振分けを幾何演算を使って行う //... return(newF); }
public Shell Do(Vector3d position, out Vertex newVertex, out Loop newLoop, out Face newFace) { // インスタンス生成 var newShell = Archetype.NewShell(); newFace = Archetype.NewFace(); newLoop = Archetype.NewLoop(); newVertex = Archetype.NewVertex(); // 座標設定 newVertex.Position = position; // リンク newShell.Connect(newFace); newFace.ConnectFrame(newLoop); newLoop.Isolated = newVertex; newVertex.Isolated = newLoop; return(newShell); }
public Vertex DoSpurEv(Vector3d vPos, Vertex startV, Edge prevLE, Edge prevRE, out Edge newE) { var endV = Archetype.NewVertex(); endV.Position = vPos; newE = Archetype.NewEdge(); newE.ConnectStart(startV); newE.ConnectEnd(endV); if (startV.Isolated != null) { // ■→ // ◇ ==> ◇――→● // ←■ var lHalf = new HalfEdge { HostLoop = startV.Isolated }; var rHalf = new HalfEdge { HostLoop = startV.Isolated }; newE.ConnectLeft(lHalf); newE.ConnectRight(rHalf); // Make link of halfedge lHalf.Next = lHalf.Prev = rHalf; rHalf.Next = rHalf.Prev = lHalf; // Link : loop -> halfedge lHalf.HostLoop.First = lHalf; // Reset Isolated startV.Isolated.Isolated = null; startV.Isolated = null; } else { Debug.Assert(prevLE != null && prevRE != null && prevLE.Contains(startV)); if (prevLE == prevRE) { var lHalf = new HalfEdge { HostLoop = prevLE.Right.HostLoop }; var rHalf = new HalfEdge { HostLoop = prevLE.Right.HostLoop }; newE.ConnectLeft(lHalf); newE.ConnectRight(rHalf); lHalf.Next = rHalf; rHalf.Prev = lHalf; // Halfedge はそのリンクが自然になるようにつなげる if (prevLE.Start == startV) { // R→ R→ ■→ // ○←――◇ ==> ○←――◇――→● // ←L ←L ←■ // Make link of halfedge lHalf.Prev = prevLE.Right; prevLE.Right.Next = lHalf; rHalf.Next = prevLE.Left; prevLE.Left.Prev = rHalf; } else // prevLE.End == startV // L→ L→ ■→ // ○――→◇ ==> ○――→◇――→● // ←R ←R ←■ // Make link of halfedge { lHalf.Prev = prevLE.Left; prevLE.Left.Next = lHalf; rHalf.Next = prevLE.Right; prevLE.Right.Prev = rHalf; } } else { Debug.Assert(prevRE.Contains(startV)); var lHalf = new HalfEdge(); var rHalf = new HalfEdge(); newE.ConnectLeft(lHalf); newE.ConnectRight(rHalf); lHalf.Next = rHalf; rHalf.Prev = lHalf; if (prevRE.Start == startV) { // L→ // ○―――◇――→○ // ←R lHalf.HostLoop = rHalf.HostLoop = prevRE.Left.HostLoop; if (prevLE.Start == startV) { // ● // ↑↑ // ■|■ // |↓ // R→ L→ R→| L→ // ○←――◇――→○ ==> ○←――◇――→○ // ←L ←R ←L ←R // Make link of halfedge lHalf.Prev = prevLE.Right; prevLE.Right.Next = lHalf; rHalf.Next = prevRE.Left; prevRE.Left.Prev = rHalf; } else { // ● // ↑↑ // ■|■ // |↓ // L→ L→ L→| L→ // ○――→◇――→○ ==> ○――→◇――→○ // ←R ←R ←R ←R // Make link of halfedge lHalf.Prev = prevLE.Left; prevLE.Left.Next = lHalf; rHalf.Next = prevRE.Left; prevRE.Left.Prev = rHalf; } } else { // R→ // ○―――◇←――○ // ←L lHalf.HostLoop = rHalf.HostLoop = prevRE.Right.HostLoop; if (prevLE.Start == startV) { // ● // ↑↑ // ■|■ // |↓ // R→ R→ R→| R→ // ○←――◇←――○ ==> ○←――◇←――○ // ←L ←L ←L ←L // Make link of halfedge lHalf.Prev = prevLE.Right; prevLE.Right.Next = lHalf; rHalf.Next = prevRE.Right; prevRE.Right.Prev = rHalf; } else { // ● // ↑↑ // ■|■ // |↓ // L→ R→ L→| R→ // ○――→◇←――○ ==> ○――→◇←――○ // ←R ←L ←R ←L // Make link of halfedge lHalf.Prev = prevLE.Left; prevLE.Left.Next = lHalf; rHalf.Next = prevRE.Right; prevRE.Right.Prev = rHalf; } } } } return(endV); }