Skip to content

Commit

Permalink
fix: discard not-implemented 3d all different
Browse files Browse the repository at this point in the history
  • Loading branch information
william-silversmith committed Oct 30, 2024
1 parent f7434b3 commit 3881262
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion zmesh/_zmesh.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cdef extern from "utility.hpp":
float* vertices, uint64_t num_vertices,
unsigned int* faces, uint64_t num_faces,
float cx, float cy, float cz
)
) except +

cdef extern from "cMesher.hpp":
cdef cppclass CMesher[P,L,S]:
Expand Down
2 changes: 1 addition & 1 deletion zmesh/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def viewer(self):
render_window_interactor.SetRenderWindow(render_window)

render_window.SetSize(1024, 1024)

renderer.AddActor(actor)
renderer.SetBackground(0.1, 0.2, 0.3) # Background color

Expand Down
20 changes: 8 additions & 12 deletions zmesh/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ void fix_all_different(
unsigned int f2,
unsigned int f3 // outlier
) {

// printf("all different\n");

Vec3 v1(vertices[3*f1+0], vertices[3*f1+1], vertices[3*f1+2]);
Vec3 v2(vertices[3*f2+0], vertices[3*f2+1], vertices[3*f2+2]);
Vec3 v3(vertices[3*f3+0], vertices[3*f3+1], vertices[3*f3+2]);
Expand All @@ -227,14 +224,12 @@ void fix_all_different(
throw std::runtime_error("This code only handles differences of a single 26-connected grid space.");
}

if (delta12.num_non_zero_dims() == 3
|| delta13.num_non_zero_dims() == 3
|| delta23.num_non_zero_dims() == 3) {
Vec3<int32_t> is3d = delta12.abs() + delta23.abs() + delta13.abs();

throw std::runtime_error("3d all different not supported yet.");
if (is3d.num_non_zero_dims() == 3) {
return;
}


// rearrange vertices so that vertex 1 is in the single
// zone difference position for both 2 and 3
if (delta12.num_non_zero_dims() == 1 && delta13.num_non_zero_dims() != 1) {
Expand Down Expand Up @@ -263,7 +258,7 @@ void fix_all_different(
delta13 = (g3 - g1);

int yaxis = 0;
if (delta13.y != 0) {
if (delta13.y != 0 && xaxis != 1) {
yaxis = 1;
}
else if (delta13.z != 0) {
Expand Down Expand Up @@ -358,7 +353,6 @@ void fix_all_different(
|| (v3.get(yaxis) < plane_offset_y && i23_0.get(yaxis) >= plane_offset_y)
) {
// 5 triangle situation

m3.add_point(i13);
m3i13 = m3.last_face();
m3.add_point(i23_1);
Expand Down Expand Up @@ -458,8 +452,6 @@ void fix_single_outlier_18_connected(
const unsigned int f3 // outlier
) {

// printf("18 connected\n");

const Vec3 v1(vertices[3*f1+0], vertices[3*f1+1], vertices[3*f1+2]);
const Vec3 v2(vertices[3*f2+0], vertices[3*f2+1], vertices[3*f2+2]);
const Vec3 v3(vertices[3*f3+0], vertices[3*f3+1], vertices[3*f3+2]);
Expand Down Expand Up @@ -755,6 +747,7 @@ void fix_single_outlier(
) {

auto z1 = zones[f1];
auto z2 = zones[f2];
auto z3 = zones[f3];

Vec3<int32_t> g1 = zone2grid(z1, gs);
Expand Down Expand Up @@ -786,6 +779,9 @@ void fix_single_outlier(
f1, f2, f3
);
}
else {
throw std::runtime_error("Non-zero delta was not 1,2, or 3.");
}
}

std::vector<MeshObject> chunk_mesh_accelerated(
Expand Down

0 comments on commit 3881262

Please sign in to comment.