void DeconvolutionAlgorithm::GetModelFromImage(Model &model, const double* image, size_t width, size_t height, double phaseCentreRA, double phaseCentreDec, double pixelSizeX, double pixelSizeY, double phaseCentreDL, double phaseCentreDM, double spectralIndex, double refFreq, PolarizationEnum polarization)
{
	for(size_t y=0; y!=height; ++y)
	{
		for(size_t x=0; x!=width; ++x)
		{
			double value = image[y*width + x];
			if(value != 0.0 && std::isfinite(value))
			{
				long double l, m;
				ImageCoordinates::XYToLM<long double>(x, y, pixelSizeX, pixelSizeY, width, height, l, m);
				l += phaseCentreDL; m += phaseCentreDM;
				ModelComponent component;
				long double ra, dec;
				ImageCoordinates::LMToRaDec<long double>(l, m, phaseCentreRA, phaseCentreDec, ra, dec);
				std::stringstream nameStr;
				nameStr << "component" << model.SourceCount();
				component.SetSED(MeasuredSED(value, refFreq, spectralIndex, polarization));
				component.SetPosRA(ra);
				component.SetPosDec(dec);
				
				ModelSource source;
				source.SetName(nameStr.str());
				source.AddComponent(component);
				model.AddSource(source);
			}
		}
	}
}
Esempio n. 2
0
void
MapNode::onModelLayerAdded( ModelLayer* layer, unsigned int index )
{
    if ( !layer->getEnabled() )
        return;
    
    // install a noe operation that will associate this mapnode with
    // any MapNodeObservers loaded by the model layer:
    ModelSource* modelSource = layer->getModelSource();
    if ( modelSource )
    {
        // install a post-processing callback on the ModelLayer's source 
        // so we can update the MapNode on new data that comes in:
        modelSource->addPostMergeOperation( new MapNodeObserverInstaller(this) );
    }

    // create the scene graph:
    //osg::Node* node = layer->getOrCreateSceneGraph( _map.get(), _map->getDBOptions(), 0L );
    osg::Node* node = layer->getOrCreateSceneGraph( _map.get(), 0L );

    if ( node )
    {
        if ( _modelLayerNodes.find( layer ) != _modelLayerNodes.end() )
        {
            OE_WARN
                << "Illegal: tried to add the name model layer more than once: " 
                << layer->getName()
                << std::endl;
        }
        else
        {
            if ( dynamic_cast<TerrainDecorator*>(node) )
            {
                OE_INFO << LC << "Installing overlay node" << std::endl;
                addTerrainDecorator( node->asGroup() );
            }
            else
            {
                _models->insertChild( index, node );
            }

            ModelSource* ms = layer->getModelSource();

            if ( ms )
            {
                // enfore a rendering bin if necessary:
                if ( ms->getOptions().renderOrder().isSet() )
                {
                    node->getOrCreateStateSet()->setRenderBinDetails(
                        ms->getOptions().renderOrder().value(), "RenderBin" );
                }
            }

            _modelLayerNodes[ layer ] = node;
        }

        dirtyBound();
    }
}
Esempio n. 3
0
void
MapNode::onModelLayerAdded( ModelLayer* layer, unsigned int index )
{
    if ( !layer->getEnabled() )
        return;

    osg::Node* node = layer->getOrCreateNode();

    layer->addCallback(_modelLayerCallback.get() );

    if ( node )
    {
        if ( _modelLayerNodes.find( layer ) != _modelLayerNodes.end() )
        {
            OE_WARN
                << "Illegal: tried to add the name model layer more than once: " 
                << layer->getName()
                << std::endl;
        }
        else
        {
            if ( dynamic_cast<TerrainDecorator*>(node) || dynamic_cast<osgSim::OverlayNode*>(node) )
            {
                OE_INFO << LC << "Installing overlay node" << std::endl;
                addTerrainDecorator( node->asGroup() );
            }
            else
            {
                if ( layer->getOverlay() )
                {
#if 0
                    _overlayModels->addChild( node );
                    updateOverlayGraph();
#else
                    DrapeableNode* draper = new DrapeableNode( this );
                    draper->addChild( node );
                    _models->insertChild( index, draper );
#endif
                }
                else
                {
                    _models->insertChild( index, node );
                }
            }

            ModelSource* ms = layer->getModelSource();
            if ( ms && ms->getOptions().renderOrder().isSet() )
            {
                node->getOrCreateStateSet()->setRenderBinDetails(
                    ms->getOptions().renderOrder().value(), "RenderBin" );
            }

            _modelLayerNodes[ layer ] = node;
        }

        dirtyBound();
    }
}
Esempio n. 4
0
 void dirtyModelLayers()
 {
     for(unsigned i=0; i<s_activeMap->getNumModelLayers(); ++i)
     {
         ModelSource* ms = s_activeMap->getModelLayerAt(i)->getModelSource();
         if ( ms )
         {
             ms->dirty();
         }
         else
         {
             OE_NOTICE << s_activeMap->getModelLayerAt(i)->getName()
                 << " has no model source.\n";
         }
     }
 }
Esempio n. 5
0
    void dirtyModelLayers()
    {
        ModelLayerVector modelLayers;
        s_activeMap->getLayers(modelLayers);

        for(unsigned i=0; i<modelLayers.size(); ++i)
        {
            ModelSource* ms = modelLayers.at(i)->getModelSource();
            if ( ms )
            {
                ms->dirty();
            }
            else
            {
                OE_NOTICE << modelLayers.at(i)->getName()
                    << " has no model source.\n";
            }
        }
    }
void DeconvolutionAlgorithm::GetModelFromIQUVImage(Model &model, const double* images[4], size_t width, size_t height, double phaseCentreRA, double phaseCentreDec, double pixelSizeX, double pixelSizeY, double phaseCentreDL, double phaseCentreDM, double spectralIndex, double refFreq)
{
	for(size_t y=0; y!=height; ++y)
	{
		for(size_t x=0; x!=width; ++x)
		{
			bool isNonZero = false;
			double values[4];
			for(size_t p=0; p!=4; ++p)
			{
				values[p] = images[p][y*width + x];
				if(values[p] != 0.0 && std::isfinite(values[p]))
					isNonZero = true;
			}
			if(isNonZero)
			{
				long double l, m;
				ImageCoordinates::XYToLM<long double>(x, y, pixelSizeX, pixelSizeY, width, height, l, m);
				l += phaseCentreDL; m += phaseCentreDM;
				ModelComponent component;
				long double ra, dec;
				ImageCoordinates::LMToRaDec<long double>(l, m, phaseCentreRA, phaseCentreDec, ra, dec);
				std::stringstream nameStr;
				nameStr << "component" << model.SourceCount();
				MeasuredSED sed;
				component.SetSED(MeasuredSED(values, refFreq));
				component.SetPosRA(ra);
				component.SetPosDec(dec);
				
				ModelSource source;
				source.SetName(nameStr.str());
				source.AddComponent(component);
				model.AddSource(source);
			}
		}
	}
}