-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create an addon that tag feature line from an exported .mesh of…
… GMSH, upgrade ultimaille version
- Loading branch information
Showing
4 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <ultimaille/all.h> | ||
#include <param_parser/param_parser.h> | ||
|
||
using namespace UM; | ||
|
||
int main(int argc, char** argv) { | ||
|
||
// Add program parameters | ||
// params.add("input", "model", "").description("Model to process"); | ||
|
||
// params.add(Parameters::Type::EdgesInt(1), "edge_attribute", "").description("Edge"); | ||
// params.add(Parameters::Type::FacetCornersInt(1), "facet_attribute", "").description("Facet"); | ||
|
||
// /* Parse program arguments */ | ||
// params.init_from_args(argc, argv); | ||
|
||
// // Get parameters | ||
// std::string filename = params["model"]; | ||
// std::string facet_attribute = params["facet_attribute"]; | ||
|
||
// std::filesystem::path result_path(params.result_path()); | ||
|
||
// // Load mesh and read attributes | ||
// Quads m; | ||
// SurfaceAttributes attributes = read_by_extension(filename, m); | ||
// // Load attribute | ||
// CornerAttribute<int> ca(facet_attribute, attributes, m); | ||
|
||
// std::cout << "n corners: " << m.ncorners() << std::endl; | ||
|
||
// for (int i = 0; i < m.ncorners(); i++) { | ||
// std::cout << "ca: " << ca[i] << std::endl; | ||
// } | ||
|
||
// // Save | ||
|
||
// // Output model to output directory at working dir if no result_path given | ||
// if (result_path.empty() && !std::filesystem::is_directory("output")) { | ||
// std::filesystem::create_directories("output"); | ||
// result_path = "output"; | ||
// } | ||
|
||
// // Get file name and output path | ||
// std::string file = std::filesystem::path(filename).filename().string(); | ||
// std::string out_filename = (result_path / file).string(); | ||
|
||
// write_by_extension(out_filename, m, {{}, {}, {{"ca", ca.ptr}}}); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
|
||
#include <ultimaille/all.h> | ||
#include <param_parser/param_parser.h> | ||
|
||
inline std::string separator() | ||
{ | ||
#ifdef _WIN32 | ||
return "\\"; | ||
#else | ||
return "/"; | ||
#endif | ||
} | ||
|
||
using namespace UM; | ||
|
||
int main(int argc, char** argv) { | ||
|
||
// Create parameters | ||
Parameters params; | ||
|
||
params.help = "Tag feature lines of a surface + polyline model"; | ||
|
||
// Add program parameters | ||
params.add(Parameters::Type::Input, "model", "").description(""); | ||
|
||
/* Parse program arguments */ | ||
params.init_from_args(argc, argv); | ||
|
||
// Get args | ||
std::string model = params["model"]; | ||
std::filesystem::path result_path(params.result_path()); | ||
|
||
// Out file | ||
std::filesystem::path model_path(model); | ||
|
||
std::filesystem::path out_filename = result_path / (model_path.filename().string() + "_tagged.geogram"); | ||
|
||
// Read surface | ||
Triangles m; | ||
read_by_extension(model, m); | ||
CornerAttribute<bool> feature_line_attr(m); | ||
|
||
// Read poyline | ||
PolyLine p; | ||
PolyLineAttributes attributes = read_by_extension(model, p); | ||
|
||
m.connect(); | ||
|
||
// Mark halfedge as feature line | ||
// May have a smarter way ? | ||
for (auto e : p.iter_edges()) { | ||
for (auto he : m.iter_halfedges()) { | ||
|
||
if (e.from() == he.from() && e.to() == he.to()) { | ||
feature_line_attr[he] = true; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
write_by_extension(out_filename, m, {{}, {}, {{"feature_line", feature_line_attr.ptr}}}); | ||
std::cout << "writed to: " << out_filename << std::endl; | ||
|
||
return 0; | ||
} |