[Bf-blender-cvs] [e459c264136] newboolean: Fixed violations of new Blender C++ style rules.
Howard Trickey
noreply at git.blender.org
Fri Jul 3 19:31:40 CEST 2020
Commit: e459c26413680f74f558c5bfe5f07a96e9598374
Author: Howard Trickey
Date: Fri Jul 3 11:03:26 2020 -0400
Branches: newboolean
https://developer.blender.org/rBe459c26413680f74f558c5bfe5f07a96e9598374
Fixed violations of new Blender C++ style rules.
===================================================================
M source/blender/blenlib/BLI_boolean.hh
M source/blender/blenlib/BLI_delaunay_2d.h
M source/blender/blenlib/BLI_mesh_intersect.hh
M source/blender/blenlib/intern/boolean.cc
M source/blender/blenlib/intern/delaunay_2d.cc
M source/blender/blenlib/intern/mesh_intersect.cc
===================================================================
diff --git a/source/blender/blenlib/BLI_boolean.hh b/source/blender/blenlib/BLI_boolean.hh
index ea0ca05099f..487a35c55c2 100644
--- a/source/blender/blenlib/BLI_boolean.hh
+++ b/source/blender/blenlib/BLI_boolean.hh
@@ -26,8 +26,7 @@
#include "BLI_mesh_intersect.hh"
#include "BLI_mpq3.hh"
-namespace blender {
-namespace meshintersect {
+namespace blender::meshintersect {
/* Enum values after BOOLEAN_NONE need to match BMESH_ISECT_BOOLEAN_... values in
* editmesh_intersect.c. */
@@ -65,7 +64,6 @@ void write_obj_polymesh(const Array<mpq3> &vert,
const Array<Array<int>> &face,
const std::string &objname);
-} // namespace meshintersect
-} // namespace blender
+} // namespace blender::meshintersect
#endif /* __BLI_BOOLEAN_HH__ */
diff --git a/source/blender/blenlib/BLI_delaunay_2d.h b/source/blender/blenlib/BLI_delaunay_2d.h
index d134e141d4c..818b9b74cd7 100644
--- a/source/blender/blenlib/BLI_delaunay_2d.h
+++ b/source/blender/blenlib/BLI_delaunay_2d.h
@@ -210,14 +210,11 @@ void BLI_delaunay_2d_cdt_free(CDT_result *result);
# include "BLI_array.hh"
# include "BLI_double2.hh"
-# include "BLI_linklist.h"
# include "BLI_math_mpq.hh"
-# include "BLI_mempool.h"
# include "BLI_mpq2.hh"
# include "BLI_vector.hh"
-namespace blender {
-namespace meshintersect {
+namespace blender::meshintersect {
/* vec2<Arith_t> is a 2d vector with Arith_t as the type for coordinates. */
template<typename Arith_t> struct vec2_impl;
@@ -229,151 +226,6 @@ template<> struct vec2_impl<mpq_class> {
};
template<typename Arith_t> using vec2 = typename vec2_impl<Arith_t>::type;
-/* Define a templated 2D arrangment of vertices, edges, and faces.
- * The SymEdge data structure is the basis for a structure that allows
- * easy traversal to neighboring (by toplogy) geometric elements.
- * Each of CDTVert, CDTEdge, and CDTFace have an input_id linked list,
- * whose nodes contain integers that keep track of which input verts, edges,
- * and faces, respectively, that the element was derived from.
- *
- * While this could be cleaned up some, it is usable by other routines in Blender
- * that need to keep track of a 2D arrangement, with topology.
- */
-template<typename Arith_t> class CDTVert;
-template<typename Arith_t> class CDTEdge;
-template<typename Arith_t> class CDTFace;
-
-template<typename Arith_t> class SymEdge {
- public:
- SymEdge<Arith_t> *next{nullptr}; /* In face, doing CCW traversal of face. */
- SymEdge<Arith_t> *rot{nullptr}; /* CCW around vert. */
- CDTVert<Arith_t> *vert{nullptr}; /* Vert at origin. */
- CDTEdge<Arith_t> *edge{nullptr}; /* Undirected edge this is for. */
- CDTFace<Arith_t> *face{nullptr}; /* Face on left side. */
-
- SymEdge() = default;
-};
-
-/* Return other SymEdge for same CDTEdge as se. */
-template<typename T> inline SymEdge<T> *sym(const SymEdge<T> *se)
-{
- return se->next->rot;
-}
-
-/* Return SymEdge whose next is se. */
-template<typename T> inline SymEdge<T> *prev(const SymEdge<T> *se)
-{
- return se->rot->next->rot;
-}
-
-template<typename Arith_t> class CDTVert {
- public:
- vec2<Arith_t> co; /* Coordinate. */
- SymEdge<Arith_t> *symedge{nullptr}; /* Some edge attached to it. */
- LinkNode *input_ids{nullptr}; /* List of corresponding vertex input ids. */
- int index{-1}; /* Index into array that CDTArrangement keeps. */
- int merge_to_index{-1}; /* Index of a CDTVert that this has merged to. -1 if no merge. */
- int visit_index{0}; /* Used by algorithms operating on CDT structures. */
-
- CDTVert() = default;
- explicit CDTVert(const vec2<Arith_t> &pt);
-};
-
-template<typename Arith_t> class CDTEdge {
- public:
- LinkNode *input_ids{nullptr}; /* List of input edge ids that this is part of. */
- SymEdge<Arith_t> symedges[2]{SymEdge<Arith_t>(),
- SymEdge<Arith_t>()}; /* The directed edges for this edge. */
-
- CDTEdge() = default;
-};
-
-template<typename Arith_t> class CDTFace {
- public:
- SymEdge<Arith_t> *symedge{
- nullptr}; /* A symedge in face; only used during output, so only valid then. */
- LinkNode *input_ids{nullptr}; /* List of input face ids that this is part of. */
- int visit_index{0}; /* Used by algorithms operating on CDT structures. */
- bool deleted{false}; /* Marks this face no longer used. */
-
- CDTFace() = default;
-};
-
-template<typename Arith_t> class CDTArrangement {
- public:
- /* The arrangement owns the memory pointed to by the pointers in these vectors.
- * They are pointers instead of actual structures because these vectors may be resized and
- * other elements refer to the elements by pointer.
- */
- Vector<CDTVert<Arith_t> *>
- verts; /* The verts. Some may be merged to others (see their merge_to_index). */
- Vector<CDTEdge<Arith_t> *>
- edges; /* The edges. Some may be deleted (SymEdge next and rot pointers are null). */
- Vector<CDTFace<Arith_t> *> faces; /* The faces. Some may be deleted (see their delete member). */
- CDTFace<Arith_t> *outer_face{nullptr}; /* Which CDTFace is the outer face. */
-
- CDTArrangement() = default;
- ~CDTArrangement();
-
- /* Hint to how much space to reserve in the Vectors of the arrangement, based on these counts of
- * input elements. */
- void reserve(int num_verts, int num_edges, int num_faces);
-
- /* Add a new vertex to the arrangement, with the given 2D coordinate. It will not be connected to
- * anything yet. */
- CDTVert<Arith_t> *add_vert(const vec2<Arith_t> &pt);
-
- /* Add an edge from v1 to v2. The edge will have a left face and a right face, specified by fleft
- * and fright. The edge will not be connected to anything yet. If the vertices do not yet have a
- * symedge pointer, their pointer is set to the symedge in this new edge.
- */
- CDTEdge<Arith_t> *add_edge(CDTVert<Arith_t> *v1,
- CDTVert<Arith_t> *v2,
- CDTFace<Arith_t> *fleft,
- CDTFace<Arith_t> *fright);
-
- /* Add a new face. It is disconnected until an add_edge makes it the left or right face of an
- * edge. */
- CDTFace<Arith_t> *add_face();
-
- /* Make a new edge from v to se->vert, splicing it in. */
- CDTEdge<Arith_t> *add_vert_to_symedge_edge(CDTVert<Arith_t> *v, SymEdge<Arith_t> *se);
-
- /* Assuming s1 and s2 are both SymEdges in a face with > 3 sides and one is not the next of the
- * other, Add an edge from s1->v to s2->v, splitting the face in two. The original face will be
- * the one that s1 has as left face, and a new face will be added and made s2 and its
- * next-cycle's left face.
- */
- CDTEdge<Arith_t> *add_diagonal(SymEdge<Arith_t> *s1, SymEdge<Arith_t> *s2);
-
- /* Connect the verts of se1 and se2, assuming that currently those two SymEdges are on teh outer
- * boundary (have face == outer_face) of two components that are isolated from each other.
- */
- CDTEdge<Arith_t> *connect_separate_parts(SymEdge<Arith_t> *se1, SymEdge<Arith_t> *se2);
-
- /* Split se at fraction lambda, and return the new CDTEdge that is the new second half.
- * Copy the edge input_ids into the new one.
- */
- CDTEdge<Arith_t> *split_edge(SymEdge<Arith_t> *se, Arith_t lambda);
-
- /* Delete an edge. The new combined face on either side of the deleted edge will be the one that
- * was e's face. There will now be an unused face, which will be marked deleted, and an unused
- * CDTEdge, marked by setting the next and rot pointers of its SymEdges to nullptr.
- */
- void delete_edge(SymEdge<Arith_t> *se);
-
- /* If the vertex with index i in the vert array has not been merge, return it.
- * Else return the one that it has merged to. */
- CDTVert<Arith_t> *get_vert_resolve_merge(int i)
- {
- CDTVert<Arith_t> *v = this->verts[i];
- if (v->merge_to_index != -1) {
- v = this->verts[v->merge_to_index];
- }
- return v;
- }
-};
-
template<typename Arith_t> class CDT_input {
public:
Array<vec2<Arith_t>> vert;
@@ -398,8 +250,7 @@ CDT_result<double> delaunay_2d_calc(const CDT_input<double> &input, CDT_output_t
CDT_result<mpq_class> delaunay_2d_calc(const CDT_input<mpq_class> &input,
CDT_output_type output_type);
-} /* namespace meshintersect */
-} /* namespace blender */
+} /* namespace blender::meshintersect */
#endif /* __cplusplus */
diff --git a/source/blender/blenlib/BLI_mesh_intersect.hh b/source/blender/blenlib/BLI_mesh_intersect.hh
index 8ce26b6e533..d1d11401195 100644
--- a/source/blender/blenlib/BLI_mesh_intersect.hh
+++ b/source/blender/blenlib/BLI_mesh_intersect.hh
@@ -30,9 +30,7 @@
#include "BLI_mpq3.hh"
#include "BLI_vector.hh"
-namespace blender {
-
-namespace meshintersect {
+namespace blender::meshintersect {
/* The indices are for vertices in some external space of coordinates.
* The "orig" component is used to track how a triangle originally came
@@ -41,72 +39,54 @@ namespace meshintersect {
* memory.
*/
class IndexedTriangle {
+ int v_[3]{-1, -1, -1};
+ int orig_{-1};
+
public:
IndexedTriangle() = default;
- IndexedTriangle(int v0, int v1, int v2, int orig) : m_v{v0, v1, v2}, m_orig{orig}
- {
- }
- IndexedTriangle(const IndexedTriangle &other)
+ IndexedTriangle(int v0, int v1, int v2, int orig) : v_{v0, v1, v2}, orig_{orig}
{
- m_v[0] = other.m_v[0];
- m_v[1] = other.m_v[1];
- m_v[2] = other.m_v[2];
- m_orig = other.m_orig;
- }
- IndexedTriangle &operator=(const IndexedTriangle &other)
- {
- if (this != &other) {
- m_v[0] = other.m_v[0];
- m_v[1] = other.m_v[1];
- m_v[2] = other.m_v[2];
- m_orig = other.m_orig;
- }
- return *this;
}
int v0() const
{
- return m_v[0];
+ return v_[0];
}
int v1() const
{
- return m_v[1];
+ return v_[1];
}
int v2() const
{
- return m_v[2];
+ return v_[2];
}
int orig() const
{
- return m_orig;
+ return orig_;
}
int operator[](int i) const
{
- return m_v[i];
+ return v_[i];
}
int &operator[](int i)
{
- return m_v[i];
+ return v_[i];
}
bool operator==(const I
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list