Commit 42994b51 authored by Will Schroeder's avatar Will Schroeder
Browse files

Initial revision

parent 748e4740
/*=========================================================================
Program: Visualization Library
Module: Cell.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 specification of computational cells.
//
#ifndef __vlCell_h
#define __vlCell_h
#include "Object.hh"
#include "FPoints.hh"
class vlCell : public vlObject
{
public:
vlCell() {};
char *GetClassName() {return "vlCell";};
void SetPoints(vlFloatPoints *pts) {this->Points = pts;};
virtual float DistanceToPoint(float *x) = 0;
protected:
vlFloatPoints *Points;
};
#endif
/*=========================================================================
Program: Visualization Library
Module: PolyLine.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
=========================================================================*/
//
// Computational class for polylines.
//
#ifndef __vlPolyLine_h
#define __vlPolyLine_h
#include "Cell.hh"
#include "Points.hh"
#include "CellArr.hh"
#include "FNormals.hh"
#define MAX_RESOLUTION MAX_VERTS
class vlPolyLine : public vlCell
{
public:
vlPolyLine() {};
char *GetClassName() {return "vlPolyLine";};
int GenerateNormals(vlPoints *, vlCellArray *, vlFloatNormals *);
float DistanceToPoint(float *x);
};
#endif
/*=========================================================================
Program: Visualization Library
Module: PolyVert.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
=========================================================================*/
//
// Computational class for polypoints.
//
#ifndef __vlPolyPoints_h
#define __vlPolyPoints_h
#include "Cell.hh"
class vlPolyPoints : public vlCell
{
public:
vlPolyPoints() {};
char *GetClassName() {return "vlPolyPoints";};
float DistanceToPoint(float *x);
};
#endif
/*=========================================================================
Program: Visualization Library
Module: Quad.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
=========================================================================*/
//
// Computational class for quads.
//
#ifndef __vlQuad_h
#define __vlQuad_h
#include "Cell.hh"
class vlQuad : public vlCell
{
public:
vlQuad() {};
char *GetClassName() {return "vlQuad";};
float DistanceToPoint(float *x);
};
#endif
/*=========================================================================
Program: Visualization Library
Module: Tetra.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
=========================================================================*/
//
// Computational class for tetras.
//
#ifndef __vlTetra_h
#define __vlTetra_h
#include "Cell.hh"
class vlTetra : public vlCell
{
public:
vlTetra() {};
char *GetClassName() {return "vlTetra";};
float DistanceToPoint(float *x);
};
#endif
/*=========================================================================
Program: Visualization Library
Module: TriStrip.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
=========================================================================*/
//
// Computational class for triangle strips.
//
#ifndef __vlTriangleStrip_h
#define __vlTriangleStrip_h
#include "Cell.hh"
class vlTriangleStrip : public vlCell
{
public:
vlTriangleStrip() {};
char *GetClassName() {return "vlTriangleStrip";};
float DistanceToPoint(float *x);
};
#endif
/*=========================================================================
Program: Visualization Library
Module: Triangle.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
=========================================================================*/
//
// Computational class for triangles
//
#ifndef __vlTriangle_h
#define __vlTriangle_h
#include "Cell.hh"
class vlTriangle : public vlCell
{
public:
vlTriangle() {};
char *GetClassName() {return "vlTriangle";};
float DistanceToPoint(float *x);
};
#endif
/*=========================================================================
Program: Visualization Library
Module: Vertex.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
=========================================================================*/
//
// Computationsl class for point cells
//
#ifndef __vlPoint_h
#define __vlPoint_h
#include "Cell.hh"
class vlPoint : public vlCell
{
public:
vlPoint() {};
char *GetClassName() {return "vlPoint";};
float DistanceToPoint(float *x);
};
#endif
/*=========================================================================
Program: Visualization Library
Module: Voxel.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
=========================================================================*/
//
// Computational class for bricks.
//
#ifndef __vlBrick_h
#define __vlBrick_h
#include "Cell.hh"
class vlBrick : public vlCell
{
public:
vlBrick() {};
char *GetClassName() {return "vlBrick";};
float DistanceToPoint(float *x);
};
#endif
/*=========================================================================
Program: Visualization Library
Module: Cell.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 "Cell.hh"
/*=========================================================================
Program: Visualization Library
Module: PolyLine.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 "PolyLine.hh"
#include "vlMath.hh"
int vlPolyLine::GenerateNormals(vlPoints *pts, vlCellArray *lines, vlFloatNormals *normals)
{
int npts, *linePts;
float s[3], q[3], norm[3], *n;
float *p1, *p2;
float s_norm, n_norm, q_norm;
int i, j;
vlMath math;
//
// Loop over all lines
//
for (lines->InitTraversal(); lines->GetNextCell(npts,linePts); )
{
//
// Determine initial starting normal
//
if ( npts < 2 ) return 0;
p1 = pts->GetPoint(linePts[0]);
p2 = pts->GetPoint(linePts[1]);
for (i=0; i<3; i++) s[i] = p2[i] - p1[i];
if ( (s_norm = math.Norm(s)) == 0.0 ) return 0;
for (i=0; i<3; i++) s[i] /= s_norm;
for (i=0; i<3; i++)
{
if ( s[i] != 0.0 )
{
norm[(i+2)%3] = 0.0;
norm[(i+1)%3] = 1.0;
norm[i] = -s[(i+1)%3]/s[i];
break;
}
}
n_norm = math.Norm(norm);
for (i=0; i<3; i++) norm[i] /= n_norm;
normals->InsertNormal(0,norm);
//
// Generate normals for new point by projecting previous normal
//
for (j=1; j<npts; j++)
{
p1 = pts->GetPoint(linePts[j-1]);
p2 = pts->GetPoint(linePts[j]);
for (i=0; i<3; i++) s[i] = p2[i] - p1[i];
if ( (s_norm = math.Norm(s)) == 0.0 ) return 0;
for (i=0; i<3; i++) s[i] /= s_norm;
n = normals->GetNormal(j-1);
math.Cross(s,n,q);
if ( (q_norm = math.Norm(q)) == 0.0 ) return 0;
for (i=0; i<3; i++) q[i] /= q_norm;
math.Cross (q, s, norm);
n_norm = math.Norm(norm);
for (i=0; i<3; i++) norm[i] /= n_norm;
normals->InsertNormal(j,norm);
}
}
return 1;
}
float vlPolyLine::DistanceToPoint(float *x)
{
return 1.0;
}
/*=========================================================================
Program: Visualization Library
Module: PolyVert.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 "PolyPts.hh"
float vlPolyPoints::DistanceToPoint(float *x)
{
return 1.0;
}
/*=========================================================================
Program: Visualization Library
Module: Quad.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 "Quad.hh"
float vlQuad::DistanceToPoint(float *x)
{
return 1.0;
}
/*=========================================================================
Program: Visualization Library
Module: Tetra.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 "Tetra.hh"
float vlTetra::DistanceToPoint(float *x)
{
return 1.0;
}
/*=========================================================================
Program: Visualization Library
Module: TriStrip.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 "TriStrip.hh"
float vlTriangleStrip::DistanceToPoint(float *x)
{
return 1.0;
}
/*=========================================================================
Program: Visualization Library
Module: Triangle.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 "Triangle.hh"
float vlTriangle::DistanceToPoint(float *x)
{
return 1.0;
}
/*=========================================================================
Program: Visualization Library
Module: Vertex.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 <math.h>
#include "Point.hh"
float vlPoint::DistanceToPoint (float *x)
{
int numPts;
float *X;
if ( !this->Points || (numPts=this->Points->NumberOfPoints()) < 1 )
return LARGE_FLOAT;
X = this->Points->GetPoint(0);
return (float)sqrt((X[0]-x[0])*(X[0]-x[0]) +
(X[1]-x[1])*(X[1]-x[1]) +
(X[2]-x[2])*(X[2]-x[2]));