Solid Canonicalized() { if (IsCanonicalized) { return(this); } else { var factory = new FuzzyCsgFactory(); var result = factory.GetCsg(Polygons); return(new Solid(result, true, this.IsRetesselated)); } }
Solid Canonicalized() { if (IsCanonicalized) { return(this); } else { var factory = new FuzzyCsgFactory(); var result = factory.GetCsg(this); result.IsCanonicalized = true; result.IsRetesselated = IsRetesselated; result.Properties = Properties; return(result); } }
public List <Solid> SubtractAndPartition(params Solid[] csgs) { var a = new Tree(Bounds, Polygons); bool reteselate = !IsRetesselated; bool cannonicalize = !IsCanonicalized; foreach (var csg in csgs) { if (!csg.IsCanonicalized) { cannonicalize = true; } if (!csg.IsRetesselated) { reteselate = true; } var b = new Tree(csg.Bounds, csg.Polygons); a.Invert(); a.ClipTo(b); b.ClipTo(a, true); a.AddPolygons(b.AllPolygons()); a.Invert(); } IEnumerable <IReadOnlyList <Polygon> > result = PartitionPolygons(a.AllPolygons()); if (reteselate) { result = result.Select(poly => Reteselate(poly, cannonicalize)); } else { if (cannonicalize) { result = result.Select(polys => { var factory = new FuzzyCsgFactory(); return(factory.GetCsg(polys)); }); } } return(result.Select(polys => new Solid(polys, true, true)).ToList()); }