Behind you! A three-headed monkey!

QTetraMesher 0.8.4

Sunday, April 6th, 2025

This update contains a full UI rework and a new binary release for Windows (x64).

Release Notes:

  • Complete UI rework! Bye bye *.ui files, all UI stuff is done in code because I can. And some things are incredibly tedious to do in the Qt Designer…
  • Tetrameshing Options are now in the main UI instead of popup windows
  • Qt6 build on Windows and at least some Linuxes
  • Cutplanes in 6 directions to inspect inside mesh quality
  • Windows binary release:



Unix timestamp seconds and nanoseconds string conversion in C++

Friday, November 29th, 2024

I have recently worked with the PcapPlusPlus library to analyze timestamps from PCAP ethernet captures. And I have fucked up majorly the Unix timestamp to string conversion. This post is meant to
1. remind me of my failure…
2. remember how to do it right the next time

Unix timestamps represent time elapsed since 00:00:00 UTC on Thursday, 1 January 1970, mostly in seconds, in case of .pcap(ng) files with an additional fractional nanoseconds part.
The following timestamp represents Mon Jul 15 2024 17:48:40 GMT+0000 and almost a second full of nanoseconds (the fractional part):

1721065720.968918119

In my C++ program I wanted to export stuff as CSV including a row of Unix timestamps. PcapPlusPlus allows getting the timestamp from a parsed packet read from a pcap(ng) file like this:

uint32 seconds = parsedPacket.getRawPacket()->getPacketTimeStamp().tv_sec;
uint32 nanosececonds = parsedPacket.getRawPacket()->getPacketTimeStamp().tv_nsec;

Converting this to string seems to be straight forward using a std::stringstream. The crucial part is that the nanoseconds part can start with one or more zeros such as this:

1721065721.008918119

The fractional part represents 0.008918119 seconds. This must be 9 digits long!
Parsing the fractional part of this with a std::stringstream will strip the leading zeros which reduces the length of the nanoseconds fractional part: The fractional part must preserve the 9 digits because 0.8918119 s is much bigger than 0.008918119 s.
To properly parse the fractional part (e.g. to plot it) it must be ensured that the leading zeros also go into the string written into the CSV:

#include <sstream>
#include <iomanip>
const std::string pcapTimestampToString(const uint32 seconds_, 
                                        const uint32 nanoseconds_) {
  std::stringstream ss;
  ss<<seconds_<<".";
  ss<<std::setfill('0')<<std::setw(9)<<nanoseconds_;
  return ss.str();
}
 
const std::string pcapTimestampString = pcapTimestampToString(
                 parsedPacket.getRawPacket()->getPacketTimeStamp().tv_sec, 
                 parsedPacket.getRawPacket()->getPacketTimeStamp().tv_nsec);

This was partially answered by Stackoverflow but not specifically enough to not deserve a dedicated post.



A GPG plugin for the Kate text editor

Saturday, August 26th, 2023

This is a GPG plugin for KDE’s texteditor Kate which lets you decrypt and encrypt text files from and to .gpg/.asc.

Sourcecode and further documentation: https://github.com/dennis2society/kate-gpg-plugin



OpenCV’s TextureFlow Example in C++

Friday, March 29th, 2013

OpenCV's TextureFlow example screenshot (C++ variant)

OpenCV’s TextureFlow example screenshot (C++ variant)

 

Since version 2.4.3 OpenCV has a nice example for generating a texture flow image from an input image. This generates a grid-like distributed edge-gradient image from the input. Unfortunately this example is in Python with no C++ translation available. A while ago I have made an attempt to translate this to C++. The result is not 100% identical to the Python variant, but close enough:

 

 

 

 

 

Read the rest



QTetraMesher – A Tetrahedral Mesh Generator for Windows and Linux using Qt

Thursday, March 7th, 2013

This is a Qt-based program for Windows and Linux to generate tetrahedral meshes for finite element simulation from various surface mesh formats. It also offers a fast and easy-to-use mesh viewer based on QGLViewer and allows basic mesh manipulations (currently only scaling is possible). Two different methods for tetrahedralization are possible: Delaunay Triangulation and Johnathan Shewchuk’s Isosurface Stuffing algorithm.

This project has its own page: http://qtm.dennis2society.de/

qtm_with_CGAL_options_small qtm_with_stuffing_options_small