Skip to content
Snippets Groups Projects
Select Git revision
  • 839368ab160631dfe3204404889f44739e8d0f5c
  • master default protected
  • hierarchical-basis
  • alphashapes
  • bl
  • relaying
  • new_export_boris
  • oras_vs_osm
  • reassign_partitions
  • distributed_fwi
  • rename-classes
  • fix/fortran-api-example-t4
  • robust_partitions
  • reducing_files
  • fix_overlaps
  • 3115-issue-fix
  • 3023-Fillet2D-Update
  • convert_fdivs
  • tmp_jcjc24
  • fixedMeshIF
  • save_edges
  • 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

t1.py

Blame
  • GModelIO_VRML.cpp 7.87 KiB
    // Gmsh - Copyright (C) 1997-2017 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 <stdlib.h>
    #include <string.h>
    #include "GModel.h"
    #include "OS.h"
    #include "MLine.h"
    #include "MTriangle.h"
    #include "MQuadrangle.h"
    
    static int skipUntil(FILE *fp, const char *key)
    {
      char str[256], key_bracket[256];
      strcpy(key_bracket, key);
      strcat(key_bracket, "[");
      while(fscanf(fp, "%s", str)){
        if(!strcmp(str, key)){
          while(!feof(fp) && fgetc(fp) != '['){}
          return 1;
        }
        if(!strcmp(str, key_bracket)){
          return 1;
        }
      }
      return 0;
    }
    
    static int readVerticesVRML(FILE *fp, std::vector<MVertex*> &vertexVector,
                                std::vector<MVertex*> &allVertexVector)
    {
      double x, y, z;
      if(fscanf(fp, "%lf %lf %lf", &x, &y, &z) != 3) return 0;
      vertexVector.push_back(new MVertex(x, y, z));
      while(fscanf(fp, " , %lf %lf %lf", &x, &y, &z) == 3)
        vertexVector.push_back(new MVertex(x, y, z));
      for(unsigned int i = 0; i < vertexVector.size(); i++)
        allVertexVector.push_back(vertexVector[i]);
      Msg::Info("%d vertices", vertexVector.size());
      return 1;
    }
    
    static int readElementsVRML(FILE *fp, std::vector<MVertex*> &vertexVector, int region,
                                std::map<int, std::vector<MElement*> > elements[3],
                                bool strips=false)
    {
      int i;
      std::vector<int> idx;
      if(fscanf(fp, "%d", &i) != 1) return 0;
      idx.push_back(i);
    
      // check if vertex indices are separated by commas
      char tmp[256];
      const char *format;
      fpos_t position;
      fgetpos(fp, &position);
      if(!fgets(tmp, sizeof(tmp), fp)) return 0;
      fsetpos(fp, &position);
      if(strstr(tmp, ","))
        format = " , %d";
      else
        format = " %d";
    
      while(fscanf(fp, format, &i) == 1){
        if(i != -1){
          idx.push_back(i);
        }
        else{