首页 \ 问答 \ 三维阵列上的三维洪水填充算法(Java)(3D Flood Fill Algorithm on a 3D Array (Java))

三维阵列上的三维洪水填充算法(Java)(3D Flood Fill Algorithm on a 3D Array (Java))

我已经广泛搜索了论坛,并没有完全涵盖这一点。 我希望在枚举类型的数组上执行我称之为3D Flood Fill算法的操作。 我想改变它中的枚举类型,而不是改变数组元素的“颜色”。 这就是我到目前为止,如果您认为这样可行或者您有任何建议,请问我们。

 /*
  * CellType is my enum type. BOUNDRY_BOX enum type is type that I line the whole 3D array with. So the
  * whole inside surface of the 3D box is filled with CellType.BOUNDRY_BOX.
  **/
 public void fillAllVoidCells(CellType[][][] grid, CellType targetType, CellType replacementType, int x, int y, int z)
 {
    if ((grid[x][y][z] != targetType) && grid[x][y][z] != CellType.BOUNDRY_BOX)
    {
        break;
    }
    else
    {
        grid[x][y][z] = replacementType;

        fillAllVoidCells(grid, targetType, replacementType, x + 1, y, z);   // right
        fillAllVoidCells(grid, targetType, replacementType, x - 1, y, z);   // left
        fillAllVoidCells(grid, targetType, replacementType, x, y + 1, z);   // in front
        fillAllVoidCells(grid, targetType, replacementType, x, y - 1, z);   // behind
        fillAllVoidCells(grid, targetType, replacementType, x, y, z + 1);   // above
        fillAllVoidCells(grid, targetType, replacementType, x, y, z - 1);   // below
    }
 }

I have searched the forums extensively and nothing quite covers this. I am looking to do what I'd call essentially a 3D Flood Fill algorithm on an array on enum types. Rather than changing the "color" of the array elements, I'd like to change the enum type in it. This is what I have so far, could you guys let me know if you think this will work or if you have any suggestions?

 /*
  * CellType is my enum type. BOUNDRY_BOX enum type is type that I line the whole 3D array with. So the
  * whole inside surface of the 3D box is filled with CellType.BOUNDRY_BOX.
  **/
 public void fillAllVoidCells(CellType[][][] grid, CellType targetType, CellType replacementType, int x, int y, int z)
 {
    if ((grid[x][y][z] != targetType) && grid[x][y][z] != CellType.BOUNDRY_BOX)
    {
        break;
    }
    else
    {
        grid[x][y][z] = replacementType;

        fillAllVoidCells(grid, targetType, replacementType, x + 1, y, z);   // right
        fillAllVoidCells(grid, targetType, replacementType, x - 1, y, z);   // left
        fillAllVoidCells(grid, targetType, replacementType, x, y + 1, z);   // in front
        fillAllVoidCells(grid, targetType, replacementType, x, y - 1, z);   // behind
        fillAllVoidCells(grid, targetType, replacementType, x, y, z + 1);   // above
        fillAllVoidCells(grid, targetType, replacementType, x, y, z - 1);   // below
    }
 }

原文:https://stackoverflow.com/questions/16272940
更新时间:2023-07-08 11:07

最满意答案

MQSI_FILENODES_ROOT_DIRECTORY变量在启动时需要对ExecutionGroup进程可见,因此首先要检查的是如何设置env var并重新启动代理?

由于进程在Windows上分叉的方式,设置env变量的过程通常类似于:

停止代理关闭代理命令提示修改mqsiprofile.cmd以包含变量打开新代理命令提示验证设置env var即/ echo%MQSI_FILENODES_ROOT_DIRECTORY%启动代理

该目录还需要可由Broker的进程ID读取(如果要删除文件或将其移动到backout dir等,则可写)。


The MQSI_FILENODES_ROOT_DIRECTORY variable needs to be visible to the ExecutionGroup process at startup, so first thing to check is how did you set the env var and did you restart the broker?

Due to the way that processes are forked on windows the process for setting env vars is usually something like:

Stop broker Close Broker Command Prompt Modify mqsiprofile.cmd to include variable Open new Broker Command Prompt Verify env var is set ie/ echo %MQSI_FILENODES_ROOT_DIRECTORY% Start Broker

The directory also needs to be readable by the Broker's process ID (and writable if you will be deleting the file or moving it to a backout dir etc).

相关问答

更多
  • 用这个做了.. ChannelSftp sftp = (ChannelSftp) channel; sftp.cd(hostDir); Vector files = sftp.ls("*"); for (int i = 0; i < files.size(); i++) { Object obj = files.elementAt(i); if (obj instanceof com.jcraft.jsch.ChannelSftp.LsEntry) { ...
  • 使用os.path.expanduser : import os with open(os.path.expanduser('~/.file')) as f: print f.read() use os.path.expanduser: import os with open(os.path.expanduser('~/.file')) as f: print f.read()
  • MQSI_FILENODES_ROOT_DIRECTORY变量在启动时需要对ExecutionGroup进程可见,因此首先要检查的是如何设置env var并重新启动代理? 由于进程在Windows上分叉的方式,设置env变量的过程通常类似于: 停止代理关闭代理命令提示修改mqsiprofile.cmd以包含变量打开新代理命令提示验证设置env var即/ echo%MQSI_FILENODES_ROOT_DIRECTORY%启动代理 该目录还需要可由Broker的进程ID读取(如果要删除文件或将其移动到ba ...
  • 一般而言,存档文件是文件和目录条目的平面序列。 存档格式通常不指定所需的顺序。 某些归档格式隐式要求存在目录条目,但有些归档条目根本不需要它们。 在前一种情况下,隐式要求来自归档实用程序,如果文件应该在的目录不存在,则在提取文件时会抱怨。 这意味着要么需要在归档中的任何位置创建它,要么在运行实用程序之前存在该目录。 其他归档实用程序(如tar或zip )将只创建缺少的目录。 换句话说,目录条目仅代表目录本身,而不代表其内容。 在一般情况下,您应准备在树中创建目录节点,因为您在文件和目录条目的名称中发现它们。 ...
  • 通常,您必须将这些项目设置为复制到bin文件夹中。 在解决方案资源管理器/导航器中右键单击,选择属性并设置“复制到输出目录”。 希望这会起作用 Usually, you have to set those items to be copied into the bin folder. Right click in solution explorer/navigator, choose properties and set "Copy to output directory". hope this will ...
  • 有很多事情会导致这种异常。 这里有几件事要尝试: - 验证Xanadu.txt是使用isFile()方法的文件。 如果它返回false,那么你知道你的问题在哪里。 - 尝试将文件放置在项目目录中。 - 鉴于您已经尝试使用绝对文件路径,我还会确保您的程序有权查看和写入文件。 要检查eclipse是否具有权限,请转至文件的属性 There are a lot of things that can cause that exception. Here are a few things to try: -Verif ...
  • 不需要构建一串图像,然后将该字符串分解为一组图像,而不是像Radu所提到的那样直接将图像添加到数组中。 这是更正的代码: $imglist = array(); $img_folder = "path to my image"; //use the directory class $imgs = dir($img_folder); //read all files from the directory, checks if are images and adds them to a list whi ...
  • 这个如何? pv是管道查看器,是bash管道的速率限制器。 const spawn = require('child_process').spawn; const exec = require('child_process').exec; const tail = spawn('tail -f /tpm/filelist | pv -l -L 10 -q'); tail.stdout.on('data', fileName => { // parse filenames here console.l ...
  • 。 是当前目录..是一个目录 使用readdir时,您将获得额外的2个。 我更喜欢使用glob()。 该功能还允许您仅过滤html文件 "; } ?> . is for current dir .. is for one directory up When using readdir you w ...
  • 建议使用作为: 您也可以使用Spring 3.1+ Java Config执行此操作: @Bean public static PropertyPlaceholderConfigurer properties(){ PropertyPlaceholderConfig ...

相关文章

更多

最新问答

更多
  • python的访问器方法有哪些
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。
  • 响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
  • 在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
  • NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
  • 元素上的盒子阴影行为(box-shadow behaviour on elements)
  • Laravel检查是否存在记录(Laravel Checking If a Record Exists)
  • 设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
  • 想学Linux 运维 深圳有哪个培训机构好一点
  • 为什么有时不需要在lambda中捕获一个常量变量?(Why is a const variable sometimes not required to be captured in a lambda?)
  • 在Framework 3.5中使用服务器标签<%=%>设置Visible属性(Set Visible property with server tag <%= %> in Framework 3.5)
  • AdoNetAppender中的log4net连接类型无效(log4net connection type invalid in AdoNetAppender)
  • 错误:发送后无法设置标题。(Error: Can't set headers after they are sent. authentication system)
  • 等待EC2实例重启(Wait for an EC2 instance to reboot)
  • 如何在红宝石中使用正则表达式?(How to do this in regex in ruby?)
  • 使用鼠标在OpenGL GLUT中绘制多边形(Draw a polygon in OpenGL GLUT with mouse)
  • 江民杀毒软件的KSysnon.sys模块是什么东西?
  • 处理器在传递到add_xpath()或add_value()时调用了什么顺序?(What order are processors called when passed into add_xpath() or add_value()?)
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • SQL查询,其中字段不包含$ x(SQL Query Where Field DOES NOT Contain $x)
  • PerSession与PerCall(PerSession vs. PerCall)
  • C#:有两个构造函数的对象:如何限制哪些属性设置在一起?(C#: Object having two constructors: how to limit which properties are set together?)
  • 平衡一个精灵(Balancing a sprite)
  • n2cms Asp.net在“文件”菜单上给出错误(文件管理器)(n2cms Asp.net give error on Files menu (File Manager))
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的