File: wavefront.cmd

package info (click to toggle)
evolver 2.70+ds-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 17,148 kB
  • sloc: ansic: 127,395; makefile: 209; sh: 98
file content (103 lines) | stat: -rw-r--r-- 2,768 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// wavefront.cmd

// Surface Evolver command file for producing Wavefront format file
// for surface, suitable for feeding to JavaView.

// Programmer: Ken Brakke, brakke@susqu.edu, http://www.susqu.edu/brakke

// Usage:
// Set "show facet where ..." to show desired facets.
//    wavefront >>> "filename.obj"
// or, for version with normals at vertices,
//    wavefrontn >>> "filename.obj"

wavefront_assumptions := {
  if torus then
  { errprintf "Cannot run 'wavefront' command in torus mode. Do 'detorus' first.\n";
    abort;
  };

  if symmetry_group then
  { errprintf "Cannot run 'wavefront' command in symmetry group mode. Do 'detorus' first.\n";
    abort;
  };

  if space_dimension != 3 then
  { errprintf "The 'wavefront' command must be run in three-dimensional space.\n";
    abort;
  };

  if surface_dimension == 1 then
  { errprintf "The 'wavefront' command is not meant for the string model.\n";
    abort;
  };

  if simplex_representation then
  { errprintf "The 'wavefront' command is not meant for the simplex model.\n";
    abort;
  };

  if lagrange_order >= 2 then
  { errprintf "The 'wavefront' command is meant for the linear model, not quadratic or Lagrange.\n";
    abort;
  };

}

define vertex attribute v_num integer
wavefront := { 
   local new_v_num;

   wavefront_assumptions;

   // Make sure vertices consecutively numbered
   new_v_num := 1;
   foreach vertex vv do { vv.v_num := new_v_num; new_v_num += 1 };
   
   printf "# Wavefront .obj file for %s\n",datafilename;
   printf "# Produced by the Surface Evolver.\n\n";

   foreach vertex vv do printf "v %f %f %f\n",vv.x,vv.y,vv.z;
   printf "\n";
   foreach facet ff where show do 
     printf "f %g %g %g\n",ff.vertex[1].v_num,
      ff.vertex[2].v_num, ff.vertex[3].v_num;

}

// version with normals at vertices
wavefrontn := { 
   local new_v_num;

   wavefront_assumptions;

   // Make sure vertices consecutively numbered
   new_v_num := 1;
   foreach vertex vv do { vv.v_num := new_v_num; new_v_num += 1 };
   
   printf "# Wavefront .obj file for %s\n",datafilename;
   printf "# Produced by the Surface Evolver.\n\n";

   foreach vertex vv do printf "v %f %f %f\n",vv.x,vv.y,vv.z;
   printf "\n";
   foreach vertex vv do printf "vn %f %f %f\n",vv.vertexnormal[1],
      vv.vertexnormal[2],vv.vertexnormal[3];
   printf "\n";
   foreach facet ff where show do 
    printf "f %g/%g %g/%g %g/%g\n",ff.vertex[1].v_num,
      ff.vertex[1].v_num, ff.vertex[2].v_num,
      ff.vertex[2].v_num, ff.vertex[3].v_num,
      ff.vertex[3].v_num;

}

// End wavefront.cmd

/* Usage:
     Do "show facets where ... " to show desired facets.
     wavefront
 or  wavefrontn
*/