Fase 1a: Punt -> Vec2 amb operadors moderns

Primera sub-fase del naming sweep. Punt era un struct sense
operacions, conservat per compatibilitat amb el Pascal original.
Substituit per Vec2, un aggregate amb operadors aritmetics, dot,
length, normalized i length_squared (camelBack: lengthSquared)
seguint les regles del .clang-tidy del projecte.

Canvis:
- core/types.hpp reescrit: nou struct Vec2 amb +=,-=,*=,/=,
  unary -, ==, dot, length, lengthSquared, normalized
- Operadors fora de la classe: +, -, *, / (amb float per ambdues
  bandes), - unari, ==
- Vec2 segueix sent aggregate (sense constructors definits):
  els 'designated initializers' del codi existent funcionen igual:
  Vec2{.x = ..., .y = ...}
- Sed global sobre 35 fitxers: tots els 'Punt' -> 'Vec2'

Net: 35 fitxers tocats, +180 / -114. Compila i enllaça.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-19 11:33:27 +02:00
parent 6cf990bc1d
commit cd38101f99
35 changed files with 180 additions and 114 deletions
+4 -4
View File
@@ -19,7 +19,7 @@ enum class PrimitiveType {
// Primitiva individual (polyline o line)
struct ShapePrimitive {
PrimitiveType type;
std::vector<Punt> points; // 2+ punts per polyline, exactament 2 per line
std::vector<Vec2> points; // 2+ punts per polyline, exactament 2 per line
};
// Classe Shape - representa una forma vectorial carregada des de .shp
@@ -39,7 +39,7 @@ class Shape {
[[nodiscard]] const std::vector<ShapePrimitive>& get_primitives() const {
return primitives_;
}
[[nodiscard]] const Punt& get_centre() const { return centre_; }
[[nodiscard]] const Vec2& get_centre() const { return centre_; }
[[nodiscard]] float get_escala_defecte() const { return escala_defecte_; }
[[nodiscard]] bool es_valida() const { return !primitives_.empty(); }
@@ -49,7 +49,7 @@ class Shape {
private:
std::vector<ShapePrimitive> primitives_;
Punt centre_; // Centre/origen de la forma
Vec2 centre_; // Centre/origen de la forma
float escala_defecte_; // Escala per defecte (normalment 1.0)
std::string nom_; // Nom de la forma (per depuració)
@@ -58,7 +58,7 @@ class Shape {
[[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<Punt> parse_points(const std::string& str) const;
[[nodiscard]] std::vector<Vec2> parse_points(const std::string& str) const;
};
} // namespace Graphics