suwoodblender/blenderpython/simple_test.py

112 lines
3.3 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
简单的几何创建测试
"""
import sys
sys.path.append('.')
def test_geometry_creation():
"""测试几何创建功能"""
print("🚀 开始测试核心几何创建功能")
try:
# 导入模块
import suw_impl
impl = suw_impl.SUWImpl.get_instance()
print('✅ SUWImpl加载成功')
# 测试create_face方法
print("\n🔧 测试create_face方法")
test_surface = {
'segs': [
['(0,0,0)', '(1000,0,0)'],
['(1000,0,0)', '(1000,1000,0)'],
['(1000,1000,0)', '(0,1000,0)'],
['(0,1000,0)', '(0,0,0)']
],
'vz': '(0,0,1)',
'vx': '(1,0,0)'
}
container = {'type': 'test_container'}
face = impl.create_face(container, test_surface, 'mat_normal')
print(f'✅ create_face测试: 面创建{"成功" if face else "失败"}')
# 测试follow_me方法
print("\n🔀 测试follow_me方法")
test_follow_surface = {
'segs': [
['(0,0,0)', '(100,0,0)'],
['(100,0,0)', '(100,100,0)'],
['(100,100,0)', '(0,100,0)'],
['(0,100,0)', '(0,0,0)']
],
'vz': '(0,0,1)'
}
test_path = [{'type': 'line_edge', 'start': suw_impl.Point3d(0,0,0), 'end': suw_impl.Point3d(0,0,100)}]
normal = impl.follow_me(container, test_follow_surface, test_path, 'mat_normal')
print(f'✅ follow_me测试: 法向量{"获取成功" if normal else "获取失败"}')
# 测试work_trimmed方法
print("\n✂️ 测试work_trimmed方法")
test_work = {
'p1': '(0,0,0)',
'p2': '(0,0,100)',
'dia': 10,
'differ': False
}
test_part = {'type': 'test_part', 'children': []}
impl.work_trimmed(test_part, test_work)
print('✅ work_trimmed测试完成')
# 测试c03方法
print("\n🏗️ 测试c03方法")
test_c03_data = {
'uid': 'test_uid',
'zid': 'test_zid',
'children': [
{
'surf': {
'p': 1,
'segs': [['(0,0,0)', '(1000,0,0)', '(1000,1000,0)', '(0,1000,0)']]
},
'child': 'child1'
}
]
}
impl.c03(test_c03_data)
print('✅ c03测试完成')
# 测试c04方法
print("\n🔧 测试c04方法")
test_c04_data = {
'uid': 'test_uid',
'cp': 'test_cp',
'zid': 'test_zid',
'pid': 'test_pid',
'finals': [
{
'typ': 1,
'mn': 'test_material',
'ckey': 'mat_normal'
}
]
}
impl.c04(test_c04_data)
print('✅ c04测试完成')
print("\n🎉 所有核心几何创建功能测试成功!")
except Exception as e:
print(f"❌ 测试失败: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_geometry_creation()