Commit: 8556a10bd9f608ebdbf8d1faf573fc53aa59324a
Author: Howard Trickey
Date:   Fri Aug 28 10:21:59 2020 -0400
Branches: newboolean
https://developer.blender.org/rB8556a10bd9f608ebdbf8d1faf573fc53aa59324a

Moved orientation etc tests into BLI_math_boolean.hh.

These tests are only used by the delaunay, mesh_intersect,
and mesh_boolean files. At the suggestion of Brecht, moving
them into BLI_math_boolean.hh and math_boolean.cc.

===================================================================

M       source/blender/blenlib/BLI_double2.hh
M       source/blender/blenlib/BLI_double3.hh
A       source/blender/blenlib/BLI_math_boolean.hh
M       source/blender/blenlib/BLI_mpq2.hh
M       source/blender/blenlib/BLI_mpq3.hh
M       source/blender/blenlib/CMakeLists.txt
M       source/blender/blenlib/intern/delaunay_2d.cc
A       source/blender/blenlib/intern/math_boolean.cc
M       source/blender/blenlib/intern/math_vec.cc
M       source/blender/blenlib/intern/mesh_boolean.cc
M       source/blender/blenlib/intern/mesh_intersect.cc

===================================================================

diff --git a/source/blender/blenlib/BLI_double2.hh 
b/source/blender/blenlib/BLI_double2.hh
index 37584729498..3466b946e73 100644
--- a/source/blender/blenlib/BLI_double2.hh
+++ b/source/blender/blenlib/BLI_double2.hh
@@ -138,14 +138,6 @@ struct double2 {
                                     const double2 &v2,
                                     const double2 &v3,
                                     const double2 &v4);
-
-  static int orient2d(const double2 &a, const double2 &b, const double2 &c);
-
-  static int orient2d_fast(const double2 &a, const double2 &b, const double2 
&c);
-
-  static int incircle(const double2 &a, const double2 &b, const double2 &c, 
const double2 &d);
-
-  static int incircle_fast(const double2 &a, const double2 &b, const double2 
&c, const double2 &d);
 };
 
 }  // namespace blender
diff --git a/source/blender/blenlib/BLI_double3.hh 
b/source/blender/blenlib/BLI_double3.hh
index f783055590a..5b6204935d7 100644
--- a/source/blender/blenlib/BLI_double3.hh
+++ b/source/blender/blenlib/BLI_double3.hh
@@ -240,20 +240,6 @@ struct double3 {
   }
 
   static double3 cross_poly(Span<double3> poly);
-
-  /* #orient3d gives the exact result, using multi-precision arithmetic when 
result
-   * is close to zero. orient3d_fast just uses double arithmetic, so may be
-   * wrong if the answer is very close to zero.
-   * Similarly, for #insphere and #insphere_fast. */
-  static int orient3d(const double3 &a, const double3 &b, const double3 &c, 
const double3 &d);
-
-  static int orient3d_fast(const double3 &a, const double3 &b, const double3 
&c, const double3 &d);
-
-  static int insphere(
-      const double3 &a, const double3 &b, const double3 &c, const double3 &d, 
const double3 &e);
-
-  static int insphere_fast(
-      const double3 &a, const double3 &b, const double3 &c, const double3 &d, 
const double3 &e);
 };
 
 }  // namespace blender
diff --git a/source/blender/blenlib/BLI_math_boolean.hh 
b/source/blender/blenlib/BLI_math_boolean.hh
new file mode 100644
index 00000000000..da79e9eeaba
--- /dev/null
+++ b/source/blender/blenlib/BLI_math_boolean.hh
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup bli
+ * \brief Math vector functions needed specifically for mesh intersect and 
boolean.
+ */
+
+#include "BLI_double2.hh"
+#include "BLI_double3.hh"
+
+#ifdef WITH_GMP
+#include "BLI_math_mpq.hh"
+#include "BLI_mpq2.hh"
+#include "BLI_mpq3.hh"
+#endif
+
+namespace blender {
+
+/* #orient2d gives the exact result, using multi-precision arithmetic when 
result
+* is close to zero. orient3d_fast just uses double arithmetic, so may be
+* wrong if the answer is very close to zero.
+* Similarly, for #incircle and #incircle_fast. */
+int orient2d(const double2 &a, const double2 &b, const double2 &c);
+int orient2d_fast(const double2 &a, const double2 &b, const double2 &c);
+
+int incircle(const double2 &a, const double2 &b, const double2 &c, const 
double2 &d);
+int incircle_fast(const double2 &a, const double2 &b, const double2 &c, const 
double2 &d);
+
+
+/* #orient3d gives the exact result, using multi-precision arithmetic when 
result
+ * is close to zero. orient3d_fast just uses double arithmetic, so may be
+ * wrong if the answer is very close to zero.
+ * Similarly, for #insphere and #insphere_fast. */
+int orient3d(const double3 &a, const double3 &b, const double3 &c, const 
double3 &d);
+int orient3d_fast(const double3 &a, const double3 &b, const double3 &c, const 
double3 &d);
+
+int insphere(const double3 &a, const double3 &b, const double3 &c, const 
double3 &d, const double3 &e);
+int insphere_fast(const double3 &a, const double3 &b, const double3 &c, const 
double3 &d, const double3 &e);
+
+#ifdef WITH_GMP
+int orient2d(const mpq2 &a, const mpq2 &b, const mpq2 &c);
+int incircle(const mpq2 &a, const mpq2 &b, const mpq2 &c, const mpq2 &d);
+int orient3d(const mpq3 &a, const mpq3 &b, const mpq3 &c, const mpq3 &d);
+#endif
+}  // namespace blender
diff --git a/source/blender/blenlib/BLI_mpq2.hh 
b/source/blender/blenlib/BLI_mpq2.hh
index c7d8eaeeeb6..6261b50466b 100644
--- a/source/blender/blenlib/BLI_mpq2.hh
+++ b/source/blender/blenlib/BLI_mpq2.hh
@@ -175,10 +175,6 @@ struct mpq2 {
                                     const mpq2 &v3,
                                     const mpq2 &v4);
 
-  static int orient2d(const mpq2 &a, const mpq2 &b, const mpq2 &c);
-
-  static int incircle(const mpq2 &a, const mpq2 &b, const mpq2 &c, const mpq2 
&d);
-
   /** There is a sensible use for hashing on exact arithmetic types. */
   uint64_t hash() const;
 };
diff --git a/source/blender/blenlib/BLI_mpq3.hh 
b/source/blender/blenlib/BLI_mpq3.hh
index fc59448b104..fb5e2b61cdb 100644
--- a/source/blender/blenlib/BLI_mpq3.hh
+++ b/source/blender/blenlib/BLI_mpq3.hh
@@ -270,8 +270,6 @@ struct mpq3 {
 
   static mpq3 cross_poly(Span<mpq3> poly);
 
-  static int orient3d(const mpq3 &a, const mpq3 &b, const mpq3 &c, const mpq3 
&d);
-
   /** There is a sensible use for hashing on exact arithmetic types. */
   uint64_t hash() const;
 };
diff --git a/source/blender/blenlib/CMakeLists.txt 
b/source/blender/blenlib/CMakeLists.txt
index f2069e484d2..1db45cff09a 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -90,6 +90,7 @@ set(SRC
   intern/math_base_inline.c
   intern/math_base_safe_inline.c
   intern/math_bits_inline.c
+  intern/math_boolean.cc
   intern/math_color.c
   intern/math_color_blend_inline.c
   intern/math_color_inline.c
@@ -220,6 +221,7 @@ set(SRC
   BLI_math_base.h
   BLI_math_base_safe.h
   BLI_math_bits.h
+  BLI_math_boolean.hh
   BLI_math_color.h
   BLI_math_color_blend.h
   BLI_math_geom.h
diff --git a/source/blender/blenlib/intern/delaunay_2d.cc 
b/source/blender/blenlib/intern/delaunay_2d.cc
index 9bc81d2cbb6..7b0f6a658ce 100644
--- a/source/blender/blenlib/intern/delaunay_2d.cc
+++ b/source/blender/blenlib/intern/delaunay_2d.cc
@@ -26,6 +26,7 @@
 #include "BLI_array.hh"
 #include "BLI_double2.hh"
 #include "BLI_linklist.h"
+#include "BLI_math_boolean.hh"
 #include "BLI_math_mpq.hh"
 #include "BLI_mpq2.hh"
 #include "BLI_vector.hh"
@@ -956,19 +957,19 @@ template<typename T> void 
find_site_merges(Array<SiteInfo<T>> &sites)
 
 template<typename T> inline bool vert_left_of_symedge(CDTVert<T> *v, 
SymEdge<T> *se)
 {
-  return vec2<T>::orient2d(v->co, se->vert->co, se->next->vert->co) > 0;
+  return orient2d(v->co, se->vert->co, se->next->vert->co) > 0;
 }
 
 template<typename T> inline bool vert_right_of_symedge(CDTVert<T> *v, 
SymEdge<T> *se)
 {
-  return vec2<T>::orient2d(v->co, se->next->vert->co, se->vert->co) > 0;
+  return orient2d(v->co, se->next->vert->co, se->vert->co) > 0;
 }
 
 /* Is se above basel? */
 template<typename T>
 inline bool dc_tri_valid(SymEdge<T> *se, SymEdge<T> *basel, SymEdge<T> 
*basel_sym)
 {
-  return vec2<T>::orient2d(se->next->vert->co, basel_sym->vert->co, 
basel->vert->co) > 0;
+  return orient2d(se->next->vert->co, basel_sym->vert->co, basel->vert->co) > 
0;
 }
 
 /**
@@ -1012,7 +1013,7 @@ void dc_tri(CDTArrangement<T> *cdt,
     }
     CDTVert<T> *v3 = sites[start + 2].v;
     CDTEdge<T> *eb = cdt->add_vert_to_symedge_edge(v3, &ea->symedges[1]);
-    int orient = vec2<T>::orient2d(v1->co, v2->co, v3->co);
+    int orient = orient2d(v1->co, v2->co, v3->co);
     if (orient > 0) {
       cdt->add_diagonal(&eb->symedges[0], &ea->symedges[0]);
       *r_le = &ea->symedges[0];
@@ -1100,10 +1101,10 @@ void dc_tri(CDTArrangement<T> *cdt,
         std::cout << "found valid lcand\n";
         std::cout << "  lcand" << lcand << "\n";
       }
-      while (vec2<T>::incircle(basel_sym->vert->co,
-                               basel->vert->co,
-                               lcand->next->vert->co,
-                               lcand->rot->next->vert->co) > 0.0) {
+      while (incircle(basel_sym->vert->co,
+                      basel->vert->co,
+                      lcand->next->vert->co,
+                      lcand->rot->next->vert->co) > 0.0) {
         if (dbg_level > 1) {
           std::cout << "incircle says to remove lcand\n";
           std::cout << "  lcand" << lcand << "\n";
@@ -1119,10 +1120,10 @@ void dc_tri(CDTArrangement<T> *cdt,
         std::cout << "found valid rcand\n";
         std::cout << "  rcand" << rcand << "\n";
       }
-      while (vec2<T>::incircle(basel_sym->vert->co,
-                               basel->vert->co,
-                               rcand->next->vert->co,
-                               sym(rcand)->next->next->vert->co) > 0.0) {
+      while (incircle(basel_sym->vert->co,
+                      basel->vert->co,
+                      rcand->next->vert->co,
+                      sym(rcand)->next->next->vert->co) > 0.0) {
         if (dbg_level > 0) {
           std::cout << "incircle says to remove rcand\n";
           std::cout << "  rcand" << rcand << "\n";
@@ -1146,10 +1147,10 @@ void dc_tri(CDTArrangement<T> *cdt,
     }
     /* The next cross edge to be connected is to either `lcand->next->vert` or 
`rcand->next->vert`;
      * if both are valid, choose the appropriate one using the #incircle test. 
*/
-    if (!valid_lcand || (valid_rcand && 
vec2<T>::incircle(lcand->next->vert->co,
-                                                          lcand->vert->co,
-                                                          rcand->vert->co,
-                                                          
rcand->next->vert->co) > 0)) {
+    if (!valid_lcand ||
+        (valid_rcand &&
+         incircle(lcand->next-

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to