Esempio n. 1
0
void PredWrapper::init( const Point3HVec& pointVec, Point3 ptInfty )
{
	_pointArr	= &pointVec[0]; 
	_pointNum	= pointVec.size(); 
	_infIdx		= _pointNum; 
	_ptInfty	= ptInfty; 

    exactinit();
}
Esempio n. 2
0
void Application::readPoints()
{
    assert( _pointVec.empty() && "Input point vector not empty!" );

    Config& config = getConfig();

    std::ifstream inFile( config._inFilename.c_str() );

    if ( !inFile )
    {
        std::cout << "Error opening input file: " << config._inFilename << " !!!\n";
        exit( 1 );
    }

    ////
    // Read input points
    ////

    std::string strVal;
    Point3 point;
    Point3HVec inPointVec;
    Point3Set pointSet;
    int idx         = 0;
    int orgCount    = 0;
    float val       = 0.0f;
    float minVal    = 999.0f;
    float maxVal    = -999.0f;

    while ( inFile >> strVal )
    {
        std::istringstream iss( strVal );

        // Read a coordinate
        iss >> val;
        point._p[ idx ] = val;
        ++idx;

        // Compare bounds
        if ( val < minVal ) minVal = val;
        if ( val > maxVal ) maxVal = val;

        // Read a point
        if ( 3 == idx )
        {
            idx = 0;

            ++orgCount;

            // Check if point unique
            if ( pointSet.end() == pointSet.find( point ) )
            {
                pointSet.insert( point );
                inPointVec.push_back( point );
            }
        }
    }

    ////
    // Check for duplicate points
    ////

    const int dupCount = orgCount - ( int ) inPointVec.size();

    if ( dupCount > 0 )
    {
        std::cout << dupCount << " duplicate points in input file!" << std::endl;
    }

    ////
    // Scale points and store them
    ////

    pointSet.clear();

    // Iterate input points
    for ( int ip = 0; ip < ( int ) inPointVec.size(); ++ip )
    {
        Point3& inPt = inPointVec[ ip ];

        // Iterate coordinates
        for ( int vi = 0; vi < 3; ++vi )
        {
            const RealType inVal  = inPt._p[ vi ];
            const RealType outVal = scalePoint( ( RealType ) config._gridSize, minVal, maxVal, inVal );
            inPt._p[ vi ]         = outVal;
        }

        // Check if point unique
        if ( pointSet.end() == pointSet.find( inPt ) )
        {
            pointSet.insert( inPt );
            _pointVec.push_back( inPt );
        }
    }

    // Update
    config._pointNum = _pointVec.size();

    cout << "Unique points: " << _pointVec.size() << endl;

    return;
}