コード例 #1
0
ファイル: Support.cpp プロジェクト: xhy20070406/PDAL
void Support::registerFields(Stage& stage, Schema& schema, PointFormat format)
{
    std::ostringstream text;

    std::vector<pdal::Dimension> const& d = stage.getDefaultDimensions();

    Schema dimensions(d);

    schema.appendDimension(dimensions.getDimension("X", stage.getName()));
    schema.appendDimension(dimensions.getDimension("Y", stage.getName()));
    schema.appendDimension(dimensions.getDimension("Z", stage.getName()));

    schema.appendDimension(dimensions.getDimension("Intensity", stage.getName()));
    schema.appendDimension(dimensions.getDimension("ReturnNumber", stage.getName())); // 3 bits only
    schema.appendDimension(dimensions.getDimension("NumberOfReturns", stage.getName())); // 3 bits only
    schema.appendDimension(dimensions.getDimension("ScanDirectionFlag", stage.getName()));  // 1 bit only
    schema.appendDimension(dimensions.getDimension("EdgeOfFlightLine", stage.getName())); // 1 bit only

    schema.appendDimension(dimensions.getDimension("Classification", stage.getName()));
    schema.appendDimension(dimensions.getDimension("ScanAngleRank", stage.getName()));

    schema.appendDimension(dimensions.getDimension("UserData", stage.getName()));
    schema.appendDimension(dimensions.getDimension("PointSourceId", stage.getName()));

    if (hasTime(format))
    {
        schema.appendDimension(dimensions.getDimension("Time", stage.getName()));
    }

    if (hasColor(format))
    {
        schema.appendDimension(dimensions.getDimension("Red", stage.getName()));
        schema.appendDimension(dimensions.getDimension("Green", stage.getName()));
        schema.appendDimension(dimensions.getDimension("Blue", stage.getName()));
    }

    // if (hasWave(format))
    // {
    //
    //     schema.appendDimension(Dimension(DimensionId::Las_WavePacketDescriptorIndex));
    //     schema.appendDimension(Dimension(DimensionId::Las_WaveformDataOffset));
    //     schema.appendDimension(Dimension(DimensionId::Las_ReturnPointWaveformLocation));
    //     schema.appendDimension(Dimension(DimensionId::Las_WaveformXt));
    //     schema.appendDimension(Dimension(DimensionId::Las_WaveformYt));
    //     schema.appendDimension(Dimension(DimensionId::Las_WaveformZt));
    // }

    return;
}
コード例 #2
0
void CC3UniformlyEvolvingPointParticle::updateBeforeTransform( CC3NodeUpdatingVisitor* visitor )
{
	super::updateBeforeTransform( visitor );

	if( !isAlive() ) 
		return;
	
	GLfloat dt = visitor->getDeltaTime();
	
	if ( hasSize() )
		setSize( getSize() + (m_sizeVelocity * dt) );
	
	if ( hasColor() )
	{
		// We have to do the math on each component instead of using the color math functions
		// because the functions clamp prematurely, and we need negative values for the velocity.
		ccColor4F currColor = getColor4F();
		setColor4F( ccc4f(CLAMP(currColor.r + (m_colorVelocity.r * dt), 0.0f, 1.0f),
					CLAMP(currColor.g + (m_colorVelocity.g * dt), 0.0f, 1.0f),
					CLAMP(currColor.b + (m_colorVelocity.b * dt), 0.0f, 1.0f),
					CLAMP(currColor.a + (m_colorVelocity.a * dt), 0.0f, 1.0f)) 
		);
	}
}
コード例 #3
0
ファイル: Main.cpp プロジェクト: mly/BMW
void LabelRegions(sf::Image *src, sf::Image* dst, Blob* boundaries [], int* nBlob)
{
	int labels[BASE_SIZE];
	for(int i = 0; i < BASE_SIZE; i++)
		labels[i] = BASE_SIZE+1;
	
	int count = 1;
	int nred = 0;
	
	for (int i = 1; i < src->GetHeight(); i++) {
		for (int j = 1; j < src->GetWidth(); j++) {
			sf::Color r = src->GetPixel(j, i);
			if (hasColor(r)) {
				nred++;
				sf::Color left = dst->GetPixel(j-1, i);
				sf::Color up = dst->GetPixel(j, i-1);
				dst->SetPixel(j, i, left);
				if (up.r != 0) {
					if (dst->GetPixel(j,i).r == 0) {
						dst->SetPixel(j, i, up);
					} else {
						sf::Color color;
						color.r = blobUnion(labels, left.r, up.r);
						dst->SetPixel(j, i, color);
					}
				} else {
					if (dst->GetPixel(j,i).r == 0) {
						labels[count] = count;
						sf::Color color;
						color.r = count;
						dst->SetPixel(j,i, color);
						count++;
					}
				}
			}
		}
	}
	
	int remap [count];
	memset(remap,0,sizeof(remap));
	
	for(int i=1; i<count; i++){
		remap[labels[i]]=1;
	}
	
	*nBlob = 0;   
	int newcount = 1;
	for(int i=1; i<count; i++){
		if(remap[i]){
			remap[i] = newcount;
			(*nBlob) = newcount;
			newcount++;
		}
	}
	
	for(int i=1; i<count; i++){
		labels[i] = remap[labels[i]];
	}
	
	
	for (int i=1; i<count; i++){
		if (boundaries[labels[i]] == NULL){
			boundaries[labels[i]] = (Blob *)malloc(sizeof(Blob));
			boundaries[labels[i]]->numPoints = 0;
			boundaries[labels[i]]->points = NULL;
		}
	}

	for (int i = 1; i < dst->GetHeight()-1; i++) {
		for (int j = 1; j < dst->GetWidth()-1; j++) {
			sf::Color r = src->GetPixel(j, i);
			sf::Color left = dst->GetPixel(j-1, i);
			sf::Color right = dst->GetPixel(j+1, i);
			sf::Color up = dst->GetPixel(j, i-1);
			sf::Color down = dst->GetPixel(j, i+1);
			if(hasColor(r) && dst->GetPixel(j,i).r > 0){
				int label = labels[dst->GetPixel(j,i).r];
				// increment number of points in boundary
				boundaries[label]->numPoints++;
				
				if (!left.r||!right.r||!up.r||!down.r){
					BlobPoint* newpt = (BlobPoint*) malloc(sizeof(BlobPoint));
					
					// give destination correct label
					sf::Color color;
					color.r = label;
					dst->SetPixel(j,i,color);
					newpt->x = j;
					newpt->y = i;
					newpt->nextPoint = boundaries[label]->points;
					
					// add point to correct blob
					boundaries[label]->points = newpt;
				}
			}
		}
	} 
}
コード例 #4
0
 /** Get the color at the vertex. Call only if hasColor() returns true. */
 ColorRGBA const & getColor() const
 {
   debugAssertM(hasColor(), "DisplayMeshVertex: Vertex does not have a color");
   return *color;
 }
コード例 #5
0
ファイル: quantization.cpp プロジェクト: aigamedev/mapcrafter
RGBAPixel Octree::getColor() const {
	assert(hasColor());
	return rgba(red / reference, green / reference, blue / reference, alpha / reference);
}
コード例 #6
0
void ObscuranceMainThread::run()
{
    Q_ASSERT(m_volume);

    m_stopped = false;

    vtkVolumeRayCastMapper *mapper = vtkVolumeRayCastMapper::SafeDownCast(m_volume->GetMapper());
    vtkEncodedGradientEstimator *gradientEstimator = mapper->GetGradientEstimator();
    /// \TODO fent això aquí crec que va més ràpid, però s'hauria de comprovar i provar també amb l'Update()
    gradientEstimator->GetEncodedNormals();

    // Creem els threads
    /// \todo QThread::idealThreadCount() amb Qt >= 4.3
    int numberOfThreads = vtkMultiThreader::GetGlobalDefaultNumberOfThreads();
    QVector<ObscuranceThread*> threads(numberOfThreads);

    // Variables necessàries
    vtkImageData *image = mapper->GetInput();
    unsigned short *data = reinterpret_cast<unsigned short*>(image->GetPointData()->GetScalars()->GetVoidPointer(0));
    int dataSize = image->GetPointData()->GetScalars()->GetSize();
    int dimensions[3];
    image->GetDimensions(dimensions);
    vtkIdType vtkIncrements[3];
    image->GetIncrements(vtkIncrements);

    int increments[3];
    increments[0] = vtkIncrements[0];
    increments[1] = vtkIncrements[1];
    increments[2] = vtkIncrements[2];

    m_obscurance = new Obscurance(dataSize, hasColor(), m_doublePrecision);

    for (int i = 0; i < numberOfThreads; i++)
    {
        ObscuranceThread * thread = new ObscuranceThread(i, numberOfThreads, m_transferFunction);
        thread->setGradientEstimator(gradientEstimator);
        thread->setData(data, dataSize, dimensions, increments);
        thread->setObscuranceParameters(m_maximumDistance, m_function, m_variant, m_obscurance);
        thread->setSaliency(m_saliency, m_fxSaliencyA, m_fxSaliencyB, m_fxSaliencyLow, m_fxSaliencyHigh);
        threads[i] = thread;
    }

    // Estructures de dades reaprofitables
    QVector<Vector3> lineStarts;

    const QVector<Vector3> directions = getDirections();
    int nDirections = directions.size();

    // Iterem per les direccions
    for (int i = 0; i < nDirections && !m_stopped; i++)
    {
        const Vector3 &direction = directions.at(i);

        DEBUG_LOG(QString("Direcció %1: %2").arg(i).arg(direction.toString()));

        // Direcció dominant (0 = x, 1 = y, 2 = z)
        int dominant;
        Vector3 absDirection(qAbs(direction.x), qAbs(direction.y), qAbs(direction.z));
        if (absDirection.x >= absDirection.y)
        {
            if (absDirection.x >= absDirection.z)
            {
                dominant = 0;
            }
            else
            {
                dominant = 2;
            }
        }
        else
        {
            if (absDirection.y >= absDirection.z)
            {
                dominant = 1;
            }
            else
            {
                dominant = 2;
            }
        }

        // Vector per avançar
        Vector3 forward;
        switch (dominant)
        {
            case 0:
                forward = Vector3(direction.x, direction.y, direction.z);
                break;
            case 1:
                forward = Vector3(direction.y, direction.z, direction.x);
                break;
            case 2: 
                forward = Vector3(direction.z, direction.x, direction.y);
                break;
        }
        // La direcció x passa a ser 1 o -1
        forward /= qAbs(forward.x);
        DEBUG_LOG(QString("forward = ") + forward.toString());

        // Dimensions i increments segons la direcció dominant
        int x = dominant, y = (dominant + 1) % 3, z = (dominant + 2) % 3;
        int dimX = dimensions[x], dimY = dimensions[y], dimZ = dimensions[z];
        int incX = increments[x], incY = increments[y], incZ = increments[z];
        int sX = 1, sY = 1, sZ = 1;
        qptrdiff startDelta = 0;
        if (forward.x < 0.0)
        {
            startDelta += incX * (dimX - 1);
//             incX = -incX;
            forward.x = -forward.x;
            sX = -1;
        }
        if (forward.y < 0.0)
        {
            startDelta += incY * (dimY - 1);
//             incY = -incY;
            forward.y = -forward.y;
            sY = -1;
        }
        if (forward.z < 0.0)
        {
            startDelta += incZ * (dimZ - 1);
//             incZ = -incZ;
            forward.z = -forward.z;
            sZ = -1;
        }
        DEBUG_LOG(QString("forward = ") + forward.toString());
        // Ara els 3 components són positius

        // Llista dels vòxels que són començament de línia
        getLineStarts(lineStarts, dimX, dimY, dimZ, forward);

//         int incXYZ[3] = { incX, incY, incZ };
        int xyz[3] = { x, y, z };
        int sXYZ[3] = { sX, sY, sZ };

        // Iniciem els threads
        for (int j = 0; j < numberOfThreads; j++)
        {
            ObscuranceThread * thread = threads[j];
            thread->setPerDirectionParameters(direction, forward, xyz, sXYZ, lineStarts, startDelta);
            thread->start();
        }

        // Esperem que acabin els threads
        for (int j = 0; j < numberOfThreads; j++)
        {
            threads[j]->wait();
        }

        emit progress(100 * (i + 1) / nDirections);
    }

    // Destruïm els threads
    for (int j = 0; j < numberOfThreads; j++)
    {
        delete threads[j];
    }
    // Si han cancel·lat el procés ja podem plegar
    if (m_stopped)
    {
        emit progress(0);
        delete m_obscurance; m_obscurance = 0;
        return;
    }

    m_obscurance->normalize();

    emit computed();
}
コード例 #7
0
bool ObscuranceMainThread::hasColor() const
{
    return hasColor(m_variant);
}
コード例 #8
0
ccColor4B CC3PointParticle::getColor4B()
{
	return hasColor() ? m_pEmitter->getVertexColor4BAt(m_particleIndex) : super::getColor4B(); 
}