<commit_before>// __BEGIN_LICENSE__
//  Copyright (c) 2009-2013, United States Government as represented by the
//  Administrator of the National Aeronautics and Space Administration. All
//  rights reserved.
//
//  The NGT platform is licensed under the Apache License, Version 2.0 (the
//  "License"); you may not use this file except in compliance with the
//  License. You may obtain a copy of the License at
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
// __END_LICENSE__


// ===========================================================================
// The polygon rasterization code is based on s_pgdraw.c and
// s_pgspan.c from the OpenGL reference implementation
// ===========================================================================


// ===========================================================================
// NOTE: although within a pixel, we currently don't get results
// identical to NVIDIA's OpenGL implementation OpenGL version. This
// may be a difference between the definitions of the pixel center
// (NVIDIA may use the 0.5 pixel offset). We also may be using a
// subtly different transform to the final window coords. Should check
// againt __glUpdateViewport and __glUpdateViewportTransform in
// s_xform.c. Also code in __glim_Ortho. -- LJE
// ===========================================================================

// ===========================================================================
// According to Levoy:
//
//     http://graphics.stanford.edu/courses/cs248-01/scan/scan1.html
//
// SGI "uses a DDA with fixed-point arithmetic. log2N bits of
// sub-pixel precision for an N-pixel line". This seems to be similar
// to the approach taken here for polygon rasterization.
// ===========================================================================

#include <vw/Core/Exception.h>
#include <vw/Core/FundamentalTypes.h>
#include <asp/Core/SoftwareRenderer.h>

#include <iostream>

using namespace std;
using namespace vw;
using namespace stereo;

enum { eShadeFlat = 0x0, eShadeSmooth = 0x1 };

// ===========================================================================
// Constants and enums
// ===========================================================================

// NOTE: double does *NOT* work!
// #define _VW_USE_DOUBLE_
#ifdef _VW_USE_DOUBLE_

#define __TWO_63 9223372036854775808.0
#define __FRACTION(result, f) result = (vw::int64) ((f) * __TWO_63)
#define SHIFT 63
typedef double RealT;

#else

#define __TWO_31 2147483648.0F
#define __FRACTION(result, f) result = (vw::int32) ((f) * __TWO_31)
#define SHIFT 31
typedef float RealT;

#endif

static const int kVerticesPerTriangle = 3;

// ===========================================================================
// Type declarations
// ===========================================================================

// Coordinate structure.  Coordinates contain x, y, z and w.
struct Coords
{
  Coords() {}
  Coords(float coords[2])
  {
    x = coords[0]; y = coords[1]; z = 0.0; w = 1.0;
  }
  RealT x, y, z, w;
};

// Color structure.  Colors are composed of red, green, blue and alpha.
struct Color
{
  Color() {}
  Color(float gray) { r = gray; g = 0.0; b = 0.0; a = 1.0; }
  Color(float color[], int numComponents)
  {
    switch (numComponents)
    {
    case 1:
      r = color[0]; g = 0.0; b = 0.0; a = 1.0;
      return;
    case 3:
      r = color[0]; g = color[1]; b = color[2]; a = 1.0;
      return;
    case 4:
      r = color[0]; g = color[1]; b = color[2]; a = color[3];
      return;
    }
  }
  RealT r, g, b, a;
};

// Interpolator record for color interpolators.  Used for primary and
// secondary colors;
struct ColorIterator
{
  RealT rLittle, gLittle, bLittle, aLittle;
  RealT rBig, gBig, bBig, aBig;
  RealT drdx, dgdx, dbdx, dadx;
  RealT drdy, dgdy, dbdy, dady;
};

// A fragment is a collection of all the data needed after<commit_msg>SoftwareRenderer: Handle default case, to quiet the compiler<commit_after>// __BEGIN_LICENSE__
//  Copyright (c) 2009-2013, United States Government as represented by the
//  Administrator of the National Aeronautics and Space Administration. All
//  rights reserved.
//
//  The NGT platform is licensed under the Apache License, Version 2.0 (the
//  "License"); you may not use this file except in compliance with the
//  License. You may obtain a copy of the License at
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
// __END_LICENSE__


// ===========================================================================
// The polygon rasterization code is based on s_pgdraw.c and
// s_pgspan.c from the OpenGL reference implementation
// ===========================================================================


// ===========================================================================
// NOTE: although within a pixel, we currently don't get results
// identical to NVIDIA's OpenGL implementation OpenGL version. This
// may be a difference between the definitions of the pixel center
// (NVIDIA may use the 0.5 pixel offset). We also may be using a
// subtly different transform to the final window coords. Should check
// againt __glUpdateViewport and __glUpdateViewportTransform in
// s_xform.c. Also code in __glim_Ortho. -- LJE
// ===========================================================================

// ===========================================================================
// According to Levoy:
//
//     http://graphics.stanford.edu/courses/cs248-01/scan/scan1.html
//
// SGI "uses a DDA with fixed-point arithmetic. log2N bits of
// sub-pixel precision for an N-pixel line". This seems to be similar
// to the approach taken here for polygon rasterization.
// ===========================================================================

#include <vw/Core/Exception.h>
#include <vw/Core/FundamentalTypes.h>
#include <asp/Core/SoftwareRenderer.h>

#include <iostream>

using namespace std;
using namespace vw;
using namespace stereo;

enum { eShadeFlat = 0x0, eShadeSmooth = 0x1 };

// ===========================================================================
// Constants and enums
// ===========================================================================

// NOTE: double does *NOT* work!
// #define _VW_USE_DOUBLE_
#ifdef _VW_USE_DOUBLE_

#define __TWO_63 9223372036854775808.0
#define __FRACTION(result, f) result = (vw::int64) ((f) * __TWO_63)
#define SHIFT 63
typedef double RealT;

#else

#define __TWO_31 2147483648.0F
#define __FRACTION(result, f) result = (vw::int32) ((f) * __TWO_31)
#define SHIFT 31
typedef float RealT;

#endif

static const int kVerticesPerTriangle = 3;

// ===========================================================================
// Type declarations
// ===========================================================================

// Coordinate structure.  Coordinates contain x, y, z and w.
struct Coords
{
  Coords() {}
  Coords(float coords[2])
  {
    x = coords[0]; y = coords[1]; z = 0.0; w = 1.0;
  }
  RealT x, y, z, w;
};

// Color structure.  Colors are composed of red, green, blue and alpha.
struct Color
{
  Color() {}
  Color(float gray) { r = gray; g = 0.0; b = 0.0; a = 1.0; }
  Color(float color[], int numComponents)
  {
    switch (numComponents)
    {
    case 1:
      r = color[0]; g = 0.0; b = 0.0; a = 1.0;
      return;
    case 3:
      r = color[0]; g = color[1]; b = color[2]; a = 1.0;
      return;
    case 4:
      r = color[0]; g = color[1]; b = color[2]; a = color[3];
      return;
    default:
      r = 0.0; g = 0.0; b = 0.0; a = 1.0;
    }
  }
  RealT r, g, b, a;
};

// Interpolator record for color interpolators.  Used for primary and
// secondary colors;
struct ColorIterator
{
  RealT rLittle, gLittle, bLittle, aLittle;
  RealT rBig, gBig, bBig, aBig;
  RealT drdx, dgdx, dbdx, dadx;
  RealT drdy, dgdy, dbdy, dady;
};

// A fragment is a collection of all the data needed after
{'fraction_non_alphanumeric': 0.26984312807305083, 'fraction_numerical': 0.02552095527979396, 'mean_word_length': 3.9871570344424985, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1861434', 'n_tokens_mistral': 2664, 'n_tokens_neox': 2410, 'n_words': 877}