|
@@ -10,14 +10,15 @@ from tqdm import tqdm
|
|
|
|
|
|
import core
|
|
import core
|
|
from drawer import ShaftDrawer, TunDrawer, WindowDrawer, GateDrawer, FanMainDrawer, FanSystemDrawer, WindFlowDrawer
|
|
from drawer import ShaftDrawer, TunDrawer, WindowDrawer, GateDrawer, FanMainDrawer, FanSystemDrawer, WindFlowDrawer
|
|
|
|
+from drawer.CADJson import CADJson
|
|
from drawer.WindBridgeDrawer import WindBridgeDrawer
|
|
from drawer.WindBridgeDrawer import WindBridgeDrawer
|
|
|
|
|
|
app = Flask(__name__)
|
|
app = Flask(__name__)
|
|
|
|
|
|
cur_dir = os.getcwd()
|
|
cur_dir = os.getcwd()
|
|
|
|
|
|
-url = 'http://192.168.183.216:8008/python/tunCAD'
|
|
|
|
-
|
|
|
|
|
|
+# url = 'http://192.168.183.216:8008/python/tunCAD'
|
|
|
|
+url = 'data/cad.json'
|
|
|
|
|
|
@app.route('/sysvent/draw/<int:model_id>', methods=['GET'])
|
|
@app.route('/sysvent/draw/<int:model_id>', methods=['GET'])
|
|
def post_json(model_id):
|
|
def post_json(model_id):
|
|
@@ -51,8 +52,7 @@ def download_dxf_file(model_id):
|
|
# 指定文件的完整路径
|
|
# 指定文件的完整路径
|
|
filename = str(model_id) + ".dxf"
|
|
filename = str(model_id) + ".dxf"
|
|
|
|
|
|
- cad_json = request_graph_point(model_id)
|
|
|
|
- draw_system_vent(cad_json,model_id)
|
|
|
|
|
|
+ draw_system_vent(url,model_id)
|
|
|
|
|
|
file_path = f'save\\{filename}'
|
|
file_path = f'save\\{filename}'
|
|
# 使用send_file发送文件,as_attachment=True表示以附件形式发送
|
|
# 使用send_file发送文件,as_attachment=True表示以附件形式发送
|
|
@@ -78,133 +78,69 @@ def calculate_route_middle(wind_flow_unit):
|
|
return path_middle, route
|
|
return path_middle, route
|
|
|
|
|
|
|
|
|
|
-def draw_system_vent(cad_json, model_id):
|
|
|
|
- doc = ezdxf.new('R2000')
|
|
|
|
- doc.styles.add("LiberationSerif", font="LiberationSerif.ttf")
|
|
|
|
- msp = doc.modelspace()
|
|
|
|
|
|
+def draw_system_vent(path, model_id):
|
|
|
|
+ # doc = ezdxf.new('R2000')
|
|
|
|
|
|
- node_list = cad_json["tunsMapCAD"]
|
|
|
|
- tun_list = []
|
|
|
|
- window_list = []
|
|
|
|
- gate_list = []
|
|
|
|
- fan_list = []
|
|
|
|
- for node in node_list:
|
|
|
|
- node = node[1]
|
|
|
|
- tun = {
|
|
|
|
- "vec12": node["vec12"],
|
|
|
|
- "vec34": node["vec34"],
|
|
|
|
- "tun_id": node["ntunid"],
|
|
|
|
- "from": (node["nfrom"]["x"], node["nfrom"]["z"]),
|
|
|
|
- "to": (node["nto"]["x"], node["nto"]["z"]),
|
|
|
|
- "layer_id": node["nlayerid"],
|
|
|
|
- "width": node["fwidth"],
|
|
|
|
- "type": node["tunType"],
|
|
|
|
- "angle": node["angleRad"],
|
|
|
|
- "route": core.calculate_angle_with_x_axis((node["nfrom"]["x"], node["nfrom"]["z"]),
|
|
|
|
- (node["nto"]["x"], node["nto"]["z"]))
|
|
|
|
- }
|
|
|
|
- tun_list.append(tun)
|
|
|
|
- for window in node["windows"]:
|
|
|
|
- window["route"] = tun["route"]
|
|
|
|
- window["gap"] = node["fwidth"]
|
|
|
|
|
|
+ cad_json = CADJson(path)
|
|
|
|
|
|
- window_list.extend(node["windows"])
|
|
|
|
- for gate in node["gates"]:
|
|
|
|
- gate["route"] = tun["route"]
|
|
|
|
- gate["gap"] = node["fwidth"]
|
|
|
|
- gate_list.extend(node["gates"])
|
|
|
|
|
|
+ # tun_list = cad_json.tun_list
|
|
|
|
+ # fan_list = cad_json.fan_list
|
|
|
|
+ # window_list = cad_json.window_list
|
|
|
|
|
|
- for fan in node["fans"]:
|
|
|
|
- fan["route"] = tun["route"]
|
|
|
|
- fan["gap"] = node["fwidth"]
|
|
|
|
|
|
+ doc = ezdxf.readfile("data/moban.dxf")
|
|
|
|
+ doc.styles.add("msyh", font="data/msyh.ttc")
|
|
|
|
+ for layer in cad_json.json['layerMap']:
|
|
|
|
+ doc.layers.new(name=f'图层{layer[0]}')
|
|
|
|
|
|
- fan_list.extend(node["fans"])
|
|
|
|
|
|
+ msp = doc.modelspace()
|
|
|
|
|
|
- for tun in tqdm(tun_list, desc=' 【巷道绘制中】'):
|
|
|
|
|
|
+ for tun in tqdm(cad_json.tun_list, desc=' 【巷道绘制中】'):
|
|
if tun['type'] == '1':
|
|
if tun['type'] == '1':
|
|
shaft_center = tun['from'][0], tun['from'][1]
|
|
shaft_center = tun['from'][0], tun['from'][1]
|
|
- sd = ShaftDrawer(msp, tun['width'], shaft_center, tun["route"], 42)
|
|
|
|
|
|
+ sd = ShaftDrawer(msp, tun['layer_id'], tun['width'], shaft_center, 0)
|
|
sd.draw_shaft_drawer()
|
|
sd.draw_shaft_drawer()
|
|
else:
|
|
else:
|
|
- vec12 = []
|
|
|
|
- vec34 = []
|
|
|
|
- for item in tun['vec12']:
|
|
|
|
- vec12.append({
|
|
|
|
- "x": item["x"],
|
|
|
|
- "y": item["z"]
|
|
|
|
- })
|
|
|
|
- for item in tun['vec34']:
|
|
|
|
- vec12.append({
|
|
|
|
- "x": item["x"],
|
|
|
|
- "y": item["z"]
|
|
|
|
- })
|
|
|
|
- color = core.get_color_by_layer(tun['layer_id'])
|
|
|
|
-
|
|
|
|
- td = TunDrawer(msp, tun['layer_id'], color, vec12, vec34, tun["from"], tun["to"])
|
|
|
|
|
|
+ td = TunDrawer(msp, tun['layer_id'], tun["vec12"], tun["vec34"], tun["from"], tun["to"], tun["name"],
|
|
|
|
+ tun["width"])
|
|
td.draw_tun()
|
|
td.draw_tun()
|
|
|
|
|
|
- for window in tqdm(window_list, desc=f' 【风窗绘制中】'):
|
|
|
|
- point_c = window['x'], window['z']
|
|
|
|
- wd = WindowDrawer(msp, window["gap"], point_c, window["route"])
|
|
|
|
|
|
+ for window in tqdm(cad_json.window_list, desc=f' 【风窗绘制中】'):
|
|
|
|
+ wd = WindowDrawer(msp, window["width"], window["layer"], window["center"], window["route"])
|
|
wd.draw_window()
|
|
wd.draw_window()
|
|
|
|
|
|
- for gate in tqdm(gate_list, desc=f' 【风窗绘制中】'):
|
|
|
|
- point_c = gate['x'], gate['z']
|
|
|
|
- gd = GateDrawer(msp, gate["gap"], point_c, gate["route"])
|
|
|
|
|
|
+ for gate in tqdm(cad_json.gate_list, desc=f' 【风门绘制中】'):
|
|
|
|
+ gd = GateDrawer(msp, gate["layer"], gate["width"], gate['center'], gate["route"])
|
|
gd.draw_gate()
|
|
gd.draw_gate()
|
|
|
|
|
|
- for fan in tqdm(fan_list, desc=f' 【风扇绘制中】'):
|
|
|
|
- if 'fanmain' in str(fan['strtype']):
|
|
|
|
- point_c = fan['x'], fan['z']
|
|
|
|
- fmd = FanMainDrawer(msp, fan["gap"], point_c, fan["route"])
|
|
|
|
|
|
+ for fan in tqdm(cad_json.fan_list, desc=f' 【风扇绘制中】'):
|
|
|
|
+ if 'fanmain' in str(fan['type']):
|
|
|
|
+ fmd = FanMainDrawer(msp, fan["layer"], fan["width"], fan['center'], fan["route"])
|
|
fmd.draw_fan_main()
|
|
fmd.draw_fan_main()
|
|
- if 'fansystem' in str(fan['strtype']):
|
|
|
|
- point_c = fan['x'], fan['z']
|
|
|
|
- fsd = FanSystemDrawer(msp, fan["gap"], point_c, fan["route"])
|
|
|
|
|
|
+ if 'fansystem' in str(fan['type']):
|
|
|
|
+ fsd = FanSystemDrawer(msp, fan["width"], fan['center'], fan["route"])
|
|
fsd.draw_fan_system()
|
|
fsd.draw_fan_system()
|
|
-
|
|
|
|
- path_point_layers = cad_json["pathPointMap"]
|
|
|
|
-
|
|
|
|
- for path_point in path_point_layers:
|
|
|
|
-
|
|
|
|
- in_paths = path_point[1]['inPaths']
|
|
|
|
- for in_path in tqdm(in_paths, desc=f'图层{path_point[0]} 【进风方向绘制中】'):
|
|
|
|
- if len(in_path) != 0:
|
|
|
|
- path_middle, route = calculate_route_middle(in_path)
|
|
|
|
- wfd = WindFlowDrawer(msp, 5, path_middle, route, 3)
|
|
|
|
- wfd.draw_wind_flow()
|
|
|
|
- no_paths = path_point[1]['noPaths']
|
|
|
|
- for no_path in tqdm(no_paths, desc=f'图层{path_point[0]} 【未指定方向绘制中】'):
|
|
|
|
- if len(no_path) != 0:
|
|
|
|
- path_middle, route = calculate_route_middle(no_path)
|
|
|
|
- wfd = WindFlowDrawer(msp, 5, path_middle, route, 3)
|
|
|
|
- wfd.draw_wind_flow()
|
|
|
|
- out_paths = path_point[1]['outPaths']
|
|
|
|
- for out_path in tqdm(out_paths, desc=f'图层{path_point[0]} 【回风方向绘制中】'):
|
|
|
|
- if len(out_path) != 0:
|
|
|
|
- path_middle, route = calculate_route_middle(out_path)
|
|
|
|
- wfd = WindFlowDrawer(msp, 5, path_middle, route, 1)
|
|
|
|
- wfd.draw_wind_flow()
|
|
|
|
- use_paths = path_point[1]['usePaths']
|
|
|
|
- for use_path in tqdm(use_paths, desc=f'图层{path_point[0]} 【用风方向绘制中】'):
|
|
|
|
- if len(use_path) != 0:
|
|
|
|
- path_middle, route = calculate_route_middle(use_path)
|
|
|
|
- wfd = WindFlowDrawer(msp, 5, path_middle, route, 1)
|
|
|
|
-
|
|
|
|
- layer_map = cad_json["layerMap"]
|
|
|
|
-
|
|
|
|
- for layer in layer_map:
|
|
|
|
- cross_nodes = layer[1]['crossNodes']
|
|
|
|
- for cross_node in tqdm(cross_nodes, desc=f'图层{layer[0]} 【风桥绘制中】'):
|
|
|
|
- center = cross_node['crossPoint']['x'], -cross_node['crossPoint']['y']
|
|
|
|
- tun = [tun_ for tun_ in tun_list if tun_.get("tun_id") == cross_node['tun1Id']][0]
|
|
|
|
- route = core.calculate_angle_with_x_axis(tun["from"], tun["to"])
|
|
|
|
- line_1 = (tun["vec12"][0]["x"], tun["vec12"][0]["z"]), (tun["vec12"][-1]["x"], tun["vec12"][-1]["z"])
|
|
|
|
- line_2 = (tun["vec34"][0]["x"], tun["vec34"][0]["z"]), (tun["vec34"][-1]["x"], tun["vec34"][-1]["z"])
|
|
|
|
- gap = core.min_distance_between_segments(line_1,
|
|
|
|
- line_2)
|
|
|
|
- wbd = WindBridgeDrawer(msp, center, cross_node['tun1Id'], cross_node['tun2Id'], layer[0], tun["angle"], gap)
|
|
|
|
- wbd.draw_wind_bridge_drawer()
|
|
|
|
|
|
+ wind_flow_list = cad_json.wind_flow_list
|
|
|
|
+ for in_path in tqdm(wind_flow_list['in'], desc=f' 【进风方向绘制中】'):
|
|
|
|
+ if len(in_path) != 0:
|
|
|
|
+ wfd = WindFlowDrawer(msp, in_path['layer'], 3, in_path['center'], in_path['route'], in_path['type'])
|
|
|
|
+ wfd.draw_wind_flow()
|
|
|
|
+ for no_path in tqdm(wind_flow_list['no'], desc=f'【未指定方向绘制中】'):
|
|
|
|
+ if len(no_path) != 0:
|
|
|
|
+ wfd = WindFlowDrawer(msp, no_path['layer'], 3, no_path['center'], no_path['route'], no_path['type'])
|
|
|
|
+ wfd.draw_wind_flow()
|
|
|
|
+ for out_path in tqdm(wind_flow_list['out'], desc=f'【回风方向绘制中】'):
|
|
|
|
+ if len(out_path) != 0:
|
|
|
|
+ wfd = WindFlowDrawer(msp, out_path['layer'], 3, out_path['center'], out_path['route'], out_path['type'])
|
|
|
|
+ wfd.draw_wind_flow()
|
|
|
|
+ for use_path in tqdm(wind_flow_list['use'], desc=f' 【用风方向绘制中】'):
|
|
|
|
+ if len(use_path) != 0:
|
|
|
|
+ wfd = WindFlowDrawer(msp, use_path['layer'], 3, use_path['center'], use_path['route'], use_path['type'])
|
|
|
|
+ wfd.draw_wind_flow()
|
|
|
|
+
|
|
|
|
+ for wind_bridge in tqdm(cad_json.wind_bridge_list, desc=f' 【风桥绘制中】'):
|
|
|
|
+ wbd = WindBridgeDrawer(msp, wind_bridge['center'], wind_bridge['layer'],
|
|
|
|
+ wind_bridge['route'], wind_bridge['width'])
|
|
|
|
+ wbd.draw_wind_bridge_drawer()
|
|
|
|
|
|
doc.saveas(f'save/{str(model_id)}.dxf')
|
|
doc.saveas(f'save/{str(model_id)}.dxf')
|
|
|
|
|