Class: VORuby::STC::V1_10::Region::Constraint
- Inherits:
-
Object
- Object
- VORuby::STC::V1_10::Region::Constraint
- Includes:
- SerializableToXml
- Defined in:
- lib/voruby/stc/1.10/region.rb
Overview
An area on the unit sphere defined by the intersection with a plane
Instance Attribute Summary collapse
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#vector ⇒ Object
Returns the value of attribute vector.
Class Method Summary collapse
Instance Method Summary collapse
- #==(c) ⇒ Object
-
#initialize(options = {}) ⇒ Constraint
constructor
A new instance of Constraint.
- #to_s ⇒ Object
- #to_xml(name = nil) ⇒ Object
Methods included from SerializableToXml
Constructor Details
#initialize(options = {}) ⇒ Constraint
Returns a new instance of Constraint.
559 560 561 562 563 |
# File 'lib/voruby/stc/1.10/region.rb', line 559 def initialize(={}) raise_argument_required_error('vector') if !.has_key?(:vector) raise_argument_required_error('offset') if !.has_key?(:offset) .each { |key, value| send("#{key}=", value) } end |
Instance Attribute Details
#offset ⇒ Object
Returns the value of attribute offset.
557 558 559 |
# File 'lib/voruby/stc/1.10/region.rb', line 557 def offset @offset end |
#vector ⇒ Object
Returns the value of attribute vector.
557 558 559 |
# File 'lib/voruby/stc/1.10/region.rb', line 557 def vector @vector end |
Class Method Details
.from_xml(xml) ⇒ Object
607 608 609 610 611 612 613 614 615 616 |
# File 'lib/voruby/stc/1.10/region.rb', line 607 def self.from_xml(xml) root = element_from(xml) = { :vector => Double3.from_xml(REXML::XPath.first(root, 'x:Vector', {'x' => obj_ns.uri})), :offset => Float(REXML::XPath.first(root, 'x:Offset', {'x' => obj_ns.uri}).text) } Constraint.new() end |
Instance Method Details
#==(c) ⇒ Object
584 585 586 587 |
# File 'lib/voruby/stc/1.10/region.rb', line 584 def ==(c) self.vector == c.vector and self.offset == c.offset end |
#to_s ⇒ Object
603 604 605 |
# File 'lib/voruby/stc/1.10/region.rb', line 603 def to_s "#{self.vector} #{self.offset}" end |
#to_xml(name = nil) ⇒ Object
589 590 591 592 593 594 595 596 597 598 599 600 601 |
# File 'lib/voruby/stc/1.10/region.rb', line 589 def to_xml(name=nil) el = element(name) el.add_element(self.vector.to_xml('Vector', obj_ns)) offset = REXML::Element.new("#{obj_ns.prefix}:Offset") offset.text = self.offset.to_s el.add_element(offset) collapse_namespaces(el) el end |