Skip to content
Snippets Groups Projects
Select Git revision
  • 88d91b7992485482273861c082f31a4c29e6bc98
  • master default protected
  • overlaps_tags_and_distributed_export
  • overlaps_tags_and_distributed_export_rebased
  • relaying
  • alphashapes
  • patches-4.14
  • steplayer
  • bl
  • pluginMeshQuality
  • fixBugsAmaury
  • hierarchical-basis
  • new_export_boris
  • oras_vs_osm
  • reassign_partitions
  • distributed_fwi
  • rename-classes
  • fix/fortran-api-example-t4
  • robust_partitions
  • reducing_files
  • fix_overlaps
  • gmsh_4_14_0
  • gmsh_4_13_1
  • gmsh_4_13_0
  • gmsh_4_12_2
  • gmsh_4_12_1
  • gmsh_4_12_0
  • gmsh_4_11_1
  • gmsh_4_11_0
  • gmsh_4_10_5
  • gmsh_4_10_4
  • gmsh_4_10_3
  • gmsh_4_10_2
  • gmsh_4_10_1
  • gmsh_4_10_0
  • gmsh_4_9_5
  • gmsh_4_9_4
  • gmsh_4_9_3
  • gmsh_4_9_2
  • gmsh_4_9_1
  • gmsh_4_9_0
41 results

gl2ps.cpp

Blame
  • GModelIO_POS.cpp 2.43 KiB
    // Gmsh - Copyright (C) 1997-2016 C. Geuzaine, J.-F. Remacle
    //
    // See the LICENSE.txt file for license information. Please report all
    // bugs and problems to the public mailing list <gmsh@onelab.info>.
    
    #include <stdio.h>
    #include "GModel.h"
    #include "OS.h"
    #include "MElement.h"
    
    int GModel::writePOS(const std::string &name, bool printElementary,
                         bool printElementNumber, bool printSICN, bool printGamma,
                         bool printRho, bool printDisto,
                         bool saveAll, double scalingFactor)
    {
      FILE *fp = Fopen(name.c_str(), "w");
      if(!fp){
        Msg::Error("Unable to open file '%s'", name.c_str());
        return 0;
      }
    
      /*
      bool printVertices = true;
      if(printVertices){
        fprintf(fp, "View \"Vertices\" {\n");
        std::vector<GEntity*> entities;
        getEntities(entities);
        for(unsigned int i = 0; i < entities.size(); i++)
          for(unsigned int j = 0; j < entities[i]->mesh_vertices.size(); j++){
            MVertex *v = entities[i]->mesh_vertices[j];
            fprintf(fp, "SP(%g,%g,%g){1};\n", v->x(), v->y(), v->z());
          }
        fprintf(fp, "};\n");
        fclose(fp);
        return 1;
      }
      */
    
      bool f[6] = {printElementary, printElementNumber, printSICN, printGamma, printRho,
                   printDisto};
    
      bool first = true;
      std::string names;
      if(f[0]){
        if(first) first = false; else names += ",";
        names += "\"Elementary Entity\"";
      }
      if(f[1]){
        if(first) first = false; else names += ",";
        names += "\"Element Number\"";
      }
      if(f[2]){
        if(first) first = false; else names += ",";
        names += "\"SICN\"";
      }
      if(f[3]){
        if(first) first = false; else names += ",";
        names += "\"Gamma\"";
      }
      if(f[4]){
        if(first) first = false; else names += ",";
        names += "\"Rho\"";
      }
      if(f[5]){
        if(first) first = false; else names += ",";
        names += "\"Disto\"";
      }
    
      if(names.empty()){ fclose(fp); return 0; }
    
      if(noPhysicalGroups()) saveAll = true;
    
      fprintf(fp, "View \"Statistics\" {\n");
      fprintf(fp, "T2(1.e5,30,%d){%s};\n", (1<<16)|(4<<8), names.c_str());
    
      std::vector<GEntity*> entities;
      getEntities(entities);
      for(unsigned int i = 0; i < entities.size(); i++)
        if(saveAll || entities[i]->physicals.size())
          for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++)
            entities[i]->getMeshElement(j)->writePOS
              (fp, f[0], f[1], f[2], f[3], f[4], f[5], scalingFactor, entities[i]->tag());
      fprintf(fp, "};\n");
    
      fclose(fp);
      return 1;
    }