当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectHeader::classType方法代码示例

本文整理汇总了C++中ObjectHeader::classType方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectHeader::classType方法的具体用法?C++ ObjectHeader::classType怎么用?C++ ObjectHeader::classType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectHeader的用法示例。


在下文中一共展示了ObjectHeader::classType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{
    // Get geometric tolerance from the argument list.    
    double epsge = atof(argv[1]);

    // Read curve file
    //string inp_curve_filename("approj_curve.g2"); 
    //string inp_curve_filename("const_u_paramcurve.g2"); 
    string inp_curve_filename("const_v_paramcurve.g2"); 
    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();
    shared_ptr<ParamCurve> pcurve = curve;

    // Read surface file
    string inp_surf_filename("surface.g2");   
    ifstream sfile(inp_surf_filename.c_str());
    if (!sfile) {
	cerr << "\nFile error. Could not open file: " << inp_surf_filename.c_str() << endl;
	return 1;
    }
    shared_ptr<SplineSurface> surf(new SplineSurface);
    sfile >> header;
    if (!header.classType() == SplineSurface::classType()) {
	THROW("Object type is NOT SplineSurface.");
    }
    sfile >> (*surf);
    sfile.close();
    shared_ptr<ParamSurface> psurf = surf;

    // Create projection curves
    shared_ptr<SplineCurve> proj_cv;
    shared_ptr<SplineCurve> par_cv;
    CurveCreators::projectCurve(pcurve, psurf, epsge, proj_cv, par_cv);

    // Write 3D space curve to file.
    ofstream scvout("proj_space_curve.g2");
    //proj_cv->writeStandardHeader(scvout);
    scvout << "100 1 0 4 0 255 0  255" << endl; // write header. Green curve
    scvout << *proj_cv;    // write space spline curve data.
    scvout.close();

    // Write 2D parameter curve to file.
    ofstream pcvout("proj_param_curve.g2");
    par_cv->writeStandardHeader(pcvout); // write header
    pcvout << *par_cv;    // write parameter spline curve data.
    pcvout.close();

    return 0;
}
开发者ID:99731,项目名称:GoTools,代码行数:60,代码来源:project_curve.C

示例2: main

int main(int argc, char** argv)
{
    string inp_curve_filename("approj_curve.g2"); 
    Point location(0.0, 5.0, 200.0);
    Point axis_dir(1.0, 0.0, 0.0);
    cout << "\nRunning program '" << argv[0] << "' with spline 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> spline_curve(new SplineCurve);
    ObjectHeader header;
    cfile >> header;
    if (!header.classType() == SplineCurve::classType()) {
	THROW("Object type is NOT SplineCurve.");
    }
    cfile >> (*spline_curve);
    cfile.close();

    // Print some curve information
    Point pnt3d(3);
    spline_curve->point(pnt3d, spline_curve->startparam());     
    cout << "\nSplineCurve:  Dim= " << spline_curve->dimension()
	 << "\nStart.  Param= " << spline_curve->startparam() << "  Point= "
	 << pnt3d << endl;
    spline_curve->point(pnt3d, spline_curve->endparam());    
    cout << "End.  Param= " << spline_curve->endparam() << "  Point= "
	 << pnt3d << endl;
    cout << "Bounding box =   " << spline_curve->boundingBox() << endl;

    // Create the SurfaceOfRevolution object.
    SurfaceOfRevolution surf_of_revolution(location, axis_dir, spline_curve);
    cout << "\nSurface:  Dim= " << surf_of_revolution.dimension() << endl;
    cout << "Bounding box =  " << surf_of_revolution.boundingBox() << endl;
    cout << "Location =  " << surf_of_revolution.getLocation() << endl;
    cout << "Axis direction =  " << surf_of_revolution.getAxisDir() << endl;


    // Make a SplineSurface representation and write to file.
    SplineSurface* spline_surf = surf_of_revolution.geometrySurface();
    ofstream fout("surface_of_revolution.g2");
    spline_surf->writeStandardHeader(fout);
    spline_surf->write(fout);
    fout.close();
    // cout << "\nOpen the files 'surface_of_revolution.g2' and 'approj_curve.g2'"
    //      << " in 'goview' to look at the results.\n" << endl;
    delete spline_surf;

    return 0;
}
开发者ID:99731,项目名称:GoTools,代码行数:56,代码来源:surface_of_revolution.C

示例3: main

int main(int argc, char** argv)
{
    ASSERT(argc >= 2);
    ifstream file(argv[1]);
    ObjectHeader head;
    SplineSurface sf;
    SplineCurve cv;
    file >> head;
    if (head.classType() == SplineSurface::classType()) { 
	file >> sf;
    } else if (head.classType() == SplineCurve::classType()) {
开发者ID:99731,项目名称:GoTools,代码行数:11,代码来源:test_closestpoint.C

示例4: main

int main(int argc, char* argv[] )
{
    if (argc != 5)
    {
        std::cout << "Usage: " << argv[0]
                  << " input_ellipse tmin tmax output_subcurve" << endl;
        return -1;
    }

    // Open input surface file
    ifstream is(argv[1]);
    double tmin(atof(argv[2]));
    double tmax(atof(argv[3]));
    ofstream os(argv[4]);
    if (is.bad())
    {
        std::cout << "Bad or no input filename" << std::endl;
        return -1;
    }

    // Read surface from file
    ObjectHeader head;
    Ellipse ellipse; // Typically: centre, dir, normal, r1, r2.
    is >> head;
    ASSERT(head.classType() == Ellipse::classType());
    is >> ellipse;

    if (tmin < ellipse.startparam() || tmax > ellipse.endparam())
    {
        std::cout << "tmin or tmax outside domain of ellipse." << std::endl;
        return -1;
    }

    std::cout << "Writing to file." << std::endl;

    // Extract subcurve, write to file.
    ellipse.setParamBounds(tmin, tmax);

    shared_ptr<SplineCurve> sub_ellipse(ellipse.geometryCurve());

    sub_ellipse->writeStandardHeader(os);
    sub_ellipse->write(os);

    return 0;
}
开发者ID:VicoLiang,项目名称:GoTools,代码行数:45,代码来源:test_ellipse.C

示例5: main

int main(int argc, char** argv)
{
    if (argc < 3) {
	cerr << "Usage: " << argv[0] << " u_res v_res" << endl;
	return 1;
    }
    int ures = atoi(argv[1]);
    int vres = atoi(argv[2]);

    ObjectHeader head;
    cin >> head;
    ASSERT(head.classType() == SplineSurface::classType());
    SplineSurface sf;
    cin >> sf;
    vector<double> points;
    vector<double> param_u;
    vector<double> param_v;
    sf.gridEvaluator(ures, vres, points, param_u, param_v);
    RectGrid grid(ures, vres, sf.dimension(), &points[0]);
    grid.writeStandardHeader(cout);
    grid.write(cout);
}
开发者ID:99731,项目名称:GoTools,代码行数:22,代码来源:make_grid.C

示例6: main

int main(int argc, char** argv)
{
    // Read the surface from a file in Go-format.
    string filename("degenerate_sf.g2");
    cout << "\nProgram " << argv[0] << " using file " << filename.c_str() << endl;
    ifstream file(filename.c_str());
    if (!file) {
	cerr << "\nFile error. Could not open file: " << filename.c_str() << endl;
	return 1;
    }
    ObjectHeader head;
    SplineSurface surf;
    file >> head;
    if (!head.classType() == SplineSurface::classType()) {
	THROW("Object type is NOT SplineSurface.");
    }
    file >> surf;
    file.close();

    // Read the points from a file. xyz-coordinates.
    string point_filename("inp_degen_surf_close_points.dat");
    ifstream pfile(point_filename.c_str());
    if (!pfile) {
	cerr << "\nFile error. Could not open file: " << point_filename.c_str() << endl;
	return 1;
    }
    vector<Point> points;
    while (1) {
	Point p(3);
	pfile >> p;
	if (!pfile) break;
	points.push_back(p);
    }
    pfile.close();
    int N = (int)points.size();
    
    cout << "\nProgram '" << argv[0] << "' using input files '" << filename.c_str()
	 << "' and '" << point_filename.c_str()
	 << ", and output file 'degen_surf_close_points.g2'." << endl;

    // Find the points on the surface closest to these points.
    double close_u;      // Closest point's u parameter.
    double close_v;      // Closest point's v parameter.
    Point  close_pt(3);  // Closest point's coordinates.
    double close_dist;   // Distance between the two points.
    double epsilon = 1e-8;  // Parameter tolerance

    // Write to file vectors from a point to the closest point on the surface.
    ofstream fout2("degenerate_sf_close_points.g2");
    // Class_LineCloud=410 MAJOR_VERSION=1 MINOR_VERSION=1 auxillary data=4
    // The four auxillary data values defines the colour (r g b alpha)
    fout2 << "410 1 0 4 255 0 0 255" << endl; // Header.
    fout2 << N << endl;

    // Find closest point using the whole surface. (The two last arguments
    // 'RectDomain* domain_of_interest' and 'double *seed' are by default
    // equal to 0).
    cout << "\nClosest points from inputfile points to points on the surface ";
    for (int i=0; i<N; ++i) {
	surf.closestPoint(points[i], close_u, close_v, close_pt, close_dist,
			  epsilon);
	fout2 << points[i] << ' ' <<  close_pt << endl;  // write vector
	cout << "Point: " << points[i] << "  Closest point: " << close_pt
	     << "\nParameter values= " <<  close_u << " , " <<  close_v
	     << "  Closest distance= " << close_dist << endl;
    }
    fout2.close();


    // Find closest point from points on the surface. Should be 0 + some tolerance.
    cout << "\nClosest points from points on the surface." << endl;
    const int nsp = 9;
    double du = (surf.endparam_u() - surf.startparam_u()) / (nsp-1);
    double dv = (surf.endparam_v() - surf.startparam_v()) / (nsp-1);
    cout << "Parameter u from " << surf.startparam_u() << " to " << surf.endparam_u()
	 << "  step "  << du << endl;
    cout << "Parameter v from " << surf.startparam_v() << " to " << surf.endparam_v()
	 << "  step "  << dv << endl;
    double max_dist = 0.0;
    Point point;
    for (double v=surf.startparam_v(); v<=surf.endparam_v(); v += dv) {
	for (double u=surf.startparam_u(); u<=surf.endparam_u(); u += du) {
	    surf.point(point, u, v);  // interpolate at u,v
	    surf.closestPoint(point, close_u, close_v, close_pt, close_dist,
			      epsilon);
#ifdef DEBUG
	    cout << "\n        Point: " << point << "\nClosest point: " << close_pt
		 << "\nParameter values= " <<  close_u << " , " <<  close_v
		 << "  Closest distance= " << close_dist << endl;
#endif
	}
	max_dist = std::max(close_dist, max_dist);
    }
    cout << "\nMaximum distance between an interpolated point and the "
	 << "corresponding input point is " << max_dist << '\n' << endl;

}
开发者ID:99731,项目名称:GoTools,代码行数:97,代码来源:closestpoint_degenerate_sf.C

示例7: 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;
}
开发者ID:99731,项目名称:GoTools,代码行数:73,代码来源:rotational_swept_surface.C

示例8: main

int main(int argc, char *argv[])
{
    if (argc != 3)
    {
	std::cout << "Usage: sfs_file (.g2) repaired_sfs_file (.g2)" << std::endl;
	return -1;
    }

    std::ifstream filein(argv[1]); // Input bd sfs (may contain other objects).
    std::ofstream fileout(argv[2]); // Fixed bd sfs (and unaltered other objects).

    // For BoundedSurface we may choose to recreate all the boundary parameter curves.
    const bool recreate_par_cvs = true;
    if (recreate_par_cvs)
    {
	cout << "Recreating all parameter curve for CurveOnSurface." << endl;
    }

    // Create the default factory
    GoTools::init();

    ObjectHeader header;
    int num_bd_sfs = 0;
    int num_bd_sfs_fixed = 0;
    int num_bd_sfs_fix_failed = 0;
    int obj_id = 0;
    while (filein)
    {
	std::cout << "Object number: " << obj_id << std::endl;
	try {
	    header.read(filein);
	}
	catch (...)
	{
	    MESSAGE("Failed reading the Header!");
	    break; // Assuming we are either done or the rest of the file is garbage ...
	}

	shared_ptr<GeomObject> geom_obj(Factory::createObject(header.classType()));
	try
	{
	    geom_obj->read(filein);
	}
	catch (...)
	{
	    MESSAGE("Failed reading the GeomObject!");
	}
	if (geom_obj->instanceType() != Class_BoundedSurface)
	{
	    cout << "Writing to file an object of type :" << geom_obj->instanceType()<< endl;
	    geom_obj->writeStandardHeader(fileout);
	    geom_obj->write(fileout);
	} else if (geom_obj->instanceType() == Class_BoundedSurface)
	{
	    ++num_bd_sfs;
	    BoundedSurface* bd_sf = dynamic_cast<BoundedSurface*>(geom_obj.get());
	    double epsgeo = 1.5e-02;// bd_sf->getEpsGeo(); // The smallest for all the loops.
	    int valid_state = 0;
	    bool is_valid = bd_sf->isValid(valid_state);


#ifndef NDEBUG
	    std::ofstream debug("tmp/debug.g2");
	    ParamSurface* under_sf = bd_sf->underlyingSurface().get();
	    under_sf->writeStandardHeader(debug);
	    under_sf->write(debug);
	    for (int ki = 0; ki < bd_sf->numberOfLoops(); ++ki)
	    {
		shared_ptr<CurveLoop> loop = bd_sf->loop(ki);
		for (size_t kj = 0; kj < loop->size(); ++kj)
		{
		    shared_ptr<ParamCurve> cv = (*loop)[kj];
		    if (cv->instanceType() == Class_CurveOnSurface)
		    {
			shared_ptr<CurveOnSurface> cv_on_sf =
			    dynamic_pointer_cast<CurveOnSurface, ParamCurve>(cv);
			if (cv_on_sf->parameterCurve() != NULL) {
			    shared_ptr<SplineCurve> pcv =
				dynamic_pointer_cast<SplineCurve, ParamCurve>
				(cv_on_sf->parameterCurve());
			    if (pcv.get() != NULL)
				SplineDebugUtils::writeSpaceParamCurve(*pcv, debug, 0.0);
			    else
			    {
				cv_on_sf->parameterCurve()->writeStandardHeader(debug);
				cv_on_sf->parameterCurve()->write(debug);
			    }
			}
			if (cv_on_sf->spaceCurve() != NULL)
			{
			    cv_on_sf->spaceCurve()->writeStandardHeader(debug);
			    cv_on_sf->spaceCurve()->write(debug);
			}
		    }
		    else
		    {
			cv->writeStandardHeader(debug);
			cv->write(debug);
		    }
		}
//.........这里部分代码省略.........
开发者ID:heididahl,项目名称:GoTools,代码行数:101,代码来源:repairInvalidBoundedSurfaces.C

示例9: main

int main(int argc, char *argv[])
{
  if (argc != 4) {
    std::cout << "Usage: lrspline_in (.g2) refinement_in lrspline_out.g2 " << std::endl;
    return -1;
  }

  std::ifstream filein(argv[1]);
  std::ifstream filein2(argv[2]);
  std::ofstream fileout(argv[3]);

  // Create the default factory
  GoTools::init();
  Registrator<LRSplineSurface> r293;

  // Read input surface
  ObjectHeader header;
  try {
    header.read(filein);
  }
  catch (...)
    {
      std::cerr << "Exiting" << std::endl;
      exit(-1);
    }
  shared_ptr<GeomObject> geom_obj(Factory::createObject(header.classType()));
  geom_obj->read(filein);
  
  shared_ptr<ParamSurface> sf = dynamic_pointer_cast<ParamSurface, GeomObject>(geom_obj);
  if (!sf.get())
    {
      std::cerr << "Input file contains no surface" << std::endl;
      exit(-1);
    }

  shared_ptr<LRSplineSurface> lrsf = 
    dynamic_pointer_cast<LRSplineSurface, ParamSurface>(sf);
  if (!lrsf.get())
    {
      shared_ptr<SplineSurface> splsf = 
	dynamic_pointer_cast<SplineSurface, ParamSurface>(sf);
      if (splsf.get())
	lrsf = shared_ptr<LRSplineSurface>(new LRSplineSurface(splsf.get(), 1.0e-6));
    }
  if (!lrsf.get())
    {
      std::cerr << "Input file contains no spline surface" << std::endl;
      exit(-1);
    }
    
  
  shared_ptr<LRSplineSurface> tmp2(lrsf->clone());
  if (tmp2->dimension() == 1)
    tmp2->to3D();

  // tmp2->writeStandardHeader(fileout);
  // tmp2->write(fileout);
  // fileout << std::endl;
  // LineCloud lines2 = tmp2->getElementBds();
  // lines2.writeStandardHeader(fileout);
  // lines2.write(fileout);
  
  int nmb_refs;
  filein2 >> nmb_refs;
  for (int ki=0; ki<nmb_refs; ++ki)
    {
      double parval, start, end;
      int dir;
      int mult;

      filein2 >> parval;
      filein2 >> start;
      filein2 >> end;
      filein2 >> dir;
      filein2 >> mult;
      //lrsf->refine((dir==0) ? XFIXED : YFIXED, parval, start, end, mult);
      std::cout << "Iteration no. " << ki << std::endl;
      lrsf->refine((dir==0) ? XFIXED : YFIXED, parval, start, end, mult, true);

      puts("Writing lr-spline to file.");
      if (lrsf->dimension() == 1)
	lrsf->to3D();
      lrsf->writeStandardHeader(fileout);
      lrsf->write(fileout);
      fileout << std::endl;
    }
  return 0;
}
开发者ID:SINTEF-Geometry,项目名称:GoTools,代码行数:88,代码来源:testRefine.C

示例10: main

int main(int argc, char** argv)
{

  if (argc != 6)
    {
      cout << "Usage: " << argv[0] << " surfaceinfile surface3doutfile points3doutfile num_u num_v" << endl;
      exit(-1);
    }

  ifstream filein(argv[1]);
  ALWAYS_ERROR_IF(filein.bad(), "Bad or no curvee input filename");
  ObjectHeader head;
  filein >> head;
  if (head.classType() != SplineSurface::classType()) {
    THROW("Not a spline surface");
  }

  SplineSurface sf;
  filein >> sf;

  ofstream fileoutsurf(argv[2]);
  ALWAYS_ERROR_IF(fileoutsurf.bad(), "Bad surface output filename");

  ofstream fileoutpts(argv[3]);
  ALWAYS_ERROR_IF(fileoutpts.bad(), "Bad points output filename");

  int num_u = atoi(argv[4]);
  int num_v = atoi(argv[5]);

  vector<double> pts, param_u, param_v;

  sf.gridEvaluator(num_u, num_v, pts, param_u, param_v);

  vector<double> coefs3d;
  vector<Point> pts3d;
  int dim = sf.dimension();
  bool rational = sf.rational();

  int ctrl_pts = sf.numCoefs_u() * sf.numCoefs_v();
  vector<double>::const_iterator it = sf.ctrl_begin();

  for (int i = 0; i < ctrl_pts; ++i)
    {
      if (dim <= 3)
	for (int j = 0; j < 3; ++j)
	  {
	    if (j>=dim)
	      coefs3d.push_back(0.0);
	    else
	      {
		coefs3d.push_back(*it);
		++it;
	      }
	  }
      else
	{
	  for (int j = 0; j < 3; ++j, ++it)
	    coefs3d.push_back(*it);
	  it += (dim-3);
	}
      if (rational)
	{
	  coefs3d.push_back(*it);
	  ++it;
	}
    }

  int pts_pos = 0;
  for (int i = 0; i < num_u*num_v; ++i)
    {
      double x, y, z;
      if (dim == 0)
	x = 0.0;
      else
	x = pts[pts_pos];
      if (dim <= 1)
	y = 0.0;
      else
	y = pts[pts_pos+1];
      if (dim <= 2)
	z = 0.0;
      else
	z = pts[pts_pos+2];
      pts_pos += dim;
      pts3d.push_back(Point(x, y, z));
    }

  SplineSurface sf3d(sf.basis_u(), sf.basis_v(), coefs3d.begin(), 3, rational);

  sf3d.writeStandardHeader(fileoutsurf);
  sf3d.write(fileoutsurf);

  fileoutpts << "400 1 0 4 255 255 0 255" << endl;
  fileoutpts << pts3d.size() << endl;
  for (int i = 0; i < (int)pts3d.size(); ++i)
    fileoutpts << pts3d[i] << endl;
}
开发者ID:99731,项目名称:GoTools,代码行数:97,代码来源:test_gridEvalNon3d.C

示例11: 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();
//.........这里部分代码省略.........
开发者ID:akva2,项目名称:IFEM-GPM,代码行数:101,代码来源:main_orderElevation.cpp

示例12: main

int main(int argc, char** argv)
{
    if (argc != 5) {
	cout << "\nUsage: " << argv[0]
	     << " Infile1 Infile2 continuity Outfile\n" << endl;
	exit(-1);
    }
    cout << "\nRunning program " << argv[0]
	 << "\nInfile1    = " << argv[1]
	 << "\nInfile2    = " << argv[2]
	 << "\ncontinuity = " << argv[3]
	 << "\nOutfile    = " << argv[4]
	 <<  '\n' << endl;
    // Read first curve file
    ifstream infile(argv[1]);
    if (!infile) {
	cerr << "\nFile error. Could not open file: " << argv[1] << endl;
	return 1;
    }
    SplineCurve curve, other_curve;
    ObjectHeader header;
    infile >> header >> curve;
    if (!header.classType() == SplineCurve::classType()) {
	THROW("Object type is NOT SplineCurve.");
    }
    infile.close();

    // Read second curve file
    ifstream infile2(argv[2]);
    if (!infile2) {
	cerr << "\nFile error. Could not open file: " << argv[2] << endl;
	return 1;
    }
    infile2 >> header >> other_curve;
    if (!header.classType() == SplineCurve::classType()) {
	THROW("Object type is NOT SplineCurve.");
    }
    infile2.close();

    cout << "Curve orders : " << curve.order() << " and " << other_curve.order()
	 << endl;
    // Append the start of the second curve to the end of the first curve.
    double dist = 0; // The estimated maximum distorsion after 'smoothing' of
                     // joined curve to achieve the desired continuity.
    int continuity = atoi(argv[3]);  // Continuity. From -1 to order()-1.
    bool repar = true;     // The reparametrizatin of the second curve will also
                           // be scaled as a function of position of control
                           // points close to the transition.
    curve.appendCurve(&other_curve, continuity, dist, repar);
    cout << "Curve orders : " << curve.order() << " and " << other_curve.order()
 	 << " after appending curve." << endl;
    cout << "Estimated difference between original and smooth curve: "
	 << dist << endl;

    // Write the the new curve to output file. 
    ofstream outfile(argv[4]);
    outfile << header << curve;	

    return 0;

}
开发者ID:99731,项目名称:GoTools,代码行数:61,代码来源:append_curve.C

示例13: if

//===========================================================================
vector<double>  
TrimCrvUtils::readTrimPoints(ifstream& filein, Point& translate_vec)
//===========================================================================
{
  vector<double> pts_2d;
  translate_vec = Point(0.0, 0.0, 0.0);
  const bool translate_model = true;//false;
  if (translate_model)
    {
      MESSAGE("Switched off translation of the model to the origin!");
    }

  ObjectHeader header;
  header.read(filein);
  if (header.classType() == Class_PointCloud)
    {
      PointCloud3D pt_cloud;
      pt_cloud.read(filein);
      if (translate_model)
	{
	  translateToOrigin(pt_cloud, translate_vec);
	}
      const int dim = pt_cloud.dimension();
      assert(dim == 3);
      const int num_pts = pt_cloud.numPoints();
      vector<double> pts_3d(pt_cloud.rawData(), pt_cloud.rawData() + dim*num_pts);
      pts_2d.resize(num_pts*2);
      for (int ki = 0; ki < num_pts; ++ki)
	{
	  pts_2d[ki*2] = pts_3d[ki*dim];
	  pts_2d[ki*2+1] = pts_3d[ki*dim+1];
	}
    }
  else if (header.classType() == Class_LineCloud)
    {
      LineCloud line_cloud;
      line_cloud.read(filein);
      if (translate_model)
	{
	  translateToOrigin(line_cloud, translate_vec);
	}
      // Assuming the dimension is 3. Which is a requirement by LineCloud, strangely enough.
      const int dim = 3;
      const int num_lines = line_cloud.numLines();
      const int num_pts = num_lines + 1;
      pts_2d.resize(num_pts*2);
      const double* raw_data = line_cloud.rawData();
      pts_2d[0] = raw_data[0];
      pts_2d[1] = raw_data[1];
      for (int ki = 1; ki < num_pts; ++ki)
	{
	  pts_2d[ki*2] = raw_data[ki*dim*2-dim];
	  pts_2d[ki*2+1] = raw_data[ki*dim*2-dim+1];
	}
    }
  else
    {
      MESSAGE("Object  type " << header.classType() << " is not supported.");
    }

  return pts_2d;
}
开发者ID:SINTEF-Geometry,项目名称:GoTools,代码行数:63,代码来源:TrimCrvUtils.C


注:本文中的ObjectHeader::classType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。