ms

package module
v0.0.0-...-804368d Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 25 Imported by: 0

README

ms

mesh/fem software tui/opengl

Documentation

Index

Constants

View Source
const (
	Single = true
	Many   = false
)
View Source
const FileExtension = "ms"

Variables

View Source
var Operations []Operation
View Source
var WindowRatio float64 = 0.4

Functions

func Input3Float

func Input3Float(header string, prefix, postfix [3]string, defaultValue [3]float64) (
	w vl.Widget,
	gettext func() (_ [3]float64, ok bool),
	initialization func(),
)

func InputFloat

func InputFloat(prefix, postfix string, defaultValue float64) (
	w vl.Widget,
	gettext func() (_ float64, ok bool),
	initialization func(),
)

func InputUnsigned

func InputUnsigned(prefix, postfix string, defaultValue uint) (
	w vl.Widget,
	gettext func() (_ uint, ok bool),
	initialization func(),
)

func NewTui

func NewTui(mesh Mesh, closedApp *bool, actions *chan ds.Action) (tui vl.Widget, initialization func(), err error)

func Run

func Run() (err error)

func Select

func Select(name string, single bool, selector func(single bool) []uint) (
	w vl.Widget,
	gettext func() []uint,
	initialization func(),
)

func SelectAll

func SelectAll(m Mesh) (
	w vl.Widget,
	getCoords func() []uint,
	getElements func() []uint,
	initialization func(),
)

Types

type AddRemovable

type AddRemovable interface {
	AddNode(X, Y, Z float64) (id uint)
	AddLineByNodeNumber(n1, n2 uint) (id uint)
	AddTriangle3ByNodeNumber(n1, n2, n3 uint) (id uint, ok bool)
	AddQuadr4ByNodeNumber(n1, n2, n3, n4 uint) (id uint, ok bool)

	AddModel(m Model)

	AddLeftCursor(lc LeftCursor)

	// Add lines by convex points on one plane
	AddConvexLines(nodes, elements []uint)

	// split elements
	SplitLinesByDistance(lines []uint, distance float64, atBegin bool)
	SplitLinesByRatio(lines []uint, proportional float64, atBegin bool)
	SplitLinesByEqualParts(lines []uint, parts uint)
	SplitTri3To3Tri3(tris []uint)

	Intersection(nodes, elements []uint)

	// Engineering change coordinates with precision 0.5 mm = 0.0005 meter
	MergeNodes(minDistance float64)

	// merge lines into one only if have same point
	MergeLines(lines []uint)

	// Scale by ratio [sX,sY,sZ] and node
	ScaleOrtho(
		basePoint gog.Point3d,
		scale [3]float64,
		nodes, elements []uint,
	)

	// remove
	Remove(nodes, elements []uint)
	RemoveNodesWithoutElements()
	RemoveSameCoordinates()
	RemoveZeroLines()
	RemoveZeroTriangles()

	GetCoordByID(id uint) (c gog.Point3d, ok bool)

	GetCoords() []Coordinate
	GetElements() []Element
}

type Checkable

type Checkable interface {
	Check() error
}

type Coordinate

type Coordinate struct {
	gog.Point3d
	Removed bool
	// contains filtered or unexported fields
}

Coordinate store coordinate of points

func (Coordinate) Check

func (c Coordinate) Check() error

type Direction

type Direction uint8
const (
	DirX Direction = iota
	DirY
	DirZ
)

func (Direction) String

func (d Direction) String() string

type Editable

type Editable interface {
	Undo()
}

type ElType

type ElType uint8 // from 0 to 255
const (
	Line2     ElType = iota + 1 // 1
	Triangle3                   // 2
	Quadr4                      // 3

	ElRemove = math.MaxUint8 // 255
)

func (ElType) String

func (e ElType) String() string

type Element

type Element struct {
	ElementType ElType
	Indexes     []int // index of coordinate
	// contains filtered or unexported fields
}

Element is typical element for FEM. Examples:

Line o======o
ElType : 1
Indexes: 2 (amount indexes of coordinates)

Triangle o======o
          \    /
           \  /
            o
ElType : 2
Indexes: 3 (amount indexes of coordinates)

Quadr4 o======o
       |      |
       |      |
       o======o
ElType : 3
Indexes: 4 (amount indexes of coordinates)

func (Element) Check

func (e Element) Check() error

type Filable

type Filable interface {
	Open(name string) error
	IsChangedModel() bool
	GetPresentFilename() (name string)
	Save() error
	SaveAs(filename string) error
	Close()
}

type GroupID

type GroupID uint8
const (
	File GroupID = iota
	Edit
	View
	// PartOperations
	Selection
	AddRemove
	// Ignore
	Hide
	MoveCopy
	// 	TypModels
	// 	Check
	Plugin
)

func (GroupID) String

func (g GroupID) String() string

type Hidable

type Hidable interface {
	Hide(coordinates, elements []uint)
	UnhideAll()
}

type LeftCursor

type LeftCursor uint8
const (
	AddLinesLC LeftCursor = iota
	AddTrianglesLC
	AddQuardsLC
)

type Measurementable

type Measurementable interface {
}

type Model

type Model struct {
	Elements []Element
	Coords   []Coordinate
	Groups   struct {
		Data string
		// contains filtered or unexported fields
	}
	// contains filtered or unexported fields
}

func (*Model) AddConvexLines

func (mm *Model) AddConvexLines(nodes, elements []uint)

func (*Model) AddLeftCursor

func (mm *Model) AddLeftCursor(lc LeftCursor)

func (*Model) AddLineByNodeNumber

func (mm *Model) AddLineByNodeNumber(n1, n2 uint) (id uint)

func (*Model) AddModel

func (mm *Model) AddModel(m Model)

func (*Model) AddNode

func (mm *Model) AddNode(X, Y, Z float64) (id uint)

func (*Model) AddQuadr4ByNodeNumber

func (mm *Model) AddQuadr4ByNodeNumber(n1, n2, n3, n4 uint) (id uint, ok bool)

func (*Model) AddTriangle3ByNodeNumber

func (mm *Model) AddTriangle3ByNodeNumber(n1, n2, n3 uint) (id uint, ok bool)

func (*Model) Check

func (mm *Model) Check() error

func (*Model) ColorEdge

func (mm *Model) ColorEdge(isColor bool)

func (*Model) Copy

func (mm *Model) Copy(nodes, elements []uint,
	basePoint [3]float64,
	paths []diffCoordinate,
	addLines, addTri bool)

func (*Model) DemoSpiral

func (mm *Model) DemoSpiral(n uint)

func (*Model) DeselectAll

func (mm *Model) DeselectAll()

func (*Model) GetCoordByID

func (mm *Model) GetCoordByID(id uint) (c gog.Point3d, ok bool)

func (*Model) GetCoords

func (mm *Model) GetCoords() []Coordinate

func (*Model) GetElements

func (mm *Model) GetElements() []Element

func (*Model) GetPresentFilename

func (mm *Model) GetPresentFilename() (name string)

func (*Model) GetRootGroup

func (mm *Model) GetRootGroup() groups.Group

func (*Model) GetSelectElements

func (mm *Model) GetSelectElements(single bool, filter func(_ ElType) (acceptable bool)) (ids []uint)

func (*Model) GetSelectNodes

func (mm *Model) GetSelectNodes(single bool) (ids []uint)

func (*Model) Hide

func (mm *Model) Hide(nodes, elements []uint)

func (*Model) Intersection

func (mm *Model) Intersection(nodes, elements []uint)

func (*Model) InvertSelect

func (mm *Model) InvertSelect(nodes bool, elements []bool)

func (*Model) MergeLines

func (mm *Model) MergeLines(lines []uint)

func (*Model) MergeNodes

func (mm *Model) MergeNodes(minDistance float64)

func (*Model) Mirror

func (mm *Model) Mirror(nodes, elements []uint,
	basePoint [3]gog.Point3d,
	copyModel bool,
	addLines, addTri bool)

func (*Model) Move

func (mm *Model) Move(nodes, elements []uint,
	basePoint [3]float64,
	path diffCoordinate)

func (*Model) Open

func (mm *Model) Open(mesh groups.Mesh, filename string) (err error)

func (*Model) Redo

func (mm *Model) Redo()

func (*Model) Remove

func (mm *Model) Remove(nodes, elements []uint)

func (*Model) RemoveNodesWithoutElements

func (mm *Model) RemoveNodesWithoutElements()

func (*Model) RemoveSameCoordinates

func (mm *Model) RemoveSameCoordinates()

TODO remove

func (*Model) RemoveZeroLines

func (mm *Model) RemoveZeroLines()

func (*Model) RemoveZeroTriangles

func (mm *Model) RemoveZeroTriangles()

func (*Model) Save

func (mm *Model) Save() (err error)

func (*Model) SaveAs

func (mm *Model) SaveAs(filename string) (err error)

func (*Model) ScaleOrtho

func (mm *Model) ScaleOrtho(
	basePoint gog.Point3d,
	scale [3]float64,
	nodes, elements []uint,
)

func (*Model) Select

func (mm *Model) Select(nodes, elements []uint)

func (*Model) SelectAll

func (mm *Model) SelectAll(nodes bool, elements []bool)

func (*Model) SelectElementsOnPlane

func (mm *Model) SelectElementsOnPlane(xoy, yoz, xoz bool, elements []bool)

func (*Model) SelectLeftCursor

func (mm *Model) SelectLeftCursor(nodes bool, elements []bool)

func (*Model) SelectLinesByLenght

func (mm *Model) SelectLinesByLenght(more bool, lenght float64)

func (*Model) SelectLinesCylindrical

func (mm *Model) SelectLinesCylindrical(node uint, radiant, conc bool, axe Direction)

func (*Model) SelectLinesOrtho

func (mm *Model) SelectLinesOrtho(x, y, z bool)

func (*Model) SelectLinesParallel

func (mm *Model) SelectLinesParallel(lines []uint)

func (*Model) SelectScreen

func (mm *Model) SelectScreen(from, to [2]int32)

func (*Model) SplitLinesByDistance

func (mm *Model) SplitLinesByDistance(lines []uint, distance float64, atBegin bool)

func (*Model) SplitLinesByEqualParts

func (mm *Model) SplitLinesByEqualParts(lines []uint, parts uint)

func (*Model) SplitLinesByRatio

func (mm *Model) SplitLinesByRatio(lines []uint, proportional float64, atBegin bool)

func (*Model) SplitTri3To3Tri3

func (mm *Model) SplitTri3To3Tri3(elements []uint)

func (*Model) StandardView

func (mm *Model) StandardView(view SView)

func (*Model) Undo

func (mm *Model) Undo()

func (*Model) UnhideAll

func (mm *Model) UnhideAll()

func (*Model) Update

func (mm *Model) Update(nodes, elements *uint)

type Mouse

type Mouse interface {
	WithShiftKey(key bool)
	Press(x, y int32)
	Update(x, y int32)
	Release(x, y int32)

	ReadyPreview() bool
	Preview(xinit, yinit int32)

	ReadyAction() bool
	Action(op *Opengl)

	Reset()

	Status() string
}

type Mouse2P

type Mouse2P struct {
	// contains filtered or unexported fields
}

func (*Mouse2P) Press

func (m2 *Mouse2P) Press(x, y int32)

func (*Mouse2P) ReadyAction

func (m2 *Mouse2P) ReadyAction() bool

func (*Mouse2P) ReadyPreview

func (m2 *Mouse2P) ReadyPreview() bool

func (*Mouse2P) Release

func (m2 *Mouse2P) Release(x, y int32)

func (*Mouse2P) Reset

func (m2 *Mouse2P) Reset()

func (*Mouse2P) Status

func (m2 *Mouse2P) Status() string

func (*Mouse2P) Update

func (m2 *Mouse2P) Update(x, y int32)

func (*Mouse2P) WithShiftKey

func (m2 *Mouse2P) WithShiftKey(key bool)

type MouseAdd

type MouseAdd struct {
	MouseSelect

	LC LeftCursor
	// contains filtered or unexported fields
}

func (*MouseAdd) Action

func (ma *MouseAdd) Action(op *Opengl)

func (*MouseAdd) Reset

func (ma *MouseAdd) Reset()

func (*MouseAdd) Status

func (ma *MouseAdd) Status() string

type MouseMove

type MouseMove struct {
	Mouse2P
}

func (*MouseMove) Action

func (mr *MouseMove) Action(op *Opengl)

func (*MouseMove) Preview

func (mr *MouseMove) Preview(xinit, yinit int32)

type MouseRoll

type MouseRoll interface {
	Roll(xoffset, yoffset int32, op *Opengl)
}

type MouseRotate

type MouseRotate struct {
	Mouse2P
}

func (*MouseRotate) Action

func (mr *MouseRotate) Action(op *Opengl)

func (*MouseRotate) Preview

func (mr *MouseRotate) Preview(xinit, yinit int32)

type MouseSelect

type MouseSelect struct {
	AddShift bool
	Mouse2P
}

func (*MouseSelect) Action

func (ms *MouseSelect) Action(op *Opengl)

func (*MouseSelect) Preview

func (ms *MouseSelect) Preview(xinit, yinit int32)

func (*MouseSelect) WithShiftKey

func (ms *MouseSelect) WithShiftKey(key bool)

type MouseZoom

type MouseZoom struct {
	// contains filtered or unexported fields
}

func (*MouseZoom) AfterRoll

func (mz *MouseZoom) AfterRoll(op *Opengl)

func (*MouseZoom) Roll

func (mz *MouseZoom) Roll(xoffset, yoffset int32, op *Opengl)

type MoveCopyble

type MoveCopyble interface {
	Move(nodes, elements []uint,
		basePoint [3]float64,
		path diffCoordinate)
	Copy(nodes, elements []uint,
		basePoint [3]float64,
		paths []diffCoordinate,
		addLines, addTri bool)
	Mirror(nodes, elements []uint,
		basePoint [3]gog.Point3d,
		copy bool,
		addLines, addTri bool)
}

type Opengl

type Opengl struct {
	// contains filtered or unexported fields
}

func NewOpengl

func NewOpengl(m Mesh, actions *chan ds.Action) (op *Opengl, err error)

func (*Opengl) AddLeftCursor

func (op *Opengl) AddLeftCursor(lc LeftCursor)

func (*Opengl) ColorEdge

func (op *Opengl) ColorEdge(isColor bool)

func (*Opengl) Draw

func (op *Opengl) Draw(x, y, w, h int32)

func (*Opengl) Init

func (op *Opengl) Init()

func (*Opengl) MouseDefault

func (op *Opengl) MouseDefault()

func (*Opengl) SelectLeftCursor

func (op *Opengl) SelectLeftCursor(nodes bool, elements []bool)

func (*Opengl) SelectScreen

func (op *Opengl) SelectScreen(from, to [2]int32)

func (*Opengl) SetCharCallback

func (op *Opengl) SetCharCallback(r rune)

func (*Opengl) SetCursorPosCallback

func (op *Opengl) SetCursorPosCallback(
	xpos float64,
	ypos float64,
)

func (*Opengl) SetFont

func (op *Opengl) SetFont(f *glsymbol.Font)

func (*Opengl) SetKeyCallback

func (op *Opengl) SetKeyCallback(
	key glfw.Key,
	scancode int,
	action glfw.Action,
	mods glfw.ModifierKey,
)

func (*Opengl) SetMouseButtonCallback

func (op *Opengl) SetMouseButtonCallback(
	button glfw.MouseButton,
	action glfw.Action,
	mods glfw.ModifierKey,
	xcursor, ycursor float64,
)

func (*Opengl) SetScrollCallback

func (op *Opengl) SetScrollCallback(
	xcursor, ycursor float64,
	xoffset, yoffset float64,
)

func (*Opengl) StandardView

func (op *Opengl) StandardView(view SView)

func (*Opengl) UpdateModel

func (op *Opengl) UpdateModel()

func (*Opengl) ViewAll

func (op *Opengl) ViewAll()

TODO: aadd to TUI and other

type Operation

type Operation struct {
	Group GroupID
	Name  string
	Part  func(
		m Mesh,
		actions *chan ds.Action,
		closedApp *bool,
	) (
		w vl.Widget,
		initialization func(),
	)
}

type Plane

type Plane uint8
const (
	PlaneXOY Plane = iota
	PlaneXOZ
	PlaneYOZ
)

func (Plane) String

func (p Plane) String() string

type Pluginable

type Pluginable interface {
	DemoSpiral(levels uint)
}

type SView

type SView uint8
const (
	StandardViewXOYpos SView = iota
	StandardViewYOZpos
	StandardViewXOZpos
	StandardViewXOYneg
	StandardViewYOZneg
	StandardViewXOZneg
	StandardViewIsometric
)

func (SView) String

func (s SView) String() string

type Selectable

type Selectable interface {
	SelectLeftCursor(nodes bool, elements []bool)

	Select(nodes, elements []uint)

	GetSelectNodes(single bool) (ids []uint)
	GetSelectElements(single bool, filter func(_ ElType) (acceptable bool)) (ids []uint)

	InvertSelect(nodes bool, elements []bool)

	SelectLinesOrtho(x, y, z bool)
	SelectLinesParallel(lines []uint)
	SelectLinesByLenght(more bool, lenght float64)

	SelectElementsOnPlane(xoy, xoz, yoz bool, elements []bool)
	// TODO rename  to SelectElementsCylindrical
	SelectLinesCylindrical(node uint, radiant, conc bool, axe Direction)

	SelectAll(nodes bool, elements []bool)
	DeselectAll()

	SelectScreen(from, to [2]int32)
}

type Undo

type Undo struct {
	// contains filtered or unexported fields
}

func (*Undo) AddConvexLines

func (u *Undo) AddConvexLines(nodes, elements []uint)

func (*Undo) AddLeftCursor

func (u *Undo) AddLeftCursor(lc LeftCursor)

func (*Undo) AddLineByNodeNumber

func (u *Undo) AddLineByNodeNumber(n1, n2 uint) (id uint)

func (*Undo) AddModel

func (u *Undo) AddModel(m Model)

func (*Undo) AddNode

func (u *Undo) AddNode(X, Y, Z float64) (id uint)

func (*Undo) AddQuadr4ByNodeNumber

func (u *Undo) AddQuadr4ByNodeNumber(n1, n2, n3, n4 uint) (id uint, ok bool)

func (*Undo) AddTriangle3ByNodeNumber

func (u *Undo) AddTriangle3ByNodeNumber(n1, n2, n3 uint) (id uint, ok bool)

func (*Undo) Check

func (u *Undo) Check() error

func (*Undo) Close

func (u *Undo) Close()

func (*Undo) ColorEdge

func (u *Undo) ColorEdge(isColor bool)

func (*Undo) Copy

func (u *Undo) Copy(nodes, elements []uint,
	basePoint [3]float64,
	paths []diffCoordinate,
	addLines, addTri bool)

func (*Undo) DemoSpiral

func (u *Undo) DemoSpiral(n uint)

func (*Undo) DeselectAll

func (u *Undo) DeselectAll()

func (*Undo) GetCoordByID

func (u *Undo) GetCoordByID(id uint) (_ gog.Point3d, ok bool)

func (*Undo) GetCoords

func (u *Undo) GetCoords() []Coordinate

func (*Undo) GetElements

func (u *Undo) GetElements() []Element

func (*Undo) GetPresentFilename

func (u *Undo) GetPresentFilename() (name string)

func (*Undo) GetRootGroup

func (u *Undo) GetRootGroup() groups.Group

func (*Undo) GetSelectElements

func (u *Undo) GetSelectElements(single bool, filter func(_ ElType) (acceptable bool)) (ids []uint)

func (*Undo) GetSelectNodes

func (u *Undo) GetSelectNodes(single bool) (ids []uint)

func (*Undo) GetSelected

func (u *Undo) GetSelected() (nodes, elements []uint)

func (*Undo) Hide

func (u *Undo) Hide(coordinates, elements []uint)

func (*Undo) Intersection

func (u *Undo) Intersection(nodes, elements []uint)

func (*Undo) InvertSelect

func (u *Undo) InvertSelect(nodes bool, elements []bool)

func (*Undo) IsChangedModel

func (u *Undo) IsChangedModel() bool

func (*Undo) MergeLines

func (u *Undo) MergeLines(lines []uint)

func (*Undo) MergeNodes

func (u *Undo) MergeNodes(minDistance float64)

func (*Undo) Mirror

func (u *Undo) Mirror(nodes, elements []uint,
	basePoint [3]gog.Point3d,
	copy bool,
	addLines, addTri bool)

func (*Undo) Move

func (u *Undo) Move(nodes, elements []uint,
	basePoint [3]float64,
	path diffCoordinate)

func (*Undo) Open

func (u *Undo) Open(name string) (err error)

func (*Undo) Remove

func (u *Undo) Remove(nodes, elements []uint)

func (*Undo) RemoveNodesWithoutElements

func (u *Undo) RemoveNodesWithoutElements()

func (*Undo) RemoveSameCoordinates

func (u *Undo) RemoveSameCoordinates()

func (*Undo) RemoveZeroLines

func (u *Undo) RemoveZeroLines()

func (*Undo) RemoveZeroTriangles

func (u *Undo) RemoveZeroTriangles()

func (*Undo) Save

func (u *Undo) Save() error

func (*Undo) SaveAs

func (u *Undo) SaveAs(filename string) error

func (*Undo) ScaleOrtho

func (u *Undo) ScaleOrtho(basePoint gog.Point3d,
	scale [3]float64,
	nodes, elements []uint,
)

func (*Undo) Select

func (u *Undo) Select(nodes, elements []uint)

func (*Undo) SelectAll

func (u *Undo) SelectAll(nodes bool, elements []bool)

func (*Undo) SelectElementsOnPlane

func (u *Undo) SelectElementsOnPlane(xoy, xoz, yoz bool, elements []bool)

func (*Undo) SelectLeftCursor

func (u *Undo) SelectLeftCursor(nodes bool, elements []bool)

func (*Undo) SelectLinesByLenght

func (u *Undo) SelectLinesByLenght(more bool, lenght float64)

func (*Undo) SelectLinesCylindrical

func (u *Undo) SelectLinesCylindrical(node uint, radiant, conc bool, axe Direction)

func (*Undo) SelectLinesOrtho

func (u *Undo) SelectLinesOrtho(x, y, z bool)

func (*Undo) SelectLinesParallel

func (u *Undo) SelectLinesParallel(lines []uint)

func (*Undo) SelectScreen

func (u *Undo) SelectScreen(from, to [2]int32)

func (*Undo) SplitLinesByDistance

func (u *Undo) SplitLinesByDistance(lines []uint, distance float64, atBegin bool)

func (*Undo) SplitLinesByEqualParts

func (u *Undo) SplitLinesByEqualParts(lines []uint, parts uint)

func (*Undo) SplitLinesByRatio

func (u *Undo) SplitLinesByRatio(lines []uint, proportional float64, atBegin bool)

func (*Undo) SplitTri3To3Tri3

func (u *Undo) SplitTri3To3Tri3(tris []uint)

func (*Undo) StandardView

func (u *Undo) StandardView(view SView)

func (*Undo) Undo

func (u *Undo) Undo()

func (*Undo) UnhideAll

func (u *Undo) UnhideAll()

func (*Undo) Update

func (u *Undo) Update(nodes, elements *uint)

func (*Undo) ViewAll

func (u *Undo) ViewAll()

type Viewable

type Viewable interface {
	// Wireframe mode
	// Solid mode
	StandardView(view SView)
	ColorEdge(isColor bool)
	ViewAll()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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