void NS_DIM_PREFIX BulletPlot(void) { #ifdef ModelP INT son; #endif void *scratch; /* reuse z buffer if possible */ if (BulletDim == 3 && sizeof(ZTYP) >= 4) scratch = ZBuffer; else scratch = NULL; /* merge buffers */ #ifdef ModelP for (son = degree-1; son >= 0; son--) { GetConcentrate(son, ABuffer, Length); MergeBuffers(ZBuffer, ABuffer); } Concentrate(ZBuffer, Length); if (me == master) #endif { FramePicture(); (*OutputDevice->PlotPixelBuffer)(PBuffer, scratch, XShift, YShift, Width, Height); } }
void avtWholeImageCompositerWithZ::Execute(void) { int numRows = 0; int numCols = 0; float *ioz = NULL; float *rioz = NULL; unsigned char *iorgb = NULL; unsigned char *riorgb = NULL; vtkImageData *mergedLocalImage = NULL; vtkImageData *mergedGlobalImage = NULL; // sanity checks if (inputImages.size() == 0) EXCEPTION0(ImproperUseException); for (size_t i = 0; i < inputImages.size(); i++) { inputImages[i]->GetImage().GetSize(&numRows, &numCols); if (numRows != outRows || numCols != outCols) EXCEPTION0(ImproperUseException); } int nPixels = outRows * outCols; avtImageRepresentation &zeroImageRep = inputImages[0]->GetImage(); if (inputImages.size() > 1) { // // Merge within a processor // int t1 = visitTimer->StartTimer(); mergedLocalImage = avtImageRepresentation::NewImage(outCols, outRows); visitTimer->StopTimer(t1, "Allocating image"); iorgb = (unsigned char *) mergedLocalImage->GetScalarPointer(0, 0, 0); ioz = new float [nPixels]; float *z0 = zeroImageRep.GetZBuffer(); const unsigned char *rgb0 = zeroImageRep.GetRGBBuffer(); // we memcpy because we can't alter any of the input images int t2 = visitTimer->StartTimer(); memcpy(ioz, z0, nPixels * sizeof(float)); memcpy(iorgb, rgb0, nPixels * 3 * sizeof(unsigned char)); visitTimer->StopTimer(t2, "Mem copies"); // do the merges, accumulating results in ioz and iorgb int t3 = visitTimer->StartTimer(); for (size_t i = 1; i < inputImages.size(); i++) { float *z = NULL; z = inputImages[i]->GetImage().GetZBuffer(); const unsigned char *rgb = inputImages[i]->GetImage().GetRGBBuffer(); MergeBuffers(nPixels, false, z, rgb, ioz, iorgb); } visitTimer->StopTimer(t3, "merging multiple images"); } else { mergedLocalImage = NULL; ioz = zeroImageRep.GetZBuffer(); iorgb = zeroImageRep.GetRGBBuffer(); } if (mpiRoot >= 0) { // only root allocates output AVT image (for a non-allreduce) if (allReduce || mpiRank == mpiRoot) { mergedGlobalImage = avtImageRepresentation::NewImage(outCols, outRows); riorgb = (unsigned char *) mergedGlobalImage->GetScalarPointer(0, 0, 0); rioz = new float [nPixels]; } // // Merge across processors // int t4 = visitTimer->StartTimer(); MergeBuffers(nPixels, true, ioz, iorgb, rioz, riorgb); visitTimer->StopTimer(t4, "MergeBuffers"); if (mergedLocalImage != NULL) { mergedLocalImage->Delete(); delete [] ioz; } if (allReduce || mpiRank == mpiRoot) { if (shouldOutputZBuffer) { avtImageRepresentation theOutput(mergedGlobalImage,rioz,true); SetOutputImage(theOutput); } else { delete [] rioz; avtImageRepresentation theOutput(mergedGlobalImage); SetOutputImage(theOutput); } mergedGlobalImage->Delete(); } else { avtImageRepresentation theOutput(NULL); SetOutputImage(theOutput); } } else { if (mergedLocalImage != NULL) { if (shouldOutputZBuffer) { avtImageRepresentation theOutput(mergedLocalImage,ioz,true); SetOutputImage(theOutput); } else { delete [] ioz; avtImageRepresentation theOutput(mergedLocalImage); SetOutputImage(theOutput); } mergedLocalImage->Delete(); } else { avtImageRepresentation theOutput(zeroImageRep); SetOutputImage(theOutput); } } }