vtk

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

README

Gosl. vtk. 3D Visualisation with the VTK tool kit

go.dev reference

More information is available in the documentation of this package.

This package uses the Visualisation Toolkit to generate interactive 3D visualisations.

Examples

Drawing spheres

The Sphere structure draws one sphere whereas the Spheres structure draws many spheres at once. A data file with the spheres coordinates and radii is considered.

Source code: ../examples/vtk_spheres01.go

Drawing an isosurface

Source code: ../examples/vtk_isosurf01.go

Documentation

Overview

Package vtk wraps the visualisation tool kit (VTK) for drawing 3D surfaces (scalar fields, vector fields, etc.)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arrow

type Arrow struct {

	// options
	X0         []float64 // origin of arrow
	V          []float64 // vector defining arrow
	ConePct    float64   // percentage of length to draw tip cone
	ConeRad    float64   // radius of cone
	CyliRad    float64   // cylinder radius
	Resolution int       // resolution of cross-section
	Color      []float64 // {red, green, blue, opacity}
	// contains filtered or unexported fields
}

Arrow adds an arrow to Scene

func NewArrow

func NewArrow() *Arrow

NewArrow allocates a new Arrow structure

func (*Arrow) AddTo

func (o *Arrow) AddTo(scn *Scene)

AddTo adds Arrow to Scene

type FxType added in v1.0.1

type FxType func(x []float64) (fval, vx, vy, vz float64)

FxType is a callback function to compute f, v := f(x) where v = dfdx

type IsoSurf

type IsoSurf struct {

	// options
	Limits        []float64 // {xmin,xmax, ymin,ymax, zmin,zmax}
	Ndiv          []int     // {nx, ny, nz}. all must be >= 2
	Frange        []float64 // {fmin, fmax}. min and max values of isosurface levels
	OctRotate     bool      // apply rotation to octahedral reference system
	Nlevels       int       // number of isosurface levels (0 or 1 => just one @ Levelmin)
	CmapType      string    // colormap type. e.g. "warm"
	CmapNclrs     int       // colormap number of colors
	CmapRangeType int       // colormap range type
	CmapFrange    []float64 // colormap fmin and fmax
	Color         []float64 // {red, green, blue, opacity}
	ShowWire      bool      // show wireframe of main object
	GridShowPts   bool      // show underlying grid
	// contains filtered or unexported fields
}

IsoSurf holds data to generate isosurfaces

CmapNclrs:
    0 => use fixed color
CmapRangeType:
    0 => [default] use sgrid range values (automatic)
    1 => use Frange
    2 => use CmapFrange

func NewIsoSurf

func NewIsoSurf(f FxType) *IsoSurf

NewIsoSurf allocates a new IsoSurf structure

func (*IsoSurf) AddTo

func (o *IsoSurf) AddTo(scn *Scene)

AddTo adds IsoSurf to Scene

type Scene

type Scene struct {

	// options
	AxesLen    float64   // length of x-y-z axes
	HydroLine  bool      // show hydrostatic line
	Reverse    bool      // reverse direction for default camera
	FullAxes   bool      // show negative and positive portions of axes
	WithPlanes bool      // show transparent auxiliary planes
	Interact   bool      // run interactive mode
	SaveEps    bool      // save eps figure upon exit
	SavePng    bool      // save png figure upon exit
	PngMag     int       // magnification for png file
	Fnk        string    // file name key (without .png)
	LblX       string    // label for x-axis
	LblY       string    // label for y-axis
	LblZ       string    // label for z-axis
	LblSz      int       // size of labels in points
	LblClr     []float64 // r,g,b color components for labels

	// window
	Zoom   float64 // zoom
	Width  int     // width of window
	Height int     // height of window
	// contains filtered or unexported fields
}

Scene holds essential data to draw and interact with the x-y-z Cartesian system

func NewScene

func NewScene() *Scene

NewScene allocates a new Scene structure

func (*Scene) Run

func (o *Scene) Run()

Run shows Scene in interactive mode or saving a .png file

func (*Scene) SetCamera

func (o *Scene) SetCamera(xUp, yUp, zUp, xFoc, yFoc, zFoc, xPos, yPos, zPos float64)

SetCamera sets camera

type Sphere

type Sphere struct {

	// options
	Cen   []float64 // centre x-y-z coordinates
	R     float64   // radius
	Color []float64 // {red, green, blue, opacity}
	// contains filtered or unexported fields
}

Sphere adds a sphere to Scene

func NewSphere

func NewSphere() *Sphere

NewSphere allocates a new Sphere structure

func (*Sphere) AddTo

func (o *Sphere) AddTo(scn *Scene)

AddTo adds Sphere to Scene

type Spheres

type Spheres struct {

	// options
	X     []float64 // x coordinates
	Y     []float64 // y coordinates
	Z     []float64 // z coordinates
	R     []float64 // radii
	Color []float64 // {red, green, blue, opacity}
	// contains filtered or unexported fields
}

Spheres adds a set of spheres (e.g. particles) to Scene

func NewSpheres

func NewSpheres() *Spheres

NewSpheres allocates a new set of spheres structure

func NewSpheresFromFile

func NewSpheresFromFile(filename string) *Spheres

NewSpheresFromFile add spheres (e.g. particles) by reading a file in the following format

 x    y    z    r
0.0  0.0  0.0  0.1
1.0  0.0  0.0  0.1
 ...

func (*Spheres) AddTo

func (o *Spheres) AddTo(scn *Scene)

AddTo adds Spheres to Scene

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL