Empty volumes for labellayer and foregroundlayer

Hi,

I am new to using VTK,

I am getting background layer just fine with the right HU values. However, when I pull out labellayer from slicelogic and use the function getvolume. It is always nullptr. On my screen I can see there are segmentations.

Here is my code so far,

  QStringList theList;
  QString text;
  int* ijk = new int[0, 0, 0];
  double* xyz;
  std::map<QString, vtkMRMLSliceLayerLogic*> layerLogic;
  vtkMRMLVolumeNode* volumeNode;
  vtkImageData* imageData;
  vtkMRMLSliceNode* sliceNode;
  vtkMRMLCrosshairNode* crossHair;
  qDebug() << "Updating current logic";
  crossHair = vtkMRMLCrosshairNode::SafeDownCast(
    qSlicerApplication::application()->mrmlScene()->GetFirstNodeByClass("vtkMRMLCrosshairNode")
  );

  if (crossHair) sliceNode = crossHair->GetCursorPositionXYZ(xyz);

  if (sliceNode == nullptr) return theList;
  vtkSlicerApplicationLogic* appLogic = vtkSlicerApplicationLogic::SafeDownCast(
    qSlicerApplication::application()->applicationLogic()
  );
  if (appLogic == nullptr) return theList;
  d->sliceLogic = vtkMRMLSliceLogic::SafeDownCast(
    appLogic->GetSliceLogic(sliceNode)
  );
  if (d->sliceLogic == nullptr) return theList;

  layerLogic["B"] = vtkMRMLSliceLayerLogic::SafeDownCast(d->sliceLogic->GetBackgroundLayer());
  layerLogic["F"] = vtkMRMLSliceLayerLogic::SafeDownCast(d->sliceLogic->GetForegroundLayer());
  layerLogic["L"] = vtkMRMLSliceLayerLogic::SafeDownCast(d->sliceLogic->GetLabelLayer());

  int i = 0;
  for (auto& layer : layerLogic) {
    text = "";
    if (layer.second == nullptr) {
      qDebug() << layer.first << " has is empty";
      theList.push_back(layer.first);
      continue;
    }
    qDebug() << "Get volume: ";
    volumeNode = vtkMRMLVolumeNode::SafeDownCast(
      d->sliceLogic->GetLayerVolumeNode(i)
    );

After this I print which layers have no volume.

Thanks if anyone can help