Class: VORuby::STC::V1_10::STC::VelocitySphereType

Inherits:
SphereType show all
Defined in:
lib/voruby/stc/1.10/stc.rb

Overview

Defines a velocity sphere. A special kind of area is a circle or sphere (in two or three dimensions), defined by a center position and a radius; the radius requires a unit

Direct Known Subclasses

VelocitySphere

Instance Attribute Summary collapse

Attributes inherited from SphereType

#center, #radius, #unit

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SphereType

#fill_factor, #fill_factor=, #radius_unit, #radius_unit=

Methods included from SerializableToXml

#element

Constructor Details

#initialize(options = {}) ⇒ VelocitySphereType

Returns a new instance of VelocitySphereType.



2137
2138
2139
2140
# File 'lib/voruby/stc/1.10/stc.rb', line 2137

def initialize(options={})
  raise_argument_required_error('velocity time unit') if !options.has_key?(:vel_time_unit)
  super(options)
end

Instance Attribute Details

#vel_time_unitObject

Returns the value of attribute vel_time_unit.



2135
2136
2137
# File 'lib/voruby/stc/1.10/stc.rb', line 2135

def vel_time_unit
  @vel_time_unit
end

Class Method Details

.from_xml(xml) ⇒ Object



2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
# File 'lib/voruby/stc/1.10/stc.rb', line 2161

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {
    :radius => Float(REXML::XPath.first(root, 'x:Radius', {'x' => obj_ns.uri}).text),
    :center => Double3.from_xml(REXML::XPath.first(root, 'x:Center', {'x' => obj_ns.uri})),
    :unit => PosUnit.new(root.attributes.get_attribute_ns(obj_ns.uri, 'unit').value),
    :vel_time_unit => VelTimeUnit.new(root.attributes.get_attribute_ns(obj_ns.uri, 'vel_time_unit').value)
  }
  
  radius_unit = root.attributes.get_attribute_ns(obj_ns.uri, 'radius_unit')
  options[:radius_unit] = PosUnit.new(radius_unit.value) if radius_unit
  
  fill_factor = root.attributes.get_attribute_ns(obj_ns.uri, 'fill_factor')
  options[:fill_factor] = Float(fill_factor.value) if fill_factor
  
  self.new(options)
end

Instance Method Details

#==(s) ⇒ Object



2151
2152
2153
# File 'lib/voruby/stc/1.10/stc.rb', line 2151

def ==(s)
  super(s) and self.vel_time_unit == s.vel_time_unit
end

#to_xml(name = nil) ⇒ Object



2155
2156
2157
2158
2159
# File 'lib/voruby/stc/1.10/stc.rb', line 2155

def to_xml(name=nil)
  el = super(name)
  el.attributes["#{obj_ns.prefix}:vel_time_unit"] = self.vel_time_unit.to_s
  el
end