void Add(OutLine newOne) { //子节点的下级 foreach (var OutLine in OutLines) { if (OutLine.Contains(newOne)) { OutLine.Add(newOne); return; } } //子节点的上级 bool isTopLevel = false; for (int i = OutLines.Count() - 1; i >= 0; i--) { var SubOutLine = OutLines[i]; if (newOne.Contains(SubOutLine)) { OutLines.Remove(SubOutLine); SubOutLine.RevertAllOutLineType(); newOne.SubOutLines.Add(SubOutLine); isTopLevel = true; } } if (isTopLevel) { newOne.IsSolid = true; OutLines.Add(newOne); return; } //无相关的新节点 OutLines.Add(newOne); }
//public bool IsInit { get { return Edges != null; } } //public OutLine() //{ //} //void Add(EdgeArray edgeArray) //{ // if (!IsInit) // { // Init(edgeArray); // } // else // { // Add(new OutLine(edgeArray)); // } //} //public OutLine Add(EdgeArrayArray edgeLoops) //{ // var current = this; // //闭合区间集合,EdgeArray // foreach (EdgeArray edgeArray in edgeLoops) // { // if (!IsInit) // { // Init(edgeArray); // continue; // } // current= current.Add(new OutLine(edgeArray)); // } // return current; //} public void Add(OutLine newOne) { //当前节点下级的上级 bool isTopLevel = false; for (int i = SubOutLines.Count() - 1; i >= 0; i--) { var outLine = SubOutLines[i]; if (newOne.Contains(outLine)) { SubOutLines.Remove(outLine); outLine.RevertAllOutLineType(); newOne.SubOutLines.Add(outLine); isTopLevel = true; } } if (isTopLevel) { newOne.IsSolid = !IsSolid; SubOutLines.Add(newOne); return; } //当前节点下级的下级 for (int i = SubOutLines.Count() - 1; i >= 0; i--) { var outLine = SubOutLines[i]; if (outLine.Contains(newOne)) { outLine.Add(newOne); return; } } //与其他下级无关联 newOne.IsSolid = !IsSolid; SubOutLines.Add(newOne); return; }