Jelajahi Sumber

增加dam转txt方法

dengsixing 1 tahun lalu
induk
melakukan
a1e98a735a

+ 40 - 18
4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateObjUtil.java

@@ -316,6 +316,46 @@ public class CreateObjUtil {
 
 	}
 
+	public static void convertDamToTxt(String srcpath,String despath) throws IOException {
+		FileInputStream fis= null;
+		ByteArrayInputStream stream = null;
+		BufferedOutputStream bos = null;
+		BufferedInputStream bis = null;
+		try {
+			fis=new FileInputStream(new File(srcpath));
+			BigSceneProto.binary_mesh data_NavigationInfo = BigSceneProto.binary_mesh.parseFrom(fis);
+			String jsonFormat1 = JsonFormat.printToString(data_NavigationInfo);
+			stream = new ByteArrayInputStream(jsonFormat1.getBytes());
+			bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
+			bis = new BufferedInputStream(stream);
+			int b = -1;
+			while ((b = bis.read()) != -1) {
+				bos.write(b);
+			}
+
+		}finally{
+			try {
+				if(bis != null){
+					bis.close();
+				}
+				if(bos != null){
+					bos.close();
+				}
+				if(fis != null){
+					fis.close();
+				}
+			}catch (Exception e){
+				log.error("关闭文件流报错", e);
+			}
+		}
+	}
+
+	public static void main(String[] args) throws Exception {
+
+		convertDamToTxt("D:\\test\\01c0889ce8f34afc885fafdc94bec106_50k.dam", "D:\\test\\modeldata.txt");
+
+	}
+
 	public static void convertVisionmodeldataToTxt(String srcpath,String despath)throws Exception
 	{
 		try
@@ -697,23 +737,5 @@ public class CreateObjUtil {
 		log.info("matterpro获取阿里云图片方法完成,时间为:" + (System.currentTimeMillis() - start));
 	}
 
-	public static void main(String[] args) throws Exception {
-
-		String downloadedPath = "C:\\Users\\dsx\\Desktop\\孙\\已下载场景.txt";
-		String allPath = "C:\\Users\\dsx\\Desktop\\孙\\1.txt";
-		String nowMeshPath = "C:\\Users\\dsx\\Desktop\\孙\\now-mesh.txt";
-		String nowLaserPath = "C:\\Users\\dsx\\Desktop\\孙\\now-laser.txt";
-
-		List<String> downloadedNums = FileUtil.readUtf8Lines(downloadedPath);
-		List<String> allNums = FileUtil.readUtf8Lines(allPath);
-		Set<String> nowMeshNums = allNums.stream().filter(v -> !downloadedNums.contains(v) && !v.startsWith("SS-") && !v.startsWith("SG-")).collect(Collectors.toSet());
-		Set<String> nowLaserNums = allNums.stream().filter(v -> !downloadedNums.contains(v) && (v.startsWith("SS-") || v.startsWith("SG-"))).collect(Collectors.toSet());
-		FileUtil.writeUtf8Lines(nowMeshNums, nowMeshPath);
-		FileUtil.writeUtf8Lines(nowLaserNums, nowLaserPath);
-
-//		CreateObjUtil.convertVisionmodeldataToTxt("D:\\test\\vision.modeldata", "D:\\test\\vision.txt");
-
-
-	}
 
 }