diff --git a/Sources/Rendering/Core/Actor/api.md b/Sources/Rendering/Core/Actor/api.md index 1f5ff3b54cc..4360474b915 100644 --- a/Sources/Rendering/Core/Actor/api.md +++ b/Sources/Rendering/Core/Actor/api.md @@ -1,6 +1,6 @@ vtkActor is used to represent an entity in a rendering scene. It inherits functions related to the actors position, and orientation from -vtkProp. The actor also has scaling and maintains a reference to the +vtkProp3D. The actor also has scaling and maintains a reference to the defining geometry (i.e., the mapper), rendering properties, and possibly a texture map. vtkActor combines these instance variables into one 4x4 transformation matrix as follows: [x y z 1] = [x y z 1] Translate(-origin) @@ -8,7 +8,7 @@ Scale(scale) Rot(y) Rot(x) Rot (z) Trans(origin) Trans(position) ## See Also -Property Texture Mapper Assembly Follower LODActor +Property Mapper ## newInstance() @@ -32,32 +32,10 @@ are used in that process. virtual void GetActors(vtkPropCollection *); ``` -## renderOpaqueGeometry(viewport) - -Support the standard render methods. -Returns 0 on success, 1 on failure. - -## renderTranslucentPolygonalGeometry(viewport) - -Support the standard render methods. - ## hasTranslucentPolygonalGeometry() Does this prop have some translucent polygonal geometry? -## render(renderer, mapper) - -This causes the actor to be rendered. It in turn will render the actor's -property, texture map and then mapper. If a property hasn't been -assigned, then the actor will create one automatically. Note that a side -effect of this method is that the pipeline will be updated. - -## releaseGraphicsResources(window) - -Release any graphics resources that are being consumed by this actor. -The parameter window could be used to determine which graphic -resources to release. - ## property Set/Get the property object that controls this actors surface @@ -70,7 +48,7 @@ property object. Create a new property suitable for use with this type of Actor. For example, a vtkMesaActor should create a vtkMesaProperty -in this function. The default is to just call vtkProperty::New. +in this function. The default is to create a vtkProperty. ## backfaceProperty diff --git a/Sources/Rendering/Core/Actor/index.js b/Sources/Rendering/Core/Actor/index.js index ba75638cd37..97c122f904a 100644 --- a/Sources/Rendering/Core/Actor/index.js +++ b/Sources/Rendering/Core/Actor/index.js @@ -52,23 +52,6 @@ function vtkActor(publicAPI, model) { return !publicAPI.getIsOpaque(); }; - publicAPI.releaseGraphicsResources = (win) => { - // pass this information onto the mapper - if (model.mapper) { - model.mapper.releaseGraphicsResources(win); - } - - // TBD: pass this information onto the texture(s) - - // pass this information to the properties - if (model.property) { - model.property.releaseGraphicsResources(win); - } - if (model.backfaceProperty) { - model.backfaceProperty.releaseGraphicsResources(win); - } - }; - publicAPI.makeProperty = vtkProperty.newInstance; publicAPI.getProperty = () => { diff --git a/Sources/Rendering/Core/Actor2D/api.md b/Sources/Rendering/Core/Actor2D/api.md new file mode 100644 index 00000000000..1d4ff5c2435 --- /dev/null +++ b/Sources/Rendering/Core/Actor2D/api.md @@ -0,0 +1,57 @@ +vtkActor2D is used to represent a 2D entity in a rendering scene. It inherits +functions related to the actors position, and orientation from +vtkProp. The actor also has scaling and maintains a reference to the +defining geometry (i.e., the mapper), rendering properties, and possibly a +texture map. + +## See Also + +Property2D Mapper2D + +## newInstance() + +Create an instance of vtkActor2D + +## getActors2D() + +For some exporters and other other operations we must be +able to collect all the actors or volumes. These methods +are used in that process. + +## hasTranslucentPolygonalGeometry() + +Does this prop have some translucent polygonal geometry? + +## property + +Set/Get the property object that controls this actors surface +properties. This should be an instance of a vtkProperty object. Every +actor must have a property associated with it. If one isn't specified, +then one will be generated automatically. Multiple actors can share one +property object. + +## makeProperty() + +Create a new property suitable for use with this type of Actor. +The default is to create a vtkProperty2D. + +## mapper + +This is the method that is used to connect an actor to the end of a +visualization pipeline, i.e. the mapper. This should be a subclass +of vtkMapper2D. Typically vtkPolyDataMapper2D will be used. + +## bounds() + +Get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax). + +## getMTime() + +Get the newest "modification time" of the actor, its properties, and texture (if set). + +## getRedrawMTime() + +Return the mtime of anything that would cause the rendered image to +appear differently. Usually this involves checking the mtime of the +prop plus anything else it depends on such as properties, textures, +etc. diff --git a/Sources/Rendering/Core/Camera/api.md b/Sources/Rendering/Core/Camera/api.md index b2f081ae7e0..f93b0a8e459 100644 --- a/Sources/Rendering/Core/Camera/api.md +++ b/Sources/Rendering/Core/Camera/api.md @@ -70,7 +70,7 @@ Rotate the focal point about the view up vector, using the camera's position as rotation. Note that the view up vector is whatever was set via SetViewUp, and is not necessarily perpendicular to the direction of projection. The result is a horizontal rotation of the scene. - ### elevation(angle) +### elevation(angle) Rotate the camera about the cross product of the negative of the direction of projection and the view up vector, using the focal point as the center of rotation. The result is a vertical rotation @@ -121,7 +121,7 @@ of these values must be positive. How the clipping planes are set can have a lar well z-buffering works. In particular the front clipping plane can make a very big difference. Setting it to 0.01 when it really could be 1.0 can have a big impact on your z-buffer resolution farther away. The default clipping range is (0.1,1000). Clipping distance is measured in world -coordinate unless a scale factor exists in camera's ModelTransformMatrix. +coordinates. ### thickness @@ -153,16 +153,6 @@ using the transform's matrix to multiply the old points by the new transform. Get the ViewPlaneNormal. This vector will point opposite to the direction of projection, unless you have created a sheared output view using SetViewShear/SetObliqueAngles. -### viewShear - -Set/get the shear transform of the viewing frustum. Parameters are dx/dz, dy/dz, and center. -center is a factor that describes where to shear around. The distance dshear from the camera -where no shear occurs is given by (dshear = center * FocalDistance). - -### eyeAngle - -Set/Get the separation between eyes (in degrees). This is used when generating stereo images. - ### focalDisk Set the size of the cameras lens in world coordinates. This is only used when the renderer is @@ -190,32 +180,6 @@ calculation. Default is (0.5, -0.5, -0.5). Set/Get top right corner point of the screen. This will be used only for offaxis frustum calculation. Default is (0.5, 0.5, -0.5). -### eyeSeparation - -Set/Get distance between the eyes. This will be used only for offaxis frustum calculation. -Default is 0.06. - -### eyePosition - -Set/Get the eye position (center point between two eyes). This is a convenience function that -sets the translation component of EyeTransformMatrix. This will be used only for offaxis -frustum calculation. - -### getEyePlaneNormal() - -Get normal vector from eye to screen rotated by EyeTransformMatrix. This will be used only for -offaxis frustum calculation. - -### eyeTransformMatrix - -Set/Get eye transformation matrix. This is the transformation matrix for the point between -eyes. This will be used only for offaxis frustum calculation. Default is identity. - -### modelTransformMatrix - -Set/Get model transformation matrix. This matrix could be used for model related transformations -such as scale, shear, roations and translations. - ### getViewTransformMatrix() Return the matrix of the view transform. The ViewTransform depends on only three ivars: the diff --git a/Sources/Rendering/Core/Camera/index.js b/Sources/Rendering/Core/Camera/index.js index 1088b207370..1497eea35b4 100644 --- a/Sources/Rendering/Core/Camera/index.js +++ b/Sources/Rendering/Core/Camera/index.js @@ -26,8 +26,6 @@ function vtkCamera(publicAPI, model) { // Set up private variables and methods const viewMatrix = mat4.create(); const projectionMatrix = mat4.create(); - // let viewUp = new vec3.fromValues(0, 1, 0); - // let distance = 0.0002; publicAPI.orthogonalizeViewUp = () => { const vt = publicAPI.getViewTransformMatrix(); @@ -261,18 +259,6 @@ function vtkCamera(publicAPI, model) { }; - publicAPI.setEyePosition = eyePosition => { - - }; - - publicAPI.getEyePosition = () => { - - }; - - publicAPI.getEyePlaneNormal = () => { - - }; - publicAPI.getViewTransformMatrix = () => { const eye = model.position; const at = model.focalPoint; @@ -325,8 +311,6 @@ function vtkCamera(publicAPI, model) { mat4.perspective(projectionMatrix, vtkMath.radiansFromDegrees(fovy), aspect, cRange[0], cRange[1]); } - // No stereo, no view shear at the current time - mat4.transpose(projectionMatrix, projectionMatrix); return projectionMatrix; }; @@ -420,19 +404,13 @@ export const DEFAULT_VALUES = { thickness: 1000, windowCenter: [0, 0], viewPlaneNormal: [0, 0, 1], - viewShear: [0, 0, 1], - eyeAngle: 2, focalDisk: 1, useOffAxisProjection: false, screenBottomLeft: [-0.5, -0.5, -0.5], screenBottomRight: [0.5, -0.5, -0.5], screenTopRight: [0.5, 0.5, -0.5], - eyeSeparation: 0.06, - // eyeTransformMatrix: mat4.create(), // can't do these here, or else - // modelTransformMatrix: mat4.create(), // every instance shares same default userViewTransform: null, userTransform: null, - leftEye: 1, freezeFocalPoint: false, useScissor: false, }; @@ -443,8 +421,6 @@ export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Make sure we have our own objects - model.eyeTransformMatrix = mat4.create(); - model.modelTransformMatrix = mat4.create(); // Build VTK API macro.obj(publicAPI, model); @@ -459,13 +435,8 @@ export function extend(publicAPI, model, initialValues = {}) { 'useHorizontalViewAngle', 'viewAngle', 'parallelScale', - 'eyeAngle', 'focalDisk', 'useOffAxisProjection', - 'eyeSeparation', - 'eyeTransformMatrix', - 'modelTransformMatrix', - 'leftEye', 'freezeFocalPoint', 'useScissor', ]); @@ -484,7 +455,6 @@ export function extend(publicAPI, model, initialValues = {}) { macro.setGetArray(publicAPI, model, [ 'viewUp', - 'viewShear', 'screenBottomLeft', 'screenBottomRight', 'screenTopRight', diff --git a/Sources/Rendering/Core/Coordinate/api.md b/Sources/Rendering/Core/Coordinate/api.md new file mode 100644 index 00000000000..021de44531f --- /dev/null +++ b/Sources/Rendering/Core/Coordinate/api.md @@ -0,0 +1,45 @@ +## Introduction + +vtkCoordinate performs coordinate transformation, and represent position, in a variety of vtk coordinate systems + +vtkCoordinate represents position in a variety of coordinate systems, and +converts position to other coordinate systems. It also supports relative +positioning, so you can create a cascade of vtkCoordinate objects (no loops +please!) that refer to each other. The typical usage of this object is +to set the coordinate system in which to represent a position (e.g., +SetCoordinateSystemToNormalizedDisplay()), set the value of the coordinate +(e.g., SetValue()), and then invoke the appropriate method to convert to +another coordinate system (e.g., GetComputedWorldValue()). +The coordinate systems in vtk are as follows: + +
+  DISPLAY -             x-y pixel values in window
+  NORMALIZED DISPLAY -  x-y (0,1) normalized values
+  VIEWPORT -            x-y pixel values in viewport
+  NORMALIZED VIEWPORT - x-y (0,1) normalized value in viewport
+  VIEW -                x-y-z (-1,1) values in camera coordinates. (z is depth)
+  WORLD -               x-y-z global coordinate values
+  USERDEFINED -         x-y-z in User defined space
+
+ +If you cascade vtkCoordinate objects, you refer to another vtkCoordinate +object which in turn can refer to others, and so on. This allows you to +create composite groups of things like vtkActor2D that are positioned +relative to one another. Note that in cascaded sequences, each +vtkCoordinate object may be specified in different coordinate systems! + +## See Also + +vtkActor2D + +### referenceCoordinate + +Make this coordinate relative to another coordinate instance. + +### viewport + +The viewport to use for calculations that require it. + +### value + +The x y z location of this point. diff --git a/Sources/Rendering/Core/ImageMapper/api.md b/Sources/Rendering/Core/ImageMapper/api.md new file mode 100644 index 00000000000..1e639ff81b6 --- /dev/null +++ b/Sources/Rendering/Core/ImageMapper/api.md @@ -0,0 +1,12 @@ +## Introduction + +vtkImageMapper provides 2D image display support for vtk. +It can be associated with a vtkImageSlice prop and placed within a Renderer. + +## See Also + +vtkImageSlice vtkImageProperty vtkInteractorStyleImage + +### zSlice + +What slice of image data to display from a 3D volume. diff --git a/Sources/Rendering/Core/ImageMapper/example/index.js b/Sources/Rendering/Core/ImageMapper/example/index.js index eb37d36aafe..84f1346d34a 100644 --- a/Sources/Rendering/Core/ImageMapper/example/index.js +++ b/Sources/Rendering/Core/ImageMapper/example/index.js @@ -34,7 +34,7 @@ actor.getProperty().setColorLevel(127); actor.setMapper(mapper); const gridSource = vtkImageGridSource.newInstance(); -gridSource.setDataExtent(0, 511, 0, 511, 0, 0); +gridSource.setDataExtent(0, 200, 0, 200, 0, 0); gridSource.setGridSpacing(16, 16, 0); gridSource.setGridOrigin(8, 8, 0); mapper.setInputConnection(gridSource.getOutputPort()); diff --git a/Sources/Rendering/Core/ImageMapper/index.js b/Sources/Rendering/Core/ImageMapper/index.js index 62c633157e9..e14739b3d1b 100644 --- a/Sources/Rendering/Core/ImageMapper/index.js +++ b/Sources/Rendering/Core/ImageMapper/index.js @@ -1,10 +1,6 @@ import * as macro from '../../../macro'; import vtkMath from '../../../Common/Core/Math'; -// ---------------------------------------------------------------------------- -// vtkProperty2D methods -// ---------------------------------------------------------------------------- - function vtkImageMapper(publicAPI, model) { // Set our className model.classHierarchy.push('vtkImageMapper'); diff --git a/Sources/Rendering/Core/ImageProperty/api.md b/Sources/Rendering/Core/ImageProperty/api.md new file mode 100644 index 00000000000..55ec967e2fa --- /dev/null +++ b/Sources/Rendering/Core/ImageProperty/api.md @@ -0,0 +1,39 @@ +## Introduction + +vtkImageProperty -- image display properties + +vtkImageProperty is an object that allows control of the display +of an image slice. + +## See Also + +vtkImageMapper vtkImageSlice + +### colorWindow + +Controls the window in a window level mapping of the input image. Window +level mapping is a technique to map the raw data values of an image +into screen intensities in a manner akin to + +pixelIntensity = (inputValue - level)/window; + +### colorLevel + +Controls the level in a window level mapping of the input image. Window +level mapping is a technique to map the raw data values of an image +into screen intensities in a manner akin to + +pixelIntensity = (inputValue - level)/window; + +### ambient + +Control the ambient lighting intensity for this image. + +### diffuse + +Control the diffuse lighting intensity of this image. + +### opacity + +Control the opacity of this image. + diff --git a/Sources/Rendering/Core/ImageSlice/api.md b/Sources/Rendering/Core/ImageSlice/api.md new file mode 100644 index 00000000000..a38a531de54 --- /dev/null +++ b/Sources/Rendering/Core/ImageSlice/api.md @@ -0,0 +1,26 @@ +## Introduction + +vtkImageSlice is used to represent an image in a 3D scene. It displays +the image either as a slice or as a projection from the camera's +perspective. Adjusting the position and orientation of the slice +is done by adjusting the focal point and direction of the camera, +or alternatively the slice can be set manually in vtkImageMapper +The lookup table and window/leve are set in vtkImageProperty. + +Thanks to David Gobbi at the Seaman Family MR Centre and Dept. of Clinical +Neurosciences, Foothills Medical Centre, Calgary, for providing +the basis for this and many other image display classes. + +## See Also + +vtkImageMapper vtkImageProperty + +### mapper + +The mapper to use represent this image/data. Typically this is a +vtkImageMapper. + +### property + +The properties of this image slice. The properties help determine how +an image will be rendered. Typicall an instance of vtkImageProperty. diff --git a/Sources/Rendering/Core/InteractorObserver/index.js b/Sources/Rendering/Core/InteractorObserver/index.js index a13a943a28b..531fdb91a45 100644 --- a/Sources/Rendering/Core/InteractorObserver/index.js +++ b/Sources/Rendering/Core/InteractorObserver/index.js @@ -1,18 +1,5 @@ import * as macro from '../../../macro'; -// ---------------------------------------------------------------------------- -// Global methods -// ---------------------------------------------------------------------------- - - -// ---------------------------------------------------------------------------- -// Static API -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -// vtkMyClass methods -// ---------------------------------------------------------------------------- - function vtkInteractorObserver(publicAPI, model) { // Set our className model.classHierarchy.push('vtkInteractorObserver'); diff --git a/Sources/Rendering/Core/InteractorStyle/api.md b/Sources/Rendering/Core/InteractorStyle/api.md new file mode 100644 index 00000000000..591e5a68efc --- /dev/null +++ b/Sources/Rendering/Core/InteractorStyle/api.md @@ -0,0 +1,52 @@ +## Introduction + +vtkInteractorStyle - provide event-driven interface to the rendering window + +vtkInteractorStyle is a base class implementing the majority of motion +control routines and defines an event driven interface to support +vtkRenderWindowInteractor. vtkRenderWindowInteractor implements +platform dependent key/mouse routing and timer control, which forwards +events in a neutral form to vtkInteractorStyle. + +vtkInteractorStyle can be subclassed to provide new interaction styles and +a facility to override any of the default mouse/key operations which +currently handle trackball or joystick styles is provided. Note that this +class will fire a variety of events that can be watched using an observer, +such as LeftButtonPressEvent, LeftButtonReleaseEvent, +MiddleButtonPressEvent, MiddleButtonReleaseEvent, RightButtonPressEvent, +RightButtonReleaseEvent, EnterEvent, LeaveEvent, KeyPressEvent, +KeyReleaseEvent, CharEvent, ExposeEvent, ConfigureEvent, TimerEvent, +MouseMoveEvent, + +vtkInteractorStyle subclasses may implement various styles of +interaction. Some common controls are + +### Left Mouse Move: rotate the camera around its focal point (if camera mode) or +rotate the actor around its origin (if actor mode). The rotation is in the +direction defined from the center of the renderer's viewport towards +the mouse position. In joystick mode, the magnitude of the rotation is +determined by the distance the mouse is from the center of the render +window. + +### Shift Left Mouse Move: pan the camera (if camera mode) or translate the actor (if +actor mode). In joystick mode, the direction of pan or translation is +from the center of the viewport towards the mouse position. In trackball +mode, the direction of motion is the direction the mouse moves. + +### Ctrl/Cmd Left Mouse Move: zoom the camera (if camera mode) or scale the actor (if +actor mode). Zoom in/increase scale if the mouse position is in the top +half of the viewport; zoom out/decrease scale if the mouse position is in +the bottom half. In joystick mode, the amount of zoom is controlled by the +distance of the mouse pointer from the horizontal centerline of the +window. + +### Keypress r: reset the camera view along the current view +direction. Centers the actors and moves the camera so that all actors are +visible. + +### Keypress s: modify the representation of all actors so that they are +surfaces. + +### Keypress w: modify the representation of all actors so that they are +wireframe. + diff --git a/Sources/Rendering/Core/InteractorStyle/index.js b/Sources/Rendering/Core/InteractorStyle/index.js index 223c00c4d71..b80019f8843 100644 --- a/Sources/Rendering/Core/InteractorStyle/index.js +++ b/Sources/Rendering/Core/InteractorStyle/index.js @@ -166,15 +166,6 @@ function vtkInteractorStyle(publicAPI, model) { const rwi = model.interactor; rwi.getRenderWindow().setDesiredUpdateRate(rwi.getDesiredUpdateRate()); model.invokeStartInteractionEvent({ type: 'StartInteractionEvent' }); - // if (model.seTimers && - // !(model.timerId = rwi.createRepeatingTimer(model.timerDuration)) ) { - // // vtkTestingInteractor cannot create timers - // if (std::string(rwi->GetClassName()) != "vtkTestingInteractor") - // { - // vtkErrorMacro(<< "Timer start failed"); - // } - // this->State = VTKIS_NONE; - // } } }; @@ -183,13 +174,6 @@ function vtkInteractorStyle(publicAPI, model) { if (model.animationState === STATES.VTKIS_ANIM_OFF) { const rwi = model.interactor; rwi.getRenderWindow().setDesiredUpdateRate(rwi.getStillUpdateRate()); - // if (this->UseTimers && - // // vtkTestingInteractor cannot create timers - // std::string(rwi->GetClassName()) != "vtkTestingInteractor" && - // !rwi->DestroyTimer(this->TimerId)) - // { - // vtkErrorMacro(<< "Timer stop failed"); - // } publicAPI.invokeEndInteractionEvent({ type: 'EndInteractionEvent' }); rwi.render(); } @@ -221,20 +205,6 @@ export function extend(publicAPI, model, initialValues = {}) { model.unsubscribes = new Map(); - // Create get-only macros - // macro.get(publicAPI, model, ['myProp2', 'myProp4']); - - // Create get-set macros - // macro.getSet(publicAPI, model, ['myProp3']); - - // Create set macros for array (needs to know size) - // macro.setArray(publicAPI, model, ['myProp5'], 4); - - // Create get macros for array - // macro.getArray(publicAPI, model, ['myProp1', 'myProp5']); - - // For more macro methods, see "Sources/macro.js" - // Object specific methods vtkInteractorStyle(publicAPI, model); } diff --git a/Sources/Rendering/Core/Light/api.md b/Sources/Rendering/Core/Light/api.md index 055276722ca..003e41790b4 100644 --- a/Sources/Rendering/Core/Light/api.md +++ b/Sources/Rendering/Core/Light/api.md @@ -30,13 +30,6 @@ intensity=1, the light is turned on, positional lighting is off, ConeAngle=30, AttenuationValues=(1,0,0), Exponent=1 and the TransformMatrix is NULL. -### render(renderer, int) - -Abstract interface to renderer. Each concrete subclass of vtkLight -will load its data into the graphics system in response to this method -invocation. The actual loading is performed by a vtkLightDevice -subclass, which will get created automatically. - ### ambientColor, diffuseColor, specularColor Set/Get the color of the light. It is possible to set the ambient, diff --git a/Sources/Rendering/Core/Mapper/api.md b/Sources/Rendering/Core/Mapper/api.md index 7e771bba9d4..7824dbd3f25 100644 --- a/Sources/Rendering/Core/Mapper/api.md +++ b/Sources/Rendering/Core/Mapper/api.md @@ -32,17 +32,6 @@ draw a mesh with some edges a different color, and the edges lie on the mesh, this feature can be useful to get nice looking lines. (See the ResolveCoincidentTopology-related methods.) -### render(renderer, actor) (VIRTUAL) - -Method initiates the mapping process. Generally sent by the actor -as each frame is rendered. - -### releaseGraphicsResources(win) (VIRTUAL) - -Release any graphics resources that are being consumed by this mapper. -The parameter window could be used to determine which graphic -resources to release. - ### lookupTable Set/Get a lookup table for the mapper to use. diff --git a/Sources/Rendering/Core/Prop/index.js b/Sources/Rendering/Core/Prop/index.js index 458e41b12d7..8627ba92bec 100644 --- a/Sources/Rendering/Core/Prop/index.js +++ b/Sources/Rendering/Core/Prop/index.js @@ -53,15 +53,11 @@ function vtkProp(publicAPI, model) { publicAPI.removeTexture = (texture) => { const newTextureList = model.textures.filter(item => item === texture); if (model.texture.length !== newTextureList.length) { - texture.releaseGraphicsResources(model.vtkWindow); model.textures = newTextureList; } }; publicAPI.removeAllTextures = () => { - model.textures.forEach(texture => { - texture.releaseGraphicsResources(model.vtkWindow); - }); model.textures = []; }; } diff --git a/Sources/Rendering/Core/Property/api.md b/Sources/Rendering/Core/Property/api.md index 06ad6271e68..a3e6e63d11e 100644 --- a/Sources/Rendering/Core/Property/api.md +++ b/Sources/Rendering/Core/Property/api.md @@ -17,21 +17,6 @@ specular color, and edge color white; ambient coefficient=0; diffuse coefficient=0; specular coefficient=0; specular power=1; Gouraud shading; and surface representation. Backface and frontface culling are off. -### render(actor, renderer) - -This method causes the property to set up whatever is required for -its instance variables. This is actually handled by a subclass of -vtkProperty, which is created automatically. This -method includes the invoking actor as an argument which can -be used by property devices that require the actor. - -### backfaceRender(actor, renderer) - -This method renders the property as a backface property. TwoSidedLighting -must be turned off to see any backface properties. Note that only -colors and opacity are used for backface properties. Other properties -such as Representation, Culling are specified by the Property. - ### lighting Set/Get lighting flag for an object. Initial value is true. @@ -141,23 +126,6 @@ Set/Get the color of primitive edges (if edge visibility is enabled). Set/Get the width of a Line. The width is expressed in screen units. This is only implemented for OpenGL. The default is 1.0. -### lineStipplePattern - -Set/Get the stippling pattern of a Line, as a 16-bit binary pattern -(1 = pixel on, 0 = pixel off). -This is only implemented for OpenGL. The default is 0xFFFF. - -```js -property.setLineStipplePattern(b0, b1); -const uint8Array = property.getLineStipplePattern(); -``` - -### lineStippleRepeatFactor - -Set/Get the stippling repeat factor of a Line, which specifies how -many times each bit in the pattern is to be repeated. -This is only implemented for OpenGL. The default is 1. - ### pointSize Set/Get the diameter of a point. The size is expressed in screen units. @@ -174,9 +142,3 @@ away from camera are not drawn. Turn on/off fast culling of polygons based on orientation of normal with respect to camera. If frontface culling is on, polygons facing towards camera are not drawn. - -### releaseGraphicsResources(win) - -Release any graphics resources that are being consumed by this -property. The parameter window could be used to determine which graphic -resources to release. diff --git a/Sources/Rendering/Core/Property/index.js b/Sources/Rendering/Core/Property/index.js index 4c809934d98..31c039763b3 100644 --- a/Sources/Rendering/Core/Property/index.js +++ b/Sources/Rendering/Core/Property/index.js @@ -44,8 +44,6 @@ function vtkProperty(publicAPI, model) { return [].concat(model.color); }; - publicAPI.render = notImplemented('render'); - publicAPI.postRender = notImplemented('postRender'); publicAPI.addShaderVariable = notImplemented('AddShaderVariable'); publicAPI.setInterpolationToFlat = () => publicAPI.setInterpolation(VTK_INTERPOLATION.FLAT); @@ -54,12 +52,6 @@ function vtkProperty(publicAPI, model) { publicAPI.getInterpolationAsString = () => VTK_SHADING_MODEL[model.interpolation]; - publicAPI.setLineStipplePattern = (b0, b1) => { - model.lineStipplePattern[0] = b0; - model.lineStipplePattern[1] = b1; - publicAPI.modified(); - }; - publicAPI.setRepresentationToWireframe = () => publicAPI.setRepresentation(VTK_REPRESENTATION.WIREFRAME); publicAPI.setRepresentationToSurface = () => publicAPI.setRepresentation(VTK_REPRESENTATION.SURFACE); publicAPI.setRepresentationToPoints = () => publicAPI.setRepresentation(VTK_REPRESENTATION.POINTS); @@ -88,8 +80,6 @@ const DEFAULT_VALUES = { frontfaceCulling: false, pointSize: 1, lineWidth: 1, - lineStipplePattern: null, - lineStippleRepeatFactor: 1, lighting: true, shading: false, @@ -101,16 +91,9 @@ const DEFAULT_VALUES = { export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); - // Internal objects - model.lineStipplePattern = new Uint8Array(2); - model.lineStipplePattern[0] = 255; - model.lineStipplePattern[1] = 255; - // Build VTK API macro.obj(publicAPI, model); - macro.get(publicAPI, model, [ - 'lineStipplePattern', - ]); + macro.setGet(publicAPI, model, [ 'lighting', 'interpolation', @@ -121,8 +104,6 @@ export function extend(publicAPI, model, initialValues = {}) { 'opacity', 'edgeVisibility', 'lineWidth', - 'lineStipplePattern', - 'lineStippleRepeatFactor', 'pointSize', 'backfaceCulling', 'frontfaceCulling', diff --git a/Sources/Rendering/Core/Property2D/api.md b/Sources/Rendering/Core/Property2D/api.md new file mode 100644 index 00000000000..63adda0783f --- /dev/null +++ b/Sources/Rendering/Core/Property2D/api.md @@ -0,0 +1,39 @@ +## Introduction + +represent surface properties of a 2D geometric object + +vtkProperty2D is an object that represents lighting and other surface +properties of a 2D geometric object. The primary properties that can be +set are colors (overall, ambient, diffuse, specular, and edge color); +specular power; opacity of the object; the representation of the +object (points, wireframe, or surface); and the shading method to be +used (flat, Gouraud, and Phong). Also, some special graphics features +like backface properties can be set and manipulated with this object. + +### newInstance() + +Construct object with object color, ambient color, diffuse color, +specular color, and edge color white; ambient coefficient=0; diffuse +coefficient=0; specular coefficient=0; specular power=1; Gouraud shading; +and surface representation. Backface and frontface culling are off. + +### setColor(r, g, b) / getColor() : [r, g, b] + +Set the color of the object. Has the side effect of setting the +ambient diffuse and specular colors as well. This is basically +a quick overall color setting method. + +### opacity + +Set/Get the object's opacity. 1.0 is totally opaque and 0.0 is completely +transparent. + +### lineWidth + +Set/Get the width of a Line. The width is expressed in screen units. +This is only implemented for OpenGL. The default is 1.0. + +### pointSize + +Set/Get the diameter of a point. The size is expressed in screen units. +This is only implemented for OpenGL. The default is 1.0. diff --git a/Sources/Rendering/Core/RenderWindow/api.md b/Sources/Rendering/Core/RenderWindow/api.md index 4263e751be3..2a1d5a9f02c 100644 --- a/Sources/Rendering/Core/RenderWindow/api.md +++ b/Sources/Rendering/Core/RenderWindow/api.md @@ -1,34 +1,15 @@ ## newInstance() -create a window for renderers to draw into +create a window for renderers to be placed into RenderWindow is an object that specify the behavior of a rendering window. A rendering window is a window in a graphical user -interface where renderers draw their images. Methods are provided to -synchronize the rendering process, set window size, and control double -buffering. +interface where renderers draw their images. ### addRenderer(renderer)/ removeRenderer(renderer) / hasRenderer() : Boolean Manage associated renderers. -### render() - -Trigger a render call on each renderers. - -### start() - -Initialize the rendering process. - -### finalize() - -Finalize the rendering process. - -### frame() - -A termination method performed at the end of the rendering process -to do things like swapping buffers (if necessary) or similar actions. - ### getRenderers() : Array Return the array of Renderers. @@ -60,7 +41,3 @@ Get the number of layers for renderers. Each renderer should have its layer set individually. Some algorithms iterate through all layers, so it is not wise to set the number of layers to be exorbitantly large (say bigger than 100). - -### getNeverRendered() - -Return true if that render window never rendered anything yet. diff --git a/Sources/Rendering/Core/RenderWindowInteractor/api.md b/Sources/Rendering/Core/RenderWindowInteractor/api.md index 2576526e6da..699cfe3040e 100644 --- a/Sources/Rendering/Core/RenderWindowInteractor/api.md +++ b/Sources/Rendering/Core/RenderWindowInteractor/api.md @@ -1,16 +1,14 @@ -vtkRenderWindowInteractor - platform-independent render window +vtkRenderWindowInteractor - handle render window interaction including picking and frame rate control. ### Description -vtkRenderWindowInteractor provides a platform-independent interaction -mechanism for mouse/key/time events. It serves as a base class for -platform-dependent implementations that handle routing of mouse/key/timer +vtkRenderWindowInteractor provides an interaction +mechanism for mouse/key/time events. It handles routing of mouse/key/timer messages to vtkInteractorObserver and its subclasses. vtkRenderWindowInteractor -also provides controls for picking, rendering frame rate, and headlights. +also provides controls for picking, rendering frame rate. -vtkRenderWindowInteractor has changed from previous implementations and -now serves only as a shell to hold user preferences and route messages to +vtkRenderWindowInteractor serves to hold user preferences and route messages to vtkInteractorStyle. Callbacks are available for many events. Platform specific subclasses should provide methods for manipulating timers, TerminateApp, and an event loop if required via @@ -19,6 +17,6 @@ Initialize/Start/Enable/Disable. ### Caveats vtkRenderWindowInteractor routes events through VTK's command/observer design pattern. That is, when vtkRenderWindowInteractor (actually, one of -its subclasses) sees a platform-dependent event, it translates this into +its subclasses) sees a event, it translates this into a VTK event using the InvokeEvent() method. Then any vtkInteractorObservers registered for that event are expected to respond as appropriate. diff --git a/Sources/Rendering/Core/RenderWindowInteractor/index.js b/Sources/Rendering/Core/RenderWindowInteractor/index.js index dc07342aea8..a91cd4bf9e0 100644 --- a/Sources/Rendering/Core/RenderWindowInteractor/index.js +++ b/Sources/Rendering/Core/RenderWindowInteractor/index.js @@ -39,15 +39,6 @@ const eventsWeHandle = [ 'Swipe', ]; -// ---------------------------------------------------------------------------- -// Static API -// ---------------------------------------------------------------------------- - - -// ---------------------------------------------------------------------------- -// vtkMyClass methods -// ---------------------------------------------------------------------------- - function vtkRenderWindowInteractor(publicAPI, model) { // Set our className model.classHierarchy.push('vtkRenderWindowInteractor'); @@ -77,14 +68,6 @@ function vtkRenderWindowInteractor(publicAPI, model) { //---------------------------------------------------------------------- publicAPI.setRenderWindow = (aren) => { vtkErrorMacro('you want to call setView(view) instead of setRenderWindow on a vtk.js interactor'); - // if (model.renderWindow !== aren) { - // model.renderWindow = aren; - // if (model.renderWindow != null) { - // if (model.renderWindow.getInteractor() !== publicAPI) { - // model.renderWindow.setInteractor(publicAPI); - // } - // } - // } }; //---------------------------------------------------------------------- diff --git a/Sources/Rendering/Core/Renderer/api.md b/Sources/Rendering/Core/Renderer/api.md index 01c67d6e1ba..650750d27c2 100644 --- a/Sources/Rendering/Core/Renderer/api.md +++ b/Sources/Rendering/Core/Renderer/api.md @@ -1,11 +1,10 @@ -Renderer provides an abstract specification for renderers. A renderer -is an object that controls the rendering process for objects. Rendering -is the process of converting geometry, a specification for lights, and -a camera view into an image. vtkRenderer also performs coordinate -transformation between world coordinates, view coordinates (the computer -graphics rendering coordinate system), and display coordinates (the -actual screen coordinates on the display device). Certain advanced -rendering features such as two-sided lighting can also be controlled. +## Introduction + +Renderer is a Viewport designed to hold 3D props. As such it contains +an instance of vtkCamera, a collection of vtkLights, and vtkActors. It exists +within a RenderWindow. A RenderWindow may have multiple Renderers +representing different viewports of the Window and Renderers can be layered +on top of each other as well. ### addActor(actor) / removeActor(actor) / getActors() : [] @@ -70,34 +69,6 @@ TimeFactor has been taken out of the render process. It is still computed in case someone finds it useful. It may be taken away in the future. -### render() - -CALLED BY vtkRenderWindow ONLY. End-user pass your way and call -vtkRenderWindow::Render(). -Create an image. This is a superclass method which will in turn -call the DeviceRender method of Subclasses of vtkRenderer. - -### deviceRender() (NoOp) - -Create an image. Subclasses of vtkRenderer must implement this method. - -### deviceRenderTranslucentPolygonalGeometry() - -Render translucent polygonal geometry. Default implementation just call -UpdateTranslucentPolygonalGeometry(). -Subclasses of vtkRenderer that can deal with depth peeling must -override this method. -It updates boolean ivar LastRenderingUsedDepthPeeling. - -### clearLights() (NoOp) - -Internal method temporarily removes lights before reloading -them into graphics pipeline. - -### clear() (NoOp) - -Clear the image to the background color. - ### visibleActorCount() / visibleVolumeCount() Returns the number of visible actors. @@ -131,10 +102,6 @@ When this flag is off, render commands are ignored. It is used to either multiplex a vtkRenderWindow or render only part of a vtkRenderWindow. By default, Draw is on. -### ambiant (set/get Number 0 to 1) - -Intensity of ambient lighting. - ### interactive (set/get Boolean) Turn on/off interactive status. An interactive renderer is one that diff --git a/Sources/Rendering/Core/Renderer/index.js b/Sources/Rendering/Core/Renderer/index.js index dd89cb34354..570890965e3 100644 --- a/Sources/Rendering/Core/Renderer/index.js +++ b/Sources/Rendering/Core/Renderer/index.js @@ -81,22 +81,6 @@ function vtkRenderer(publicAPI, model) { // Set our className model.classHierarchy.push('vtkRenderer'); - publicAPI.releaseGraphicsResources = vtkWindow => { - if (model.backgroundTexture) { - model.backgroundTexture.releaseGraphicsResources(vtkWindow); - } - - model.props.forEach(prop => { - if (prop) { - prop.releaseGraphicsResources(vtkWindow); - } - }); - }; - - // macro - // - getAllocatedRenderTime - // - getTimeFactor - publicAPI.updateCamera = () => { if (!model.activeCamera) { vtkDebugMacro('No cameras are on, creating one.'); @@ -388,8 +372,6 @@ function vtkRenderer(publicAPI, model) { // the view angle to become very small and cause bad depth sorting. model.activeCamera.setViewAngle(30.0); - expandBounds(boundsToUse, model.activeCamera.getModelTransformMatrix()); - center[0] = (boundsToUse[0] + boundsToUse[1]) / 2.0; center[1] = (boundsToUse[2] + boundsToUse[3]) / 2.0; center[2] = (boundsToUse[4] + boundsToUse[5]) / 2.0; @@ -467,15 +449,8 @@ function vtkRenderer(publicAPI, model) { } let vn = null; let position = null; - if (!model.activeCamera.getUseOffAxisProjection()) { - vn = model.activeCamera.getViewPlaneNormal(); - position = model.activeCamera.getPosition(); - expandBounds(boundsToUse, model.activeCamera.getModelTransformMatrix()); - } else { - position = model.activeCamera.getEyePosition(); - vn = model.activeCamera.getEyePlaneNormal(); - expandBounds(boundsToUse, model.activeCamera.getModelViewTransformMatrix()); - } + vn = model.activeCamera.getViewPlaneNormal(); + position = model.activeCamera.getPosition(); const a = -vn[0]; const b = -vn[1]; @@ -547,21 +522,6 @@ function vtkRenderer(publicAPI, model) { publicAPI.setRenderWindow = renderWindow => { if (renderWindow !== model.renderWindow) { - // This renderer is be dis-associated with its previous render window. - // this information needs to be passed to the renderer's actors and - // volumes so they can release and render window specific (or graphics - // context specific) information (such as display lists and texture ids) - model.props.forEach(prop => { - prop.releaseGraphicsResources(model.renderWindow); - }); - // what about lights? - // what about cullers? - publicAPI.releaseGraphicsResources(model.renderWindow); - - if (model.backgroundTexture && model.renderWindow) { - model.backgroundTexture.releaseGraphicsResources(model.renderWindow); - } - model.vtkWindow = renderWindow; model.renderWindow = renderWindow; } diff --git a/Sources/Rendering/Core/Texture/api.md b/Sources/Rendering/Core/Texture/api.md index 577192b3701..daecb83100e 100644 --- a/Sources/Rendering/Core/Texture/api.md +++ b/Sources/Rendering/Core/Texture/api.md @@ -16,16 +16,11 @@ to save memory resources.) Currently only 2D texture maps are supported, even though the data pipeline supports 1,2, and 3D texture coordinates. -Some renderers such as old OpenGL require that the texture map dimensions -are a power of two in each direction. If a non-power of two texture map is -used, it is automatically resampled to a power of two in one or more -directions, at the cost of an expensive computation. If the OpenGL -implementation is recent enough (OpenGL>=2.0 or -extension GL_ARB_texture_non_power_of_two exists) there is no such -restriction and no extra computational cost. +Some systems require that the texture map dimensions +are a power of two in each direction. ### See Also -vtkProp vtkRenderer vtkOpenGLTexture +vtkProp vtkRenderer ### Repeat diff --git a/Sources/Rendering/Core/Viewport/api.md b/Sources/Rendering/Core/Viewport/api.md index dcf2182a9dc..60e5755e1f8 100644 --- a/Sources/Rendering/Core/Viewport/api.md +++ b/Sources/Rendering/Core/Viewport/api.md @@ -1,3 +1,14 @@ +## Introduction + +vtkViewport represents part or all of a RenderWindow. It holds a +colleciton of props that will be rendered into the area it represents. +This class also contains methods to convert between coordinate systems +commonly used in rendering. + +## See Also + +vtkActor vtkRenderer vtkRenderWindow vtkCoordinate vtkProp + ### addViewProp(prop) Add a prop to the list of props. Does nothing if the prop is @@ -26,3 +37,12 @@ Remove all props from the list of props. Add/Remove different types of props to the renderer. These methods are all synonyms to AddViewProp and RemoveViewProp. They are here for convenience and backwards compatibility. + +### normalizedDisplayToNormalizedViewport (x, y, z) +### normalizedViewportToView (x, y, z) +### viewToNormalizedDisplay (x, y, z) +### normalizedViewportToNormalizedDisplay (x, y, z) +### viewToNormalizedViewport (x, y, z) + +See vtkCoordinate for the definition of these coordinate systems. + diff --git a/Sources/Rendering/Core/Viewport/index.js b/Sources/Rendering/Core/Viewport/index.js index 6c0092b3385..3f7408de051 100644 --- a/Sources/Rendering/Core/Viewport/index.js +++ b/Sources/Rendering/Core/Viewport/index.js @@ -24,15 +24,11 @@ function vtkViewport(publicAPI, model) { publicAPI.removeViewProp = (prop) => { const newPropList = model.props.filter(item => item === prop); if (model.props.length !== newPropList.length) { - prop.releaseGraphicsResources(model.vtkWindow); model.props = newPropList; } }; publicAPI.removeAllViewProps = () => { - model.props.forEach(prop => { - prop.releaseGraphicsResources(model.vtkWindow); - }); model.props = []; }; diff --git a/Sources/Rendering/OpenGL/Actor/api.md b/Sources/Rendering/OpenGL/Actor/api.md deleted file mode 100644 index ecb1e16a49d..00000000000 --- a/Sources/Rendering/OpenGL/Actor/api.md +++ /dev/null @@ -1,11 +0,0 @@ -OpenGL actor - -vtkOpenGLRenderer is designed to view/render a vtkActor - -### build(prepass) - -preparefor rendering - -### render(prepass) - -do the rendering diff --git a/Sources/Rendering/OpenGL/Camera/api.md b/Sources/Rendering/OpenGL/Camera/api.md deleted file mode 100644 index 36836ed5d51..00000000000 --- a/Sources/Rendering/OpenGL/Camera/api.md +++ /dev/null @@ -1,11 +0,0 @@ -OpenGL camera - -vtkOpenGLCamera is designed to handle opengl calls for the camera - -### build(prepass) - -preparefor rendering - -### render(prepass) - -do the rendering diff --git a/Sources/Rendering/OpenGL/CellArrayBufferObject/api.md b/Sources/Rendering/OpenGL/CellArrayBufferObject/api.md index 2ae0ca67ff1..6acc625124c 100644 --- a/Sources/Rendering/OpenGL/CellArrayBufferObject/api.md +++ b/Sources/Rendering/OpenGL/CellArrayBufferObject/api.md @@ -1,9 +1,42 @@ WebGL build ArrayBufferObjects based on CellArrays The vtkCellArrayBufferObject is designed to build array buffers that do not rely on -an index buffer but rather just a glDrawArrays. They are build based on cellArrays +an index buffer but rather just a glDrawArrays. They are built based on cellArrays that get passed from a PolyDataMapper ### createVBO = (cellArray, inRep, outRep, points, normals, tcoords, colors) The main entry point, builds the array buffer based on the supplied arguments + +### elementCount + +How many elements are in this buffer. Generally you would call DrawArrays +with this number. + +### stride + +The stride in bytes between one element and the next + +### vertexOffset + +The offset in bytes from the start of an element and the vertex data + +### normalOffset + +The offset in bytes from the start of an element and the normal data + +### tCoordOffset + +The offset in bytes from the start of an element and the texture coordinate data + +### tCoordComponents + +The number of components in a texture coordinate, typically 2 + +### colorOffset + +The offset in bytes from the start of an element and the color data + +### colorComponents + +The number of components in a color value typically 4 diff --git a/Sources/Rendering/OpenGL/CellArrayBufferObject/index.js b/Sources/Rendering/OpenGL/CellArrayBufferObject/index.js index 4f71c2687dc..52703d17cf2 100644 --- a/Sources/Rendering/OpenGL/CellArrayBufferObject/index.js +++ b/Sources/Rendering/OpenGL/CellArrayBufferObject/index.js @@ -40,14 +40,16 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) { const colorComponents = (options.colors ? options.colors.getNumberOfComponents() : 0); const textureComponents = (options.tcoords ? options.tcoords.getNumberOfComponents() : 0); + // the values of 4 below are because floats are 4 bytes + if (options.normals) { - model.normalOffset = /* sizeof(float) */ 4 * model.blockSize; + model.normalOffset = 4 * model.blockSize; model.blockSize += 3; normalData = options.normals.getData(); } if (options.tcoords) { - model.tCoordOffset = /* sizeof(float) */ 4 * model.blockSize; + model.tCoordOffset = 4 * model.blockSize; model.tCoordComponents = textureComponents; model.blockSize += textureComponents; tcoordData = options.tcoords.getData(); @@ -55,12 +57,11 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) { if (options.colors) { model.colorComponents = options.colors.getNumberOfComponents(); - model.colorOffset = /* sizeof(float) */ 4 * model.blockSize; -// model.blockSize += 1; + model.colorOffset = 4 * model.blockSize; model.blockSize += model.colorComponents; colorData = options.colors.getData(); } - model.stride = /* sizeof(float) */ 4 * model.blockSize; + model.stride = 4 * model.blockSize; let pointIdx = 0; let normalIdx = 0; @@ -68,8 +69,6 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) { let colorIdx = 0; let cellCount = 0; - // const colorHolder = new Uint8Array(4); - const addAPoint = function addAPoint(i) { // Vertices pointIdx = i * 3; @@ -107,19 +106,6 @@ function vtkOpenGLCellArrayBufferObject(publicAPI, model) { packedVBO.push(colorData[colorIdx++] / 255.5); } } - // if (colorData !== null) { - // colorHolder[0] = colorData[colorIdx++]; - // colorHolder[1] = colorData[colorIdx++]; - // colorHolder[2] = colorData[colorIdx++]; - - // if (colorComponents === 4) { - // colorHolder[3] = colorData[colorIdx++]; - // } else { // must be 3 color components then - // colorHolder[3] = 255; - // } - - // packedVBO.push(new Float32Array(colorHolder.buffer)[0]); - // } }; const cellBuilders = { diff --git a/Sources/Rendering/OpenGL/Helper/api.md b/Sources/Rendering/OpenGL/Helper/api.md index 51041693ec1..cd1ca884577 100644 --- a/Sources/Rendering/OpenGL/Helper/api.md +++ b/Sources/Rendering/OpenGL/Helper/api.md @@ -12,9 +12,9 @@ The shader program The VertexArrayObject -### IBO +### CABO -The index buffer object +The cell array buffer object. See vtkCellArrayBufferObject ### shaderSourceTime diff --git a/Sources/Rendering/OpenGL/Helper/index.js b/Sources/Rendering/OpenGL/Helper/index.js index 80c8699241e..1823d785a20 100644 --- a/Sources/Rendering/OpenGL/Helper/index.js +++ b/Sources/Rendering/OpenGL/Helper/index.js @@ -27,7 +27,6 @@ const DEFAULT_VALUES = { shaderSourceTime: null, VAO: null, attributeUpdateTime: null, - IBO: null, CABO: null, }; diff --git a/Sources/Rendering/OpenGL/IndexBufferObject/api.md b/Sources/Rendering/OpenGL/IndexBufferObject/api.md deleted file mode 100644 index 3c3efc61952..00000000000 --- a/Sources/Rendering/OpenGL/IndexBufferObject/api.md +++ /dev/null @@ -1,52 +0,0 @@ -## OpenGL index buffer object - -OpenGL buffer object to store index data on the GPU. - -### createTriangleIndexBuffer(cellArray, points) - -Used to create an IBO for triangle primatives - -### appendTriangleIndexBuffer(indexArray, cells, points, vertexOffset) - -Used to create an IBO for triangle primatives - -### createTriangleLineIndexBuffer(cells) - -Create a IBO for wireframe polys/tris - -### appendTriangleLineIndexBuffer(indexArray, cells, vertexOffset); - -Create a IBO for wireframe polys/tris - -### createLineIndexBuffer(cells) - -Create a IBO for wireframe polys/tris - -### appendLineIndexBuffer(indexArray, cells, vertexOffset) - -Used to create an IBO for line primatives - -### createPointIndexBuffer(cells) - -Used to create an IBO for primatives as points - -### appendPointIndexBuffer(indexArray, cells, vertexOffset) - -Used to create an IBO for primatives as points - -### createStripIndexBuffer(cells, wireframe) - -Used to create an IBO for line strips and triangle strips (wireframe is a boolean option) - -### createEdgeFlagIndexBuffer(cells, edgeflags) - -Special index buffer for polys wireframe with edge visibility flags - -### createCellSupportArrays(cellArrays, cellCellMap, representation) - -Create supporting arays that are needed when rendering cell data. Some VTK cells -have to be broken into smaller cells for OpenGL When we have cell data we have to -map cell attributes from the VTK cell number to the actual OpenGL cell. The following -code fills in: - - cellCellMap which maps a openGL cell id to the VTK cell it came from diff --git a/Sources/Rendering/OpenGL/IndexBufferObject/index.js b/Sources/Rendering/OpenGL/IndexBufferObject/index.js deleted file mode 100644 index f9163fa8408..00000000000 --- a/Sources/Rendering/OpenGL/IndexBufferObject/index.js +++ /dev/null @@ -1,457 +0,0 @@ -import * as macro from '../../../macro'; -import vtkBufferObject from '../BufferObject'; -import DynamicTypedArray from '../../../../Sources/Common/Core/DynamicTypedArray'; -import { OBJECT_TYPE } from '../BufferObject/Constants'; - -/* eslint-disable no-multi-spaces */ - -// ---------------------------------------------------------------------------- -// Global methods -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -// Static API -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -// vtkOpenGLIndexBufferObject methods -// ---------------------------------------------------------------------------- - -function vtkOpenGLIndexBufferObject(publicAPI, model) { - // Set our className - model.classHierarchy.push('vtkOpenGLIndexBufferObject'); - - // Sizes/offsets are all in bytes as OpenGL API expects them. - publicAPI.createTriangleIndexBuffer = (cellData, points) => { - if (cellData === null) { - model.indexCount = 0; - return 0; - } - - const dynArray = new DynamicTypedArray({ chunkSize: 65500, arrayType: 'Uint16Array' }); - publicAPI.appendTriangleIndexBuffer(dynArray, cellData, points, 0); - const indexArray = dynArray.getFrozenArray(); - model.indexCount = indexArray.length; - if (model.indexCount > 0) { - publicAPI.upload(indexArray, OBJECT_TYPE.ELEMENT_ARRAY_BUFFER); - } - return model.indexCount; - }; - - publicAPI.appendTriangleIndexBuffer = (indexArray, cellData, points, vOffset) => { - const cells = cellData.getData(); - - let currentCellOffset = 0; - // const polygon = null; - - while (currentCellOffset < cells.length) { - const npts = cells[currentCellOffset]; - const idxOffset = currentCellOffset + 1; - - if (npts < 3) { - // ignore degenerate triangles - console.log(`skipping degenerate triangle at connectivity entry ${currentCellOffset}`); - } else if (npts === 3) { - indexArray.push(cells[idxOffset] + vOffset); - indexArray.push(cells[idxOffset + 1] + vOffset); - indexArray.push(cells[idxOffset + 2] + vOffset); - } else { // triangulate needed - // special cases for quads, penta, hex which are common - /* eslint-disable no-lonely-if */ - if (npts === 4) { - indexArray.push(cells[idxOffset] + vOffset); - indexArray.push(cells[idxOffset + 1] + vOffset); - indexArray.push(cells[idxOffset + 2] + vOffset); - indexArray.push(cells[idxOffset] + vOffset); - indexArray.push(cells[idxOffset + 2] + vOffset); - indexArray.push(cells[idxOffset + 3] + vOffset); - } else if (npts === 5) { - indexArray.push(cells[idxOffset] + vOffset); - indexArray.push(cells[idxOffset + 1] + vOffset); - indexArray.push(cells[idxOffset + 2] + vOffset); - indexArray.push(cells[idxOffset] + vOffset); - indexArray.push(cells[idxOffset + 2] + vOffset); - indexArray.push(cells[idxOffset + 3] + vOffset); - indexArray.push(cells[idxOffset] + vOffset); - indexArray.push(cells[idxOffset + 3] + vOffset); - indexArray.push(cells[idxOffset + 4] + vOffset); - } else if (npts === 6) { - indexArray.push(cells[idxOffset] + vOffset); - indexArray.push(cells[idxOffset + 1] + vOffset); - indexArray.push(cells[idxOffset + 2] + vOffset); - indexArray.push(cells[idxOffset] + vOffset); - indexArray.push(cells[idxOffset + 2] + vOffset); - indexArray.push(cells[idxOffset + 3] + vOffset); - indexArray.push(cells[idxOffset] + vOffset); - indexArray.push(cells[idxOffset + 3] + vOffset); - indexArray.push(cells[idxOffset + 4] + vOffset); - indexArray.push(cells[idxOffset] + vOffset); - indexArray.push(cells[idxOffset + 4] + vOffset); - indexArray.push(cells[idxOffset + 5] + vOffset); - } else { // 7 sided polygon or higher, do a full smart triangulation - console.log('7 more sides in a polygon is not yet implemented'); - // if (!polygon) { - // polygon = vtkPolygon::New(); - // tris = vtkIdList::New(); - // triPoints = vtkPoints::New(); - // } - - // vtkIdType *triIndices = new vtkIdType[npts]; - // triPoints->SetNumberOfPoints(npts); - // for (int i = 0; i < npts; ++i) { - // int idx = indices[i]; - // triPoints->SetPoint(i,points->GetPoint(idx)); - // triIndices[i] = i; - // } - // polygon->Initialize(npts, triIndices, triPoints); - // polygon->Triangulate(tris); - // for (int j = 0; j < tris->GetNumberOfIds(); ++j) { - // indexArray.push(static_cast(indices[tris->GetId(j)]+vOffset)); - // } - // delete [] triIndices; - } - } - - // move to next cell - currentCellOffset += (npts + 1); - } - - // if (polygon) { - // polygon.delete(); - // tris.delete(); - // triPoints.delete(); - // } - }; - - publicAPI.createLineIndexBuffer = (cellData) => { - if (cellData === null) { - model.indexCount = 0; - return 0; - } - - const dynArray = new DynamicTypedArray(); - publicAPI.appendLineIndexBuffer(dynArray, cellData, 0); - const indexArray = dynArray.getFrozenArray(); - model.indexCount = indexArray.length; - if (model.indexCount > 0) { - publicAPI.upload(indexArray, OBJECT_TYPE.ELEMENT_ARRAY_BUFFER); - } - return model.indexCount; - }; - - publicAPI.appendLineIndexBuffer = (indexArray, cellData, vOffset) => { - const cells = cellData.getData(); - - let currentCellOffset = 0; - - while (currentCellOffset < cells.length) { - const npts = cells[currentCellOffset]; - const idxOffset = currentCellOffset + 1; - - for (let i = 0; i < npts - 1; ++i) { - indexArray.push(cells[idxOffset + i] + vOffset); - indexArray.push(cells[idxOffset + i + 1] + vOffset); - } - - // move to next cell - currentCellOffset += (npts + 1); - } - }; - - publicAPI.createTriangleLineIndexBuffer = cellData => { - if (cellData === null) { - model.indexCount = 0; - return 0; - } - const dynArray = new DynamicTypedArray(); - publicAPI.appendTriangleLineIndexBuffer(dynArray, cellData, 0); - const indexArray = dynArray.getFrozenArray(); - model.indexCount = indexArray.length; - if (model.indexCount > 0) { - publicAPI.upload(indexArray, OBJECT_TYPE.ELEMENT_ARRAY_BUFFER); - } - return model.indexCount; - }; - - publicAPI.appendTriangleLineIndexBuffer = (indexArray, cellData, vOffset) => { - const cells = cellData.getData(); - - let currentCellOffset = 0; - - while (currentCellOffset < cells.length) { - const npts = cells[currentCellOffset]; - const idxOffset = currentCellOffset + 1; - - for (let i = 0; i < npts; ++i) { - indexArray.push(cells[idxOffset + i] + vOffset); - indexArray.push(cells[idxOffset + (i < (npts - 1) ? i + 1 : 0)] + vOffset); - } - - // move to next cell - currentCellOffset += (npts + 1); - } - }; - - publicAPI.createPointIndexBuffer = (cellData) => { - if (cellData === null) { - model.indexCount = 0; - return 0; - } - const dynArray = new DynamicTypedArray(); - publicAPI.appendPointIndexBuffer(dynArray, cellData, 0); - const indexArray = dynArray.getFrozenArray(); - model.indexCount = indexArray.length; - if (model.indexCount > 0) { - publicAPI.upload(indexArray, OBJECT_TYPE.ELEMENT_ARRAY_BUFFER); - } - return model.indexCount; - }; - - publicAPI.appendPointIndexBuffer = (indexArray, cellData, vOffset) => { - const cells = cellData.getData(); - - let currentCellOffset = 0; - - while (currentCellOffset < cells.length) { - const npts = cells[currentCellOffset]; - const idxOffset = currentCellOffset + 1; - - for (let i = 0; i < npts; ++i) { - indexArray.push(cells[idxOffset + i] + vOffset); - } - - // move to next cell - currentCellOffset += (npts + 1); - } - }; - - publicAPI.createStripIndexBuffer = (cellData, wireframeTriStrips) => { - if (cellData === null) { - model.indexCount = 0; - return 0; - } - - const cells = cellData.getData(); - - const dynArray = new DynamicTypedArray(); - - if (wireframeTriStrips) { - let currentCellOffset = 0; - - while (currentCellOffset < cells.length) { - const npts = cells[currentCellOffset]; - const idxOffset = currentCellOffset + 1; - - dynArray.push(cells[idxOffset]); - dynArray.push(cells[idxOffset + 1]); - - for (let i = 0; i < npts - 2; ++i) { - dynArray.push(cells[idxOffset + i]); - dynArray.push(cells[idxOffset + i + 2]); - dynArray.push(cells[idxOffset + i + 1]); - dynArray.push(cells[idxOffset + i + 2]); - } - - // move to next cell - currentCellOffset += (npts + 1); - } - } else { - let currentCellOffset = 0; - - while (currentCellOffset < cells.length) { - const npts = cells[currentCellOffset]; - const idxOffset = currentCellOffset + 1; - - for (let i = 0; i < npts - 2; ++i) { - dynArray.push(cells[idxOffset + i]); - dynArray.push(cells[idxOffset + i + 1 + (i % 2)]); - dynArray.push(cells[idxOffset + i + 1 + ((i + 1) % 2)]); - } - - // move to next cell - currentCellOffset += (npts + 1); - } - } - - const indexArray = dynArray.getFrozenArray(); - model.indexCount = indexArray.length; - if (model.indexCount > 0) { - publicAPI.upload(indexArray, OBJECT_TYPE.ELEMENT_ARRAY_BUFFER); - } - return model.indexCount; - }; - - publicAPI.createEdgeFlagIndexBuffer = (cellData, ef) => { - console.log('edge flag index buffer is not yet implemented.'); - // if (cellData === null) { - // model.indexCount = 0; - // return 0; - // } - // // vtkCellArray *cells, - // // vtkDataArray *ef) - // const info = computeIndexBufferInfo(cells); - // if (info.numberOfCells === 0) { - // model.indexCount = 0; - // return 0; - // } - // model.indexCount = info.numberOfVertices; - - // vtkIdType *pts = 0; - // vtkIdType npts = 0; - // std::vector indexArray; - // unsigned char *ucef = NULL; - // ucef = vtkUnsignedCharArray::SafeDownCast(ef)->GetPointer(0); - // indexArray.reserve(cells->GetData()->GetSize()*2); - // for (cells->InitTraversal(); cells->GetNextCell(npts,pts); ) - // { - // for (int j = 0; j < npts; ++j) - // { - // if (ucef[pts[j]] && npts > 1) // draw this edge and poly is not degenerate - // { - // // determine the ending vertex - // vtkIdType nextVert = (j == npts-1) ? pts[0] : pts[j+1]; - // indexArray.push(static_cast(pts[j])); - // indexArray.push(static_cast(nextVert)); - // } - // } - // } - // this->Upload(indexArray, vtkOpenGLIndexBufferObject::ElementArrayBuffer); - // this->IndexCount = indexArray.size(); - // return indexArray.size(); - }; - - publicAPI.createCellSupportArrays = (prims, cellCellMap, representation) => { - console.log('cell support arrays not yet implemented'); - // // vtkCellArray *prims[4], - // // std::vector &cellCellMap, - // // int representation - // // need an array to track what points to orig points - // size_t minSize = prims[0]->GetNumberOfCells() + - // prims[1]->GetNumberOfCells() + - // prims[2]->GetNumberOfCells() + - // prims[3]->GetNumberOfCells(); - // vtkIdType* indices(NULL); - // vtkIdType npts(0); - - // // make sure we have at least minSize - // cellCellMap.reserve(minSize); - // unsigned int vtkCellCount = 0; - - // // points - // for (prims[0]->InitTraversal(); prims[0]->GetNextCell(npts, indices); ) - // { - // for (int i=0; i < npts; ++i) - // { - // cellCellMap.push(vtkCellCount); - // } - // vtkCellCount++; - // } // for cell - - // if (representation == VTK_POINTS) - // { - // for (int j = 1; j < 4; j++) - // { - // for (prims[j]->InitTraversal(); prims[j]->GetNextCell(npts, indices); ) - // { - // for (int i=0; i < npts; ++i) - // { - // cellCellMap.push(vtkCellCount); - // } - // vtkCellCount++; - // } // for cell - // } - // } - // else // lines or surfaces - // { - // // lines - // for (prims[1]->InitTraversal(); prims[1]->GetNextCell(npts, indices); ) - // { - // for (int i = 0; i < npts-1; ++i) - // { - // cellCellMap.push(vtkCellCount); - // } - // vtkCellCount++; - // } // for cell - - // if (representation == VTK_WIREFRAME) - // { - // // polys - // for (prims[2]->InitTraversal(); prims[2]->GetNextCell(npts, indices); ) - // { - // for (int i = 0; i < npts; ++i) - // { - // cellCellMap.push(vtkCellCount); - // } - // vtkCellCount++; - // } // for cell - - // // strips - // for (prims[3]->InitTraversal(); prims[3]->GetNextCell(npts, indices); ) - // { - // cellCellMap.push(vtkCellCount); - // for (int i = 2; i < npts; ++i) - // { - // cellCellMap.push(vtkCellCount); - // cellCellMap.push(vtkCellCount); - // } - // vtkCellCount++; - // } // for cell - // } - // else - // { - // // polys - // for (prims[2]->InitTraversal(); prims[2]->GetNextCell(npts, indices); ) - // { - // if (npts > 2) - // { - // for (int i = 2; i < npts; ++i) - // { - // cellCellMap.push(vtkCellCount); - // } - // } - // vtkCellCount++; - // } // for cell - - // // strips - // for (prims[3]->InitTraversal(); prims[3]->GetNextCell(npts, indices); ) - // { - // for (int i = 2; i < npts; ++i) - // { - // cellCellMap.push(vtkCellCount); - // } - // vtkCellCount++; - // } // for cell - // } - // } - }; -} - -// ---------------------------------------------------------------------------- -// Object factory -// ---------------------------------------------------------------------------- - -const DEFAULT_VALUES = { - indexCount: 0, -}; - -// ---------------------------------------------------------------------------- - -export function extend(publicAPI, model, initialValues = {}) { - Object.assign(model, DEFAULT_VALUES, initialValues); - - // Inheritance - vtkBufferObject.extend(publicAPI, model); - - macro.get(publicAPI, model, ['indexCount']); - - // Object specific methods - vtkOpenGLIndexBufferObject(publicAPI, model); -} - -// ---------------------------------------------------------------------------- - -export const newInstance = macro.newInstance(extend); - -// ---------------------------------------------------------------------------- - -export default { newInstance, extend }; diff --git a/Sources/Rendering/OpenGL/VertexBufferObject/Constants.js b/Sources/Rendering/OpenGL/VertexBufferObject/Constants.js deleted file mode 100644 index d3762692935..00000000000 --- a/Sources/Rendering/OpenGL/VertexBufferObject/Constants.js +++ /dev/null @@ -1,7 +0,0 @@ -export const SHIFT_SCALE_METHOD = { - DISABLE_SHIFT_SCALE: 0, // Do not shift/scale point coordinates. Ever! - AUTO_SHIFT_SCALE: 1, // The default, automatic computation. - MANUAL_SHIFT_SCALE: 2, // Manual shift/scale provided (for use with AppendVBO) -}; - -export default { SHIFT_SCALE_METHOD }; diff --git a/Sources/Rendering/OpenGL/VertexBufferObject/api.md b/Sources/Rendering/OpenGL/VertexBufferObject/api.md deleted file mode 100644 index 0f01bb189a7..00000000000 --- a/Sources/Rendering/OpenGL/VertexBufferObject/api.md +++ /dev/null @@ -1,89 +0,0 @@ -## OpenGL vertex buffer object - -OpenGL buffer object to store geometry and/or attribute data on the GPU. - -### createVBO(points, numPoints, normals, tcoords, colors, colorComponents) - -Take the points, and pack them into this VBO. This currently takes whatever the input -type might be and packs them into a VBO using floats for the vertices and normals, and -unsigned char for the colors (if the array is non-null). - -### appendVBO(points, numPoints, normals, tcoords, colors, colorComponents) - -Take the points, and append them into this VBO. - -### coordShiftAndScaleEnabled - -Set/Get the variable indicating whether coordinate shift and scale is enabled. - -### coordShiftAndScaleMethod - -Set/Get the shift and scale method. The options are specified in the "Constants.js" -file, but are shown below: - -```js -export const SHIFT_SCALE_METHOD = { - DISABLE_SHIFT_SCALE: 0, // Do not shift/scale point coordinates. Ever! - AUTO_SHIFT_SCALE: 1, // The default, automatic computation. - MANUAL_SHIFT_SCALE: 2, // Manual shift/scale provided (for use with AppendVBO) -}; -``` - -### coordShift - -Set/Get the coordinate shift array. - -### coordScale - -Set/Get the coordinate scale array. - -## Coordinate Shift - -Coordinate shift and scale is not yet implemented. - -``` -By default, shift and scale vectors are enabled whenever CreateVBO is called with -points whose bounds are many bbox-lengths away from the origin. - - Shifting and scaling may be completely disabled, - or manually specified, or left at the default. - - Manual specification is for the case when you - will be calling AppendVBO instead of just CreateVBO - and know better bounds than the what CreateVBO - might produce. - - The automatic method tells CreatVBO to compute shift and - scale vectors that remap the points to the unit cube. - - // Get the shift and scale vectors computed by CreateVBO; - // or set the values CreateVBO and AppendVBO will use. - // Note that the "Set" methods **must** be called before the - // first time that CreateVBO or AppendVBO is invoked and - // should never be called afterwards. - // - // The CoordShiftAndScaleMethod describes how the shift - // and scale vectors are obtained (or that they should never - // be used). - // The GetCoordShiftAndScaleEnabled() method returns true if - // a shift and scale are currently being applied (or false if not). - // - // The "Get" methods are used by the mapper to modify the world - // and camera transformation matrices to match the scaling applied - // to coordinates in the VBO. - // CreateVBO only applies a shift and scale when the midpoint - // of the point bounding-box is distant from the origin by a - // factor of 10,000 or more relative to the size of the box - // along any axis. - // - // For example, if the x coordinates of the points range from - // 200,000 to 200,001 then the factor is - // 200,000.5 / (200,001 - 200,000) = 2x10^5, which is larger - // than 10,000 -- so the coordinates will be shifted and scaled. - // - // This is important as many OpenGL drivers use reduced precision - // to hold point coordinates. - // - // These methods are used by the mapper to determine the - // additional transform (if any) to apply to the rendering transform. -``` diff --git a/Sources/Rendering/OpenGL/VertexBufferObject/index.js b/Sources/Rendering/OpenGL/VertexBufferObject/index.js deleted file mode 100644 index edebe832de2..00000000000 --- a/Sources/Rendering/OpenGL/VertexBufferObject/index.js +++ /dev/null @@ -1,221 +0,0 @@ -import * as macro from '../../../macro'; -import vtkBufferObject from '../BufferObject'; -import DynamicTypedArray from '../../../Common/Core/DynamicTypedArray'; -import { SHIFT_SCALE_METHOD } from './Constants'; -import { OBJECT_TYPE } from '../BufferObject/Constants'; - -// ---------------------------------------------------------------------------- -// vtkOpenGLVertexBufferObject methods -// ---------------------------------------------------------------------------- - -function vtkOpenGLVertexBufferObject(publicAPI, model) { - // Set our className - model.classHierarchy.push('vtkOpenGLVertexBufferObject'); - - const packedVBO = new DynamicTypedArray(); // the data - - publicAPI.setType(OBJECT_TYPE.ARRAY_BUFFER); - - publicAPI.createVBO = (points, numPts, normals, tcoords, colors, colorComponents) => { - if (model.coordShiftAndScaleMethod === SHIFT_SCALE_METHOD.AUTO_SHIFT_SCALE) { - const bds = points.bounds; - const shift = [0, 0, 0]; - const scale = [1, 1, 1]; - let needed = false; - for (let i = 0; i < 3; ++i) { - shift[i] = bds[2 * i]; // -0.5 * (bds[2 * i + 1] + bds[2 * i]); - const delta = bds[(2 * i) + 1] - bds[2 * i]; - if (delta > 0.0 && Math.abs(shift[i]) / delta > 1.0e4) { - needed = true; - scale[i] = 1.0 / delta; - } else { - scale[i] = 1.0; - } - } - if (needed) { - model.setCoordShift(shift); - model.setCoordScale(scale); - } - } - // fast path - if (model.coordShiftAndScaleEnabled === false && tcoords === null && normals === null && - colors === null && points.getDataType() === 'Float32Array') { - const blockSize = 3; - model.vertexOffset = 0; - model.normalOffset = 0; - model.tCoordOffset = 0; - model.tCoordComponents = 0; - // colorComponents = 0; - model.colorOffset = 0; - model.stride = 4 * blockSize; // FIXME: Do we need to worry about hard-coded float size here - model.vertexCount = numPts; - publicAPI.upload(points.getData(), OBJECT_TYPE.ARRAY_BUFFER); - return; - } - - // slower path - model.vertexCount = 0; - publicAPI.appendVBO(points, numPts, normals, tcoords, colors, colorComponents); - publicAPI.upload(packedVBO, OBJECT_TYPE.ARRAY_BUFFER); - packedVBO.reset(); - }; - - publicAPI.appendVBO = (points, numPoints, normals, tcoords, colors, colorComponents) => { - // Figure out how big each block will be, currently 6 or 7 floats. - let blockSize = 3; - model.vertexOffset = 0; - model.normalOffset = 0; - model.tCoordOffset = 0; - model.tCoordComponents = 0; - model.colorComponents = 0; - model.colorOffset = 0; - - const pointData = points.getData(); - let normalData = null; - let tcoordData = null; - let colorData = null; - - const textureComponents = tcoords.getNumberOfComponents(); - - if (normals !== null) { - model.normalOffset = /* sizeof(float) */ 4 * blockSize; - blockSize += 3; - normalData = normals.getData(); - } - - if (tcoords !== null) { - model.tCoordOffset = /* sizeof(float) */ 4 * blockSize; - model.tCoordComponents = textureComponents; - blockSize += textureComponents; - tcoordData = tcoords.getData(); - } - - if (colors !== null) { - model.colorComponents = colorComponents; - model.colorOffset = /* sizeof(float) */ 4 * blockSize; - blockSize += 1; - colorData = colors.getData(); - } - model.stride = /* sizeof(float) */ 4 * blockSize; - - let pointIdx = 0; - let normalIdx = 0; - let tcoordIdx = 0; - let colorIdx = 0; - - const colorHolder = new Uint8Array(4); - - // TODO: optimize this somehow, lots of if statements in here - for (let i = 0; i < numPoints; ++i) { - pointIdx = i * 3; - normalIdx = i * 3; - tcoordIdx = i * textureComponents; - colorIdx = i * colorComponents; - - // Vertices - packedVBO.push(pointData[pointIdx++]); - packedVBO.push(pointData[pointIdx++]); - packedVBO.push(pointData[pointIdx++]); - - if (normalData !== null) { - packedVBO.push(normalData[normalIdx++]); - packedVBO.push(normalData[normalIdx++]); - packedVBO.push(normalData[normalIdx++]); - } - - if (tcoordData !== null) { - for (let j = 0; j < textureComponents; ++j) { - packedVBO.push(tcoordData[tcoordIdx++]); - } - } - - if (colorData !== null) { - colorHolder[0] = colorData[colorIdx++]; - colorHolder[1] = colorData[colorIdx++]; - colorHolder[2] = colorData[colorIdx++]; - - if (colorComponents === 4) { - colorHolder[3] = colorData[colorIdx++]; - } else { // must be 3 color components then - colorHolder[3] = 255; - } - - packedVBO.push(new Float32Array(colorHolder.buffer)[0]); - } - } - - model.vertexCount += numPoints; - }; - - publicAPI.setCoordShiftAndScaleMethod = shiftScaleMethod => { - console.log('coordinate shift and scale not yet implemented'); - }; - - publicAPI.setCoordShift = shiftArray => { - console.log('coordinate shift and scale not yet implemented'); - }; - - publicAPI.setCoordScale = scaleArray => { - console.log('coordinate shift and scale not yet implemented'); - }; -} - -// ---------------------------------------------------------------------------- -// Object factory -// ---------------------------------------------------------------------------- - -const DEFAULT_VALUES = { - coordShift: [0, 0, 0], - coordScale: [1, 1, 1], - shiftScaleMethod: SHIFT_SCALE_METHOD.DISABLE_SHIFT_SCALE, - coordShiftAndScaleEnabled: false, - vertexCount: 0, - stride: 0, - vertexOffset: 0, - normalOffset: 0, - tCoordOffset: 0, - tCoordComponents: 0, - colorOffset: 0, - numColorComponents: 0, -}; - -// ---------------------------------------------------------------------------- - -export function extend(publicAPI, model, initialValues = {}) { - Object.assign(model, DEFAULT_VALUES, initialValues); - - // Inheritance - vtkBufferObject.extend(publicAPI, model); - - macro.get(publicAPI, model, [ - 'coordShiftAndScaleEnabled', - 'vertexCount', - 'stride', - 'vertexOffset', - 'normalOffset', - 'tCoordOffset', - 'tCoordComponents', - 'colorOffset', - 'numColorComponents', - ]); - - // macro.get(publicAPI, model, [ - // { name: 'shiftScaleMethod', enum: SHIFT_SCALE_METHOD, type: 'enum' }, - // ]); - - macro.getArray(publicAPI, model, [ - 'coordShift', - 'coordScale', - ]); - - // Object specific methods - vtkOpenGLVertexBufferObject(publicAPI, model); -} - -// ---------------------------------------------------------------------------- - -export const newInstance = macro.newInstance(extend); - -// ---------------------------------------------------------------------------- - -export default { newInstance, extend }; diff --git a/Sources/Rendering/OpenGL/index.js b/Sources/Rendering/OpenGL/index.js index a84cdce90e7..85d556a2780 100644 --- a/Sources/Rendering/OpenGL/index.js +++ b/Sources/Rendering/OpenGL/index.js @@ -2,7 +2,6 @@ import vtkActor from './Actor'; import vtkBufferObject from './BufferObject'; import vtkCellArrayBufferObject from './CellArrayBufferObject'; import vtkHelper from './Helper'; -import vtkIndexBufferObject from './IndexBufferObject'; import vtkPolyDataMapper from './PolyDataMapper'; import vtkRenderer from './Renderer'; import vtkRenderWindow from './RenderWindow'; @@ -10,7 +9,6 @@ import vtkShader from './Shader'; import vtkShaderCache from './ShaderCache'; import vtkShaderProgram from './ShaderProgram'; import vtkVertexArrayObject from './VertexArrayObject'; -import vtkVertexBufferObject from './VertexBufferObject'; import vtkViewNodeFactory from './ViewNodeFactory'; export default { @@ -18,7 +16,6 @@ export default { vtkBufferObject, vtkCellArrayBufferObject, vtkHelper, - vtkIndexBufferObject, vtkPolyDataMapper, vtkRenderer, vtkRenderWindow, @@ -26,6 +23,5 @@ export default { vtkShaderCache, vtkShaderProgram, vtkVertexArrayObject, - vtkVertexBufferObject, vtkViewNodeFactory, };