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
11 changes: 3 additions & 8 deletions AE_PunktBeschriftung/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
cmake_minimum_required(VERSION 3.17)
project(labelpoints)
project(label_map)

set(CMAKE_CXX_STANDARD 20)

add_executable(label_map src/main/main.cpp
src/main/generator/InstanceGenerator.cpp
src/main/representations/Instance.cpp
src/main/representations/PointWithLabel.cpp
src/main/representations/Box.cpp
src/main/representations/Point2D.cpp
src/main/representations/Solution.cpp
src/main/representations/Rectangle.cpp
src/main/representations/PlacedRectangle.cpp
src/main/representations/Defs.cpp src/main/solver/TrivialSolver.cpp include/solver/TrivialSolver.hpp
src/main/representations/Point.cpp
src/main/solver/TrivialSolver.cpp
src/main/io/InstanceReader.cpp)

target_include_directories(label_map PUBLIC include)
Expand Down
7 changes: 3 additions & 4 deletions AE_PunktBeschriftung/include/generator/InstanceGenerator.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef UNTITLED_INSTANCEGENERATOR_HPP
#define UNTITLED_INSTANCEGENERATOR_HPP
#pragma once

#include <representations/Instance.hpp>

#include <iostream>
#include "../representations/Instance.hpp"

class InstanceGenerator {

Expand All @@ -11,4 +11,3 @@ class InstanceGenerator {
unsigned int seed);
};

#endif //UNTITLED_INSTANCEGENERATOR_HPP
16 changes: 7 additions & 9 deletions AE_PunktBeschriftung/include/io/InstanceReader.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#ifndef INSTANCE_READER_HPP
#define INSTANCE_READER_HPP

#include <string>
#pragma once

#include <representations/Instance.hpp>
#include <representations/Solution.hpp>
#include <representations/Point.hpp>

void readInstance(Instance& instance, const std::string& filename);
#include <string>

void readInstanceAndSolution(Instance& instance, Solution& solution, const std::string& filename);
Instance readInstance(const std::string& filename);

std::shared_ptr<PointWithLabel> parseLine(std::string const& line);
void parseLine(Instance& instance, const std::string& line);

int parsePositiveInteger(const std::string& line);

void checkBoxConsistency(int x, int y, int width, int height, int upperLeftX, int upperLeftY);
#endif //INSTANCE_READER_HPP

Point::Corner parseCornerPlacement(int x, int y, int upperLeftX, int upperLeftY);
23 changes: 0 additions & 23 deletions AE_PunktBeschriftung/include/representations/Box.hpp

This file was deleted.

16 changes: 0 additions & 16 deletions AE_PunktBeschriftung/include/representations/Defs.hpp

This file was deleted.

30 changes: 20 additions & 10 deletions AE_PunktBeschriftung/include/representations/Instance.hpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
#ifndef UNTITLED_INSTANCE_HPP
#define UNTITLED_INSTANCE_HPP
#pragma once

#include <stack>
#include <representations/Point.hpp>
#include <vector>
#include <representations/PointWithLabel.hpp>

class Instance {

private:
std::vector<std::shared_ptr<PointWithLabel> > points;

friend std::ostream &operator<<(std::ostream &ostream, const Instance &instance);
std::vector<Point> points; // contains all points of the instance

std::vector<int> labelled_points; // contains all indices of points with actual labels

friend std::ostream& operator<<(std::ostream &ostream, const Instance &instance);

public:
Instance();

Instance(int size);

void reserve(int num);

void operator+(std::shared_ptr<PointWithLabel> point2D);
void add(const Point& point);

int size() const;

const std::shared_ptr<PointWithLabel>& getPoint(int idx) const;
void setLabel(int idx, Point::Corner corner);

const Point& getPoint(int idx) const;

std::vector<int>& getLabelledPoints();

int countLabelledPoints() const;

bool isFeasible() const;
};

#endif //UNTITLED_INSTANCE_HPP
36 changes: 0 additions & 36 deletions AE_PunktBeschriftung/include/representations/PlacedRectangle.hpp

This file was deleted.

50 changes: 50 additions & 0 deletions AE_PunktBeschriftung/include/representations/Point.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#pragma once

#include <string>
#include <tuple>

using Point2D = std::tuple<int, int>;

class Point {

public:

enum Corner {
NOT_PLACED = 0, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT
};

private:

int x;
int y;
int width;
int height;
std::string label;
Corner placement;

std::tuple<int, int> upperLeft;
std::tuple<int, int> lowerRight;

friend std::ostream &operator<<(std::ostream &ostream, const Point &point);

public:

Point(int x, int y, int width, int height, std::string label);

int getX() const;

int getY() const;

std::string getName() const;

void setPlacement(Corner placement);

const Corner& getPlacement() const;

bool checkCollision(const Point& other, Corner corner) const;

bool checkCollision(const Point& other) const;

std::tuple< Point2D, Point2D > getCoordsForPlacement(Corner corner) const;

};
18 changes: 0 additions & 18 deletions AE_PunktBeschriftung/include/representations/Point2D.hpp

This file was deleted.

28 changes: 0 additions & 28 deletions AE_PunktBeschriftung/include/representations/PointWithLabel.hpp

This file was deleted.

33 changes: 0 additions & 33 deletions AE_PunktBeschriftung/include/representations/Rectangle.hpp

This file was deleted.

48 changes: 0 additions & 48 deletions AE_PunktBeschriftung/include/representations/Solution.hpp

This file was deleted.

11 changes: 0 additions & 11 deletions AE_PunktBeschriftung/include/solver/Solver.hpp

This file was deleted.

Loading