Skip to content

Commit

Permalink
Merge pull request #60 from MicroscopeIT/BartekK/HOL-47-Maintenance
Browse files Browse the repository at this point in the history
BartekK/HOL-47-Maintenance
  • Loading branch information
ellendil committed Jun 24, 2020
2 parents 108ab3d + bab6e76 commit cb213a3
Show file tree
Hide file tree
Showing 2,429 changed files with 127 additions and 408,200 deletions.
5 changes: 5 additions & 0 deletions VTKConverter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vs/
VTKConverter/bin/
VTKConverter/obj/
*.csproj
*.csproj.user
Binary file removed VTKConverter/.vs/VTKConverter/v15/.suo
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed VTKConverter/.vs/VTKConverter/v16/.suo
Binary file not shown.
Empty file.
Binary file not shown.
1,015 changes: 0 additions & 1,015 deletions VTKConverter/.vs/config/applicationhost.config

This file was deleted.

10 changes: 8 additions & 2 deletions VTKConverter/VTKConverter/ModelConversion/ModelConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ class ModelConverter

public void Convert(string inputRootDir, string outputFolder)
{
CreateOutputRoot(inputRootDir, outputFolder);
var singleModel = new SingleModel(inputRootDir);

CreateOutputRoot(inputRootDir, outputFolder, singleModel);
ConvertSingleModel(singleModel);
}

private void CreateOutputRoot(string inputRootDir, string outputFolder)
private void CreateOutputRoot(string inputRootDir, string outputFolder, SingleModel singleModel)
{
outputRootDir = outputFolder + @"\" + Path.GetFileName(inputRootDir);
Directory.CreateDirectory(outputRootDir);
File.Copy(inputRootDir + @"\ModelInfo.json", outputRootDir + @"\ModelInfo.json", true);
if (singleModel.Info.IconFileName != null)
{
File.Copy(inputRootDir + @"\" + singleModel.Info.IconFileName,
outputRootDir + @"\" + singleModel.Info.IconFileName, true);
}
}

private void ConvertSingleModel(SingleModel singleModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ namespace VTKConverter
public class ModelInfo
{
public string Caption;
// Icon filename.
// Initially (when deserialized from JSON) this is relative to ModelInfo.json,
// but it is converted to an absolute path during SingleModel.ReadInfoFile,
// so most of the code can safely assume it's an absolute filename.
// Must be a PNG file now.
public string IconFileName;
public List<ModelLayerInfo> Layers = new List<ModelLayerInfo>();
}

// Information about a single layer.
// Information about a single layer.\
public class ModelLayerInfo
{
public string Caption;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class AnatomyData : ModelData
{
public AnatomyData(vtkDataSet vtkModel) : base(vtkModel)
{
LoadVertices(vtkModel);
LoadIndices(vtkModel);
ImportVertices(vtkModel);
ImportIndices(vtkModel);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public FibreData(vtkDataSet vtkModel) : base(vtkModel)
{
numberOfPoints = vtkModel.GetNumberOfPoints();
ComputePointIndices(numberOfPoints);
LoadVertices(vtkModel);
GetVectors(vtkModel);
GetAngles(vtkModel);
ImportVertices(vtkModel);
ImportVectors(vtkModel);
ImportAngles(vtkModel);
}

private void GetVectors(vtkDataSet vtkModel)
private void ImportVectors(vtkDataSet vtkModel)
{
Vectors = new double[numberOfPoints][];

Expand All @@ -27,7 +27,7 @@ private void GetVectors(vtkDataSet vtkModel)
}
}

private void GetAngles(vtkDataSet vtkModel)
private void ImportAngles(vtkDataSet vtkModel)
{
Scalars = new double[numberOfPoints][];
vtkPointData pointData = vtkModel.GetPointData();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Kitware.VTK;
using System.Linq;
using Kitware.VTK;

namespace VTKConverter.DataImport
{
Expand All @@ -9,25 +10,27 @@ class FlowData : ModelData
public FlowData(vtkDataSet vtkModel) : base(vtkModel)
{
numberOfVertices = vtkModel.GetNumberOfPoints() / 2;
GetLineVerticesAndVectors(vtkModel);
ImportVerticesAndVectors(vtkModel);
ComputePointIndices(numberOfVertices);
GetFlowColors(vtkModel);
ImportFlowColors(vtkModel);
}

private void GetLineVerticesAndVectors(vtkDataSet vtkModel)
private void ImportVerticesAndVectors(vtkDataSet vtkModel)
{
Vertices = new double[numberOfVertices][];
Vectors = new double[numberOfVertices][];
int currentVertexNumber = 0;
for (int i = 0; i < numberOfVertices * 2; i+=2)
{
Vertices[currentVertexNumber] = vtkModel.GetPoint(i);
Vectors[currentVertexNumber] = vtkModel.GetPoint(i+1);
Vectors[currentVertexNumber] = vtkModel.GetPoint(i + 1).Zip(vtkModel.GetPoint(i), (vector, vertex) => vector - vertex).ToArray();
Vertices[currentVertexNumber][2] = -Vertices[currentVertexNumber][2];
Vectors[currentVertexNumber][2] = -Vectors[currentVertexNumber][2];
currentVertexNumber += 1;
}
}

private void GetFlowColors(vtkDataSet vtkModel)
private void ImportFlowColors(vtkDataSet vtkModel)
{
// Kitware.VTK.dll automatically scales colours to 0-255 range.
Scalars = new double[numberOfVertices][];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ abstract class ModelData

public ModelData(vtkDataSet vtkModel)
{
LoadBounds(vtkModel);
ImportFrameBounds(vtkModel);
}

private void LoadBounds(vtkDataSet vtkModel)
private void ImportFrameBounds(vtkDataSet vtkModel)
{
double[] boundingCoordinates = vtkModel.GetBounds();
BoundingBox = new double[6] {boundingCoordinates[0], boundingCoordinates[2], -boundingCoordinates[4],
boundingCoordinates[1], boundingCoordinates[3], -boundingCoordinates[5]};
}

protected void LoadVertices(vtkDataSet vtkModel)
protected void ImportVertices(vtkDataSet vtkModel)
{
int numberOfPoints = vtkModel.GetNumberOfPoints();
Vertices = new double[numberOfPoints][];
Expand All @@ -39,15 +39,15 @@ protected void LoadVertices(vtkDataSet vtkModel)
}
}

protected virtual void LoadIndices(vtkDataSet vtkModel)
protected virtual void ImportIndices(vtkDataSet vtkModel)
{
int numberOfCells = vtkModel.GetNumberOfCells();
NumberOfFacetEdges = vtkModel.GetMaxCellSize();
Indices = new int[NumberOfFacetEdges * numberOfCells];
int currentIndexNumber = 0;
for (int i = 0; i < numberOfCells; i++)
{
currentIndexNumber = LoadCellIndices(currentIndexNumber, vtkModel.GetCell(i).GetPointIds());
currentIndexNumber = ImportCellIndices(currentIndexNumber, vtkModel.GetCell(i).GetPointIds());
}
}

Expand All @@ -66,7 +66,7 @@ protected void ComputePointIndices(int numberOfPoints)
}
}

private int LoadCellIndices(int currentIndexNumber, vtkIdList cellIndices)
private int ImportCellIndices(int currentIndexNumber, vtkIdList cellIndices)
{
int numberOfIndices = cellIndices.GetNumberOfIds();
for (int j = 0; j < numberOfIndices; j++)
Expand Down
77 changes: 0 additions & 77 deletions VTKConverter/VTKConverter/VTKConverter.csproj

This file was deleted.

10 changes: 0 additions & 10 deletions VTKConverter/VTKConverter/VTKConverter.csproj.user

This file was deleted.

Binary file removed VTKConverter/VTKConverter/bin/Cosmo.dll
Binary file not shown.
Binary file removed VTKConverter/VTKConverter/bin/EventMonitor.exe
Binary file not shown.
Binary file removed VTKConverter/VTKConverter/bin/FileTree.exe
Binary file not shown.
Binary file removed VTKConverter/VTKConverter/bin/Kitware.VTK.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit cb213a3

Please sign in to comment.