Exemple #1
0
void TreeUpdate(int left, int right, int i)
{
    if (node[i].left == left && node[i].right == right)
    {
        node[i].cover++;
        return ;
    }
    // 叶子节点
    if (node[i].left == node[i].right)
    {
        return ;
    }
    
    int mid = (node[i].left + node[i].right)/2;
    if (right <= mid)
    {
        TreeUpdate(left, right, i*2);
    }
    else if (left > mid)
    {
        TreeUpdate(left, right, i*2+1);
    }
    else
    {
        TreeUpdate(left, mid, i*2);
        TreeUpdate(mid+1, right, i*2+1);
    }
}
void SceneObject_Door::RegenAABB()
{
	m_aabb =  m_pDoorModel->GetAABB().GetTransformedAABB(Matrix4x4f::TranslateMatrix(m_pos) * Matrix4x4f::RotateMatrix_Y(m_angle));

	if(IsSPTManaged())
		TreeUpdate();
}
Exemple #3
0
void VSCVidTreeEmap::Init()
{
	if (m_bInit == true)
	{
		return;
	}
	m_pRoot = new  QTreeWidgetItem(this);
	QIcon icon1;
	icon1.addFile(QStringLiteral(":/action/resources/map.png"), QSize(), QIcon::Normal, QIcon::Off);
	
	m_pRoot->setIcon(0, icon1);

	m_pRoot->setText(0, QApplication::translate("Emap",
	        "Emap", 0));
	
	addTopLevelItem(m_pRoot);
	m_pRoot->setExpanded(true);
	
	TreeUpdate();
	
	/* Register the device callback */
	//m_pFactory.RegChangeNotify((void *)this, VSCVidTreeEmap::CallChange);
	connect(&(m_pFactory), SIGNAL(SignalCallChange(int, std::string)), this, SLOT(SlotCallChange(int, std::string)));
	m_bInit = true;
}
Exemple #4
0
int main(int argc, char **argv)
{
    //freopen("in.txt", "r", stdin);
    
    int n, i, l, r;
    
    while (EOF != scanf("%d", &n), n)
    {
        TreeMake(1, n, 1);
        for (i = 1; i <= n; ++i)
        {
            scanf("%d %d", &l, &r);
            TreeUpdate(l, r, 1);
        }
        for (i = 1; i < n; ++i)
        {
            g_nRes = 0;
            TreeQuery(i, 1);
            printf("%d ", g_nRes);
        }
        g_nRes = 0;
        TreeQuery(i, 1);
        printf("%d\n", g_nRes);
    }

    return 0;
}
Exemple #5
0
	void ConvexHull::IncWorldCenter(const Vec2f &increment)
	{
		m_worldCenter += increment;

		m_aabb.IncCenter(increment);

		TreeUpdate();
	}
Exemple #6
0
	void ConvexHull::SetWorldCenter(const Vec2f &newCenter)
	{
		m_worldCenter = newCenter;

		m_aabb.SetCenter(m_worldCenter);

		TreeUpdate();
	}
	void Light_Point::SetDirectionAngle(float directionAngle)
	{
		assert(AlwaysUpdate());

		m_directionAngle = directionAngle;

		CalculateAABB();
		TreeUpdate();
	}
Exemple #8
0
	void Light::IncRadius(float increment)
	{
		assert(m_alwaysUpdate);

		m_radius += increment;

		CalculateAABB();
		TreeUpdate();
	}
Exemple #9
0
	void Light::SetRadius(float radius)
	{
		assert(m_alwaysUpdate);

		m_radius = radius;

		CalculateAABB();
		TreeUpdate();
	}
	void Light_Point::IncDirectionAngle(float increment)
	{
		assert(AlwaysUpdate());

		m_directionAngle += increment;

		CalculateAABB();
		TreeUpdate();
	}
	void Light_Point::SetSpreadAngle(float spreadAngle)
	{
		assert(AlwaysUpdate());

		m_spreadAngle = spreadAngle;

		CalculateAABB();
		TreeUpdate();
	}
	void Light_Point::IncSpreadAngle(float increment)
	{
		assert(AlwaysUpdate());

		m_spreadAngle += increment;

		CalculateAABB();
		TreeUpdate();
	}
Exemple #13
0
	void Light::IncCenter(Vec2f increment)
	{
		m_center += increment;

		m_aabb.IncCenter(increment);

		TreeUpdate();

		m_updateRequired = true;
	}
Exemple #14
0
bool VSCVidTreeEmap::CallChange(ClientFactoryChangeData data)
{
	switch (data.type)
	{
		case CLIENT_FACTORY_EMAP_ADD:
		{
			TreeUpdate();
			break;
		}
		case CLIENT_FACTORY_EMAP_DEL:
		{
			TreeUpdate();
			break;
		}
		default:
		   	break;
	};

	return true;
}
Exemple #15
0
	void Light::SetCenter(Vec2f center)
	{
		Vec2f difference(center - m_center);

		m_center = center;

		m_aabb.IncCenter(difference);

		TreeUpdate();

		m_updateRequired = true;
	}
void SceneObject_Prop_Physics_Static::RegenAABB()
{
	btVector3 min, max;

	m_pRigidBody->getAabb(min, max);

	m_aabb.m_lowerBound = cons(min);
	m_aabb.m_upperBound = cons(max);

	m_aabb.CalculateHalfDims();
	m_aabb.CalculateCenter();

	if(IsSPTManaged())
		TreeUpdate();
}
Exemple #17
0
VSCVidTreeCam::VSCVidTreeCam(ClientFactory &pFactory, QWidget *parent)
: VSCVidTreeInf(pFactory, parent)
{
	m_pRoot = new  VSCVidItemCam((QTreeWidgetItem *)this);
	
	QIcon icon1;
	icon1.addFile(QStringLiteral(":/device/resources/camera.png"), QSize(), QIcon::Normal, QIcon::Off);
	
    m_pRoot->setIcon(0, icon1);

    m_pRoot->setText(0, QApplication::translate("Camera",
            "Camera", 0));
	
	addTopLevelItem(m_pRoot);
	m_pRoot->setExpanded(true);
	
	TreeUpdate();
	
	/* Register the device callback TODO */
	
}
void SceneObject_ParticleEmitter_Sprite::Logic()
{
	// ----------------------- Spawning -----------------------

	if(m_emit)
	{
		m_spawnTimer += GetScene()->m_frameTimer.GetTimeMultiplier();

		if(m_spawnTimer > m_spawnTime)
		{
			// Spawn multiple per frame, if went over more than one multiple of the spawn time
			int numSpawn = static_cast<int>(m_spawnTimer / m_spawnTime);

			// Spawn particles
			for(int i = 0; i < numSpawn; i++)
				m_pParticles.push_back(EmitParticle());

			// Reset timer, keep overflow (fmodf equivalent)
			m_spawnTimer -= numSpawn * m_spawnTime;

			// Pick new random spawn time
			m_spawnTime = Randf(m_minSpawnTime, m_maxSpawnTime);
		}
	}

	// ----------------------- Updating -----------------------

	if(m_pParticles.empty())
	{
		if(m_autoDestruct)
			Destroy();
	}
	else
	{
		// Recalculate AABB while at it
		m_aabb.m_lowerBound = m_pParticles.front()->m_position;
		m_aabb.m_upperBound = m_aabb.m_lowerBound;

		for(std::list<Particle_Sprite*>::iterator it = m_pParticles.begin(); it != m_pParticles.end();)
		{
			Particle_Sprite* pParticle = *it;

			if(pParticle->Logic())
			{
				// Destroy particle
				delete pParticle;

				it = m_pParticles.erase(it);
			}
			else
			{
				// Affect particle
				for(unsigned int i = 0, size = m_pAffectorFuncs.size(); i < size; i++)
					m_pAffectorFuncs[i](pParticle);

				// Grow AABB
				float radius = pParticle->GetRadius();

				Vec3f particleLower(pParticle->m_position - Vec3f(radius, radius, radius));
				Vec3f particleUpper(pParticle->m_position + Vec3f(radius, radius, radius));
				
				if(particleLower.x < m_aabb.m_lowerBound.x)
					m_aabb.m_lowerBound.x = pParticle->m_position.x - pParticle->m_radius;

				if(particleLower.y < m_aabb.m_lowerBound.y)
					m_aabb.m_lowerBound.y = pParticle->m_position.y - pParticle->m_radius;

				if(particleLower.z < m_aabb.m_lowerBound.z)
					m_aabb.m_lowerBound.z = pParticle->m_position.z - pParticle->m_radius;

				if(particleUpper.x > m_aabb.m_upperBound.x)
					m_aabb.m_upperBound.x = pParticle->m_position.x + pParticle->m_radius;

				if(particleUpper.y > m_aabb.m_upperBound.y)
					m_aabb.m_upperBound.y = pParticle->m_position.y + pParticle->m_radius;

				if(particleUpper.z > m_aabb.m_upperBound.z)
					m_aabb.m_upperBound.z = pParticle->m_position.z + pParticle->m_radius;

				it++;
			}
		}

		if(IsSPTManaged())
			TreeUpdate();
	}
}
//--------------------------------------------------------------
void defense::update(){
    
 
    CurrentSlide = keyString[SlideCounter];
    if(VideoIsPlaying == false){
    bool bNewFrame = false;
    vidGrabber.update();
    bNewFrame = vidGrabber.isFrameNew();
	if (bNewFrame){
       colorImg.setFromPixels(vidGrabber.getPixels(), Nx,Ny);
       colorImg.mirror(false, true);
       TheInputRGB = colorImg.getCvImage(); 
       grayImage = colorImg;
       TheInputGray = grayImage.getCvImage();
       cvResize(TheInputGray, HalfInputGray);
    }
    
    }
    
    if ((CurrentSlide.compare("BlockDiagram")==0)&&(InterMode>0)){
        ImageToEllipseList(TheInputGray, 16);
        CoherentEllipses();
        
    }
    

    if ((CurrentSlide.compare("VideoReview")==0)&&(VideoIsPlaying)){
        Mov.idleMovie();
    }
    
    if ((CurrentSlide.compare("VideoNPR")==0)&&(VideoIsPlaying)){
        Mov.idleMovie();
    }
    
    if ((CurrentSlide.compare("RedrawingRegions")==0)&&(InterMode<2)){
        updateMat();
    }
    
    if ((CurrentSlide.compare("RedrawingRegions")==0)&&(InterMode==3)){
    ImgToContours(TheInputGray,14,0);
    } 
    if ((CurrentSlide.compare("RedrawingRegions")==0)&&(InterMode==4)){
        ImgToContours(TheInputGray,8,1);
    } 
    if ((CurrentSlide.compare("EdgesAndLines")==0)&&(InterMode==1)){
        ImgToLineList();
    } 
    
    if ((CurrentSlide.compare("OrientationSlide")==0)||
        (CurrentSlide.compare("SizeSlide")==0)||
        CurrentSlide.compare("ShapeSlide")==0){
        
        NumOfSquares = ofVec2f(64,48);
        
        
//    if ((NumOfSquares.x != (int)(10+(Nx/4-10)*Slider2/127.0))||
//        (NumOfSquares.y != (int)(10+(Ny/4-10)*Slider3/127.0))){
//        NumOfSquares.x = (int)(10+(Nx/4-10)*Slider2/127.0);
//        NumOfSquares.y = (int)(10+(Ny/4-10)*Slider3/127.0);
        Destino = cvCreateImage(cvSize(NumOfSquares.x, NumOfSquares.y), 8, 1);
//    }
        cvResize(TheInputGray, Destino);
    }
    if (CurrentSlide.compare("DensitySlide")==0) {
        NumOfSquares = ofVec2f(128,96);
//        if ((NumOfSquares.x != (int)(10+(Nx/4-10)*Slider2/127.0))||
//            (NumOfSquares.y != (int)(10+(Ny/4-10)*Slider3/127.0))){
//            NumOfSquares.x = (int)(10+(Nx/4-10)*Slider2/127.0);
//            NumOfSquares.y = (int)(10+(Ny/4-10)*Slider3/127.0);
            Destino = cvCreateImage(cvSize(NumOfSquares.x, NumOfSquares.y), 8, 1);
//        }
        cvResize(TheInputGray, Destino);
        DithPointList();
    }
    if (CurrentSlide.compare("Connectedness")==0) {
        NumOfSquares = ofVec2f(128,96);
//        if ((NumOfSquares.x != (int)(10+(Nx/4-10)*Slider2/127.0))||
//            (NumOfSquares.y != (int)(10+(Ny/4-10)*Slider3/127.0))){
//            NumOfSquares.x = (int)(10+(Nx/4-10)*Slider2/127.0);
//            NumOfSquares.y = (int)(10+(Ny/4-10)*Slider3/127.0);
            Destino = cvCreateImage(cvSize(NumOfSquares.x, NumOfSquares.y), 8, 1);
//        }
        cvResize(TheInputGray, Destino);
        DithPointList();
        SortPointsToPlot();
          
    }
    
    
    if (CurrentSlide.compare("Transcoding")==0){
        
        NumOfSquares = ofVec2f(64,48);
        
        
        //    if ((NumOfSquares.x != (int)(10+(Nx/4-10)*Slider2/127.0))||
        //        (NumOfSquares.y != (int)(10+(Ny/4-10)*Slider3/127.0))){
        //        NumOfSquares.x = (int)(10+(Nx/4-10)*Slider2/127.0);
        //        NumOfSquares.y = (int)(10+(Ny/4-10)*Slider3/127.0);
        Destino = cvCreateImage(cvSize(NumOfSquares.x, NumOfSquares.y), 8, 1);
        //    }
        cvResize(TheInputGray, Destino);
    } 
    
    
    
    if(CurrentSlide.compare("NCcir")==0){
        NCCirUpdate();
        CircsFrameCount++;
        if (CircsFrameCount>260){
            CircsFrameCount=1;
        }
    
    }
    
    if (CurrentSlide.compare("NCcirMatched")==0) {
        CirMatched(0);
    }
    if (CurrentSlide.compare("MinMaxcir")==0) {
        CirMatched(1);
    }
    if (CurrentSlide.compare("BottleNeckCir")==0) {
        CirMatched(2);
    } 
    if (CurrentSlide.compare("DirectionFiltCir")==0) {
        CirMatched(3);
    }
    
    if((CurrentSlide.compare("NCcirMatched")==0)||
       (CurrentSlide.compare("MinMaxcir")==0)||
       (CurrentSlide.compare("BottleNeckCir")==0)||
       (CurrentSlide.compare("DirectionFiltCir")==0)){
        
        G_ka = 1.35 + 4*Slider1/127.0;
        G_Dammping = .45 + 4*Slider2/127.0;
        MaxBetweener = 2 + 18*(int)Slider3/127.0;
        BetweenFrames++;
        if(BetweenFrames>=MaxBetweener){
            CircsFrameCount++;
            BetweenFrames=0;
            if (CircsFrameCount>260){
                CircsFrameCount=1;
            }
        }
  
    }
    
    if((CurrentSlide.compare("MeshFlow")==0)||
    (CurrentSlide.compare("ArrowsDraw")==0)){
        
        G_kMesh=4.0 + 4*Slider1/127.0; // elastic constant	
        G_kgMesh=.4*Slider2/127.0; // gradient factor
//        G_kdMesh=.5+4*Slider3/127.0; // drag constant
       G_kdMesh=.05+4*Slider3/127.0; // drag constant  
        MeshFlowUpdate();
    }
    
    
    
    
    if(CurrentSlide.compare("GradientCircs")==0){
    
        CirclesGradientUpdate();
    }
    
    if (CurrentSlide.compare("TargetsAlgorithm")==0) {
        MaxMode =2;
        if(InterMode>MaxMode-1){InterMode=0;} 
        TargetAlgorithmUpdate(InterMode);
    }
    
    
    if (CurrentSlide.compare("EllipwithTarget")==0){
        
        ImageToEllipseList(TheInputGray, 16);
        MaxMode =2;
        if(InterMode>MaxMode-1){InterMode=0;} 
        if (InterMode==1){
            CoherentEllipses();
        }
        
    }
    
    
    if (CurrentSlide.compare("TargetEllipseExample")==0){
    
        ImageToEllipseList(TheInputGray, 16);
        CoherentEllipses();
    
    }
    
    if (CurrentSlide.compare("GoodFeaturesExample")==0) {
        GoodFeaturesUpdate();
    }

    if (CurrentSlide.compare("Mixing")==0){

        NumOfSquares.x = 28;
        NumOfSquares.y = 28;
        
        
            Destino = cvCreateImage(cvSize(NumOfSquares.x, NumOfSquares.y), 8, 1);
        cvResize(TheInputGray, Destino);
    }
    
    
    if ((CurrentSlide.compare("Bagette")==0)){
        ImageToEllipseList(TheInputGray, 16);
        CoherentEllipses();     
    }
  
    if ((CurrentSlide.compare("CaptureSlideJul26")==0)){
        ImageToEllipseList(TheInputGray, 16);
        CoherentEllipses();     
    }
   
    
    
    if (CurrentSlide.compare("Hormigas")==0) {
        HormigasUpdate();
    }
    
    if (CurrentSlide.compare("Tree")==0) {
        TreeUpdate();
    } 
    if (CurrentSlide.compare("TemplateDemo")==0) {
        ofSetFrameRate(12);
        TemplateDemoUpdate();
    }
    if (CurrentSlide.compare("TemplateDemo")!=0){
    ofSetFrameRate(30);
    }
    
   
    
}