public static object CubeFromCSV( [ExcelArgument(Description = "Output cube name")] string ObjectName, [ExcelArgument(Description = "Input filename")] string FileName) { return(ExcelHelper.Execute(_logger, () => { var cube = CubeEx.FromCSVFile(FileName); return RiskFunctions.PushCubeToCache(cube, ObjectName); })); }
private CubeEx DividedCube(int divide, Model3DGroup cube) { double voxelWidth = cube.Bounds.SizeX / divide; List <List <Point3DEx> > cubevoxels = new List <List <Point3DEx> >(); List <List <Point3DEx> > tetraVoxelsTriangles = new List <List <Point3DEx> >(); List <List <Point3DEx> > tetraVoxelsVertices = new List <List <Point3DEx> >(); var hexahedrons = new List <Point3DEx> [divide, divide, divide]; for (int i = 0; i < divide; i++) { for (int j = 0; j < divide; j++) { for (int k = 0; k < divide; k++) { List <Point3DEx> tmp = new List <Point3DEx>(); tmp.Add(new Point3DEx(i * voxelWidth - voxelWidth / 2, j * voxelWidth - voxelWidth / 2, k * voxelWidth - voxelWidth / 2)); tmp.Add(new Point3DEx(i * voxelWidth + voxelWidth / 2, j * voxelWidth - voxelWidth / 2, k * voxelWidth - voxelWidth / 2)); tmp.Add(new Point3DEx(i * voxelWidth + voxelWidth / 2, j * voxelWidth - voxelWidth / 2, k * voxelWidth + voxelWidth / 2)); tmp.Add(new Point3DEx(i * voxelWidth - voxelWidth / 2, j * voxelWidth - voxelWidth / 2, k * voxelWidth + voxelWidth / 2)); tmp.Add(new Point3DEx(i * voxelWidth - voxelWidth / 2, j * voxelWidth + voxelWidth / 2, k * voxelWidth - voxelWidth / 2)); tmp.Add(new Point3DEx(i * voxelWidth + voxelWidth / 2, j * voxelWidth + voxelWidth / 2, k * voxelWidth - voxelWidth / 2)); tmp.Add(new Point3DEx(i * voxelWidth + voxelWidth / 2, j * voxelWidth + voxelWidth / 2, k * voxelWidth + voxelWidth / 2)); tmp.Add(new Point3DEx(i * voxelWidth - voxelWidth / 2, j * voxelWidth + voxelWidth / 2, k * voxelWidth + voxelWidth / 2)); cubevoxels.Add(tmp); hexahedrons[i, j, k] = tmp; } } } //kazdy z malych szescianow dzielimy na 5 czworoscianow foreach (var c in cubevoxels) { //lista z trojkatami szescianow tetraVoxelsTriangles.Add(new List <Point3DEx>(new[] { c[3], c[2], c[6], c[2], c[1], c[6], c[3], c[2], c[1], c[3], c[6], c[1] })); tetraVoxelsTriangles.Add(new List <Point3DEx>(new[] { c[1], c[5], c[6], c[1], c[4], c[5], c[5], c[4], c[6], c[1], c[4], c[6] })); tetraVoxelsTriangles.Add(new List <Point3DEx>(new[] { c[3], c[6], c[7], c[3], c[7], c[4], c[7], c[6], c[4], c[3], c[6], c[4] })); tetraVoxelsTriangles.Add(new List <Point3DEx>(new[] { c[0], c[3], c[4], c[0], c[1], c[4], c[0], c[3], c[1], c[4], c[3], c[1] })); tetraVoxelsTriangles.Add(new List <Point3DEx>(new[] { c[4], c[3], c[1], c[3], c[6], c[1], c[1], c[6], c[4], c[3], c[6], c[4] })); //lista z wierzcholkami szescianow tetraVoxelsVertices.Add(new List <Point3DEx>(new[] { c[6], c[3], c[2], c[1] })); tetraVoxelsVertices.Add(new List <Point3DEx>(new[] { c[1], c[4], c[5], c[6] })); tetraVoxelsVertices.Add(new List <Point3DEx>(new[] { c[3], c[6], c[7], c[4] })); tetraVoxelsVertices.Add(new List <Point3DEx>(new[] { c[4], c[1], c[0], c[3] })); tetraVoxelsVertices.Add(new List <Point3DEx>(new[] { c[1], c[3], c[4], c[6] })); } CubeEx myCube = new CubeEx(cube); myCube.Hexahedrons = hexahedrons; myCube.TetrahedronsList = tetraVoxelsVertices; return(myCube); }
public void IsEqual() { Assert.True(CubeEx.IsEqual(0.77, 0.77)); Assert.True(CubeEx.IsEqual(77, 77)); Assert.True(CubeEx.IsEqual('C', 'C')); Assert.True(CubeEx.IsEqual(false, false)); Assert.True(CubeEx.IsEqual(DateTime.Today, DateTime.Today)); Assert.True(CubeEx.IsEqual(1.6M, 1.6M)); Assert.False(CubeEx.IsEqual(new List <string>(), 1.6M)); }
public static object CubeFromCSV( [ExcelArgument(Description = "Output cube name")] string ObjectName, [ExcelArgument(Description = "Input filename")] string FileName, [ExcelArgument(Description = "Has header row, default true")] object HasHeaderRow, [ExcelArgument(Description = "Has value column, default true")] object HasValueColumn) { return(ExcelHelper.Execute(_logger, () => { var hasHeader = HasHeaderRow.OptionalExcel(true); var hasValue = HasValueColumn.OptionalExcel(true); var cube = (!hasHeader && !hasValue) ? CubeEx.FromCSVFileRaw(FileName) : CubeEx.FromCSVFile(FileName, hasHeader, hasValue); return RiskFunctions.PushCubeToCache(cube, ObjectName); })); }
public ModelBuilder(double size, int divide, int depth) { _modelCube = DividedCube(divide, CreateBigCube(0, 0, depth, size)); _triangleIndices = CreateTriangleIndicesList(); }