39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
#include "vde/foundation/io_3dm.h"
|
|
#include "vde/brep/format_io.h"
|
|
|
|
#include <gtest/gtest.h>
|
|
#include <cstdlib>
|
|
#include <fstream>
|
|
#include <string>
|
|
|
|
using namespace vde::foundation;
|
|
using namespace vde::brep;
|
|
|
|
TEST(ThreeDm, NativeSampleIfProvided) {
|
|
const char* sample = std::getenv("VDE_3DM_SAMPLE");
|
|
if (sample == nullptr) GTEST_SKIP() << "未设置 VDE_3DM_SAMPLE";
|
|
ThreeDmImportResult r = import_3dm(sample);
|
|
EXPECT_TRUE(r.success) << r.error;
|
|
EXPECT_FALSE(r.bodies.empty());
|
|
size_t verts = 0, faces = 0;
|
|
for (const auto& b : r.bodies) {
|
|
verts += b.num_vertices();
|
|
faces += b.num_faces();
|
|
}
|
|
EXPECT_GT(verts, 0u);
|
|
EXPECT_GT(faces, 0u);
|
|
bool grid_fallback = false;
|
|
for (const auto& w : r.warnings)
|
|
if (w.find("参数网格") != std::string::npos) grid_fallback = true;
|
|
EXPECT_TRUE(grid_fallback) << "five_solids 应走 B-Rep 参数网格回退";
|
|
}
|
|
|
|
TEST(ThreeDm, ImportCadDetectsThreeDm) {
|
|
const char* sample = std::getenv("VDE_3DM_SAMPLE");
|
|
if (sample == nullptr) GTEST_SKIP() << "未设置 VDE_3DM_SAMPLE";
|
|
CadImportResult r = import_cad(sample);
|
|
EXPECT_TRUE(r.ok) << (r.messages.empty() ? "" : r.messages.front());
|
|
EXPECT_EQ(r.detected.format, vde::io::FileFormat::ThreeDm);
|
|
EXPECT_FALSE(r.bodies.empty());
|
|
}
|