
The resulting grid has n vertices and n-1 edges.
The implementation provides a means of adding points to the discretization, so that the grid can be built up incrementally, or updated.
NAO/IrrDLine.hand link against library
libNAOBase.aThe following constructors are provided:
| NAIrregularDiscreteLine(); |
| Create an NAIrregularDiscreteLine. (default constructor). |
| NAIrregularDiscreteLine(n ,x ); | ||||||
| Create an irregular grid on a line | ||||||
|
The following member functions are available in addition to those provided
by the abstract interface NARegion:
| long addPoint(x ); | |||
| Adds a point to an irregular discrete line. | |||
|
| long addPoint(pt ); | |||
| Add a point to an IrregularDiscreteLine. | |||
|
| double* getPointList(); |
| Returns a pointer to a list of the grid points. |
| void setPointList(n ,pts ); | ||||||
| Replaces the entire list of points. | ||||||
|
| int getNumberOfCoordinatesPerVertex(c ) const; | |||
| Returns the number of coordinates per vertex of a component mesh. | |||
|
addPoint returns the index of the vertex just added.
Note that once other points are added, this index may no longer
be valid.
Be careful with the getPointList member function,
that returns a pointer to the list of points.
If you change the value of the array, the grid will change. If you
do not violate the ordering this can be done, but the assumption is
that the array is sorted in increasing order, and user beware if
the array is changed to violate this assumption. (Is that dire enough?)
#include <NAO/IrrDLine.h>
#include <NAO/UTDrMfld.h>
#include <NAO/UTGraph.h>
#include <NAO/NADblPt.h>
int main (int argc, char *argv[])
{
int i,n;
NAIrregularDiscreteLine *Line=new NAIrregularDiscreteLine();
Line->addPoint(0.);
Line->addPoint(1.);
n=Line->getNumberOfVertices();
cout << "There are " << n << " vertices" << endl << flush;
NAPointOnManifold *x=new NADoublePointOnManifold(1);
for(i=0;i<n;i++)
{
Line->getVertex(i,x);
cout << " " << i << " " << x->getCoordinate(0).Double() << endl << flush;
}
x->unReference();
n=Line->getNumberOfCells(1);
cout << "There are " << n << " 1-cells" << endl << flush;
for(i=0;i<n;i++)
{
cout << i << " (" << Line->getCellFace(1,i,0) << "," << Line->getCellFace(1,i,1) << ")" << endl << flush;
}
NADraw(Line,"blue");
NAGraphicsPause();
Line->addPoint(.3);
Line->addPoint(.6);
Line->addPoint(.1);
n=Line->getNumberOfVertices();
cout << "There are " << n << " vertices" << endl << flush;
x=new NADoublePointOnManifold(1);
for(i=0;i<n;i++)
{
Line->getVertex(i,x);
cout << " " << i << " " << x->getCoordinate(0).Double() << endl << flush;
}
x->unReference();
n=Line->getNumberOfCells(1);
cout << "There are " << n << " 1-cells" << endl << flush;
for(i=0;i<n;i++)
{
cout << i << " (" << Line->getCellFace(1,i,0) << "," << Line->getCellFace(1,i,1) << ")" << endl << flush;
}
NAGraphicsClear();
NADraw(Line,"blue");
NAGraphicsPause();
Line->unReference();
NAGraphicsClose();
return(0);
}
This is what I see when I run this:
There are 2 vertices 0 0 1 1 There are 1 1-cells 0 (0,1) drawing a discrete 1-Manifold in 1-Space! (IrregularDiscreteLine) shpause: Hit enter when you are ready to continue. "q" quits.There are 5 vertices 0 0 1 0.1 2 0.3 3 0.6 4 1 There are 4 1-cells 0 (0,1) 1 (1,2) 2 (2,3) 3 (3,4) drawing a discrete 1-Manifold in 1-Space! (IrregularDiscreteLine) shpause: Hit enter when you are ready to continue. "q" quits.
~NATopLevel: Just deleted the last NATopLevel Object total TopLevels allocated 7 PointOnManifolds 6 smartPtr's 0 Manifolds 1 smartPtr's 0 FunctionSpaces 0 smartPtr's 0 Functions 0 smartPtr's 0 OperatorSpaces 0 smartPtr's 0 Operators 0 smartPtr's 0 Algorithms 0 Problems 0 Lists 0
Siblings of this class:
The NA1dLinearInterpolatedFunction uses this grid to store the domain of the function.
[Comments | NAO home page ]
[ IBM home page | Order | Privacy | ContactIBM | Legal ]