public void Build(List <Polygon> polygons) { if (polygons.Count == 0) { return; } if (Plane == null) { Plane = polygons[0].Plane.Clone(); } var pp = Plane.ToPrecisionPlane(); var front = new List <Polygon>(); var back = new List <Polygon>(); foreach (var polygon in polygons.Select(x => x.ToPrecisionPolygon())) { polygon.Split(pp, out var b, out var f, out var cb, out var cf); if (f != null) { front.Add(f.ToStandardPolygon()); } if (b != null) { back.Add(b.ToStandardPolygon()); } if (cf != null) { front.Add(cf.ToStandardPolygon()); } if (cb != null) { back.Add(cb.ToStandardPolygon()); } } if (front.Count > 0) { if (Front == null) { Front = new CsgNode(); } Front.Build(front); } if (back.Count > 0) { if (Back == null) { Back = new CsgNode(); } Back.Build(back); } }
public void Build(List <Polygon> polygons) { if (polygons.Count == 0) { return; } if (Plane == null) { Plane = polygons[0].Plane.Clone(); } var front = new List <Polygon>(); var back = new List <Polygon>(); foreach (var polygon in polygons) { Polygon f, b, cf, cb; polygon.Split(Plane, out b, out f, out cb, out cf); if (f != null) { front.Add(f); } if (b != null) { back.Add(b); } if (cf != null) { Polygons.Add(cf); } if (cb != null) { Polygons.Add(cb); } } if (front.Count > 0) { if (Front == null) { Front = new CsgNode(); } Front.Build(front); } if (back.Count > 0) { if (Back == null) { Back = new CsgNode(); } Back.Build(back); } }