示例#1
0
 /**
  * splits this VoxelSelection into two, in accordance with the supplied mask: For each set voxel
  * in this: 1) if the mask is clear, the voxel is removed from this and added to the return value
  * 2) if the mask is set, the voxel remains in this
  *
  * @param mask
  * @param xOffsetOfMask the origin of the mask relative to the origin of this fragment
  * @param yOffsetOfMask
  * @param zOffsetOfMask
  * @return a new VoxelSelection containing those voxels that aren't also present in the mask.
  */
 public VoxelSelection splitByMask(
     VoxelSelection mask, int xOffsetOfMask, int yOffsetOfMask, int zOffsetOfMask) {
   VoxelSelection notOverlapped = new VoxelSelection(this);
   notOverlapped.clearAll();
   int xSize = mask.getxSize();
   int ySize = mask.getySize();
   int zSize = mask.getzSize();
   for (int x = 0; x < xSize; ++x) {
     for (int z = 0; z < zSize; ++z) {
       for (int y = 0; y < ySize; ++y) {
         if (getVoxel(x - xOffsetOfMask, y - yOffsetOfMask, z - zOffsetOfMask)) {
           if (!mask.getVoxel(x, y, z)) {
             notOverlapped.setVoxel(x - xOffsetOfMask, y - yOffsetOfMask, z - zOffsetOfMask);
             this.clearVoxel(x - xOffsetOfMask, y - yOffsetOfMask, z - zOffsetOfMask);
           }
         }
       }
     }
   }
   return notOverlapped;
 }