//////////////////////////////////////
// START of File: C2_KERNL.CPP
//////////////////////////////////////

//===================================================================
//
// COPYRIGHT NOTICE:  This code is protected by Copyright!
//
// Copyright (c) 1994, 1995, 1996, 1997 by DPC Technology.
// All rights reserved.
//
// See files "cf_copyr.h" and "cf_licen.h" for details of
// copyright and license specifications, and contact information.
//
//===================================================================

// Include this source file's header file:
#include    <cf_api/bf_defs.h>
#include    <cf_api/c1_kernl.hpp>
            // relative to the IDE's (global) include path: ~/cfrz

//====================================================================
// Implement 2D-ONLY Geometric xforms for the ChartFolio Framework:
//====================================================================

void
    cf_Kernel
        ::calcGeomMatrix()
//---------------------------------------------------
// This 2D-only kernel has only two settings:
// 	(1) front/center: i.e. snap-to-x=zero-degrees,
// 	(2) top/center: i.e. snap-to-x=90-degrees.
//---------------------------------------------------
{
	// Only 2D-Polar Charts look straight-down from the top:
	if ( dXRotAngle > 45.0 )
   {	// snap-to top/center: x=90-degrees:
    	cf_4by4mGeomMatrix[ 0 ][ 0 ] = 1.0;
    	cf_4by4mGeomMatrix[ 0 ][ 1 ] = 0.0;
    	cf_4by4mGeomMatrix[ 0 ][ 2 ] = 0.0;
    	cf_4by4mGeomMatrix[ 0 ][ 3 ] = 0.0;

    	cf_4by4mGeomMatrix[ 1 ][ 0 ] = 0.0;
    	cf_4by4mGeomMatrix[ 1 ][ 1 ] = 0.0;
    	cf_4by4mGeomMatrix[ 1 ][ 2 ] = 1.0;
    	cf_4by4mGeomMatrix[ 1 ][ 3 ] = 0.0;

    	cf_4by4mGeomMatrix[ 2 ][ 0 ] = 0.0;
    	cf_4by4mGeomMatrix[ 2 ][ 1 ] = -1.0;
    	cf_4by4mGeomMatrix[ 2 ][ 2 ] = 0.0;
    	cf_4by4mGeomMatrix[ 2 ][ 3 ] = 0.0;

    	cf_4by4mGeomMatrix[ 3 ][ 0 ] = 0.0;
    	cf_4by4mGeomMatrix[ 3 ][ 1 ] = 0.0;
    	cf_4by4mGeomMatrix[ 3 ][ 2 ] = 0.0;
      cf_4by4mGeomMatrix[ 3 ][ 3 ] = 1.0;
		// Thus yielding an X=90, Y=0, Z=0 matrix:
		//      1       0       0       0
		//      0       0       1       0
		//      0       -1      0       0
		//      0       0       0       1
   }
	// All other 2D Cartesian Charts look stright-on from the front:
   else
   {	// snap-to front/center: x=0-degrees:
   	cf_4by4mGeomMatrix[ 0 ][ 0 ] = 1.0;
    	cf_4by4mGeomMatrix[ 0 ][ 1 ] = 0.0;
    	cf_4by4mGeomMatrix[ 0 ][ 2 ] = 0.0;
    	cf_4by4mGeomMatrix[ 0 ][ 3 ] = 0.0;

    	cf_4by4mGeomMatrix[ 1 ][ 0 ] = 0.0;
    	cf_4by4mGeomMatrix[ 1 ][ 1 ] = 1.0;
    	cf_4by4mGeomMatrix[ 1 ][ 2 ] = 0.0;
    	cf_4by4mGeomMatrix[ 1 ][ 3 ] = 0.0;

    	cf_4by4mGeomMatrix[ 2 ][ 0 ] = 0.0;
    	cf_4by4mGeomMatrix[ 2 ][ 1 ] = 0.0;
    	cf_4by4mGeomMatrix[ 2 ][ 2 ] = 1.0;
    	cf_4by4mGeomMatrix[ 2 ][ 3 ] = 0.0;

    	cf_4by4mGeomMatrix[ 3 ][ 0 ] = 0.0;
    	cf_4by4mGeomMatrix[ 3 ][ 1 ] = 0.0;
    	cf_4by4mGeomMatrix[ 3 ][ 2 ] = 0.0;
      cf_4by4mGeomMatrix[ 3 ][ 3 ] = 1.0;
		// Thus yielding an X=0, Y=0, Z=0 matrix:
		//      1       0       0       0
		//      0       1       0       0
		//      0       0       1       0
		//      0       0       0       1
    }

    // (re)Apply the Geometry Transform Matrix to the
    // virtual coordinates for the 3D bounding box:
    for ( int i = 0; i < 8; i++ )
    {
        a_d3DBoxXformXCoord[ i ] = a_d3DBoxInitXCoord[ i ];
        a_d3DBoxXformYCoord[ i ] = a_d3DBoxInitYCoord[ i ];
        a_d3DBoxXformZCoord[ i ] = a_d3DBoxInitZCoord[ i ];
    }   // Reset the transformed coordinates to the initial ones
        // to avoid xforming already xformed coords!...

    this->applyGeomXform(   a_d3DBoxXformXCoord,
                            a_d3DBoxXformYCoord,
                            a_d3DBoxXformZCoord,
                            8  );
                            // Xformed coords of 3D box now set!

    // Apply the Current Geometry to the HSE Ref Point
    // -- which will be at X=0, Y=0, and Z = twice the distance
    // from the Z=0 origin to the dZMax of the 3D Box:
    this->dDsortRefPointX = 0.0;
    this->dDsortRefPointY = 0.0;
    this->dDsortRefPointZ = ( this->dXMax + this->dYMax + this->dZMax ) * 2;

    /*this->applyGeomXform( &(this->dDsortRefPointX),
                            &(this->dDsortRefPointY),
                            &(this->dDsortRefPointZ),
                            1  );*/

}   // end of cf_Kernel::calcGeomMatrix()


//
//=====================================================
// End of Implmentation of version dependent cf_Kernel
// 2D-ONLY Geometry Calculation Method(s).
//=====================================================
//

//////////////////////////////////////
// END of File: C2_KERNL.CPP
//////////////////////////////////////
