Ejemplo n.º 1
0
void Spiral::fillGrid()
{
    Coordinate pos;
    Direction dir = Up;
    pos.x = pos.y = m / 2;
    
    int count = m * m;
    int index = 1;
    
    while(index <= count)
    {
        visit(pos, index++);
        
        Direction ideal = getIdealDirection(dir);
        Coordinate next = getNextCoordinate(ideal, pos);
        if(hasVisited(next))
            next = getNextCoordinate(dir, pos);
        else
            dir = ideal;
        
        pos = next;
    }
    
    for(int i = 0; i < m; ++i)
        delete [] visited[i];
    delete [] visited;
    visited = nullptr;
}
    virtual void visit(ossimConnectableObject* obj)
    {
        if(!hasVisited(obj))
        {
            ossimImageHandler* handler        = dynamic_cast<ossimImageHandler*>(obj);
            ossimHistogramSource* histoSource = dynamic_cast<ossimHistogramSource*>(obj);

            if(handler)
            {
                ossimFilename file = handler->createDefaultHistogramFilename();
                if(file.exists())
                {
                    m_histogram = new ossimMultiResLevelHistogram();
                    if(!m_histogram->importHistogram(file))
                    {
                        stopTraversal();
                        m_histogram = 0;
                    }
                }
            }
            else if(histoSource)
            {
                m_histogram = histoSource->getHistogram();
                if(m_histogram.valid())
                {
                    stopTraversal();
                }
            }
        }
        ossimVisitor::visit(obj);
    }
Ejemplo n.º 3
0
	//---------
	void RouteFind::step(const Problem & problem, Route visited) {
		if (visited.cost > this->bestSolution.cost)
			return;

		if (visited.back() == this->end) {
			if (visited.cost < this->bestSolution.cost) {
				this->bestSolution = visited;
			}
			return;
		}

		for (int i=0; i<problem.nodeCount; i++) {
			if (!hasVisited(i, visited)) {
				Journey j(visited.back(), i);
				float cost = problem.getSymmetricCost(j);
				if (cost == -1)
					continue;
				else {
					Route visitBranch(visited);
					visitBranch.addStep(i, cost);
					step(problem, visitBranch);
				}
			}
		}
	}
void ossimGui::GatherImageViewProjTransVisitor::visit(ossimObject* obj)
{
    if(!hasVisited(obj))
    {
        ossimImageRenderer* renderer = dynamic_cast<ossimImageRenderer*>(obj);
        if(renderer)
        {
            ossimImageViewProjectionTransform* ivpt = dynamic_cast<ossimImageViewProjectionTransform*>(renderer->getImageViewTransform());
            if(ivpt)
            {
                m_transformList.push_back(new IvtGeomTransform(ivpt, ivpt->getImageGeometry()) );
            }
            else
            {
                ossimImageViewAffineTransform* ivat = dynamic_cast<ossimImageViewAffineTransform*>(renderer->getImageViewTransform());
                if(ivat&&renderer->getInput())
                {
                    ossimTypeNameVisitor v("ossimImageHandler", true);
                    renderer->accept(v);

                    ossimImageHandler* handler = v.getObjectAs<ossimImageHandler>(0);
                    if(handler)
                    {
                        ossimRefPtr<ossimImageGeometry> geom = handler->getImageGeometry();
                        if(geom.valid())
                        {
                            m_transformList.push_back(new IvtGeomTransform(ivat, geom.get()) );
                        }
                    }
                }
            }
        }
        ossimVisitor::visit(obj);
    }
}
Ejemplo n.º 5
0
void ossimEventVisitor::visit(ossimConnectableObject* obj)
{
   if(!hasVisited(obj))
   {
      obj->fireEvent(*m_event);
   }
   ossimVisitor::visit(obj);
}
Ejemplo n.º 6
0
void ossimTypeIdVisitor::visit(ossimConnectableObject* obj)
{
   if(!hasVisited(obj))
   {
      ossimCollectionVisitor::visit(obj);
      if(obj&&obj->canCastTo(m_typeId))
      {
         m_collection.push_back(obj);
         if(m_firstOfTypeFlag) m_stopTraversalFlag = true;
      }
   }
}
Ejemplo n.º 7
0
void ossimEventVisitor::visit(ossimObject* obj)
{
   if(!hasVisited(obj))
   {
      ossimListenerManager* manager = dynamic_cast<ossimListenerManager*> (obj);
      if(manager)
      {
         manager->fireEvent(*m_event);
         ossimVisitor::visit(obj);
      }
   }
}
Ejemplo n.º 8
0
void ossimIdVisitor::visit(ossimConnectableObject* obj)
{
   if ( !hasVisited(obj) )
   {
      if(obj->getId() == m_id)
      {
         m_object = obj;
         m_stopTraversalFlag = true;
      }
      ossimVisitor::visit(obj);
   }
}
Ejemplo n.º 9
0
void ossimElevManager::ConnectionStringVisitor::visit(ossimObject* obj)
{
   if(!hasVisited(obj))
   {
      ossimElevationDatabase* databsase = dynamic_cast<ossimElevationDatabase*>(obj);
      if(databsase)
      {
         if(m_connectionString == databsase->getConnectionString())
         {
            m_database = databsase;
            m_stopTraversalFlag = true;
         }
      }
   }
}
Ejemplo n.º 10
0
void ossimSourceInitializeVisitor::visit(ossimObject* obj)
{
   if( !hasVisited(obj) )
   {
      ossimSource* vi = dynamic_cast<ossimSource*>(obj);

      if ( vi )
      {
         vi->initialize();
      }
      
      // This will put the obj in the m_markNode for hasVisited method.
      ossimVisitor::visit(obj);
   }
}
Ejemplo n.º 11
0
void ossimViewInterfaceVisitor::visit(ossimObject* obj)
{
   if( !hasVisited(obj) )
   {
      if ( m_view.get() )
      {
         ossimViewInterface* vi = dynamic_cast<ossimViewInterface*>(obj);
         if ( vi )
         {
            // Set the view:
            vi->setView( m_view.get() );

            // Send property event for outputs connected to us.
            ossimRefPtr<ossimEvent> propEvent = new ossimPropertyEvent(obj);
            ossimEventVisitor ev( propEvent.get(), VISIT_OUTPUTS );
            obj->accept(ev);
         }
      }
      
      // This will put the obj in the m_markNode for hasVisited method.
      ossimVisitor::visit(obj);
   }
}
Ejemplo n.º 12
0
QColor RecursiveBacktrackerColorizer::getColorForCell(const int idx) const {
  auto spt = rbm.lock();
  if (!spt) return pristine;
  if (spt->idx == idx) return current;
  return spt->hasVisited(idx) ? done : pristine;
}