33#include <NDEVR/FactoryOptions.h>
35#include <NDEVR/Grid.h>
36#include <NDEVR/Geometry.h>
37#include <NDEVR/Model.h>
38#include <NDEVR/Grid.h>
39#include <NDEVR/Material.h>
41#include <NDEVR/Scanner.h>
42#include <NDEVR/Translator.h>
43#include <NDEVR/Exception.h>
50 static void readFile(File& file, Model& model,
const FactoryOptions&)
52 Scanner scanner(file);
55 Vector<2, fltp08> offset;
56 Vector<2, fltp08> size;
57 Vector<2, uint04> index_size;
58 Geometry
mesh = model.createChildGeometry();
60 scanner.nextLine(); offset[
Y] = scanner.getNext<
fltp08>();
61 scanner.nextLine(); offset[
X] = scanner.getNext<
fltp08>();
62 scanner.nextLine(); size[
Y] = scanner.getNext<
fltp08>() - offset[Y];
63 scanner.nextLine(); size[
X] = scanner.getNext<
fltp08>() - offset[X];
66 scanner.nextLine(); index_size[
X] = scanner.getNext<
uint04>() + 1;
67 scanner.nextLine(); index_size[
Y] = scanner.getNext<
uint04>() + 1;
69 Vector<2, fltp08> scale = size / (index_size - 1U).as<2, fltp08>();
71 grid_mesh.setupVertexTable(index_size, Geometry::e_cartesian_1F);
73 for (uint04 y = 0; y < index_size[
Y]; y++)
75 for (uint04 x = 0; x < index_size[
X]; x++)
77 if (!scanner.nextLine())
78 throw FileException(String(file),
_t(
"Bad vertex size"));
79 grid_mesh.setGridVector(VertexProperty::Position, x, y, scanner.getNext<fltp04>());
82 Matrix<fltp08> trans(1);
83 trans = trans.offset(offset);
84 trans = trans.scale(scale);
85 mesh.setTransform(trans);
87 grid_mesh.calculateGridNormals();
89 Material mat = model.createChildMaterial(PrimitiveProperty::Solid);
90 mat.setShadingModel(Material::ShadingModel::e_phong);
92 mat.setUVMode(UVType::e_KD, Material::UVMode::e_solid_color);
93 mat.setUVColor(UVType::e_KD, Vector<4, fltp04>(.5f, .5f, .5f, 1.0f));
95 mat.setUVMode(UVType::e_KS, Material::UVMode::e_solid_color);
96 mat.setUVColor(UVType::e_KS, Vector<4, fltp04>(.1f, .1f, .1f, 1.0f));
98 static bool canRead(
const File& file)
100 if (file.endsWith(
".grd",
true))
#define _t(english_string)
Definition Translator.h:90
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:115
@ Y
Definition BaseValues.hpp:197
@ X
Definition BaseValues.hpp:195
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:176