예제 #1
0
/**
Returns a pointer the first object.
*/
QObject* GCF::ObjectIterator::firstObject() const
{
    // Start with the first component.
    bool success = firstComponent();
    if(!success)
        return 0;

    // Keeping looking until an object is found.
    while(d->componentIndex < d->components.count() && !d->current.object)
        nextObject();

    return d->current.object;
}
예제 #2
0
		void Image3D<T>::atBilinear(const double x, const double y, const double z, T *color)const{
			// 4 concerned pixels on floor(z)
			double x1 = floor(x);
			double y1 = floor(y);
			int    x2 = std::min((int)x1+1, (int)imageWidth-1);
			int    y2 = std::min((int)y1+1, (int)imageHeight-1);
			double z1 = floor(z);

			// default : border is black
			std::vector<T> black(imageNbChannel);
			std::fill(black.begin(),black.end(),T(0));
			T *color1  = &(black[0]);
			T *color2  = &(black[0]);
			T *color3  = &(black[0]);
			T *color4  = &(black[0]);
			
			// colors
			color1 = this->at((int)x1,(int)y1,(int)z1);
			color2 = this->at((int)x1,y2,(int)z1);
			color3 = this->at(x2,y2,(int)z1);
			color4 = this->at(x2,(int)y1,(int)z1);
			  
			// first component
			std::vector<T> firstComponent(imageNbChannel);
			for(unsigned int c=0; c<imageNbChannel; ++c)
			    firstComponent[c] = (T)(((x-x1)*color4[c] + (1.0-(x-x1))*color1[c]) * (1.0-(y-y1)) +
			                            ((x-x1)*color3[c] + (1.0-(x-x1))*color2[c]) * (y-y1));
			                            			                   	                   
			// 4 concerned pixels on floor(z)+1
			int z2 = std::min((int)z1+1, (int)imageDepth-1);
			color1  = &(black[0]);
			color2  = &(black[0]);
			color3  = &(black[0]);
			color4  = &(black[0]);			                  
			
			// colors
			color1 = this->at((int)x1,(int)y1,(int)z2);
			color2 = this->at((int)x1,y2,(int)z2);
			color3 = this->at(x2,y2,(int)z2);
			color4 = this->at(x2,(int)y1,(int)z2);			
			
    		// second component
	    	std::vector<T> secondComponent(imageNbChannel);
			for(unsigned int c=0; c<imageNbChannel; ++c)
			    secondComponent[c] = (T)(((x-x1)*color4[c] + (1.0-(x-x1))*color1[c]) * (1.0-(y-y1)) +
			                             ((x-x1)*color3[c] + (1.0-(x-x1))*color2[c]) * (y-y1));
			
			// final color 
		    for(unsigned int c=0; c<imageNbChannel; ++c)
			    color[c] = (1-(z-z1))*firstComponent[c] + (z-z1)*secondComponent[c];			
		}