extract explicit mesh with topology information from implicit surfaces with boolean operations, and do surface/volume integrating on them.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

126 lines
4.1 KiB

#include <timer/scoped_timer.hpp>
#include "primitive_process/subface.hpp"
#include "primitive_process/subface/simple/sphere_face.hpp"
#include <SurfaceIntegrator.hpp>
// ✅ 封装成函数:通过引用填充一个 parametric_plane_t 实例
void populate_parametric_plane(parametric_plane_t& plane) {
// 确保是空的(可选)
// plane = parametric_plane_t();
auto& chain_vertices = plane.chain_vertices;
auto& chain_group_indices = plane.chain_group_indices;
auto& v_flags = plane.vertex_special_flags;
auto& e_flags = plane.edge_near_parallel_flags;
int vertex_count = 4;
chain_vertices.reserve(vertex_count);
v_flags.reserve(vertex_count);
e_flags.reserve(vertex_count - 1);
// 1. 添加一条链的顶点 (chain 0)
chain_vertices.push_back({{0.0, 0.0}});
chain_vertices.push_back({{1.0, 0.0}});
chain_vertices.push_back({{1.0, 1.0}});
chain0_vertices.push_back({{0.0, 1.0}});
chain_vertices.reserve(unique_chain_indices.size());
chain_vertex_flags.reserve(unique_chain_indices.size());
for (const auto& chain_index : unique_chain_indices) {
const auto& chain = chains[chain_index];
auto& chain_vertices_ = chain_vertices.emplace_back();
chain_vertices_.resize(chain.size());
std::transform(chain.begin(), chain.end(), chain_vertices_.begin(), [&](uint32_t vertex_index) {
auto mapped_vertex_index = vertex_old_index_to_unique_index.at(vertex_index);
return mapping_func(vertices[mapped_vertex_index]);
});
auto& chain_vertex_flags_ = chain_vertex_flags.emplace_back();
chain_vertex_flags_.resize(chain.size());
chain_vertex_flags_[0] = chain_end_vertex_signular_flag[2 * chain_index];
chain_vertex_flags_[chain.size() - 1] = chain_end_vertex_signular_flag[2 * chain_index + 1];
}
v_flags.reverse();
dynamic_bitset_mp<> v_flags;
v_flags.set(0);
v_flags.set(3);
plane.vertex_special_flags.push_back(v_flags);
// 3. 设置边平行标志
dynamic_bitset_mp<> e_flags;
e_flags.set(1);
plane.edge_near_parallel_flags.push_back(e_flags);
// 4. 添加链组索引
plane.chain_group_indices.emplace_back();
auto& group_indices = plane.chain_group_indices.back();
group_indices.push_back(0);
group_indices.push_back(2);
}
// --- 使用示例 ---
int main() {
std::cout << "=== 使用函数填充 parametric_plane_t 实例 ===" << std::endl;
// 先创建实例
parametric_plane_t plane;
// 调用函数填充数据
populate_parametric_plane(plane);
// 验证数据
std::cout << "\n--- 实例数据摘要 ---" << std::endl;
std::cout << "链的数量: " << plane.chain_vertices.size() << std::endl;
if (!plane.chain_vertices.empty()) {
std::cout << "第一条链的顶点数量: " << plane.chain_vertices[0].size() << std::endl;
std::cout << "第一条链的顶点特殊标志: " << plane.vertex_special_flags[0] << std::endl;
std::cout << "第一条链的边平行标志: " << plane.edge_near_parallel_flags[0] << std::endl;
std::cout << "第一条链所属的组: ";
for (auto idx : plane.chain_group_indices[0]) {
std::cout << idx << " ";
}
std::cout << std::endl;
}
std::cout << "\n✅ 测试完成!" << std::endl;
return 0;
}
int main()
{
labelled_timers_manager timer{};
internal::sphere_face_t sphere_face;
stl_vector_mp<object_with_index_mapping<subface>> subfaces;
flat_hash_map_mp<uint32_t, parametric_plane_t> uv_planes;
subfaces.reserve(1);
subfaces.emplace_back(&sphere_face, 0);
uv_planes[0] = parametric_plane_t{};
uv_planes[0].u_min = 0.0;
// box_descriptor_t box{
// {0., 0., 0.},
// {1., 1., 1.}
// };
// primitive_node_t node{PRIMITIVE_TYPE_BOX, &box};
// timer.push_timer("run-time under 10^6 loops (old)");
// for (auto i = 0; i < 1'000'000; ++i) { auto result = evaluate(node, Eigen::Vector3d::Ones() * 2); }
// timer.pop_timer("run-time under 10^6 loops (old)");
// timer.print();
return 0;
}