private void RunThread() { RaiseEvent(eCSGEvent.eStarted, "", null); try { List <csgjs_polygon> a = ConvertTo(m_obj1); List <csgjs_polygon> b = ConvertTo(m_obj2); csgjs_csgnode A = new csgjs_csgnode(a); csgjs_csgnode B = new csgjs_csgnode(b); csgjs_csgnode AB = null; switch (m_op) { case eCSGOp.eIntersection: AB = csgjs_csgnode.csg_intersect(A, B); break; case eCSGOp.eSubtraction: AB = csgjs_csgnode.csg_subtract(A, B); break; case eCSGOp.eUnion: AB = csgjs_csgnode.csg_union(A, B); break; } //raise an event Object3d res = ConvertFrom(AB.allPolygons()); RaiseEvent(eCSGEvent.eCompleted, "", res); } catch (Exception ex) { DebugLogger.Instance().LogError(ex); RaiseEvent(eCSGEvent.eError, "", null); } m_running = false; }
private Object3d Intersect(Object3d obj1, Object3d obj2) { List <csgjs_polygon> a = ConvertTo(obj1); List <csgjs_polygon> b = ConvertTo(obj2); csgjs_csgnode A = new csgjs_csgnode(a); csgjs_csgnode B = new csgjs_csgnode(b); csgjs_csgnode AB = csgjs_csgnode.csg_intersect(A, B); return(ConvertFrom(AB.allPolygons())); }
// Return a new CSG solid representing space in either this solid or in the // solid `csg`. Neither this solid nor the solid `csg` are modified. public static csgjs_csgnode csg_union(csgjs_csgnode a1, csgjs_csgnode b1) { csgjs_csgnode a = a1.clone(); csgjs_csgnode b = b1.clone(); a.clipTo(b); b.clipTo(a); b.invert(); b.clipTo(a); b.invert(); a.build(b.allPolygons()); csgjs_csgnode ret = new csgjs_csgnode(a.allPolygons()); a = null; b = null; return(ret); }
// Return a list of all polygons in this BSP tree. public List <csgjs_polygon> allPolygons() { List <csgjs_polygon> list = new List <csgjs_polygon>(); foreach (csgjs_polygon p in polygons) { list.Add(p.clone()); } List <csgjs_polygon> list_front = new List <csgjs_polygon>(); List <csgjs_polygon> list_back = new List <csgjs_polygon>(); if (front != null) { list_front = front.allPolygons(); } if (back != null) { list_back = back.allPolygons(); } //list.insert(list.end(), list_front.begin(), list_front.end()); //list.insert(list.end(), list_back.begin(), list_back.end()); foreach (csgjs_polygon pf in list_front) { list.Add(pf.clone()); } foreach (csgjs_polygon pb in list_back) { list.Add(pb.clone()); } return(list); }