//////////////////////////////////////
// START of File: CO3_FACE.HPP
//////////////////////////////////////

#ifndef CO3_FACE_HPP            // Avoid multiple includes...
#define CO3_FACE_HPP    TRUE    // ...holds to a terminal #endif below...

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

//
// Master Header File Listing:
//
// #include    <cf_api/co3_face.hpp>
// "2D/3D Surface Facet (Polygon w/ HSE)" object.
//

//--------------------------------------------------------------------
// Include Chart Framework class or ID defs/headers this file needs.
// Paths are relative to the IDE's (global) include path: ~/cfrz
//--------------------------------------------------------------------
class       cf_Virt3DObj;
class       cf_3DPoint;
class       cf_3DPolygon;
#include    <cf_api/co1_pgon.hpp>


//
// Declare a ChartFolio "cf_3DFacet" zApp class.
//
// Class cf_3DFacet is virtually identical to class pictPolyLine --
// it abstracts a set of graphable cf_3DPoints, along with other
// polygon attributes.
//
// The main differences lie in how a polygon gets rendered in 2D/3D
// mode, versus how the base polyline class gets rendered.  Thus,
// we will over-ride some of the base class functionality.
//
// Additionally, since cf_3DFacets are the often-used components 
// of pictChart objects, they will use a lot of HSE (Hidden Surface 
// Elimination) and DSORT (Depth Sorting) functionality.
//
class CF_EXPORT   cf_3DFacet : 
        public 
        cf_3DPolygon 
{

public:

    cf_3DFacet();   // Default c-tor does NOT assign display attribs.
    
    cf_3DFacet( cf_DispAttribs *p_attrToDrawWith );
                    // Std c-tor lets user assign display attribs

    virtual     ~cf_3DFacet();
                // Virtual D-tor is critical!

    cf_3DFacet& operator=( const cf_3DFacet& cr_cf_3dfSource );
                // VERY important for dynamic array ops, etc.!


    virtual void applyGeomXform( cf_Kernel  *p_cf_kUseThisKernel );
    virtual void applyProjXform( cf_Kernel  *p_cf_kUseThisKernel );

    virtual void applyScaleOp(  double dXScaleFactor,
                                double dYScaleFactor, 
                                double dZScaleFactor );

    virtual void applyTranslateOp(  double  dXTrans,
                                    double  dYTrans,
                                    double  dZTrans );

    BOOL        testForHSE();
                // 3D HSE function discerns "forward-facing" facets
    BOOL        testIsFaceForward();
                // Returns last result of this->applyTestHSE(), 
                // without the overhead of running the calc...

private:
    BOOL        testCtrOnFarSideOf( cf_3DFacet *cf_3dfTarget );
    BOOL        testCtrOnNearSideOf( cf_3DFacet *cf_3dfTarget );
    BOOL        testOverlapGeomZ( cf_3DFacet *cf_3dfTarget );
    BOOL        testOverlapGeomXY( cf_3DFacet *cf_3dfTarget );
    BOOL        testOverlapScreenXY( cf_3DFacet *cf_3dfTarget );
    BOOL        testNearlyCoplanarWith( cf_3DFacet *cf_3dfTarget );
                // 3D FSORT functions called from master function

public:
    BOOL        testShouldSwapWith( cf_3DFacet *cf_3dfTarget );
                // Facet-based "master" DSORT evaluator function 
                // calls modular FSORT members above...

    virtual void    draw2D( bf_Display *p_bf_dspOutputDisplay );
    virtual void    draw3D( bf_Display *p_bf_dspOutputDisplay );

private:

    BOOL        bFacingForwardForHSE;
                // Holds the current evaluation of whether or not
                // this is a "forward-facing" facet.  (Non-forward
                // facing facets that compose *polyhedra* do NOT 
                // need rendering (and maybe even projection xforms)
                // so HSE speeds polyhedra renderng up -- BIG TIME! )
                // C-tor inits to FALSE, meaning that until 
                // otherwise notified, we WILL render (and project)
                // this facet.
                        
};  //
    // End of cf_3DFacet declaration.
    //

#endif      // Terminates include re-definition protection

//////////////////////////////////////
// END of File: CO3_FACE.HPP
//////////////////////////////////////
            
