Exemple #1
0
long double MoonPhase(long double jdt)
{
	static long double d1, d2;

	if (jdt > d2){
		d1 = d2;
		if (d1 == 0) d1 = MoonPhasePrevious(jdt, 0);
		d2 = Squeeze(d1 + 30, 0);
	}
	return jdt - d1;
}
Exemple #2
0
static int 
compress_keccak (uint8_t *out, const uint8_t *blocks[], unsigned int blocks_to_comp)
{
  spongeState sponge;

  if (InitSponge (&sponge, KECCAK_RATE, KECCAK_CAPACITY))
    return ERROR_KECCAK;

  for (unsigned int i = 0; i < blocks_to_comp; i++) {
    if (Absorb (&sponge, blocks[i], 8 * KECCAK_1600_BLOCK_SIZE))
      return ERROR_KECCAK;
  }
  
  if (Squeeze (&sponge, out, 8 * KECCAK_1600_BLOCK_SIZE))
    return ERROR_KECCAK;

  return ERROR_NONE;
}
Exemple #3
0
/**
Create the vtkStructuredGrid from the provided workspace
@param progressUpdating: Reporting object to pass progress information up the
stack.
@return fully constructed vtkDataSet.
*/
vtkSmartPointer<vtkDataSet>
vtkMDLineFactory::create(ProgressAction &progressUpdating) const {
  auto product = tryDelegatingCreation<IMDEventWorkspace, 1>(m_workspace,
                                                             progressUpdating);
  if (product != nullptr) {
    return product;
  } else {
    g_log.warning() << "Factory " << this->getFactoryTypeName()
                    << " is being used. You are viewing data with less than "
                       "three dimensions in the VSI. \n";

    IMDEventWorkspace_sptr imdws =
        doInitialize<IMDEventWorkspace, 1>(m_workspace);
    // Acquire a scoped read-only lock to the workspace (prevent segfault from
    // algos modifying ws)
    Mantid::Kernel::ReadLock lock(*imdws);

    const size_t nDims = imdws->getNumDims();
    size_t nNonIntegrated = imdws->getNonIntegratedDimensions().size();

    /*
    Write mask array with correct order for each internal dimension.
    */
    auto masks = Mantid::Kernel::make_unique<bool[]>(nDims);
    for (size_t i_dim = 0; i_dim < nDims; ++i_dim) {
      bool bIntegrated = imdws->getDimension(i_dim)->getIsIntegrated();
      masks[i_dim] =
          !bIntegrated; // TRUE for unmaksed, integrated dimensions are masked.
    }

    // Ensure destruction in any event.
    boost::scoped_ptr<IMDIterator> it(
        createIteratorWithNormalization(m_normalizationOption, imdws.get()));

    // Create 2 points per box.
    vtkNew<vtkPoints> points;
    points->SetNumberOfPoints(it->getDataSize() * 2);

    // One scalar per box
    vtkNew<vtkFloatArray> signals;
    signals->Allocate(it->getDataSize());
    signals->SetName(vtkDataSetFactory::ScalarName.c_str());
    signals->SetNumberOfComponents(1);

    size_t nVertexes;

    auto visualDataSet = vtkSmartPointer<vtkUnstructuredGrid>::New();
    visualDataSet->Allocate(it->getDataSize());

    vtkNew<vtkIdList> linePointList;
    linePointList->SetNumberOfIds(2);

    Mantid::API::CoordTransform const *transform = NULL;
    if (m_useTransform) {
      transform = imdws->getTransformToOriginal();
    }

    Mantid::coord_t out[1];
    auto useBox = std::vector<bool>(it->getDataSize());

    double progressFactor = 0.5 / double(it->getDataSize());
    double progressOffset = 0.5;

    size_t iBox = 0;
    do {
      progressUpdating.eventRaised(double(iBox) * progressFactor);

      Mantid::signal_t signal_normalized = it->getNormalizedSignal();
      if (std::isfinite(signal_normalized) &&
          m_thresholdRange->inRange(signal_normalized)) {
        useBox[iBox] = true;
        signals->InsertNextValue(static_cast<float>(signal_normalized));

        auto coords = std::unique_ptr<coord_t[]>(
            it->getVertexesArray(nVertexes, nNonIntegrated, masks.get()));

        // Iterate through all coordinates. Candidate for speed improvement.
        for (size_t v = 0; v < nVertexes; ++v) {
          coord_t *coord = coords.get() + v * 1;
          size_t id = iBox * 2 + v;
          if (m_useTransform) {
            transform->apply(coord, out);
            points->SetPoint(id, out[0], 0, 0);
          } else {
            points->SetPoint(id, coord[0], 0, 0);
          }
        }
      } // valid number of vertexes returned
      else {
        useBox[iBox] = false;
      }
      ++iBox;
    } while (it->next());

    for (size_t ii = 0; ii < it->getDataSize(); ++ii) {
      progressUpdating.eventRaised((double(ii) * progressFactor) +
                                   progressOffset);

      if (useBox[ii] == true) {
        vtkIdType pointIds = ii * 2;

        linePointList->SetId(0, pointIds + 0); // xyx
        linePointList->SetId(1, pointIds + 1); // dxyz
        visualDataSet->InsertNextCell(VTK_LINE, linePointList.GetPointer());
      } // valid number of vertexes returned
    }

    signals->Squeeze();
    points->Squeeze();

    visualDataSet->SetPoints(points.GetPointer());
    visualDataSet->GetCellData()->SetScalars(signals.GetPointer());
    visualDataSet->Squeeze();

    // Hedge against empty data sets
    if (visualDataSet->GetNumberOfPoints() <= 0) {
      vtkNullUnstructuredGrid nullGrid;
      visualDataSet = nullGrid.createNullData();
    }

    vtkSmartPointer<vtkDataSet> dataset = visualDataSet;
    return dataset;
  }
}
void CQDM_Edit::DrawMe(bool FastMode, bool ShowSelected, int NumBehindSection) //draws the digital part in initialized OpenGL window
//Show Selected highlights current sleceted voxel, Section view uses the currently selected axis and direction to show section, FadeBehindSelection optionally fades out the layers (for 2D view)
{
	int Selected = GetCurSel();
	if (!ShowSelected) Selected = -1; //don't draw the selected one...
	if (FastMode && NumBehindSection != LAYERMAX) NumBehindSection = 0; //in fast mode don't draw faded out ones...

	CVXC_Material* pMaterial;
	bool IsVis;
	int aS = Structure.GetArraySize();
	int x, y, z, MatIndex;
	int XMin=0, YMin=0, ZMin=0, XMax=LAYERMAX, YMax=LAYERMAX, ZMax=LAYERMAX;
	if (ViewSection){
		if (CurSecAxis == XAXIS){
			if (CurSecFromNeg){ XMin = CurSecLayer; XMax = CurSecLayer+NumBehindSection;}
			else {XMin = CurSecLayer-NumBehindSection; XMax = CurSecLayer;}
		}
		else if (CurSecAxis == YAXIS){
			if (CurSecFromNeg){ YMin = CurSecLayer; YMax = CurSecLayer+NumBehindSection;}
			else {YMin = CurSecLayer-NumBehindSection; YMax = CurSecLayer;}
		}
		else if (CurSecAxis == ZAXIS){
			if (CurSecFromNeg){ ZMin = CurSecLayer; ZMax = CurSecLayer+NumBehindSection;}
			else {ZMin = CurSecLayer-NumBehindSection; ZMax = CurSecLayer;}
		}
	}

	Vec3D<> Center;
	Vec3D<> Squeeze(Voxel.GetXSqueeze(), Voxel.GetYSqueeze(), Voxel.GetZSqueeze());
	double Dim = GetLatticeDim();
	Vec3D<> VoxEnv = GetLatDimEnv();
	Vec3D<> WS(GetVXDim()*VoxEnv.x, GetVYDim()*VoxEnv.y, GetVZDim()*VoxEnv.z);
	int NumCellAround = 0;
	if (ViewTiled) NumCellAround = 1;

	for (int ix=-NumCellAround; ix<=NumCellAround; ix++){ //for showing repeated unit cells
		for (int jy=-NumCellAround; jy<=NumCellAround; jy++){
			for (int kz=-NumCellAround; kz<=NumCellAround; kz++){
				if(ViewSection){ //don't draw ones that aren't in current plane section
					if (CurSecAxis == XAXIS && ix != 0) continue;
					else if (CurSecAxis == YAXIS && jy != 0) continue; 
					else if (CurSecAxis == ZAXIS && kz != 0) continue; 
				}

				glPushMatrix();
				glTranslated(ix*WS.x, jy*WS.y, kz*WS.z);


				for (int i = 0; i<aS; i++){ //go through all the voxels...
					GetXYZNom(&x, &y, &z, i);
					
					if (ViewSection && (x<XMin || x>XMax || y<YMin || y>YMax || z<ZMin || z>ZMax)) continue; //jump ship here if we're outside of the section view:

					MatIndex = Structure[i];
					if (MatIndex <= 0) continue; //don't draw if nothing there
					if (FastMode){ //disable picking, show selected, and resolving composite materials
						glColor3f(Palette[MatIndex].GetRedf(), Palette[MatIndex].GetGreenf(), Palette[MatIndex].GetBluef());
					}
					else { //NOT fastmode: enable picking, show selected, and resolve composite materials
						glLoadName(i); //to enable picking

						bool IsVis;
						pMaterial = GetLeafMat(i, &IsVis);
						if (pMaterial == NULL || !IsVis) continue;
						if (pMaterial->GetAlphai() == 0) continue;

						double FadeOut = 0.0;
						if (ViewSection && NumBehindSection != LAYERMAX){ //if there's fading out to be done...
							if (CurSecAxis == XAXIS) FadeOut = abs((double)(x - CurSecLayer))/(NumBehindSection+1);
							else if (CurSecAxis == YAXIS) FadeOut = abs((double)(y - CurSecLayer))/(NumBehindSection+1);
							else if (CurSecAxis == ZAXIS) FadeOut = abs((double)(z - CurSecLayer))/(NumBehindSection+1);

						}
						SetCurGLColor(pMaterial, i==Selected, FadeOut);

					}

					GetXYZ(&Center, i); 

					glPushMatrix();
					glTranslated(Center.x, Center.y, Center.z);
					glScaled(Dim*Squeeze.x, Dim*Squeeze.y, Dim*Squeeze.z);
					switch (Voxel.GetVoxName()){
						case VS_SPHERE:	CGL_Utils::DrawSphereFace(); break;
						case VS_BOX: CGL_Utils::DrawCubeFace(); break;
						case VS_CYLINDER: CGL_Utils::DrawCylFace(); break;
						default: break;
					}
					glPopMatrix();
				}

				if (!FastMode && Voxel.GetVoxName() != VS_SPHERE){ //no lines in fast mode or for spheres!
					glDisable(GL_LIGHTING);
					glLineWidth(1.0);
					for (int i = 0; i<aS; i++){ //go through all the voxels...
						GetXYZNom(&x, &y, &z, i);
						if (ViewSection && (x<XMin || x>XMax || y<YMin || y>YMax || z<ZMin || z>ZMax)) continue; //jump ship here if we're outside of the section view:


						if (Structure[i] <= 0) continue; //don't draw if nothing there
						glColor3f(0, 0, 0);
						GetXYZ(&Center, i); 

						glPushMatrix();
						glTranslated(Center.x, Center.y, Center.z);
						glScaled(Dim*Squeeze.x, Dim*Squeeze.y, Dim*Squeeze.z);
						switch (Voxel.GetVoxName()){
							case VS_BOX: CGL_Utils::DrawCubeEdge(); break;
							case VS_CYLINDER: CGL_Utils::DrawCylEdge(); break;
							default: break;
						}
						glPopMatrix();
					}
					glEnable(GL_LIGHTING);
				}
				glPopMatrix();
			}
		}
	}

	//if (!ViewSection){//if not in section mode, draw it all!
	//	//if(FastMode) 
	//		DrawFast(Selctd, FastMode); 
	//	//else Draw(Selctd);
	//}
	//else { //otherwise draw the appropriate section view
	//	switch (CurSecAxis){
	//		case ZAXIS: DrawSecZ(CurSecLayer, NumBehindSection, CurSecFromNeg, Selctd); break;
	//		case YAXIS: DrawSecY(CurSecLayer, NumBehindSection, CurSecFromNeg, Selctd); break;
	//		case XAXIS: DrawSecX(CurSecLayer, NumBehindSection, CurSecFromNeg, Selctd); break;
	//	}
	//}
}
Exemple #5
0
int main()
{
    UINT32 x = 0;
    int i;
	{
	    UINT32 state[50];
	    const UINT32 imageOfAllZero[50] = {
	        0xD33D89FB, 0xC4B60CAD, 0x2FAD58B0, 0x88AE581B, 0xF4262C1A, 
	        0x8A53D3EF, 0x77B4B09B, 0xE0147822, 0x10A38DCF, 0xB6305181, 
	        0xF723F2BE, 0xF9C67B78, 0x4EB02ABA, 0x8FCCC118, 0x2DC2E52E, 
	        0xA3B29275, 0x342F5536, 0xE4DD320A, 0x45C7C3EA, 0x493D8BE4, 
	        0x9C1717E7, 0xF3E75194, 0x12A23D11, 0xEDD52441, 0x13E6DBFF, 
	        0x8C61BB03, 0x945B1B82, 0x1E4A11A5, 0x1C3453E7, 0x0D730C1B, 
	        0x3B9C1D29, 0x0C534AF4, 0xA6EC29CC, 0x4FFDAA4D, 0x96C7DAA5, 
	        0x45487850, 0x4ECFBC29, 0xE630383B, 0x26806B48, 0xA7EB2B5A,
	        0x62D02426, 0x8265F750, 0x49D20B1A, 0x20E4D82C, 0x6F72B2B8, 
	        0x1C45D049, 0xFEA9F415, 0x4D0E74C7, 0x8DFDEA09, 0xFCF72ED2 };

		// Test 1 (all-zero state through Keccak-f[1600])
	    memset(state, 0, 50*sizeof(UINT32));
		KeccakPermutation((unsigned char*)state);
	    for(i=0; i<50; i++)
	        if (state[i] != imageOfAllZero[i])
	            for( ; ; ) {
					//	Kaccek (aka other algo)
	                x++;
	            }
		// For benchmarking
		{
			#ifdef ProvideFast1024
			KeccakAbsorb1024bits((unsigned char*)state, (unsigned char*)imageOfAllZero);
			#else
			KeccakAbsorb((unsigned char*)state, (unsigned char*)imageOfAllZero, 16);
			#endif
		}
	}
	{
		hashState state;
		const UINT8 Msg29[4] = { 0x53, 0x58, 0x7B, 0xC8 };
		const UINT8 Msg29_out[160] = {
			0xDE, 0xEB, 0xFB, 0x5F, 0xBC, 0x67, 0x14, 0x3A, 0x70, 0xF5, 0xEE, 0x51, 0x8F, 0x3C, 0xE2, 0x0A, 
			0x70, 0x2A, 0x3C, 0x25, 0x0C, 0x22, 0xD9, 0x39, 0xD7, 0xEE, 0xF5, 0x98, 0xA3, 0x9C, 0xA5, 0xC5, 
			0x37, 0x41, 0xB6, 0xF5, 0x7B, 0x58, 0x40, 0xAD, 0xD2, 0x8E, 0xF6, 0x14, 0x0A, 0xAD, 0x9D, 0x4C, 
			0x2B, 0x8E, 0xCC, 0x6A, 0x89, 0xFC, 0x5E, 0xFE, 0x73, 0x1F, 0x5E, 0x69, 0x7B, 0x83, 0xB8, 0x1C, 
			0x27, 0xED, 0xE0, 0xD2, 0x26, 0xBB, 0x30, 0xDE, 0x0A, 0x93, 0xF5, 0xCE, 0xDB, 0xC1, 0x6E, 0x32, 
			0xBA, 0x9D, 0x6B, 0x10, 0x48, 0x8A, 0x5A, 0x0E, 0x55, 0x5C, 0xB2, 0x96, 0x9F, 0x51, 0xE5, 0x8D, 
			0x46, 0xF0, 0x03, 0xF5, 0x0F, 0x9D, 0x84, 0x5A, 0xAF, 0x43, 0x07, 0x66, 0x76, 0x23, 0x82, 0xAD, 
			0xFD, 0x9B, 0x4C, 0xF0, 0x59, 0x16, 0xDF, 0xD6, 0x5C, 0x8A, 0x8C, 0xFC, 0xDE, 0xC5, 0xD0, 0x45, 
			0x34, 0x07, 0x38, 0x7D, 0xBC, 0xF3, 0xA7, 0x44, 0x26, 0x8E, 0x85, 0xB3, 0x5B, 0x50, 0x0E, 0xDD, 
			0x1E, 0xD5, 0x09, 0x01, 0x55, 0xA6, 0x35, 0xBF, 0xA4, 0x6A, 0xC2, 0x4D, 0xA7, 0x98, 0xE8, 0x24 };
		UINT8 output[160];

		// Test 2 (message of length 29 from ShortMsgKAT_0.txt)
		Init(&state, 0);
		Update(&state, Msg29, 29);
		Final(&state, 0);
		Squeeze(&state, output, 160*8);
	    for(i=0; i<160; i++)
	        if (output[i] != Msg29_out[i])
	            for( ; ; ) {
					//	Kaccek (aka other algo)
	                x++;
	            }
	}

	for ( ; ; ) ;
}
Exemple #6
0
void keccak128(const unsigned char* in, const unsigned long long inlen, unsigned char *out) {
    spongeState state;
    InitSponge(&state, 1344, 256);
    Absorb(&state, in, inlen*8);
    Squeeze(&state, out, 128);
}
Exemple #7
0
long double MoonPhaseNext(long double jdt, long double phase)
{
	return Squeeze(jdt - 29.6 * fmod360(MoonPhaseGet(jdt) - phase) / 360 + 30, phase);
}
Exemple #8
0
long double MoonPhasePrevious(long double jdt, long double phase)
{
	return Squeeze(jdt - 29.6 * fmod360(MoonPhaseGet(jdt) - phase) / 360 + 1, phase);
}
Exemple #9
0
/**
 * Put a window back where it should be if we don't (any longer) control
 * it and reparent it back up to the root.  This leaves it where it was
 * before we started (well, adjusted by any moves we've made to it
 * since), and placed so that if we restart and take it back over, it'll
 * wind up right where it is now, so restarting doesn't shift windows all
 * over the place.
 */
void
RestoreWinConfig(TwmWindow *tmp)
{
	int gravx, gravy;
	int newx, newy;

	// Things adjusting by the border have to move our border size, but
	// subtract away from that the old border we're restoring.
	const int borders = tmp->frame_bw + tmp->frame_bw3D - tmp->old_bw;

	// If this window is "unmapped" by moving it way offscreen, and is in
	// that state, move it back onto the window.
	if(tmp->UnmapByMovingFarAway && !visible(tmp)) {
		XMoveWindow(dpy, tmp->frame, tmp->frame_x, tmp->frame_y);
	}

	// If it's squeezed, unsqueeze it.
	if(tmp->squeezed) {
		Squeeze(tmp);
	}

	// This is apparently our standard "is this window still around?"
	// idiom.
	if(XGetGeometry(dpy, tmp->w, &JunkRoot, &JunkX, &JunkY,
	                &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0) {
		// Well, give up...
		return;
	}

	// Get gravity bits to know how to move stuff around when we take
	// away the decorations.
	GetGravityOffsets(tmp, &gravx, &gravy);

	// We want to move the window to where it should be "outside" of our
	// frame.  This varies depending on the window gravity detail, and we
	// have to account for that, since on re-startup we'll be doing it to
	// resposition it after we re-wrap it.
	//
	// e.g., in simple "NorthWest" gravity, we just made the frame start
	// where the window did, and shifted the app window right (by the
	// border width) and down (by the border width + titlebar).  However,
	// "SouthEast" gravity means the bottom right of the frame is where
	// the windows' was, and the window itself shifted left/up by the
	// border.  Compare e.g. an xterm with -geometry "+0+0" with one
	// using "-0-0" as an easy trick to make windows with different
	// geoms.
	newx = tmp->frame_x;
	newy = tmp->frame_y;


	// So, first consider the north/south gravity.  If gravity is North,
	// we put the top of the frame where the window was and shifted
	// everything inside down, so the top of the frame now is where the
	// window should be put.  With South-y gravity, the window should
	// wind up at the bottom of the frame, which means we need to shift
	// it down by the titlebar height, plus twice the border width.  But
	// if the vertical gravity is neutral, then the window needs to wind
	// up staying right where it is, because we built the frame around it
	// without moving it.
	//
	// Previous code here (and code elsewhere) expressed this calculation
	// by the rather confusing idiom ((gravy + 1) * border_width), which
	// gives the right answer, but is confusing as hell...
	if(gravy < 0) {
		// North; where the frame starts (already set)
	}
	else if(gravy > 0) {
		// South; shift down title + 2*border
		newy += tmp->title_height + 2 * borders;
	}
	else {
		// Neutral; down by the titlebar + border.
		newy += tmp->title_height + borders;
	}


	// Now east/west.  West means align with the frame start, east means
	// align with the frame right edge, neutral means where it already
	// is.
	if(gravx < 0) {
		// West; it's already correct
	}
	else if(gravx > 0) {
		// East; shift over by 2*border
		newx += 2 * borders;
	}
	else {
		// Neutral; over by the left border
		newx += borders;
	}


	// If it's in a WindowBox, reparent the frame back up to our real root
	if(tmp->winbox && tmp->winbox->twmwin && tmp->frame) {
		int xbox, ybox;
		unsigned int j_bw;

		// XXX This isn't right, right?  This will give coords relative
		// to the window box, but we're using them relative to the real
		// screen root?
		if(XGetGeometry(dpy, tmp->frame, &JunkRoot, &xbox, &ybox,
		                &JunkWidth, &JunkHeight, &j_bw, &JunkDepth)) {
			ReparentWindow(dpy, tmp, WinWin, Scr->Root, xbox, ybox);
		}
	}


	// Restore the original window border if there were one
	if(tmp->old_bw) {
		XSetWindowBorderWidth(dpy, tmp->w, tmp->old_bw);
	}

	// Reparent and move back to where it otter be
	XReparentWindow(dpy, tmp->w, Scr->Root, newx, newy);

	// If it came with a pre-made icon window, hide it
	if(tmp->wmhints->flags & IconWindowHint) {
		XUnmapWindow(dpy, tmp->wmhints->icon_window);
	}

	// Done
	return;
}
/**
Create the vtkStructuredGrid from the provided workspace
@param progressUpdating: Reporting object to pass progress information up the
stack.
@return fully constructed vtkDataSet.
*/
vtkSmartPointer<vtkDataSet>
vtkMDHistoLineFactory::create(ProgressAction &progressUpdating) const {
  auto product =
      tryDelegatingCreation<MDHistoWorkspace, 1>(m_workspace, progressUpdating);
  if (product != nullptr) {
    return product;
  } else {
    g_log.warning() << "Factory " << this->getFactoryTypeName()
                    << " is being used. You are viewing data with less than "
                       "three dimensions in the VSI. \n";

    Mantid::Kernel::ReadLock lock(*m_workspace);
    const int nBinsX =
        static_cast<int>(m_workspace->getXDimension()->getNBins());

    const coord_t minX = m_workspace->getXDimension()->getMinimum();

    coord_t incrementX = m_workspace->getXDimension()->getBinWidth();

    const int imageSize = nBinsX;
    vtkNew<vtkPoints> points;
    points->Allocate(static_cast<int>(imageSize));

    vtkNew<vtkFloatArray> signal;
    signal->Allocate(imageSize);
    signal->SetName(vtkDataSetFactory::ScalarName.c_str());
    signal->SetNumberOfComponents(1);

    UnstructuredPoint unstructPoint;
    const int nPointsX = nBinsX;
    Column column(nPointsX);

    NullCoordTransform transform;
    // Mantid::API::CoordTransform* transform =
    // m_workspace->getTransformFromOriginal();
    Mantid::coord_t in[3];
    Mantid::coord_t out[3];

    double progressFactor = 0.5 / double(nBinsX);
    double progressOffset = 0.5;

    // Loop through dimensions
    for (int i = 0; i < nPointsX; i++) {
      progressUpdating.eventRaised(progressFactor * double(i));
      in[0] = minX +
              static_cast<coord_t>(i) * incrementX; // Calculate increment in x;

      float signalScalar =
          static_cast<float>(m_workspace->getSignalNormalizedAt(i));

      if (!std::isfinite(signalScalar)) {
        // Flagged so that topological and scalar data is not applied.
        unstructPoint.isSparse = true;
      } else {
        if (i < (nBinsX - 1)) {
          signal->InsertNextValue(static_cast<float>(signalScalar));
        }
        unstructPoint.isSparse = false;
      }

      transform.apply(in, out);

      unstructPoint.pointId = points->InsertNextPoint(out);
      column[i] = unstructPoint;
    }

    points->Squeeze();
    signal->Squeeze();

    auto visualDataSet = vtkSmartPointer<vtkUnstructuredGrid>::New();
    visualDataSet->Allocate(imageSize);
    visualDataSet->SetPoints(points.GetPointer());
    visualDataSet->GetCellData()->SetScalars(signal.GetPointer());

    for (int i = 0; i < nBinsX - 1; i++) {
      progressUpdating.eventRaised((progressFactor * double(i)) +
                                   progressOffset);
      // Only create topologies for those cells which are not sparse.
      if (!column[i].isSparse) {
        vtkLine *line = vtkLine::New();
        line->GetPointIds()->SetId(0, column[i].pointId);
        line->GetPointIds()->SetId(1, column[i + 1].pointId);
        visualDataSet->InsertNextCell(VTK_LINE, line->GetPointIds());
      }
    }

    visualDataSet->Squeeze();

    // Hedge against empty data sets
    if (visualDataSet->GetNumberOfPoints() <= 0) {
      vtkNullUnstructuredGrid nullGrid;
      visualDataSet = nullGrid.createNullData();
    }

    vtkSmartPointer<vtkDataSet> dataset = visualDataSet;
    return dataset;
  }
}