医站点医维基

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1863|回复: 0

[VTK] ParaViewWeb on Windows

[复制链接]

336

主题

410

回帖

2806

积分

管理员

积分
2806

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2017-4-8 00:53:13 | 显示全部楼层 |阅读模式
This readme described the process of setting up a Paraview Web Server instance on a Windows 10 workstation. Once the ParaView Web is setup, the Visualizer app may be embedded in some other application’s web page (as an internal frame).
Download the correct binariesThis guide has been created while using Paraview 5.2.0 installation binaries. There are a few choices available and among those, the binary for Windows MPI was used. The following details were specified while downloading the file from http://www.paraview.org/download/
Version of ParaView: v5.2
Type of Download: ParaView Binary Installers
Operating System: Windows 64 bit
File to Download: ParaView-5.2.0-Qt4-OpenGL2-MPI-Windows-64bit.exe
Before installing ParaView, the following libraries need to be present:
  • Microsoft Message Passing Interface (MS MPI) Libraries - download the MS MPI libraries from the Microsoft Website
Run the downloaded executable file and follow the onscreen installation instructions to install the ParaView Desktop application. Once the application has been installed:
  • Start the application, and
  • Open a data file and check that the file is properly rendered by the application. Sample data files can be found bundled with the installer.
For the purpose of this document, the ParaView application is installed in C: drive in a directory named ParaView-5.2.0 (C:\ParaView-5.2.0). Henceforth, this directory will be referred to as <paraview-root>.
It is recommended that the paraview application is installed in a path which does not  have spaces. For example, installing the application in C:\Program Files\ParaView 5.2.0  is NOT recommended.
Install Apache Web ServerThe Apache web server acts as the front end to the ParaView Web application.
Download Apache Web Server for WindowsThe Apache web server is not natively supported on Windows. To get a Windows installer, a modified server can be downloaded from a number of third party vendors like:
Note: It is important to download the corresponding version of Visual C++ Runtime libraries
Once the Apache HTTPD is installed the server needs to be configured for:
  • Virtual host
  • Integration with ParaView Web
Configuring the Apache httpd ServerFor the purpose of this document, the Apache server is extracted to the C: drive in a directory named Apache24 (C:\Apache24). Henceforth, this directory will be referred to as <apache-root>.
Adding Virtual HostsOpen the <apache-root>\conf\extra\httpd-vhosts.conf file and add the following sections:
Grant all access rights in the  directory to the httpd server.
<Directory <paraview-root>>
  Require all granted
</Directory>
Create a default host config for traffic directed to http://localhost:
<VirtualHost *:80>
  DocumentRoot <apache-root>/htdocs
  ServerName localhost
</VirtualHost>
Create a virutal host named “paraview” which will be used for directing all traffic to the ParaView Web:
<VirtualHost *:80>
  ServerName   paraview
  ServerAdmin  admin@paraview.com
  DocumentRoot <paraview-root>/share/paraview-5.2/web/visualizer/www
  ErrorLog <paraview-root>/error.log
  CustomLog  <paraview-root>/log/apache2/access.log combined
  <Directory "<paraview-root>">
      Options Indexes FollowSymLinks
      Order allow,deny
      Allow from all
      AllowOverride None
      Require all granted
  </Directory>

  # Handle launcher forwarding
  # port and endpoint should match launcher.config
  ProxyPass /paraview http://localhost:9000/paraview

  # Handle WebSocket forwarding
  RewriteEngine On

  # This is the path the mapping file Jetty creates
  # path to proxy should match launcher.config
  RewriteMap session-to-port txt:<apache-root>/proxy.txt

  # This is the rewrite condition. Look for anything with a sessionId= in the
  # query part of the URL and capture the value to use below.
  RewriteCond %{QUERY_STRING} ^sessionId=(.*)&path=(.*)$ [NC]

  # This does the rewrite using the mapping file and the sessionId
  RewriteRule ^/proxy.*$  ws://${session-to-port:%1}/%2  [P]
</VirtualHost>
Save the <apache-root>\conf\extra\httpd-vhosts.conf file and:
  • create the folder(s): <paraview-root>\log\apache2
  • create an empty file named proxy.txt in the <apache-root> directory
  • open the <apache-root>\conf\httpd.conf file and enable (uncomment) the following modules:
    • vhost_alias
    • proxy
    • proxy_http
    • proxy_wstunnel
    • rewrite
  • open the C:\Windows\System32\drivers\etc\hosts file and add an entry for paraview:
127.0.0.1            paraview
<your-ip-address>    paraview
Creating the ParaView Web Launcher configurationOnce the virtual hosts have been setup, the ParaView Web launcher configuration needs to be created so the requests for ParaView Web are processed appropriately. To do this, create a file named launcher.config in the ParaView installation directory. (<paraview-root>\launcher.config). The content of the file is as follows:
{
  "configuration": {
    "host" : "localhost",
    "port" : 9000,
    "endpoint": "paraview",
  "content": "<paraview-root>/share/paraview-5.2/web/visualizer/www",
    "proxy_file" : "<apache-root>/proxy.txt",
    "sessionURL" : "ws://paraview:80/proxy?sessionId=${id}&path=ws",
    "timeout" : 30,
    "log_dir" : "<paraview-root>/log/",
    "fields" : []
  },
  "resources" : [ {
  "host" : "localhost",
  "port_range" : [9001, 9999]
  } ],
  "properties" : {
    "python_exec" : "<paraview-root>/bin/pvpython.exe",
    "visualizer": "<paraview-root>/share/paraview-5.2/web/visualizer/server/pvw-visualizer.py"
  },
  "apps": {
    "visualizer": {
        "cmd": [
            "${python_exec}", "-dr", "${visualizer}", "--port", "${port}", "--authKey", "${secret}",  "--data", "${dataDir}", "--load-file", "${dataFile}"
        ],
        "ready_line" : "Starting factory"
    }
  }
}
Modify the index.htmlAdd the following script to the <paraview-root>\share\paraview-5.2\web\visualizer\www\index.html file (replace the existing script):
<script>   
  function getFileToLoad() {
    var directoryPath = window.name;
    var filename = directoryPath.split('\\').slice(-1).join('\\');
    var directory = directoryPath.substring(0, directoryPath.indexOf(filename));
    return {
      dataFile:filename,
      dataDir:directory
    };
  };
  Visualizer.connect({
      application: 'visualizer',
      dataFile: getFileToLoad().dataFile,
      dataDir: getFileToLoad().dataDir
  });
  Visualizer.autoStopServer(10);
</script>
In the above script, the following properties are being passed:
  • dataFile - the name of the file to be rendered in the Visualizer
  • dataDir - the location of the data directory under which the data file(s) are present
If the dataDir location is fixed then it can be hard coded in the script, and only the dataFile name needs to be passed. In such a case, the following script should be used:
// grab the parameter from the URL
function getUrlParameter(name) {
  name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
  var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
  var results = regex.exec(location.search);
  return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};

Visualizer.connect({
  application: 'visualizer',
  dataFile: getUrlParameter('data'),
  dataDir: 'C:\\SomeFolder\\Data\\Files'
});
The URL to invoke this would be: http://paraview/?data=can.ex2
Starting up from the command lineOpen a command prompt to run each of the following:
  • Start the apache httd server by running: <apache-root>\bin\httpd.exe
  • Create a launcher script (launcher.bat) to start the ParaView Web Server with the following commands:
set PV_HOME=<paraview-root>
%PV_HOME%\bin\pvpython.exe %PV_HOME%\bin\Lib\site-packages\vtk\web\launcher.py %PV_HOME%\launcher.config
Run launcher.bat file
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|关于我们|医维基|网站地图|Archiver|手机版|医疗之家 ( 沪ICP备2023001278号-1 )  

GMT+8, 2024-5-2 20:24 , Processed in 0.119044 second(s), 24 queries .

Designed by Medical BBS

快速回复 返回顶部 返回列表