<commit_before>/*=========================================================================

  Program:   Visualization Library
  Module:    PolyMap.cc
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

This file is part of the Visualization Library. No part of this file or its 
contents may be copied, reproduced or altered in any way without the express
written consent of the authors.

Copyright (c) <NAME>, <NAME>, <NAME> 1993, 1994 

=========================================================================*/
#include "PolyMap.hh"

// Description:
// Construct mapper with vertices, lines, polygons, and triangle strips
// turned on.
vlPolyMapper::vlPolyMapper()
{
  this->Verts = NULL;
  this->Lines = NULL;
  this->Polys = NULL;
  this->Strips = NULL;
  this->Colors = NULL;

  this->VertsVisibility = 1;
  this->LinesVisibility = 1;
  this->PolysVisibility = 1;
  this->StripsVisibility = 1;
}

vlPolyMapper::~vlPolyMapper()
{
  //delete internally created objects
  if ( this->Verts != NULL ) delete this->Verts;
  if ( this->Lines != NULL ) delete this->Lines;
  if ( this->Polys != NULL ) delete this->Polys;
  if ( this->Strips != NULL ) delete this->Strips;
  if ( this->Colors != NULL ) delete this->Colors;
}

void vlPolyMapper::SetInput(vlPolyData *in)
{
  if (in != this->Input )
    {
    vlDebugMacro(<<" setting Input to " << (void *)in);
    this->Input = (vlDataSet *) in;
    this->Modified();
    }
}

//
// Return bounding box of data
//
float *vlPolyMapper::GetBounds()
{
  static float bounds[] = {-1.0,1.0, -1.0,1.0, -1.0,1.0};

  if ( ! this->Input ) 
    return bounds;
  else
    {
    this->Input->Update();
    return this->Input->GetBounds();
    }
}

//
// Receives from Actor -> maps data to primitives
//
void vlPolyMapper::Render(vlRenderer *ren)
{
  vlPointData *pd;
  vlScalars *scalars;
  int i;
  vlPolyData *input=(vlPolyData *)this->Input;
  vlColorScalars *colors;
//
// make sure that we've been properly initialized
//
  if ( input == NULL ) 
    {
    vlErrorMacro(<< "No input!");
    return;
    }
  else
    input->Update();

  if ( this->LookupTable == NULL ) this->CreateDefaultLookupTable();
  this->LookupTable->Build();
//
// Now send data down to primitives and draw it
//
  if ( this->GetMTime() > this->BuildTime || 
  input->GetMTime() > this->BuildTime || 
  this->LookupTable->GetMTime() > this->BuildTime )
    {
//
// create colors
//
    if ( this->ScalarsVisible && (pd=input->GetPointData()) && 
    (scalars=pd->GetScalars()) )
      {
      if ( strcmp(scalars->GetScalarType(),"ColorScalars") )
        {
        if ( this->Colors == NULL ) 
          {
          this->Colors = colors = (vlColorScalars *) 
                                new vlAPixmap(input->GetNumberOfPoints());
          }
        else
          {
          colors = this->Colors;
          }

        this->LookupTable->SetTableRange(this->ScalarRange);
        for (i=0; i<input->GetNumberOfPoints(); i++)
          {
          colors->SetColor(i,this->LookupTable->MapValue(scalars->GetScalar(i)));
          }
        }
      else
        {
        colors = (vlColorScalars *)scalars;
        }
      }
    else
      {
      if ( this->Colors ) delete this->Colors;
      this->Colors = colors = NULL;
      }

    if (this->VertsVisibility && input->GetNumberOfVerts())
      {
      if (!this->Verts) this->Verts = ren->GetPrimitive("points");<commit_msg>really fixed the bug Will said he had fixed :-)<commit_after>/*=========================================================================

  Program:   Visualization Library
  Module:    PolyMap.cc
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

This file is part of the Visualization Library. No part of this file or its 
contents may be copied, reproduced or altered in any way without the express
written consent of the authors.

Copyright (c) <NAME>, <NAME>, <NAME> 1993, 1994 

=========================================================================*/
#include "PolyMap.hh"

// Description:
// Construct mapper with vertices, lines, polygons, and triangle strips
// turned on.
vlPolyMapper::vlPolyMapper()
{
  this->Verts = NULL;
  this->Lines = NULL;
  this->Polys = NULL;
  this->Strips = NULL;
  this->Colors = NULL;

  this->VertsVisibility = 1;
  this->LinesVisibility = 1;
  this->PolysVisibility = 1;
  this->StripsVisibility = 1;
}

vlPolyMapper::~vlPolyMapper()
{
  //delete internally created objects
  if ( this->Verts != NULL ) delete this->Verts;
  if ( this->Lines != NULL ) delete this->Lines;
  if ( this->Polys != NULL ) delete this->Polys;
  if ( this->Strips != NULL ) delete this->Strips;
  if ( this->Colors != NULL ) delete this->Colors;
}

void vlPolyMapper::SetInput(vlPolyData *in)
{
  if (in != this->Input )
    {
    vlDebugMacro(<<" setting Input to " << (void *)in);
    this->Input = (vlDataSet *) in;
    this->Modified();
    }
}

//
// Return bounding box of data
//
float *vlPolyMapper::GetBounds()
{
  static float bounds[] = {-1.0,1.0, -1.0,1.0, -1.0,1.0};

  if ( ! this->Input ) 
    return bounds;
  else
    {
    this->Input->Update();
    return this->Input->GetBounds();
    }
}

//
// Receives from Actor -> maps data to primitives
//
void vlPolyMapper::Render(vlRenderer *ren)
{
  vlPointData *pd;
  vlScalars *scalars;
  int i;
  vlPolyData *input=(vlPolyData *)this->Input;
  vlColorScalars *colors;
//
// make sure that we've been properly initialized
//
  if ( input == NULL ) 
    {
    vlErrorMacro(<< "No input!");
    return;
    }
  else
    input->Update();

  if ( this->LookupTable == NULL ) this->CreateDefaultLookupTable();
  this->LookupTable->Build();
//
// Now send data down to primitives and draw it
//
  if ( this->GetMTime() > this->BuildTime || 
  input->GetMTime() > this->BuildTime || 
  this->LookupTable->GetMTime() > this->BuildTime )
    {
//
// create colors
//
    if ( this->ScalarsVisible && (pd=input->GetPointData()) && 
    (scalars=pd->GetScalars()) )
      {
      if ( strcmp(scalars->GetScalarType(),"ColorScalar") )
        {
        if ( this->Colors == NULL ) 
          {
          this->Colors = colors = (vlColorScalars *) 
                                new vlAPixmap(input->GetNumberOfPoints());
          }
        else
          {
          colors = this->Colors;
          }

        this->LookupTable->SetTableRange(this->ScalarRange);
        for (i=0; i<input->GetNumberOfPoints(); i++)
          {
          colors->SetColor(i,this->LookupTable->MapValue(scalars->GetScalar(i)));
          }
        }
      else
        {
        colors = (vlColorScalars *)scalars;
        }
      }
    else
      {
      if ( this->Colors ) delete this->Colors;
      this->Colors = colors = NULL;
      }

    if (this->VertsVisibility && input->GetNumberOfVerts())
      {
      if (!this->Verts) this->Verts = ren->GetPrimitive("points");
{'fraction_non_alphanumeric': 0.19009468317552805, 'fraction_numerical': 0.007283321194464676, 'mean_word_length': 2.6618666666666666, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 145, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '454278', 'n_tokens_mistral': 2201, 'n_tokens_neox': 2138, 'n_words': 516}