Пример #1
0
int Traj_GmxTrX::readFrame(int set, Frame& frameIn) {
    file_.Seek( (frameSize_ * set) + headerBytes_ );
    // Read box info
    if (box_size_ > 0) {
        if (ReadBox( frameIn.bAddress() )) return 1;
    }
    // Blank read past virial/pressure tensor
    file_.Seek( file_.Tell() + vir_size_ + pres_size_ );
    // Read coordinates
    if (x_size_ > 0) {
        if (ReadAtomVector(frameIn.xAddress(), x_size_)) {
            mprinterr("Error: Reading TRX coords frame %i\n", set+1);
            return 1;
        }
    }
    // Read velocities
    if (v_size_ > 0) {
        if (ReadAtomVector(frameIn.vAddress(), v_size_)) {
            mprinterr("Error: Reading TRX velocities frame %i\n", set+1);
            return 1;
        }
    }

    return 0;
}
Пример #2
0
void GetCellPossibilities(int X, int Y, int PuzzleMatrix[9][9], std::vector<int> &CellInfo)
{
    if (PuzzleMatrix[X][Y] != 0) return;

    std::vector<int> Data;
    int BoxMatrix[3][3] = {{0}};
    int RowLineMatrix[9] = {0};
    int ColumnLineMatrix[9] = {0};
    int RowBoxIndex = 0, ColumnBoxIndex = 0;
    GetBoxIndex(X, Y, RowBoxIndex, ColumnBoxIndex);

    ReadRowLine(Y, PuzzleMatrix, RowLineMatrix);
    ReadColumnLine(X, PuzzleMatrix, ColumnLineMatrix);
    ReadBox(RowBoxIndex, ColumnBoxIndex, PuzzleMatrix, BoxMatrix);

    for (int I = 0; I < 9; ++I)
    {
        if (BoxMatrix[I / 3][I % 3] != 0) Data.push_back(BoxMatrix[I / 3][I % 3]);
        if (RowLineMatrix[I] != 0) Data.push_back(RowLineMatrix[I]);
        if (ColumnLineMatrix[I] != 0) Data.push_back(ColumnLineMatrix[I]);
    }

    std::sort(Data.begin(), Data.end());
    Data.erase(std::unique(Data.begin(), Data.end()), Data.end());

    for (int I = 1, J = 0; I < 10; ++I, ++J)
    {
        if (std::find(Data.begin(), Data.end(), I) == Data.end())
        {
            CellInfo.push_back(I);
        }
    }
}
Пример #3
0
int GDALJP2Box::ReadFirstChild( GDALJP2Box *poSuperBox )

{
    szBoxType[0] = '\0';
    if( !poSuperBox->IsSuperBox() )
        return FALSE;

    return SetOffset( poSuperBox->nDataOffset ) && ReadBox();
}
Пример #4
0
/** Prepare trajectory for reading. Determine number of frames. */
int Traj_GmxTrX::setupTrajin(FileName const& fname, Topology* trajParm)
{
    int nframes = 0;
    if (file_.SetupRead( fname, debug_ )) return TRAJIN_ERR;
    // Open and read in header
    if ( file_.OpenFile() ) return TRAJIN_ERR;
    ReadTrxHeader();
    if (debug_ > 0) GmxInfo(); // DEBUG
    // Warn if # atoms in parm does not match
    if (trajParm->Natom() != natoms_) {
        mprinterr("Error: # atoms in TRX file (%i) does not match # atoms in parm %s (%i)\n",
                  natoms_, trajParm->c_str(), trajParm->Natom());
        return TRAJIN_ERR;
    }
    // If float precision, create temp array. Temp array not needed for double reads.
    if (precision_ == sizeof(float)) {
        if (farray_ != 0) delete[] farray_;
        farray_ = new float[ natom3_ ];
    }
    // Attempt to determine # of frames in traj
    headerBytes_ = (size_t)file_.Tell();
    frameSize_ = headerBytes_ + (size_t)box_size_ + (size_t)vir_size_ + (size_t)pres_size_ +
                 (size_t)x_size_   + (size_t)v_size_ +   (size_t)f_size_;
    //(size_t)ir_size_ + (size_t)e_size_ + (size_t)top_size_ +
    //(size_t)sym_size_;
    size_t file_size = (size_t)file_.UncompressedSize();
    if (file_size > 0) {
        nframes = (int)(file_size / frameSize_);
        if ( (file_size % frameSize_) != 0 ) {
            mprintf("Warning: %s: Number of frames in TRX file could not be accurately determined.\n"
                    "Warning:   Will attempt to read %i frames.\n", file_.Filename().base(), nframes);
        }
    } else {
        mprintf("Warning: Uncompressed size could not be determined. This is normal for\n");
        mprintf("Warning: bzip2 files. Cannot check # of frames. Frames will be read until EOF.\n");
        nframes = TRAJIN_UNK;
    }
    // Load box info so that it can be checked.
    double box[6];
    box[0]=0.0;
    box[1]=0.0;
    box[2]=0.0;
    box[3]=0.0;
    box[4]=0.0;
    box[5]=0.0;
    if ( box_size_ > 0 ) {
        if ( ReadBox( box ) ) return TRAJIN_ERR;
    }
    // Set traj info - No time or temperature
    SetCoordInfo( CoordinateInfo(Box(box), (v_size_ > 0), false, false) );
    closeTraj();
    return nframes;
}
Пример #5
0
int CIFStockLotbox::ReadData(QSettings& set)
{
    set.beginGroup("LOTBOX");
    m_Lotbox.SetBoxNum(set.value("box_num").toInt());
    m_Lotbox.SetAllNum( set.value("all_num").toInt());
    m_Lotbox.SetAllSum(set.value("all_sum").toInt());
    m_Lotbox.SetMinFace(set.value("min_face").toInt());
    m_Lotbox.SetMaxFace(set.value("max_face").toInt());
    set.endGroup();

    for (int i=0;i<m_Lotbox.GetBoxNum();i++)
    {
        ReadBox(set, i);
    }

    return 1;
}
Пример #6
0
int GDALJP2Box::ReadNext()

{
    return SetOffset( nBoxOffset + nBoxLength ) && ReadBox();
}
Пример #7
0
int GDALJP2Box::ReadFirst()

{
    return SetOffset(0) && ReadBox();
}
Пример #8
0
void SceneImporter<real>::ReadScene( std::istream& stream, Scene<real>& oScene )
{
	// Read the 'Scene' token
	ReadNextExactToken( stream, "Scene" );
	ReadNextExactToken( stream, "{" );

	// Read scene components
	std::string token = ReadNextToken( stream );

	while( token != "}" )
	{
		if ( token == "SceneInfo" )
		{
			ReadNextExactToken( stream, "(" );
			ReadSceneInfo( stream, oScene );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );
		}
		else if ( token == "TurntableCamera" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Camera<real>* camera = ReadTurntableCamera( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( camera, true );
		}
		else if ( token == "DirectionalLight" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Light<real>* light = ReadDirectionalLight( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( light, true );
		}
		else if ( token == "PointLight" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Light<real>* light = ReadPointLight( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( light, true );
		}
		else if ( token == "SpotLight" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Light<real>* light = ReadSpotLight( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( light, true );
		}
		else if ( token == "BlinnPhongMaterial" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Material* material = ReadBlinnPhongMaterial( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( material, true );
		}
		else if ( token == "EnvironmentMaterial" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Material* material = ReadEnvironmentMaterial( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( material, true );
		}
		else if ( token == "CubeMap" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Texture<real>* cubeMap = ReadCubeMap( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( cubeMap, true );
		}
		else if ( token == "Texture2D" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Texture<real>* texture = ReadTexture2D( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( texture, true );
		}
		else if ( token == "Box" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Node<real>* box = ReadBox( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( box, true );
		}
		else if ( token == "Cone" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Node<real>* cone = ReadCone( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( cone, true );
		}
		else if ( token == "Cylinder" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Node<real>* cylinder = ReadCylinder( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( cylinder, true );
		}
		else if ( token == "Plane" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Node<real>* plane = ReadPlane( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( plane, true );
		}
		else if ( token == "Sphere" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Node<real>* sphere = ReadSphere( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( sphere, true );
		}
		else if ( token == "TriMesh" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Node<real>* triMesh = ReadTriMesh( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( triMesh, true );
		}
		else if ( token == "Node" )
		{
			std::string name = ReadNextToken( stream );
			ReadNextExactToken( stream, "(" );
			Node<real>* node = ReadNode( stream, name );
			ReadNextExactToken( stream, ")" );
			ReadNextExactToken( stream, ";" );

			oScene.AddObject( node, true );
		}
		else
		{
			throw ( std::string( "Unknown token: " ) + token ).c_str();
		}

		token = ReadNextToken( stream );
	}

	// Read scene ending token
	ReadNextExactToken( stream, ";" );
}
Пример #9
0
	PageAttrs::PageAttrs(PageAttrs *pAttrs, Dict *pDict)
	{
		Object obj1;

		if (pAttrs) // Предыдущие настройки
		{
			m_oMediaBox    = pAttrs->m_oMediaBox;
			m_pCropBox     = pAttrs->m_pCropBox;
			m_bHaveCropBox = pAttrs->m_bHaveCropBox;
			m_nRotate      = pAttrs->m_nRotate;
			pAttrs->m_oResources.Copy(&m_oResources);
		}
		else // Настройки по умолчанию
		{
			m_oMediaBox.m_dLeft    = 0;
			m_oMediaBox.m_dBottom  = 0;
			m_oMediaBox.m_dRight   = 612;
			m_oMediaBox.m_dTop     = 792;

			m_pCropBox.m_dLeft = m_pCropBox.m_dBottom = m_pCropBox.m_dRight = m_pCropBox.m_dTop = 0;
			m_bHaveCropBox = false;
			m_nRotate = 0;
			m_oResources.InitNull();
		}

		// MediaBox
		ReadBox(pDict, "MediaBox", &m_oMediaBox);

		// CropBox
		if (ReadBox(pDict, "CropBox", &m_pCropBox))
		{
			m_bHaveCropBox = true;
		}
		if (!m_bHaveCropBox)
		{
			m_pCropBox = m_oMediaBox;
		}

		// Остальные
		m_oBleedBox = m_pCropBox;
		ReadBox(pDict, "BleedBox", &m_oBleedBox);

		m_oTrimBox = m_pCropBox;
		ReadBox(pDict, "TrimBox", &m_oTrimBox);

		m_oArtBox = m_pCropBox;
		ReadBox(pDict, "ArtBox", &m_oArtBox);

		// Подгоняем размеры под m_oMediaBox 
		m_pCropBox.ClipTo(&m_oMediaBox);
		m_oBleedBox.ClipTo(&m_oMediaBox);
		m_oTrimBox.ClipTo(&m_oMediaBox);
		m_oArtBox.ClipTo(&m_oMediaBox);

		// Поворот
		Object oTemp;
		pDict->Search("Rotate", &oTemp);
		if (oTemp.IsInt())
		{
			m_nRotate = oTemp.GetInt();
		}
		oTemp.Free();
		while (m_nRotate < 0)
		{
			m_nRotate += 360;
		}
		while (m_nRotate >= 360)
		{
			m_nRotate -= 360;
		}

		pDict->Search("LastModified", &m_oLastModified);
		pDict->Search("BoxColorInfo", &m_oBoxColorInfo);
		pDict->Search("Group", &m_oGroup);
		pDict->Search("Metadata", &m_oMetadata);
		pDict->Search("PieceInfo", &m_oPieceInfo);
		pDict->Search("SeparationInfo", &m_oSeparationInfo);

		// Resources
		pDict->Search("Resources", &oTemp);
		if (oTemp.IsDict())
		{
			m_oResources.Free();
			oTemp.Copy(&m_oResources);
		}
		oTemp.Free();
	}