Esempio n. 1
0
void TestDim::index() {
	Dim sca;
	Dim row2(Dim::row_vec(2));
	Dim row3(Dim::row_vec(3));
	Dim col2(Dim::col_vec(2));
	Dim col3(Dim::col_vec(3));
	Dim mat22(Dim::matrix(2,2));
	Dim mat32(Dim::matrix(3,2));
	Dim mat23(Dim::matrix(2,3));
	Dim mat33(Dim::matrix(3,3));

	CPPUNIT_ASSERT      (sca.index_dim(DoubleIndex::one_elt(sca,0,0))==sca);

	CPPUNIT_ASSERT      (row3.index_dim(DoubleIndex::one_elt(row3,0,0))==sca);
	CPPUNIT_ASSERT      (row3.index_dim(DoubleIndex::one_row(row3,0))==row3);
	CPPUNIT_ASSERT      (row3.index_dim(DoubleIndex::cols(row3,0,1))==row2);

	CPPUNIT_ASSERT      (col3.index_dim(DoubleIndex::one_elt(col3,0,0))==sca);
	CPPUNIT_ASSERT      (col3.index_dim(DoubleIndex::one_col(col3,0))==col3);
	CPPUNIT_ASSERT      (col3.index_dim(DoubleIndex::rows(col3,0,1))==col2);

	CPPUNIT_ASSERT      (mat23.index_dim(DoubleIndex::one_elt(mat23,0,0))==sca);
	CPPUNIT_ASSERT      (mat23.index_dim(DoubleIndex::one_row(mat23,0))==row3);
	CPPUNIT_ASSERT      (mat23.index_dim(DoubleIndex::one_col(mat23,0))==col2);
	CPPUNIT_ASSERT      (mat23.index_dim(DoubleIndex::cols(mat23,0,1))==mat22);
	CPPUNIT_ASSERT      (mat23.index_dim(DoubleIndex::subrow(mat23,0,0,1))==row2);
	CPPUNIT_ASSERT      (mat23.index_dim(DoubleIndex::all(mat23))==mat23);

	CPPUNIT_ASSERT      (mat32.index_dim(DoubleIndex::subcol(mat32,0,1,0))==col2);

	CPPUNIT_ASSERT      (mat33.index_dim(DoubleIndex::rows(mat33,0,1))==mat23);
	CPPUNIT_ASSERT      (mat33.index_dim(DoubleIndex::cols(mat33,0,1))==mat32);
}
Esempio n. 2
0
void FibreReader<DIM>::GetAllOrtho(std::vector< c_vector<double, DIM> >& first_direction,
                                   std::vector< c_vector<double, DIM> >& second_direction,
                                   std::vector< c_vector<double, DIM> >& third_direction)
{
    assert(first_direction.empty());
    assert(second_direction.empty());
    assert(third_direction.empty());
    if (mNumItemsPerLine != DIM*DIM)
    {
        EXCEPTION("Use GetAllAxi when reading axisymmetric fibres");
    }
    for (unsigned i=0; i<mNumLinesOfData; i++)
    {
        c_matrix<double, DIM, DIM> temp_matrix;
        GetFibreSheetAndNormalMatrix(i, temp_matrix, true);

        //Note that although the matrix appears row-wise in the ascii .ortho file,
        //for convenience it is stored column-wise.
        matrix_column<c_matrix<double, DIM, DIM> > col0(temp_matrix, 0);
        first_direction.push_back(col0);
        if (DIM>=2)
        {
            matrix_column<c_matrix<double, DIM, DIM> > col1(temp_matrix, 1);
            second_direction.push_back(col1);
        }
        if (DIM==3)
        {
            matrix_column<c_matrix<double, DIM, DIM> > col2(temp_matrix, 2);
            third_direction.push_back(col2);
        }
    }
}
TEST(PaletteTranslator, BuildSortLuminance)
{
	//uint32 y = r * 299 + g * 587 + b * 114;

	Color col0(0, 0, 10);
	Color col1(0, 0, 11);
	Color col2(10, 0, 0);
	Color col3(11, 0, 0);
	Color col4(0, 10, 0);
	Color col5(0, 11, 0);

	Palette pal;
	pal.m_count = 6;
	pal[0] = col3;
	pal[1] = col5;
	pal[2] = col1;
	pal[3] = col2;
	pal[4] = col4;
	pal[5] = col0;

	Palette exp;
	exp.m_count = 6;
	exp[0] = col0;
	exp[1] = col1;
	exp[2] = col2;
	exp[3] = col3;
	exp[4] = col4;
	exp[5] = col5;

	PaletteTranslator pt;
	pt.BuildSortLuminance(pal, nullptr);

	ASSERT_TRUE( pal == exp );
}
Esempio n. 4
0
Matrix4 Matrix4::multiply(Matrix4 a)
{
    Matrix4 b;
  /*
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			b.m[i][j] = m[0][j] * a.m[i][0] + m[1][j] * a.m[i][1] + m[2][j] * a.m[i][2] + m[3][j] * a.m[i][3];
		}
	}*/
	Vector4 row1(m[0][0], m[1][0], m[2][0], m[3][0]);
	Vector4 row2(m[0][1], m[1][1], m[2][1], m[3][1]);
	Vector4 row3(m[0][2], m[1][2], m[2][2], m[3][2]);
	Vector4 row4(m[0][3], m[1][3], m[2][3], m[3][3]);

	Vector4 col1(a.m[0][0], a.m[0][1], a.m[0][2], a.m[0][3]);
	Vector4 col2(a.m[1][0], a.m[1][1], a.m[1][2], a.m[1][3]);
	Vector4 col3(a.m[2][0], a.m[2][1], a.m[2][2], a.m[2][3]);
	Vector4 col4(a.m[3][0], a.m[3][1], a.m[3][2], a.m[3][3]);

	b.set(row1.dot(col1), row2.dot(col1), row3.dot(col1), row4.dot(col1),
		row1.dot(col2), row2.dot(col2), row3.dot(col2), row4.dot(col2),
		row1.dot(col3), row2.dot(col3), row3.dot(col3), row4.dot(col3),
		row1.dot(col4), row2.dot(col4), row3.dot(col4), row4.dot(col4));

    return b;
}
Esempio n. 5
0
BOOST_AUTO_TEST_CASE_TEMPLATE(create, T, float_types) {
	// default constructor
	vmath::core::Matrix<T, 3, 2> M_default;
	BOOST_CHECK_SMALL(M_default[0][0], static_cast<T>(1e-7));
	BOOST_CHECK_SMALL(M_default[0][1], static_cast<T>(1e-7));
	BOOST_CHECK_SMALL(M_default[0][2], static_cast<T>(1e-7));
	BOOST_CHECK_SMALL(M_default[1][0], static_cast<T>(1e-7));
	BOOST_CHECK_SMALL(M_default[1][1], static_cast<T>(1e-7));
	BOOST_CHECK_SMALL(M_default[1][2], static_cast<T>(1e-7));
	// parameterized constructor
	std::array<vmath::core::Vector<T, 3>, 2> data = {{
			vmath::core::Vector<T, 3>(static_cast<T>(1.0), static_cast<T>(2.0), static_cast<T>(3.0)),
			vmath::core::Vector<T, 3>(static_cast<T>(4.0), static_cast<T>(5.0), static_cast<T>(6.0))
		}};
	vmath::core::Matrix<T, 3, 2> M_param(data);
	BOOST_CHECK_CLOSE(M_param[0][0], static_cast<T>(1.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_param[0][1], static_cast<T>(2.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_param[0][2], static_cast<T>(3.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_param[1][0], static_cast<T>(4.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_param[1][1], static_cast<T>(5.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_param[1][2], static_cast<T>(6.0), 1e-4f);
	// parameterized constructor
	vmath::core::Vector<T, 3> col1(static_cast<T>(1.0), static_cast<T>(2.0), static_cast<T>(3.0));
	vmath::core::Vector<T, 3> col2(static_cast<T>(4.0), static_cast<T>(5.0), static_cast<T>(6.0));
	vmath::core::Matrix<T, 3, 2> M_param2(col1, col2);
	BOOST_CHECK_CLOSE(M_param2[0][0], static_cast<T>(1.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_param2[0][1], static_cast<T>(2.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_param2[0][2], static_cast<T>(3.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_param2[1][0], static_cast<T>(4.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_param2[1][1], static_cast<T>(5.0), 1e-4f);
	BOOST_CHECK_CLOSE(M_param2[1][2], static_cast<T>(6.0), 1e-4f);
}
Esempio n. 6
0
void ScreenAlignedText::tessellate(void)
{

	//cout << "ScreenAlignedText::tessellate called" << endl;

	if( _mfText.empty() )
		return;
	Text fontText;

	//SFSharedFontStylePtr *psfsp = getSFFont();
	//SFSharedFontStyleWrapperPtr *wrapperPtr = getSFFont();
	SharedFontStyleWrapperPtr wrapperPtr = getFont();
		   
	//SFSharedFontStylePtr psfsp = wrapperPtr->getSFFStyleContainer();

	//SharedFontStylePtr psfs = psfsp->getValue();
	SharedFontStylePtr psfs = wrapperPtr->getFStyleContainer();

	if( psfs == NullFC )
	{
		cerr << "ScreenAlignedText::tessellate:  psfs = NullFC ! " << endl;
		return;
	}
	FontStyleP pFS = psfs->getContainedFontStyle();
	if( pFS == NULL )
	{		
		cerr << "ScreenAlignedText::tessellate:  pFS = NULL ! " << endl;
		return;
	}

    fontText.setFontStyle( pFS );
    fontText.setJustifyMajor(MIDDLE_JT);

	// Colors are changed during rendering, 
	// but are needed for 
	// calling the fillImage routine
    Color4ub    col1( 255, 255, 255, 255);
    Color4ub    col2( 0, 0, 0, 0 );
	ImagePtr pImg = Image::create();

	std::vector<std::string> lineVec;

	for(unsigned int i = 0; i < _mfText.size(); i++ )
	{
		lineVec.push_back( _mfText[i] );
	}

	vector<NodePtr> cNodes;

    if(fontText.fillImage(pImg, lineVec, &col1, &col2,
						  false, 0, 0, SET_TEX_TCM, CLEAR_ADD_MM, 1, true ) )
    {	
		_sfRenderImage.setValue( pImg );
	}

	// cout << "ScreenAlignedText::tessellate(void)" << endl;
}
Esempio n. 7
0
void WriteBMP::rayIncr(vec3* colorVec, vec3* rayPos, vec3 rayToIncr, float* T, float k, float rayLength) {
	*Q = 1.0f;
	*Q2 = 1.0f;
	int ind = WriteBMP::getVoxelIndex(rayPos);
	if (ind == -1) {
		if (*entered || length(*eye - *rayPos) > rayLength) {
			*colorVec += *T * *bgColor;
			return;
		}
		*dens = 0.0f;
	} else {
		*entered = true;
		Voxel vox = allVoxels[ind];
		*dens = *vox.density;
		vec3 lidir;
		vec3* ldir;
		if (*vox.lightVal == -1 && *dens != 0.0f) {
			lrPos->x = lightPos->x;
			lrPos->y = lightPos->y;
			lrPos->z = lightPos->z;
			lidir = normalize(*rayPos - *lightPos);
			ldir = new vec3(lidir.x, lidir.y, lidir.z);
			*ldir *= *stepSize;
			lightMarch(lightPos, lrPos, ldir, Q, length(*lightPos - *rayPos), 0.5f);
			*vox.lightVal = *Q;
		} else {
			*Q = *vox.lightVal;
		}
		if (*vox.lightVal2 == -1 && *dens != 0.0f) {
			lidir = normalize(*rayPos - *lightPos2);
			ldir = new vec3(lidir.x, lidir.y, lidir.z);
			*ldir *= *stepSize;
			
			lrPos->x = lightPos2->x;
			lrPos->y = lightPos2->y;
			lrPos->z = lightPos2->z;
			
			lightMarch(lightPos2, lrPos, ldir, Q2, length(*lightPos2 - *rayPos), 0.5f);
			*vox.lightVal2 = *Q2;
		} else {
			*Q2 = *vox.lightVal2;
		}
	}
	vec3 col(lightCol->x * matColor->x, lightCol->y * matColor->y, lightCol->z * matColor->z);
	vec3 col2(lightCol2->x * matColor->x, lightCol2->y * matColor->y, lightCol2->z * matColor->z);
	float dT = exp(-1.0f * k * *stepSize * *dens);
	*T *= dT;
	*rayPos += rayToIncr;
	*colorVec += ((1 - dT)/k) * *T * col * *Q;
	*colorVec += ((1 - dT)/k) * *T * col2 * *Q2;
	*colorVec = clamp(*colorVec, 0.0f, 1.0f);
	if (*T < 0.01) {
		*colorVec += *T * *bgColor;
		return;
	}
	rayIncr(colorVec, rayPos, rayToIncr, T, k, rayLength);
}
Esempio n. 8
0
/**
 * Decomposes matrix M such that T * R * S = M, where T is translation matrix,
 * R is rotation matrix and S is scaling matrix.
 * http://code.google.com/p/assimp-net/source/browse/trunk/AssimpNet/Matrix4x4.cs
 * (this method is exact to at least 0.0001f)
 *
 * | 1  0  0  T1 | | R11 R12 R13 0 | | a 0 0 0 |   | aR11 bR12 cR13 T1 |
 * | 0  1  0  T2 |.| R21 R22 R23 0 |.| 0 b 0 0 | = | aR21 bR22 cR23 T2 |
 * | 0  0  0  T3 | | R31 R32 R33 0 | | 0 0 c 0 |   | aR31 bR32 cR33 T3 |
 * | 0  0  0   1 | |  0   0   0  1 | | 0 0 0 1 |   |  0    0    0    1 |
 *
 * @param m (in) matrix to decompose
 * @param scaling (out) scaling vector
 * @param rotation (out) rotation matrix
 * @param translation (out) translation vector
 */
void decomposeTRS(const glm::mat4& m, glm::vec3& translation, glm::mat4& rotation, glm::vec3& scaling)
{
    // Extract the translation
    translation.x = m[3][0];
    translation.y = m[3][1];
    translation.z = m[3][2];

    // Extract col vectors of the matrix
    glm::vec3 col1(m[0][0], m[0][1], m[0][2]);
    glm::vec3 col2(m[1][0], m[1][1], m[1][2]);
    glm::vec3 col3(m[2][0], m[2][1], m[2][2]);

    //Extract the scaling factors
    scaling.x = glm::length(col1);
    scaling.y = glm::length(col2);
    scaling.z = glm::length(col3);

    // Handle negative scaling
    if (glm::determinant(m) < 0) {
        scaling.x = -scaling.x;
        scaling.y = -scaling.y;
        scaling.z = -scaling.z;
    }

    // Remove scaling from the matrix
    if (scaling.x != 0) {
        col1 /= scaling.x;
    }

    if (scaling.y != 0) {
        col2 /= scaling.y;
    }

    if (scaling.z != 0) {
        col3 /= scaling.z;
    }

    rotation[0][0] = col1.x;
    rotation[0][1] = col1.y;
    rotation[0][2] = col1.z;
    rotation[0][3] = 0.0;

    rotation[1][0] = col2.x;
    rotation[1][1] = col2.y;
    rotation[1][2] = col2.z;
    rotation[1][3] = 0.0;

    rotation[2][0] = col3.x;
    rotation[2][1] = col3.y;
    rotation[2][2] = col3.z;
    rotation[2][3] = 0.0;

    rotation[3][0] = 0.0;
    rotation[3][1] = 0.0;
    rotation[3][2] = 0.0;
    rotation[3][3] = 1.0;
}
Esempio n. 9
0
int main()
{
	zdb::Database database(L"test");
	zdb::DbColumn col1(L"lalka1", DbDataType::Int32);
	zdb::DbColumn col2(L"lalka2", DbDataType::Int64);
	zdb::DbColumn col3(L"lalka3", DbDataType::Int8);
	std::vector<zdb::DbColumn> columns = { col1, col2, col3 };
	database.AddTable(L"testTable", columns);
	return 0;
}
Esempio n. 10
0
/* GLTexture::bgTex
 * Returns the global chequered 'background' texture
 *******************************************************************/
GLTexture& GLTexture::bgTex() {
	if (!tex_background.isLoaded()) {
		wxColour col1(bgtx_colour1);
		wxColour col2(bgtx_colour2);
		tex_background.genChequeredTexture(8,
			rgba_t(col1.Red(), col1.Green(), col1.Blue(), 255),
			rgba_t(col2.Red(), col2.Green(), col2.Blue(), 255));
	}
	return tex_background;
}
Esempio n. 11
0
void CGpApp::DrawEnergyBar()
{
	LC_RECTF	rc1(0,0,  (FLOAT)INT(1.5F * ENERGYBARmax), 16);
	LC_RECTF	rc2(0,0,  (FLOAT)INT(1.5F * ENERGYBARmax * m_ShieldEnergy / SHIELDENERGYmax), 16);
	LCXVECTOR2	vcTrn(0, m_nScnH - 20.0F);
	LCXCOLOR	col2(1,0,0,0.7F);
	LCXCOLOR	col1(0,0,1,0.7F);

	m_pSpt->DrawEx(NULL, &rc1, &vcTrn, NULL, NULL, 0, &col1);
	m_pSpt->Draw(NULL, &rc2, &vcTrn, &col2);
}
Esempio n. 12
0
//-------------------------------------------------------------------------------
// @ IvRenderer::SetWorldMatrix()
//-------------------------------------------------------------------------------
// Sets the world matrix for the renderer
//-------------------------------------------------------------------------------
void IvRenderer::SetWorldMatrix(const IvMatrix44& matrix)
{
    mWorldMat = matrix;
    mWVPMat = mProjectionMat*mViewMat*mWorldMat;
    IvMatrix33 worldMat3x3;
    IvVector3 col0(mWorldMat(0,0), mWorldMat(1,0), mWorldMat(2,0));
    IvVector3 col1(mWorldMat(0,1), mWorldMat(1,1), mWorldMat(2,1));
    IvVector3 col2(mWorldMat(0,2), mWorldMat(1,2), mWorldMat(2,2));
    worldMat3x3.SetColumns(col0, col1, col2);
    mNormalMat.Rotation(Transpose(Inverse(worldMat3x3)));
}
Esempio n. 13
0
LOCAL_C void CreateTable()
	{
	CDbColSet *cs=CDbColSet::NewLC();
	TDbCol col1(KColumnInt,EDbColInt32);
	col1.iAttributes=TDbCol::ENotNull;
	cs->AddL(col1);
	TDbCol col2(KColumnText,EDbColText,200/sizeof(TText));
	col2.iAttributes=TDbCol::ENotNull;
	cs->AddL(col2);
	test(TheDatabase.CreateTable(KTableName,*cs)==KErrNone);
	CleanupStack::PopAndDestroy();
	}
Esempio n. 14
0
void
ColumnMajorMatrixTest::ThreeColConstructor()
{
  VectorValue<Real> col1( 1, 2, 3 );
  VectorValue<Real> col2( 4, 5, 6 );
  VectorValue<Real> col3( 7, 8, 9 );

  ColumnMajorMatrix test( col1, col2, col3 );

  CPPUNIT_ASSERT( test == *a );
  CPPUNIT_ASSERT( test.numEntries() == 9 );
}
Esempio n. 15
0
    // extract frustum plane in world space.
    // the normals facing inward.
    // pass in view * projection matrix.
    void Frustum::InitFromMatrix(const Matrix &VP)
    {

        // near and far plane corners
        static float3 verts[8] =
        {
            // near plane corners
            float3( -1, -1,0 ),
            float3( 1, -1,0 ),
            float3( 1, 1,0 ),
            float3( -1, 1 ,0),

            // far plane corners.
            float3( -1, -1 ,1),
            float3( 1,  -1,1 ),
            float3( 1,  1,1 ),
            float3( -1, 1,1 )
        };

        this->m_matrix = VP;

        float4 col0(VP(0,0), VP(1,0), VP(2,0), VP(3,0));
        float4 col1(VP(0,1), VP(1,1), VP(2,1), VP(3,1));
        float4 col2(VP(0,2), VP(1,2), VP(2,2), VP(3,2));
        float4 col3(VP(0,3), VP(1,3), VP(2,3), VP(3,3));

        
        // Planes face inward.
        m_planes[Near]   = Plane(col2);        // near
        m_planes[Far]    = Plane(col3 - col2); // far
        m_planes[Left]   = Plane(col3 + col0); // left
        m_planes[Right]  = Plane(col3 - col0); // right
        m_planes[Top]    = Plane(col3 - col1); // top
        m_planes[Bottom] = Plane(col3 + col1); // bottom

        // normalize all six planes
        for(int i = 0; i < 6; i++)
        {
            m_planes[i].Normalize();
        }


        // tranform eight corner from device coordiate to world coordinate.
        Matrix invVP = VP;
        invVP.Invert();
        for(int i = 0; i < 8; i++)
        {
            this->m_corners[i] = float3::Transform(verts[i],invVP);
        }
    }
Esempio n. 16
0
void wxZEdit::EndPanel()
{
    wxCaptionBarStyle style;
    wxColour col1(193,208,233), col2(49,106,197);
    style.SetFirstColour(col1);
    style.SetSecondColour(col2);
    style.SetCaptionStyle(wxCAPTIONBAR_FILLED_RECTANGLE);
    m_pnl->ApplyCaptionStyleAll(style);

    // ask for a resize
    wxSizeEvent mevent( GetSize()+wxSize(1,1), GetId() );
    mevent.SetEventObject( this );
    ProcessEvent( mevent );

}
Esempio n. 17
0
void door(void) {
    initLeds();
    col1();
    col4();
    col7();
    _delay_ms(200);
    col1();
    col5();
    col9();
    _delay_ms(200);
    col1();
    col2();
    col3();
    _delay_ms(200);
}
Esempio n. 18
0
void PaletteGrid::mouseMoveEvent(QMouseEvent* event)
{
    VoxelFile* voxel = window->get_voxel();
    if (!voxel)
        return;
    if (!(event->buttons() & Qt::LeftButton))
        return;
     if ((event->pos() - drag_start).manhattanLength() < QApplication::startDragDistance())
         return;
    QDrag* drag = new QDrag(this);
    QMimeData* mimeData = new QMimeData;
    RGBColor& col = global_palette[palette_index];
    QColor col2(col.r, col.g, col.b);
    mimeData->setColorData(col2);
    drag->setMimeData(mimeData);
    //Qt::DropAction dropAction = drag->exec(Qt::CopyAction);
}
Esempio n. 19
0
void IrrDriver::renderLightsScatter(unsigned pointlightcount)
{
    getFBO(FBO_HALF1).Bind();
    glClearColor(0., 0., 0., 0.);
    glClear(GL_COLOR_BUFFER_BIT);

    const Track * const track = World::getWorld()->getTrack();

    // This function is only called once per frame - thus no need for setters.
    float start = track->getFogStart() + .001;
    const video::SColor tmpcol = track->getFogColor();

    core::vector3df col(tmpcol.getRed() / 255.0f,
        tmpcol.getGreen() / 255.0f,
        tmpcol.getBlue() / 255.0f);

    glDisable(GL_DEPTH_TEST);
    glDepthMask(GL_FALSE);
    glEnable(GL_BLEND);
    glBlendEquation(GL_FUNC_ADD);
    glBlendFunc(GL_ONE, GL_ONE);

    FullScreenShader::FogShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
    DrawFullScreenEffect<FullScreenShader::FogShader>(1.f / (40.f * start), col);

    glEnable(GL_DEPTH_TEST);
    core::vector3df col2(1., 1., 1.);

    glUseProgram(LightShader::PointLightScatterShader::getInstance()->Program);
    glBindVertexArray(LightShader::PointLightScatterShader::getInstance()->vao);

    LightShader::PointLightScatterShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
    LightShader::PointLightScatterShader::getInstance()->setUniforms(1.f / (40.f * start), col2);

    glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, MIN2(pointlightcount, MAXLIGHT));

    glDisable(GL_BLEND);
    m_post_processing->renderGaussian6Blur(getFBO(FBO_HALF1), getFBO(FBO_HALF2), 5., 5.);
    glEnable(GL_BLEND);

    glDisable(GL_DEPTH_TEST);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    getFBO(FBO_COLORS).Bind();
    m_post_processing->renderPassThrough(getRenderTargetTexture(RTT_HALF1));
}
Esempio n. 20
0
//==============================================================================
void DebugDrawer::drawGrid()
{
	Vec4 col0(0.5, 0.5, 0.5, 1.0);
	Vec4 col1(0.0, 0.0, 1.0, 1.0);
	Vec4 col2(1.0, 0.0, 0.0, 1.0);

	const F32 SPACE = 1.0; // space between lines
	const U NUM = 57;  // lines number. must be odd

	const F32 GRID_HALF_SIZE = ((NUM - 1) * SPACE / 2);

	setColor(col0);

	begin(GL_LINES);

	for(U x = - NUM / 2 * SPACE; x < NUM / 2 * SPACE; x += SPACE)
	{
		setColor(col0);

		// if the middle line then change color
		if(x == 0)
		{
			setColor(col1);
		}

		// line in z
		pushBackVertex(Vec3(x, 0.0, -GRID_HALF_SIZE));
		pushBackVertex(Vec3(x, 0.0, GRID_HALF_SIZE));

		// if middle line change col so you can highlight the x-axis
		if(x == 0)
		{
			setColor(col2);
		}

		// line in the x
		pushBackVertex(Vec3(-GRID_HALF_SIZE, 0.0, x));
		pushBackVertex(Vec3(GRID_HALF_SIZE, 0.0, x));
	}

	// render
	end();
}
Esempio n. 21
0
void Camera::buildFrustumPlanes()
{
	D3DXMATRIX VP = m_view * m_proj;

	D3DXVECTOR4 col0(VP(0, 0), VP(1, 0), VP(2, 0), VP(3, 0));
	D3DXVECTOR4 col1(VP(0, 1), VP(1, 1), VP(2, 1), VP(3, 1));
	D3DXVECTOR4 col2(VP(0, 2), VP(1, 2), VP(2, 2), VP(3, 2));
	D3DXVECTOR4 col3(VP(0, 3), VP(1, 3), VP(2, 3), VP(3, 3));

	// Planes face inward.
	mFrustumPlanes[0] = (D3DXPLANE)(col2);        // near
	mFrustumPlanes[1] = (D3DXPLANE)(col3 - col2); // far
	mFrustumPlanes[2] = (D3DXPLANE)(col3 + col0); // left
	mFrustumPlanes[3] = (D3DXPLANE)(col3 - col0); // right
	mFrustumPlanes[4] = (D3DXPLANE)(col3 - col1); // top
	mFrustumPlanes[5] = (D3DXPLANE)(col3 + col1); // bottom

	for (int i = 0; i < 6; i++)
		D3DXPlaneNormalize(&mFrustumPlanes[i], &mFrustumPlanes[i]);
}
void SqlBackendTest::collections()
{
	Collection col( "Article" );
	Article *article;
	CollectionIterator it( col.begin() );
	CollectionIterator end( col.end() );
	for ( ; it != end; ++it ) {
		article = static_cast<Article*>( *it );
		// As long as we don't have a way to sort collections, we won't be
		// able to make this test nicer
		if ( article->label() != "Article One"  && article->label() != "Article Two" ) {
			CHECK( true, false );
		}
	}
	
	ObjectRef<Customer> c1 = Customer::create();
	c1->setCustomerName( "foo" );
	ObjectRef<Customer> c2 = Customer::create();
	c2->setCustomerName( "bar" );

	ObjectRef<Article> a1 = Article::create();
	a1->setLabel( "foo" );
	a1->setDescription( "liluli foo liluli" );
	ObjectRef<CustomerOrder> o1 = CustomerOrder::create();
	o1->setNumber( 3000 );
	o1->setCustomer( c1 );
	o1->articles()->add( a1 );
	Manager::self()->commit();

	Collection col2( "SELECT Customer.* WHERE Customer.Customer_CustomerOrder.Article_CustomerOrder.description like '%foo%'" );
	Customer *customer;
	CollectionIterator it2( col2.begin() );
	CollectionIterator end2( col2.end() );
	CHECK( col2.begin() == col2.end(), false );
	for ( ; it2 != end2; ++it2 ) {
		customer = static_cast<Customer*>( *it2 );
		// As long as we don't have a way to sort collections, we won't be
		// able to make this test nicer
		CHECK( customer->customerName(), QString( "foo" ) );
	}
}
Esempio n. 23
0
bool CopyArrayOperator::
SplitDisconnectedUnit( DepCompCopyArrayCollect& collect,
                        DepCompCopyArrayCollect::CopyArrayUnit& unit,
                        DepCompAstRefGraphCreate& refDep,
                       DepCompCopyArrayCollect::CopyArrayUnit::NodeSet& cuts)
{
  assert(unit.refs.size() > 0);
  DepCompCopyArrayCollect::CopyArrayUnit::InsideGraph insidegraph(&refDep,unit);
  const DepCompAstRefGraphNode* cur = *unit.refs.begin();

  GraphGetNodeReachable<DepCompCopyArrayCollect::CopyArrayUnit::InsideGraph, 
                        AppendPtrSet<const DepCompAstRefGraphNode> > op;
  DepCompCopyArrayCollect::CopyArrayUnit::NodeSet innodes;
  AppendPtrSet<const DepCompAstRefGraphNode> col1(innodes), col2(cuts);
  op(&insidegraph, cur, GraphAccess::EdgeIn,col1); 
  for (DepCompCopyArrayCollect::CopyArrayUnit::NodeSet::const_iterator p1 = innodes.begin();
       !p1.ReachEnd(); ++p1) {
     op(&insidegraph, (*p1), GraphAccess::EdgeOut,col2); 
  }
  cuts |= innodes;
  return cuts.size() < unit.refs.size();
}
Esempio n. 24
0
	TextureManager::TextureManager()
	{
		sf::Image textureimage;
		textureimage.create(32, 32, sf::Color(255, 0, 0));

		sf::Color col1(254, 254, 234);
		sf::Color col2(0, 72, 180);

		for(int i = 0; i < 32; ++i)
		{
			for(int j = i * 0.5; j < 32 - (i * 0.5); ++j) {
				textureimage.setPixel(i, j, col1);
			}
		}

		for(int i = 0; i < 32; ++i) {
			textureimage.setPixel(31, i, col2);
			textureimage.setPixel(i, 31, col2);
		}

		fallbacktexture = new sf::Texture();
		fallbacktexture->loadFromImage(textureimage);
	}
TEST(PaletteTranslator, BuildDuplicatedColors)
{
	Color col0(11, 12, 13);
	Color col1(14, 15, 16);
	Color col2(20, 21, 22, 0);
	Color col3(11, 12, 13);
	Color col4(30, 31, 32, 0);

	Palette pal;
	pal.m_count = 5;
	pal[0] = col0;
	pal[1] = col1;
	pal[2] = col2;
	pal[3] = col3;
	pal[4] = col4;

	Palette exp;
	exp.m_count = 3;
	exp[0] = col0;
	exp[1] = col1;
	exp[2] = col2;

	uint32 colCounts[256] = { 1, 10, 100, 1000, 10000 };
	uint32 expectedColCounts[256] = { 1001, 10, 10100, 0, 0 };

	PaletteTranslator pt;
	pt.BuildDuplicatedColors(pal, colCounts);
	ASSERT_TRUE( pal == exp );
	ASSERT_TRUE( memcmp(colCounts, expectedColCounts, sizeof(colCounts)) == 0 );

	uint8 pixels[] = { 0, 1, 2, 3, 4 };
	const uint8 expectedPixels[] = { 0, 1, 2, 0, 2 };
	
	pt.Translate(pixels, sizeof(pixels));
	
	ASSERT_TRUE( memcmp(pixels, expectedPixels, sizeof(pixels)) == 0 );
}
Esempio n. 26
0
void TestDim::vec() {
	Dim sca;
	Dim row2(Dim::row_vec(2));
	Dim row3(Dim::row_vec(3));
	Dim col2(Dim::col_vec(2));
	Dim col3(Dim::col_vec(3));
	Dim mat22(Dim::matrix(2,2));
	Dim mat32(Dim::matrix(3,2));
	Dim mat23(Dim::matrix(2,3));
	Dim mat33(Dim::matrix(3,3));

	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(sca),true)==sca);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(sca),false)==sca);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(sca,sca),true)==row2);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(sca,sca),false)==col2);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(sca,sca,sca),true)==row3);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(sca,sca,sca),false)==col3);

	CPPUNIT_ASSERT_THROW(vec_dim(Array<const Dim>(sca,col2),true),DimException);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(sca,col2),false)==col3);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(sca,row2),true)==row3);
	CPPUNIT_ASSERT_THROW(vec_dim(Array<const Dim>(sca,row2),false),DimException);
	CPPUNIT_ASSERT_THROW(vec_dim(Array<const Dim>(sca,mat22),true),DimException);
	CPPUNIT_ASSERT_THROW(vec_dim(Array<const Dim>(sca,mat22),false),DimException);

	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(col2),true)==col2);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(col2),false)==col2);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(col2,col2),true)==mat22);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(col2,col2),false)==Dim::col_vec(4));
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(col2,col2,col2),true)==mat23);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(col2,col2,col2),false)==Dim::col_vec(6));
	CPPUNIT_ASSERT_THROW(vec_dim(Array<const Dim>(col2,row2),true),DimException);
	CPPUNIT_ASSERT_THROW(vec_dim(Array<const Dim>(col2,row2),false),DimException);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(col2,mat22),true)==mat23);
	CPPUNIT_ASSERT_THROW(vec_dim(Array<const Dim>(col2,mat22),false),DimException);
	CPPUNIT_ASSERT      (vec_dim(Array<const Dim>(col2,mat22,col2),true)==Dim::matrix(2,4));
}
Esempio n. 27
0
int Lua_Color_Equal(LuaPlus::LuaState *lua)
{
	LuaPlus::LuaStack args(lua);
	float a[2]={0}, r[2]={0}, g[2]={0}, b[2]={0};

	if (args.Count()==2)
	{
		for (int i=0; i<2; i++)
		{
			if (args[i+1].IsTable())
			{
				if (args[i+1]["a"].IsNumber()) a[i]=args[i+1]["a"].GetFloat();
				if (args[i+1]["r"].IsNumber()) r[i]=args[i+1]["r"].GetFloat();
				if (args[i+1]["g"].IsNumber()) g[i]=args[i+1]["g"].GetFloat();
				if (args[i+1]["b"].IsNumber()) b[i]=args[i+1]["b"].GetFloat();
			}
		}
	}

	RUGE::CColor col1(a[0], r[0], g[0], b[0]), col2(a[1], r[1], g[1], b[1]);

	lua->PushBoolean(col1==col2 ? true : false);
	return 1;
}
Esempio n. 28
0
void KNDdeTorusCollocation::init(const KNVector& sol, const KNVector& par)
{
  double* t1 = new double[NTAU+1];
  double* t2 = new double[NTAU+1];
  for (size_t i2 = 0; i2 < nint2; i2++)
  {
    for (size_t i1 = 0; i1 < nint1; i1++)
    {
      for (size_t j2 = 0; j2 < ndeg2; j2++)
      {
        for (size_t j1 = 0; j1 < ndeg1; j1++)
        {
          const size_t idx = idxmap(j1, j2, i1, i2); // this is a unique

          time1(idx) = ((double)i1 + col1(j1)) / nint1;
          time2(idx) = ((double)i2 + col2(j2)) / nint2;
        }
      }
    }
  }

  sys->p_tau(p_tau, time1, par);

  p_xx.clear();
  for (size_t idx = 0; idx < time1.size(); ++idx)
  {
    t1[0] = time1(idx);
    t2[0] = time2(idx);
    for (size_t k = 0; k < NTAU; k++)
    {
      t1[1+k] = (t1[0] - p_tau(k,idx) / par(0)) - floor(t1[0] - p_tau(k,idx) / par(0));
      t2[1+k] = (t2[0] - par(RHO) * p_tau(k,idx) / par(0)) - floor(t2[0] - par(RHO) * p_tau(k,idx) / par(0));
    }

    for (size_t k = 0; k < NTAU + 1; k++)
    {
      size_t i1 = static_cast<size_t>(floor(nint1 * t1[k]));
      size_t i2 = static_cast<size_t>(floor(nint2 * t2[k]));
      // some error checking
      if ((t1[k] > 1.0) || (t2[k] > 1.0) ||
          (t1[k] < 0.0) || (t2[k] < 0.0)) std::cout << "Er ";
      if ((i1 >= nint1) || (i2 >= nint2)) std::cout << "Ei ";
      // end error checking
      for (size_t j2 = 0; j2 < ndeg2 + 1; j2++)
      {
        for (size_t j1 = 0; j1 < ndeg1 + 1; j1++)
        {
          const size_t idxKK = idxkk(j1, j2, k);
          kk(idxKK,idx) = idxmap(j1, j2, i1, i2);
          ee(idxKK,idx) = idxKK;
        }
      }
    }

    // sorting
    comp aa(kk.pointer(0,idx));
    std::sort(ee.pointer(0,idx), ee.pointer(0,idx) + (NTAU + 1)*(ndeg1 + 1)*(ndeg2 + 1), aa);

    // filtering same indices
    rr(ee(0,idx),idx) = 0;
    size_t nz = 0;
    for (size_t i = 1; i < (NTAU + 1)*(ndeg1 + 1)*(ndeg2 + 1); i++)
    {
      if (kk(ee(i-1,idx),idx) != kk(ee(i,idx),idx)) nz++;
      rr(ee(i,idx),idx) = nz;
    }

    // interpolate the solution
    for (size_t k = 1; k < NTAU + 1; k++)
    {
      const double c1 = nint1 * t1[k] - floor(nint1 * t1[k]);
      const double c2 = nint2 * t2[k] - floor(nint2 * t2[k]);
      for (size_t j2 = 0; j2 < ndeg2 + 1; j2++)
      {
        for (size_t j1 = 0; j1 < ndeg1 + 1; j1++)
        {
          const size_t idxKK = idxkk(j1, j2, k);
          const double cf = poly_lgr_eval(mesh1, j1, c1) * poly_lgr_eval(mesh2, j2, c2);
          for (size_t p = 0; p < NDIM; p++)
          {
            p_xx(p, k - 1, idx) += cf * sol(p + NDIM * kk(idxKK, idx));
          }
        }
      }
    }
    // derivatives at all delays
    for (size_t k = 0; k < NTAU + 1; k++)
    {
      const double c1 = nint1 * t1[k] - floor(nint1 * t1[k]);
      const double c2 = nint2 * t2[k] - floor(nint2 * t2[k]);
      for (size_t j2 = 0; j2 < ndeg2 + 1; j2++)
      {
        for (size_t j1 = 0; j1 < ndeg1 + 1; j1++)
        {
          const size_t idxKK = idxkk(j1, j2, k);
          const double cf1 = poly_dlg_eval(mesh1, j1, c1) * nint1 * poly_lgr_eval(mesh2, j2, c2);
          const double cf2 = poly_lgr_eval(mesh1, j1, c1) * poly_dlg_eval(mesh2, j2, c2) * nint2;
          for (size_t p = 0; p < NDIM; p++)
          {
            p_xx(p, NTAU + 2*k, idx)   += cf1 * sol(p + NDIM * kk(idxKK, idx));
            p_xx(p, NTAU + 2*k + 1, idx) += cf2 * sol(p + NDIM * kk(idxKK, idx));
          }
        }
      }
    }
  }
//   for (int idx = 0; idx < time1.size(); ++idx) std::cout<<p_xx(0, NTAU, idx)<<"\t";
//   std::cout<<"\np_xx(0,...) was\n";
  delete[] t2;
  delete[] t1;
}
Esempio n. 29
0
void    GLUI_Translation::draw_2d_arrow( int radius, int filled, int orientation )
{
  float x1 = .2, x2 = .4, y1 = .54, y2 = .94, y0;
  float x1a, x1b;
  vec3  col1( 0.0, 0.0, 0.0 ), col2( .45, .45, .45 ), 
    col3( .7, .7, .7 ), col4( 1.0, 1.0, 1.0 );
  vec3  c1, c2, c3, c4, c5, c6;
  vec3  white(1.0,1.0,1.0), black(0.0,0.0,0.0), gray(.45,.45,.45), 
    bkgd(.7,.7,.7);
  int   c_off; /* color index offset */

  if ( glui )
    bkgd.set(glui->bkgd_color_f[0],
	     glui->bkgd_color_f[1],
	     glui->bkgd_color_f[2]);

  /*	bkgd[0] = 255.0; bkgd[1] = 0;              */

  /** The following 8 colors define the shading of an octagon, in
    clockwise order, starting from the upstroke on the left  **/
  /** This is for an outside and inside octagons **/
  vec3 colors_out[]={white, white, white, gray, black, black, black, gray};
  vec3 colors_in[] ={bkgd,white,bkgd,gray,gray,gray,gray,gray};

#define SET_COL_OUT(i) glColor3fv((float*) &colors_out[(i)%8][0]);
#define SET_COL_IN(i) glColor3fv((float*) &colors_in[(i)%8][0]);

  x1 = (float)radius * .2;
  x2 = x1 * 2;
  y1 = (float)radius * .54;
  y2 = y1 + x2;
  x1a = x1;
  x1b = x1;

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();

#define DRAW_SEG( xa,ya,xb,yb ) glVertex2f(xa,ya); glVertex2f(xb,yb);

  glScalef( -1.0, 1.0, 1.0 );
	
  if ( orientation == 2 ) {
    c_off = 4;
  }
  else if ( orientation == 0 ) {
    c_off = 0;
    glRotatef( 180.0, 0.0, 0.0, 1.0 );
  }
  else if ( orientation == 1 ) {
    c_off = 2;
    glRotatef( 90.0, 0.0, 0.0, 1.0 );
  }
  else if ( orientation == 3 ) {
    c_off = 6;
    glRotatef( -90.0, 0.0, 0.0, 1.0 );
  }

  if ( trans_type == GLUI_TRANSLATION_Z )
    y0 = 0.0;
  else if ( trans_type == GLUI_TRANSLATION_XY )
    y0 = x1;
  else
    y0 = 0.0;

	
  if ( trans_type == GLUI_TRANSLATION_Z ) {
    if ( orientation == 0 ) {
      y1 += 2.0;
      y2 += 0.0;

      x1b -= 2.0;
      x2  -= 2.0;
      x1a += 2.0;
    }
    else if ( orientation == 2 ) {
      y1 -= 6.0;
      x1a += 2.0;
      x1b += 4.0;
      x2  += 6.0; 
    }
  }

  /*** Fill in inside of arrow  ***/
  if ( NOT filled ) {  /*** Means button is up - control is not clicked ***/
    /*glColor3f( .8, .8, .8 );              */
    set_to_bkgd_color();
    glColor3f( bkgd[0]+.07, bkgd[1]+.07, bkgd[2]+.07 );
  }
  else {               /*** Button is down on control ***/
    glColor3f( .6, .6, .6 );
    c_off += 4;  /* Indents the shadows - goes from a raised look to embossed */
  }

  /*** Check if control is enabled or not ***/
  if ( NOT enabled ) {
    set_to_bkgd_color();
    /*c_off += 4;  -- Indents the shadows - goes from a raised look to embossed */              
    colors_out[0] = colors_out[1] = colors_out[2] = colors_out[7] = gray;
    colors_out[3] = colors_out[4] = colors_out[5] = colors_out[6] = white;
    colors_in[0] = colors_in[1] = colors_in[2] = colors_in[7] = white;
    colors_in[3] = colors_in[4] = colors_in[5] = colors_in[6] = gray;
	
  }

  glBegin( GL_POLYGON );
  glVertex2f( 0.0, 0.0  );  glVertex2f( -x1a, 0.0 );
  glVertex2f( -x1a, 0.0   );  glVertex2f( -x1b, y1 );
  glVertex2f( x1b, y1);      glVertex2f( x1a, 0.0 );
  glVertex2f( x1a, 0.0 );     glVertex2f( 0.0, 0.0  );
  glEnd();
  glBegin( GL_TRIANGLES );
  glVertex2f( -x2, y1 ); glVertex2f( 0.0, y2 ); glVertex2f( x2, y1 );
  glEnd();

  glLineWidth( 1.0 );
  /*** Draw arrow outline ***/
  glBegin( GL_LINES );

  SET_COL_IN(1+c_off);  DRAW_SEG( 0.0, y2-1.0, -x2, y1-1.0 );
  SET_COL_IN(6+c_off);	DRAW_SEG( -x2+2.0, y1+1.0, -x1b+1.0, y1+1.0 );
  SET_COL_IN(0+c_off);	DRAW_SEG( -x1b+1.0, y1+1.0, -x1a+1.0, y0 );
  SET_COL_IN(3+c_off);	DRAW_SEG( 0.0, y2-1.0, x2, y1-1.0 );
  SET_COL_IN(6+c_off);	DRAW_SEG( x2-1.0, y1+1.0, x1b-1.0, y1+1.0 );
  SET_COL_IN(4+c_off);	DRAW_SEG( x1b-1.0, y1+1.0, x1a-1.0, y0 );

  SET_COL_OUT(0+c_off);  DRAW_SEG( -x1a, y0, -x1b, y1  );
  SET_COL_OUT(6+c_off);  DRAW_SEG( -x1b, y1,  -x2, y1  );
  SET_COL_OUT(1+c_off);  DRAW_SEG( -x2, y1,  0.0, y2  );
  SET_COL_OUT(3+c_off);  DRAW_SEG( 0.0, y2,   x2, y1  );
  SET_COL_OUT(6+c_off);  DRAW_SEG(  x2, y1,   x1b, y1  );
  SET_COL_OUT(4+c_off);  DRAW_SEG(  x1b, y1,   x1a, y0 );

  glEnd();

#undef DRAW_SEG

  glPopMatrix();
}
Esempio n. 30
0
// --------------
// -----Main-----
// --------------
int
main (int argc, char** argv)
{
  // --------------------------------------
  // -----Parse Command Line Arguments-----
  // --------------------------------------
  
    double normals_radius= 0.005;
  if (pcl::console::parse (argc, argv, "-n", normals_radius) >= 0)
  {
    std::cout << " Radius: " << normals_radius << "\n";
  }
  
      double harris_radius = 0.5;
  if (pcl::console::parse (argc, argv, "--hariss_radius", harris_radius) >= 0)
  {
    std::cout << " harris_radius: " << harris_radius << "\n";
  }
 
      double harris_search_radius = 0.01;
  if (pcl::console::parse (argc, argv, "--harris_search_radius", harris_search_radius) >= 0)
  {
    std::cout << " harris_search_radius: " << harris_search_radius << "\n";
  }

  
    pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudRGB (new pcl::PointCloud<pcl::PointXYZRGB>);
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

  if (pcl::io::loadPCDFile<pcl::PointXYZRGB> (argv[1], *cloudRGB) == -1) //* load the file
  {
    std::cout << "Couldn't read file cloud.pcd ";
    return (-1);
  }
  
  pcl::copyPointCloud(*cloudRGB, *cloud);

      pcl::PointCloud<pcl::PointXYZ>::Ptr harris3d (new pcl::PointCloud<pcl::PointXYZ>);
      pcl::PointCloud<pcl::PointXYZ>::Ptr iss3d (new pcl::PointCloud<pcl::PointXYZ>);
      pcl::PointCloud<pcl::PointXYZ>::Ptr susan (new pcl::PointCloud<pcl::PointXYZ>);
      pcl::PointCloud<pcl::PointXYZ>::Ptr harris6d (new pcl::PointCloud<pcl::PointXYZ>);
      pcl::PointCloud<pcl::PointXYZ>::Ptr sift (new pcl::PointCloud<pcl::PointXYZ>);

  
  	NormalCloudPtr normals(new NormalCloud());
	pcl::NormalEstimationOMP<PointT, NormalT> est;
	est.setRadiusSearch(normals_radius);
	est.setInputCloud(cloud);
	est.compute(*normals);

	{

	pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());

		pcl::PointCloud<pcl::PointXYZI>::Ptr keypoints_temp(
				new pcl::PointCloud<pcl::PointXYZI>());

		HarrisKeypoint* detector = new HarrisKeypoint(HarrisKeypoint::HARRIS);

		detector->setNonMaxSupression(true);
		detector->setRadius(harris_radius);

		detector->setRadiusSearch(harris_search_radius);
		detector->setMethod(HarrisKeypoint::HARRIS);
	//	detector->setKSearch();
		detector->setNumberOfThreads(10);
		detector->setSearchMethod(tree);
	//	detector->setThreshold();
	//	detector->use_indices_ = false;
		detector->setInputCloud(cloud);


		detector->compute(*keypoints_temp);

		pcl::PointCloud<pcl::PointXYZ>::Ptr keypoints(
				new pcl::PointCloud<pcl::PointXYZ>());

		pcl::copyPointCloud(*keypoints_temp, *harris3d);
}

	std::cout <<  " harris3d size :" << harris3d->size() << std::endl;;
	
	

/*
	{

		double iss_salient_radius_;
			double iss_non_max_radius_;
			double iss_gamma_21_ (0.975);
			double iss_gamma_32_ (0.975);
			double iss_min_neighbors_ (20);
			int iss_threads_ (10);

			pcl::PointCloud<pcl::PointXYZ>::Ptr keypoints (new pcl::PointCloud<pcl::PointXYZ> ());
			pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());

			// Fill in the model cloud

			double model_resolution = 0.01;

			// Compute model_resolution

			iss_salient_radius_ = 6 * model_resolution;
			iss_non_max_radius_ = 4 * model_resolution;

			//
			// Compute keypoints
			//
			pcl::ISSKeypoint3D<pcl::PointXYZ, pcl::PointXYZ> iss_detector;

			iss_detector.setSearchMethod (tree);
			iss_detector.setSalientRadius (iss_salient_radius_);
			iss_detector.setNonMaxRadius (iss_non_max_radius_);
			iss_detector.setThreshold21 (iss_gamma_21_);
			iss_detector.setThreshold32 (iss_gamma_32_);
			iss_detector.setMinNeighbors (iss_min_neighbors_);
			iss_detector.setNumberOfThreads (iss_threads_);
			iss_detector.setInputCloud (cloud);
			iss_detector.compute (*iss3d);
	}


	std::cout << " iss3d size :" << iss3d->size() << std::endl;

	
	
	{
		pcl::search::KdTree<pcl::PointXYZRGB>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGB> ());

		pcl::SUSANKeypoint<pcl::PointXYZRGB, pcl::PointXYZRGB>* susan3D = new  pcl::SUSANKeypoint<pcl::PointXYZRGB, pcl::PointXYZRGB>;
		susan3D->setInputCloud(cloudRGB);
		susan3D->setNonMaxSupression(true);
		susan3D->setSearchMethod(tree);
		
		susan3D->setRadius(harris_radius);
		susan3D->setRadiusSearch(harris_search_radius);
		
		pcl::PointCloud<pcl::PointXYZRGB>::Ptr keypoints (new pcl::PointCloud<pcl::PointXYZRGB> ());
		susan3D->compute(*keypoints);

		pcl::PointCloud<pcl::PointXYZ>::Ptr susan(new pcl::PointCloud<pcl::PointXYZ>());

		pcl::copyPointCloud(*keypoints, *susan);
	}

	std::cout <<  " susan size :" << susan->size() << std::endl;

	
	
	{

	pcl::search::KdTree<pcl::PointXYZRGB>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGB> ());

		pcl::PointCloud<pcl::PointXYZI>::Ptr keypoints_temp(
				new pcl::PointCloud<pcl::PointXYZI>());

		HarrisKeypoint6D* detector = new HarrisKeypoint6D(HarrisKeypoint::HARRIS);

		detector->setNonMaxSupression(true);
		detector->setRadius(harris_radius);
		detector->setRadiusSearch(harris_search_radius);
	//	detector->setMethod(HarrisKeypoint::HARRIS);
		

		detector->setNumberOfThreads(10);
		detector->setSearchMethod(tree);
	//	detector->setThreshold();
	//	detector->use_indices_ = false;
		detector->setInputCloud(cloudRGB);


		detector->compute(*keypoints_temp);

		pcl::copyPointCloud(*keypoints_temp, *harris6d);
}

	std::cout <<  " harris6d size :" << harris6d->size() << std::endl;

	/*
	*/

		pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> white (cloud, 255, 255, 255);
	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> red (harris3d, 255, 0, 0);
	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> green (iss3d, 0, 255, 0);
	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> blue (susan, 0, 0, 255);
	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> col2 (harris6d, 255, 0, 255);
	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> col3 (sift, 255, 255, 0);
	//////
  
   boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
  viewer->setBackgroundColor (0, 0, 0);
  viewer->addPointCloud<pcl::PointXYZ> (cloud, white, "cloud");
    viewer->addPointCloud<pcl::PointXYZ> (harris3d, red, "keypoints2");
    viewer->addPointCloud<pcl::PointXYZ> (iss3d, green, "keypoints3");
    viewer->addPointCloud<pcl::PointXYZ> (susan, blue, "keypoint4s");
    viewer->addPointCloud<pcl::PointXYZ> (harris6d, col2, "keypoin3ts");
    viewer->addPointCloud<pcl::PointXYZ> (sift, col3, "keypoint36");
  viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 4, "keypoints2");
  viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 4, "keypoints3");
  viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 4, "keypoint4s");
  viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 4, "keypoin3ts");
  viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 4, "keypoint36");
 // viewer->addPointCloudNormals<pcl::PointXYZ, pcl::Normal> (cloud, normals, 5, 0.05, "normals");
  viewer->addCoordinateSystem (1.0, "global");
  viewer->initCameraParameters ();
//   viewer->addSphere (cloud->points[0], normals_radius, "sphere+norm", 0);
  //  viewer->addSphere (cloud->points[0], shot_radius, "sphere+shot", 0);


  //--------------------
  // -----Main loop-----
  //--------------------
  while (!viewer->wasStopped ())
  {
    viewer->spinOnce (100);
    boost::this_thread::sleep (boost::posix_time::microseconds (100000));
  }
}