Share
 
 

About postprocessing

The postprocessing step takes place after toolpaths have been calculated for all parts on the tray. The toolpath creation step is done for each part individually and happens multi-threaded layer by layer. Therefore, it is not possible to achieve certain tasks in this step, e.g. sorting the toolpaths on a layer from left to right. It would only be possible to sort the toolpaths of one part from left to right.

In postprocessing the whole tray is available with all calculated toolpaths. This makes it possible to optimize the toolpaths on each layer, e.g. to reduce traveling time in between parts or to assign toolpaths to individual lasers.

As part of the configuration step there is a script function configurePostProcessingSteps which is used to configure the postprocessing step. Here is an example for the implementation of the configurePostProcessingSteps function:

/** 
* @param  a_config    bsPostProcessingConfig 
*/
exports.configurePostProcessingSteps = function(a_config)
{  
  // 1. Sorting the toolpaths and calculate build time for each layer
  a_config.addPostProcessingStep(
    postprocessLayerStack_MT,{bMultithread: true, nProgressWeight: 10});
  
  // 2. Collecting the resulting build times from all layers 
  // and store the total time on the tray.
  a_config.addPostProcessingStep(
    postprocessLayerStack_ST,{bMultithread: false, nProgressWeight: 1});
}

The script function is registering other script functions to be called by the application to perform the postprocessing. Any number of functions can be registered, which will be called in the given order. The functions can be multi-threaded for time consuming tasks as well as single-threaded for tasks which require to analyze the data on the tray with a single thread. A progress weight is controlling the progress bar behavior of the main application while doing the postprocessing.

The functions named here must exist in the same script module. In this example, the first one (postprocessLayerStack_MT) will be called multiple times by multiple threads, each time with another range of layers. The second one (postprocessLayerStack_ST) will only be called once for the whole range of layers on the tray.

/** 
 * Multithreaded post-processing. This function may be called
 * several times with a different layer range.
 * @param  a_modelData        bsModelData
 * @param  a_progress         bsProgress
 * @param  a_layer_start_nr   Integer. First layer to process
 * @param  a_layer_end_nr     Integer. Last layer to process
 */
var postprocessLayerStack_MT = function(
  a_modelData, 
  a_progress, 
  a_layer_start_nr, 
  a_layer_end_nr)
{      
  a_progress.initSteps(a_layer_end_nr - a_layer_start_nr + 1);
      
  for(let layer_nr = a_layer_start_nr; layer_nr <= a_layer_end_nr; ++layer_nr)
  {          
    var exposure_array = a_modelData.getLayerPolylineArray(
      layer_nr, POLY_IT.nLayerExposure, "rw");    
        
    // Doing something with the toolpaths of each layer,
    // but only within the given range of layers because the function
    // will be called again by another thread with another range of layers    
        
    a_progress.step(1);
  }
};
/** 
 * Single threaded post-processing. This function will be called only once
 * with the full layer range
 * @param  a_modelData        bsModelData
 * @param  a_progress         bsProgress
 * @param  a_layer_start_nr   Integer. First layer to process
 * @param  a_layer_end_nr     Integer. Last layer to process
 */
var postprocessLayerStack_ST = function(
  a_modelData, 
  a_progress, 
  a_layer_start_nr, 
  a_layer_end_nr)
{  
  a_progress.initSteps(a_layer_end_nr - a_layer_start_nr + 1);
  
  var layer_iter = a_modelData.getPreferredLayerProcessingOrderIterator(
      a_layer_start_nr, a_layer_end_nr, POLY_IT.nLayerExposure);
    
  while(layer_iter.isValid() && !a_progress.cancelled())
  {        
    var layer_nr = layer_iter.getLayerNr();

    var exposure_array = a_modelData.getLayerPolylineArray(
      layer_nr, POLY_IT.nLayerExposure, "rw");    
        
    // Doing something with the toolpaths of each layer
           
    layer_iter.next();
    a_progress.step(1);
  }  
}

For backward compatibility it is possible to not provide the function configurePostProcessingSteps.

In that case it is possible to have no postprocessing at all or to have just one single threaded function which must be exported:

/** 
 * Postprocessing step. This function gets a whole tray of build parts
 * @param  modelData        bsModelData
 * @param  progress         bsProgress
 * @param  layer_start_nr   Integer. First layer to process
 * @param  layer_end_nr     Integer. Last layer to process
 */
exports.postprocessLayerStack = function(
  modelData, 
  progress, 
  layer_start_nr, 
  layer_end_nr)
{
  
}

Was this information helpful?