本文整理汇总了C++中Vec函数的典型用法代码示例。如果您正苦于以下问题:C++ Vec函数的具体用法?C++ Vec怎么用?C++ Vec使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Vec
QColor
MeshGenerator::getVRLutColor(uchar *volData,
int dlen,
int depth, int nextra,
QVector3D pos,
QVector3D normal,
uchar *lut,
bool lookInside,
QVector3D globalPos)
{
// go a bit deeper and start
QVector3D vpos = pos + normal;
// -- find how far deep we can go
int nd = 0;
for(int n=0; n<=depth; n++)
{
int i = vpos.x();
int j = vpos.y();
int k = vpos.z();
if (i > m_nZ-1 || j > m_nY-1 || k > dlen+2*nextra-1 ||
i < 0 || j < 0 || k < 0) // gone out
break;
nd ++;
vpos += normal;
}
// now start collecting the samples
vpos = pos + normal;
QVector3D gpos = globalPos + normal;
Vec rgb = Vec(0,0,0);
float tota = 0;
for(int ns=0; ns<=nd; ns++)
{
int i = vpos.x();
int j = vpos.y();
int k = vpos.z();
i = qBound(0, i, m_nZ-1);
j = qBound(0, j, m_nY-1);
k = qBound(0, k, dlen+2*nextra-1);
Vec po0 = Vec(m_dataMin.x+gpos.x(), m_dataMin.y+gpos.y(), gpos.z());
Vec po = po0*m_samplingLevel;
bool ok=true;
if (ok)
{
ushort v, gr;
if (m_voxelType == 0)
{
v = volData[k*m_nY*m_nZ + j*m_nZ + i];
gr = 0;
}
else
{
v = ((ushort*)volData)[k*m_nY*m_nZ + j*m_nZ + i];
gr = v%256;
v = v/256;
}
// QMessageBox::information(0, "", QString("vrlut : %1 %2 %3 : %4").\
// arg(i).arg(j).arg(k).arg(v));
float a = lut[4*(256*gr + v)+3]/255.0f;
float r = lut[4*(256*gr + v)+0]*a;
float g = lut[4*(256*gr + v)+1]*a;
float b = lut[4*(256*gr + v)+2]*a;
if (m_blendPresent)
{
for(int ci=0; ci<m_crops.count(); ci++)
{
if (m_crops[ci].cropType() > CropObject::Displace_Displace &&
m_crops[ci].cropType() < CropObject::Glow_Ball)
{
float viewMix = m_crops[ci].checkBlend(po);
int tfSet = m_crops[ci].tfset();
tfSet *= 256*256*4;
float a1 = lut[tfSet+4*(256*gr + v)+3]/255.0f;
float r1 = lut[tfSet+4*(256*gr + v)+0]*a1;
float g1 = lut[tfSet+4*(256*gr + v)+1]*a1;
float b1 = lut[tfSet+4*(256*gr + v)+2]*a1;
r = (1-viewMix)*r + viewMix*r1;
g = (1-viewMix)*g + viewMix*g1;
b = (1-viewMix)*b + viewMix*b1;
a = (1-viewMix)*a + viewMix*a1;
}
}
}
if (m_pathBlendPresent)
{
for(int ci=0; ci<m_paths.count(); ci++)
{
if (m_paths[ci].blend())
{
//.........这里部分代码省略.........
示例2: Vec
inline Vec operator-(Vec u) { return Vec(x - u.x, y - u.y, z - u.z); }
示例3: Vec
Vec operator%(Vec&b){return Vec(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);}
示例4: StrassenDMM
var StrassenDMM(Var A,Var B,size_t m,size_t p,size_t n,size_t bound)//m为M行数,n为N列数,p为n行数,bound为递归下界
{
if(m<=bound||n<=bound||p<=bound)
return Matrix::Dot(A,B);
else
{
var A11=Take(A,1,m/2,1,p/2);
var A12=Take(A,1,m/2,p/2+1,p);
var A21=Take(A,m/2+1,m,1,p/2);
var A22=Take(A,m/2+1,m,p/2+1,p);
var B11=Take(B,1,p/2,1,n/2);
var B12=Take(B,1,p/2,n/2+1,n);
var B21=Take(B,p/2+1,p,1,n/2);
var B22=Take(B,p/2+1,p,n/2+1,n);
var S1=Matrix::Add(A21,A22);
var S2=Matrix::Sub(S1,A11);
var S3=Matrix::Sub(A11,A21);
var S4=Matrix::Sub(A12,S2);
var T1=Matrix::Sub(B12,B11);
var T2=Matrix::Sub(B22,T1);
var T3=Matrix::Sub(B22,B12);
var T4=Matrix::Sub(T2,B21);
var P1=Matrix::StrassenDMM(A11,B11,m/2,p/2,n/2,bound);
var P2=Matrix::StrassenDMM(A12,B21,m/2,p/2,n/2,bound);
var P3=Matrix::StrassenDMM(S4,B22,m/2,p/2,n/2,bound);
var P4=Matrix::StrassenDMM(A22,T4,m/2,p/2,n/2,bound);
var P5=Matrix::StrassenDMM(S1,T1,m/2,p/2,n/2,bound);
var P6=Matrix::StrassenDMM(S2,T2,m/2,p/2,n/2,bound);
var P7=Matrix::StrassenDMM(S3,T3,m/2,p/2,n/2,bound);
var U1=Matrix::Add(P1,P2);
var U2=Matrix::Add(P1,P6);
var U3=Matrix::Add(U2,P7);
var U4=Matrix::Add(U2,P5);
var U5=Matrix::Add(U4,P3);
var U6=Matrix::Sub(U3,P4);
var U7=Matrix::Add(U3,P5);
var r=Vec(m);
for (size_t i=0;i<m;++i)
{
var &c=At(r,i);
c=Vec(n);
}
for (size_t i=0;i<m/2;++i)
{
for (size_t j=0;j<n/2;++j)
{
Entry(r,i,j)=Entry(U1,i,j);
}
}
for (size_t i=0;i<m/2;++i)
{
for (size_t j=n/2;j<n;++j)
{
Entry(r,i,j)=Entry(U5,i,j-n/2);
}
}
for (size_t i=m/2;i<m;++i)
{
for (size_t j=0;j<n/2;++j)
{
Entry(r,i,j)=Entry(U6,i-m/2,j);
}
}
for (size_t i=m/2;i<m;++i)
{
for (size_t j=n/2;j<n;++j)
{
Entry(r,i,j)=Entry(U7,i-m/2,j-n/2);
}
}
return r;
}
}
示例5: radiance
enum Refl_t { DIFF, SPEC, REFR }; // material types, used in radiance()
struct Sphere {
double rad; // radius
Vec p, e, c; // position, emission, color
Refl_t refl; // reflection type (DIFFuse, SPECular, REFRactive)
Sphere(double rad_, Vec p_, Vec e_, Vec c_, Refl_t refl_):
rad(rad_), p(p_), e(e_), c(c_), refl(refl_) {}
double intersect(const Ray &r) const { // returns distance, 0 if nohit
Vec op = p-r.o; // Solve t^2*d.d + 2*t*(o-p).d + (o-p).(o-p)-R^2 = 0
double t, eps=1e-4, b=op.dot(r.d), det=b*b-op.dot(op)+rad*rad;
if (det<0) return 0; else det=sqrt(det);
return (t=b-det)>eps ? t : ((t=b+det)>eps ? t : 0);
}
};
Sphere spheres[] = {//Scene: radius, position, emission, color, material
Sphere(1e5, Vec( 1e5+1,40.8,81.6), Vec(),Vec(.75,.25,.25),DIFF),//Left
Sphere(1e5, Vec(-1e5+99,40.8,81.6),Vec(),Vec(.25,.25,.75),DIFF),//Rght
Sphere(1e5, Vec(50,40.8, 1e5), Vec(),Vec(.75,.75,.75),DIFF),//Back
Sphere(1e5, Vec(50,40.8,-1e5+170), Vec(),Vec(), DIFF),//Frnt
Sphere(1e5, Vec(50, 1e5, 81.6), Vec(),Vec(.75,.75,.75),DIFF),//Botm
Sphere(1e5, Vec(50,-1e5+81.6,81.6),Vec(),Vec(.75,.75,.75),DIFF),//Top
Sphere(16.5,Vec(27,16.5,47), Vec(),Vec(1,1,1)*.999, SPEC),//Mirr
Sphere(16.5,Vec(73,16.5,78), Vec(),Vec(1,1,1)*.999, REFR),//Glas
Sphere(600, Vec(50,681.6-.27,81.6),Vec(12,12,12), Vec(), DIFF) //Lite
};
inline double clamp(double x){ return x<0 ? 0 : x>1 ? 1 : x; }
inline int toInt(double x){ return int(pow(clamp(x),1/2.2)*255+.5); }
inline bool intersect(const Ray &r, double &t, int &id){
double n=sizeof(spheres)/sizeof(Sphere), d, inf=t=1e20;
for(int i=int(n);i--;) if((d=spheres[i].intersect(r))&&d<t){t=d;id=i;}
return t<inf;
示例6: main
int main(int argc, char *argv[]){
int w,h,samples;
double radius;
double xposition, yposition, zposition;
double xcolor, ycolor, zcolor;
double xemission,yemission,zemission;
int material;
//height and width of frame
scanf("%d %d",&w,&h);
//number of samples
scanf("%d",&samples);
for(int i=0;i<objects;++i){
scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %d",&radius,&xposition,&yposition,&zposition,&xcolor,&ycolor,&zcolor,&xemission,&yemission,&zemission,&material);
spheres[i].radius=radius;
spheres[i].position.x=xposition;
spheres[i].position.y=yposition;
spheres[i].position.z=zposition;
spheres[i].light.x=xemission;
spheres[i].light.y=yemission;
spheres[i].light.z=zemission;
spheres[i].object_color.x=xcolor;
spheres[i].object_color.y=ycolor;
spheres[i].object_color.z=zcolor;
spheres[i].type_of_reflection=material;
//printf("hi%lf\t %lf\t %lf\t %lf\t %lf\t %lf\t %lf\t %lf\t %lf\t %lf\t %d\n",radius,xposition,yposition,zposition,xcolor,ycolor,zcolor,xemission,yemission,zemission,material);
}
Vec camera_origin;
camera_origin.x=50;
camera_origin.y=52;
camera_origin.z=295.6;
Vec camera_direction;
camera_direction.x=0;
camera_direction.y=-0.042612;
camera_direction.z=-1;
Ray cam;
cam.origin =camera_origin;
cam.direction =norm(camera_direction);
Vec cx;
cx.x = w*0.5/h;
cx.y = 0;
cx.z = 0;
Vec cy=norm(cross(cx,cam.direction))*0.5;
Vec r;
Vec *image=new Vec[w*h];
for (int y=0; y<h; y++){
for (int x=0; x<w; x++) {
//if(x%10==0)
//fprintf(stderr,".");
int sy=0, i=(h-y-1)*w+x;
int sx=1;r=Vec();
for (int s=0; s<samples; s++){
Vec d = cx*( (0.75 + x)/w - .5) + cy*( ( 0.25 + y)/h - .5) + cam.direction;
Ray rr0;
rr0.origin = cam.origin+d*140;
rr0.direction = norm(d);
r = r + calculate_light(rr0,0)*(1./samples);
}
image[i].x = image[i].x + (normalize_0_1(r.x));
image[i].y = image[i].y + (normalize_0_1(r.y));
image[i].z = image[i].z + (normalize_0_1(r.z));
//not working properly so made the function normalize
double temp1;
if(r.x<0) temp1=0;
else if(r.x>1) temp1=1;
else temp1=r.x;
// image[i].x = image[i].x + temp1;
double temp2;
if(r.y<0) temp2=0;
else if(r.y>1) temp2=1;
else temp2=r.y;
// image[i].y = image[i].y + temp2;
double temp3;
if(r.z<0) temp3=0;
else if(r.z>1) temp3=1;
else temp3=r.z;
// image[i].z = image[i].z + temp3;
}
if(y%10==0)fprintf(stderr,".");
}
//print_image(c,w,h);
//estimate of maximum value of colour for normalization
double max = -999999999;
for(int i=0;i<w*h;++i){
if(image[i].x>max) max = image[i].x;
if(image[i].y>max) max = image[i].y;
if(image[i].z>max) max = image[i].z;
}
//find the normalization constant
//.........这里部分代码省略.........
示例7: CreateTimer
void Displacements::computeField(int gridSquareSize, int fitMethod, int lRotate, int rRotate)
{
CreateTimer(allTimer);
printf("\nComputing field for selection..\n");
// Get faces and points of selected part
Vector<int> selectedFaces = skeleton->getSelectedFaces(true);
StdList<Face*> meshFaces = stair.mostBaseMesh()->getFacesFromIndices(selectedFaces);
Vector<int> points = SET_TO_VECTOR(stair.mostBaseMesh()->getVerticesFromFaces(selectedFaces));
// Convert selected skeleton part into points in space
Vector<Vec> skeletonPoints = skeleton->getSelectedSkeletonPoints();
// Make sure we have a smooth and nicely sampled spine
while((int)skeletonPoints.size() < gridSquareSize)
{
skeleton->smoothSelectedEdges(4);
skeletonPoints = skeleton->getSelectedSkeletonPoints();
}
// Compute length by traveling spine
float gridLength = 0;
for(int i = 0; i < (int)skeletonPoints.size() - 1; i++)
gridLength += Vec(skeletonPoints[i] - skeletonPoints[i+1]).norm();
// Figure out maximum point on base surface to use as radius (there might be a faster way)
HistogramFloat histogram (1);
skeleton->sampleProjectPoints(0.75f, stair.mostBaseMesh(), points, &histogram);
float radius = histogram.Average();
if(radius <= 0.0f)
radius = stair.mostDetailedMesh()->radius * 0.1; // just in case...
CreateTimer(gridTimer);
// CREATE GRID
grid = Grid(skeletonPoints, radius, gridLength, gridSquareSize, &stair, meshFaces,lRotate, rRotate);
printf(".Grid time (%d ms).", (int)gridTimer.elapsed());
CreateTimer(fitTimer);
// FIT GRID
switch(fitMethod)
{
case 1: // Fit using cross sections
grid.FitCrossSections(); break;
case 2: // Fit cylinder
grid.FitCylinder( ); break;
default:
grid.FitNothing( ); break;
}
printf(".Fit time (%d ms).", (int)fitTimer.elapsed());
CreateTimer(gridifyTimer);
// Assign detailed mesh points into cylindrical grid cells
grid.Gridify( selectedFaces );
isReady = true;
printf(".total Gridify time = %d ms\n", (int)gridifyTimer.elapsed());
printf("\n\nField time = %d ms\n=======\n", (int)allTimer.elapsed());
}
示例8: Vec
void
ClipGrabber::mouseMoveEvent(QMouseEvent* const event,
Camera* const camera)
{
if (!m_pressed)
return;
QPoint delta = event->pos() - m_prevPos;
//Vec voxelScaling = Global::voxelScaling();
Vec voxelScaling = Vec(1,1,1);
Vec tang = m_tang;
Vec xaxis = m_xaxis;
Vec yaxis = m_yaxis;
if (event->buttons() != Qt::LeftButton)
{
tang = VECDIVIDE(tang, voxelScaling);
xaxis = VECDIVIDE(xaxis, voxelScaling);
yaxis = VECDIVIDE(yaxis, voxelScaling);
Vec trans(delta.x(), -delta.y(), 0.0f);
// Scale to fit the screen mouse displacement
trans *= 2.0 * tan(camera->fieldOfView()/2.0) *
fabs((camera->frame()->coordinatesOf(Vec(0,0,0))).z) /
camera->screenHeight();
// Transform to world coordinate system.
trans = camera->frame()->orientation().rotate(trans);
//Vec voxelScaling = Global::voxelScaling();
Vec voxelScaling = Vec(1,1,1);
trans = VECDIVIDE(trans, voxelScaling);
if (event->modifiers() & Qt::ControlModifier ||
event->modifiers() & Qt::MetaModifier)
{
if (moveAxis() < MoveY0)
{
float vx = trans*m_xaxis;
if (moveAxis() == MoveX0)
setScale1(scale1() + 0.05*vx);
else
setScale1(scale1() - 0.05*vx);
}
else if (moveAxis() < MoveZ)
{
float vy = trans*m_yaxis;
if (moveAxis() == MoveY0)
setScale2(scale2() + 0.05*vy);
else
setScale2(scale2() - 0.05*vy);
}
}
else
{
if (moveAxis() < MoveY0)
{
float vx = trans*xaxis;
trans = vx*xaxis;
}
else if (moveAxis() < MoveZ)
{
float vy = trans*yaxis;
trans = vy*yaxis;
}
else if (moveAxis() == MoveZ)
{
float vz = trans*tang;
trans = vz*tang;
}
translate(trans);
}
}
else
{
bool ctrlOn = (event->modifiers() & Qt::ControlModifier ||
event->modifiers() & Qt::MetaModifier);
if (moveAxis() == MoveZ && !ctrlOn)
{
Vec axis;
axis = (delta.y()*camera->rightVector() +
delta.x()*camera->upVector());
rotate(axis, qMax(qAbs(delta.x()), qAbs(delta.y())));
}
else
{
Vec axis;
if (moveAxis() < MoveY0) axis = xaxis;
else if (moveAxis() < MoveZ) axis = yaxis;
else axis = tang;
//Vec voxelScaling = Global::voxelScaling();
Vec voxelScaling = Vec(1,1,1);
Vec pos = VECPRODUCT(position(), voxelScaling);
//.........这里部分代码省略.........
示例9: a
void Constraint::drawTorsion()
{
Vec a(m_atoms[0]->getPosition());
Vec b(m_atoms[1]->getPosition());
Vec c(m_atoms[2]->getPosition());
Vec d(m_atoms[3]->getPosition());
Vec e(a+c-b);
Vec f(d+b-c);
GLShape::Tube(a, b, s_tubeRadius, s_tubeResolution);
GLShape::Tube(c, b, s_tubeRadius, s_tubeResolution);
GLShape::Tube(a, e, s_tubeRadius, s_tubeResolution);
GLShape::Tube(c, e, s_tubeRadius, s_tubeResolution);
GLShape::Tube(d, c, s_tubeRadius, s_tubeResolution);
GLShape::Tube(b, c, s_tubeRadius, s_tubeResolution);
GLShape::Tube(d, f, s_tubeRadius, s_tubeResolution);
GLShape::Tube(b, f, s_tubeRadius, s_tubeResolution);
GLShape::Sphere(e, s_tubeRadius, s_tubeResolution);
GLShape::Sphere(f, s_tubeRadius, s_tubeResolution);
Vec cb(c-b);
// Align the frame z-axis to the cb bond
Quaternion orientation(Vec(0.0,0.0,1.0), cb);
Frame frame(b+0.5*cb, orientation);
// Now determine the frame coordinates of a and
// rotate it so that it aligns with the frame y-axis
Vec fa(frame.coordinatesOf(a).unit());
frame.rotate(Quaternion(Vec(0.0,0.0,1.0), atan2(fa.y,fa.x)));
glPushMatrix();
glMultMatrixd(frame.matrix());
double radius(0.5);
double angle(Layer::Atom::torsion(m_atoms[0], m_atoms[1], m_atoms[2], m_atoms[3]));
angle = angle * M_PI / 180.0;
GLShape::Torus(radius, s_tubeRadius, s_tubeResolution, angle);
glPopMatrix();
glEnable(GL_BLEND);
glDisable(GL_LIGHTING);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4fv(m_color);
glBegin(GL_QUAD_STRIP);
glVertex3f(a.x, a.y, a.z);
glVertex3f(e.x, e.y, e.z);
glVertex3f(b.x, b.y, b.z);
glVertex3f(c.x, c.y, c.z);
glVertex3f(f.x, f.y, f.z);
glVertex3f(d.x, d.y, d.z);
glEnd();
/*
glBegin(GL_TRIANGLE_STRIP);
glVertex3f(a.x, a.y, a.z);
glVertex3f(c.x, c.y, c.z);
glVertex3f(b.x, b.y, b.z);
glVertex3f(d.x, d.y, d.z);
glEnd();
*/
glEnable(GL_LIGHTING);
glDisable(GL_BLEND);
}
示例10: Vec
WhiteBall::WhiteBall(const Point & pos) :Ball(pos, Vec(-0.1, -0.1, 0.0), BallGUI(wAmbient, wSpecular), false) {
textureInit();
}
示例11: AABBox
// Build KD tree for tris
void KDNode::build(std::vector<Triangle*> &tris, int depth){
leaf = false;
triangles = std::vector<Triangle*>();
left = NULL;
right = NULL;
box = AABBox();
if (tris.size() == 0) return;
if (depth > 25 || tris.size() <= 6) {
triangles = tris;
leaf = true;
box = tris[0]->get_bounding_box();
for (long i=1; i<tris.size(); i++) {
box.expand(tris[i]->get_bounding_box());
}
left = new KDNode();
right = new KDNode();
left->triangles = std::vector<Triangle*>();
right->triangles = std::vector<Triangle*>();
return;
}
box = tris[0]->get_bounding_box();
Vec midpt = Vec();
double tris_recp = 1.0/tris.size();
for (long i=1; i<tris.size(); i++) {
box.expand(tris[i]->get_bounding_box());
midpt = midpt + (tris[i]->get_midpoint() * tris_recp);
}
std::vector<Triangle*> left_tris;
std::vector<Triangle*> right_tris;
int axis = box.get_longest_axis();
for (long i=0; i<tris.size(); i++) {
switch (axis) {
case 0:
midpt.x >= tris[i]->get_midpoint().x ? right_tris.push_back(tris[i]) : left_tris.push_back(tris[i]);
break;
case 1:
midpt.y >= tris[i]->get_midpoint().y ? right_tris.push_back(tris[i]) : left_tris.push_back(tris[i]);
break;
case 2:
midpt.z >= tris[i]->get_midpoint().z ? right_tris.push_back(tris[i]) : left_tris.push_back(tris[i]);
break;
}
}
if (tris.size() == left_tris.size() || tris.size() == right_tris.size()) {
triangles = tris;
leaf = true;
box = tris[0]->get_bounding_box();
for (long i=1; i<tris.size(); i++) {
box.expand(tris[i]->get_bounding_box());
}
left = new KDNode();
right = new KDNode();
left->triangles = std::vector<Triangle*>();
right->triangles = std::vector<Triangle*>();
return;
}
left = new KDNode();
right = new KDNode();
left->build(left_tris, depth+1);
right->build(right_tris, depth+1);
return;
}
示例12: col
void
MeshGenerator::generateMesh(int nSlabs,
QStringList volumeFiles,
QString flnm,
int depth,
QGradientStops vstops,
int fillValue,
bool checkForMore,
bool lookInside,
Vec voxelScaling,
QList<Vec> clipPos,
QList<Vec> clipNormal,
QList<CropObject> crops,
QList<PathObject> paths,
uchar *lut,
int chan,
bool avgColor)
{
bool saveIntermediate = false;
int bpv = 1;
if (m_voxelType > 0) bpv = 2;
int nbytes = bpv*m_nY*m_nZ;
// if (nSlabs > 1)
// {
// QStringList sl;
// sl << "No";
// sl << "Yes";
// bool ok;
// QString okstr = QInputDialog::getItem(0, "Save slab files",
// "Save slab files in .ply format.\nFiles will not be collated together to create a unified mesh for the whole sample.",
// sl, 0, false, &ok);
// if (ok && okstr == "Yes")
// saveIntermediate = true;
// }
QGradientStops lutstops;
for(int i=0; i<255; i++)
{
QColor col(lut[4*i+0], lut[4*i+1], lut[4*i+2], lut[4*i+3]);
lutstops << QGradientStop((float)i/(float)255.0f, col);
}
bool trim = (qRound(m_dataSize.x) < m_height ||
qRound(m_dataSize.y) < m_width ||
qRound(m_dataSize.z) < m_depth);
bool clipPresent = (clipPos.count() > 0);
m_cropPresent = false;
m_tearPresent = false;
m_blendPresent = false;
for(int ci=0; ci<m_crops.count(); ci++)
{
if (crops[ci].cropType() < CropObject::Tear_Tear)
m_cropPresent = true;
else if (crops[ci].cropType() < CropObject::View_Tear)
m_tearPresent = true;
else if (m_crops[ci].cropType() > CropObject::Displace_Displace &&
m_crops[ci].cropType() < CropObject::Glow_Ball)
m_blendPresent = true;
}
m_pathCropPresent = false;
m_pathBlendPresent = false;
for (int i=0; i<m_paths.count(); i++)
{
if (m_paths[i].blend()) m_pathBlendPresent = true;
if (m_paths[i].crop()) m_pathCropPresent = true;
}
int nextra = depth;
int blockStep = m_nX/nSlabs;
//-----------------------------
int nvols = volumeFiles.count();
//-----------------------------
for (int volnum=0; volnum < nvols; volnum++)
{
//if (nvols > 1)
{
m_vfm->setBaseFilename(volumeFiles[volnum]);
uchar *vslice = m_vfm->getSlice(0);
}
m_meshLog->moveCursor(QTextCursor::End);
m_meshLog->insertPlainText(QString("\nProcessing file %1 of %2 : %3\n").\
arg(volnum+1).arg(nvols).arg(m_vfm->fileName()));
for (int nb=0; nb<nSlabs; nb++)
{
m_meshLog->moveCursor(QTextCursor::End);
m_meshLog->insertPlainText(QString(" Processing slab %1 of %2\n").arg(nb+1).arg(nSlabs));
int d0 = nb*blockStep;
int d1 = qMin(m_nX-1, (nb+1)*blockStep);
int dlen = d1-d0+1;
int d0z = d0 + qRound(m_dataMin.z);
//.........这里部分代码省略.........
示例13: GetVectorNonConst
/** Get a Vector in a particular column as a non-const
* Vector. This is fail if the column has currently only a
* non-const Vector stored. */
inline SmartPtr<Vector> GetVectorNonConst(Index i)
{
ObjectChanged();
return Vec(i);
}
示例14: onMouseDrag
void Interface :: onMouseDrag(){
// if (key.alt) enable(Mode::CamArb);
// if (key.caps) enable(Mode::CamTrack);
//
static Biv B;
static float nx;
static float ny;
static float tdx;
static float tdy;
static Rot ra = Rot::xy;
static Rot rb = Rot::xz;
static Rot rc = Rot::yz;
//relative top left (0.0 - .002 or so);
float dx = mouse.dx;
float dy = mouse.dy; //changed
//current position relative to top left (0.0 - 1.0)
float cx = mouse.pos[0];//mouse.xrel;
float cy = mouse.pos[1];//mouse.yrel;//changed
//Accumulated Movement
nx += dx; //+ or -?
ny += dy;
//Temporary Accumulated Movement
tdx = mouse.newClick ? 0 : tdx + dx; //+ or -?
tdy = mouse.newClick ? 0 : tdy + dy;
mouse.dragAccum = Vec(nx,ny,0); //total dvector since program launch
mouse.drag = Vec(tdx,tdy,0); //vector from last click and hold to current position
mouse.dragCat = Op::sp( mouse.drag, !scene().cat() ); //rotate drag by inverse concatenated orientation
mouse.dragBivCat = vd().z ^ mouse.dragCat;
mouse.dragBiv = Vec::z ^ mouse.drag; //( Vec ( nx, ny, 0 ) ); // nx*-1 ?
Vec v1 = mouse.pos;
Vec v2 = mouse.move;
Vec v = v1 - Vec(camera().pos());
Vec rel ( .5-cx, .5-cy, 0.0 );
Vec nn ( nx, ny, 0.0 );
mouse.newClick = 0;
int mdir = 0;
if ( fabs(tdx) > fabs(tdy) ) mdir = tdx > 0 ? MouseData::Right : MouseData::Left;
else if ( fabs(tdx) < fabs(tdy) ) mdir = tdy > 0 ? MouseData::Up : MouseData::Down;
mouse.gesture = mdir;
if (keyboard.alt) {
mouseModelTransform(1.0, true);
} else if (keyboard.shift) {
mouseCamTranslate(1.0, true);
} else if (keyboard.ctrl){
mouseCamSpin(1.0,true);
}
// //Camera Itself Does not Move Position, but glMatrices move via camera's rotor
// //i.e. in arb mode the camera orientation itself doesn't move, just the mvm underneath
// if (mMode & Mode::CamArb){
// Rot tr = Gen::rot( mouse.dragBiv );
// camera().mvm(tr); // or -tr?
// }
//
// //In Tilt Mode the Camera Rotates Up and Down, Left and Right
// if (mMode & Mode::CamTilt){
// Vec mv = GL::unproject(glv.mouse().x(), glv.mouse().y(), 0, camera());
// B = Biv(Vec::z ^ Vec(nx,ny,0));
// rb = Gen::rot_biv(B);
// }
//
// if (mMode & Mode::CamTrack){
// float xm = glv.mouse().dx() / scene().width();
// float ym = glv.mouse().dy() / scene().height();
// Vec dv = camera().x() * xm + camera().y() * ym;
// camera().pos() += dv;
// }
}
示例15: subset
Vec subset(int start, int end){
return Vec(ptr + start, end - start);
}