Commit e7283cd1 authored by Moritz's avatar Moritz

PointcloudToGridMapper: split function IntegratePointsIntoGrid into three...

PointcloudToGridMapper: split function IntegratePointsIntoGrid into three functions for better readability
parent 53f0a123
......@@ -16,16 +16,20 @@ namespace Teamproject {
/// </summary>
public float[,,] info { get; private set; }
//Dictionary<int, PCachePoint> _points;
float _inputGridStepSize = -1;
//pcache
private List<PCachePoint> _points;
//adjusted free points by including offset
private List<PCachePoint> adjPoints;
private Vector3 gridSize;
private Vector3 offsetCorrection; //if the grid doesn't start at 0, 0, 0 -> vector to move all points, so that grid is aligned
private float gridStepSize;
//Inverted Lists: calculate neighbourhoods (lists)
private List<PCachePoint>[,,] nei;
/// <summary>
/// Maps given points into a grid
/// Should have a complexity of (numberOfGridPoints) * (numberOfMappedPoints)
......@@ -65,10 +69,16 @@ namespace Teamproject {
}
}
public Vector3 GetOffsetCorrection() {
return offsetCorrection;
}
public void StartConvert() {
Debug.Log("PointCloudToGridMapper: " + _points.Count + " point to map onto grid");
CreateGrid();
AlignPointsToCoordinateOrigin();
CreateNeighborhoodListsForGridPoints();
IntegratePointsIntoGrid();
}
......@@ -127,7 +137,15 @@ namespace Teamproject {
Debug.Log("Grid size: " + gridSize);
}
private void IntegratePointsIntoGrid() {
private void AlignPointsToCoordinateOrigin() {
//adjust free points by including offset
adjPoints = new List<PCachePoint>();
foreach (PCachePoint pd in _points)
adjPoints.Add(new PCachePoint(pd.Type, pd.Position + offsetCorrection, pd.Direction));
}
private void CreateNeighborhoodListsForGridPoints() {
/*
* To integrate the points (point = "free" point calculated from the simulation results, not bound to grid) into the grid,
* we need to know which free points influence which gridpoints. Free points influence a gridpoint if they are near enough,
......@@ -153,16 +171,11 @@ namespace Teamproject {
*/
//adjust free points by including offset
List<PCachePoint> adjPoints = new List<PCachePoint>();
foreach (PCachePoint pd in _points)
adjPoints.Add(new PCachePoint(pd.Type, pd.Position + offsetCorrection, pd.Direction));
float neighborhoodRange = gridStepSize;
//Inverted Lists: calculate neighbourhoods (lists)
List<PCachePoint>[,,] nei = new List<PCachePoint>[(int)gridSize.x, (int)gridSize.y, (int)gridSize.z];
nei = new List<PCachePoint>[(int)gridSize.x, (int)gridSize.y, (int)gridSize.z];
foreach (PCachePoint pcpoint in adjPoints) {
......@@ -227,9 +240,9 @@ namespace Teamproject {
}
}
}
}
private void IntegratePointsIntoGrid() {
/*
* To calculate the direction vector on each gridpoint: take direction vectors of the neighbourhoods free points
* Different approaches to combine the Vectors:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment