Window::Sizes Box::_getWidthImplementation() const { // The width of a horizontal box is all of the widgets added together. if(_boxType == HORIZONTAL) { // If we're a uniformly sized box, our width is our largest width plus our // largest padding, multiplied times the number of widgets. Our minimum width // is the size of the largest minWidth times the number of widgets. if(_uniform) return Sizes( _getMaxWidgetWidthTotal() * size(), _getMaxWidgetMinWidthTotal() * size() ); // Othweriwse, our width is all of the widths added together, and our minWidth // is all of the minWidths added together. else return Sizes( _accumulate<Plus>(&Widget::getWidthTotal), _accumulate<Plus>(&Widget::getMinWidthTotal) ); } // If we're a vertical Box, our width is the width of the larget Widget in the group. // Our minWidth is the largest minWidth of the Widgets in the group. else return Sizes( _getMaxWidgetWidthTotal(), _getMaxWidgetMinWidthTotal() ); }
Window::Sizes Window::_getHeightImplementation() const { osg::BoundingBox bb = getGeode()->getBoundingBox(); point_type h = osg::round(bb.yMax() - bb.yMin()); return Sizes(h, 0.0f); }
Window::Sizes Window::_getWidthImplementation() const { osg::BoundingBox bb = getGeode()->getBoundingBox(); point_type w = osg::round(bb.xMax() - bb.xMin()); return Sizes(w, 0.0f); }
void xField::fromDAT(const char* fileName) { FILE* loadFile = fopen(fileName, "rb+"); //Define file size: fseek(loadFile, 0L, SEEK_END); uint32_t sc = uint32_t(ftell(loadFile)); fseek(loadFile, 0L, SEEK_SET); uint32_t dx, dy, dz; fread(&dx, sizeof(uint32_t), 1, loadFile); fread(&dy, sizeof(uint32_t), 1, loadFile); fread(&dz, sizeof(uint32_t), 1, loadFile); m_sizes = Sizes(dx, dy, dz); sc -= uint32_t(sizeof(uint32_t)) * 3; uint32_t total = sc / uint32_t(sizeof(double)); double f[total]; // load structure fread(&f, sizeof(double), total, loadFile); /*for (uint32_t i = 0; i < total; i += 4) { ocell vc; vc.push_back(OCell(Coord<double>(f[i], f[i + 1], f[i + 2]), f[i + 3])); clusters.push_back(vc); }*/ fclose(loadFile); //Agregate(clusters); }
Window::Sizes Box::_getHeightImplementation() const { if(_boxType == VERTICAL) { if(_uniform) return Sizes( _getMaxWidgetHeightTotal() * size(), _getMaxWidgetMinHeightTotal() * size() ); else return Sizes( _accumulate<Plus>(&Widget::getHeightTotal), _accumulate<Plus>(&Widget::getMinHeightTotal) ); } else return Sizes( _getMaxWidgetHeightTotal(), _getMaxWidgetMinHeightTotal() ); }
void xField::fromDLA(const char* fileName) { FILE* in = fopen(fileName, "r"); uint32_t dx, dy, dz; fscanf(in, "%d\t%d\t%d\n", &dx, &dy, &dz); m_sizes = Sizes(dx, dy, dz); // double fx, fy, fz, fr; // load structure /*while (fscanf(in, "%lf\t%lf\t%lf\t%lf\n", &fx, &fy, &fz, &fr) == 4) { ocell vc; vc.push_back(OCell(Coord<double>(fx, fy, fz), fr)); clusters.push_back(vc); }*/ fclose(in); //Agregate(clusters); }
Interactor* Builder::TypeSizeControls () { Tray* t = new Tray; Interactor* typeLabel = TypeLabel(); Interactor* types = Types(); Interactor* sizeLabel = SizeLabel(); Interactor* sizes = Sizes(); t->HBox(t, typeLabel, hgap(), types, new HGlue, t); t->HBox(t, sizeLabel, hgap(), sizes, new HGlue, t); t->Align(Left, types, sizes); t->VBox(t, typeLabel, vspc(), sizeLabel, t); t->Align(VertCenter, typeLabel, types); t->Align(VertCenter, sizeLabel, sizes); return t; }
void clGLVertexArray::RegenerateOffsets() { int VertexCount = static_cast<int>( GetVertexAttribs()->FVertices.size() ); LArray<int> Sizes( L_VS_TOTAL_ATTRIBS ); // these pointers are Offsets inside a VBO buffer for ( int i = 0; i != L_VS_TOTAL_ATTRIBS; i++ ) { Sizes[ i ] = FEnumeratedStreams[i] ? sizeof( float ) * L_VS_VEC_COMPONENTS[ i ] * VertexCount : 0; int Offset = 0; for ( int j = 0; j != i; j ++ ) { Offset += Sizes[ j ]; } FAttribVBOOffset[ i ] = ( void* )( size_t )Offset; } }
void xField::fromTXT(const char* fileName) { uint32_t dx = 0, dy = 0, dz = 0; FILE* in1 = fopen(fileName, "r"); double fx, fy, fz, fr; while (fscanf(in1, "%lf\t%lf\t%lf\t%lf\n", &fx, &fy, &fz, &fr) == 4) { if (dx < fx + fr) dx = uint32_t(fx + fr + 1); if (dy < fy + fr) dy = uint32_t(fy + fr + 1); if (dz < fz + fr) dz = uint32_t(fz + fr + 1); } fclose(in1); FILE* in2 = fopen(fileName, "r"); m_sizes = Sizes(dx, dy, dz); // load structure /*while (fscanf(in2, "%lf\t%lf\t%lf\t%lf\n", &fx, &fy, &fz, &fr) == 4) { ocell vc; vc.push_back(OCell(Coord<double>(fx, fy, fz), fr)); clusters.push_back(vc); }*/ fclose(in2); //Agregate(clusters); }
Sizes MxField::sizes() const { return Sizes(uint32_t(m_sides.x * m_cellSize), uint32_t(m_sides.y * m_cellSize), uint32_t(m_sides.z * m_cellSize)); }
/*! The environment should have been previously initialized and linked with a single voxel object. This function sets or resets the entire simulation with the new environment. @param[in] pEnvIn A pointer to initialized CVX_Environment to import into the simulator. @param[out] RetMessage A pointer to initialized string. Output information from the Import function is appended to this string. */ bool CVX_Sim::Import(CVX_Environment* pEnvIn, CMesh* pSurfMeshIn, std::string* RetMessage) { ClearAll(); //clears out all arrays and stuff if (pEnvIn != NULL) pEnv = pEnvIn; if (pEnv == NULL) {if (RetMessage) *RetMessage += "Invalid Environment pointer"; return false;} LocalVXC = *pEnv->pObj; //make a copy of the reference digital object! if (LocalVXC.GetNumVox() == 0) {if (RetMessage) *RetMessage += "No voxels in object"; return false;} int SIndexIt = 0; //keep track of how many voxel we've added (for storing reverse lookup array...) int NumBCs = pEnv->GetNumBCs(); CVX_FRegion* pCurBc; //initialize XtoSIndexMap & StoXIndexMap XtoSIndexMap.resize(LocalVXC.GetStArraySize(), -1); // = new int[LocalVXC.GetStArraySize()]; StoXIndexMap.resize(LocalVXC.GetNumVox(), -1); // = new int [m_NumVox]; std::vector<int> Sizes(NumBCs, 0); for (int i=0; i<NumBCs; i++) Sizes[i] = pEnv->GetNumTouching(i); // pEnv->GetNumVoxTouchingForced(&Sizes); //get the number of voxels in each region (to apply equal force to each voxel within this region!) // Vec3D BCpoint; Vec3D<> BCsize = pEnv->pObj->GetLatDimEnv()/2.0; Vec3D<> WSSize = pEnv->pObj->GetWorkSpace(); //Add all Voxels: bool HasPlasticMaterial = false; Vec3D<> ThisPos; Vec3D<> ThisScale = LocalVXC.GetLatDimEnv(); //Build voxel list for (int i=0; i<LocalVXC.GetStArraySize(); i++){ //for each voxel in the array XtoSIndexMap[i] = -1; //assume there is not a voxel here... if(LocalVXC.Structure[i] != 0 ){ //if there's material here int ThisMatIndex = LocalVXC.GetLeafMatIndex(i); int ThisMatModel = LocalVXC.Palette[ThisMatIndex].GetMatModel(); if (ThisMatModel == MDL_BILINEAR || ThisMatModel == MDL_DATA) HasPlasticMaterial = true; //enable plasticity in the sim LocalVXC.GetXYZ(&ThisPos, i, false);//Get XYZ location CVXS_Voxel CurVox(this, SIndexIt, i, ThisMatIndex, ThisPos, ThisScale); XtoSIndexMap[i] = SIndexIt; //so we can find this voxel based on it's original index StoXIndexMap[SIndexIt] = i; //so we can find the original index based on its simulator position for (int j = 0; j<NumBCs; j++){ //go through each primitive defined as a constraint! pCurBc = pEnv->GetBC(j); if (pCurBc->GetRegion()->IsTouching(&ThisPos, &BCsize, &WSSize)){ //if this point is within CurVox.FixDof(pCurBc->DofFixed); CurVox.AddExternalForce(pCurBc->Force/Sizes[j]); CurVox.AddExternalTorque(pCurBc->Torque/Sizes[j]); CurVox.SetExternalDisp(pCurBc->Displace); CurVox.SetExternalTDisp(pCurBc->AngDisplace); } } if(BlendingEnabled) CurVox.CalcMyBlendMix(); //needs to be done basically last. VoxArray.push_back(CurVox); SIndexIt++; } } //add input voxel so that NumVox() works! InputVoxSInd = (int)VoxArray.size(); CVXS_Voxel TmpVox(this, 0, 0, 0, Vec3D<>(0,0,0), Vec3D<>(0,0,0)); // TmpVox.LinkToVXSim(this); VoxArray.push_back(TmpVox); //SET UP ALL PERMANENT BONDS (in between materials and the input bond) Vec3D<> RelDist; //exhaustive (slower, but still OK) for (int i=0; i<NumVox(); i++){ //for each voxel in our newly-made array for (int j = i+1; j<NumVox(); j++){ if (!LocalVXC.IsAdjacent(StoXIndexMap[i], StoXIndexMap[j], false, &RelDist)) continue; if (!CreateBond(B_LINEAR, i, j, true) && RetMessage) *RetMessage += "At least one bond creation failed during import"; } } //Create input bond CreateBond(B_INPUT_LINEAR_NOROT, InputVoxSInd, InputVoxSInd, true, &InputBondInd, false); //create input bond, but initialize it to meaningless connection to self UpdateAllBondPointers(); //necessary since we probably reallocated the bond array when adding pbonds the first time //Set up our surface list... for (int i=0; i<NumVox(); i++){ //for each voxel in our newly-made array if (VoxArray[i].GetNumLocalBonds() != 6){ SurfVoxels.push_back(i); } //todo: only do for those on surfaces, I think. VoxArray[i].CalcNearby((int)(CollisionHorizon*1.5)); //populate the nearby array } #ifdef USE_OPEN_GL VoxMesh.ImportLinkSim(this); VoxMesh.DefMesh.DrawSmooth = false; //if the input mesh is not valid, use marching cubes to create one if (!pSurfMeshIn){ CMesh GeneratedSmoothMesh; CArray3Df OccupancyArray(pEnv->pObj->GetVXDim(), pEnv->pObj->GetVYDim(), pEnv->pObj->GetVZDim()); int NumPossibleVox = pEnv->pObj->GetStArraySize(); for (int g=0; g<NumPossibleVox; g++){ if (pEnv->pObj->Structure.GetData(g)>0) OccupancyArray[g] = 1.0; } CMarchCube::SingleMaterial(&GeneratedSmoothMesh, &OccupancyArray, 0.5, pEnv->pObj->GetLatticeDim()); SurfMesh.ImportSimWithMesh(this, &GeneratedSmoothMesh); } else SurfMesh.ImportSimWithMesh(this, pSurfMeshIn); #endif ResetSimulation(); OptimalDt = CalcMaxDt(); //to set up dialogs parameter ranges, we need this before the first iteration. EnablePlasticity(HasPlasticMaterial); //turn off plasticity if we don't need it... Initalized = true; // std::string tmpString; std::ostringstream os; os << "Completed Simulation Import: " << NumVox() << " Voxels, " << NumBond() << "Bonds.\n"; *RetMessage += os.str(); return true; }