Skip to content

Instantly share code, notes, and snippets.

View agirault's full-sized avatar
👨‍💻

Alexis Girault agirault

👨‍💻
View GitHub Profile
//--------------------------------------------------------------------------
void qMRMLSubjectHierarchyTreeView::updateItemsSelectableFlag()
{
Q_D(qMRMLSubjectHierarchyTreeView);
if (!d->SubjectHierarchyNode)
{
return;
}
qMRMLSubjectHierarchyModel* sceneModel = qobject_cast<qMRMLSubjectHierarchyModel*>(this->model());
auto picker = vtkSmartPointer<vtkPropPicker>::New();
picker->Pick(screen_x, screen_y, 0, renderer);
// Check if pick is in bounds
vtkAssemblyPath* path = picker->GetPath();
bool validPick = false;
if (path) {
vtkCollectionSimpleIterator sit;
path->InitTraversal(sit);
vtkAssemblyNode *node;
@agirault
agirault / __git_status_flag.bash
Last active August 2, 2019 14:59
To put in your bash_rc
# git status with a dirty flag
function __git_status_flag {
git_status="$(git status 2> /dev/null)"
clean_pattern="working tree clean" # For macOS. For Linux: "working directory clean"
remote_pattern="Your branch is (.*)"
diverge_pattern="Your branch and (.*) have diverged"
if [[ ! ${git_status} =~ ${clean_pattern} ]]; then
state="⚡ "
fi
const char* objPath = ""; //orientation cube
const char* jpgPath = ""; //orientation texture
vtkRenderWindow* renderWindow = self.vtkView.renderWindow;
// Create & add the renderer
renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(0., 0., 0.);
renderer->SetViewport(0., 0., 1., 1.);
renderer->InteractiveOn();
renderWindow->AddRenderer(renderer);
@agirault
agirault / reslice_vtkDICOM.cpp
Last active August 31, 2017 20:36
Reslice vtkImageData from vtkDICOMReader using patient matrix
// Directory
const char *folderASCII = [folder cStringUsingEncoding:NSASCIIStringEncoding];
auto dicomDir = vtkSmartPointer<vtkDICOMDirectory>::New();
dicomDir->SetDirectoryName(folderASCII);
dicomDir->Update();
// Reader
auto reader = vtkSmartPointer<vtkDICOMReader>::New();
reader->SetFileNames(dicomDir->GetFileNamesForSeries(0));
//reader->SetMemoryRowOrderToFileNative();
@agirault
agirault / vtkOpenGLVertexBufferObject.cxx
Last active June 27, 2016 18:09
Create VBO to support multitextures. Write byte after byte
//-----------------------------------------------------------------------------
void vtkOpenGLVertexBufferObject::AddDataArray(vtkDataArray *data)
{
if (!this->VertexCount)
{
this->VertexCount = data->GetNumberOfTuples();
}
else if (VertexCount != data->GetNumberOfTuples())
{
vtkErrorMacro("AddDataArray() can not add array with a different number of "
#!/bin/bash
# Download MacOSX SDK and link them into XCode
# Make sure to update XCode beforehand (xcode-select --install)
mkdir SDKs
cd SDKs
git clone https://github.com/phracker/MacOSX-SDKs.git MacOSX.platform
cd ..
git clone https://gist.github.com/f213c737c0b2b581b13c.git
@agirault
agirault / add-sdks.py
Last active December 17, 2015 22:28
Links all your SDKs to XCode
#!/usr/bin/python
# add-sdks.py
# Rob Napier <robnapier@gmail.com>
# Alexis girault <alexis.girault@kitware.com>
# Script to link in all your old SDKs to Xcode
# Needs to be run every time you update Xcode
#
# 1. Create a directory and store the SDKs:
@agirault
agirault / exportScreenshot.cxx
Last active November 16, 2015 15:15
Example of vtkRenderWindow OffScreenRendering for Image export
// Enable OffScreen Rendering
renderWindow->OffScreenRenderingOn();
// Set renderWindow size
const int* windowSize = renderWindow->GetSize();
int W = windowSize[0];
int H = windowSize[1];
renderWindow->SetSize(d->exportWidthSpinBox->value(),d->exportHeightSpinBox->value());
// Get Image
@agirault
agirault / homography_screenreality
Created December 11, 2014 00:40
homography screenReality
//-- Matrix
float modelview[16];
float projection[16];
glGetFloatv (GL_MODELVIEW_MATRIX, modelview);
glGetFloatv (GL_PROJECTION_MATRIX, projection);
cv::Mat modelM(4,4,CV_32FC2,modelview);
cv::Mat projM(4,4,CV_32FC2,projection);
cv::Mat M = projM*modelM;
std::cout<<M<<std::endl;