#region ================== Copyright (c) 2007 Pascal vd Heiden /* * Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com * This program is released under GNU General Public License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #endregion #region ================== Namespaces using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Text; using CodeImp.DoomBuilder.Geometry; using CodeImp.DoomBuilder.Rendering; using SlimDX.Direct3D9; using System.Drawing; using CodeImp.DoomBuilder.Map; #endregion namespace CodeImp.DoomBuilder.Geometry { public class SidedefsTracePath : List { #region ================== Constants #endregion #region ================== Variables #endregion #region ================== Properties #endregion #region ================== Constructor / Disposer // Constructor public SidedefsTracePath() { // Initialize } // Constructor public SidedefsTracePath(SidedefsTracePath p, Sidedef add) : base(p) { // Initialize base.Add(add); } #endregion #region ================== Methods // This checks if the polygon is closed public bool CheckIsClosed() { // There must be at least 2 sidedefs if(base.Count > 1) { // The end sidedef must share a vertex with the first return (base[0].Line.Start == base[base.Count - 1].Line.Start) || (base[0].Line.Start == base[base.Count - 1].Line.End) || (base[0].Line.End == base[base.Count - 1].Line.Start) || (base[0].Line.End == base[base.Count - 1].Line.End); } else { // Not closed return false; } } // This makes a polygon from the path public Polygon MakePolygon() { Polygon p = new Polygon(); // Any sides at all? if(base.Count > 0) { // Add all sides for(int i = 0; i < base.Count; i++) { // On front or back? if(base[i].IsFront) p.AddLast(new EarClipVertex(base[i].Line.End.Position)); else p.AddLast(new EarClipVertex(base[i].Line.Start.Position)); } } return p; } #endregion } }