Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prim input&output for fTetwild node #1645

Merged
merged 5 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions projects/Geometry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## QuadMesh节点参数说明
| 参数 | 类型 | 说明 |
| --- | ---- | --- |
| prim | PrimitiveObject | 输入三角形网格。 |
| deterministic | bool | 使用较慢的确定性算法。 |
| crease | float | 判断为折痕的二面角阈值。 |
| smooth_iter | int | 平滑和光线追踪重投影的次数(默认2)。 |
| quad_dominant | bool | 生成以四边形为主的三角形-四边形混合网格。 |
| intrinsic | bool | 使用intrinsic方法(默认extrinsic方法)。 |
| boundary | bool | 对于非闭合的表面,保持边缘轮廓。(有保留边的输入时自动开启) |
| scale | float | 期望的世界坐标下边长。(与vert_num, face_num至多同时指定一项) |
| vert_num | int | 期望点数。 |
| face_num | int | 期望面数。 |
| line_pick_tag | string | 保留的边的属性名称,属性应为int类型,该属性值为1的边被保留。只能保留边方向,不能严格固定顶点位置。 |
| marked_lines | list of vec2i | 保留的边的列表。只能保留边方向,不能严格固定顶点位置。 |


## fTetWild节点参数说明
| 参数 | 类型 | 说明 |
| --- | ---- | --- |
| prim | PrimitiveObject | 输入三角形网格。 |
| input_dir | readpath | 输入三角形网格文件路径。如果有prim输入则忽略此项。 |
| output_dir | string | 输出四面体网格文件路径。若为空,当以prim输入时则不输出任何文件,以文件读入时则输出到“<原路经>/<原文件名>_.msh” |
| tag | readpath | 输入用于布尔运算的面片标记的文件路径。 |
| operation | enum | 布尔运算种类 |
| edge_length | float | 期望相对边长。默认0.05。 |
| epsilon | float | 期望相对偏差。默认1e-3。 |
| stop_energy | float | 停止优化的能量阈值。默认10。 |
| skip_simplify | bool | 跳过预处理。 |
| no_binary | bool | 以ascii格式输出。(仅在有输出文件时生效) |
| no_color | bool | 不输出颜色。(仅在有输出文件时生效) |
| smooth_open_boundary | bool | 对于非闭合表面,光滑其边缘。 |
| export_raw | bool | 输出原始结果。 |
| manifold_surface | bool | 处理输出为流形。 |
| coarsen | bool | 尽可能使输出稀疏。 |
| csg | readpath | 包含csg树的json文件路径。 |
| disable_filtering | bool | 不过滤掉外部的元素。 |
| use_floodfill | bool | 使用泛洪法提取内部体积。 |
| use_general_wn | bool | 使用通常的绕数。 |
| use_input_for_wn | bool | 使用输入表面得到绕数。 |
| bg_mesh | readpath | 用于得到长度场的背景网格(.msh格式)文件路径 |
24 changes: 12 additions & 12 deletions projects/Geometry/quadmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct QuadMesh : INode {
float scale = get_input2<float>("scale");
int vert_num = get_input2<int>("vert_num");
int face_num = get_input2<int>("face_num");
int knn = get_input2<int>("knn");
// int knn = get_input2<int>("knn");
auto line_pick_tag = get_input<zeno::StringObject>("line_pick_tag")->get();

if (prim->verts.size() < 4) {
Expand Down Expand Up @@ -142,16 +142,16 @@ struct QuadMesh : INode {
argv[argc+1][face_num_str.size()] = '\0';
argc += 2;
}
if (knn > 0) {
argv[argc] = (char*)malloc(sizeof("--knn\0"));
strcpy(argv[argc], "--knn\0");
std::string knn_str = to_string(knn);
argv[argc+1] = (char*)malloc((knn_str.size()+1)*sizeof(char));
for (int i = 0; i < knn_str.size(); ++i)
argv[argc+1][i] = knn_str[i];
argv[argc+1][knn_str.size()] = '\0';
argc += 2;
}
// if (knn > 0) {
// argv[argc] = (char*)malloc(sizeof("--knn\0"));
// strcpy(argv[argc], "--knn\0");
// std::string knn_str = to_string(knn);
// argv[argc+1] = (char*)malloc((knn_str.size()+1)*sizeof(char));
// for (int i = 0; i < knn_str.size(); ++i)
// argv[argc+1][i] = knn_str[i];
// argv[argc+1][knn_str.size()] = '\0';
// argc += 2;
// }

std::vector<std::vector<int>> faces(prim->tris->size(), std::vector<int>{});
std::vector<std::vector<float>> verts(prim->verts->size(), std::vector<float>{});
Expand Down Expand Up @@ -208,7 +208,7 @@ ZENO_DEFNODE(QuadMesh)
{"float", "scale", "0"},
{"int", "vert_num", "0"},
{"int", "face_num", "0"},
{"int", "knn", "0"},
// {"int", "knn", "0"},
{"string", "line_pick_tag", "line_selected"},
{"marked_lines"}},
{{"prim"}},
Expand Down
30 changes: 27 additions & 3 deletions projects/Geometry/tetmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace zeno {

struct FTetWild : INode {
virtual void apply() override {
auto prim = get_input<PrimitiveObject>("prim");
auto input_dir = get_input2<std::string>("input_dir");
input_dir.erase(input_dir.find_last_not_of(" ")+1);
auto output_dir = get_input2<std::string>("output_dir");
auto tag = get_input2<std::string>("tag");
tag.erase(tag.find_last_not_of(" ")+1);
Expand Down Expand Up @@ -197,13 +199,35 @@ struct FTetWild : INode {
strcpy(argv[argc+1], "3\0");
argc += 2;

runFTetWild(argc, argv);
std::vector<std::vector<int>> faces(prim->tris->size(), std::vector<int>{});
std::vector<std::vector<float>> verts(prim->verts->size(), std::vector<float>{});
for (int i = 0; i < prim->tris->size(); ++i)
for (int j = 0; j < 3; ++j)
faces[i].push_back(prim->tris[i][j]);
for (int i = 0; i < prim->verts->size(); ++i)
for (int j = 0; j < 3; ++j)
verts[i].push_back(prim->verts[i][j]);

runFTetWild(faces, verts, argc, argv);

prim->quads.clear();
prim->quads.resize(faces.size());
prim->verts.clear();
prim->verts.resize(verts.size());
for (int i = 0; i < faces.size(); ++i)
for (int j = 0; j < 4; ++j)
prim->quads[i][j] = faces[i][j];
for (int i = 0; i < verts.size(); ++i)
for (int j = 0; j < 3; ++j)
prim->verts[i][j] = verts[i][j];
set_output("prim", std::move(prim));
}
};

ZENO_DEFNODE(FTetWild)
({
{{"readpath", "input_dir"},
{{"prim"},
{"readpath", "input_dir", " "},
{"string", "output_dir"},
{"readpath", "tag", " "},
{"enum none union intersection difference", "operation", "none"},
Expand All @@ -223,7 +247,7 @@ ZENO_DEFNODE(FTetWild)
{"bool", "use_general_wn", "0"},
{"bool", "use_input_for_wn", "0"},
{"readpath", "bg_mesh", " "}},
{},
{("prim")},
{},
{"primitive"},
});
Expand Down
Loading