[Bf-blender-cvs] [f60100b8ca4] soc-2021-adaptive-cloth: adaptive_cloth: operator << overload for debug printing
ishbosamiya
noreply at git.blender.org
Mon Jun 28 08:28:23 CEST 2021
Commit: f60100b8ca4d8287e9b620b1a79d1fd3aae244c7
Author: ishbosamiya
Date: Thu Jun 24 12:05:19 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBf60100b8ca4d8287e9b620b1a79d1fd3aae244c7
adaptive_cloth: operator << overload for debug printing
===================================================================
M source/blender/blenkernel/BKE_cloth_remesh.hh
M source/blender/blenlib/BLI_generational_arena.hh
===================================================================
diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index 1d97503a147..a5856a7e4dc 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -49,6 +49,7 @@ void BKE_cloth_remesh(const struct Object *ob,
# include <bits/stdint-uintn.h>
# include <filesystem>
# include <fstream>
+# include <iostream>
# include <istream>
# include <limits>
# include <sstream>
@@ -84,6 +85,27 @@ using EdgeVerts = std::tuple<VertIndex, VertIndex>;
using usize = uint64_t;
+template<typename T> std::ostream &operator<<(std::ostream &stream, const blender::Vector<T> &vec)
+{
+ stream << "(";
+ for (const auto &i : vec) {
+ stream << i << ", ";
+ }
+ stream << "\b\b)";
+ return stream;
+}
+
+template<typename T> std::ostream &operator<<(std::ostream &stream, const std::optional<T> &option)
+{
+ if (option) {
+ stream << "Some(" << option << ")";
+ }
+ else {
+ stream << "None";
+ }
+ return stream;
+}
+
/**
* `Node`: Stores the worldspace/localspace coordinates of the
* `Mesh`. Commonly called the vertex of the mesh (note: in this mesh
@@ -110,6 +132,13 @@ template<typename T> class Node {
this->extra_data = extra_data;
}
+ friend std::ostream &operator<<(std::ostream &stream, const Node &node)
+ {
+ stream << "(" << node.self_index << ", " << node.verts << ", " << node.pos << ","
+ << node.normal << ")";
+ return stream;
+ }
+
template<typename, typename, typename, typename> friend class Mesh;
};
@@ -143,6 +172,13 @@ template<typename T> class Vert {
this->extra_data = extra_data;
}
+ friend std::ostream &operator<<(std::ostream &stream, const Vert &vert)
+ {
+ stream << "(" << vert.self_index << ", " << vert.edges << ", " << vert.node << "," << vert.uv
+ << ")";
+ return stream;
+ }
+
template<typename, typename, typename, typename> friend class Mesh;
};
@@ -189,6 +225,17 @@ template<typename T> class Edge {
return false;
}
+ const auto &get_faces() const
+ {
+ return this->faces;
+ }
+
+ friend std::ostream &operator<<(std::ostream &stream, const Edge &edge)
+ {
+ stream << "(" << edge.self_index << ", " << edge.faces << ", " << edge.verts << ")";
+ return stream;
+ }
+
template<typename, typename, typename, typename> friend class Mesh;
};
@@ -221,6 +268,17 @@ template<typename T> class Face {
this->extra_data = extra_data;
}
+ const auto &get_verts() const
+ {
+ return this->verts;
+ }
+
+ friend std::ostream &operator<<(std::ostream &stream, const Face &face)
+ {
+ stream << "(" << face.self_index << ", " << face.verts << ", " << face.normal << ")";
+ return stream;
+ }
+
template<typename, typename, typename, typename> friend class Mesh;
};
diff --git a/source/blender/blenlib/BLI_generational_arena.hh b/source/blender/blenlib/BLI_generational_arena.hh
index 94738881404..ed065256c53 100644
--- a/source/blender/blenlib/BLI_generational_arena.hh
+++ b/source/blender/blenlib/BLI_generational_arena.hh
@@ -105,6 +105,12 @@ class Index {
return std::make_tuple(this->index, this->generation);
}
+ friend std::ostream &operator<<(std::ostream &stream, const Index &index)
+ {
+ stream << "(" << index.index << ", " << index.generation << ")";
+ return stream;
+ }
+
template<typename, int64_t, typename> friend class Arena;
};
More information about the Bf-blender-cvs
mailing list