|
|
@ -6,9 +6,7 @@ |
|
|
|
|
|
|
|
#include <fstream> |
|
|
|
|
|
|
|
|
|
|
|
void export_halfpatch_obj( |
|
|
|
const stl_vector_mp<Eigen::Vector3d>& iso_pts, |
|
|
|
void export_halfpatch_obj(const stl_vector_mp<Eigen::Vector3d>& iso_pts, |
|
|
|
const stl_vector_mp<polygon_face_t>& iso_faces, |
|
|
|
const stl_vector_mp<stl_vector_mp<uint32_t>>& patches, |
|
|
|
const std::string& filename) |
|
|
@ -34,9 +32,7 @@ void export_halfpatch_obj( |
|
|
|
ofs << "mtllib " << mtl_filename << "\n"; |
|
|
|
|
|
|
|
// 输出所有顶点
|
|
|
|
for (const auto& v : iso_pts) { |
|
|
|
ofs << "v " << v.x() << " " << v.y() << " " << v.z() << "\n"; |
|
|
|
} |
|
|
|
for (const auto& v : iso_pts) { ofs << "v " << v.x() << " " << v.y() << " " << v.z() << "\n"; } |
|
|
|
|
|
|
|
// 遍历所有 half-patch
|
|
|
|
for (size_t half_patch = 0; half_patch < patches.size() * 2; ++half_patch) { |
|
|
@ -48,11 +44,9 @@ void export_halfpatch_obj( |
|
|
|
const auto& face = iso_faces[face_idx]; |
|
|
|
ofs << "f"; |
|
|
|
if (is_forward) { |
|
|
|
for (auto vi : face.vertex_indices) |
|
|
|
ofs << " " << (vi + 1); |
|
|
|
for (auto vi : face.vertex_indices) ofs << " " << (vi + 1); |
|
|
|
} else { |
|
|
|
for (auto it = face.vertex_indices.rbegin(); it != face.vertex_indices.rend(); ++it) |
|
|
|
ofs << " " << (*it + 1); |
|
|
|
for (auto it = face.vertex_indices.rbegin(); it != face.vertex_indices.rend(); ++it) ofs << " " << (*it + 1); |
|
|
|
} |
|
|
|
ofs << "\n"; |
|
|
|
} |
|
|
@ -60,6 +54,33 @@ void export_halfpatch_obj( |
|
|
|
ofs.close(); |
|
|
|
} |
|
|
|
|
|
|
|
void export_obj(const stl_vector_mp<Eigen::Vector3d>& vertices, |
|
|
|
stl_vector_mp<uint32_t>& faces, |
|
|
|
stl_vector_mp<uint32_t>& output_vertex_counts_of_face, |
|
|
|
const std::string& filename) |
|
|
|
{ |
|
|
|
std::string obj_filename = filename + ".obj"; |
|
|
|
std::ofstream ofs(obj_filename); |
|
|
|
if (!ofs) return; |
|
|
|
|
|
|
|
|
|
|
|
// 输出所有顶点
|
|
|
|
for (const auto& v : vertices) { ofs << "v " << v.x() << " " << v.y() << " " << v.z() << "\n"; } |
|
|
|
// 输出所有面
|
|
|
|
// 输出所有面
|
|
|
|
size_t idx = 0; |
|
|
|
for (auto count : output_vertex_counts_of_face) { |
|
|
|
ofs << "f"; |
|
|
|
for (size_t i = 0; i < count; ++i) { |
|
|
|
ofs << " " << (faces[idx++] + 1); // OBJ 索引从1开始
|
|
|
|
} |
|
|
|
ofs << "\n"; |
|
|
|
} |
|
|
|
|
|
|
|
ofs.close(); |
|
|
|
|
|
|
|
ofs.close(); |
|
|
|
} |
|
|
|
|
|
|
|
ISNP_API void build_implicit_network_by_blobtree(const s_settings& settings, |
|
|
|
const baked_blobtree_t& tree, |
|
|
@ -208,6 +229,10 @@ ISNP_API void build_implicit_network_by_blobtree(const s_settings& |
|
|
|
transform_subface_to_primitive_labels(tree, cell_subface_signs, cell_primitive_signs); |
|
|
|
} |
|
|
|
active_cell_label = filter_cells_by_boolean(tree, cell_primitive_signs); |
|
|
|
|
|
|
|
for (uint32_t i = 0; i < arrangement_cells.size(); ++i) { |
|
|
|
std::cout << "Cell " << i << " active: " << active_cell_label[i] << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
filter_polygon_faces(iso_faces, |
|
|
|
patches, |
|
|
@ -218,10 +243,8 @@ ISNP_API void build_implicit_network_by_blobtree(const s_settings& |
|
|
|
active_cell_label, |
|
|
|
output_polygon_faces, |
|
|
|
output_vertex_counts_of_face); |
|
|
|
filter_active_vertices(output_vertices, output_polygon_faces); |
|
|
|
export_halfpatch_obj(iso_pts, iso_faces, patches, "halfpatch_final"); |
|
|
|
filter_active_vertices(iso_pts, output_vertices, output_polygon_faces); |
|
|
|
export_obj(output_vertices, output_polygon_faces,output_vertex_counts_of_face,"final"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|