dengsixing 1 год назад
Родитель
Сommit
b539de984a

+ 26 - 22
4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateHouseJsonUtil.java

@@ -148,8 +148,12 @@ public class CreateHouseJsonUtil {
 			Map<String, String> parent = new HashMap<>();
 			String startParent = startMap.get(pointBean.getVectorId());
 			String endParent = endMap.get(pointBean.getVectorId());
-			parent.put(startParent, "start");
-			parent.put(endParent, "end");
+			if(StrUtil.isNotEmpty(startParent)){
+				parent.put(startParent, "start");
+			}
+			if(StrUtil.isNotEmpty(endParent)){
+				parent.put(endParent, "end");
+			}
 			pointBean.setParent(parent);
 		}
 		JSONArray pointArr = JSON.parseArray(JSON.toJSONString(pointBeans));
@@ -162,19 +166,19 @@ public class CreateHouseJsonUtil {
 		return result;
 
 	}
-	
+
 	private static JSONObject init() {
 		JSONObject outContent = new JSONObject();
 		outContent.put("name", "houseType.json");
 		outContent.put("version", "2.1");
-		
+
 		outContent.put("floors", new JSONArray());
 		outContent.put("newVectorId", null);
 		outContent.put("setting", null);
 		outContent.put("boundingBox", null);
 		return outContent;
 	}
-	
+
 	private static JSONArray readFloorJson(String filePath) {
 		try {
 			JSONObject floorplan = FileUtils.readJson(filePath);
@@ -185,13 +189,13 @@ public class CreateHouseJsonUtil {
 			return null;
 		}
 	}
-	
+
 	private static JSONObject convert(JSONObject floorJson,int floor) {
 		JSONArray rooms = floorJson.getJSONArray("rooms");
 		JSONObject walls = floorJson.getJSONObject("walls");
 		JSONObject points = floorJson.getJSONObject("points");
 		JSONObject symbols = floorJson.getJSONObject("symbols");
-		
+
 		JSONArray _points = convertPoints(points);
 		JSONArray _walls = convertWalls(walls);
 		JSONArray _symbols = convertSymbols(symbols,floor);
@@ -205,9 +209,9 @@ public class CreateHouseJsonUtil {
 		floorData.put("rooms", _rooms);
 		return floorData;
 	}
-	
+
 	private static JSONArray convertPoints(JSONObject points) {
-		
+
 	   JSONArray _points = new JSONArray();
        for (Map.Entry<String, Object> entry: points.entrySet()) {
     	   JSONObject pointValue = (JSONObject)entry.getValue();
@@ -216,15 +220,15 @@ public class CreateHouseJsonUtil {
     	   _pointValue.put("y", pointValue.getFloat("y"));
     	   _pointValue.put("parent", pointValue.getJSONObject("parent"));
     	   _pointValue.put("vectorId", pointValue.getString("vectorId"));
-    	   
+
     	   _points.add(_pointValue);
        }
-		
+
        return _points;
 	}
-	
+
 	private static JSONArray convertWalls(JSONObject walls) {
-		
+
 	   JSONArray _walls = new JSONArray();
        for (Map.Entry<String, Object> entry: walls.entrySet()) {
     	   JSONObject wallValue = (JSONObject)entry.getValue();
@@ -238,10 +242,10 @@ public class CreateHouseJsonUtil {
     	   //rightEdgeId
     	   _walls.add(_wallValue);
        }
-		
+
        return _walls;
 	}
-	
+
 	//门/窗
 	private static JSONArray convertSymbols(JSONObject symbols,int floor) {
 	   JSONArray _symbols = new JSONArray();
@@ -256,19 +260,19 @@ public class CreateHouseJsonUtil {
     	   											_symbolValue.put("points2d", symbolValue.getJSONArray("points2d"));
     	   _symbolValue.put("geoType", symbolValue.getString("geoType"));
     	   _symbolValue.put("floor", floor);
-    	   
+
     	   //"groundClearance": -0.7,
 		   //"height": 1.3,
-    	   
+
     	   _symbols.add(_symbolValue);
        }
-		
+
        return _symbols;
 	}
-	
+
 	private static JSONArray convertRooms(JSONArray rooms,int floor) {
 		JSONArray _rooms = new JSONArray();
-		
+
 		for(int i=0;i<rooms.size();++i) {
 			JSONObject room = rooms.getJSONObject(i);
 			String name = room.getString("name");
@@ -277,7 +281,7 @@ public class CreateHouseJsonUtil {
 			JSONArray wallIds = room.getJSONArray("wallIds");
 			JSONArray wallPointIDs = room.getJSONArray("wallPointIDs");
 			String parent = room.getString("parent");
-			
+
 			JSONObject _room = new JSONObject();
 			_room.put("name", name);
 			_room.put("roomId", roomId);
@@ -285,7 +289,7 @@ public class CreateHouseJsonUtil {
 			_room.put("wallIds", wallIds);
 			_room.put("wallPointIDs", wallPointIDs);
 			_room.put("parent", parent);
-			
+
 			_rooms.add(_room);
 		}
 		return _rooms;

+ 83 - 87
4dkankan-utils-model/src/main/java/com/fdkankan/model/utils/CreateObjUtil.java

@@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
 
 import java.io.*;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import lombok.extern.slf4j.Slf4j;
 
@@ -34,7 +35,7 @@ public class CreateObjUtil {
 		}
 		log.info("计算完毕");
 	}
-	
+
 	public void saveuploadImgs2(String folderName) throws IOException, Exception
 	{
 		log.info("开始计算");
@@ -49,7 +50,7 @@ public class CreateObjUtil {
 		log.info("计算完毕");
 		log.info("obj和camera转换成大场景要的格式");
 		convertobjTotxt( folderName);
-		
+
 	}
 
 	//开始建模
@@ -129,7 +130,7 @@ public class CreateObjUtil {
 		callshell(command);
 		log.info("复制完毕:" + command);
 	}
-	
+
 	//开始建模
 	public void build3dModelSFM(String folderName,String isModel) throws Exception{
 		log.info("开始建模");
@@ -177,7 +178,7 @@ public class CreateObjUtil {
 			e.printStackTrace();
 		}
 	}
-	
+
 	//调整切图
 	public void adjustImgs(String folderName)
 	{
@@ -192,7 +193,7 @@ public class CreateObjUtil {
 			e.printStackTrace();
 		}
 	}
-	
+
 	//obj和camera转换成大场景要的格式
 	public void convertobjTotxt(String folderName) throws Exception
 	{
@@ -202,16 +203,16 @@ public class CreateObjUtil {
 		//camera
 		command = "/home/ubuntu/photoscan-pro/main/read_camera/read_camera "+folderName;
 		callshell(command);
-		
+
 		String prefix = ConstantFilePath.CREATE_BIG_SCENE_PATH+folderName+File.separator+"data"+File.separator;
 		String srcpath = prefix +"mesh.txt";
 		String despath = prefix +"dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam";
-				
+
 		convertTxtToDam( srcpath, despath);
 		//dam转换成lzma
 		command = "lzma /home/ubuntu/photo_data/bigscene/"+folderName+"/data/dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam";
 		callshell(command);
-		
+
 		srcpath = prefix +"vision.txt";
 		despath = prefix +"vision.modeldata";
 		convertTxtToVisionmodeldata( srcpath, despath);
@@ -270,7 +271,7 @@ public class CreateObjUtil {
 		}
 
 	}
-	
+
 	public static void convertTxtToDam(String srcpath,String despath)throws Exception{
 		InputStream inputStream = null;
 		InputStreamReader reader = null;
@@ -314,28 +315,28 @@ public class CreateObjUtil {
 		}
 
 	}
-	
+
 	public static void convertVisionmodeldataToTxt(String srcpath,String despath)throws Exception
 	{
 		try
 		{
-			File file = new File(srcpath); 
+			File file = new File(srcpath);
 			FileInputStream fis=new FileInputStream(file);
 
 			Visionmodeldata.NavigationInfo data_NavigationInfo = Visionmodeldata.NavigationInfo.parseFrom(fis);
-	
-			//PrintStream out = new PrintStream(despath); 
+
+			//PrintStream out = new PrintStream(despath);
 			String jsonFormat1 = JsonFormat.printToString(data_NavigationInfo);
-			ByteArrayInputStream stream = new ByteArrayInputStream(jsonFormat1.getBytes());  
-	        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径  
-	        BufferedInputStream bis = new BufferedInputStream(stream);  
-	        int b = -1;  
-	        while ((b = bis.read()) != -1) {  
-	           bos.write(b);  
-	        }  
+			ByteArrayInputStream stream = new ByteArrayInputStream(jsonFormat1.getBytes());
+	        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
+	        BufferedInputStream bis = new BufferedInputStream(stream);
+	        int b = -1;
+	        while ((b = bis.read()) != -1) {
+	           bos.write(b);
+	        }
 			//out.close();
-	        bis.close();  
-	        bos.close(); 
+	        bis.close();
+	        bos.close();
 		}
 		catch(Exception e)
 		{
@@ -344,7 +345,7 @@ public class CreateObjUtil {
 	        log.error(trace.toString());
 		}
 	}
-	
+
 	public static void convertTxtToVisionmodeldata(String srcpath,String despath)throws Exception
 	{
 		try{
@@ -352,17 +353,17 @@ public class CreateObjUtil {
 			String jsonFormat = readTxtFileToJson(srcpath);
 			JsonFormat.merge(jsonFormat, builder);
 			byte[] buf= builder.build().toByteArray();
-			
+
 			//把序列化后的数据写入本地磁盘
-	        ByteArrayInputStream stream = new ByteArrayInputStream(buf);  
-	        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径  
-	        BufferedInputStream bis = new BufferedInputStream(stream);  
-	        int b = -1;  
-	        while ((b = bis.read()) != -1) {  
-	           bos.write(b);  
-	        }  
-	        bis.close();  
-	        bos.close(); 
+	        ByteArrayInputStream stream = new ByteArrayInputStream(buf);
+	        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
+	        BufferedInputStream bis = new BufferedInputStream(stream);
+	        int b = -1;
+	        while ((b = bis.read()) != -1) {
+	           bos.write(b);
+	        }
+	        bis.close();
+	        bos.close();
 		}
 		catch(Exception e)
 		{
@@ -429,22 +430,22 @@ public class CreateObjUtil {
 			log.error(trace.toString());
 		}
 	}
-	
+
 	public static void callshell(String command){
         try {
 			 Long start = System.currentTimeMillis();
 			 Process process = Runtime.getRuntime().exec(command);
         	 StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
-             errorGobbler.start();  
-             StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");  
-             outGobbler.start();  
+             errorGobbler.start();
+             StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
+             outGobbler.start();
              process.waitFor();
 			log.info("脚本{}执行完毕,用时:{}ms",command,System.currentTimeMillis()-start);
-        } catch (Exception e) {  
-            e.printStackTrace();  
-        }  
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 	}
-	
+
 	public static int doWaitFor(Process process) {
 		  InputStream in = null;
 		  InputStream err = null;
@@ -498,44 +499,44 @@ public class CreateObjUtil {
 		  return exitValue;
 		}
 
-	
+
 	private boolean isModel(String sPath,String folderName)
 	{
-		boolean flag = false;  
-		File file = new File(sPath);  
-	    if (file.isFile() && file.exists()) {  
-	        flag = true;  
-	    }  
+		boolean flag = false;
+		File file = new File(sPath);
+	    if (file.isFile() && file.exists()) {
+	        flag = true;
+	    }
 	    log.info("等待...");
-	    return flag;  
+	    return flag;
 	}
-	
+
 	public static String readTxtFileToJson(String filePath){
-        try { 
-                String encoding="UTF-8"; 
-                File file=new File(filePath); 
-                if(file.isFile() && file.exists()){ 
-                    InputStreamReader read = new InputStreamReader( 
+        try {
+                String encoding="UTF-8";
+                File file=new File(filePath);
+                if(file.isFile() && file.exists()){
+                    InputStreamReader read = new InputStreamReader(
                     new FileInputStream(file),encoding);
-                    BufferedReader bufferedReader = new BufferedReader(read); 
-                    String lineTxt = null; 
+                    BufferedReader bufferedReader = new BufferedReader(read);
+                    String lineTxt = null;
                     String result="";
-                    while((lineTxt = bufferedReader.readLine()) != null){ 
+                    while((lineTxt = bufferedReader.readLine()) != null){
                     	result+=lineTxt;
-                        //log.info(lineTxt); 
-                    } 
-                    read.close(); 
+                        //log.info(lineTxt);
+                    }
+                    read.close();
                     return result;
-        }else{ 
+        }else{
             return null;
-        } 
-        } catch (Exception e) { 
-            e.printStackTrace(); 
+        }
+        } catch (Exception e) {
+            e.printStackTrace();
             return null;
-        } 
-      
+        }
+
     }
-	
+
 	public Map<String,String> getAllFile(String dPath,String prefix)
 	{
 		File dirFile = new File(dPath);
@@ -551,7 +552,7 @@ public class CreateObjUtil {
         }
 	    return map;
 	}
-	
+
 	public Map<String,String> getchildFile(String dPath,String prefix,String childname)
 	{
 		File dirFile = new File(dPath+File.separator+childname);
@@ -568,7 +569,7 @@ public class CreateObjUtil {
         }
 	    return map;
 	}
-	
+
 	//转台拼图
 	public void buildPanoramicImgs(String folderName)throws Exception
 	{
@@ -577,7 +578,7 @@ public class CreateObjUtil {
 		callshell(command);
 		log.info("全景图拼接完毕");
 	}
-	
+
 	//六目拼图、切图,计算
 	public void buildForSix(String folderName)throws Exception
 	{
@@ -698,24 +699,19 @@ public class CreateObjUtil {
 
 	public static void main(String[] args) throws Exception {
 
-		List<File> zipList = new ArrayList<>();
-		zipList.addAll(FileUtil.loopFiles("E:\\20240112"));
-		zipList.addAll(FileUtil.loopFiles("E:\\20240113"));
-		zipList.addAll(FileUtil.loopFiles("E:\\20240115"));
-		zipList.addAll(FileUtil.loopFiles("E:\\20240116"));
-		zipList.addAll(FileUtil.loopFiles("E:\\20240117"));
-		zipList.addAll(FileUtil.loopFiles("E:\\20240118"));
-		zipList.addAll(FileUtil.loopFiles("E:\\20240119"));
-		zipList.addAll(FileUtil.loopFiles("E:\\20240130"));
-		Set<String> numList = new HashSet<>();
-		zipList.stream().forEach(file -> {
-			String str = file.getName();
-			numList.add(str.substring(0, str.lastIndexOf(".")));
-		});
-		for (String num : numList) {
-			FileUtil.appendUtf8String(num + "\n", "E:\\num.txt");
-		}
+		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");
 
 
 	}