Skip to content

Instantly share code, notes, and snippets.

View 1f0's full-sized avatar
🎯
focusing

Minliang LIN 1f0

🎯
focusing
View GitHub Profile
@1f0
1f0 / vol2vtk
Last active June 2, 2018 03:07
Copy from other person
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
int vol2tet(const std::string& filename,
std::vector<size_t>& tet,
std::vector<double>& verts)
{
std::ifstream ifs(filename.c_str());
# 拷贝字体到 /usr/share/fonts
mkfontscale
mkfontdir
# 查看到刚安装的字体了
fc-list :lang=zh
@1f0
1f0 / blender_mtl_exporter.py
Created April 15, 2018 14:44
Blender addons for exporting material
'''
# blender-mtl-exporter
This addons can export all custom properties of all materials in the *.blend file
# Usage
Just open the "File > Export > Material (.mtl)"
'''
import bpy
@1f0
1f0 / vtk2stl.py
Last active June 1, 2018 07:53
Convert UnstructuredGrid *.vtk files to stl files, demo python code
#!/usr/bin/env python
"""Convert UnstructuredGrid in .vtk files to STL files."""
import sys
import vtk
if len(sys.argv) < 2 or sys.argv[1] == '-h' or sys.argv[1] == '--help':
print('Usage: vtk-unstructuredgrid-to-stl.py <input.vtk> <output.stl>')
sys.exit(1)
import sys
if(len(sys.argv)!=3):
print('Usage: ', sys.argv[0], 'input.vtk output.obj')
sys.exit()
import vtk
reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName(sys.argv[1])
@1f0
1f0 / pvrender.py
Created June 2, 2018 03:06
paraview-python simple code rendering obj
from __future__ import print_function
from paraview.simple import *
import sys
import vtk
if(len(sys.argv) < 3):
print('Usage: ', sys.argv[0], 'input.obj', 'output.png', '[camera.pvcc]')
reader = WavefrontOBJReader(FileName=sys.argv[1])
Show(reader)
from __future__ import print_function
import sys
import vtk
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(512,512)
reader = vtk.vtkOBJReader()
@1f0
1f0 / two-obj-to-one.py
Created June 2, 2018 03:19
merge two obj to one
import sys
if(len(sys.argv)!=4):
print('Usage: ', sys.argv[0], 'input1.obj input2.obj output.obj')
sys.exit()
import vtk
def read(f):
reader = vtk.vtkOBJReader()
@1f0
1f0 / js-array-dictionary-compare.js
Created July 6, 2018 09:23
After experiment, we find out that array access is even a little more efficient than reference access.
'use strict';
var dict = [];
var dict2 = {};
var i, j, t0, t1;
var ICNT = 1000;
var JCNT = 1000;
t0 = performance.now();
for (i = 0; i <= ICNT; i += 2) {
@1f0
1f0 / blob.js
Last active August 27, 2018 12:50
download anything use blob in console
content = JSON.stringify(SOMETHING);
blob = new Blob([content],{type:"octet/stream"});
url = window.URL.createObjectURL(blob);
console.log(url);