Skip to content

Instantly share code, notes, and snippets.

View jirihnidek's full-sized avatar

Jiri Hnidek jirihnidek

View GitHub Profile
@jirihnidek
jirihnidek / CMakeLists.txt
Created November 25, 2016 14:35
Test of threads at Linux
# Main CMakeFile.txt
# Minimal version of CMake
cmake_minimum_required (VERSION 2.6)
# Build type
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
@jirihnidek
jirihnidek / CMakeLists.txt
Last active November 29, 2016 08:30
Test of forking (creating lot of child processes) at Linux
# Main CMakeFile.txt
# Minimal version of CMake
cmake_minimum_required (VERSION 2.6)
# Build type
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
@jirihnidek
jirihnidek / bspline_solid-boolean.py
Created November 9, 2016 08:17
Example of solid boolean operation
"""
This module is able to create simple solid object (cube). Each side of
cube is bspline surface. This solid object can be exported to BREP file.
"""
from OCC.gp import *
from OCC.Geom import *
from OCC.TColGeom import *
from OCC.TColgp import *
from OCC.GeomConvert import *
@jirihnidek
jirihnidek / simple_webgl.html
Last active November 7, 2016 21:54
Simple example of WebGL
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>WebGL Simple Point</title>
</head>
<body>
<canvas width="512" height="512" id="webgl_canvas"></canvas>
@jirihnidek
jirihnidek / bmesh_shape_keys.py
Created September 15, 2016 19:57
Simple Blender Python script demonstrating using BMesh and Shape Keys
import bpy
import bmesh
import mathutils
def main():
"""
Example of bmesh and shape keys
"""
# Add basis shape
@jirihnidek
jirihnidek / blender_img_3d_background.py
Last active December 31, 2021 15:56
This is simple Blender Python script for setting 3D background empty object.
"""
This example try to create new empty object visualized as
image. Image fits to the background of current active camera.
When you set X,Y coordinates of empty object called 'Pixel',
then this object is position at corresponding X,Y coordinate
at image in 3D space.
"""
import bpy
import math
@jirihnidek
jirihnidek / blender_dist_pnt_to_plane.py
Last active September 15, 2016 19:36
Simple Blender script for computing distance between plane (camera) and point.
"""
Demonstration of computation distance point to plane. Plane is represented by normal
vector and point laying at the plane.
"""
import bpy
import mathutils
def main():
#include <stdlib.h>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS_Edge.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <TopoDS_Wire.hxx>
"""
This simple example of Blender Python script prints membership of verticies in vertex groups and weights. It uses deform layer.
"""
import bpy
import bmesh
obj = bpy.context.object
# Get the active mesh
import bpy
import bmesh
obj = bpy.context.active_object
mesh = obj.data
bmsh = bmesh.new()
bmsh.from_mesh(mesh)
# Do something with mesh: e.g. add layer
layer = bmsh.verts.layers.int.new('Example')
for id,vert in enumerate(bmsh.verts):