Class LiteFace3
In: readfoamfiles.rb
Parent: FXGLShape

Methods

canDrag   deselect   drawface   drawshape   hide   new   select   show  

Attributes

boundary  [RW] 
info  [RW] 
 ref attributes
attr_accessor :p0, :p1, :p2, :p3
 interaction attributes
selected  [RW] 
 ref attributes
attr_accessor :p0, :p1, :p2, :p3
 interaction attributes

Public Class methods

[Source]

# File readfoamfiles.rb, line 176
    def initialize(boundary)
        #super(0.0,0.0,0.0, SHADING_FLAT|STYLE_SURFACE)
        super(0.0,0.0,0.0, SHADING_FLAT|STYLE_SURFACE|STYLE_WIREFRAME)
        #super(0.0,0.0,0.0, SHADING_FLAT|STYLE_WIREFRAME)
        #super(0.0,0.0,0.0, SHADING_FLAT|STYLE_SURFACE|STYLE_WIREFRAME)
        #super(0.0,0.0,0.0, SHADING_FLAT|STYLE_SURFACE|FACECULLING_OFF)
        #super(0.0,0.0,0.0, SHADING_FLAT|STYLE_WIREFRAME|FACECULLING_ON)
        @boundary = boundary
        @firstinit = true
        @normal = Array.new
        #@boundary.each_with_index do |bdry, idx|
        #   puts "idx #{idx} boundary #{bdry}"
        #end
        if @boundary.size == 9
           @name = @boundary[0].to_s
           @type = @boundary[2].to_s
           @physicaltype = @boundary[4].to_s
           @nfaces = @boundary[6].to_i
           @startface = @boundary[8].to_i
        elsif @boundary.size == 7
           @name = @boundary[0].to_s
           @type = @boundary[2].to_s
           @physicaltype = nil
           @nfaces = @boundary[4].to_i
           @startface = @boundary[6].to_i
        end
        if @physicaltype.to_s == "inlet" || (@physicaltype == nil && @type == "patch" )
           @color = [ 160.0/255, 160.0/255, 255.0/255, 0 ]
           @selcolor = [ 255.0/255, 255.0/255, 0.0/255, 0 ]
        elsif @physicaltype == "PressureOutlet" || @physicaltype == "inletOutlet"
           @color = [ 255.0/255, 160.0/255, 160.0/255, 0 ]
           @selcolor = [ 255.0/255, 255.0/255, 0.0/255, 0 ]
        elsif @type == "empty"
           @color = [ 200.0/255, 200.0/255, 120.0/255, 0 ]
           @selcolor = [ 255.0/255, 255.0/255, 0.0/255, 0 ]
        else
           @color = [ 165.0/255, 160.0/255, 160.0/255, 0 ]
           @selcolor = [ 255.0/255, 255.0/255, 0.0/255, 0 ]
        end
      #rescue
      #   FXMessageBox.error(self,MBOX_OK,"Error",
      #   "Problem with creation of Face.\nAbort current object creation")
      #end
      @selected = false
      @xlow = $points4[0][0]
      @xhigh = @xlow
      @ylow = $points4[0][1]
      @yhigh = @ylow
      @zlow = $points4[0][2]
      @zhigh = @zlow
      $points4.each do |point|
         @xlow = point[0] if @xlow > point[0]
         @xhigh = point[0] if @xhigh < point[0]
         @ylow = point[1] if @ylow > point[1]
         @yhigh = point[1] if @yhigh < point[1]
         @zlow = point[2] if @zlow > point[2]
         @zhigh = point[2] if @zhigh < point[2]
      end
      setRange( FXRangef.new(@xlow, @xhigh, @ylow, @yhigh, @zlow, @zhigh ) )
    end

Public Instance methods

[Source]

# File readfoamfiles.rb, line 296
   def canDrag
      false
   end

[Source]

# File readfoamfiles.rb, line 286
   def deselect
      @currentlist = @face1
      @selected = false
   end

Draws this face into viewer (an FXGLViewer instance).

[Source]

# File readfoamfiles.rb, line 240
   def drawface(selected1)
      GL.Enable(GL::LIGHT0);
      endface = @startface + @nfaces - 1
      (@startface..endface).each do  |faceno|
         face = $faces4[faceno]
         if selected1
            GL.Light(GL::LIGHT0, GL::DIFFUSE, @selcolor);
            GL.Light(GL::LIGHT0, GL::AMBIENT, @selcolor);
         else
            GL.Light(GL::LIGHT0, GL::DIFFUSE, @color);
            GL.Light(GL::LIGHT0, GL::AMBIENT, @color);
         end
         GL::Begin(GL::QUAD_STRIP);
         p0x, p0y, p0z = $points4[face[0]][0], $points4[face[0]][1], $points4[face[0]][2]
         p1x, p1y, p1z = $points4[face[1]][0], $points4[face[1]][1], $points4[face[1]][2]
         p3x, p3y, p3z = $points4[face[3]][0], $points4[face[3]][1], $points4[face[3]][2]
         normal = crossNormal( [ p3x - p0x, p3y - p0y, p3z - p0z], [ p1x - p0x, p1y - p0y, p1z - p0z] )
         GL::Normal(-normal[0], -normal[1], -normal[2]);
         if face.size == 4
            [ 0, 1, 3, 2].each do |no|
               GL::Vertex($points4[face[no]][0], $points4[face[no]][1], $points4[face[no]][2] );
            end
         end
         GL::End();
      end
   end

[Source]

# File readfoamfiles.rb, line 266
   def drawshape(viewer)
      if @firstinit
         @face1 = GL.GenLists(1)
         GL.NewList(@face1, GL::COMPILE)
         drawface(false)
         GL.EndList()
         @face2 = GL.GenLists(2)
         GL.NewList(@face2, GL::COMPILE)
         drawface(true)
         GL.EndList()
         @currentlist = @face1
         @firstinit = false
      end
      GL.CallList(@currentlist)
   end

[Source]

# File readfoamfiles.rb, line 293
   def hide
      $globalscene.remove(self)
   end

[Source]

# File readfoamfiles.rb, line 282
   def select
      @currentlist = @face2
      @selected = true
   end

[Source]

# File readfoamfiles.rb, line 290
   def show
      $globalscene.append(self)
   end

[Validate]