~llaniewski/esys-particle/remote-force

« back to all changes in this revision

Viewing changes to Tools/dump2vtk/frame_vtk.cpp

  • Committer: L Laniewski-Wollk
  • Date: 2022-05-18 07:19:40 UTC
  • mfrom: (1186.1.45 esys-particle)
  • Revision ID: llaniewski@gmail.com-20220518071940-0wsaxtb7ux633sta
MergeĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
540
540
  } else if ((version==1)||(version==2) || (version==3)) {
541
541
    headerfile >> dummystring >> dummy;
542
542
    headerfile >> dummy >> dummy >> dummy;
543
 
    headerfile >> dummystring >> geo_version;
 
543
    std::getline(headerfile,dummystring);
544
544
  } else {
545
545
    cerr << "unknown checkpoint version " << version << endl;
546
546
  }
547
547
  // get bounding box
548
 
  headerfile >> dummystring;
549
 
  headerfile >> xmin >> ymin >> zmin >> xmax >> ymax >> zmax ;
 
548
  std::getline(headerfile,dummystring);
 
549
  headerfile >> dummystring >> xmin >> ymin >> zmin >> xmax >> ymax >> zmax ;
550
550
 
551
551
  // ignore periodic bdry
552
552
  headerfile >> dummystring >> dummy >> dummy >> dummy;
1317
1317
        outputfile << "DATASET POLYDATA\n";
1318
1318
        outputfile << "POINTS " << numNodes << " float\n";
1319
1319
 
 
1320
        std::map<int,int> node_map; // we need an id->position map for the nodes in case node numbering doesn't start at 0
1320
1321
        for(int nn=0;nn<numNodes;nn++){
1321
 
           string X, Y, Z;
1322
 
           datafile >> skip >> skip >> skip >> X >> Y >> Z;
 
1322
           double X, Y, Z; 
 
1323
           int nid; // node id
 
1324
           datafile >> nid >> skip >> skip >> X >> Y >> Z;
1323
1325
           outputfile << X << " " << Y << " " << Z << "\n";
 
1326
           node_map[nid]=nn;
1324
1327
        }
1325
1328
 
1326
1329
        datafile >> skip;
1329
1332
        outputfile << "\nPOLYGONS " << numTri << " " << numTri*4 << "\n";
1330
1333
 
1331
1334
        for(int nn=0;nn<numTri;nn++){
1332
 
           string P1, P2, P3;
 
1335
           int P1, P2, P3; // corner ids in the snapshot
1333
1336
           datafile >> skip >> skip >> P1 >> P2 >> P3;
1334
 
           outputfile << "3 " << P1 << " " << P2 << " " << P3 << "\n";
 
1337
           // convert node ids to node positions
 
1338
           auto cp1=node_map.find(P1);
 
1339
           auto cp2=node_map.find(P2);
 
1340
           auto cp3=node_map.find(P3);
 
1341
           
 
1342
           if(cp1==node_map.end() || cp2==node_map.end() || cp3==node_map.end()){
 
1343
                std::cerr << "wrong node id found while processing mesh " << meshName << std::endl;  
 
1344
           } else {
 
1345
                outputfile << "3 " << cp1->second << " " << cp2->second << " " << cp3->second << "\n";
 
1346
           }
1335
1347
        }
1336
1348
      }
1337
1349
    }