Example #1
0
    void processModelVoxel26(int x, int y, int z) {

      if (grid.getState(x + 1, y + 1, z + 1) == OUTSIDE
          || grid.getState(x - 1, y + 1, z + 1) == OUTSIDE
          || grid.getState(x + 1, y - 1, z + 1) == OUTSIDE
          || grid.getState(x - 1, y - 1, z + 1) == OUTSIDE
          || grid.getState(x + 1, y + 1, z - 1) == OUTSIDE
          || grid.getState(x - 1, y + 1, z - 1) == OUTSIDE
          || grid.getState(x + 1, y - 1, z - 1) == OUTSIDE
          || grid.getState(x - 1, y - 1, z - 1) == OUTSIDE
          || grid.getState(x + 1, y + 1, z) == OUTSIDE
          || grid.getState(x - 1, y + 1, z) == OUTSIDE
          || grid.getState(x + 1, y - 1, z) == OUTSIDE
          || grid.getState(x - 1, y - 1, z) == OUTSIDE
          || grid.getState(x + 1, y, z + 1) == OUTSIDE
          || grid.getState(x - 1, y, z + 1) == OUTSIDE
          || grid.getState(x + 1, y, z - 1) == OUTSIDE
          || grid.getState(x - 1, y, z - 1) == OUTSIDE
          || grid.getState(x, y + 1, z + 1) == OUTSIDE
          || grid.getState(x, y - 1, z + 1) == OUTSIDE
          || grid.getState(x, y + 1, z - 1) == OUTSIDE
          || grid.getState(x, y - 1, z - 1) == OUTSIDE
          || grid.getState(x + 1, y, z) == OUTSIDE
          || grid.getState(x - 1, y, z) == OUTSIDE
          || grid.getState(x, y + 1, z) == OUTSIDE
          || grid.getState(x, y - 1, z) == OUTSIDE
          || grid.getState(x, y, z + 1) == OUTSIDE
          || grid.getState(x, y, z - 1) == OUTSIDE) {

        surfaceMask.set(x, y, z, 1);
      }
    }
Example #2
0
    void processModelVoxel(int x, int y, int z) {
      if (voxelChecker != null) {
        if (!voxelChecker.canProcess(x, y, z)) {
          return;
        }
      }
      int nlength = neighbors.length;
      int index = 0;
      while (index < nlength) {
        int ix = neighbors[index++];
        int iy = neighbors[index++];
        int iz = neighbors[index++];
        int xx = x + ix;
        int yy = y + iy;
        int zz = z + iz;
        if (xx >= 0 && xx < nx && yy >= 0 && yy < ny && zz >= 0 && zz < nz) {

          if (grid.getState(xx, yy, zz) == OUTSIDE) {
            // we have outside neighbor, set mask to
            surfaceMask.set(x, y, z, 1);
            return;
          }
        }
      }
    }
Example #3
0
  /** removes one layer of surface voxels */
  public void makeOneIteration(int nnCount) {

    // m_markedCount = 0;

    // long t0 = currentTimeMillis();
    // if(m_surfaceMask != null){
    // we have surface voxels stored on previous step
    // scan only surface voxels
    // processSurfaceVoxel(x,y,z);

    // } else {
    // no surface calculated yet. Scan the whole grid to find marked voxels

    m_grid.find(VoxelClasses.INSIDE, new SurfaceVoxelsCollector(m_grid, m_surfaceMask, nnCount));

    // }

    // set marked voxels as OUTSIDE
    m_surfaceMask.find(VoxelClasses.INSIDE, new VoxelStateSetter(m_grid, Grid.OUTSIDE));

    m_surfaceMask.clear();
  }
Example #4
0
  public AttributeGrid execute(AttributeGrid grid) {

    printf("ErosionMask.execute()\n");

    m_grid = grid;

    int nx = grid.getWidth();
    int ny = grid.getHeight();
    int nz = grid.getDepth();
    m_surfaceMask = new GridBitIntervals(nx, ny, nz);

    if (m_nnCount == 0) {

      // spherical erosion
      m_grid.find(
          VoxelClasses.INSIDE,
          new CustomVoxelsCollector(
              m_grid, m_surfaceMask, MaskFactory.makeBall(m_iterCount), m_voxelChecker));
      // m_grid.find(VoxelClasses.INSIDE, new SphericalVoxelsCollector(m_grid, m_surfaceMask,
      // m_iterCount, m_voxelChecker));
      // set marked voxels as OUTSIDE
      m_surfaceMask.find(VoxelClasses.INSIDE, new VoxelStateSetter(m_grid, Grid.OUTSIDE));
      m_surfaceMask.clear();

    } else {

      for (int i = 0; i < m_iterCount; i++) {

        makeOneIteration(getCount(i));
      }
    }

    m_grid = null;
    m_surfaceMask = null;

    return grid;
  }
Example #5
0
 void processModelVoxel(int x, int y, int z) {
   if (voxelChecker != null) {
     if (!voxelChecker.canProcess(x, y, z)) {
       return;
     }
   }
   for (int iy = -ballSize; iy <= ballSize; iy++) {
     for (int ix = -ballSize; ix <= ballSize; ix++) {
       for (int iz = -ballSize; iz <= ballSize; iz++) {
         int r2 = (ix * ix + iy * iy + iz * iz);
         if (r2 <= ballSize2) {
           // printf("%d \n", r2, );
           if (grid.getState(x + ix, y + iy, z + iz) == OUTSIDE) {
             //
             surfaceMask.set(x, y, z, 1);
             return;
           }
         }
       }
     }
   }
 }