Commit fe075dc6 authored by Will Schroeder's avatar Will Schroeder
Browse files

Initial revision

parent e002517c
/*=========================================================================
Program: Visualization Library
Module: MaskPoly.hh
Language: C++
Date: $Date$
Version: $Revision$
Description:
---------------------------------------------------------------------------
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) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Sample subset of points and associated data
//
#ifndef __vlMaskPolyData_h
#define __vlMaskPolyData_h
#include "P2PF.hh"
class vlMaskPolyData : public vlPolyToPolyFilter
{
public:
vlMaskPolyData();
~vlMaskPolyData();
char *GetClassName() {return "vlMaskPolyData";};
void PrintSelf(ostream& os, vlIndent indent);
// Turn on every nth entity
vlSetClampMacro(OnRatio,int,1,LARGE_INTEGER);
vlGetMacro(OnRatio,int);
// Start with this point
vlSetClampMacro(Offset,int,0,LARGE_INTEGER);
vlGetMacro(Offset,int);
protected:
void Execute();
// every OnRatio entity is on; all others are off.
int OnRatio;
// offset (or starting point id)
int Offset;
};
#endif
/*=========================================================================
Program: Visualization Library
Module: MaskPts.hh
Language: C++
Date: $Date$
Version: $Revision$
Description:
---------------------------------------------------------------------------
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) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Sample subset of points and associated data
//
#ifndef __vlMaskPoints_h
#define __vlMaskPoints_h
#include "DS2PolyF.hh"
class vlMaskPoints : public vlDataSetToPolyFilter
{
public:
vlMaskPoints():OnRatio(2),Offset(0) {};
char *GetClassName() {return "vlMaskPoints";};
void PrintSelf(ostream& os, vlIndent indent);
// Turn on every nth point
vlSetClampMacro(OnRatio,int,1,LARGE_INTEGER);
vlGetMacro(OnRatio,int);
// Start with this point
vlSetClampMacro(Offset,int,0,LARGE_INTEGER);
vlGetMacro(Offset,int);
protected:
void Execute();
// every OnRatio point is on; all others are off.
int OnRatio;
// offset (or starting point id)
int Offset;
};
#endif
/*=========================================================================
Program: Visualization Library
Module: Pl3dRead.hh
Language: C++
Date: $Date$
Version: $Revision$
Description:
---------------------------------------------------------------------------
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) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Read PLOT3D data files
//
#ifndef __vlPLOT3DReader_h
#define __vlPLOT3DReader_h
#include <stdio.h>
#include "SGridSrc.hh"
#include "FScalars.hh"
#include "FVectors.hh"
// file formats
#define WHOLE_SINGLE_GRID_NO_IBLANKING 0
#define WHOLE_SINGLE_GRID_WITH_IBLANKING 1
#define WHOLE_MULTI_GRID_NO_IBLANKING 2
#define WHOLE_MULTI_GRID_WITH_IBLANKING 3
#define PLANES_SINGLE_GRID_NO_IBLANKING 4
#define PLANES_SINGLE_GRID_WITH_IBLANKING 5
#define PLANES_MULTI_GRID_NO_IBLANKING 6
#define PLANES_MULTI_GRID_WITH_IBLANKING 7
// file types
#define BINARY 0
#define ASCII 1
class vlPLOT3DReader : public vlStructuredGridSource
{
public:
vlPLOT3DReader();
~vlPLOT3DReader();
char *GetClassName() {return "vlPLOT3DReader";};
void PrintSelf(ostream& os, vlIndent indent);
vlSetStringMacro(XYZFilename);
vlGetStringMacro(XYZFilename);
vlSetStringMacro(QFilename);
vlGetStringMacro(QFilename);
vlSetStringMacro(FunctionFilename);
vlGetStringMacro(FunctionFilename);
vlSetClampMacro(FileFormat,int,0,7);
vlGetMacro(FileFormat,int);
vlSetClampMacro(GridNumber,int,0,LARGE_INTEGER);
vlGetMacro(GridNumber,int);
vlSetMacro(AutoRelease,int);
vlGetMacro(AutoRelease,int);
vlBooleanMacro(AutoRelease,int);
// these are read from PLOT3D file
vlGetMacro(Fsmach,float);
vlGetMacro(Alpha,float);
vlGetMacro(Re,float);
vlGetMacro(Time,float);
vlSetMacro(R,float);
vlGetMacro(R,float);
vlSetMacro(Gamma,float);
vlGetMacro(Gamma,float);
vlSetMacro(Uvinf,float);
vlGetMacro(Uvinf,float);
vlSetMacro(Vvinf,float);
vlGetMacro(Vvinf,float);
vlSetMacro(Wvinf,float);
vlGetMacro(Wvinf,float);
// derived functions from data in PLOT3D files
void ComputeVelocity();
void ComputeTemperature();
void ComputePressure();
protected:
void Execute();
//Keep track of time change due to computing derived function.
vlTimeStamp DerivedTime;
//supplied in PLOT3D file
float Fsmach;
float Alpha;
float Re;
float Time;
//parameters used in computing derived functions
float R;
float Gamma;
float Uvinf;
float Vvinf;
float Wvinf;
//data read from file (grid always carried in Points field)
vlFloatScalars *Density;
vlFloatVectors *Momentum;
vlFloatScalars *Energy;
void ReleaseSupportingData();
char *XYZFilename;
char *QFilename;
char *FunctionFilename;
int GridNumber; //for multi-grid files, the one we're interested in
int FileFormat; //various PLOT3D formats
int FileType; // BINARY=0, ASCII=1
int GetFileType(FILE *fp);
int AutoRelease; //controls whether data is automatically freed after use
//methods to read data
void ReadGrid();
void ReadDensity();
void ReadMomentum();
void ReadEnergy();
void ReadFunctionFile();
};
#endif
/*=========================================================================
Program: Visualization Library
Module: SGridSrc.hh
Language: C++
Date: $Date$
Version: $Revision$
Description:
---------------------------------------------------------------------------
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) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Abstract class for specifying behavior of structured grid sources
//
#ifndef __vlStructuredGridSource_h
#define __vlStructuredGridSource_h
#include "Source.hh"
#include "SGrid.hh"
class vlStructuredGridSource : public vlSource, public vlStructuredGrid
{
public:
char *GetClassName() {return "vlStructuredGridSource";};
void PrintSelf(ostream& os, vlIndent indent);
void Update();
};
#endif
/*=========================================================================
Program: Visualization Library
Module: MaskPoly.cc
Language: C++
Date: $Date$
Version: $Revision$
Description:
---------------------------------------------------------------------------
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) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include "MaskPoly.hh"
//
// Down sample polygonal data. Don't cnage points, usually not worth it.
//
void vlMaskPolyData::Execute()
{
int numVerts, numLines, numPolys, numStrips;
vlCellArray *inVerts,*inLines,*inPolys,*inStrips;
int numNewVerts, numNewLines, numNewPolys, numNewStrips;
vlCellArray *newVerts, *newLines, *newPolys, *newStrips;
int id, interval;
vlPointData *pd;
int npts, *pts;
//
// Check input / pass data through
//
this->Initialize();
inVerts = this->Input->GetVerts();
numVerts = inVerts->GetNumberOfCells();
numNewVerts = numVerts / this->OnRatio;
inLines = this->Input->GetLines();
numLines = inLines->GetNumberOfCells();
numNewLines = numLines / this->OnRatio;
inPolys = this->Input->GetPolys();
numPolys = inPolys->GetNumberOfCells();
numNewPolys = numPolys / this->OnRatio;
inStrips = this->Input->GetStrips();
numStrips = inStrips->GetNumberOfCells();
numNewStrips = numStrips / this->OnRatio;
if ( numNewVerts < 1 && numNewLines < 1 &&
numNewPolys < 1 && numNewStrips < 1 )
{
vlErrorMacro (<<"No PolyData to mask!");
return;
}
this->SetPoints(this->Input->GetPoints());
pd = this->Input->GetPointData();
this->PointData = *pd;
//
// Allocate space
//
newVerts = new vlCellArray(numNewVerts);
newLines = new vlCellArray;
newLines->Initialize(newLines->EstimateSize(numNewLines,2));
newPolys = new vlCellArray;
newPolys->Initialize(newPolys->EstimateSize(numNewPolys,4));
newStrips = new vlCellArray;
newStrips->Initialize(newStrips->EstimateSize(numNewStrips,6));
//
// Traverse topological lists and traverse
//
interval = this->Offset + this->OnRatio;
for (id=0, inVerts->InitTraversal(); inVerts->GetNextCell(npts,pts); id++)
{
if ( ! (id % interval) )
{
newVerts->InsertNextCell(npts,pts);
}
}
for (id=0, inLines->InitTraversal(); inLines->GetNextCell(npts,pts); id++)
{
if ( ! (id % interval) )
{
newLines->InsertNextCell(npts,pts);
}
}
for (id=0, inPolys->InitTraversal(); inPolys->GetNextCell(npts,pts); id++)
{
if ( ! (id % interval) )
{
newPolys->InsertNextCell(npts,pts);
}
}
for (id=0, inStrips->InitTraversal(); inStrips->GetNextCell(npts,pts); id++)
{
if ( ! (id % interval) )
{
newStrips->InsertNextCell(npts,pts);
}
}
//
// Update ourselves
//
newVerts->Squeeze();
this->SetVerts(newVerts);
newLines->Squeeze();
this->SetLines(newLines);
newPolys->Squeeze();
this->SetPolys(newPolys);
newStrips->Squeeze();
this->SetStrips(newStrips);
}
/*=========================================================================
Program: Visualization Library
Module: MaskPts.cc
Language: C++
Date: $Date$
Version: $Revision$
Description:
---------------------------------------------------------------------------
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) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include "MaskPts.hh"
void vlMaskPoints::Execute()
{
vlFloatPoints *newPts;
vlPointData *pd;
int numPts=this->Input->GetNumberOfPoints();
int numNewPts;
float *x;
int ptId, id;
//
// Check input
//
this->Initialize();
if ( numPts < 1 )
{
vlErrorMacro(<<"No data to mask!");
return;
}
pd = this->Input->GetPointData();
//
// Allocate space
//
numNewPts = numPts / this->OnRatio;
newPts = new vlFloatPoints(numNewPts);
this->PointData.CopyInitialize(pd);
//
// Traverse points and copy
//
for ( ptId = this->Offset; ptId < numPts; ptId += this->OnRatio )
{
x = this->Input->GetPoint(ptId);
id = newPts->InsertNextPoint(x);
this->PointData.CopyData(pd,ptId,id);
}
//
// Update ourselves
//
this->SetPoints(newPts);
}
/*=========================================================================
Program: Visualization Library
Module: Pl3dRead.cc
Language: C++
Date: $Date$
Version: $Revision$
Description:
---------------------------------------------------------------------------
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) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include <ctype.h>
#include "Pl3dRead.hh"
#include "ByteSwap.hh"
vlPLOT3DReader::vlPLOT3DReader()
{
this->Fsmach = 0.0;
this->Alpha = 0.0;
this->Re = 0.0;
this->Time = 0.0;
this->R = 1.0;
this->Gamma = 1.4;
this->Uvinf = 0.0;
this->Vvinf = 0.0;
this->Wvinf = 0.0;
this->Density = 0;
this->Momentum = 0;
this->Energy = 0;
this->XYZFilename = 0;
this->QFilename = 0;
this->FunctionFilename = 0;
this->FileFormat = WHOLE_SINGLE_GRID_NO_IBLANKING;
this->FileType = BINARY;
this->GridNumber = 0;
this->AutoRelease = 1;
}
vlPLOT3DReader::~vlPLOT3DReader()
{
this->ReleaseSupportingData();
if ( this->XYZFilename ) delete [] this->XYZFilename;
if ( this->QFilename ) delete [] this->QFilename;
if ( this->FunctionFilename ) delete [] this->FunctionFilename;
}
void vlPLOT3DReader::PrintSelf(ostream& os, vlIndent indent)
{
if (this->ShouldIPrint(vlPLOT3DReader::GetClassName()))
{
vlStructuredGridSource::PrintSelf(os,indent);
os << indent << "XYZ Filename: " << this->XYZFilename << "\n";
os << indent << "Q Filename: " << this->QFilename << "\n";
os << indent << "Function Filename: " << this->FunctionFilename << "\n";
}
}
void vlPLOT3DReader::Execute()
{
FILE *xyzFp;
vlFloatPoints *newPts;
vlCellArray *newPolys;
//
// Initialize
//
this->Initialize();
if ((xyzFp = fopen(this->XYZFilename, "r")) == NULL)
{
vlErrorMacro(<< "File: " << this->XYZFilename << " not found");
return;
}
}
void vlPLOT3DReader::ReadGrid()
{
}
void vlPLOT3DReader::ReadDensity()
{
}
void vlPLOT3DReader::ReadMomentum()
{
}
void vlPLOT3DReader::ReadEnergy()
{
}
void vlPLOT3DReader::ReadFunctionFile()
{
}
//
// The following are "derived functions"; that is, functions that are
// computed from information provided in the PLOT3D files.
//
void vlPLOT3DReader::ReleaseSupportingData()
{
if ( this->Density )
{
this->Density->UnRegister(this);
this->Density = 0;
}
if ( this->Momentum )
{
this->Momentum->UnRegister(this);
this->Momentum = 0;
}
if ( this->Energy )
{
this->Energy->UnRegister(this);
this->Energy = 0;
}
}
void vlPLOT3DReader::ComputeVelocity()
{
// make sure data is available
if ( ! this->Density ) this->ReadDensity();
if ( ! this->Momentum ) this->ReadMomentum();
if ( ! this->Energy ) this->ReadEnergy();
// Compute velocity
// clean up after ourselves
if ( this->AutoRelease ) this->ReleaseSupportingData();
this->Modified();
this->DerivedTime.Modified();
}
void vlPLOT3DReader::ComputeTemperature()
{
this->Modified();
this->DerivedTime.Modified();
}
void vlPLOT3DReader::ComputePressure()
{
this->Modified();
this->DerivedTime.Modified();
}
/*=========================================================================
Program: Visualization Library
Module: SGridSrc.cc
Language: C++