Files
manigraph/include/klein/klein.h
2025-04-12 11:53:04 -06:00

51 lines
913 B
C

#ifdef KLEIN_H
#error file included twice
#endif
#define KLEIN_H
#include <stdint.h>
#ifdef KLEIN_IMPLEMENT
#include <stdio.h>
#include <stdlib.h>
#endif
struct klein
{
float *vertex, *normals;
uint64_t vertex_size;
uint8_t dim;
};
/*
The klein format must have:
5 bytes with klein.
1 byte empty for expantions
1 byte with the dimention of the surface
*/
static inline
int klein_export_file(struct klein klein, const char * filename);
#ifdef KLEIN_IMPLEMENT
static inline
int klein_export_file(struct klein klein, const char * filename)
{
FILE *file = fopen(filename, "wb");
if (!file)
return 1;
fwrite("KLEIN", 1, 5, file);
fwrite("\0", 1, 1, file);
fwrite(&klein.dim, 1, 1, file);
fwrite(&klein.vertex_size, 8, 1, file);
fwrite(klein.vertex, 4, klein.vertex_size * klein.dim, file);
fwrite(klein.normals, 4, klein.vertex_size * klein.dim, file);
fclose(file);
return 0;
}
#endif