Skip to content

Instantly share code, notes, and snippets.

Avatar

Ibraheem Alhashim ialhashim

View GitHub Profile
View shine.css
@keyframes shine{
0% {background-position: top left;}
50% {background-position: top right;}
100% {
background-position: top right;
background: #e91e63;
-webkit-background-clip: text;
}
}
@ialhashim
ialhashim / DivergingColorMaps.hpp
Last active Dec 31, 2019
C++ code for a color map based on work by Kenneth Moreland
View DivergingColorMaps.hpp
// Color map based on work by Kenneth Moreland: http://www.sandia.gov/~kmorel/documents/ColorMaps/
#pragma once
#include <QVector> // or use std::vector
inline std::vector< std::vector<double> > makeColorMap()
{
QVector<int> colorArray;
colorArray <<59<<76<<192<<60<<78<<194<<61<<80<<195<<62<<81<<197<<
63<<83<<198<<64<<85<<200<<66<<87<<201<<67<<88<<203<<68<<90<<204<<
69<<92<<206<<70<<93<<207<<71<<95<<209<<73<<97<<210<<74<<99<<211<<
@ialhashim
ialhashim / LABP.hpp
Created Aug 29, 2015
Linear Angle Based Parameterization
View LABP.hpp
#pragma once
// Linear angle based parameterization SGP '07 - c++ code
// Based on code by Rhaleb Zayer
#include "SurfaceMeshModel.h"
#include "SurfaceMeshHelper.h"
using namespace SurfaceMesh;
#include <Eigen/Core>
View gist:f99ffdfaa60caeafc070
Query:
https://3dwarehouse.sketchup.com/search.html?q=chair
Extract subjectIDs
Then:
https://3dwarehouse.sketchup.com/warehouse/getbinary?subjectId=XXXXXXXX&subjectClass=entity&cache=1440704568191&name=skj
View DisjointStrings.hpp
struct DisjointStrings{
DisjointStrings(QVector < QPair<QString, QString> > pairings = QVector < QPair<QString, QString> >()){
if (pairings.empty()) return;
QSet<QString> all_nodes;
for (auto p : pairings) { all_nodes << p.first; all_nodes << p.second; }
DisjointSet U(all_nodes.size());
QMap < QString, int > node_idx;
QMap < int, QString > idx_node;
for (auto n : all_nodes) { node_idx[n] = node_idx.size(); idx_node[node_idx[n]] = n; }
View projectionOnSegment.h
// https://github.com/libigl/libigl/blob/master/include/igl/project_to_line.cpp
auto projectionOnSegment = [&](const Vector3 & p, const Vector3 & s, const Vector3 & d){
Real px = p[0], py = p[1], pz = p[2];
Real sx = s[0], sy = s[1], sz = s[2];
Real dx = d[0], dy = d[1], dz = d[2];
Real dms[3], smp[3];
dms[0] = dx-sx; dms[1] = dy-sy; dms[2] = dz-sz;
Real v_sqrlen = dms[0]*dms[0] + dms[1]*dms[1] + dms[2]*dms[2]; assert(v_sqrlen != 0);
smp[0] = sx-px; smp[1] = sy-py; smp[2] = sz-pz;
@ialhashim
ialhashim / voronoi.hpp
Last active Jun 8, 2020
Header-only C++ implementation to generate Voronoi diagrams (nice data structure)
View voronoi.hpp
// Source: https://github.com/samkusin/gamelabs/tree/master/voronoi
// with a bug fix (ennetws)
/* Usage:
using namespace cinekine;
...
voronoi::Sites sites;
for(int i = 0; i < 5; i++) sites.push_back(voronoi::Vertex(rand()*xBound/RAND_MAX,rand()*yBound/RAND_MAX));
...
voronoi::Graph graph = voronoi::build(std::move(sites), xBound, yBound);
...
@ialhashim
ialhashim / powercrust.h
Created Dec 26, 2014
Portable Powercrust in C++
View powercrust.h
// Portable version of powercrust, adapted from https://github.com/timhutton/vtkpowercrust
/*===================================================================================================
vtkPowerCrustSurfaceReconstruction algorithm reconstructs surfaces from unorganized point data.
Copyright (C) 2014 Arash Akbarinia, Tim Hutton, Bruce Lamond Dieter Pfeffer, Oliver Moss
====================================================================================================*/
/*
#include "CellArray.h"
@ialhashim
ialhashim / fitting3D.cpp
Created Nov 14, 2014
Fitting 3D points to a plane or a line
View fitting3D.cpp
template<class Vector3>
std::pair<Vector3, Vector3> best_plane_from_points(const std::vector<Vector3> & c)
{
// copy coordinates to matrix in Eigen format
size_t num_atoms = c.size();
Eigen::Matrix< Vector3::Scalar, Eigen::Dynamic, Eigen::Dynamic > coord(3, num_atoms);
for (size_t i = 0; i < num_atoms; ++i) coord.col(i) = c[i];
// calculate centroid
Vector3 centroid(coord.row(0).mean(), coord.row(1).mean(), coord.row(2).mean());
@ialhashim
ialhashim / fixVS.vs1
Last active Aug 29, 2015
Fixing Microsoft Visual Studio 2013 and Qt x64
View fixVS.vs1
# Install NuGet to run inside VS
# Get VC project files
$include = @("*.vcxproj","*.sln")
$projectFiles = gci . -recurse -force -include $include
foreach ($file in $projectFiles) {
(get-content $file) | % { $_ -creplace 'Win32', 'x64' } | set-content $file
(get-content $file) | % { $_ -creplace '%40QMAKE_SUBSYSTEM_SUFFIX%40', '' } | set-content $file
}