#include "loft.h" namespace other{ double p_len(Array& p){ double l=0; int n = (int)p.size(); for(int i=n-1, j=0; j& p, const int start, const int stride){ double l=0; int n = (int)start+stride; for(int i=n-1, j=start; j& r){ double l=0; int n = (int)r.size(); for(int i=0; i > loft_tris(Array p1, Array p2){ int n = p1.size(); int m = p2.size(); double s = p_len(p1)/p_len(p2); Array > tris(n+m,false); double d=0.; int i=0; int j=0; while(i s*v2){ tris[i+j].set(i,(j+1)%m + n, j+n); j++; d=d - s*v2; } else{ tris[i+j].set(i, (i+1)%n, (j+1)%m + n); tris[i+j+1].set(i, (j+1)%m + n, j+n); i++; j++; } } tris[i+j].set((i compute_loft(Array p1, Array p2){ return new_(loft_tris(p1,p2)); } //compute lofts on an array with stride st, connecting last to first const Ref compute_lofts_circ(Array p, const int st, bool align){ int n = p.size(); Array > tris(2*n,false); int m = n/st; for(int l=0; l p1(st,false); Array p2(st,false); int offset = 0; if(align){ real dist = std::numeric_limits::max(); for(int i=0; i >& temp = loft_tris(p1,p2); for(int i=0; i<2*st; ++i){ int x = (temp[i].x+st*l)%n; int y = (temp[i].y+st*l)%n; int z = (temp[i].z+st*l)%n; tris[i+l*2*st].set(x,y,z); } } return new_(tris); } //compute the rail mesh, assuming the vertices are {p1,p2} const Ref compute_rail(Array r1, Array r2){ int n = r1.size(); int m = r2.size(); double s = r_len(r1)/r_len(r2); Array > tris(n+m-2,false); double d=0.; int i=0; int j=0; while(i s*v2){ tris[i+j].set(i,j+1+n, j+n); j++; d=d - s*v2; } else{ tris[i+j].set(i, i+1, j+1+n); tris[i+j+1].set(i, j+1+n, j+n); i++; j++; } } tris[i+j].set((i(tris); } } using namespace other; void wrap_loft() { OTHER_FUNCTION(compute_loft) OTHER_FUNCTION(compute_lofts_circ) OTHER_FUNCTION(compute_rail) }