Browse Source

laser-to-dxf

lyhzzz 4 tháng trước cách đây
mục cha
commit
80ba4537ca

+ 13 - 5
4dkankan-utils-dxf/src/main/java/com/fdkankan/dxf/parse/utils/LaserMeterToDxfUtil.java

@@ -58,16 +58,24 @@ public class LaserMeterToDxfUtil {
             JSONObject jsonObject = (JSONObject) (obj);
             JSONArray points = jsonObject.getJSONArray("points");
             String type = jsonObject.getString("type");
-            if(type.contains("AREA")){
+            if(type.contains("AREA") || type.contains("RECTANGLE")){
                 for (int i = 0 ;i < points.size();i ++){
                     JSONObject point1 = (JSONObject) points.get(i);
                     JSONObject point2 = (JSONObject) points.get(  i+1 >= points.size()? 0 :i+1 );
                     drawLine(point1,point2,pointSet,dxfDocWriter);
-
                 }
-
             }
-            if(type.equals("LINE")){
+            if(type.contains("SERIES") ){
+                for (int i = 0 ;i < points.size();i ++){
+                    if(i+1 >= points.size()){
+                        continue;
+                    }
+                    JSONObject point1 = (JSONObject) points.get(i);
+                    JSONObject point2 = (JSONObject) points.get(  i+1 >= points.size()? 0 :i+1 );
+                    drawLine(point1,point2,pointSet,dxfDocWriter);
+                }
+            }
+            if(type.contains("LINE") ){
                 JSONObject point1 = (JSONObject) (points.get(0));
                 JSONObject point2 = (JSONObject) (points.get(1));
                 drawLine(point1,point2,pointSet,dxfDocWriter);
@@ -153,7 +161,7 @@ public class LaserMeterToDxfUtil {
     }
 
     public static void main(String[] args) throws Exception{
-        String inPath ="D:\\cad\\work\\111\\6.json";
+        String inPath ="D:\\cad\\work\\111\\1.json";
         String outPath ="D:\\cad\\work\\111\\"+new Date().getTime()+".dxf";
         LaserMeterToDxfUtil.toDxf(new File(inPath),outPath);
     }