mirror of https://github.com/CGAL/cgal
add testsuit for triangular vector field
This commit is contained in:
parent
fe90baad79
commit
81f1c566e2
|
|
@ -28,52 +28,79 @@ typedef Stl_rungk::Point_iterator_2 Point_iterator;
|
||||||
typedef Stl_rungk::Point_2 Point_2;
|
typedef Stl_rungk::Point_2 Point_2;
|
||||||
typedef Stl_rungk::Vector_2 Vector_2;
|
typedef Stl_rungk::Vector_2 Vector_2;
|
||||||
|
|
||||||
|
typedef CGAL::Triangular_field_2<K> TRField;
|
||||||
|
typedef CGAL::Runge_kutta_integrator_2<TRField> TRRunge_kutta_integrator;
|
||||||
|
typedef CGAL::Stream_lines_2<TRField, TRRunge_kutta_integrator> TRStl;
|
||||||
|
typedef TRStl::Stream_line_iterator_2 TRStl_iterator;
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
for (int i=1;i<=23;i++)
|
for (int i=1;i<=23;i++)
|
||||||
|
{
|
||||||
|
char file_name[80];
|
||||||
|
std::sprintf(file_name, "data/%d.vec.cin", i);
|
||||||
|
std::ifstream infile(file_name, std::ios::in);
|
||||||
|
double iXSize, iYSize;
|
||||||
|
unsigned int x_samples, y_samples;
|
||||||
|
iXSize = iYSize = 512;
|
||||||
|
infile >> x_samples;
|
||||||
|
infile >> y_samples;
|
||||||
|
Field regular_grid_2(x_samples, y_samples, iXSize, iYSize);
|
||||||
|
/*fill the grid with the appropriate values*/
|
||||||
|
for (unsigned int i=0;i<x_samples;i++)
|
||||||
|
for (unsigned int j=0;j<y_samples;j++)
|
||||||
{
|
{
|
||||||
char file_name[80];
|
double xval, yval;
|
||||||
std::sprintf(file_name, "data/%d.vec.cin", i);
|
infile >> xval;
|
||||||
std::ifstream infile(file_name, std::ios::in);
|
infile >> yval;
|
||||||
double iXSize, iYSize;
|
regular_grid_2.set_field(i, j, Vector_2(xval, yval));
|
||||||
unsigned int x_samples, y_samples;
|
|
||||||
iXSize = iYSize = 512;
|
|
||||||
infile >> x_samples;
|
|
||||||
infile >> y_samples;
|
|
||||||
Field regular_grid_2(x_samples, y_samples, iXSize, iYSize);
|
|
||||||
/*fill the grid with the appropriate values*/
|
|
||||||
for (unsigned int i=0;i<x_samples;i++)
|
|
||||||
for (unsigned int j=0;j<y_samples;j++)
|
|
||||||
{
|
|
||||||
double xval, yval;
|
|
||||||
infile >> xval;
|
|
||||||
infile >> yval;
|
|
||||||
regular_grid_2.set_field(i, j, Vector_2(xval, yval));
|
|
||||||
}
|
|
||||||
infile.close();
|
|
||||||
std::cout << "processing... (" << file_name << ")\n";
|
|
||||||
/* the placement of streamlines using Runge-Kutta integrator */
|
|
||||||
std::cout << "using Runge-Kutta integrator\n";
|
|
||||||
Runge_kutta_integrator runge_kutta_integrator;
|
|
||||||
double dSep = 3.5;
|
|
||||||
double dRat = 1.6;
|
|
||||||
Stl_rungk Stream_lines_rungk(regular_grid_2, runge_kutta_integrator,dSep,dRat,1);
|
|
||||||
std::cout << "placement generated\n";
|
|
||||||
std::cout << "updating parameters...\n";
|
|
||||||
Stream_lines_rungk.set_separating_distance(12.0);
|
|
||||||
Stream_lines_rungk.set_saturation_ratio(1.7);
|
|
||||||
Stream_lines_rungk.update();
|
|
||||||
std::cout << "placement generated\n";
|
|
||||||
std::ofstream fw("result.stl",std::ios::out);
|
|
||||||
Stream_lines_rungk.print_stream_lines(fw);
|
|
||||||
fw.close();
|
|
||||||
/* the placement of streamlines using Euler integrator */
|
|
||||||
std::cout << "using Runge-Kutta integrator\n";
|
|
||||||
Euler_integrator euler_integrator;
|
|
||||||
dSep = 3.5;
|
|
||||||
dRat = 1.6;
|
|
||||||
Stl_euler Stream_lines(regular_grid_2, euler_integrator,dSep,dRat,1);
|
|
||||||
std::cout << "placement generated\n";
|
|
||||||
}
|
}
|
||||||
|
infile.close();
|
||||||
|
std::cout << "processing... (" << file_name << ")\n";
|
||||||
|
/* the placement of streamlines using Runge-Kutta integrator */
|
||||||
|
std::cout << "using Runge-Kutta integrator\n";
|
||||||
|
Runge_kutta_integrator runge_kutta_integrator;
|
||||||
|
double dSep = 3.5;
|
||||||
|
double dRat = 1.6;
|
||||||
|
Stl_rungk Stream_lines_rungk(regular_grid_2, runge_kutta_integrator,dSep,dRat,1);
|
||||||
|
std::cout << "placement generated\n";
|
||||||
|
std::cout << "updating parameters...\n";
|
||||||
|
Stream_lines_rungk.set_separating_distance(12.0);
|
||||||
|
Stream_lines_rungk.set_saturation_ratio(1.7);
|
||||||
|
Stream_lines_rungk.update();
|
||||||
|
std::cout << "placement generated\n";
|
||||||
|
std::ofstream fw("result.stl",std::ios::out);
|
||||||
|
Stream_lines_rungk.print_stream_lines(fw);
|
||||||
|
fw.close();
|
||||||
|
/* the placement of streamlines using Euler integrator */
|
||||||
|
std::cout << "using Euler integrator\n";
|
||||||
|
Euler_integrator euler_integrator;
|
||||||
|
dSep = 3.5;
|
||||||
|
dRat = 1.6;
|
||||||
|
Stl_euler Stream_lines(regular_grid_2, euler_integrator,dSep,dRat,1);
|
||||||
|
std::cout << "placement generated\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "placement of streamlines on irregular field\n";
|
||||||
|
TRRunge_kutta_integrator trrunge_kutta_integrator(1);
|
||||||
|
std::ifstream inp("data/datap.tri.cin");
|
||||||
|
std::ifstream inv("data/datav.tri.cin");
|
||||||
|
std::istream_iterator<Point_2> beginp(inp);
|
||||||
|
std::istream_iterator<Vector_2> beginv(inv);
|
||||||
|
std::istream_iterator<Point_2> endp;
|
||||||
|
TRField triangular_field(beginp, endp, beginv);
|
||||||
|
/* the placement of streamlines */
|
||||||
|
std::cout << "processing...\n";
|
||||||
|
double dSep = 38.0;
|
||||||
|
double dRat = 1.6;
|
||||||
|
TRStl TRStream_lines(triangular_field, trrunge_kutta_integrator,dSep,dRat);
|
||||||
|
std::cout << "placement generated\n";
|
||||||
|
std::cout << "updating parameters...\n";
|
||||||
|
TRStream_lines.set_separating_distance(45.0);
|
||||||
|
TRStream_lines.set_saturation_ratio(1.7);
|
||||||
|
TRStream_lines.update();
|
||||||
|
std::cout << "placement generated\n";
|
||||||
|
|
||||||
std::cout << "success\n";
|
std::cout << "success\n";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue