//this is an example of how to use receiveAdditionalAdditiveContours(), actual implementations will likely use it to feed online data instead of slices from STL files public unsafe void addAdditionalAdditiveContour(double z, ExternalSlicerManager external) { void *slice = feedRawSliceIntoDll(external.readSlice()); try { dll.receiveAdditionalAdditiveContours(state, z * dll.factor_input_to_internal, slice); } finally { dll.freeInputSlice(slice); } }
//2d simple multislicing private unsafe void multislice_2dsimple(SI.ExternalSlicerManager external, SI.MultiSlicerHandler handler, bool alsoContours, Transaction tr, BlockTableRecord btr) { double zstep = handler.z_uniform_step; double[] zs = handler.use_z_base ? external.prepareSTLSimple(zstep, handler.z_base) : external.prepareSTLSimple(zstep); int numslices = zs.Length; for (int i = 0; i < numslices; ++i) { SI.IntPoint[][] rawslice = external.readSlice(); if (rawslice.Length == 0) { continue; } if (alsoContours) { showExternalSlice(rawslice, external.scalingFactor, zs[i], tr, btr); } void *slice = handler.feedRawSliceIntoDll(rawslice); rawslice = null; void *result = handler.computeSlice2D(slice); //the slice is freed in computeSlice2D() if (result == null) { throw new ApplicationException("Error in compute2D: " + dll.err); } try { const bool mode2D = true; int ntools = handler.numProcesses; for (int j = 0; j < ntools; ++j) { readOutputSlices(result, mode2D, alsoContours, zs[i], j, tr, btr); } } finally { if (result != null) { dll.freeResult(result); } } } }
//use only external slice public void externalSlice(string configname, double zstep, string stlfile_arg) { doActionForFile(configname, stlfile_arg, (string stlfile) => { using (SI.ExternalSlicerManager external = createExternalSlicerManager(stlfile)) { try { double[] zs = external.prepareSTLSimple(zstep); int numslices = zs.Length; double scalingFactor = external.scalingFactor; modifyAutoCADDocument((Transaction tr, BlockTableRecord btr) => { for (int i = 0; i < numslices; ++i) { SI.IntPoint[][] paths = external.readSlice(); showExternalSlice(paths, scalingFactor, zs[i], tr, btr); } }); } catch { external.terminate(); throw; } } }); }
//multislicing with 3d scheduling private unsafe void multislice_3dscheduler(SI.ExternalSlicerManager external, SI.MultiSlicerHandler handler, bool alsoContours, Transaction tr, BlockTableRecord btr) { double minx, maxx, miny, maxy, minz, maxz; external.getBoundingBox(out minx, out maxx, out miny, out maxy, out minz, out maxz); double[] zs = handler.getSlicesZs(minz, maxz); external.sendZs(zs); for (int i = 0; i < zs.Length; ++i) { SI.IntPoint[][] rawslice = external.readSlice(); if ((rawslice.Length > 0) && (alsoContours)) { showExternalSlice(rawslice, external.scalingFactor, zs[i], tr, btr); } //here, it may be the moment to use dll.receiveAdditionalAdditiveContours() if we were using online feedback... void *slice = handler.feedRawSliceIntoDll(rawslice); rawslice = null; handler.feedSliceToScheduler(slice); //the slice is freed in feedSliceToScheduler() while (true) { void *result = handler.getResultFromScheduler(); if (result == null) { break; } try { const bool mode2D = false; const double z_not_used = 0.0; //for !mode2D, z is not used const int single_sliceIdx = 0; //for !mode2D, there is a single result, not one for each tool readOutputSlices(result, mode2D, alsoContours, z_not_used, single_sliceIdx, tr, btr); } finally { dll.freeResult(result); } } } }