Skip to content

Commit

Permalink
Volumetric improvements
Browse files Browse the repository at this point in the history
Python addVolumetricData interface updated to support volumetric
rendering.  Set bounding sphere of a volumetric render shape. Update
volumetric.ipynb
  • Loading branch information
dkoes committed Jun 24, 2020
1 parent 854dfe6 commit 1484f01
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 21 deletions.
17 changes: 9 additions & 8 deletions 3Dmol/glviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2601,11 +2601,10 @@ $3Dmol.GLViewer = (function() {

/**
* Construct isosurface from volumetric data in gaussian cube format
* @deprecated
* @function $3Dmol.GLViewer#addVolumetricData
* @param {String} data - Input file contents
* @param {String} format - Input file format (currently only supports "cube")
* @param {IsoSurfaceSpec} spec - Shape style specification
* @param {String} format - Input file format
* @param {IsoSurfaceSpec} or {VolumetricRenderSpec} spec - Shape style specification
* @return {$3Dmol.GLShape}
*
* @example
Expand All @@ -2623,11 +2622,13 @@ $3Dmol.GLViewer = (function() {
*/
this.addVolumetricData = function(data, format, spec) {
spec = spec || {};
var s = new $3Dmol.GLShape(spec);
s.shapePosition = shapes.length;
s.addVolumetricData(data, format, spec);
shapes.push(s);
return s;

var voldata = new $3Dmol.VolumeData(data, format);
if(spec.transferfn) { //volumetric rendering
return this.addVolumetricRender(voldata, spec);
} else {
return this.addIsosurface(voldata, spec);
}
};

/**
Expand Down
5 changes: 4 additions & 1 deletion 3Dmol/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,10 @@ $3Dmol.GLVolumetricRender = (function() {
}
var geo = shape.finalize();


this.boundingSphere = new $3Dmol.Sphere();
this.boundingSphere.center = {x: data.origin.x+xoff/2.0, y: data.origin.y+yoff/2.0, z: data.origin.z+zoff/2.0};
this.boundingSphere.radius = Math.sqrt(xoff*xoff+yoff*yoff+zoff*zoff)/2.0;

// volume selectivity based on given coords and distance
if (spec.coords !== undefined && spec.seldist !== undefined){
//TODO: create mask buffer
Expand Down
88 changes: 76 additions & 12 deletions py3Dmol/volumetric.ipynb

Large diffs are not rendered by default.

0 comments on commit 1484f01

Please sign in to comment.