コード例 #1
0
ファイル: ImageAccess.cpp プロジェクト: shaugier/FAST-1
void setScalarAsFloat(T* data, Vector3i position, Vector3i size, float value, uchar channel, uchar nrOfChannels) {

    if(position.x() < 0 || position.y() < 0 || position.z() < 0 ||
            position.x() > size.x()-1 || position.y() > size.y()-1 || position.z() > size.z()-1 || channel >= nrOfChannels)
        throw OutOfBoundsException();

    data[(position.x() + position.y()*size.x() + position.z()*size.x()*size.y())*nrOfChannels + channel] = value;

}
コード例 #2
0
ファイル: AbstractTexture.cpp プロジェクト: JanDupal/magnum
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) {
    bindInternal();
    /** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */
    #ifndef MAGNUM_TARGET_GLES2
    glTexSubImage3D(target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
    #else
    static_cast<void>(target);
    static_cast<void>(level);
    static_cast<void>(offset);
    static_cast<void>(size);
    static_cast<void>(format);
    static_cast<void>(type);
    static_cast<void>(data);
    #endif
}
コード例 #3
0
ファイル: Texture.cpp プロジェクト: realisim/realisim
//----------------------------------------------------------------------------
void Texture::set(void* iPtr, const Vector3i& iS,
    GLenum iInternalFormat,
    GLenum iFormat,
    GLenum iDataType)
{
    vector<int> s(3, 0); s[0] = iS.x(); s[1] = iS.y(); s[2] = iS.z();
  set( iPtr, s, iInternalFormat, iFormat, iDataType );
}
コード例 #4
0
coord_t Box::volume() const {
    if (!valid()) {
        return 0;
    }

    Vector3i diagonal = this->diagonal();

    return diagonal.x() * diagonal.y() * diagonal.z();
}
コード例 #5
0
ファイル: cube.cpp プロジェクト: AlbertDeFusco/avogadrolibs
double Cube::value(const Vector3i &pos) const
{
  unsigned int index = pos.x() * m_points.y() * m_points.z()
      + pos.y() * m_points.z() + pos.z();
  if (index < m_data.size())
    return m_data[index];
  else
    return 6969.0;
}
コード例 #6
0
ファイル: Octree.cpp プロジェクト: Zylann/SnowfeetEngine
//------------------------------------------------------------------------------
IntAABB Octree::calculateTotalKeyBounds()
{
    IntAABB bounds;
    for (auto it = m_roots.begin(); it != m_roots.end(); ++it)
    {
        OctreeNode & node = *(it->second);
        Vector3i pos = it->first;
        bounds.addPoint(pos.x(), pos.y());
    }
    return bounds;
}
コード例 #7
0
void BotBotCollisionGrid::Setup(Vector3i Dimensions)
{
    assert(Dimensions.x() > 0 && "Attempting to create a world grid with zero x dimensions");
    assert(Dimensions.y() > 0 && "Attempting to create a world grid with zero y dimensions");
    
    SetupLevel(Grid1, Dimensions, 64);
    SetupLevel(Grid2, Dimensions, 128);
    SetupLevel(Grid3, Dimensions, 256);
    SetupLevel(Grid4, Dimensions, 512);

    MasterGrid.clear();    
}
コード例 #8
0
void BotBotCollisionGrid::SetupLevel(vector< vector< list< Robot* > > > &Grid, Vector3i Dimensions, int GridSize)
{
    Grid.resize( (Dimensions.x() + GridSize - 1) / GridSize);//round up the number of dimensions needed
    for(unsigned int x = 0; x < Grid.size(); x++)
    {
        Grid[x].resize((Dimensions.y() + GridSize - 1) / GridSize);
        for(unsigned int y = 0; y < Grid[x].size(); y++)
        {
            Grid[x][y].clear();
        }
    }
}
uint getOctreeDepthForBounding(const Vector3i& maxXYZ) {
    coord_t max = ::std::max(maxXYZ.x(), ::std::max(maxXYZ.y(), maxXYZ.z()));

    if (max < 0) {
        throw ::std::runtime_error("Invalid bounding (all components must not be negative)");
    }

    // how many bits are required to store numbers from 0 to max
    int requiredBits = getMostSignigicantSetBitPos(max) + 1;

    return static_cast<uint>(requiredBits);
}
コード例 #10
0
ファイル: cube.cpp プロジェクト: AlbertDeFusco/avogadrolibs
bool Cube::setLimits(const Vector3 &min_, const Vector3i &dim,
                     const Vector3 &spacing_)
{
  Vector3 max_ = Vector3(min_.x() + (dim.x()-1) * spacing_[0],
                         min_.y() + (dim.y()-1) * spacing_[1],
                         min_.z() + (dim.z()-1) * spacing_[2]);
  m_min = min_;
  m_max = max_;
  m_points = dim;
  m_spacing = spacing_;
  m_data.resize(m_points.x() * m_points.y() * m_points.z());
  return true;
}
コード例 #11
0
ファイル: cube.cpp プロジェクト: AlbertDeFusco/openqube
bool Cube::setLimits(const Vector3d &min_, const Vector3i &dim,
                     double spacing_)
{
  Vector3d max_ = Vector3d(min_.x() + (dim.x()-1) * spacing_,
                          min_.y() + (dim.y()-1) * spacing_,
                          min_.z() + (dim.z()-1) * spacing_);
  m_min = min_;
  m_max = max_;
  m_points = dim;
  m_spacing = Vector3d(spacing_, spacing_, spacing_);
  m_data.resize(m_points.x() * m_points.y() * m_points.z());
  return true;
}
コード例 #12
0
ファイル: AbstractTexture.cpp プロジェクト: JanDupal/magnum
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, AbstractTexture::InternalFormat internalFormat, const Vector3i& size) {
    bindInternal();
    /** @todo Re-enable when extension wrangler is available for ES2 */
    #ifndef MAGNUM_TARGET_GLES2
    glTexStorage3D(target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
    #else
    //glTexStorage3DEXT(target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
    static_cast<void>(target);
    static_cast<void>(levels);
    static_cast<void>(internalFormat);
    static_cast<void>(size);
    #endif
}
コード例 #13
0
ファイル: cube.cpp プロジェクト: AlbertDeFusco/avogadrolibs
bool Cube::setLimits(const Vector3 &min_, const Vector3 &max_,
                     const Vector3i &points)
{
  // We can calculate all necessary properties and initialise our data
  Vector3 delta = max_ - min_;
  m_spacing = Vector3(delta.x() / (points.x()-1),
                       delta.y() / (points.y()-1),
                       delta.z() / (points.z()-1));
  m_min = min_;
  m_max = max_;
  m_points = points;
  m_data.resize(m_points.x() * m_points.y() * m_points.z());
  return true;
}
コード例 #14
0
  bool MeshGenerator::marchingCube(const Vector3i &pos)
  {
    float afCubeValue[8];
    Vector3f asEdgeVertex[12];
    Vector3f asEdgeNorm[12];

    // Calculate the position in the Cube
    Vector3f fPos(pos.x() * m_stepSize + m_min.x(),
                  pos.y() * m_stepSize + m_min.y(),
                  pos.z() * m_stepSize + m_min.z());

    //Make a local copy of the values at the cube's corners
    for(int i = 0; i < 8; ++i) {
      afCubeValue[i] = m_cube->value(Vector3i(pos + Vector3i(a2iVertexOffset[i])));
    }

    //Find which vertices are inside of the surface and which are outside
    long iFlagIndex = 0;
    for(int i = 0; i < 8; ++i) {
      if(afCubeValue[i] <= m_iso) {
        iFlagIndex |= 1<<i;
      }
    }

    //Find which edges are intersected by the surface
    long iEdgeFlags = aiCubeEdgeFlags[iFlagIndex];

    // No intersections if the cube is entirely inside or outside of the surface
    if(iEdgeFlags == 0) {
      return false;
    }

    //Find the point of intersection of the surface with each edge
    //Then find the normal to the surface at those points
    for(int i = 0; i < 12; ++i) {
      //if there is an intersection on this edge
      if(iEdgeFlags & (1<<i)) {
        float fOffset = offset(afCubeValue[a2iEdgeConnection[i][0]],
                               afCubeValue[a2iEdgeConnection[i][1]]);

        asEdgeVertex[i] = Vector3f(
          fPos.x() + (a2fVertexOffset[a2iEdgeConnection[i][0]][0]
                      + fOffset * a2fEdgeDirection[i][0]) * m_stepSize,
          fPos.y() + (a2fVertexOffset[a2iEdgeConnection[i][0]][1]
                      + fOffset * a2fEdgeDirection[i][1]) * m_stepSize,
          fPos.z() + (a2fVertexOffset[a2iEdgeConnection[i][0]][2]
                      + fOffset * a2fEdgeDirection[i][2]) * m_stepSize);

        /// FIXME Optimize this to only calculate normals when required
        asEdgeNorm[i] = normal(asEdgeVertex[i]);
      }
    }

    // Store the triangles that were found, there can be up to five per cube
    for(int i = 0; i < 5; ++i) {
      if(a2iTriangleConnectionTable[iFlagIndex][3*i] < 0)
        break;
      int iVertex = 0;
      iEdgeFlags = a2iTriangleConnectionTable[iFlagIndex][3*i];
      // Make sure we get the triangle winding the right way around!
      if (!m_reverseWinding) {
        for(int j = 0; j < 3; ++j) {
          iVertex = a2iTriangleConnectionTable[iFlagIndex][3*i+j];
          m_indices.push_back(m_vertices.size());
          m_normals.push_back(asEdgeNorm[iVertex]);
          m_vertices.push_back(asEdgeVertex[iVertex]);
        }
      }
      else {
        for(int j = 2; j >= 0; --j) {
          iVertex = a2iTriangleConnectionTable[iFlagIndex][3*i+j];
          m_indices.push_back(m_vertices.size());
          m_normals.push_back(-asEdgeNorm[iVertex]);
          m_vertices.push_back(asEdgeVertex[iVertex]);
        }
      }

    }
    return true;
  }
コード例 #15
0
bool Box::contains(const Vector3i& point) const {
    return point.x() >= m_llf.x() && point.y() >= m_llf.y() && point.z() >= m_llf.z() && m_urb.x() >= point.x() && m_urb.y() >= point.y() &&
           m_urb.z() >= point.z();
}
コード例 #16
0
ファイル: omd2omd.cpp プロジェクト: hsidky/OpenMD
int main(int argc, char* argv[]){
  
  gengetopt_args_info args_info;
  string dumpFileName;
  string outFileName;
  
  //parse the command line option
  if (cmdline_parser (argc, argv, &args_info) != 0) {
    exit(1) ;
  }
  
  //get the dumpfile name and meta-data file name
  if (args_info.input_given){
    dumpFileName = args_info.input_arg;
  } else {
    strcpy( painCave.errMsg,
            "No input file name was specified.\n" );
    painCave.isFatal = 1;
    simError();
  }
  
  if (args_info.output_given){
    outFileName = args_info.output_arg;
  } else {
    strcpy( painCave.errMsg,
            "No output file name was specified.\n" );
    painCave.isFatal = 1;
    simError();
  }

  Vector3i repeat = Vector3i(args_info.repeatX_arg,
                             args_info.repeatY_arg,
                             args_info.repeatZ_arg);
  Mat3x3d repeatD = Mat3x3d(0.0);
  repeatD(0,0) = repeat.x();
  repeatD(1,1) = repeat.y();
  repeatD(2,2) = repeat.z();

  Vector3d translate = Vector3d(args_info.translateX_arg,
                                args_info.translateY_arg,
                                args_info.translateZ_arg);

  //parse md file and set up the system

  SimCreator oldCreator;
  SimInfo* oldInfo = oldCreator.createSim(dumpFileName, false);
  Globals* simParams = oldInfo->getSimParams();
  std::vector<Component*> components = simParams->getComponents();
  std::vector<int> nMol;
  for (vector<Component*>::iterator i = components.begin(); 
       i !=components.end(); ++i) {
    int nMolOld = (*i)->getNMol();
    int nMolNew = nMolOld * repeat.x() * repeat.y() * repeat.z();    
    nMol.push_back(nMolNew);
  }
  
  createMdFile(dumpFileName, outFileName, nMol);

  SimCreator newCreator;
  SimInfo* newInfo = newCreator.createSim(outFileName, false);

  DumpReader* dumpReader = new DumpReader(oldInfo, dumpFileName);
  int nframes = dumpReader->getNFrames();
  
  DumpWriter* writer = new DumpWriter(newInfo, outFileName);
  if (writer == NULL) {
    sprintf(painCave.errMsg, "error in creating DumpWriter");
    painCave.isFatal = 1;
    simError();
  }

  SimInfo::MoleculeIterator miter;
  Molecule::IntegrableObjectIterator  iiter;
  Molecule::RigidBodyIterator rbIter;
  Molecule* mol;
  StuntDouble* sd;
  StuntDouble* sdNew;
  RigidBody* rb;
  Mat3x3d oldHmat;
  Mat3x3d newHmat;
  Snapshot* oldSnap;
  Snapshot* newSnap;
  Vector3d oldPos;
  Vector3d newPos;
  
  for (int i = 0; i < nframes; i++){
    cerr << "frame = " << i << "\n";
    dumpReader->readFrame(i);        
    oldSnap = oldInfo->getSnapshotManager()->getCurrentSnapshot();
    newSnap = newInfo->getSnapshotManager()->getCurrentSnapshot();

    newSnap->setID( oldSnap->getID() );
    newSnap->setTime( oldSnap->getTime() );
    
    oldHmat = oldSnap->getHmat();
    newHmat = repeatD*oldHmat;
    newSnap->setHmat(newHmat);

    newSnap->setThermostat( oldSnap->getThermostat() );
    newSnap->setBarostat( oldSnap->getBarostat() );

    int newIndex = 0;
    for (mol = oldInfo->beginMolecule(miter); mol != NULL; 
         mol = oldInfo->nextMolecule(miter)) {
      
      for (int ii = 0; ii < repeat.x(); ii++) {
        for (int jj = 0; jj < repeat.y(); jj++) {
          for (int kk = 0; kk < repeat.z(); kk++) {

            Vector3d trans = Vector3d(ii, jj, kk);
            for (sd = mol->beginIntegrableObject(iiter); sd != NULL;
                 sd = mol->nextIntegrableObject(iiter)) {
              oldPos = sd->getPos() + translate;
              oldSnap->wrapVector(oldPos);
              newPos = oldPos + trans * oldHmat;
              sdNew = newInfo->getIOIndexToIntegrableObject(newIndex);
              sdNew->setPos( newPos );
              sdNew->setVel( sd->getVel() );
              if (sd->isDirectional()) {
                sdNew->setA( sd->getA() );
                sdNew->setJ( sd->getJ() );
              }
              newIndex++;
            }
          }
        }
      }      
    }
  
    //update atoms of rigidbody
    for (mol = newInfo->beginMolecule(miter); mol != NULL; 
         mol = newInfo->nextMolecule(miter)) {
      
      //change the positions of atoms which belong to the rigidbodies
      for (rb = mol->beginRigidBody(rbIter); rb != NULL; 
           rb = mol->nextRigidBody(rbIter)) {
        
        rb->updateAtoms();
        rb->updateAtomVel();
      }
    }

    writer->writeDump();    
  }
  // deleting the writer will put the closing at the end of the dump file.
  delete writer;
  delete oldInfo;
}
コード例 #17
0
ファイル: AbstractTexture.cpp プロジェクト: JanDupal/magnum
void AbstractTexture::invalidateSubImplementationARB(GLint level, const Vector3i& offset, const Vector3i& size) {
    glInvalidateTexSubImage(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z());
}
コード例 #18
0
ファイル: AbstractTexture.cpp プロジェクト: JanDupal/magnum
void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) {
    glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), static_cast<GLenum>(format), static_cast<GLenum>(type), data);
}
コード例 #19
0
ファイル: AbstractTexture.cpp プロジェクト: JanDupal/magnum
void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, AbstractTexture::InternalFormat internalFormat, const Vector3i& size) {
    glTextureStorage3DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
}
コード例 #20
0
ファイル: AbstractTexture.cpp プロジェクト: JanDupal/magnum
void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, InternalFormat internalFormat, const Vector3i& size, AbstractImage::Format format, AbstractImage::Type type, const GLvoid* data) {
    glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, static_cast<GLenum>(format), static_cast<GLenum>(type), data);
}