|
@@ -38,8 +38,10 @@ public class VTK {
|
|
|
String line;
|
|
|
Integer nele =0;
|
|
|
Integer neln =0;
|
|
|
-
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 最小grid
|
|
|
+ */
|
|
|
+ Integer minGIndex =1;
|
|
|
|
|
|
|
|
|
while((line=bfreader.readLine())!=null) {//包含该行内容的字符串,不包含任何行终止符,如果已到达流末尾,则返回 null
|
|
@@ -50,6 +52,7 @@ public class VTK {
|
|
|
if(line.indexOf("CROD")>-1){
|
|
|
ArrayList<Integer> tmp=patInts(line);
|
|
|
ArrayList<Integer> cellst =new ArrayList<>();
|
|
|
+
|
|
|
cellst.add(tmp.get(2)-1);
|
|
|
cellst.add(tmp.get(3)-1);
|
|
|
cells.add(cellst);
|
|
@@ -517,22 +520,27 @@ public class VTK {
|
|
|
// 第4列表示节点的Y坐标;
|
|
|
// 第5列表示节点的Z坐标;
|
|
|
else if(line.indexOf("GRID*")>-1){
|
|
|
+
|
|
|
ArrayList<Float> pointst =new ArrayList<>();
|
|
|
ArrayList<Float> tmp=patFloats2(line);
|
|
|
String line2=bfreader.readLine();
|
|
|
ArrayList<Float> tmp2=patFloats2(line2);
|
|
|
+
|
|
|
pointst.add(tmp.get(1));
|
|
|
pointst.add(tmp.get(2));
|
|
|
pointst.add(tmp2.get(0));
|
|
|
+ pointst.add(tmp.get(0));//代号
|
|
|
points.add(pointst);
|
|
|
|
|
|
}
|
|
|
else if(line.indexOf("GRID")>-1){
|
|
|
ArrayList<Float> pointst =new ArrayList<>();
|
|
|
ArrayList<Float> tmp=patFloats(line);
|
|
|
+
|
|
|
pointst.add(tmp.get(1));
|
|
|
pointst.add(tmp.get(2));
|
|
|
pointst.add(tmp.get(3));
|
|
|
+ pointst.add(tmp.get(0));//代号
|
|
|
points.add(pointst);
|
|
|
}
|
|
|
|
|
@@ -556,7 +564,7 @@ public class VTK {
|
|
|
writer.write("\r\n");//换行
|
|
|
|
|
|
for (ArrayList<Float> point:points) {
|
|
|
- for (int i = 0; i <point.size() ; i++) {
|
|
|
+ for (int i = 0; i <point.size()-1 ; i++) {
|
|
|
writer.write(blanks(5));
|
|
|
writer.write(fixedFloat(point.get(i)));
|
|
|
}
|
|
@@ -575,7 +583,8 @@ public class VTK {
|
|
|
writer.write(fixedString(8,String.valueOf(cell.size())));
|
|
|
writer.write(blanks(2));
|
|
|
for (int i = 0; i <cell.size() ; i++) {
|
|
|
- writer.write(fixedString(8,String.valueOf(cell.get(i))));
|
|
|
+ Integer newIndex = findNewGridIndex(points, cell.get(i)+1);
|
|
|
+ writer.write(fixedString(8,newIndex.toString()));
|
|
|
}
|
|
|
writer.write("\r\n");//换行
|
|
|
}
|
|
@@ -625,6 +634,16 @@ public class VTK {
|
|
|
return vtkFile.getPath();
|
|
|
}
|
|
|
|
|
|
+ private static Integer findNewGridIndex(ArrayList<ArrayList<Float>> points, int oldeIndex) {
|
|
|
+ int i=0;
|
|
|
+ for (ArrayList<Float> point: points) {
|
|
|
+ if(point.get(3)==oldeIndex){
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
public static ArrayList<Integer> patInts(String line){
|
|
@@ -729,6 +748,9 @@ public class VTK {
|
|
|
return t;
|
|
|
}
|
|
|
public static void main(String[] args) {
|
|
|
+ File f =new File("D:\\FEMLab\\ADI.SimWork4.0\\FEMLab\\data\\static analysis\\1.09_geartooth-static.bdf");
|
|
|
+ VTK.CreateVTKFile(f,"f");
|
|
|
+
|
|
|
// String ling =" 4.000000000000 0.500000000000 -0.500000000000";
|
|
|
// System.out.println(ling.length());
|
|
|
// System.out.println(String.format("%25.12f",1.51597));
|