File size: 1,981 Bytes
1dd0e3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <chrono>
#include "stl_parser.h"

int main() {
    std::cout << "Step 1: Starting test..." << std::endl;
    
    try {
        std::cout << "Step 2: Creating ObjectPool..." << std::endl;
        hhb::core::ObjectPool<hhb::core::Triangle> pool;
        std::cout << "Step 3: ObjectPool created successfully" << std::endl;
        
        std::cout << "Step 4: Creating StlParser..." << std::endl;
        hhb::core::StlParser parser;
        std::cout << "Step 5: StlParser created successfully" << std::endl;

        // 测试文件路径
        std::string filename = "Dji+Avata+2+Simple.stl";
        std::cout << "Step 6: Testing file: " << filename << std::endl;

        // 开始计时
        auto start = std::chrono::high_resolution_clock::now();
        std::cout << "Step 7: Starting parsing..." << std::endl;

        // 解析 STL 文件
        std::cout << "Step 8: Calling parser.parse()..." << std::endl;
        hhb::core::ParserResult result = parser.parse(filename, pool);
        std::cout << "Step 9: parser.parse() returned" << std::endl;

        // 结束计时
        auto end = std::chrono::high_resolution_clock::now();
        std::chrono::duration<double, std::milli> duration = end - start;

        if (result.success) {
            std::cout << "Step 10: Successfully parsed " << result.count << " triangles" << std::endl;
            std::cout << "Step 11: Total objects in pool: " << pool.size() << std::endl;
            std::cout << "Step 12: Parsing time: " << duration.count() << " ms" << std::endl;
        } else {
            std::cerr << "Step 10: Failed to parse STL file: " << result.error << std::endl;
        }

        std::cout << "Step 13: Test completed successfully" << std::endl;
    } catch (const std::exception& e) {
        std::cerr << "Exception caught: " << e.what() << std::endl;
    } catch (...) {
        std::cerr << "Unknown exception caught" << std::endl;
    }

    return 0;
}