<commit_before># <NAME> <<EMAIL>>

##____________________________________________________________________________||
class Rotation
  attr_accessor :geometryManager
  attr_accessor :name
  attr_accessor :partName
  attr_accessor :sectionLabel
  attr_accessor :argsInDDL
  def inspect
    "#<#{self.class.name}:0x#{self.object_id.to_s(16)} #{@name}>"
  end
  def initialize geometryManager, partName
    @geometryManager = geometryManager
    @partName = partName
  end
  def clear
    @transformation = nil
  end
  def transformation
    return @transformation if @transformation 
    @transformation = define_transformation_for_rotation_from_DDL(@argsInDDL)
    @transformation
  end
end

##____________________________________________________________________________||
def define_transformation_for_rotation_from_DDL(ddl)

  def convertArguments ddl
    nonnumericArgs = ['name']
    scalarNumericArgs = ['thetaX', 'phiX', 'thetaY', 'phiY', 'thetaZ', 'phiZ']
    knownArgs = nonnumericArgs + scalarNumericArgs

    ddl.keys.each do |k|
      p "#{self}: unknown argument #{k}" unless knownArgs.include?(k)
    end

    argsInSU = Hash.new

    nonnumericArgs.each do |name|
      next unless ddl.key?(name)
      argsInSU[name] = ddl[name]
    end

    scalarNumericArgs.each do |name|
      next unless ddl.key?(name)
      argsInSU[name] = stringToSUNumeric(ddl[name])
    end

    argsInSU
  end

  args = convertArguments(ddl)
  origin = Geom::Point3d.new 0, 0, 0
  xaxis = Geom::Vector3d.new Math::cos(args['thetaX']), Math::sin(args['thetaX'])*Math::cos(args['phiX']), Math::sin(args['thetaX'])*Math::sin(args['phiX'])
  yaxis = Geom::Vector3d.new Math::cos(args['thetaY']), Math::sin(args['thetaY'])*Math::cos(args['phiY']), Math::sin(args['thetaY'])*Math::sin(args['phiY'])
  zaxis = Geom::Vector3d.new Math::cos(args['thetaZ']), Math::sin(args['thetaZ'])*Math::cos(args['phiZ']), Math::sin(args['thetaZ'])*Math::sin(args['phiZ'])
  Geom::Transformation.axes origin, zaxis, xaxis, yaxis
end

##____________________________________________________________________________||
class RotationsManager
  attr_accessor :geometryManager
  attr_accessor :partsHash, :parts

  KnownPartNames = [:Rotation, :ReflectionRotation]

  def inspect
    "#<" + self.class.name + ":0x" + self.object_id.to_s(16) + ">"
  end
  def initialize
    @partsHash = Hash.new
    @parts = Array.new
  end
  def clear
    @parts.each {|p| p.clear if p}
  end
  def get(name)
    @partsHash.key?(name) ? @partsHash[name] : nil
  end
  def add part
    raise StandardError, "unknown part name \"#{partName}\"" unless KnownPartNames.include?(part.partName)
    @parts << part
    @partsHash[part.name] = part 
  end
end

##____________________________________________________________________________||<commit_msg>change from raising an exception to writing an error message to stderr<commit_after># <NAME> <<EMAIL>>

##____________________________________________________________________________||
class Rotation
  attr_accessor :geometryManager
  attr_accessor :name
  attr_accessor :partName
  attr_accessor :sectionLabel
  attr_accessor :argsInDDL
  def inspect
    "#<#{self.class.name}:0x#{self.object_id.to_s(16)} #{@name}>"
  end
  def initialize geometryManager, partName
    @geometryManager = geometryManager
    @partName = partName
  end
  def clear
    @transformation = nil
  end
  def transformation
    return @transformation if @transformation 
    @transformation = define_transformation_for_rotation_from_DDL(@argsInDDL)
    @transformation
  end
end

##____________________________________________________________________________||
def define_transformation_for_rotation_from_DDL(ddl)

  def convertArguments ddl
    nonnumericArgs = ['name']
    scalarNumericArgs = ['thetaX', 'phiX', 'thetaY', 'phiY', 'thetaZ', 'phiZ']
    knownArgs = nonnumericArgs + scalarNumericArgs

    ddl.keys.each do |k|
      p "#{self}: unknown argument #{k}" unless knownArgs.include?(k)
    end

    argsInSU = Hash.new

    nonnumericArgs.each do |name|
      next unless ddl.key?(name)
      argsInSU[name] = ddl[name]
    end

    scalarNumericArgs.each do |name|
      next unless ddl.key?(name)
      argsInSU[name] = stringToSUNumeric(ddl[name])
    end

    argsInSU
  end

  args = convertArguments(ddl)
  origin = Geom::Point3d.new 0, 0, 0
  xaxis = Geom::Vector3d.new Math::cos(args['thetaX']), Math::sin(args['thetaX'])*Math::cos(args['phiX']), Math::sin(args['thetaX'])*Math::sin(args['phiX'])
  yaxis = Geom::Vector3d.new Math::cos(args['thetaY']), Math::sin(args['thetaY'])*Math::cos(args['phiY']), Math::sin(args['thetaY'])*Math::sin(args['phiY'])
  zaxis = Geom::Vector3d.new Math::cos(args['thetaZ']), Math::sin(args['thetaZ'])*Math::cos(args['phiZ']), Math::sin(args['thetaZ'])*Math::sin(args['phiZ'])
  Geom::Transformation.axes origin, zaxis, xaxis, yaxis
end

##____________________________________________________________________________||
class RotationsManager
  attr_accessor :geometryManager
  attr_accessor :partsHash, :parts

  KnownPartNames = [:Rotation, :ReflectionRotation]

  def inspect
    "#<" + self.class.name + ":0x" + self.object_id.to_s(16) + ">"
  end
  def initialize
    @partsHash = Hash.new
    @parts = Array.new
  end
  def clear
    @parts.each {|p| p.clear if p}
  end
  def get(name)
    @partsHash.key?(name) ? @partsHash[name] : nil
  end
  def add part
    if ! KnownPartNames.include?(part.partName)
      $stderr.write self.class.name + ": Unknown part name: \"#{part.partName}\"\n"
      return
    end
    @parts << part
    @partsHash[part.name] = part 
  end
end

##____________________________________________________________________________||
{'fraction_non_alphanumeric': 0.13496392750307937, 'fraction_numerical': 0.004575048389934893, 'mean_word_length': 4.970588235294118, 'pattern_counts': {'":': 3, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7355674', 'n_tokens_mistral': 1824, 'n_tokens_neox': 1806, 'n_words': 367}