Commit 748e4740 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Preparing for advent of cells.

parent 781b3c06
......@@ -22,7 +22,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "Object.hh"
struct vlCell {
short type;
unsigned char type;
int loc;
};
......@@ -33,10 +33,10 @@ public:
~vlCellList();
char *GetClassName() {return "vlCellList";};
vlCell &GetCell(const int id) {return this->Array[id];};
short GetCellType(const int id) {return this->Array[id].type;};
unsigned char GetCellType(const int id) {return this->Array[id].type;};
int GetCellLoc(const int id) {return this->Array[id].loc;};
void InsertCell(const int id, const short type, const int loc);
int InsertNextCell(const short type, const int pos);
void InsertCell(const int id, const unsigned char type, const int loc);
int InsertNextCell(const unsigned char type, const int pos);
void Squeeze();
void Reset();
......
......@@ -16,20 +16,20 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// PolyToStructuredPointsFilter are filters that take PolyData in and
// DataSetToStructuredPointsFilter are filters that take DataSets in and
// generate StructuredPoints data
//
#ifndef __vlPolyToStructuredPointsFilter_h
#define __vlPolyToStructuredPointsFilter_h
#ifndef __vlDataSetToStructuredPointsFilter_h
#define __vlDataSetToStructuredPointsFilter_h
#include "PolyF.hh"
#include "DataSetF.hh"
#include "SPoints.hh"
class vlPolyToStructuredPointsFilter : public vlStructuredPoints, public vlPolyFilter
class vlDataSetToStructuredPointsFilter : public vlStructuredPoints, public vlDataSetFilter
{
public:
void Update();
char *GetClassName() {return "vlPolyToStructuredPointsFilter";};
char *GetClassName() {return "vlDataSetToStructuredPointsFilter";};
void PrintSelf(ostream& os, vlIndent indent);
};
......
......@@ -21,9 +21,9 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlImplicitModeller_h
#define __vlImplicitModeller_h
#include "P2SPtsF.hh"
#include "DS2SPtsF.hh"
class vlImplicitModeller : public vlPolyToStructuredPointsFilter
class vlImplicitModeller : public vlDataSetToStructuredPointsFilter
{
public:
vlImplicitModeller();
......
......@@ -21,20 +21,15 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlLine_h
#define __vlLine_h
#include "Object.hh"
#include "Points.hh"
#include "CellArr.hh"
#include "FNormals.hh"
#include "Cell.hh"
#define MAX_RESOLUTION MAX_VERTS
class vlLine : public vlObject
class vlLine : public vlCell
{
public:
vlLine() {};
char *GetClassName() {return "vlLine";};
int GenerateNormals(vlPoints *, vlCellArray *, vlFloatNormals *);
float DistanceToPoint(float *x);
};
......
......@@ -29,14 +29,16 @@ struct vlLink {
class vlLinkList : public vlObject {
public:
vlLinkList():Array(0),Size(0),MaxId(-1),Extend(1000) {};
vlLinkList(const int sz, const int ext);
vlLinkList(const int sz, const int ext=1000);
~vlLinkList();
char *GetClassName() {return "vlLinkList";};
vlLink &GetLink(const int id) {return this->Array[id];};
unsigned short GetNcells(const int id) {return this->Array[id].ncells;};
int *GetCells(const int id) {return this->Array[id].cells;};
void InsertLink(const int id, const unsigned short ncells, int *cells);
int InsertNextLink(const unsigned short ncells, int *cells);
void IncrementLinkCount(const int id) {this->Array[id].ncells++;};
void AllocateLinks();
void InsertCellReference(const int id, const int pos, const int cellId)
{this->Array[id].cells[pos] = cellId;};
void Squeeze();
void Reset();
......
......@@ -23,8 +23,6 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "DataSet.hh"
#include "FPoints.hh"
#include "CellArr.hh"
#include "CellList.hh"
#include "LinkList.hh"
#define MAX_VERTS MAX_CELL_SIZE
......@@ -77,13 +75,8 @@ private:
vlCellArray *Lines;
vlCellArray *Polys;
vlCellArray *Strips;
vlCellList Cells;
vlLinkList Links;
// dummy static member below used as a trick to simplify traversal
static vlCellArray *Dummy;
void BuildCells();
void BuildLinks();
};
#endif
......
......@@ -21,12 +21,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlPolygon_h
#define __vlPolygon_h
#include "Object.hh"
#include "Cell.hh"
#include "Points.hh"
#define MAX_RESOLUTION MAX_VERTS
class vlPolygon : public vlObject
class vlPolygon : public vlCell
{
public:
vlPolygon() {};
......@@ -35,6 +35,7 @@ public:
void ComputeNormal(vlPoints *p, int numPts, int *pts, float *n);
void ComputeNormal(float *v1, float *v2, float *v3, float *n);
float DistanceToPoint(float *x);
};
#endif
......
......@@ -32,7 +32,7 @@ vlCellList::~vlCellList()
//
// Add a cell to structure
//
void vlCellList::InsertCell(const int id, const short type, const int loc)
void vlCellList::InsertCell(const int id, const unsigned char type, const int loc)
{
vlCell *cell;
......@@ -46,7 +46,7 @@ void vlCellList::InsertCell(const int id, const short type, const int loc)
return;
}
int vlCellList::InsertNextCell(const short type, const int loc)
int vlCellList::InsertNextCell(const unsigned char type, const int loc)
{
this->InsertCell (++this->MaxId,type,loc);
return this->MaxId;
......
......@@ -15,21 +15,21 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include "P2SPtsF.hh"
#include "DS2SPtsF.hh"
void vlPolyToStructuredPointsFilter::Update()
void vlDataSetToStructuredPointsFilter::Update()
{
vlPolyFilter::Update();
vlDataSetFilter::Update();
}
void vlPolyToStructuredPointsFilter::PrintSelf(ostream& os, vlIndent indent)
void vlDataSetToStructuredPointsFilter::PrintSelf(ostream& os, vlIndent indent)
{
if (this->ShouldIPrint(vlPolyToStructuredPointsFilter::GetClassName()))
if (this->ShouldIPrint(vlDataSetToStructuredPointsFilter::GetClassName()))
{
this->PrintWatchOn(); // watch for multiple inheritance
vlStructuredPoints::PrintSelf(os,indent);
vlPolyFilter::PrintSelf(os,indent);
vlDataSetFilter::PrintSelf(os,indent);
this->PrintWatchOff(); // stop worrying about it now
}
......
......@@ -37,7 +37,7 @@ void vlImplicitModeller::PrintSelf(ostream& os, vlIndent indent)
{
if (this->ShouldIPrint(vlImplicitModeller::GetClassName()))
{
vlPolyToStructuredPointsFilter::PrintSelf(os,indent);
vlDataSetToStructuredPointsFilter::PrintSelf(os,indent);
os << indent << "Maximum Distance: " << this->MaximumDistance << "\n";
os << indent << "ModelBounds: \n";
......
......@@ -16,70 +16,9 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include "Line.hh"
#include "vlMath.hh"
int vlLine::GenerateNormals(vlPoints *pts, vlCellArray *lines, vlFloatNormals *normals)
float vlLine::DistanceToPoint(float *x)
{
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;
return 1.0;
}
......@@ -13,7 +13,6 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include <iostream.h>
#include "LinkList.hh"
vlLinkList::vlLinkList(const int sz, const int ext)
......@@ -32,24 +31,12 @@ vlLinkList::~vlLinkList()
//
// Add a link to structure
//
void vlLinkList::InsertLink(const int id, const unsigned short ncells, int *cells)
void vlLinkList::AllocateLinks()
{
vlLink *link;
if ( id >= this->Size ) this->Resize(id);
if ( id > this->MaxId ) this->MaxId = id;
link = this->Array + id;
link->ncells = ncells;
for (unsigned short i=0; i<ncells; i++) link->cells[i] = cells[i];
return;
}
int vlLinkList::InsertNextLink(const unsigned short ncells, int *cells)
{
this->InsertLink (++this->MaxId,ncells,cells);
return this->MaxId;
for (int i=0; i<=this->MaxId; i++)
{
this->Array[i].cells = new int[this->Array[i].ncells];
}
}
void vlLinkList::Squeeze()
......
......@@ -79,3 +79,9 @@ void vlPolygon::ComputeNormal(float *v1, float *v2, float *v3, float *n)
n[2] /= length;
}
}
float vlPolygon::DistanceToPoint(float *x)
{
return 1.0;
}
......@@ -19,7 +19,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "RibbonF.hh"
#include "FPoints.hh"
#include "FNormals.hh"
#include "Line.hh"
#include "PolyLine.hh"
vlRibbonFilter::vlRibbonFilter()
{
......@@ -63,8 +63,8 @@ void vlRibbonFilter::Execute()
if ( !(inNormals=pd->GetNormals()) )
{
vlPolyLine lineNormalGenerator;
deleteNormals = 1;
vlLine lineNormalGenerator;
inNormals = new vlFloatNormals(inPts->NumberOfPoints());
if ( !lineNormalGenerator.GenerateNormals(inPts,inLines,(vlFloatNormals*)inNormals) )
{
......
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