Kstars

MeshBuffer.cpp
1 #include <iostream>
2 #include <cstdlib>
3 
4 #include "HTMesh.h"
5 #include "MeshBuffer.h"
6 
7 MeshBuffer::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 
21 MeshBuffer::~MeshBuffer()
22 {
23  free(m_buffer);
24 }
25 
26 int 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 }
int append(Trixel trixel)
add trixels to the buffer
Definition: MeshBuffer.cpp:26
Definition: HTMesh.h:56
int size() const
returns the total number of trixels in the HTM.
Definition: HTMesh.h:118
void fill()
fills the buffer with consecutive integers
Definition: MeshBuffer.cpp:37
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 8 2022 04:13:22 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.