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

Initial revision

parent c03658b7
/*=========================================================================
Program: Visualization Library
Module: VectDot.hh
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) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlVectorDot - generate scalars from dot product of vectors and normals (e.g., show displacement plot)
// .SECTION Description
// vlVectorDot is a filter to generate scalar values from a dataset.
// The scalar value at a point is created by computing the dot product
// between the normal and vector at that point. Combined with the appropriate
// color map, this can show nodal lines/mode shapes of vibration, or a
// displacement plot.
#ifndef __vlVectorDot_h
#define __vlVectorDot_h
#include "DS2DSF.hh"
class vlVectorDot : public vlDataSetToDataSetFilter
{
public:
vlVectorDot();
char *GetClassName() {return "vlVectorDot";};
void PrintSelf(ostream& os, vlIndent indent);
// Description:
// Specify range to map scalars into.
vlSetVector2Macro(ScalarRange,float);
// Description:
// Get the range that scalars map into.
vlGetVectorMacro(ScalarRange,float,2);
protected:
void Execute();
float ScalarRange[2];
};
#endif
/*=========================================================================
Program: Visualization Library
Module: VectDot.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) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include "VectDot.hh"
#include "vlMath.hh"
// Description:
// Construct object with scalar range is (-1,1).
vlVectorDot::vlVectorDot()
{
this->ScalarRange[0] = -1.0;
this->ScalarRange[1] = 1.0;
}
//
// Compute dot product.
//
void vlVectorDot::Execute()
{
int ptId, numPts;
vlFloatScalars *newScalars;
vlMath math;
vlDataSet *input=this->Input;
vlPointData *pd=input->GetPointData();
vlNormals *inNormals;
vlVectors *inVectors;
float s, *n, *v, min, max, dR, dS;
//
// Initialize
//
vlDebugMacro(<<"Generating vector/normal dot product!");
this->Initialize();
if ( ((numPts=input->GetNumberOfPoints()) < 1) ||
((inVectors=pd->GetVectors()) == NULL) ||
((inNormals=pd->GetNormals()) == NULL ) )
{
vlErrorMacro(<< "No input!");
return;
}
//
// Allocate
//
newScalars = new vlFloatScalars(numPts);
//
// Compute initial scalars
//
for (min=LARGE_FLOAT,max=(-LARGE_FLOAT),ptId=0; ptId < numPts; ptId++)
{
n = inNormals->GetNormal(ptId);
v = inVectors->GetVector(ptId);
s = math.Dot(n,v);
if ( s < min ) min = s;
if ( s > max ) max = s;
newScalars->InsertScalar(ptId,s);
}
//
// Map scalars into scalar range
//
if ( (dR=this->ScalarRange[1]-this->ScalarRange[0]) == 0.0 ) dR = 1.0;
if ( (dS=max-min) == 0.0 ) dS = 1.0;
for ( ptId=0; ptId < numPts; ptId++ )
{
s = newScalars->GetScalar(ptId);
s = ((s - min)/dS) * dR + this->ScalarRange[0];
newScalars->InsertScalar(ptId,s);
}
//
// Update self
//
this->PointData.CopyScalarsOff();
this->PointData.PassData(this->Input->GetPointData());
this->PointData.SetScalars(newScalars);
}
void vlVectorDot::PrintSelf(ostream& os, vlIndent indent)
{
vlDataSetToDataSetFilter::PrintSelf(os,indent);
os << indent << "Scalar Range: (" << this->ScalarRange[0] << ", "
<< this->ScalarRange[1] << ")\n";
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment