mirror of https://github.com/vitalif/openscad
parent
94d11adeb2
commit
4d619a7e38
|
@ -1200,6 +1200,10 @@ add_cmdline_test(throwntogethertest EXE ${OPENSCAD_BINPATH} ARGS --preview=throw
|
|||
# with anything. It's self-contained and returns != 0 on error
|
||||
add_cmdline_test(cgalstlsanitytest EXE ${CMAKE_SOURCE_DIR}/cgalstlsanitytest SUFFIX txt ARGS ${OPENSCAD_BINPATH} FILES ${CGALSTLSANITYTEST_FILES})
|
||||
|
||||
# Export/Import 3d png tests.
|
||||
add_cmdline_test(stlpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/test_3d_export.py ARGS ${OPENSCAD_BINPATH} --colorscheme=Monotone STL EXPECTEDDIR cgalpngtest SUFFIX png FILES ${EXPORT3D_TEST_FILES})
|
||||
add_cmdline_test(offpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT ${CMAKE_SOURCE_DIR}/test_3d_export.py ARGS ${OPENSCAD_BINPATH} --colorscheme=Montone OFF EXPECTEDDIR cgalpngtest SUFFIX png FILES ${EXPORT3D_TEST_FILES})
|
||||
|
||||
# Add experimental tests
|
||||
|
||||
list(APPEND EXPERIMENTAL_TEXT_FILES
|
||||
|
|
|
@ -100,19 +100,19 @@ public:
|
|||
}
|
||||
unsigned char Get_Red(unsigned int i) const
|
||||
{
|
||||
return (Data[i] & 0xFF);
|
||||
return (Data[i%Data.size()] & 0xFF);
|
||||
}
|
||||
unsigned char Get_Green(unsigned int i) const
|
||||
{
|
||||
return ((Data[i] >> 8) & 0xFF);
|
||||
return ((Data[i%Data.size()] >> 8) & 0xFF);
|
||||
}
|
||||
unsigned char Get_Blue(unsigned int i) const
|
||||
{
|
||||
return ((Data[i] >> 16) & 0xFF);
|
||||
return ((Data[i%Data.size()] >> 16) & 0xFF);
|
||||
}
|
||||
unsigned char Get_Alpha(unsigned int i) const
|
||||
{
|
||||
return ((Data[i] >> 24) & 0xFF);
|
||||
return ((Data[i%Data.size()] >> 24) & 0xFF);
|
||||
}
|
||||
void Set(unsigned char r, unsigned char g, unsigned char b,
|
||||
unsigned char a, unsigned int i)
|
||||
|
@ -137,7 +137,7 @@ public:
|
|||
}
|
||||
unsigned int Get(unsigned int i) const
|
||||
{
|
||||
return Data[i];
|
||||
return Data[i%Data.size()];
|
||||
}
|
||||
const string &Get_Name() const
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ public:
|
|||
//ordered RGBARGBA..., use it as texture, draw it, ...
|
||||
cout << "width " << width << ", height " << height << "\n";
|
||||
|
||||
RGBAImage *rgbaimg = new RGBAImage(width,height,"newimage");
|
||||
RGBAImage *rgbaimg = new RGBAImage(width,height,filename);
|
||||
|
||||
for(unsigned y = 0; y < height; y += 1) {
|
||||
for(unsigned x = 0; x < width; x += 1) {
|
||||
|
@ -208,9 +208,111 @@ public:
|
|||
}
|
||||
return rgbaimg;
|
||||
}
|
||||
|
||||
void UpSample()
|
||||
{
|
||||
unsigned char red, green, blue, alpha;
|
||||
unsigned oldwidth = Width;
|
||||
//unsigned oldheight = Height;
|
||||
unsigned newwidth = Width*2;
|
||||
unsigned newheight = Height*2;
|
||||
RGBAImage newimg( newwidth, newheight, this->Name );
|
||||
for (unsigned x = 0; x < newwidth; x++) {
|
||||
for (unsigned y = 0; y < newheight; y++) {
|
||||
red = this->Get_Red( (y/2)*oldwidth + (x/2) );
|
||||
green = this->Get_Green( (y/2)*oldwidth + (x/2) );
|
||||
blue = this->Get_Blue( (y/2)*oldwidth + (x/2) );
|
||||
alpha = this->Get_Alpha( (y/2)*oldwidth + (x/2) );
|
||||
newimg.Set( red, green, blue, alpha, y*newwidth+x );
|
||||
}
|
||||
}
|
||||
Width = newwidth;
|
||||
Height = newheight;
|
||||
Data.clear();
|
||||
Data.resize( newimg.Data.size() );
|
||||
for (unsigned i=0;i<newimg.Data.size();i++) {
|
||||
Data[i] = newimg.Data[i];
|
||||
}
|
||||
}
|
||||
|
||||
// make the image half its original size.
|
||||
// this will slightly blur the image.
|
||||
// the result somewhat resembles antialiasing.
|
||||
void DownSample()
|
||||
{
|
||||
unsigned int redsum,greensum,bluesum,alphasum;
|
||||
unsigned int redavg,greenavg,blueavg,alphaavg;
|
||||
unsigned char red, green, blue, alpha;
|
||||
unsigned oldwidth = Width;
|
||||
//unsigned oldheight = Height;
|
||||
unsigned newwidth = Width/2;
|
||||
unsigned newheight = Height/2;
|
||||
RGBAImage newimg( newwidth, newheight, this->Name );
|
||||
for (unsigned x = 0; x < newwidth; x++) {
|
||||
for (unsigned y = 0; y < newheight; y++) {
|
||||
redsum=greensum=bluesum=alphasum=0;
|
||||
redavg=greenavg=blueavg=alphaavg=0;
|
||||
for (int i=-1;i<=1;i++) {
|
||||
for (int j=-1;j<=1;j++) {
|
||||
red = this->Get_Red( (y*2+i)*oldwidth + (x*2+j) );
|
||||
green = this->Get_Green( (y*2+i)*oldwidth + (x*2+j) );
|
||||
blue = this->Get_Blue( (y*2+i)*oldwidth + (x*2+j) );
|
||||
alpha = this->Get_Alpha( (y*2+i)*oldwidth + (x*2+j) );
|
||||
redsum += red;
|
||||
greensum += green;
|
||||
bluesum += blue;
|
||||
alphasum += alpha;
|
||||
}
|
||||
}
|
||||
redavg = redsum / 9;
|
||||
greenavg = greensum / 9;
|
||||
blueavg = bluesum / 9;
|
||||
alphaavg = alphasum / 9;
|
||||
newimg.Set( redavg, greenavg, blueavg, alphaavg, y*newwidth+x );
|
||||
}
|
||||
}
|
||||
Width = newwidth;
|
||||
Height = newheight;
|
||||
Data.clear();
|
||||
Data.resize( newimg.Data.size() );
|
||||
for (unsigned i=0;i<newimg.Data.size();i++) {
|
||||
Data[i] = newimg.Data[i];
|
||||
}
|
||||
}
|
||||
|
||||
// this somewhat resembles antialiasing.
|
||||
void SimpleBlur()
|
||||
{
|
||||
unsigned int redsum,greensum,bluesum,alphasum;
|
||||
unsigned int redavg,greenavg,blueavg,alphaavg;
|
||||
unsigned char red, green, blue, alpha;
|
||||
for (unsigned x = 0; x < Width; x++) {
|
||||
for (unsigned y = 0; y < Height; y++) {
|
||||
redsum=greensum=bluesum=alphasum=0;
|
||||
redavg=greenavg=blueavg=alphaavg=0;
|
||||
for (int i=-1;i<=1;i++) {
|
||||
for (int j=-1;j<=1;j++) {
|
||||
red = this->Get_Red( (y+i)*Width + (x+j) );
|
||||
green = this->Get_Green( (y+i)*Width + (x+j) );
|
||||
blue = this->Get_Blue( (y+i)*Width + (x+j) );
|
||||
alpha = this->Get_Alpha( (y+i)*Width + (x+j) );
|
||||
redsum += red;
|
||||
greensum += green;
|
||||
bluesum += blue;
|
||||
alphasum += alpha;
|
||||
}
|
||||
}
|
||||
redavg = redsum / 9;
|
||||
greenavg = greensum / 9;
|
||||
blueavg = bluesum / 9;
|
||||
alphaavg = alphasum / 9;
|
||||
this->Set( redavg, greenavg, blueavg, alphaavg, y*Width+x );
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
const unsigned int Width;
|
||||
const unsigned int Height;
|
||||
unsigned int Width;
|
||||
unsigned int Height;
|
||||
const string Name;
|
||||
vector<unsigned int> Data;
|
||||
};
|
||||
|
@ -294,7 +396,9 @@ public:
|
|||
Luminance = 100.0f;
|
||||
ColorFactor = 0.1f;
|
||||
MaxPyramidLevels = 2;
|
||||
FinalMaxPyramidLevels = 5;
|
||||
//FinalMaxPyramidLevels = 5; // 58 fails
|
||||
FinalMaxPyramidLevels = 3; // 57 fails
|
||||
//FinalMaxPyramidLevels = 2; // 75 fails
|
||||
FlipExit = false;
|
||||
}
|
||||
bool Parse_Args(int argc, char **argv)
|
||||
|
@ -459,6 +563,7 @@ public:
|
|||
ImgDiff = new RGBAImage(ImgA->Get_Width(), ImgA->Get_Height(),
|
||||
output_file_name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1060,6 +1165,37 @@ bool LevelClimberCompare(CompareArgs &args) {
|
|||
cout << ". Rerunning with " << args.MaxPyramidLevels << "\n";
|
||||
test = Yee_Compare_Engine( args );
|
||||
}
|
||||
if (test==false) {
|
||||
cout << "Tests failed at final max pyramid level. \n";
|
||||
//cout << "Retesting with Downsampling (shrink/blur image)\n";
|
||||
cout << "Retesting with downsampling and simple blur\n";
|
||||
|
||||
// args.ImgA->UpSample();
|
||||
// args.ImgB->UpSample();
|
||||
args.ImgA->DownSample();
|
||||
args.ImgB->DownSample();
|
||||
if (args.ImgDiff) {
|
||||
args.ImgA->WriteToFile( args.ImgDiff->Get_Name()+".1.downsample.png" );
|
||||
args.ImgB->WriteToFile( args.ImgDiff->Get_Name()+".2.downsample.png" );
|
||||
args.ImgDiff->DownSample();
|
||||
}
|
||||
|
||||
// i=1, lots of fail
|
||||
// i=2, 8 fail
|
||||
// i=3, 7 fail
|
||||
for (int i=0;i<3;i++){
|
||||
args.ImgA->SimpleBlur();
|
||||
args.ImgB->SimpleBlur();
|
||||
}
|
||||
|
||||
if (args.ImgDiff) {
|
||||
args.ImgA->WriteToFile( args.ImgDiff->Get_Name()+".1.simpleblur.png" );
|
||||
args.ImgB->WriteToFile( args.ImgDiff->Get_Name()+".2.simpleblur.png" );
|
||||
}
|
||||
|
||||
args.ColorFactor = 0.05;
|
||||
test = Yee_Compare_Engine( args );
|
||||
}
|
||||
return test;
|
||||
}
|
||||
|
||||
|
@ -1109,14 +1245,14 @@ int main(int argc, char **argv)
|
|||
if (args.Verbose)
|
||||
{
|
||||
if (interactive()) std::cout << green;
|
||||
std::cout << "PASS: " << args.ErrorStr;
|
||||
std::cout << "PASS: result: " << args.ErrorStr;
|
||||
if (interactive()) std::cout << nocolor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (interactive()) std::cout << red;
|
||||
std::cout << "FAIL: " << args.ErrorStr;
|
||||
std::cout << "FAIL: result: " << args.ErrorStr;
|
||||
if (interactive()) std::cout << nocolor;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue