KiCad PCB EDA Suite
Loading...
Searching...
No Matches
glb_utils.cpp File Reference
#include "glb_utils.h"
#include <cstdint>
#include <cstring>
#include <fstream>
#include <map>
#include <vector>
#include <json_common.h>
#include <kiplatform/io.h>

Go to the source code of this file.

Functions

bool FixGlbLinesPrimitives (const wxString &aFilePath)
 Fix LINES primitives in a GLB file that have odd index counts.
 

Variables

static constexpr uint32_t GLB_MAGIC = 0x46546C67
 
static constexpr uint32_t GLB_CHUNK_JSON = 0x4E4F534A
 
static constexpr int GLTF_LINES_MODE = 1
 

Function Documentation

◆ FixGlbLinesPrimitives()

bool FixGlbLinesPrimitives ( const wxString & aFilePath)

Fix LINES primitives in a GLB file that have odd index counts.

OCCT 7.9+ can emit glTF LINES primitives with odd index counts for degenerate BSpline edges. The glTF spec requires LINES (mode 1) to have an even number of indices since each pair defines one line segment. Blender and other strict importers reject files that violate this constraint.

This function reads the GLB, adjusts any offending accessor counts to be even, and rewrites the file in place.

Parameters
aFilePathpath to the GLB file to fix
Returns
true if the file was processed successfully (or needed no changes)

Definition at line 42 of file glb_utils.cpp.

References KIPLATFORM::IO::AtomicWriteFile(), GLB_CHUNK_JSON, GLB_MAGIC, and GLTF_LINES_MODE.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and STEP_PCB_MODEL::WriteGLTF().

Variable Documentation

◆ GLB_CHUNK_JSON

uint32_t GLB_CHUNK_JSON = 0x4E4F534A
staticconstexpr

Definition at line 38 of file glb_utils.cpp.

Referenced by FixGlbLinesPrimitives(), ValidateGlbFile(), and WriteTempGlb().

◆ GLB_MAGIC

uint32_t GLB_MAGIC = 0x46546C67
staticconstexpr

Definition at line 37 of file glb_utils.cpp.

Referenced by FixGlbLinesPrimitives(), ValidateGlbFile(), and WriteTempGlb().

◆ GLTF_LINES_MODE

int GLTF_LINES_MODE = 1
staticconstexpr