Kstars

MeshBuffer.cpp
1#include <iostream>
2#include <cstdlib>
3
4#include "HTMesh.h"
5#include "MeshBuffer.h"
6
7MeshBuffer::MeshBuffer(HTMesh *mesh)
8{
9 m_size = 0;
10 m_error = 0;
11 maxSize = mesh->size();
12 m_buffer = (Trixel *)malloc(sizeof(Trixel) * maxSize);
13
14 if (m_buffer == nullptr)
15 {
16 fprintf(stderr, "MeshBuffer: Could not allocate buffer sized %d\n", maxSize * (int)sizeof(Trixel));
17 exit(1);
18 }
19}
20
21MeshBuffer::~MeshBuffer()
22{
23 free(m_buffer);
24}
25
26int MeshBuffer::append(Trixel trixel)
27{
28 if (m_size >= maxSize)
29 {
30 m_error++;
31 return 0;
32 }
33 m_buffer[m_size++] = trixel;
34 return 1;
35}
36
38{
39 for (Trixel i = 0; i < (int)maxSize; i++)
40 {
41 m_buffer[i] = i;
42 }
43 m_size = maxSize;
44}
HTMesh was originally intended to be a simple interface to the HTM library for the KStars project tha...
Definition HTMesh.h:57
int size() const
returns the total number of trixels in the HTM.
Definition HTMesh.h:118
void fill()
fills the buffer with consecutive integers
int append(Trixel trixel)
add trixels to the buffer
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:05:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.