Skip to content

Instantly share code, notes, and snippets.

View mhogg's full-sized avatar

Michael Hogg mhogg

  • Sydney, Australia
View GitHub Profile
# Ref: https://github.com/Beastmaster/itk-python-example/blob/master/vtkSlidebar.py
# Ref: https://kitware.github.io/vtk-examples/site/Cxx/Widgets/Slider/
import vtk
sphereSource = vtk.vtkSphereSource()
sphereSource.SetCenter(0.0,0.0,0.0)
sphereSource.SetRadius(4.0)
sphereSource.Update()
import numpy as np
import vtkmodules.all as vtk
from vtkmodules.util import numpy_support as nps
from vtkmodules.vtkCommonCore import vtkCommand
class InteractorStyleDrawPolygon(vtk.vtkInteractorStyle):
"""
InteractorStyleDrawPolygon is a re-write of the vtk class of the same name in python.
# Using QThreads in PyQt5 using worker model
# There is so many conflicting posts on how QThreads should be used in pyqt. I had
# been subclassing QThread, overriding the run function, and calling start to run
# the thread. I did it this way, because I couldn't get the worker method (where
# an object is moved to a thread using moveToThread) to do what I wanted. It turns
# out that I just didn't understand why. But, once I worked it out I have stuck with
# the moveToThread method, as this is recommended by the official docs.
#
# The key part for me to understand was that when I am running a heavy calculation in
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mhogg
mhogg / plotting_QThread.py
Last active March 8, 2023 09:37
How to use QThreads in pyqt
# Code to show two plots of simulated streamed data. Data for each plot is processed (generated)
# by separate threads, and passed back to the gui thread for plotting.
# This is an example of using movetothread, which is the correct way of using QThreads
# Michael Hogg, 2015
import time, sys
from pyqtgraph.Qt import QtGui, QtCore
from PyQt4.Qt import QMutex
import pyqtgraph as pg
@mhogg
mhogg / eConn2.py
Created March 18, 2015 10:44
Gets element face connectivity
import os
root = r'D:\temp'
m = mdb.models['Model-1']
a = m.rootAssembly
p = m.parts['Part-1']
elements = p.elements
foutName = 'eConn2.txt'
npFace = 3 # Number of nodes per face. If using C3D4 elems, this will be 3
@mhogg
mhogg / elementConnectivity.py
Created March 17, 2015 05:42
Getting ABAQUS element connectivities
from abaqus import *
from abaqusConstants import *
from odbAccess import *
odb = session.viewports[session.currentViewportName].displayedObject
instName = 'MALE'
elements = odb.rootAssembly.instances[instName].elements
foutName = 'elementConnectivity.txt'