[Bf-blender-cvs] [6b140b0fb92] quadriflow: More quadriflow review fixes
Sebastian Parborg
noreply at git.blender.org
Tue Sep 10 18:36:19 CEST 2019
Commit: 6b140b0fb92357dd5b4c43aa45934de41872b478
Author: Sebastian Parborg
Date: Tue Sep 10 18:31:05 2019 +0200
Branches: quadriflow
https://developer.blender.org/rB6b140b0fb92357dd5b4c43aa45934de41872b478
More quadriflow review fixes
===================================================================
M extern/quadriflow/CMakeLists.txt
M extern/quadriflow/src/main.cpp
M extern/quadriflow/src/parametrizer-mesh.cpp
M extern/quadriflow/src/parametrizer.hpp
M intern/quadriflow/CMakeLists.txt
M intern/quadriflow/quadriflow_capi.cpp
M intern/quadriflow/quadriflow_capi.hpp
M release/scripts/startup/bl_ui/properties_data_mesh.py
M source/blender/blenkernel/BKE_mesh_remesh_voxel.h
M source/blender/blenkernel/intern/mesh_remesh_voxel.c
M source/blender/editors/object/object_remesh.c
===================================================================
diff --git a/extern/quadriflow/CMakeLists.txt b/extern/quadriflow/CMakeLists.txt
index bb794e31c42..488d95a48b9 100644
--- a/extern/quadriflow/CMakeLists.txt
+++ b/extern/quadriflow/CMakeLists.txt
@@ -1,3 +1,30 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# 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.
+#
+# The Original Code is Copyright (C) 2019, Blender Foundation
+# All rights reserved.
+# ***** END GPL LICENSE BLOCK *****
+
+# avoid noisy warnings
+if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
+ add_c_flag(
+ "-Wno-unused-result"
+ )
+endif()
+
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
diff --git a/extern/quadriflow/src/main.cpp b/extern/quadriflow/src/main.cpp
index 41ba1ab82d0..18bc4063c42 100644
--- a/extern/quadriflow/src/main.cpp
+++ b/extern/quadriflow/src/main.cpp
@@ -30,8 +30,8 @@ int main(int argc, char** argv) {
output_obj = argv[i + 1];
} else if (strcmp(argv[i], "-sharp") == 0) {
field.flag_preserve_sharp = 1;
- } else if (strcmp(argv[i], "-border") == 0) {
- field.flag_preserve_border = 1;
+ } else if (strcmp(argv[i], "-boundary") == 0) {
+ field.flag_preserve_boundary = 1;
} else if (strcmp(argv[i], "-adaptive") == 0) {
field.flag_adaptive_scale = 1;
} else if (strcmp(argv[i], "-mcf") == 0) {
@@ -56,8 +56,8 @@ int main(int argc, char** argv) {
t2 = GetCurrentTime64();
printf("Use %lf seconds\n", (t2 - t1) * 1e-3);
- if (field.flag_preserve_border) {
- printf("Add border constrains...\n");
+ if (field.flag_preserve_boundary) {
+ printf("Add boundary constrains...\n");
Hierarchy& mRes = field.hierarchy;
mRes.clearConstraints();
for (uint32_t i = 0; i < 3 * mRes.mF.cols(); ++i) {
diff --git a/extern/quadriflow/src/parametrizer-mesh.cpp b/extern/quadriflow/src/parametrizer-mesh.cpp
index b0fa5268528..19effe92390 100644
--- a/extern/quadriflow/src/parametrizer-mesh.cpp
+++ b/extern/quadriflow/src/parametrizer-mesh.cpp
@@ -124,7 +124,7 @@ void Parametrizer::ComputeMeshStatus() {
void Parametrizer::ComputeSharpEdges() {
sharp_edges.resize(F.cols() * 3, 0);
- if (flag_preserve_border) {
+ if (flag_preserve_boundary) {
for (int i = 0; i < sharp_edges.size(); ++i) {
int re = E2E[i];
if (re == -1) {
diff --git a/extern/quadriflow/src/parametrizer.hpp b/extern/quadriflow/src/parametrizer.hpp
index 74306e50fb7..1f4a02be6c2 100644
--- a/extern/quadriflow/src/parametrizer.hpp
+++ b/extern/quadriflow/src/parametrizer.hpp
@@ -162,7 +162,7 @@ class Parametrizer {
// flag
int flag_preserve_sharp = 0;
- int flag_preserve_border = 0;
+ int flag_preserve_boundary = 0;
int flag_adaptive_scale = 0;
int flag_aggresive_sat = 0;
int flag_minimum_cost_flow = 0;
diff --git a/intern/quadriflow/CMakeLists.txt b/intern/quadriflow/CMakeLists.txt
index 01b0eb15f36..615d5a34ce6 100644
--- a/intern/quadriflow/CMakeLists.txt
+++ b/intern/quadriflow/CMakeLists.txt
@@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-# The Original Code is Copyright (C) 2015, Blender Foundation
+# The Original Code is Copyright (C) 2019, Blender Foundation
# All rights reserved.
# ***** END GPL LICENSE BLOCK *****
diff --git a/intern/quadriflow/quadriflow_capi.cpp b/intern/quadriflow/quadriflow_capi.cpp
index 7cb13e9fd88..3d3aac2e4f4 100644
--- a/intern/quadriflow/quadriflow_capi.cpp
+++ b/intern/quadriflow/quadriflow_capi.cpp
@@ -29,28 +29,28 @@
using namespace qflow;
-struct obj_vertex {
+struct ObjVertex {
uint32_t p = (uint32_t)-1;
uint32_t n = (uint32_t)-1;
uint32_t uv = (uint32_t)-1;
- inline obj_vertex()
+ ObjVertex()
{
}
- inline obj_vertex(uint32_t pi)
+ ObjVertex(uint32_t pi)
{
p = pi;
}
- inline bool operator==(const obj_vertex &v) const
+ bool operator==(const ObjVertex &v) const
{
return v.p == p && v.n == n && v.uv == uv;
}
};
-struct obj_vertexHash : std::unary_function<obj_vertex, size_t> {
- std::size_t operator()(const obj_vertex &v) const
+struct ObjVertexHash : std::unary_function<ObjVertex, size_t> {
+ std::size_t operator()(const ObjVertex &v) const
{
size_t hash = std::hash<uint32_t>()(v.p);
hash = hash * 37 + std::hash<uint32_t>()(v.uv);
@@ -59,21 +59,21 @@ struct obj_vertexHash : std::unary_function<obj_vertex, size_t> {
}
};
-typedef std::unordered_map<obj_vertex, uint32_t, obj_vertexHash> VertexMap;
+typedef std::unordered_map<ObjVertex, uint32_t, ObjVertexHash> VertexMap;
-void quadriflow_remesh(QuadriflowRemeshData *qrd)
+void QFLOW_quadriflow_remesh(QuadriflowRemeshData *qrd)
{
Parametrizer field;
-
VertexMap vertexMap;
- int faces = -1;
- faces = qrd->target_faces;
+
+ /* Get remeshing parameters. */
+ int faces = qrd->target_faces;
if (qrd->preserve_sharp) {
field.flag_preserve_sharp = 1;
}
- if (qrd->preserve_border) {
- field.flag_preserve_border = 1;
+ if (qrd->preserve_boundary) {
+ field.flag_preserve_boundary = 1;
}
if (qrd->adaptive_scale) {
field.flag_adaptive_scale = 1;
@@ -88,9 +88,10 @@ void quadriflow_remesh(QuadriflowRemeshData *qrd)
field.hierarchy.rng_seed = qrd->rng_seed;
}
+ /* Copy mesh to quadriflow data structures. */
std::vector<Vector3d> positions;
std::vector<uint32_t> indices;
- std::vector<obj_vertex> vertices;
+ std::vector<ObjVertex> vertices;
for (int i = 0; i < qrd->totverts; i++) {
Vector3d v(qrd->verts[i * 3], qrd->verts[i * 3 + 1], qrd->verts[i * 3 + 2]);
@@ -100,15 +101,15 @@ void quadriflow_remesh(QuadriflowRemeshData *qrd)
for (int q = 0; q < qrd->totfaces; q++) {
Vector3i f(qrd->faces[q * 3], qrd->faces[q * 3 + 1], qrd->faces[q * 3 + 2]);
- obj_vertex tri[6];
+ ObjVertex tri[6];
int nVertices = 3;
- tri[0] = obj_vertex(f[0]);
- tri[1] = obj_vertex(f[1]);
- tri[2] = obj_vertex(f[2]);
+ tri[0] = ObjVertex(f[0]);
+ tri[1] = ObjVertex(f[1]);
+ tri[2] = ObjVertex(f[2]);
for (int i = 0; i < nVertices; ++i) {
- const obj_vertex &v = tri[i];
+ const ObjVertex &v = tri[i];
VertexMap::const_iterator it = vertexMap.find(v);
if (it == vertexMap.end()) {
vertexMap[v] = (uint32_t)vertices.size();
@@ -125,13 +126,16 @@ void quadriflow_remesh(QuadriflowRemeshData *qrd)
memcpy(field.F.data(), indices.data(), sizeof(uint32_t) * indices.size());
field.V.resize(3, vertices.size());
- for (uint32_t i = 0; i < vertices.size(); ++i)
+ for (uint32_t i = 0; i < vertices.size(); ++i) {
field.V.col(i) = positions.at(vertices[i].p);
+ }
+ /* Start processing the input mesh data */
field.NormalizeMesh();
field.Initialize(faces);
- if (field.flag_preserve_border) {
+ /* Setup mesh boundary constraints if needed */
+ if (field.flag_preserve_boundary) {
Hierarchy &mRes = field.hierarchy;
mRes.clearConstraints();
for (uint32_t i = 0; i < 3 * mRes.mF.cols(); ++i) {
@@ -152,20 +156,24 @@ void quadriflow_remesh(QuadriflowRemeshData *qrd)
mRes.propagateConstraints();
}
+ /* Optimize the mesh field orientations (tangental field etc) */
Optimizer::optimize_orientations(field.hierarchy);
field.ComputeOrientationSingularities();
if (field.flag_adaptive_scale == 1) {
field.EstimateSlope();
}
+
Optimizer::optimize_scale(field.hierarchy, field.rho, field.flag_adaptive_scale);
field.flag_adaptive_scale = 1;
Optimizer::optimize_positions(field.hierarchy, field.flag_adaptive_scale);
field.ComputePositionSingularities();
+ /* Compute the final quad geomtry using a maxflow solver */
field.ComputeIndexMap();
+ /* Get the output mesh data */
qrd->out_totverts = field.O_compact.size();
qrd->out_totfaces = field.F_compact.size();
diff --git a/intern/quadriflow/quadriflow_capi.hpp b/intern/quadriflow/quadriflow_capi.hpp
index 7d881fcf242..0c6ae1d20e2 100644
--- a/intern/quadriflow/quadriflow_capi.hpp
+++ b/intern/quadriflow/quadriflow_capi.hpp
@@ -23,30 +23,30 @@
extern "C" {
#endif
-typedef struct{
- float *verts;
- unsigned int *faces;
- int totfaces;
- int totverts;
-
- float *out_verts;
- unsigned int *out_faces;
- int out_totverts;
- int out_totfaces;
-
- int target_faces;
- bool preserve_sharp;
- bool preserve_border;
- bool adaptive_scale;
- bool minimum_cost_flow;
- bool aggresive_sat;
+typedef struct QuadriflowRemeshData {
+ float *verts;
+ unsigned int *faces;
+ int totfaces;
+ int totverts;
+
+ float *out_verts;
+ unsigned int *out_faces;
+ int out_totverts;
+ int out_totfaces;
+
+ int target_faces;
+ bool preserve_sharp;
+ bool preserve_boundary;
+ bool adaptive_scale;
+ bool minimum_cost_flow;
+ bool aggresive_sat;
int rng_seed;
} QuadriflowRemeshData;
-void quadriflow_remesh(QuadriflowRemeshData* qrd);
+void QFLOW_quadriflow_remesh(QuadriflowRemeshData *qrd);
#ifdef __cplusplus
}
#endif
-#endif // QUADRIFLOW_CAPI_HPP
+#endif // QUADRIFLOW_CAPI_HPP
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 60413cb290d..74869c2c812 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -476,7 +476,7 @@ class DATA_PT_remesh(MeshButtonsPanel, Panel):
col.operator("object.voxel_reme
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list