Documentation
¶
Overview ¶
Package zone implement Zone model.
Index ¶
Constants ¶
const RootID = 0
RootID indicate that zone with the given number is a root.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Operation ¶
type Operation struct {
BodyID body.ID `json:"bodyId"`
Type OperationType `json:"-"`
}
Operation determines construction of Zone.
func (*Operation) MarshalJSON ¶
MarshalJSON custom Marshal function.
func (*Operation) UnmarshalJSON ¶
UnmarshalJSON custom Unmarshal function.
type OperationType ¶
type OperationType int
OperationType determines operation type. OperationTypes are based on mathematical operations on sets.
const ( // Intersect operation: A ∩ B. Intersect OperationType = iota // Subtract operation: A \ B. Subtract // Union operation: A ∪ B. Union )
type Zone ¶
type Zone struct {
ID ID `json:"id"`
// ID of parent. If ID == RootID then Zone is a root.
ParentID ID `json:"parentId"`
Name string `json:"name"`
BaseID body.ID `json:"baseId"`
MaterialID material.ID `json:"materialId"`
Construction []*Operation `json:"construction"`
}
Zone is composed from list of bodies. Every Zone have Base body. Zone 3D model is created by using an pseudo algorithm:
currentResult := zone.Base
for _, construction := range(zone.Construction) {
currentResult = construction.Type(currentResult, construction.Body)
}
Operations order is determined by Constructions array order.
Eg: Base{cuboid}, Construction[{sphere, union}] is zone made from union of cuboid and sphere.
Eg: Base{sphere}. Construction{{sphere, union}, {cuboid, intersect}] is zone made from intersection of cuboid and union of 2 spheres.
Zones are structured as forest of B-trees. Parent <-> Children relationship means that children is contained entirely in parent. Zone is a tree root, if ID == RootID.
TODO: intersections other than children <-> one parent like beetween childrens of same parent are not allowed.