예제 #1
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
std::vector<int> TriangleOps::getNodeIndices(DREAM3D::SurfaceMesh::Face_t &t, int32_t* faceLabel, int label)
{
  std::vector<int > tNodes(3);
  int idx = TriangleOps::getLabelIndex(faceLabel, label);
  if (idx == 1)
  {
    tNodes[0] = t.verts[2];
    tNodes[1] = t.verts[1];
    tNodes[2] = t.verts[0];
  }
  else
  {
    tNodes[0] = t.verts[0];
    tNodes[1] = t.verts[1];
    tNodes[2] = t.verts[2];
  }
  return tNodes;
}
예제 #2
0
bool DataHDDIOTensorQuantized::_readIdsRanksScales( )
{
    assert( _nodesIds && _ranks && _scales );

    const size_t size = _nodesIds->size();

    if( _ranks->size()  != size ||
        _scales->size() != size )
    {
        LOG_ERROR << "Size of _ranks or _scales is incorect " << std::endl;
        return false;
    }

    memset( &((*_nodesIds)[ 0]), 0, size*sizeof((*_nodesIds)[0]));
    memset( &((*_ranks)[    0]), 0, size*sizeof((*_ranks)[   0]));
    memset( &((*_scales)[   0]), 0, size*sizeof((*_scales)[  0]));

    std::vector<NodeId> tNodes(  size );
    std::vector<byte>   tRanks(  size );
    std::vector<float>  tScales( size );
    memset( &tNodes[ 0], 0, tNodes.size() *sizeof(tNodes[ 0]));
    memset( &tRanks[ 0], 0, tRanks.size() *sizeof(tRanks[ 0]));
    memset( &tScales[0], 0, tScales.size()*sizeof(tScales[0]));

    std::string fName = getRanksFileName();

// Read ranks, build ids
    std::vector<double> data( size );
    const uint32_t bytesToRead = data.size()*sizeof(data[0]);

    util::InFile inFile;
    if( !inFile.open( fName, std::ios::binary, true ) ||
        !inFile.read( bytesToRead, bytesToRead, &data[0] ))
        return false;

    byte maxRank = 0;
    for( size_t i = 0; i < data.size(); ++i )
    {
        int32_t rank = static_cast<int32_t>( data[i]+0.5 );
        if( rank < 0 || rank > 255 )
        {
            LOG_ERROR << "Incorrect rank? (" << rank << ")" << std::endl;
            break;
        }
        if( rank > 0 )
        {
            tNodes[i] = i+1;
            tRanks[i] = rank;
            if( maxRank < rank )
                maxRank = rank;
        }
    }
    setMaxRankDim( maxRank );

// Read scales
    if( !inFile.read( bytesToRead*4, bytesToRead, &data[0] ))
        return false;

    for( size_t i = 0; i < data.size(); ++i )
    {
        if( tRanks[i] > 0 )
            tScales[i] = log2f( 1.0 + data[i] ) / 127.f;
    }

// Fix wrong order from TENSOR iteration
    uint32_t side    = 1;
    uint32_t current = 0;
    uint32_t start   = 0;
    std::cout << "size: " << size << std::endl;
    for( size_t i = 0; i < size; ++i )
    {
        if( current == side*side*side )
        {
            start   = VolumeTreeBase::getChild( start );
            side   *= 2;
            current = 0;
        }
        Vec3_ui32 p = VolumeTreeBase::getIndexPosition( current++ );
        uint32_t pos = start + (p.z*side+p.y)*side+p.x;
//        std::cout << "i: " << i <<  " pos: " << pos << " current: " << (current-1) << " side: " << side << std::endl;
        assert( pos < size );

        (*_nodesIds)[i] = tNodes[ pos];
        (*_ranks)[   i] = tRanks[ pos];
        (*_scales)[  i] = tScales[pos];
    }

#if 0 // print first elements of rank array
    for( size_t i = 0; i < 1+8+64; ++i )
    {
        std::cout << "i: " << i << " id: " << (int)nodes[i].id << " rank: " << (int)ranks[i] << " scale: " << scales[i] << std::endl;
    }
#endif
    return true;
}