Skip to content

Instantly share code, notes, and snippets.

View tritao's full-sized avatar
🎯
Focusing

João Matos tritao

🎯
Focusing
  • Portugal
View GitHub Profile
static PyObject* createMyConstantsEnum()
{
// Import the Python 'enum' module.
PyObject* enumModule = PyImport_ImportModule("enum");
if (!enumModule) {
PyErr_SetString(PyExc_ImportError, "Failed to import the enum module");
return nullptr;
}
@tritao
tritao / py.cpp
Last active March 2, 2025 23:01
#include <Python.h>
#include <thread>
#include <future>
#include <iostream>
#include <chrono>
// ----- Python-bound Function: execute -----
//
// This function takes an integer, offloads a computation (here, squaring the number)
// using std::async, and returns the result.
FEP00
Title Evolution of FreeCAD's Rendering Subsystem
Status Draft
Author(s) Joao Matos (tritao)
Created Mar 02, 2025
Updated Mar 02, 2025

#include <iostream>
#include <chrono>
struct Color {
float a, b, c, d;
};
volatile float sink = 0.0f;
#if defined(_MSC_VER)
diff --git a/cMake/FreeCAD_Helpers/SetupPython.cmake b/cMake/FreeCAD_Helpers/SetupPython.cmake
index a2887affcb..6043fba779 100644
--- a/cMake/FreeCAD_Helpers/SetupPython.cmake
+++ b/cMake/FreeCAD_Helpers/SetupPython.cmake
@@ -18,4 +18,12 @@ macro(SetupPython)
message(FATAL_ERROR "To build FreeCAD you need at least Python 3.8\n")
endif()
+ # If a custom Python directory was passed in, then save it as PYTHON_HOME_DIR,
+ # which is used by config.h.cmake when generating the config header file.
@tritao
tritao / coin.sh
Last active February 10, 2025 22:46
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $SCRIPT_DIR
cd coin
# rm -rf bld
mkdir -p bld && cd bld
cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCOIN_BUILD_SHARED_LIBS=1 -DCOIN_BUILD_EXAMPLES=1 -DCOIN_BUILD_TRACY_PROFILER=0 \
@tritao
tritao / Bindings.md
Last active February 15, 2025 15:23

FreeCAD C++ to Python Binding System Manual

Welcome to the new Python-based binding system for exposing FreeCAD C++ APIs to Python. This system replaces the previous XML-based approach with a more direct and flexible Python interface, allowing C++ developers to define Python bindings using native Python syntax, type annotations, and decorators.


Table of Contents

#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $SCRIPT_DIR
cd FreeCAD
# rm -rf bld
mkdir -p bld && cd bld
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_INSTALL_MODE=SYMLINK \
@tritao
tritao / gist:9411d635dec698433e2e355dc69b24fb
Created January 19, 2025 11:04
FreeCAD compile time analysis
Analyzing build trace from 'FreeCAD/bld-time/trace.out'...
**** Time summary:
Compilation (2324 times):
Parsing (frontend): 28802.2 s
Codegen & opts (backend): 1670.7 s
**** Files that took longest to parse (compiler frontend):
109871 ms: traces/qrc_resource.cpp.json
109871 ms: traces/src/Gui/CMakeFiles/FreeCADGui.dir/qrc_resource.cpp.json
59126 ms: traces/SketchObject.cpp.json
/* Options:
Date: 2021-07-05 18:21:48
Version: 5.111
Tip: To override a DTO option, remove "//" prefix before updating
BaseUrl: https://localhost:5001
//Package:
//AddServiceStackTypes: True
//AddResponseStatus: False
//AddImplicitVersion: