Viewport.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.2 $
00022 // $Date: 2003/02/14 23:01:58 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/renderer/Viewport.cpp,v $
00024                                                                         
00025                                                                         
00026 #include "Viewport.h"
00027 #include "Device.h"
00028 #include "Projection.h"
00029 
00030 Viewport::Viewport() 
00031 {
00032 
00033 }
00034 
00035 
00036 Viewport::~Viewport() 
00037 {
00038 
00039 }
00040 
00041 int
00042 Viewport::update(void) {
00043   float Sx,Sy,Tx, Ty;
00044 //  float VPright, VPleft, VPtop, VPbottom;
00045   float PRTleft, PRTright, PRTtop, PRTbottom;
00046 
00047   float length, width;
00048   length = theDevice->GetHeight(); 
00049   width = theDevice->GetWidth();;
00050 
00051   PRTleft    = portwindow[0];    
00052   PRTright   = portwindow[1];
00053   PRTbottom  = portwindow[2];
00054   PRTtop     = portwindow[3];
00055 
00056   if (PRTleft < -1 || PRTright >1 || PRTtop >1 || PRTbottom <-1) {
00057     opserr << "Viewport::update() -  PORTWINDOW must be in range { -1 1 -1 1}\n";
00058     return -1;
00059   }
00060   
00061   Sx = (PRTright - PRTleft)/2 * width/2;
00062   Sy = (PRTtop - PRTbottom)/2 * length/2;
00063   Tx = Sx + (1 + PRTleft)*width/2;
00064   Ty = Sy + (1 + PRTbottom)*length/2;
00065 
00066   TMat.Set(   Sx, 0.0, 0.0, 0.0,
00067              0.0,  Sy, 0.0, 0.0,
00068              0.0, 0.0, 1.0, 0.0,
00069               Tx,  Ty, 0.0, 1.0);
00070 
00071   return 0;
00072 }
00073 
00074 
00075 FACE &
00076 Viewport::transform(FACE &input)
00077 {
00078 
00079   // transform all the points by the transformation matrix
00080   // remember that in previos pipeline all points were marked
00081   MYPOINT *point;
00082   FOR_EACH(point, input.pointList) {
00083     point->Transform(&TMat);
00084   };
00085   
00086   return input;
00087 }
00088 
00089 
00090 
00091 MYPOINT *
00092 Viewport::transformP(MYPOINT *input)
00093 {
00094     if (input != 0)
00095         input->Transform(&TMat);
00096 
00097     return input;
00098 }
00099 
00100 
00101 void
00102 Viewport::setDevice(Device &device)
00103 {
00104     theDevice = &device;
00105 }
00106 

Generated on Mon Oct 23 15:05:27 2006 for OpenSees by doxygen 1.5.0