Commit 7a818b06 authored by Will Schroeder's avatar Will Schroeder
Browse files

*** empty log message ***

parent 8077e6bd
......@@ -52,7 +52,7 @@ public:
int GetSize() {return Ia.GetSize();};
void GetCell(int loc, int &npts, int* &pts)
{npts=this->Ia.GetValue(loc++); pts=this->Ia.GetPtr(loc);};
int GetLocation() {return this->Location;};
int GetLocation(int npts) {return (this->Location - npts - 1);};
protected:
int NumberOfCells;
......
......@@ -29,6 +29,7 @@ public:
vlContourFilter();
~vlContourFilter() {};
char *GetClassName() {return "vlContourFilter";};
void PrintSelf(ostream& os, vlIndent indent);
void SetValue(int i, float value);
vlGetVectorMacro(Values,float);
......
......@@ -22,7 +22,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "DataSetF.hh"
#include "PolyData.hh"
class vlDataSetToPolyFilter : public vlDataSetFilter, public vlPolyData
class vlDataSetToPolyFilter : public vlPolyData, public vlDataSetFilter
{
public:
void Update();
......
......@@ -12,9 +12,10 @@ public:
~vlIdList() {};
int NumberOfIds() {return (this->Ia.GetMaxId() + 1);};
int GetId(const int i) {return this->Ia[i];};
void SetId(const int i, const int id) {this->Ia[i]=id;};
void InsertId(const int i, const int id) {this->Ia.InsertValue(i,id);};
int InsertNextId(const int id) {return this->Ia.InsertNextValue(id);};
int GetId(const int i) {return this->Ia[i];};
void operator+=(vlIdList& ids) {this->Ia += ids.Ia;};
void operator+=(const int i) {this->Ia += i;};
int getChunk(const int sz) { // get chunk of memory
......
......@@ -22,14 +22,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlPlane_h
#define __vlPlane_h
#define TOL 1.e-05 // Tolerance for geometric calculation
#include "ImpFunc.hh"
#include "Object.hh"
class vlPlane : public vlObject
class vlPlane : public vlImplicitFunction
{
public:
vlPlane() {};
vlPlane();
char *GetClassName() {return "vlPlane";};
// project point onto plane, returning coordinates
......@@ -38,6 +36,20 @@ public:
float Evaluate(float normal[3], float origin[3], float x[3])
{return normal[0]*(x[0]-origin[0]) + normal[1]*(x[1]-origin[1]) +
normal[2]*(x[2]-origin[2]);};
// ImplicitFunction interface
float Evaluate(float x, float y, float z);
vlSetVector3Macro(Normal,float);
vlGetVectorMacro(Normal,float);
vlSetVector3Macro(Origin,float);
vlGetVectorMacro(Origin,float);
protected:
float Normal[3];
float Origin[3];
};
#endif
......
......@@ -70,6 +70,8 @@ void vlContourFilter::Execute()
vlFloatScalars *newScalars;
vlCellArray *newVerts, *newLines, *newPolys;
vlFloatPoints *newPoints;
vlDebugMacro(<< "Executing contour filter");
//
// Initialize and check input
//
......@@ -109,6 +111,9 @@ void vlContourFilter::Execute()
// Update ourselves. Because we don't know upfront how many verts, lines,
// polys we've created, take care to reclaim memory.
//
newPoints->Squeeze();
this->SetPoints(newPoints);
if (newVerts->GetNumberOfCells())
{
newVerts->Squeeze();
......@@ -141,3 +146,21 @@ void vlContourFilter::Execute()
this->PointData.SetScalars(newScalars);
}
void vlContourFilter::PrintSelf(ostream& os, vlIndent indent)
{
int i;
if (this->ShouldIPrint(vlContourFilter::GetClassName()))
{
vlDataSetToPolyFilter::PrintSelf(os,indent);
os << indent << "Number Of Contours : " << this->NumberOfContours << "\n";
os << indent << "Contour Values: \n";
for ( i=0; i<this->NumberOfContours; i++)
{
os << indent << " Value " << i << ": " << this->Values[i] << "\n";
}
}
}
......@@ -15,6 +15,7 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include <math.h>
#include "ImpMod.hh"
#include "FScalars.hh"
......@@ -29,9 +30,7 @@ vlImplicitModeller::vlImplicitModeller()
this->ModelBounds[4] = 0.0;
this->ModelBounds[5] = 0.0;
this->Dimension[0] = 50;
this->Dimension[1] = 50;
this->Dimension[2] = 50;
this->SetDimension(50,50,50);
}
void vlImplicitModeller::PrintSelf(ostream& os, vlIndent indent)
......@@ -90,8 +89,10 @@ void vlImplicitModeller::Execute()
int numPts, idx;
int subId;
int min[3], max[3];
float x[3], prevDistance, distance;
float x[3], prevDistance2, distance2;
int jkFactor;
vlDebugMacro(<< "Executing implicit model");
//
// Initialize self; create output objects
//
......@@ -106,6 +107,7 @@ void vlImplicitModeller::Execute()
numPts = this->Dimension[0] * this->Dimension[1] * this->Dimension[2];
newScalars = new vlFloatScalars(numPts);
for (i=0; i<numPts; i++) newScalars->SetScalar(i,LARGE_FLOAT);
maxDistance = this->ComputeModelBounds();
//
......@@ -141,15 +143,23 @@ void vlImplicitModeller::Execute()
{
x[0] = this->AspectRatio[0] * i + this->Origin[0];
idx = jkFactor*k + this->Dimension[0]*j + i;
prevDistance = newScalars->GetScalar(idx);
distance = cell->EvaluatePosition(x,subId,pcoords);
if (distance < prevDistance)
newScalars->SetScalar(idx,distance);
prevDistance2 = newScalars->GetScalar(idx);
distance2 = cell->EvaluatePosition(x,subId,pcoords);
if (distance2 < prevDistance2)
newScalars->SetScalar(idx,distance2);
}
}
}
}
//
// Run through scalars and take square root
//
for (i=0; i<numPts; i++)
{
distance2 = newScalars->GetScalar(i);
newScalars->SetScalar(i,sqrt(distance2));
}
//
// Update self
//
this->PointData.SetScalars(newScalars);
......@@ -158,5 +168,45 @@ void vlImplicitModeller::Execute()
float vlImplicitModeller::ComputeModelBounds()
{
return 1.0;
float *bounds, maxDist;
int i, adjustBounds=0;
// compute model bounds if not set previously
if ( this->ModelBounds[0] >= this->ModelBounds[1] ||
this->ModelBounds[2] >= this->ModelBounds[3] ||
this->ModelBounds[4] >= this->ModelBounds[5] )
{
adjustBounds = 1;
bounds = this->Input->GetBounds();
}
else
{
bounds = this->ModelBounds;
}
for (maxDist=0.0, i=0; i<3; i++)
if ( (bounds[2*i+1] - bounds[2*i]) > maxDist )
maxDist = bounds[2*i+1] - bounds[2*i];
maxDist *= this->MaximumDistance;
// adjust bounds so model fits strictly inside (only if not set previously)
if ( adjustBounds )
{
for (i=0; i<3; i++)
{
this->ModelBounds[2*i] = bounds[2*i] - maxDist;
this->ModelBounds[2*i+1] = bounds[2*i+1] + maxDist;
}
}
// Set volume origin and aspect ratio
for (i=0; i<3; i++)
{
this->Origin[i] = this->ModelBounds[2*i];
this->AspectRatio[i] = (this->ModelBounds[2*i+1] - this->ModelBounds[2*i]) /
(this->Dimension[i] - 1);
}
return maxDist;
}
......@@ -18,6 +18,17 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "Plane.hh"
#include "vlMath.hh"
vlPlane::vlPlane()
{
this->Normal[0] = 0.0;
this->Normal[1] = 0.0;
this->Normal[2] = 1.0;
this->Origin[0] = 0.0;
this->Origin[1] = 0.0;
this->Origin[2] = 0.0;
}
int vlPlane::ProjectPoint(float x[3], float origin[3], float normal[3], float xproj[3])
{
int i;
......@@ -28,3 +39,10 @@ int vlPlane::ProjectPoint(float x[3], float origin[3], float normal[3], float xp
t = math.Dot(normal,xo);
for (i=0; i<3; i++) xproj[i] = x[i] - t * normal[i];
}
float vlPlane::Evaluate(float x, float y, float z)
{
return ( this->Normal[0]*(x-this->Origin[0]) +
this->Normal[1]*(y-this->Origin[1]) +
this->Normal[2]*(z-this->Origin[2]) );
}
......@@ -20,6 +20,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "PolyMap.hh"
#include "CellType.hh"
#include "Point.hh"
#include "PolyPts.hh"
#include "Line.hh"
#include "PolyLine.hh"
#include "Triangle.hh"
......@@ -102,6 +103,7 @@ vlDataSet* vlPolyData::MakeObject()
vlCell *vlPolyData::GetCell(int cellId)
{
static vlPoint point;
static vlPolyPoints ppoints;
static vlLine line;
static vlPolyLine pline;
static vlTriangle triangle;
......@@ -124,6 +126,11 @@ vlCell *vlPolyData::GetCell(int cellId)
this->Verts->GetCell(loc,numPts,pts);
break;
case vlPOLY_POINTS:
cell = &ppoints;
this->Verts->GetCell(loc,numPts,pts);
break;
case vlLINE:
cell = &line;
this->Lines->GetCell(loc,numPts,pts);
......@@ -156,7 +163,7 @@ vlCell *vlPolyData::GetCell(int cellId)
}
for (i=0; i<numPts; i++)
{
cell->PointIds.InsertId(i,pts[i]);
cell->PointIds.SetId(i,pts[i]);
cell->Points.SetPoint(i,this->Points->GetPoint(i));
}
......@@ -436,9 +443,9 @@ void vlPolyData::BuildCells()
for (verts->InitTraversal(); verts->GetNextCell(npts,pts); )
{
if ( npts > 1 )
cells->InsertNextCell(vlPOLY_POINTS,verts->GetLocation());
cells->InsertNextCell(vlPOLY_POINTS,verts->GetLocation(npts));
else
cells->InsertNextCell(vlPOINT,verts->GetLocation());
cells->InsertNextCell(vlPOINT,verts->GetLocation(npts));
}
}
......@@ -447,9 +454,9 @@ void vlPolyData::BuildCells()
for (lines->InitTraversal(); lines->GetNextCell(npts,pts); )
{
if ( npts > 1 )
cells->InsertNextCell(vlPOLY_LINE,lines->GetLocation());
cells->InsertNextCell(vlPOLY_LINE,lines->GetLocation(npts));
else
cells->InsertNextCell(vlLINE,lines->GetLocation());
cells->InsertNextCell(vlLINE,lines->GetLocation(npts));
}
}
......@@ -458,11 +465,11 @@ void vlPolyData::BuildCells()
for (polys->InitTraversal(); polys->GetNextCell(npts,pts); )
{
if ( npts == 3 )
cells->InsertNextCell(vlTRIANGLE,polys->GetLocation());
cells->InsertNextCell(vlTRIANGLE,polys->GetLocation(npts));
else if ( npts == 4 )
cells->InsertNextCell(vlQUAD,polys->GetLocation());
cells->InsertNextCell(vlQUAD,polys->GetLocation(npts));
else
cells->InsertNextCell(vlPOLYGON,polys->GetLocation());
cells->InsertNextCell(vlPOLYGON,polys->GetLocation(npts));
}
}
......@@ -470,7 +477,7 @@ void vlPolyData::BuildCells()
{
for (strips->InitTraversal(); strips->GetNextCell(npts,pts); )
{
cells->InsertNextCell(vlTRIANGLE_STRIP,strips->GetLocation());
cells->InsertNextCell(vlTRIANGLE_STRIP,strips->GetLocation(npts));
}
}
}
......@@ -485,7 +492,7 @@ void vlPolyData::BuildCells()
{
if ( npts == 3 )
{
cells->InsertNextCell(vlTRIANGLE,polys->GetLocation());
cells->InsertNextCell(vlTRIANGLE,polys->GetLocation(npts));
polys->InsertNextCell(npts,pts);
}
else // triangulate poly
......@@ -494,7 +501,7 @@ void vlPolyData::BuildCells()
poly.Triangulate(outVerts);
for (i=0; i<outVerts.NumberOfIds()/3; i++)
{
cells->InsertNextCell(vlTRIANGLE,polys->GetLocation());
cells->InsertNextCell(vlTRIANGLE,polys->GetLocation(npts));
polys->InsertNextCell(3);
for (j=0; j<3; j++)
polys->InsertCellPoint(outVerts.GetId(3*i+j));
......@@ -512,7 +519,7 @@ void vlPolyData::BuildCells()
p3 = pts[2];
for (i=0; i<(npts-2); i++)
{
cells->InsertNextCell(vlTRIANGLE,polys->GetLocation());
cells->InsertNextCell(vlTRIANGLE,polys->GetLocation(npts));
polys->InsertNextCell(3);
if ( (i % 2) ) // flip ordering to preserve consistency
{
......
......@@ -202,7 +202,7 @@ int vlPolygon::ParameterizePolygon(float *p0, float *p10, float& l10,
{
int i, j;
float s, t, p[3], p1[3], p2[3], sbounds[2], tbounds[2];
int numPts;
int numPts=this->Points.NumberOfPoints();
float *x1, *x2;
vlMath math;
//
......
......@@ -167,7 +167,7 @@ vlCell *vlStructuredPoints::GetCell(int cellId)
x[0] = this->Origin[0] + loc[0] * this->AspectRatio[0];
idx = loc[0] + loc[1]*this->Dimension[0] + loc[2]*d01;
cell->PointIds.InsertId(npts,idx);
cell->Points.SetPoint(npts++,x);
cell->Points.InsertPoint(npts++,x);
}
}
}
......
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