Commit f8d5cdf1 authored by kraus's avatar kraus
Browse files

fixing binary format of Portable Bitmap

parent a7080a2f
......@@ -599,13 +599,11 @@ namespace mslang {
Mask *pixmap = static_cast<Mask*>(fun);
std::string str(it, end);
std::cout << str << std::endl;
boost::regex argument("'([^\\0]+)'(\\).*)");
boost::smatch what;
if (!boost::regex_match(str, what, argument)) return false;
std::string filename = what[1];
std::cout << filename << std::endl;
if (!boost::filesystem::exists(filename)) {
ERRORMSG("file '" << filename << "' doesn't exists" << endl);
return false;
......@@ -731,19 +729,23 @@ namespace mslang {
0.0),
bb_m.center_m));
bool allNonEmpty = true;
for (unsigned int i = 0; i < 4u; ++ i) {
next[i].transferIfInside(objects_m);
if (next[i].objects_m.size() == 0) {
allNonEmpty = false;
for (unsigned int j = 0; j < i; ++ j) {
objects_m.merge(next[j].objects_m);
}
}
bool allEmpty = true;
for (unsigned int i = 0; i < 4u; ++ i) {
if (next[i].objects_m.size() != 0) {
allEmpty = false;
break;
}
}
if (!allNonEmpty) {
if (allEmpty) {
for (unsigned int i = 0; i < 4u; ++ i) {
objects_m.merge(next[i].objects_m);
}
delete[] next;
return;
}
......
......@@ -194,9 +194,9 @@ namespace mslang {
out << "# level: " << level_m << ", size: " << objects_m.size() << std::endl;
bb_m.writeGnuplot(out);
out << "# num holes: " << objects_m.size() << std::endl;
for (const Base *obj: objects_m) {
obj->writeGnuplot(out);
}
// for (const Base *obj: objects_m) {
// obj->writeGnuplot(out);
// }
out << std::endl;
if (nodes_m != 0) {
......
......@@ -88,20 +88,22 @@ void PortableBitmapReader::readImageAscii(std::istream &in) {
void PortableBitmapReader::readImageBinary(std::istream &in) {
static const unsigned int sizeChar = sizeof(char) * 8;
unsigned int trueSize = (height_m * width_m);
unsigned int size = trueSize / sizeChar;
if (size * sizeChar != trueSize)
++ size;
unsigned int numBytes = width_m / sizeChar;
if (numBytes * sizeChar != width_m)
++ numBytes;
unsigned int numPixels = 0;
for (unsigned int i = 0; i < size; ++ i) {
char c;
in >> c;
unsigned int numBits = std::min(sizeChar, trueSize - numPixels);
for (unsigned int j = numBits; j > 0 ; -- j, ++ numPixels) {
pixels_m[numPixels] = ((c >> (numBits - 1)) & 1);
for (unsigned int i = 0; i < height_m; ++ i) {
for (unsigned int j = 0; j < numBytes; ++ j) {
unsigned char c;
in >> c;
for (unsigned int j = sizeChar; j > 0 ; -- j) {
pixels_m[numPixels ++] = ((c >> (j - 1)) & 1);
if (numPixels % width_m == 0) {
break;
}
}
}
}
}
\ No newline at end of file
......@@ -33,7 +33,6 @@ int main(int argc, char *argv[])
std::istreambuf_iterator<char>());
const unsigned int method = (atoi(argv[2]) == 0 ? 0: 1);
std::cout << method << std::endl;
const unsigned int N = atoi(argv[3]);
// std::string str("repeat( translate(union(rectangle(0.1, 0.1), ellipse(0.1, 0.1)), -0.01, -0.02), 2, 0.1, 0.2)");
......@@ -42,8 +41,8 @@ int main(int argc, char *argv[])
str = boost::regex_replace(str, boost::regex("\\s"), std::string(""), boost::match_default | boost::format_all);
if (parse(str, fun)) {
fun->print(0);
std::cout << "\n" << std::endl;
// fun->print(0);
// std::cout << "\n" << std::endl;
std::vector<mslang::Base*> baseBlocks;
fun->apply(baseBlocks);
......@@ -86,7 +85,7 @@ int main(int argc, char *argv[])
mslang::QuadTree tree;
tree.bb_m = mslang::BoundingBox(llc, urc);
std::cout << tree.bb_m << std::endl;
tree.objects_m.insert(tree.objects_m.end(), baseBlocks.begin(), baseBlocks.end());
tree.buildUp();
......@@ -95,7 +94,7 @@ int main(int argc, char *argv[])
out.close();
if (false) {
if (true) {
out.open("particles.gpl");
gsl_rng *rng = gsl_rng_alloc(gsl_rng_default);
......
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