|
@@ -0,0 +1,77 @@
|
|
|
+package com.gis.common.util;
|
|
|
+
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import com.gis.common.exception.BaseRuntimeException;
|
|
|
+import com.gis.common.proto.util.ConvertUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.junit.Test;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by owen on 2022/6/13 0013 18:08
|
|
|
+ * win版数据转换
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+public class ConvertWinUtils {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * dam to obj
|
|
|
+ * by owen 2022-06-14
|
|
|
+ * 测试完成
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void damToObj(){
|
|
|
+
|
|
|
+ String basePath = "D:\\baseData\\";
|
|
|
+ String damPath = basePath + "/dam/79ed9f301626478ab6edf9ffc747e5f8_50k.dam";
|
|
|
+ try {
|
|
|
+ doDamToTxt(damPath, basePath);
|
|
|
+ doTxtToObj(basePath);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * dam to txt
|
|
|
+ */
|
|
|
+ private static void doDamToTxt(String damPath, String basePath) throws Exception {
|
|
|
+ String txtPath = basePath + "txt2obj\\test.txt";
|
|
|
+ // 删除旧text.txt
|
|
|
+ FileUtil.del(txtPath);
|
|
|
+ ConvertUtils.convertDamToTxt2(damPath, txtPath);
|
|
|
+ log.info("处理完成:damToTxt , {}", txtPath);
|
|
|
+ BaseRuntimeException.isTrue(!FileUtil.isFile(txtPath), null, "生成text.txt失败");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * txt to obj
|
|
|
+ * 默认对目录里test.txt 文件转 obj
|
|
|
+ */
|
|
|
+ private static void doTxtToObj(String basePath) {
|
|
|
+ String txt2objDir = basePath + "txt2obj";
|
|
|
+ String txt2objCmd = "python " + basePath + "txt2obj\\run.py " + txt2objDir;
|
|
|
+ String meshObjPath = txt2objDir + "/test.obj";
|
|
|
+ FileUtil.del(meshObjPath);
|
|
|
+ CmdUtils.callLine(txt2objCmd);
|
|
|
+ // 删除旧obj
|
|
|
+ String meshObjMtlPath = txt2objDir + "/test.mtl";
|
|
|
+ if (!FileUtil.exist(meshObjPath)) {
|
|
|
+ throw new BaseRuntimeException("算法生成test.obj失败: " + meshObjPath);
|
|
|
+ }
|
|
|
+ log.info("mesh.obj生成完成");
|
|
|
+
|
|
|
+ // 将mesh.obj、mesh.obj.mtl复制到场景码跟目录
|
|
|
+// String objPath = basePath + "/test.obj";
|
|
|
+// String mntPath = basePath + "/test.mtl";
|
|
|
+// FileUtil.copy(new File(meshObjPath), new File(objPath), true);
|
|
|
+// FileUtil.copy(new File(meshObjMtlPath), new File(mntPath), true);
|
|
|
+// log.info("test.obj复制到根目录完成: {}", basePath);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|