Skip to content

Instantly share code, notes, and snippets.

View obj_export.cpp
std::ofstream aFile ( "Mesh.obj" );
for (int i = 0; i < aMesh->numVertices(); ++i) {
aFile << "v " << aMesh->vertices()[i].x() << " "
<< aMesh->vertices()[i].y() << " "
<< aMesh->vertices()[i].z() << std::endl;
}
for (int i = 0; i < aMesh->numVertices(); ++i) {
aFile << "vn " << aMesh->normals()[i].x() << " "
View WriteMesh.cpp
void BRepMesh_RestoreOrientationTool::WriteMesh (const std::string& theFileName)
{
// write obj file
std::ofstream myfile;
myfile.open (theFileName);
const Handle(BRepMesh_TriangulatedPatch)& aPatch = myPatches.back();
for (int i = 0; i < aPatch->Vertices.size(); ++i) {
BVH_Vec3d aVert = aPatch->Vertices[i];
@hb3p8
hb3p8 / ColoredTable.cpp
Created Dec 14, 2015
Colored table output win
View ColoredTable.cpp
HANDLE hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
const int aDefaultColor = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
auto printTable = [&](const std::set<Standard_Integer>& theRemSet) {
return; // disabled
std::cout << setw (3) << " ";
for (int j = 0; j < aTableSize; ++j) {
std::cout << setw (6) << j;
}
View ocl_framework.cpp
typedef double real;
typedef Eigen::Vector2d vec2;
typedef Eigen::Vector2i int2;
typedef Eigen::Vector4i int4;
vec2 mix (vec2 a, vec2 b, real c) {
return (a + b) * c;
}
@hb3p8
hb3p8 / Slerp
Created Mar 11, 2015
Spherical linear interpolation between unit quaternions q1 and q2 with interpolation parameter t.
View Slerp
// Spherical linear interpolation between unit quaternions q1 and q2 with interpolation parameter t.
Quaternion slerp(Quaternion q1, Quaternion q2, float t)
{
float w1, x1, y1, z1, w2, x2, y2, z2, w3, x3, y3, z3;
Quaternion q2New;
float theta, mult1, mult2;
w1 = q1.getW(); x1 = q1.getX(); y1 = q1.getY(); z1 = q1.getZ();
w2 = q2.getW(); x2 = q2.getX(); y2 = q2.getY(); z2 = q2.getZ();
View OCCT codestyle (AStyle)
{
// NOTE: You should always edit options in user file, not this file.
// Print debug message
"debug": false,
// Auto format on file save
"autoformat_on_save": false,
// The mapping key is `syntax name`, and the value is `formatting mode`.
View PrintPretty
// =======================================================================
// function : PrintPretty
// purpose :
// =======================================================================
void RayTraceGPU_Node::PrintPretty (std::string thePrefix, bool isLeft, int theLevel) const
{
if (IsLeaf())
{
thePrefix.erase(thePrefix.size() - 2, 2);
thePrefix += isLeft ? "|-" : "\xC0-";
View traverse opt
ivec4 ObjectNearestHit (in int theBVHOffset, in int theVrtOffset, in int theTrgOffset,
in SRay theRay, in vec3 theInverse, inout SIntersect theHit, in int theSentinel)
{
int aHead = theSentinel; // stack pointer
int aNode = 0; // node to visit
ivec4 aTriIndex = INALID_HIT;
float aTimeOut;
float aTimeLft;