void CPHMovementControl::Load (LPCSTR section){ //capture //strcpy(m_capture_bone,pSettings->r_string(section,"capture_bone")); Fbox bb; // m_PhysicMovementControl: BOX Fvector vBOX1_center= pSettings->r_fvector3 (section,"ph_box1_center" ); Fvector vBOX1_size = pSettings->r_fvector3 (section,"ph_box1_size" ); bb.set (vBOX1_center,vBOX1_center); bb.grow(vBOX1_size); SetBox (1,bb); // m_PhysicMovementControl: BOX Fvector vBOX0_center= pSettings->r_fvector3 (section,"ph_box0_center" ); Fvector vBOX0_size = pSettings->r_fvector3 (section,"ph_box0_size" ); bb.set (vBOX0_center,vBOX0_center); bb.grow(vBOX0_size); SetBox (0,bb); //// m_PhysicMovementControl: Foots //Fvector vFOOT_center= pSettings->r_fvector3 (section,"ph_foot_center" ); //Fvector vFOOT_size = pSettings->r_fvector3 (section,"ph_foot_size" ); //bb.set (vFOOT_center,vFOOT_center); bb.grow(vFOOT_size); //SetFoots (vFOOT_center,vFOOT_size); // m_PhysicMovementControl: Crash speed and mass float cs_min = pSettings->r_float (section,"ph_crash_speed_min" ); float cs_max = pSettings->r_float (section,"ph_crash_speed_max" ); float mass = pSettings->r_float (section,"ph_mass" ); xr_token retrictor_types[]={ { "actor", CPHCharacter::rtActor}, { "medium_monster", CPHCharacter::rtMonsterMedium}, { "stalker", CPHCharacter::rtStalker }, { "none", CPHCharacter::rtNone }, { 0, 0} }; if(pSettings->line_exist(section,"actor_restrictor")) SetRestrictionType(CPHCharacter::ERestrictionType(pSettings->r_token(section,"actor_restrictor",retrictor_types))); fCollisionDamageFactor=READ_IF_EXISTS(pSettings,r_float,section,"ph_collision_damage_factor",fCollisionDamageFactor); R_ASSERT3(fCollisionDamageFactor<=1.f,"ph_collision_damage_factor >1.",section); SetCrashSpeeds (cs_min,cs_max); SetMass (mass); // m_PhysicMovementControl: Frictions //float af, gf, wf; //af = pSettings->r_float (section,"ph_friction_air" ); //gf = pSettings->r_float (section,"ph_friction_ground"); //wf = pSettings->r_float (section,"ph_friction_wall" ); //SetFriction (af,wf,gf); // BOX activate // ActivateBox (0); }
// If the environment is interactive, a global will be defined. Otherwise, a global will be // defined only if it is not already defined. One will be returned if the global can't be defined. int_t EnvironmentDefine(FObject env, FObject symid, FObject val) { FAssert(EnvironmentP(env)); FAssert(SymbolP(symid) || IdentifierP(symid)); if (IdentifierP(symid)) symid = AsIdentifier(symid)->Symbol; FObject gl = EnvironmentBind(env, symid); FAssert(GlobalP(gl)); if (AsEnvironment(env)->Interactive == FalseObject) { if (AsGlobal(gl)->State != GlobalUndefined) return(1); } else if (AsGlobal(gl)->State == GlobalImported || AsGlobal(gl)->State == GlobalImportedModified) { FAssert(BoxP(AsGlobal(gl)->Box)); // AsGlobal(gl)->Box = MakeBox(NoValueObject); Modify(FGlobal, gl, Box, MakeBox(NoValueObject)); } FAssert(BoxP(AsGlobal(gl)->Box)); SetBox(AsGlobal(gl)->Box, val); // AsGlobal(gl)->State = GlobalDefined; Modify(FGlobal, gl, State, GlobalDefined); return(0); }
//--------------------------------------------------------------------------- // Constructor/Destructor LuminaireObject::LuminaireObject() : mpBlock(NULL) { GetLuminaireDesc()->MakeAutoParamBlocks(this); SetBox(const_cast<Box3&>(mDefBoxSize)); dumFlags &= ~MESH_VALID; }
/* * Open the netcdf file, read all dimension and variable IDs, close. * Return the number of frames in the file. */ int Traj_AmberNetcdf::setupTrajin(std::string const& fname, Topology* trajParm) { filename_.SetFileNameWithExpansion( fname ); if (openTrajin()) return TRAJIN_ERR; // Sanity check - Make sure this is a Netcdf trajectory if ( GetNetcdfConventions() != NC_AMBERTRAJ ) { mprinterr("Error: Netcdf file %s conventions do not include \"AMBER\"\n",filename_.base()); return TRAJIN_ERR; } // Get global attributes std::string attrText = GetAttrText("ConventionVersion"); if ( attrText != "1.0") mprintf("Warning: Netcdf file %s has ConventionVersion that is not 1.0 (%s)\n", filename_.base(), attrText.c_str()); // Get title SetTitle( GetAttrText("title") ); // Get Frame info if ( SetupFrame()!=0 ) return TRAJIN_ERR; // Setup Coordinates/Velocities if ( SetupCoordsVelo()!=0 ) return TRAJIN_ERR; SetVelocity( HasVelocities() ); // Check that specified number of atoms matches expected number. if (Ncatom() != trajParm->Natom()) { mprinterr("Error: Number of atoms in NetCDF file %s (%i) does not\n", filename_.base(),Ncatom()); mprinterr(" match number in associated parmtop (%i)!\n",trajParm->Natom()); return TRAJIN_ERR; } // Setup Time if ( SetupTime()!=0 ) return TRAJIN_ERR; // Box info double boxcrd[6]; if (SetupBox(boxcrd, NC_AMBERTRAJ) == 1) // 1 indicates an error return TRAJIN_ERR; SetBox( boxcrd ); // Replica Temperatures - Allowed to fail silently if (SetupTemperature() == 0) SetTemperature( true ); // Replica Dimensions if ( SetupMultiD() == -1 ) return TRAJIN_ERR; // NOTE: TO BE ADDED // labelDID; //int cell_spatialDID, cell_angularDID; //int spatialVID, cell_spatialVID, cell_angularVID; // Amber Netcdf coords are float. Allocate a float array for converting // float to/from double. if (Coord_ != 0) delete[] Coord_; Coord_ = new float[ Ncatom3() ]; if (Veloc_ != 0) delete[] Veloc_; if (velocityVID_ != -1) Veloc_ = new float[ Ncatom3() ]; else Veloc_ = 0; if (debug_>1) NetcdfDebug(); closeTraj(); // NetCDF files are always seekable SetSeekable( true ); return Ncframe(); }
CInputField::CInputField(const std::string &t, EInputType e, int max, char out) : m_Text(t), m_iMaxChars(max), m_cOut(out), m_eInputType(e), m_StartPos(0), m_CursorPos(0) { // SetFColors(COLOR_YELLOW, COLOR_RED); // SetDFColors(COLOR_WHITE, COLOR_RED); SetMinHeight(3); SetBox(true); }
void TBox::CreateSpriteBox(TGfxTexture * pTexture) { m_bIsDrawable = true; m_pSprite = GfxSpriteCreate(pTexture); int iSizeX = GfxSpriteGetSizeX(m_pSprite); int iSizeY = GfxSpriteGetSizeY(m_pSprite); GfxSpriteSetFilteringEnabled(m_pSprite, false); GfxSpriteSetPivot(m_pSprite, iSizeX / 2.0f, iSizeY / 2.0f); SetBox(TGfxVec2(0.0f, 0.0f), (float)iSizeX, (float)iSizeY); }
void TBox::CreateSpriteBox(TGfxTexture * pTexture, const int iTextureSize, int iTileX, int iTileY, int iTextureSizeY) { iTextureSizeY = (iTextureSizeY != 0) ? iTextureSizeY : iTextureSize; m_bIsDrawable = true; m_pSprite = GfxSpriteCreate(pTexture); GfxSpriteSetFilteringEnabled(m_pSprite, false); GfxSpriteSetCutout(m_pSprite, iTileX*iTextureSize, iTileY*iTextureSizeY, iTextureSize, iTextureSizeY); GfxSpriteSetPivot(m_pSprite, iTextureSize / 2.0f, iTextureSizeY / 2.0f); SetBox(TGfxVec2(0.0f, 0.0f), (float)iTextureSize, (float)iTextureSizeY); }
void GBoxAA::ExpandBox( GBoxAA &Box ) { if( vecMin.X > Box.vecMin.X ) vecMin.X = Box.vecMin.X; if( vecMin.Y > Box.vecMin.Y ) vecMin.Y = Box.vecMin.Y; if( vecMin.Z > Box.vecMin.Z ) vecMin.Z = Box.vecMin.Z; if( vecMax.X < Box.vecMax.X ) vecMax.X = Box.vecMax.X; if( vecMax.Y < Box.vecMax.Y ) vecMax.Y = Box.vecMax.Y; if( vecMax.Z < Box.vecMax.Z ) vecMax.Z = Box.vecMax.Z; SetBox( &vecMin, &vecMax ); }
void GBoxAA::ExpandBox( SVector &vMin, SVector &vMax ) { if( vecMin.X > vMin.X ) vecMin.X = vMin.X; if( vecMin.Y > vMin.Y ) vecMin.Y = vMin.Y; if( vecMin.Z > vMin.Z ) vecMin.Z = vMin.Z; if( vecMax.X < vMax.X ) vecMax.X = vMax.X; if( vecMax.Y < vMax.Y ) vecMax.Y = vMax.Y; if( vecMax.Z < vMax.Z ) vecMax.Z = vMax.Z; SetBox( &vecMin, &vecMax ); }
void TBox::CreateTextBox(const char * pName) { m_bIsDrawable = true; m_pTextSprite = GfxTextSpriteCreate(); GfxSpriteSetFilteringEnabled(m_pTextSprite, false); GfxTextSpritePrintf(m_pTextSprite, pName); int iSizeX = GfxSpriteGetSizeX(m_pTextSprite); int iSizeY = GfxSpriteGetSizeY(m_pTextSprite); GfxSpriteSetPivot(m_pTextSprite, iSizeX / 2.0f, iSizeY / 2.0f); SetBox(TGfxVec2(0.0f, 0.0f), (float)iSizeX, (float)iSizeY); }
// Sizes and positions an element within its parent. bool ElementUtilities::PositionElement(Element* element, const Vector2f& offset) { Element* parent = element->GetParentNode(); if (parent == NULL) return false; SetBox(element); SetElementOffset(element, offset); return true; }
BoxSetter::BoxSetter(const std::string& in, const std::string& out, const std::string& box, const PoDoFo::PdfRect& rect) :m_box(box), m_rect(rect) { PoDoFo::PdfMemDocument* source = new PoDoFo::PdfMemDocument(in.c_str()); int pcount(source->GetPageCount()); for ( int i = 0; i < pcount ; ++i ) { SetBox(source->GetPage ( i )); } source->Write(out.c_str()); }
void StageObject::InitBox(const vector<const Box_t*>& vec_group) { Box_t temp_box(*vec_group.front()); for (auto box : vec_group) { temp_box += *box; } //LOGE("[STAGEOBJECT][InitBox] final pos %s ",temp_box.position.Print().c_str()); //LOGE("[STAGEOBJECT][InitBox] final hv %s ",temp_box.halfVec.Print().c_str()); SetBox(temp_box); }
/** Set up netcdf restart file for reading, get all variable and dimension IDs. * Also check number of atoms against associated parmtop. */ int Traj_AmberRestartNC::setupTrajin(std::string const& fname, Topology* trajParm) { filename_.SetFileNameWithExpansion( fname ); if (openTrajin()) return TRAJIN_ERR; // Sanity check - Make sure this is a Netcdf restart if ( GetNetcdfConventions() != NC_AMBERRESTART ) { mprinterr("Error: Netcdf restart file %s conventions do not include \"AMBERRESTART\"\n", filename_.base()); return TRAJIN_ERR; } // Get global attributes std::string attrText = GetAttrText("ConventionVersion"); if (attrText!="1.0") mprintf("Warning: Netcdf restart file %s has ConventionVersion that is not 1.0 (%s)\n", filename_.base(), attrText.c_str()); // Get title SetTitle( GetAttrText("title") ); // Setup Coordinates/Velocities if ( SetupCoordsVelo()!=0 ) return TRAJIN_ERR; SetVelocity( HasVelocities() ); // Check that specified number of atoms matches expected number. if (Ncatom() != trajParm->Natom()) { mprinterr("Error: Number of atoms in NetCDF restart file %s (%i) does not\n", filename_.base(), Ncatom()); mprinterr(" match number in associated parmtop (%i)!\n",trajParm->Natom()); return TRAJIN_ERR; } // Setup Time if ( SetupTime()!=0 ) return TRAJIN_ERR; // Box info double boxcrd[6]; if (SetupBox(boxcrd, NC_AMBERRESTART) == 1) // 1 indicates an error return TRAJIN_ERR; SetBox( boxcrd ); // Replica Temperatures - allowed to fail silently if (SetupTemperature() == 0) SetTemperature( true ); if ( SetupMultiD() == -1 ) return TRAJIN_ERR; // NOTE: TO BE ADDED // labelDID; //int cell_spatialDID, cell_angularDID; //int spatialVID, cell_spatialVID, cell_angularVID; closeTraj(); // Only 1 frame for NC restarts return 1; }
/** * @brief FourBlocks sets the BBox as a quadrant of a given size. * @param width is horizontal size in pixels. * @param height is the vertical size in pixels. * @param i is the i-th quadrant. */ void FourBlocks(int width, int height, int i) { int halfWidth = width >> 1; int halfHeight = height >> 1; int dataX[] = {0, 0, halfWidth, halfWidth}; int dataY[] = {0, halfHeight, 0, halfHeight}; if((width % 2) == 1) { halfWidth++; } if((height % 2) == 1) { halfHeight++; } SetBox(dataX[i], dataX[i] + halfWidth, dataY[i], dataY[i] + halfHeight, 0, 1, width, height, 1); // print(); }
// Sizes an element, and positions it within its parent offset from the borders of its content area. bool ElementUtilities::PositionElement(Element* element, const Vector2f& offset, PositionAnchor anchor) { Element* parent = element->GetParentNode(); if (parent == NULL) return false; SetBox(element); Vector2f containing_block = element->GetParentNode()->GetBox().GetSize(Box::CONTENT); Vector2f element_block = element->GetBox().GetSize(Box::MARGIN); Vector2f resolved_offset = offset; if (anchor & RIGHT) resolved_offset.x = containing_block.x - (element_block.x + offset.x); if (anchor & BOTTOM) resolved_offset.y = containing_block.y - (element_block.y + offset.y); SetElementOffset(element, resolved_offset); return true; }
// The value of a global is set; if it is not already defined it will be defined first. FObject EnvironmentSet(FObject env, FObject sym, FObject val) { FObject gl = EnvironmentBind(env, sym); FAssert(GlobalP(gl)); FAssert(BoxP(AsGlobal(gl)->Box)); SetBox(AsGlobal(gl)->Box, val); if (AsGlobal(gl)->State == GlobalUndefined) { // AsGlobal(gl)->State = GlobalDefined; Modify(FGlobal, gl, State, GlobalDefined); } else { FAssert(AsGlobal(gl)->State == GlobalDefined); // AsGlobal(gl)->State = GlobalModified; Modify(FGlobal, gl, State, GlobalModified); } return(gl); }
CProgressBar::CProgressBar(float min, float max) : m_fMin(min), m_fMax(max), m_fCurrent(min) { SetMinHeight(3); SetBox(true); }
/** * @brief BBox is a constructor setting the BBox up. * @param width is the maxium horizontal coordinate in pixels. * The minimum is set to 0. * @param height is the maxium vertical coordinate in pixels. * The minimum is set to 0. * @param frames is the maxium temporal coordinate in pixels. * The minimum is set to 0. */ BBox(int width, int height, int frames) { SetBox(0, width, 0, height, 0, frames, width, height, frames); }
/** * @brief BBox is a constructor setting the BBox up. * @param x0 is the minimum horizontal coordinate in pixels. * @param x1 is the maximum horizontal coordinate in pixels. * @param y0 is the minimum vertical coordinate in pixels. * @param y1 is the maximum vertical coordinate in pixels. * @param width is the horizontal size in pixels. * @param height is the vertical size in pixels. */ BBox(int x0, int x1, int y0, int y1, int width, int height) { SetBox(x0, x1, y0, y1, 0, 1, width, height, 1); }
/** * @brief BBox is a constructor setting the BBox up. * @param x0 is the minimum horizontal coordinate in pixels. * @param x1 is the maximum horizontal coordinate in pixels. * @param y0 is the minimum vertical coordinate in pixels. * @param y1 is the maximum vertical coordinate in pixels. */ BBox(int x0, int x1, int y0, int y1) { SetBox(x0, x1, y0, y1, 0, 1, -1, -1, 1); }
/****************************************************************************** * 関数名:Stage1 * * 引数 : * 戻り値: * 説明 : ******************************************************************************/ void Stage1( void ) { //field/////////////////////////////////////////////////////////////////////// SetField( D3DXVECTOR3( 0.0f , 0.0f , 0 ) ); SetField( D3DXVECTOR3( 0.0f , 0.0f , 400 ) ); SetField( D3DXVECTOR3( 0.0f , 0.0f , 900 ) ); SetField( D3DXVECTOR3( 0.0f , 0.0f , 1300 ) ); SetField( D3DXVECTOR3( 0.0f , 0.0f , 1700 ) ); SetField( D3DXVECTOR3( 0.0f , 0.0f , 2200 ) ); SetField( D3DXVECTOR3( 0.0f , 0.0f , 2800 ) ); SetField(D3DXVECTOR3( 0.0f , 0.0f , 3500 )); //Box///////////////////////////////////////////////////////////////////////// SetBox( D3DXVECTOR3( 50.0f ,20 , 0.0f ) , BOX_NOMAL ); SetBox( D3DXVECTOR3( -50.0f , 20 , 100.0f ) , BOX_SPRING ); SetBox( D3DXVECTOR3( - 50.0f ,20 , 900.0f ) , BOX_NOMAL ); SetBox( D3DXVECTOR3( 50.0f ,20 , 1340.0f ) , BOX_NOMAL ); SetBox( D3DXVECTOR3( 50.0f ,20 , 1380.0f ) , BOX_NOMAL ); SetBox( D3DXVECTOR3( 10.0f ,20 , 1380.0f ) , BOX_NOMAL ); SetBox( D3DXVECTOR3( 50.0f ,20 , 2800.0f ) , BOX_NOMAL ); SetBox( D3DXVECTOR3( 10.0f ,20 , 2800.0f ) , BOX_NOMAL ); SetBox( D3DXVECTOR3( 50.0f ,20 , 2840.0f ) , BOX_NOMAL ); SetBox( D3DXVECTOR3( 10.0f ,20 , 2840.0f ) , BOX_NOMAL ); SetBox( D3DXVECTOR3( 30.0f ,60 , 2820.0f ) , BOX_NOMAL ); //Obstacl///////////////////////////////////////////////////////////////////// SetObstacl( D3DXVECTOR3( 0.0f ,20 , 50.0f ) , OBSTACL_NOMAL ); SetObstacl( D3DXVECTOR3( -50.0f , 20 , 2500.0f ) , OBSTACL_NOMAL ); SetObstacl( D3DXVECTOR3( 0.0f , -20 , 3100.0f ) , OBSTACL_NOMAL ); SetObstacl( D3DXVECTOR3( 0.0f , -20 , 3200.0f ) , OBSTACL_NOMAL ); SetObstacl( D3DXVECTOR3( 0.0f , -20 , 3300.0f ) , OBSTACL_NOMAL ); //Enemy/////////////////////////////////////////////////////////////////////// SetEnemy( D3DXVECTOR3( 150.0f , 0.0f , 1200.0f ) ); SetEnemy( D3DXVECTOR3( 150.0f , 0.0f , 1500.0f ) ); SetEnemy( D3DXVECTOR3( 0.0f , 0.0f , 1700.0f ) ); //Acorn/////////////////////////////////////////////////////////////////////// SetAcorn( D3DXVECTOR3( 0.0f ,0, - 80.0f ) ); //goal///////////////////////////////////////////////////////////////////// SetGoal( D3DXVECTOR3( 0.0f , 50.0f , 3500 ) ); }
void GBoxAA::Transform( SMatrix *pMat ) { if( pMat==NULL ) return; enum BoxCorner { LeftDownFront = 0, RightDownFront = 1, //1 DRTUPFR = 2, //2 LeftUpFront = 3, //3 DLTDNBK = 4, //4 RightDownBack = 5,//5 RightUpBack = 6,//6 LeftUpBack = 7//7 }; SVector avecVertex[8]; avecVertex[LeftDownFront].X = avecVertex[LeftUpFront].X = avecVertex[DLTDNBK].X = avecVertex[LeftUpBack].X = vecMin.X; avecVertex[LeftDownFront].Y = avecVertex[RightDownFront].Y = avecVertex[DLTDNBK].Y = avecVertex[RightDownBack].Y = vecMin.Y; avecVertex[DLTDNBK].Z = avecVertex[RightDownBack].Z = avecVertex[RightUpBack].Z = avecVertex[LeftUpBack].Z = vecMin.Z; avecVertex[RightDownFront].X = avecVertex[DRTUPFR].X = avecVertex[RightDownBack].X = avecVertex[RightUpBack].X = vecMax.X; avecVertex[LeftUpFront].Y = avecVertex[DRTUPFR].Y = avecVertex[LeftUpBack].Y = avecVertex[RightUpBack].Y = vecMax.Y; avecVertex[LeftDownFront].Z = avecVertex[RightDownFront].Z = avecVertex[DRTUPFR].Z = avecVertex[LeftUpFront].Z = vecMax.Z; avecVertex[LeftDownFront] = pMat->TransformVector( avecVertex[LeftDownFront] ); avecVertex[RightDownFront] = pMat->TransformVector( avecVertex[RightDownFront] ); avecVertex[RightDownBack] = pMat->TransformVector( avecVertex[DLTDNBK] ); avecVertex[LeftUpBack] = pMat->TransformVector( avecVertex[LeftUpBack] ); avecVertex[LeftUpFront] = pMat->TransformVector( avecVertex[LeftUpFront] ); avecVertex[RightUpBack] = pMat->TransformVector( avecVertex[RightUpBack] ); vecMin.X = avecVertex[LeftDownFront].X; vecMin.Y = avecVertex[LeftDownFront].Y; vecMin.Z = avecVertex[LeftDownFront].Z; vecMax.X = avecVertex[LeftDownFront].X; vecMax.Y = avecVertex[LeftDownFront].Y; vecMax.Z = avecVertex[LeftDownFront].Z; if( avecVertex[RightDownFront].X < vecMin.X ) vecMin.X = avecVertex[RightDownFront].X; if( avecVertex[RightDownFront].Y < vecMin.Y ) vecMin.Y = avecVertex[RightDownFront].Y; if( avecVertex[RightDownFront].Z < vecMin.Z ) vecMin.Z = avecVertex[RightDownFront].Z; if( avecVertex[RightDownFront].X > vecMax.X ) vecMax.X = avecVertex[RightDownFront].X; if( avecVertex[RightDownFront].Y > vecMax.Y ) vecMax.Y = avecVertex[RightDownFront].Y; if( avecVertex[RightDownFront].Z > vecMax.Z ) vecMax.Z = avecVertex[RightDownFront].Z; if( avecVertex[RightDownBack].X < vecMin.X ) vecMin.X = avecVertex[RightDownBack].X; if( avecVertex[RightDownBack].Y < vecMin.Y ) vecMin.Y = avecVertex[RightDownBack].Y; if( avecVertex[RightDownBack].Z < vecMin.Z ) vecMin.Z = avecVertex[RightDownBack].Z; if( avecVertex[RightDownBack].X > vecMax.X ) vecMax.X = avecVertex[RightDownBack].X; if( avecVertex[RightDownBack].Y > vecMax.Y ) vecMax.Y = avecVertex[RightDownBack].Y; if( avecVertex[RightDownBack].Z > vecMax.Z ) vecMax.Z = avecVertex[RightDownBack].Z; if( avecVertex[LeftUpBack].X < vecMin.X ) vecMin.X = avecVertex[LeftUpBack].X; if( avecVertex[LeftUpBack].Y < vecMin.Y ) vecMin.Y = avecVertex[LeftUpBack].Y; if( avecVertex[LeftUpBack].Z < vecMin.Z ) vecMin.Z = avecVertex[LeftUpBack].Z; if( avecVertex[LeftUpBack].X > vecMax.X ) vecMax.X = avecVertex[LeftUpBack].X; if( avecVertex[LeftUpBack].Y > vecMax.Y ) vecMax.Y = avecVertex[LeftUpBack].Y; if( avecVertex[LeftUpBack].Z > vecMax.Z ) vecMax.Z = avecVertex[LeftUpBack].Z; if( avecVertex[LeftUpFront].X < vecMin.X ) vecMin.X = avecVertex[LeftUpFront].X; if( avecVertex[LeftUpFront].Y < vecMin.Y ) vecMin.Y = avecVertex[LeftUpFront].Y; if( avecVertex[LeftUpFront].Z < vecMin.Z ) vecMin.Z = avecVertex[LeftUpFront].Z; if( avecVertex[LeftUpFront].X > vecMax.X ) vecMax.X = avecVertex[LeftUpFront].X; if( avecVertex[LeftUpFront].Y > vecMax.Y ) vecMax.Y = avecVertex[LeftUpFront].Y; if( avecVertex[LeftUpFront].Z > vecMax.Z ) vecMax.Z = avecVertex[LeftUpFront].Z; if( avecVertex[RightUpBack].X < vecMin.X ) vecMin.X = avecVertex[RightUpBack].X; if( avecVertex[RightUpBack].Y < vecMin.Y ) vecMin.Y = avecVertex[RightUpBack].Y; if( avecVertex[RightUpBack].Z < vecMin.Z ) vecMin.Z = avecVertex[RightUpBack].Z; if( avecVertex[RightUpBack].X > vecMax.X ) vecMax.X = avecVertex[RightUpBack].X; if( avecVertex[RightUpBack].Y > vecMax.Y ) vecMax.Y = avecVertex[RightUpBack].Y; if( avecVertex[RightUpBack].Z > vecMax.Z ) vecMax.Z = avecVertex[RightUpBack].Z; SetBox( &vecMin, &vecMax ); }
void Style::Set(StyleCategories cat, StyleBox val) { SetBox(cat, val); }
// Traj_AmberCoord::setupTrajin() int Traj_AmberCoord::setupTrajin(std::string const& fname, Topology* trajParm) { // Set up file for reading if (file_.SetupRead( fname, debug_ )) return TRAJIN_ERR; // Attempt to open the file. Read and set the title and titleSize if ( file_.OpenFile() ) return TRAJIN_ERR; std::string title = file_.GetLine(); // Allocate mem to read in frame (plus REMD header if present). REMD // header is checked for when file is IDd. Title size is used in seeking. natom3_ = trajParm->Natom() * 3; file_.SetupFrameBuffer( natom3_, 8, 10, hasREMD_, title.size() ); if (debug_ > 0) { mprintf("Each frame is %u bytes", file_.FrameSize()); if (hasREMD_ != 0) mprintf(" (including REMD header)"); mprintf(".\n"); } // Read the first frame of coordinates if ( file_.ReadFrame() == -1 ) { mprinterr("Error in read of Coords frame 1 of trajectory %s.\n", file_.Filename().base()); return TRAJIN_ERR; } // Check for box coordinates. If present, update the frame size and // reallocate the frame buffer. Box boxInfo; std::string nextLine = file_.GetLine(); if ( !nextLine.empty() ) { if (debug_>0) rprintf("DEBUG: Line after first frame: (%s)\n", nextLine.c_str()); if ( IsRemdHeader(nextLine.c_str()) ) { // REMD header - no box coords numBoxCoords_ = 0; } else { double box[8]; numBoxCoords_ = sscanf(nextLine.c_str(), "%8lf%8lf%8lf%8lf%8lf%8lf%8lf%8lf", box, box+1, box+2, box+3, box+4, box+5, box+6, box+7); if (numBoxCoords_ == -1) { mprinterr("Error: Could not read Box coord line of trajectory %s.",file_.Filename().base()); return TRAJIN_ERR; } else if (numBoxCoords_ == 8) { // Full line of coords was read, no box coords. numBoxCoords_ = 0; } else if (numBoxCoords_ == 3) { // Box lengths only, ortho. or truncated oct. Use default parm angles. box[3] = boxAngle_[0] = trajParm->ParmBox().Alpha(); box[4] = boxAngle_[1] = trajParm->ParmBox().Beta(); box[5] = boxAngle_[2] = trajParm->ParmBox().Gamma(); boxInfo.SetBox( box ); } else if (numBoxCoords_ == 6) { // General triclinic. Set lengths and angles. boxInfo.SetBox( box ); } else { mprinterr("Error: Expect only 3 or 6 box coords, got %i\n", numBoxCoords_); mprinterr("Error: Box line=[%s]\n", nextLine.c_str()); return TRAJIN_ERR; } } // Reallocate frame buffer accordingly file_.ResizeBuffer( numBoxCoords_ ); } // Calculate Frames and determine seekable. If not possible and this is not a // compressed file the trajectory is probably corrupted. Frames will // be read until EOF. int Frames = 0; if (debug_>0) rprintf("Title offset=%lu FrameSize=%lu UncompressedFileSize=%lu\n", title.size(), file_.FrameSize(), file_.UncompressedSize()); off_t title_size = (off_t) title.size(); off_t frame_size = (off_t) file_.FrameSize(); off_t uncompressed_size = file_.UncompressedSize(); off_t file_size = uncompressed_size - title_size; bool seekable = false; if (file_.Compression() != CpptrajFile::NO_COMPRESSION) { // -----==== AMBER TRAJ COMPRESSED ====------ // If the uncompressed size of compressed file is reported as <= 0, // uncompressed size cannot be determined. Read coordinates until // EOF. if (uncompressed_size <= 0) { mprintf("Warning: %s: Uncompressed size of trajectory could not be determined.\n", file_.Filename().base()); if (file_.Compression() == CpptrajFile::BZIP2) mprintf(" (This is normal for bzipped files)\n"); mprintf(" Number of frames could not be calculated.\n"); mprintf(" Frames will be read until EOF.\n"); Frames = TRAJIN_UNK; seekable = false; } else { // Frame calculation for large gzip files if (file_.Compression() == CpptrajFile::GZIP) { // Since this is gzip compressed, if the file_size % frame size != 0, // it could be that the uncompressed filesize > 4GB. Since // ISIZE = uncompressed % 2^32, // try ((file_size + (2^32 * i)) % frame_size) and see if any are 0. if ( (file_size % frame_size) != 0) { // Determine the maximum number of iterations to try based on the // fact that Amber trajectories typically compress about 3x with // gzip. off_t tmpfsize = ((file_size * 4) - uncompressed_size) / 4294967296LL; int maxi = (int) tmpfsize; ++maxi; if (debug_>1) mprintf("\tLooking for uncompressed gzip size > 4GB, %i iterations.\n",maxi); tmpfsize = 0; bool sizeFound = false; for (int i = 0; i < maxi; i++ ) { tmpfsize = (4294967296LL * i) + file_size; if ( (tmpfsize % frame_size) == 0) {sizeFound=true; break;} } if (sizeFound) file_size = tmpfsize; } } if ((file_size % frame_size) == 0) { Frames = (int) (file_size / frame_size); seekable = true; } else { mprintf("Warning: %s: Number of frames in compressed traj could not be determined.\n", file_.Filename().base()); mprintf(" Frames will be read until EOF.\n"); Frames = TRAJIN_UNK; seekable=false; } } } else { // ----==== AMBER TRAJ NOT COMPRESSED ====---- Frames = (int) (file_size / frame_size); if ( (file_size % frame_size) == 0 ) { seekable = true; } else { mprintf("Warning: %s: Could not accurately predict # frames. This usually \n", file_.Filename().base()); mprintf(" indicates a corrupted trajectory. Will attempt to read %i frames.\n", Frames); seekable=false; } } if (debug_>0) rprintf("Atoms: %i FrameSize: %lu TitleSize: %lu NumBox: %i Seekable: %i Frames: %i\n\n", trajParm->Natom(), frame_size, title_size, numBoxCoords_, (int)seekable, Frames); // Close the file file_.CloseFile(); // Set trajectory info SetBox( boxInfo ); SetTemperature( hasREMD_ != 0 ); SetTitle( title ); SetSeekable( seekable ); return Frames; }
//----------------------------------------------------------- // simple square box body //----------------------------------------------------------- CBox::CBox(const Vector& xPos, float fSize, float fParticleMass, int iRigidity) { SetColor(1.0f, 0.3f, 0.3f, 0.5f); SetBox(xPos, fSize, fParticleMass, iRigidity); }
Box::Box(Matrix_3x3 const& ucell) { SetBox( ucell ); }
Box::Box(const double* bIn) //: debug_(0) { SetBox( bIn ); }