[Bf-blender-cvs] [590ce6817d7] newboolean: Change bmesh_boolean.c into a C++ file and start using PolyMesh interface.
Howard Trickey
noreply at git.blender.org
Thu Jul 2 16:14:40 CEST 2020
Commit: 590ce6817d76b01d1eff0a54bf2f5240596ccefa
Author: Howard Trickey
Date: Wed Jul 1 09:15:17 2020 -0400
Branches: newboolean
https://developer.blender.org/rB590ce6817d76b01d1eff0a54bf2f5240596ccefa
Change bmesh_boolean.c into a C++ file and start using PolyMesh interface.
Also, use BLI_math_mpq.hh everywhere instead of gmpxx.h.
===================================================================
M release/scripts/addons
M source/blender/blenlib/BLI_boolean.h
M source/blender/blenlib/BLI_delaunay_2d.h
M source/blender/blenlib/BLI_math_mpq.hh
M source/blender/blenlib/BLI_mesh_intersect.hh
M source/blender/blenlib/BLI_mpq2.hh
M source/blender/blenlib/BLI_mpq3.hh
M source/blender/blenlib/intern/boolean.cc
M source/blender/blenlib/intern/delaunay_2d.cc
M source/blender/blenlib/intern/math_vec.cc
M source/blender/bmesh/CMakeLists.txt
D source/blender/bmesh/tools/bmesh_boolean.c
A source/blender/bmesh/tools/bmesh_boolean.cc
M source/blender/bmesh/tools/bmesh_boolean.h
M tests/gtests/blenlib/BLI_boolean_test.cc
M tests/gtests/blenlib/BLI_delaunay_2d_test.cc
M tests/gtests/blenlib/BLI_mesh_intersect_test.cc
===================================================================
diff --git a/release/scripts/addons b/release/scripts/addons
index aea05413b76..c83bd8d7068 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit aea05413b7689f1c72e04804b4faabc3694aec91
+Subproject commit c83bd8d7068b7bbf59b88c984d213592d1887e5f
diff --git a/source/blender/blenlib/BLI_boolean.h b/source/blender/blenlib/BLI_boolean.h
index c28c71d3be6..55155afc1d4 100644
--- a/source/blender/blenlib/BLI_boolean.h
+++ b/source/blender/blenlib/BLI_boolean.h
@@ -57,9 +57,9 @@ void BLI_boolean_trimesh_free(Boolean_trimesh_output *output);
}
# include "BLI_array.hh"
+# include "BLI_math_mpq.hh"
# include "BLI_mesh_intersect.hh"
# include "BLI_mpq3.hh"
-# include "gmpxx.h"
namespace blender {
namespace meshintersect {
diff --git a/source/blender/blenlib/BLI_delaunay_2d.h b/source/blender/blenlib/BLI_delaunay_2d.h
index 34722982022..96501268cee 100644
--- a/source/blender/blenlib/BLI_delaunay_2d.h
+++ b/source/blender/blenlib/BLI_delaunay_2d.h
@@ -208,12 +208,11 @@ void BLI_delaunay_2d_cdt_free(CDT_result *result);
/* C++ Interface. */
-# include "gmpxx.h"
-
# include "BLI_array.hh"
# include "BLI_double2.hh"
# include "BLI_linklist.h"
# include "BLI_mempool.h"
+# include "BLI_math_mpq.hh"
# include "BLI_mpq2.hh"
# include "BLI_vector.hh"
diff --git a/source/blender/blenlib/BLI_math_mpq.hh b/source/blender/blenlib/BLI_math_mpq.hh
index ede30da29b8..06fa0a2e257 100644
--- a/source/blender/blenlib/BLI_math_mpq.hh
+++ b/source/blender/blenlib/BLI_math_mpq.hh
@@ -17,10 +17,15 @@
#ifndef __BLI_MATH_MPQ_HH__
#define __BLI_MATH_MPQ_HH__
+/* This file uses an external file header to define the multiprecision
+ * rational type, mpq_class.
+ * This class keeps separate multiprecision integer numerator and
+ * denominator, reduced to lowest terms after each arithmetic operation.
+ * It can be used where it is important to have exact arithmetic results.
+ *
+ * See gmplib.org for full documentation. In particular:
+ * https://gmplib.org/manual/C_002b_002b-Interface-Rationals
+ */
#include "gmpxx.h"
-namespace BLI {
-
-} // namespace BLI
-
-#endif /* __BLI_MATH_NPQ_HH__ */
+#endif /* __BLI_MATH_MPQ_HH__ */
diff --git a/source/blender/blenlib/BLI_mesh_intersect.hh b/source/blender/blenlib/BLI_mesh_intersect.hh
index dcdc93d8e6f..8ce26b6e533 100644
--- a/source/blender/blenlib/BLI_mesh_intersect.hh
+++ b/source/blender/blenlib/BLI_mesh_intersect.hh
@@ -25,9 +25,8 @@
#include <iostream>
-#include "gmpxx.h"
-
#include "BLI_array.hh"
+#include "BLI_math_mpq.hh"
#include "BLI_mpq3.hh"
#include "BLI_vector.hh"
diff --git a/source/blender/blenlib/BLI_mpq2.hh b/source/blender/blenlib/BLI_mpq2.hh
index b9a519404b4..6ad36e645f0 100644
--- a/source/blender/blenlib/BLI_mpq2.hh
+++ b/source/blender/blenlib/BLI_mpq2.hh
@@ -17,8 +17,6 @@
#ifndef __BLI_MPQ2_HH__
#define __BLI_MPQ2_HH__
-#include "gmpxx.h"
-
#include "BLI_math_mpq.hh"
#include "BLI_mpq3.hh"
diff --git a/source/blender/blenlib/BLI_mpq3.hh b/source/blender/blenlib/BLI_mpq3.hh
index 1efa8c9ad7b..82cae0bd26d 100644
--- a/source/blender/blenlib/BLI_mpq3.hh
+++ b/source/blender/blenlib/BLI_mpq3.hh
@@ -21,7 +21,6 @@
#include "BLI_math.h"
#include "BLI_math_mpq.hh"
-#include "gmpxx.h"
namespace blender {
diff --git a/source/blender/blenlib/intern/boolean.cc b/source/blender/blenlib/intern/boolean.cc
index 6f0b18f42d1..55f969c1b81 100644
--- a/source/blender/blenlib/intern/boolean.cc
+++ b/source/blender/blenlib/intern/boolean.cc
@@ -18,14 +18,13 @@
#include <fstream>
#include <iostream>
-#include "gmpxx.h"
-
#include "BLI_array.hh"
#include "BLI_assert.h"
#include "BLI_delaunay_2d.h"
#include "BLI_hash.hh"
#include "BLI_map.hh"
#include "BLI_math.h"
+#include "BLI_math_mpq.hh"
#include "BLI_mesh_intersect.hh"
#include "BLI_mpq3.hh"
#include "BLI_set.hh"
diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc
index e7691317210..ac3868dc194 100644
--- a/source/blender/blenlib/intern/delaunay_2d.cc
+++ b/source/blender/blenlib/intern/delaunay_2d.cc
@@ -19,11 +19,10 @@
#include <iostream>
#include <sstream>
-#include "gmpxx.h"
-
#include "BLI_array.hh"
#include "BLI_double2.hh"
#include "BLI_linklist.h"
+#include "BLI_math_mpq.hh"
#include "BLI_mpq2.hh"
#include "BLI_vector.hh"
diff --git a/source/blender/blenlib/intern/math_vec.cc b/source/blender/blenlib/intern/math_vec.cc
index 793c4c78148..3261d5f5f69 100644
--- a/source/blender/blenlib/intern/math_vec.cc
+++ b/source/blender/blenlib/intern/math_vec.cc
@@ -18,13 +18,12 @@
* \ingroup bli
*/
-#include "gmpxx.h"
-
#include "BLI_double2.hh"
#include "BLI_double3.hh"
#include "BLI_float2.hh"
#include "BLI_float3.hh"
#include "BLI_hash.hh"
+#include "BLI_math_mpq.hh"
#include "BLI_mpq2.hh"
#include "BLI_mpq3.hh"
#include "BLI_utildefines.h"
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index cead636404b..5e2a689bc95 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -135,7 +135,7 @@ set(SRC
tools/bmesh_bevel.h
tools/bmesh_bisect_plane.c
tools/bmesh_bisect_plane.h
- tools/bmesh_boolean.c
+ tools/bmesh_boolean.cc
tools/bmesh_boolean.h
tools/bmesh_decimate.h
tools/bmesh_decimate_collapse.c
@@ -199,4 +199,16 @@ if(WITH_FREESTYLE)
add_definitions(-DWITH_FREESTYLE)
endif()
+if(WITH_GMP)
+ add_definitions(-DWITH_GMP)
+
+ list(APPEND INC_SYS
+ ${GMP_INCLUDE_DIRS}
+ )
+
+ list(APPEND LIB
+ ${GMP_LIBRARIES}
+ )
+endif()
+
blender_add_lib(bf_bmesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/bmesh/tools/bmesh_boolean.c b/source/blender/bmesh/tools/bmesh_boolean.c
deleted file mode 100644
index 67bf834be3a..00000000000
--- a/source/blender/bmesh/tools/bmesh_boolean.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/** \file
- * \ingroup bmesh
- *
- * Main functions for boolean on a BMesh (used by the tool and modifier)
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_boolean.h"
-#include "BLI_math.h"
-
-#include "bmesh.h"
-#include "bmesh_boolean.h"
-
-/* Make a a triangle mesh for input to the Boolean function.
- * We take only take triangles from faces f for which test_fn(f, user_data) returns 'side'.
- * Caller must call free_trimesh_input when done with the returned value. */
-static Boolean_trimesh_input *trimesh_input_from_bm(BMesh *bm,
- struct BMLoop *(*looptris)[3],
- const int looptris_tot,
- int (*(test_fn))(BMFace *f, void *user_data),
- void *user_data,
- int side)
-{
- int i, in_v_index, in_t_index, bmv_index, looptri_index, tot_in_vert, tot_in_tri;
- Boolean_trimesh_input *trimesh;
- int *bmv_to_v, *v_to_bmv, *t_to_looptri;
- BMFace *f;
-
- BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
- BM_mesh_elem_table_ensure(bm, BM_VERT | BM_FACE);
- trimesh = MEM_mallocN(sizeof(*trimesh), __func__);
- bmv_to_v = MEM_malloc_arrayN(bm->totvert, sizeof(int), __func__);
- v_to_bmv = MEM_malloc_arrayN(bm->totvert, sizeof(int), __func__);
- t_to_looptri = MEM_malloc_arrayN(looptris_tot, sizeof(int), __func__);
- for (i = 0; i < bm->totvert; i++) {
- bmv_to_v[i] = -1;
- v_to_bmv[i] = -1;
- }
- in_v_index = 0;
- tot_in_tri = 0;
- for (looptri_index = 0; looptri_index < looptris_tot; looptri_index++) {
- f = looptris[looptri_index][0]->f;
- if (test_fn(f, user_data) == side) {
- t_to_looptri[tot_in_tri++] = looptri_index;
- for (i = 0; i < 3; i++) {
- bmv_index = BM_elem_index_get(looptris[looptri_index][i]->v);
- if (bmv_to_v[bmv_index] == -1) {
- v_to_bmv[in_v_index] = bmv_index;
- bmv_to_v[bmv_index] = in_v_index;
- in_v_index++;
- }
- }
- }
- }
- tot_in_vert = in_v_index;
- trimesh->vert_len = tot_in_vert;
- trimesh->tri_len = tot_in_tri;
- trimesh->vert_coord = MEM_malloc_arrayN(tot_in_vert, sizeof(trimesh->vert_coord[0]), __func__);
- trimesh->tri = MEM_malloc_arrayN(tot_in_tri, sizeof(trimesh->tri[0]), __func__);
- for (in_v_index = 0; in_v_index < tot_in_vert; in_v_index++) {
- bmv_index = v_to_bmv[in_v_index];
- BMVert *bmv = BM_vert_at_index(bm, bmv_index);
- copy_v3_v3(trimesh->vert_coord[in_v_index], bmv->co);
- }
- for (in_t_index = 0; in_t_index < tot_in_tri; in_t_index++) {
- looptri_index = t_to_looptri[in_t_index];
- for (i = 0; i < 3; i++) {
- bmv_index = BM_elem_index_get(looptris[looptri_index][i]->v);
- BLI_assert(bmv_to_v[bmv_index] != -1);
- trimesh->tri[in_t_index][i] = bmv_to_v[bmv_index];
- }
- }
- MEM_freeN(bmv_to_v);
- MEM_freeN(v_to_bmv);
- MEM_freeN(t_to_looptri);
-
- return trimesh;
-}
-
-static void free_trimesh_input(Boolean_trimesh_input *in)
-{
- MEM_freeN(in->vert_coord);
- MEM_freeN(in->tri);
- MEM_freeN(in);
-}
-
-static void apply_trimesh_output_to_bmesh(BMesh *bm, Boolean_trimesh_output *out)
-{
- /* For now, for testing, just create new BMesh elements for returned subdivided mesh and kill old
- * mesh. */
- int v, t;
- BMIter iter;
- BMVert *bmv, *bmv_next;
-
- BM_ITER_MESH_MUTABLE (bmv, bmv_next, &iter, bm, BM_VERTS_OF_MESH) {
- BM_vert_kill(bm, bmv);
- }
-
- if (out->vert_len > 0 && out->t
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list