本文整理汇总了C++中SplineSurface::write方法的典型用法代码示例。如果您正苦于以下问题:C++ SplineSurface::write方法的具体用法?C++ SplineSurface::write怎么用?C++ SplineSurface::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplineSurface
的用法示例。
在下文中一共展示了SplineSurface::write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[] )
{
ALWAYS_ERROR_IF(argc != 7, "Usage: " << argv[0]
<< " curve1infile curve2infile surfaceoutfile point_x point_y point_z" << endl);
// Open input curve 1 file
ifstream is1(argv[1]);
ALWAYS_ERROR_IF(is1.bad(), "Bad or no curve 1 input filename");
// Open input curve 2 file
ifstream is2(argv[2]);
ALWAYS_ERROR_IF(is2.bad(), "Bad or no curve 2 input filename");
// Open output surface file
ofstream os(argv[3]);
ALWAYS_ERROR_IF(os.bad(), "Bad output filename");
Point pt(atof(argv[4]), atof(argv[5]), atof(argv[6]));
// Read curves from file
SplineCurve curv1, curv2;
ObjectHeader head;
is1 >> head >> curv1;
is2 >> head >> curv2;
SplineSurface* surf = SweepSurfaceCreator::linearSweptSurface(curv1, curv2, pt);
surf->writeStandardHeader(os);
surf->write(os);
}
示例2: main
int main(int argc, char* argv[] )
{
ALWAYS_ERROR_IF(argc != 10, "Usage: " << argv[0]
<< " curveinfile surfaceoutfile angle point_x point_y point_z axis_x axis_y axis_z" << endl);
// Open input curve file
ifstream is(argv[1]);
ALWAYS_ERROR_IF(is.bad(), "Bad or no curve input filename");
// Open output surface file
ofstream os(argv[2]);
ALWAYS_ERROR_IF(os.bad(), "Bad output filename");
double angle = atof(argv[3]);
Point pt(atof(argv[4]), atof(argv[5]), atof(argv[6]));
Point axis(atof(argv[7]), atof(argv[8]), atof(argv[9]));
// Read curve from file
SplineCurve curve;
ObjectHeader head;
is >> head >> curve;
SplineSurface* surf = SweepSurfaceCreator::rotationalSweptSurface(curve, angle, pt, axis);
surf->writeStandardHeader(os);
surf->write(os);
}
示例3: main
int main(int argc, char** argv)
{
const string inp_curve_filename("approj_curve.g2");
cout << "\nRunning program '" << argv[0]
<< "'\nSpline curve filename= '"
<< inp_curve_filename.c_str() << "'." << endl;
// Read spline curve file
ifstream cfile(inp_curve_filename.c_str());
if (!cfile) {
cerr << "\nFile error. Could not open file: "
<< inp_curve_filename.c_str() << endl;
return 1;
}
shared_ptr<SplineCurve> curve(new SplineCurve);
ObjectHeader header;
cfile >> header;
if (!header.classType() == SplineCurve::classType()) {
THROW("Object type is NOT SplineCurve.");
}
cfile >> (*curve);
cfile.close();
// Print some curve information
Point pnt3d(3);
curve->point(pnt3d, curve->startparam());
cout << "\nSplineCurve: Dim= " << curve->dimension()
<< "\nStart. Param= " << curve->startparam() << " Point= "
<< pnt3d << endl;
curve->point(pnt3d, curve->endparam());
cout << "End. Param= " << curve->endparam() << " Point= "
<< pnt3d << endl;
cout << "Bounding box = " << curve->boundingBox() << endl;
// Create a surface by rotating the curve around the axis an angle of 2PI.
double angle = 2.0*M_PI;
Point point_on_axis(0.0, 5.0, 200.0);
Point axis_dir(1.0, 0.0, 0.0);
SplineSurface* surf =
SweepSurfaceCreator::rotationalSweptSurface(*curve, angle,
point_on_axis, axis_dir);
cout << "\nSurface: Dim= " << surf->dimension() << endl;
cout << "Bounding box = " << surf->boundingBox() << endl;
cout << "Point on axis = " << point_on_axis << endl;
cout << "Axis direction = " << axis_dir << endl;
// Open output file
ofstream fout("rotational_swept_surface.g2");
// Write curve to file. Colour=red.
fout << "100 1 0 4 255 0 0 255" << endl;
curve->write(fout);
// Write surface to file. Default colour=blue.
surf->writeStandardHeader(fout);
surf->write(fout);
// Write axis to file. Colour=green.
double dlength = 1.2*(surf->boundingBox().high()[0] -
surf->boundingBox().low()[0]);
Point endp = point_on_axis + dlength*axis_dir;
SplineCurve* axis = new SplineCurve(point_on_axis, endp);
fout << "100 1 0 4 0 255 0 255" << endl;
axis->write(fout);
// cout << "Open the file 'rotational_swept_surface.g2' in 'goview' to look"
// << " at the results" << endl;
delete surf;
delete axis;
return 0;
}
示例4: main
int main(int argc, char** argv)
{
bool surface_model = true;
char* infile = 0;
for (int i = 1; i < argc; i++)
if (!infile)
infile = argv[i];
else
std::cerr <<" ** Unknown option ignored: "<< argv[i] << std::endl;
size_t i = 0;
while (i < strlen(infile) && isspace(infile[i])) i++;
std::ifstream isp(infile+i);
// For spline surface models
std::vector<SplineSurface*> in_surf;
// For spline volume models
std::vector<SplineVolume*> in_vol;
ObjectHeader head;
int n = 0;
while (!isp.eof()) {
head.read(isp);
if (head.classType() == Class_SplineVolume) {
SplineVolume* v(new SplineVolume());
v->read(isp);
in_vol.push_back(v);
surface_model = false;
}
else if (head.classType() == Class_SplineSurface) {
SplineSurface* s(new SplineSurface());
s->read(isp);
in_surf.push_back(s);
surface_model = true;
}
else
std::cerr << "Unknown spline model" << std::endl;
// Ignore blanks
ws(isp);
}
if (surface_model) {
std::vector<SplineSurface*> out_surf;
for (i = 0;i < in_surf.size();i++) {
SplineSurface* s_it = in_surf[i];
// basis1 should be one degree higher than basis2 and C^p-1 continuous
int ndim = s_it->dimension();
Go::BsplineBasis b1 = s_it->basis(0).extendedBasis(s_it->order_u()+1);
Go::BsplineBasis b2 = s_it->basis(1).extendedBasis(s_it->order_v()+1);
// Note: Currently this is implemented for non-rational splines only.
// TODO: Ask the splines people how to fix this properly, that is, how
// may be obtain the correct weights for basis1 when *surf is a NURBS?
if (s_it->rational())
std::cerr <<"WARNING: The geometry basis is rational (using NURBS)\n."
<<" The basis for the unknown fields of one degree"
<<" higher will however be non-rational.\n"
<<" This may affect accuracy.\n"<< std::endl;
// Compute parameter values of the Greville points
size_t k;
std::vector<double> ug(b1.numCoefs()), vg(b2.numCoefs());
for (k = 0; k < ug.size(); k++)
ug[k] = b1.grevilleParameter(k);
for (k = 0; k < vg.size(); k++)
vg[k] = b2.grevilleParameter(k);
// Evaluate the spline surface at all points
std::vector<double> XYZ(ndim*ug.size()*vg.size());
s_it->gridEvaluator(XYZ,ug,vg);
// Project the coordinates onto the new basis (the 2nd XYZ is dummy here)
SplineSurface* s;
s = Go::SurfaceInterpolator::regularInterpolation(b1,b2,
ug,vg,XYZ,
ndim,false,XYZ);
out_surf.push_back(s);
s->writeStandardHeader(std::cout);
s->write(std::cout);
}
for (i = 0;i < out_surf.size();i++) {
delete in_surf[i];
delete out_surf[i];
}
}
else {
std::vector<SplineVolume*> out_vol;
for (i = 0;i < in_vol.size();i++) {
SplineVolume* v_it = in_vol[i];
// basis1 should be one degree higher than basis2 and C^p-1 continuous
int ndim = v_it->dimension();
//.........这里部分代码省略.........