Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Build Project
run: sudo cmake --build . --config Release --target install
- name: Test Project
run: ctest
run: ctest -T test -T coverage

deploy:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)

project(levelz-cpp
LANGUAGES C CXX
VERSION 0.1.1
VERSION 0.2.0
DESCRIPTION "C/C++ implementation of the LevelZ File Format"
HOMEPAGE_URL "https://github.com/LevelZ-File/cpp-bindings"
)
Expand Down
66 changes: 7 additions & 59 deletions include/levelz.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include <string>
#include <vector>
#include <fstream>
Expand All @@ -10,6 +12,7 @@
#include "levelz/coordinate.h"
#include "levelz/block.h"
#include "levelz/level.h"
#include "levelz/matrix.h"

using namespace LevelZ;

Expand Down Expand Up @@ -88,40 +91,14 @@ namespace {
static std::vector<Coordinate2D> read2DPoints(const std::string& input) {
std::vector<Coordinate2D> points;

const std::regex matrix("[\\[\\]()]");
const std::vector<std::string> split = splitString(input, "*");

for (std::string s0 : split) {
if (s0.empty()) continue;

if (s0.rfind('(', 0) == 0 && s0.rfind(']') == s0.size() - 1) {
s0 = std::regex_replace(s0, matrix, "");

unsigned int i = 0;
size_t cpos = 0;
std::string s1;

int x1, x2, y1, y2;
double cx, cy;

while ((cpos = s0.find(',')) != std::string::npos) {
s1 = s0.substr(0, cpos);
switch (i) {
case 0: x1 = std::stoi(s1); break;
case 1: x2 = std::stoi(s1); break;
case 2: y1 = std::stoi(s1); break;
case 3: y2 = std::stoi(s1); break;
case 4: cx = std::stod(s1); break;
case 5: cy = std::stod(s1); break;
}

s0.erase(0, cpos + 1);
i++;
}

for (int x = x1; x < x2; x++)
for (int y = y1; y < y2; y++)
points.push_back(Coordinate2D(cx + x, cy + y));
for (const Coordinate2D& c : LevelZ::CoordinateMatrix2D::from_string(s0))
points.push_back(c);
} else
points.push_back(Coordinate2D::from_string(s0));
}
Expand All @@ -139,37 +116,8 @@ namespace {
if (s0.empty()) continue;

if (s0.rfind('(', 0) == 0 && s0.rfind(']') == s0.size() - 1) {
s0 = std::regex_replace(s0, matrix, "");

unsigned int i = 0;
size_t cpos = 0;
std::string s1;

int x1, x2, y1, y2, z1, z2;
double cx, cy, cz;

while ((cpos = s0.find(',')) != std::string::npos) {
s1 = s0.substr(0, cpos);
switch (i) {
case 0: x1 = std::stoi(s1); break;
case 1: x2 = std::stoi(s1); break;
case 2: y1 = std::stoi(s1); break;
case 3: y2 = std::stoi(s1); break;
case 4: z1 = std::stoi(s1); break;
case 5: z2 = std::stoi(s1); break;
case 6: cx = std::stod(s1); break;
case 7: cy = std::stod(s1); break;
case 8: cz = std::stod(s1); break;
}

s0.erase(0, cpos + 1);
i++;
}

for (int x = x1; x < x2; x++)
for (int y = y1; y < y2; y++)
for (int z = z1; z < z2; z++)
points.push_back(Coordinate3D(cx + x, cy + y, cz + z));
for (const Coordinate3D& c : LevelZ::CoordinateMatrix3D::from_string(s0))
points.push_back(c);
} else
points.push_back(Coordinate3D::from_string(s0));
}
Expand Down
Loading