LCOV - code coverage report
Current view: top level - eq/fabric - frustum.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 49 62 79.0 %
Date: 2016-09-29 05:02:09 Functions: 11 13 84.6 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2013, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #include "frustum.h"
      19             : 
      20             : #include <co/dataOStream.h>
      21             : #include <co/dataIStream.h>
      22             : 
      23             : namespace eq
      24             : {
      25             : namespace fabric
      26             : {
      27        6034 : Frustum::Frustum()
      28        6034 : {}
      29             : 
      30        6028 : Frustum::~Frustum()
      31             : {
      32        6028 :     _data.current = TYPE_NONE;
      33        6028 : }
      34             : 
      35          12 : void Frustum::backup()
      36             : {
      37          12 :     _backup = _data;
      38          12 : }
      39             : 
      40          12 : void Frustum::restore()
      41             : {
      42          12 :     _data = _backup;
      43          12 : }
      44             : 
      45        1252 : void Frustum::setWall( const Wall& wall )
      46             : {
      47        1252 :     if( _data.wall == wall && _data.current == TYPE_WALL )
      48        1254 :         return;
      49             : 
      50        1250 :     _data.wall       = wall;
      51        1250 :     _data.projection = wall;
      52        1250 :     _data.current    = TYPE_WALL;
      53        1250 :     notifyFrustumChanged();
      54             : }
      55             : 
      56          12 : void Frustum::setProjection( const Projection& projection )
      57             : {
      58          12 :     if( _data.projection == projection && _data.current == TYPE_PROJECTION )
      59          12 :         return;
      60             : 
      61          12 :     _data.projection = projection;
      62          12 :     _data.wall       = projection;
      63          12 :     _data.current    = TYPE_PROJECTION;
      64          12 :     notifyFrustumChanged();
      65             : }
      66             : 
      67           0 : void Frustum::unsetFrustum()
      68             : {
      69           0 :     if( _data.current == TYPE_NONE )
      70           0 :         return;
      71             : 
      72           0 :     _data.current = TYPE_NONE;
      73           0 :     notifyFrustumChanged();
      74             : }
      75             : 
      76          32 : void Frustum::serialize( co::DataOStream& os )
      77             : {
      78          32 :     switch( getCurrentType( ))
      79             :     {
      80             :         case TYPE_WALL:
      81          14 :             os << TYPE_WALL << _data.wall;
      82          14 :             break;
      83             : 
      84             :         case TYPE_PROJECTION:
      85           0 :             os << TYPE_PROJECTION << _data.projection;
      86           0 :             break;
      87             : 
      88             :         case TYPE_NONE:
      89          18 :             os << TYPE_NONE;
      90          18 :             break;
      91             : 
      92             :         default:
      93           0 :             LBASSERT( false );
      94             :     }
      95          32 : }
      96             : 
      97          14 : void Frustum::deserialize( co::DataIStream& is )
      98             : {
      99          14 :     is >> _data.current;
     100             : 
     101          14 :     switch( _data.current )
     102             :     {
     103             :         case TYPE_WALL:
     104             :         {
     105           6 :             is >> _data.wall;
     106           6 :             break;
     107             :         }
     108             :         case Frustum::TYPE_PROJECTION:
     109             :         {
     110           0 :             is >> _data.projection;
     111           0 :             break;
     112             :         }
     113             :         case Frustum::TYPE_NONE:
     114           8 :             break;
     115             : 
     116             :         default:
     117           0 :             LBASSERT( false );
     118             :     }
     119          14 :     updateFrustum();
     120          14 : }
     121             : 
     122         962 : std::ostream& operator << ( std::ostream& os, const Frustum& frustum )
     123             : {
     124         962 :     switch( frustum.getCurrentType( ))
     125             :     {
     126             :         case Frustum::TYPE_WALL:
     127         506 :             os << frustum.getWall() << std::endl;
     128         506 :             break;
     129             :         case Frustum::TYPE_PROJECTION:
     130           6 :             os << frustum.getProjection() << std::endl;
     131           6 :             break;
     132             :         case Frustum::TYPE_NONE:
     133         450 :             break;
     134             :         default:
     135           0 :             os << "INVALID FRUSTUM";
     136           0 :             break;
     137             :     }
     138         962 :     return os;
     139             : }
     140             : 
     141             : }
     142          84 : }

Generated by: LCOV version 1.11