Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Kulikov committed Apr 14, 2018
2 parents 17b0537 + ea4aef2 commit db0ad70
Show file tree
Hide file tree
Showing 13 changed files with 287 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/Get3DModel/CalculatedBlock/ChangeImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public Bitmap translateToMonochrome(Bitmap image)
for (int y = 0; y < image.Height; ++y)
for (int x = 0; x < image.Width; ++x)
{
Color c = image.GetPixel(x, y);
Color c = ((Bitmap)image.Clone()).GetPixel(x, y);
byte rgb = (byte)(0.3 * c.R + 0.59 * c.G + 0.11 * c.B);
res.SetPixel(x, y, Color.FromArgb(c.A, rgb, rgb, rgb));
}
Expand Down
8 changes: 4 additions & 4 deletions src/Get3DModel/CalculatedBlock/MathematicalDefault.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
Expand All @@ -18,9 +18,9 @@ public double gradientAtPoint(int x, int y)
public void setImage(Bitmap image)
{
this.image = new Data.Image((Bitmap)image.Clone()).Convolution(new double[,]
{{0, 1, 0},
{1, -4, 1},
{0, 1, 0}});
{{1, 1, 1},
{1, -8, 1},
{1, 1, 1}});
}

}
Expand Down
2 changes: 2 additions & 0 deletions src/Get3DModel/Data/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,6 @@ public double ConvolutionAtPoint(int x, int y, double[,] matrix)
return r;
}
}

}

19 changes: 15 additions & 4 deletions src/Get3DModel/Get3DModel.UnitTests/Get3DModel.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CalculatedBlock">
<HintPath>..\Get3DModel\bin\Debug\CalculatedBlock.dll</HintPath>
</Reference>
<Reference Include="Data">
<HintPath>..\Data\bin\Debug\Data.dll</HintPath>
</Reference>
<Reference Include="ParsingInputData">
<HintPath>..\Get3DModel\bin\Debug\ParsingInputData.dll</HintPath>
<HintPath>..\Data\bin\Debug\ParsingInputData.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
Expand All @@ -70,6 +67,20 @@
<Compile Include="SolutionTests.cs" />
<Compile Include="ImageTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CalculatedBlock\CalculatedBlock.csproj">
<Project>{b3a35c2c-a64c-4518-aac6-9906d42d1e98}</Project>
<Name>CalculatedBlock</Name>
</ProjectReference>
<ProjectReference Include="..\Get3DModel\Get3DModel.csproj">
<Project>{3dded6e7-063a-4094-a126-52d91bc5e79a}</Project>
<Name>Get3DModel</Name>
</ProjectReference>
<ProjectReference Include="..\Preserse\Preserve.csproj">
<Project>{bb2c3860-31d9-4c88-8f39-eccd1674d025}</Project>
<Name>Preserve</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
201 changes: 191 additions & 10 deletions src/Get3DModel/Get3DModel.UnitTests/ImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,41 +54,222 @@ public void GetPixelTest() //Проверка получения цвет
}

[TestMethod]
public void thisXYTest_InImage() //Проверка цвета пикселя в обертке исходного изображения
public void thisXYTest_GetInImage() //Проверка цвета пикселя в обертке исходного изображения
{
//arrange
string path = "Data\\r50g100b150.png";
IParser parser = new Parser();
Bitmap bitmap = parser.readPNG(path);
double tall=0;
// double tall=0;

Data.Image img = new Data.Image(bitmap, tall, true);
Data.Image img = new Data.Image(bitmap, true);
//act
Color rez=img[0,0];
Color exepected = Color.FromArgb(255, 50, 100, 150);
//assert
Debug.WriteLine("Проверка цвета");
Assert.AreEqual(rez, exepected);
}

[TestMethod]
public void thisXYTest_OutSideImage() //Проверка цвета пикселя за границами обертки исходного изображения
public void thisXYTest_GetOutSideImage() //Проверка цвета пикселя за границами обертки исходного изображения
{
//arrange
string path = "Data\\r50g100b150.png";
IParser parser = new Parser();
Bitmap bitmap = parser.readPNG(path);
double tall = 0;
//double tall = 0;

Data.Image img = new Data.Image(bitmap, tall, true) { DefaultColor = Color.Silver };
Data.Image img = new Data.Image(bitmap, true);
//act
Color rez = img[img.width()+1, img.height()+1];
Color exepected = Color.Silver; //Цвет по умолчанию
Color exepected = img.DefaultColor; //Цвет по умолчанию
//assert
Assert.AreEqual(exepected, rez);
}

[TestMethod]
public void thisXYTest_SetInImage() //Проверка записи цвета пикселя в изображении
{
//arrange
string path = "Data\\r50g100b150.png";
IParser parser = new Parser();
Bitmap bitmap = parser.readPNG(path);
// double tall = 0;

Data.Image img = new Data.Image(bitmap, true);
//act
Color rez = img[0, 0] = Color.Black;
Color exepected = Color.Black;
//assert
Assert.AreEqual(exepected, rez);
}

[TestMethod]
public void thisXYTest_SetOutSideImage() //Проверка записи цвета пикселя за границы изображения
{
//arrange
string path = "Data\\r50g100b150.png";
IParser parser = new Parser();
Bitmap bitmap = parser.readPNG(path);
// double tall = 0;

Data.Image img = new Data.Image(bitmap, true);
//act
Color rez_false = img[img.width()+50, img.height()+50]=Color.Black;
Color rez_true = img[img.width() + 50, img.height() + 50];
Color exepected = img.DefaultColor;
//assert
Assert.AreEqual(exepected,rez_true);
}

[TestMethod]
public void thisPointTest_GetInImage() //Проверка цвета точки в обертке исходного изображения
{
//arrange
string path = "Data\\r50g100b150.png";
IParser parser = new Parser();
Bitmap bitmap = parser.readPNG(path);
// double tall = 0;

Data.Image img = new Data.Image(bitmap, true);
System.Drawing.Point point = new System.Drawing.Point(0, 0);
//act
Color rez = img[point];
Color exepected = Color.FromArgb(255, 50, 100, 150);
//assert
Assert.AreEqual(rez, exepected);
}

[TestMethod]
public void thisPointTest_GetOutSideImage() //Проверка цвета точки за границами обертки исходного изображения
{
//arrange
string path = "Data\\r50g100b150.png";
IParser parser = new Parser();
Bitmap bitmap = parser.readPNG(path);
//double tall = 0;

Data.Image img = new Data.Image(bitmap, true);
System.Drawing.Point point = new System.Drawing.Point(img.width() + 1, img.height() + 1);
//act
Color rez = img[point];
Color exepected = img.DefaultColor; //Цвет по умолчанию
//assert
Debug.WriteLine("Проверка цвета за пределами диапазона");
Assert.AreEqual(exepected, rez);
}

[TestMethod]
public void thisPointTest_SetInImage() //Проверка записи цвета точки в изображении
{
//arrange
string path = "Data\\r50g100b150.png";
IParser parser = new Parser();
Bitmap bitmap = parser.readPNG(path);
// double tall = 0;

Data.Image img = new Data.Image(bitmap, true);
System.Drawing.Point point = new System.Drawing.Point(0, 0);
//act
Color rez = img[point] = Color.Black;
Color exepected = Color.Black;
//assert
Assert.AreEqual(exepected, rez);
}

[TestMethod]
public void thisPointTest_SetOutSideImage() //Проверка записи цвета точки за границами изображения
{
//arrange
string path = "Data\\r50g100b150.png";
IParser parser = new Parser();
Bitmap bitmap = parser.readPNG(path);
// double tall = 0;

Data.Image img = new Data.Image(bitmap, true);
System.Drawing.Point point = new System.Drawing.Point(img.width() + 1, img.height() + 1);
//act
Color rez_false = img[point] = Color.Black;
Color rez_true = img[point];
Color exepected = img.DefaultColor;
//assert
Assert.AreEqual(exepected, rez_true);
}

[TestMethod]
public void SetPixelTest_SetInImage() //Проверка записи цвета пикселя изображения в выходной буфер
{
//arrange
string path = "Data\\r50g100b150.png";
IParser parser = new Parser();
Bitmap bitmap = parser.readPNG(path);
// double tall = 0;

Data.Image img = new Data.Image(bitmap);
System.Drawing.Point point = new System.Drawing.Point(0, 0);
//act
img.SetPixel(point,255, 255, 255);
Color rez = img[0, 0];
Color exepected = Color.White;
//assert
Assert.AreEqual(exepected.ToArgb(), rez.ToArgb());
}

[TestMethod]
public void SetPixelTest_SetOutSideImage() //Проверка записи цвета за границами цветовых значений RGB (0-255)
{
//arrange
string path = "Data\\r50g100b150.png";
IParser parser = new Parser();
Bitmap bitmap = parser.readPNG(path);
// double tall = 0;

Data.Image img = new Data.Image(bitmap);
System.Drawing.Point point = new System.Drawing.Point(0, 0);
//act
img.SetPixel(point, 255, 0, 255);
Color rez = img[0, 0];
Color exepected = Color.FromArgb(255,0,255);
//assert
Assert.AreEqual(exepected, rez);
}




[TestMethod]
public void tall2Test() //Проверка считывания высоты изображения при создании объекта конструктором Image(path)
{
//arrange
string path = "Data\\sample_01.png";
Data.Image img = new Data.Image(path);
//act
double rez = img.tall;
double exepected = 1;
//assert
Assert.AreEqual(exepected, rez);
}

[TestMethod]
public void ConvolutionTest() //Проверка считывания высоты изображения при создании объекта конструктором Image(path)
{
//arrange
/* string path = "Data\\sample_01.png";
Data.Image img = new Data.Image(path);
double[,] matrix=new double[3,3];
int size=3;
for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++)
matrix[i, j] = 0;
matrix[0, 1] = 1;
matrix[1, 0] = 1;
matrix[1, 2] = 1;
matrix[2, 1] = 1;
//act
IParser parser = new Parser();
Bitmap exepected = parser.readPNG(path);
Bitmap rez = img.Convolution(matrix);
//assert
Assert.AreEqual(exepected, rez);*/
}
}
}
15 changes: 14 additions & 1 deletion src/Get3DModel/Get3DModel.UnitTests/PreserveOBJTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Data;
using Preserse;

namespace Get3DModel.UnitTests
{
[TestClass]
public class PreserveOBJTests
{
[TestMethod]
public void TestMethod1()
public void saveOBJTest() //Проверка сохранения файла
{
//arrange
string path = "Solution";
Solution sol = new Solution();
sol.createdBeginSolution(100, 100);
string patchconfig="Parser\\sample.camera";
Setting setting=new Setting(patchconfig);
IPreserveOBJ PresOBJ = new PreserveOBJ();
//act
PresOBJ.saveOBJ(sol, setting, path);
//assert
// Assert.AreEqual(exepected, rez);
}
}
}
13 changes: 12 additions & 1 deletion src/Get3DModel/Get3DModel.UnitTests/PreservePNGTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Data;
using Preserse;

namespace Get3DModel.UnitTests
{
[TestClass]
public class PreservePNGTests
{
[TestMethod]
public void TestMethod1()
public void savePNGTest() //Проверка сохранения OBJ файла
{
//arrange
string path = "Solution";
Solution sol = new Solution();
sol.createdBeginSolution(100, 100);
PreservePNG PresPNG = new PreservePNG();
//act
PresPNG.savePNG(sol, path);
//assert
// Assert.AreEqual(exepected, rez);
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/Get3DModel/Get3DModel/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ static void Main(string[] args)
x => x.EndsWith(".camera") || x.EndsWith(".ini") || x.EndsWith("ConfigurationFile.txt"));
FileInfo fileInf = new FileInfo(pathConfig);
if (fileInf.Exists)
setting = new Setting(pathConfig);
{setting = new Setting(pathConfig);
Console.WriteLine("the verification of the optics configuration file completed successfully");
}
else
{
Console.WriteLine("the configuration file is not found");
Expand All @@ -66,7 +68,7 @@ static void Main(string[] args)
preserveOBJ.saveOBJ(solution, setting, pathFolder);
if(CommandLineParams.Contains("-d")) PreserveOBJ.saveDat(solution.Map, pathFolder);
preservePNG.savePNG(solution, pathFolder);
// Console.Read();//temporary

}
}
}
Expand Down
11 changes: 0 additions & 11 deletions src/Get3DModel/Get3DModel/bin/Debug/Get3DModel.vshost.exe.manifest

This file was deleted.

Loading

0 comments on commit db0ad70

Please sign in to comment.