b746578bc8
Sustituye en bloque las cabeceras de los archivos por una sola línea de copyright. Cero rastro de "Visente", "Sergi" o "1999" en el árbol del proyecto. Se eliminan también las variantes "© 2025 Port a C++20", "© 2025 Port a C++20 con SDL3" y "© 2025 Orni Attack" (con todas sus colas descriptivas como "Arquitectura de entidades" o "Sistema de física"), que en este punto eran ruido histórico. Aplicado con un par de sed (find -type f, excluyendo source/external y source/legacy): 1. \|^// © 1999 Visente i Sergi (versión Pascal)$|d 2. s|^// © 2025 (Port a C++20.*|Orni Attack.*)$|// © 2026 JailDesigner| Verificado: la única variante de cabecera tras el sweep es "// © 2026 JailDesigner". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
65 lines
2.2 KiB
C++
65 lines
2.2 KiB
C++
// shape.hpp - Sistema de formes vectorials
|
|
// © 2026 JailDesigner
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "core/types.hpp"
|
|
|
|
namespace Graphics {
|
|
|
|
// Tipo de primitiva dins de una shape
|
|
enum class PrimitiveType {
|
|
POLYLINE, // Secuencia de points connectats
|
|
LINE // Línia individual (2 points)
|
|
};
|
|
|
|
// Primitiva individual (polyline o line)
|
|
struct ShapePrimitive {
|
|
PrimitiveType type;
|
|
std::vector<Vec2> points; // 2+ points per polyline, exactament 2 per line
|
|
};
|
|
|
|
// Clase Shape - representa una shape vectorial carregada desde .shp
|
|
class Shape {
|
|
public:
|
|
// Constructors
|
|
Shape() = default;
|
|
explicit Shape(const std::string& filepath);
|
|
|
|
// Carregar shape desde file .shp
|
|
bool load(const std::string& filepath);
|
|
|
|
// Parsejar shape desde buffer de memòria (per al sistema de recursos)
|
|
bool parseFile(const std::string& contingut);
|
|
|
|
// Getters
|
|
[[nodiscard]] const std::vector<ShapePrimitive>& get_primitives() const {
|
|
return primitives_;
|
|
}
|
|
[[nodiscard]] const Vec2& getCenter() const { return center_; }
|
|
[[nodiscard]] float get_escala_defecte() const { return escala_defecte_; }
|
|
[[nodiscard]] bool isValid() const { return !primitives_.empty(); }
|
|
|
|
// Info de depuració
|
|
[[nodiscard]] std::string get_nom() const { return nom_; }
|
|
[[nodiscard]] size_t get_num_primitives() const { return primitives_.size(); }
|
|
|
|
private:
|
|
std::vector<ShapePrimitive> primitives_;
|
|
Vec2 center_; // Centro/origin de la shape
|
|
float escala_defecte_; // Escala per defecte (normalment 1.0)
|
|
std::string nom_; // Nom de la shape (per depuració)
|
|
|
|
// Helpers privats per parsejar
|
|
[[nodiscard]] std::string trim(const std::string& str) const;
|
|
[[nodiscard]] bool starts_with(const std::string& str, const std::string& prefix) const;
|
|
[[nodiscard]] std::string extract_value(const std::string& line) const;
|
|
void parse_center(const std::string& value);
|
|
[[nodiscard]] std::vector<Vec2> parse_points(const std::string& str) const;
|
|
};
|
|
|
|
} // namespace Graphics
|