예제 #1
0
void ReadConcept(Inputor& in, PointSet &pointSet, 
								 unsigned int recordType)
{
	string str;
	pointSet.reserve(in._num);
	double x,y,z;
	double I;
	double r,g,b;

	PointRec::Reset_I();
	do
	{
		switch(recordType){
	case XYZ:
		in.getLine(str, '\n');
		sscanf(str.c_str(), "%lf %lf %lf", &x, &y, &z);
		pointSet.push_back(PointRec(x,y,z));
		break;
	case XYZI:
		in.getLine(str, '\n');
		sscanf(str.c_str(), "%lf %lf %lf %lf", &x, &y, &z, &I);
		pointSet.push_back(PointRec(x,y,z,I));
		PointRec::Update_I(I);
		break;
	case XYZRGB:
		in.getLine(str, '\n');
		sscanf(str.c_str(), "%lf %lf %lf %lf %lf %lf", &x, &y, &z, &r, &g, &b);
		pointSet.push_back(PointRec(x,y,z,-1, r, g, b));
		break;
	case XYZIRGB:
		in.getLine(str, '\n');
		sscanf(str.c_str(), "%lf %lf %lf %lf %lf %lf %lf", &x, &y, &z, &I, &r, &g, &b);
		pointSet.push_back(PointRec(x,y,z, I, r, g, b));
		PointRec::Update_I(I);
		break;
		}
		in.frame();
	}while(!in.isEnd());
}
예제 #2
0
파일: KML_Model.cpp 프로젝트: 2php/osgearth
void
KML_Model::parseCoords( xml_node<>* node, KMLContext& cx )
{
    PointSet* point = new PointSet();

    xml_node<>* location = node->first_node("location", 0, false);
    if (location)
    {
        double latitude  = as<double>(getValue(location, "latitude"), 0.0);
        double longitude = as<double>(getValue(location, "longitude"), 0.0);
        double altitude  = as<double>(getValue(location, "altitude"), 0.0);
        point->push_back( osg::Vec3d(longitude, latitude, altitude));
    }    
    _geom = point;
}
예제 #3
0
void
KML_Model::parseCoords( const Config& conf, KMLContext& cx )
{
    PointSet* point = new PointSet();

    Config location = conf.child("location");
    if (!location.empty())
    {
        double latitude  = location.value("latitude",  0.0);
        double longitude = location.value("longitude", 0.0);
        double altitude  = location.value("altitude", 0.0); 
        point->push_back( osg::Vec3d(longitude, latitude, altitude));
    }    
    _geom = point;
}
예제 #4
0
    void loadPointSet(const std::string& filename, PointSet& ps)
    {
        std::fstream fin(filename.c_str(), std::ios_base::in);

        if (!fin)
        {
            std::cout << "cannot open the file!" << std::endl;
            return;
        }

        std::vector<Scalar> m_values;
        Scalar tmp = 0;
        size_t i = 0, j = 0;
        while (fin >> tmp)
        {
            m_values.push_back(tmp);
        }

        size_t points_size = m_values.size() / Dim;

        if (points_size * Dim != m_values.size())
        {
            std::cout << "File is broken! Or Dimension is incorrect!" << std::endl;
            return;
        }

        for (size_t i = 0; i < points_size; ++ i)
        {
            if (Dim == 3)
                ps.push_back(PointType(m_values[3*i], m_values[3*i+1], m_values[3*i+2]));
            else 
                ps.push_back(PointType(m_values[2*i], m_values[2*i+1]));
        }

        fin.close();
    }
예제 #5
0
FilterContext
CentroidFilter::push(FeatureList& features, FilterContext& context )
{
    for( FeatureList::iterator i = features.begin(); i != features.end(); ++i )
    {
        Feature* f = i->get();
        
        Geometry* geom = f->getGeometry();
        if ( !geom )
            continue;

        PointSet* newGeom = new PointSet();
        newGeom->push_back( geom->getBounds().center() );

        f->setGeometry( newGeom );
    }

    return context;
}
예제 #6
0
void GradientDescent<DIM, POS, VAL>::optimize(PointSet<DIM, POS, VAL>& _pts)
{
	PointSet<DIM, POS, POS> data = _pts;
	
	int iSz = _pts.size();
	
	for(int d=0; d<DIM; d++)
	{
		Vector<DIM, POS> shift;
		shift[d] += m_shift;
			
		for(int i=0; i<iSz; i++)
		{
			data.push_back(Point<DIM, POS, POS>(_pts[i].pos() + shift, 0));
		}
	}
	
	evalFunction(data);

	m_max = 0.0;
	m_mean = 0.0;
	if(iSz != 0)
	{
		for(int i=0; i<iSz; i++)
		{
			Vector<DIM, POS> motion;
			
			for(int d=0; d<DIM; d++)
			{
				POS p = (data[i].val() - data[i+iSz*(d+1)].val()) / m_shift;
				_pts[i].pos()[d] -= p;
				motion[d] = p;
			}
			
			POS norm = motion.norm();
			m_mean += norm;
			if(m_max < norm) m_max = norm;
		}
		m_mean /= iSz;
	}
}