Skip to content

Commit

Permalink
Merge pull request pyushkevich#128 from jilei-hao/dev/mesh-wt
Browse files Browse the repository at this point in the history
Dev/mesh wt
  • Loading branch information
jilei-hao authored Sep 15, 2023
2 parents 797769e + cd95d06 commit 4127340
Show file tree
Hide file tree
Showing 19 changed files with 407 additions and 37 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ ENDIF()

# These four fields should be modified when versions change
SET(SNAP_VERSION_MAJOR 4)
SET(SNAP_VERSION_MINOR 0)
SET(SNAP_VERSION_PATCH 1)
SET(SNAP_VERSION_QUALIFIER "")
SET(SNAP_VERSION_MINOR 1)
SET(SNAP_VERSION_PATCH 0)
SET(SNAP_VERSION_QUALIFIER "-dev")

# These fields should also be modified each time
SET(SNAP_VERSION_RELEASE_DATE "20230320")
SET(SNAP_VERSION_RELEASE_DATE_FORMATTED "March 20, 2023")
SET(SNAP_VERSION_RELEASE_DATE "20230523")
SET(SNAP_VERSION_RELEASE_DATE_FORMATTED "May 23, 2023")

# This field should only change when the format of the settings files changes
# in a non backwards-compatible way
Expand Down
18 changes: 18 additions & 0 deletions Common/Registry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <cstdarg>
#include <fstream>
#include <iomanip>
#include <regex>
#include "itksys/SystemTools.hxx"
#include "IRISException.h"

Expand Down Expand Up @@ -491,6 +492,23 @@ ::FindValue(const StringType& value)
return "";
}

Registry::StringListType
Registry
::FindFoldersFromPattern(const StringType &_pattern) const
{
StringListType ret;
std::regex pattern(_pattern);
std::smatch match;

for (auto &kv : m_FolderMap)
{
if (std::regex_search(kv.first, match, pattern))
ret.push_back(kv.first);
}

return ret;
}

void
Registry
::RemoveKeys(const char *match)
Expand Down
3 changes: 3 additions & 0 deletions Common/Registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ class Registry
/** Find a value in a folder or return "" */
StringType FindValue(const StringType& value);

/** Find a list of folders keys with string pattern */
StringListType FindFoldersFromPattern(const StringType& _pattern) const;

/** Empty the contents of the registry */
void Clear();

Expand Down
2 changes: 1 addition & 1 deletion GUI/Qt/Windows/SplashPanel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ color:rgb(109, 109, 109);</string>
<string>Copyright (C) 1998-2022
Paul A. Yushkevich
Guido Gerig
Alison Pouch
Alison M. Pouch
Jilei Hao</string>
</property>
<property name="alignment">
Expand Down
7 changes: 7 additions & 0 deletions Logic/Framework/GenericImageData.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,13 @@ int GenericImageData::GetNumberOfOverlays()
return m_Wrappers[OVERLAY_ROLE].size();
}

unsigned int
GenericImageData
::GetNumberOfTimePoints() const
{
return m_Parent->GetNumberOfTimePoints();
}

ImageWrapperBase *GenericImageData::GetLastOverlay()
{
return m_Wrappers[OVERLAY_ROLE].back();
Expand Down
5 changes: 5 additions & 0 deletions Logic/Framework/GenericImageData.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ class GenericImageData : public itk::Object

int GetNumberOfOverlays();

/**
* Get Number of Timepoints in the workspace
*/
unsigned int GetNumberOfTimePoints() const;

ImageWrapperBase *GetLastOverlay();

// virtual ImageWrapperBase* GetLayer(unsigned int layer) const;
Expand Down
2 changes: 1 addition & 1 deletion Logic/Mesh/GuidedMeshIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class GuidedMeshIO
FileFormat GetFileFormat(Registry &folder, FileFormat dflt = FORMAT_COUNT);

/** Set the file format in a registry */
void SetFileFormat(Registry &folder, FileFormat format);
static void SetFileFormat(Registry &folder, FileFormat format);

/** Get enum description */
std::string GetFormatDescription(FileFormat formatEnum);
Expand Down
3 changes: 2 additions & 1 deletion Logic/Mesh/ImageMeshLayers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ ::LoadFromRegistry(Registry &project, std::string &project_dir_orig,
{
auto folder_crnt_layer = folder_layers.Folder(layer_key);
auto mesh_wrapper = StandaloneMeshWrapper::New();
mesh_wrapper->LoadFromRegistry(folder_crnt_layer, project_dir_orig, project_dir_crnt);
mesh_wrapper->LoadFromRegistry(folder_crnt_layer, project_dir_orig,
project_dir_crnt, m_ImageData->GetNumberOfTimePoints());
AddLayer(mesh_wrapper, true);

++layer_id;
Expand Down
2 changes: 1 addition & 1 deletion Logic/Mesh/LevelSetMeshWrapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ ::SaveToRegistry(Registry &)

void
LevelSetMeshWrapper
::LoadFromRegistry(Registry &, std::string &, std::string &)
::LoadFromRegistry(Registry &, std::string &, std::string &, unsigned int)
{

}
Expand Down
3 changes: 2 additions & 1 deletion Logic/Mesh/LevelSetMeshWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class LevelSetMeshWrapper : public MeshWrapperBase
virtual void SaveToRegistry(Registry &folder) override;

/** Build the layer from registry */
virtual void LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_dir) override;
virtual void LoadFromRegistry(Registry &folder, std::string &orig_dir,
std::string &crnt_dir, unsigned int nT) override;

/** Get Pipeline Modified Time */
unsigned long GetAssemblyMTime(unsigned int tp);
Expand Down
25 changes: 16 additions & 9 deletions Logic/Mesh/MeshWrapperBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "MeshDisplayMappingPolicy.h"
#include "Rebroadcaster.h"
#include "IRISApplication.h"
#include "IRISException.h"
#include <vtkPointData.h>
#include <vtkCellData.h>
#include <vtkDataSetAttributes.h>
Expand Down Expand Up @@ -432,7 +433,8 @@ ::GetNumberOfMeshes(unsigned int timepoint)

void
MeshWrapperBase
::LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_dir)
::LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_dir,
unsigned int nT)
{
GuidedMeshIO io;
bool moved = (orig_dir.compare(crnt_dir) != 0);
Expand All @@ -444,13 +446,17 @@ ::LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_di
// Load mesh timepoint assembly
auto folder_assembly = folder.Folder("MeshTimePoints");
bool fnSet = false;
unsigned int crnt_tp = 1;
std::string key_tp = Registry::Key("TimePoint[%03d]", crnt_tp);
bool has_poly = false;

while (folder_assembly.HasFolder(key_tp))
for (unsigned int tp = 1; tp <= nT; ++tp)
{
std::string key_tp = Registry::Key("TimePoint[%03d]", tp);

if (!folder_assembly.HasFolder(key_tp))
continue;

auto folder_tp = folder_assembly.Folder(key_tp);
unsigned int crnt_poly = 0;
unsigned int crnt_poly = 0; // polydata must start with index 0
std::string key_poly = Registry::Key("PolyData[%03d]", crnt_poly);

while (folder_tp.HasFolder(key_poly))
Expand All @@ -471,15 +477,16 @@ ::LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_di
.GetEnum(GuidedMeshIO::GetEnumFileFormat(), FileFormat::FORMAT_COUNT);

// Load with tp = j-1. The storeing of time point index is zero-based
io.LoadMesh(poly_file_full.c_str(), format, this, crnt_tp - 1, crnt_poly);
io.LoadMesh(poly_file_full.c_str(), format, this, tp - 1, crnt_poly);

++crnt_poly;
has_poly = true;
key_poly = Registry::Key("TimePoint[%03d]", crnt_poly);
}

++crnt_tp;
key_tp = Registry::Key("TimePoint[%03d]", crnt_tp);
}

if (!has_poly)
throw IRISException("Mesh polydata not found in the workspace file!");
}

void
Expand Down
7 changes: 5 additions & 2 deletions Logic/Mesh/MeshWrapperBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,11 @@ class MeshWrapperBase : public WrapperBase
/** Save the layer to registry */
virtual void SaveToRegistry(Registry &folder);

/** Build the layer from registry */
virtual void LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_dir);
/**
* Build the layer from registry
*/
virtual void LoadFromRegistry(Registry &folder, std::string &orig_dir,
std::string &crnt_dir, unsigned int nT);

// End of virtual methods definition
//------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Logic/Mesh/SegmentationMeshWrapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ ::SaveToRegistry(Registry &)

void
SegmentationMeshWrapper
::LoadFromRegistry(Registry &, std::string &, std::string &)
::LoadFromRegistry(Registry &, std::string &, std::string &, unsigned int)
{

}
Expand Down
3 changes: 2 additions & 1 deletion Logic/Mesh/SegmentationMeshWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class SegmentationMeshWrapper : public MeshWrapperBase
virtual void SaveToRegistry(Registry &folder) override;

/** Build the layer from registry */
virtual void LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_dir) override;
virtual void LoadFromRegistry(Registry &folder, std::string &orig_dir,
std::string &crnt_dir, unsigned int nT) override;

// End of virtual methods implementation
//-----------------------------------------------------
Expand Down
12 changes: 7 additions & 5 deletions Logic/Mesh/StandaloneMeshWrapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ ::SetMesh(vtkPolyData *mesh, unsigned int timepoint, LabelType id)
m_MeshAssemblyMap[timepoint] = assembly.GetPointer();
}

int propId = (m_CombinedDataPropertyMap.size() > 0) ?
m_CombinedDataPropertyMap.cbegin()->first : -1;

// Set Default active array id
SetActiveMeshLayerDataPropertyId(m_CombinedDataPropertyMap.cbegin()->first);
SetActiveMeshLayerDataPropertyId(propId);

InvokeEvent(ValueChangedEvent());
}
Expand Down Expand Up @@ -88,9 +91,10 @@ ::SaveToRegistry(Registry &folder)

void
StandaloneMeshWrapper
::LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_dir)
::LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_dir,
unsigned int nT)
{
Superclass::LoadFromRegistry(folder, orig_dir, crnt_dir); // Load basic structures using parent method
Superclass::LoadFromRegistry(folder, orig_dir, crnt_dir, nT); // Load basic structures using parent method

auto folder_data = folder.Folder("DataArrayProperties");
unsigned int array_id = 0;
Expand Down Expand Up @@ -130,7 +134,5 @@ ::LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_di
++array_id;
key_data = Registry::Key("DataArray[%03d]", array_id);
}

SetActiveMeshLayerDataPropertyId(0);
}

3 changes: 2 additions & 1 deletion Logic/Mesh/StandaloneMeshWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class StandaloneMeshWrapper : public MeshWrapperBase
virtual void SaveToRegistry(Registry &folder) override;

/** Build the layer from registry */
virtual void LoadFromRegistry(Registry &folder, std::string &orig_dir, std::string &crnt_dir)override;
virtual void LoadFromRegistry(Registry &folder, std::string &orig_dir,
std::string &crnt_dir, unsigned int nT) override;

// End of virtual methods definition
//-------------------------------------------------
Expand Down
Loading

0 comments on commit 4127340

Please sign in to comment.