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


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

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


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

示例1: main

int main(int argc, char** argv)
{
  if (argc != 2 && argc != 4)
    {
      std::cout << "Usage; infile (nmb u pts) (nmb v pts)" << std::endl;
      return -1;
    }

  std::ifstream infile(argv[1]);
  ObjectHeader head;
  head.read(infile);
  BoundedSurface gosf;
  gosf.read(infile);

  const RectDomain& dom = gosf.containingDomain();
  double start_u = dom.umin();
  double end_u = dom.umax();
  double start_v = dom.vmin();
  double end_v = dom.vmax();

  int nmb_u = 20, nmb_v = 20;
  if (argc == 4)
    {
      nmb_u = atoi(argv[2]);
      nmb_v = atoi(argv[3]);
    }
  double del_u = (end_u - start_u)/(double)(nmb_u-1);
  double del_v = (end_v - start_v)/(double)(nmb_v-1);

  vector<Point> inside;
  int ki, kj;
  double u, v;
  for (v=start_v, ki=0; ki<nmb_v; v+=del_v, ki++)
    for (u=start_u, kj=0; kj<nmb_u; u+=del_u, kj++)
      {
	Point curr;

	if (!gosf.inDomain(u,v))
	  continue;

	gosf.point(curr, u, v);
	inside.push_back(curr);
      }

  std::ofstream out_file("inside_pts.g2");
  out_file << "400 1 0 4 255 0 0 255" << std::endl;
  out_file << inside.size() << std::endl;
  for (ki=0; ki < (int)inside.size(); ki++)
    {
      out_file << inside[ki][0] << " " << inside[ki][1] << " ";
      out_file << inside[ki][2] << std::endl;
    }
}
开发者ID:99731,项目名称:GoTools,代码行数:53,代码来源:test_inDomain.C

示例2: main

int main(int argc, char** argv)
{
 
    if (argc != 6) {
	cout << "Usage: spline_sf x0 y0 z0 r" << endl;
	return 0;
    }

    ObjectHeader header;

    // Read the first curve from file
    ifstream filein(argv[1]);
    if (filein.bad()) {
	cerr << "File #1 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    double x0 = atof(argv[2]);
    double y0 = atof(argv[3]);
    double z0 = atof(argv[4]);
    double r = atof(argv[5]);

    header.read(filein);
    shared_ptr<ParamSurface> surf(new SplineSurface());
    surf->read(filein);
    filein.close();

    Point center(x0, y0, z0);    
    shared_ptr<SphereInt> sphere(new SphereInt(center, r));
//     double dummy_tol = 1e-03; // @@sbr Not yet used.
    shared_ptr<ParamObjectInt> par_obj_int(new ParamSurfaceInt(surf));
    shared_ptr<AlgObjectInt> alg_obj_int = sphere;

    shared_ptr<GeoTol> aepsge(new GeoTol(1.e-6));
    //IntersectorAlgPar int_alg_par(alg_obj_int, par_obj_int, aepsge);
    IntersectorAlgPar int_alg_par(sphere, par_obj_int, aepsge);

    int_alg_par.compute();
    std::vector<shared_ptr<IntersectionPoint> > int_points;
    std::vector<shared_ptr<IntersectionCurve> > int_curves;
    int_alg_par.getResult(int_points, int_curves);

    cout << "IntPoints found: " << int_points.size() << endl;
    cout << "IntCurves found: " << int_curves.size() << endl;

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

示例3: main

int main(int argc, char** argv)
{
 
    if (argc != 3) {
	cout << "Usage: pickSingularRegion FileSf1 FileSf2"
	     << endl;
	return 0;
    }


    ObjectHeader header;

    // Read the first curve from file
    ifstream input1(argv[1]);
    if (input1.bad()) {
	cerr << "File #1 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input1);
    shared_ptr<ParamSurface> surf1(new SplineSurface());
    surf1->read(input1);
    input1.close();
    
    // Read the second curve from file
    ifstream input2(argv[2]);
    if (input2.bad()) {
	cerr << "File #2 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input2);
    shared_ptr<ParamSurface> surf2(new SplineSurface());
    surf2->read(input2);
    input2.close();

    cout << setprecision(15);

    // Make the first subsurface
    SplineSurface* sf1 = dynamic_cast<SplineSurface*>(surf1.get());
    double from_upar = 52.0248;
    double from_vpar = 0.968029;
    double to_upar = sf1->endparam_u();
    double to_vpar = 1.03197;
    SplineSurface* sub1
	= sf1->subSurface(from_upar, from_vpar, to_upar, to_vpar);
    // Make the second subsurface
    SplineSurface* sf2 = dynamic_cast<SplineSurface*>(surf2.get());
    from_upar = 52.03;
    from_vpar = 0.968027;
    to_upar = 52.0349;
    to_vpar = 1.03197;
    SplineSurface* sub2
	= sf2->subSurface(from_upar, from_vpar, to_upar, to_vpar);

    // Magnify in the direction normal to the surfaces
    typedef vector<double>::iterator iter;
    for (iter it = sub1->coefs_begin(); it != sub1->coefs_end(); it += 3) {
	it[0] -= 5.5;
	it[1] += 10.6;
	it[2] += 21.9;
	it[0] *= 100;
	it[1] *= 100;
	it[2] *= 100;
    }
    for (iter it = sub2->coefs_begin(); it != sub2->coefs_end(); it += 3) {
	it[0] -= 5.5;
	it[1] += 10.6;
	it[2] += 21.9;
	it[0] *= 100;
	it[1] *= 100;
	it[2] *= 100;
    }
    Point normal1 = sub1->normalCone().centre();
    Point normal2 = sub2->normalCone().centre();
    Point normal = normal1 + normal2;
    for (iter it = sub1->coefs_begin(); it != sub1->coefs_end(); it += 3) {
	Point coef(it[0], it[1], it[2]);
	double fac = normal * coef;
	fac *= 100.0;
	it[0] += fac * normal[0];
	it[1] += fac * normal[1];
	it[2] += fac * normal[2];
    }
    for (iter it = sub2->coefs_begin(); it != sub2->coefs_end(); it += 3) {
	Point coef(it[0], it[1], it[2]);
	double fac = normal * coef;
	fac *= 100.0;
	it[0] += fac * normal[0];
	it[1] += fac * normal[1];
	it[2] += fac * normal[2];
    }

    ofstream out1("subsurf1.g2");
    sub1->writeStandardHeader(out1);
    sub1->write(out1);
    ofstream out2("subsurf2.g2");
    sub2->writeStandardHeader(out2);
    sub2->write(out2);

//.........这里部分代码省略.........
开发者ID:99731,项目名称:GoTools,代码行数:101,代码来源:pickSingularRegion.C

示例4: main

int main(int argc, char** argv)
{
 
    if (argc != 4) {
	cout << "Usage: test_CvCvIntersector FileCv1 FileCv2 aepsge"
	     << endl;
	return 0;
    }


    ObjectHeader header;

    // Read the first curve from file
    ifstream input1(argv[1]);
    if (input1.bad()) {
	cerr << "File #1 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input1);
    shared_ptr<ParamCurve> curve1(new SplineCurve());
    curve1->read(input1);
    input1.close();
    
    // Read the second curve from file
    ifstream input2(argv[2]);
    if (input2.bad()) {
	cerr << "File #2 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input2);
    shared_ptr<ParamCurve> curve2(new SplineCurve());
    curve2->read(input2);
    input2.close();

    double aepsge;
    aepsge = atof(argv[3]);

//     cout << "\nFile : " << argv[2] << " Parameter range u: "
// 	 << curve1->startparam_u() <<" " << curve1->endparam_u()
// 	 << " Parameter range v: " << curve1->startparam_v() <<" " 
// 	 << curve1->endparam_v();

//     cout << "\nFile : " << argv[2] << " Parameter range u: "
// 	 << curve2->startparam_u() <<" " << curve2->endparam_u()
// 	 << " Parameter range v: " << curve2->startparam_v() <<" " 
// 	 << curve2->endparam_v() << endl;

    shared_ptr<ParamGeomInt> scurveint1 =
	shared_ptr<ParamGeomInt>(new SplineCurveInt (curve1));
    shared_ptr<ParamGeomInt> scurveint2 =
	shared_ptr<ParamGeomInt>(new SplineCurveInt (curve2));

    CvCvIntersector cvcvintersect (scurveint1, scurveint2, aepsge);
    cvcvintersect.compute();

    std::vector<shared_ptr<IntersectionPoint> > intpts;
    std::vector<shared_ptr<IntersectionCurve> > intcrv;
    cvcvintersect.getResult(intpts, intcrv);
    printf("Number of points: %d \n", int(intpts.size()));
    printf("Number of curves: %d \n", int(intcrv.size()));

    int ki, kj;
    for (ki=0; ki < int(intpts.size()); ki++) {
	std::vector<double> par = intpts[ki]->getPar();
	for (kj=0; kj<int(par.size()); kj++)
	    std::cout << par[kj] << " ";
	std::cout << std::endl;
    }

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

示例5: main

int main(int argc, char** argv)
{
    if (argc != 7) {
	cout << "Usage: test_curveSplineCurveInt FILE1 FILE2 "
	     << "pstart1 pstart2 pstop1 pstop2"
	     << endl;
	return 0;
    }
    double pstart1, pstart2, pstop1, pstop2;
    pstart1 = atof(argv[3]);
    pstart2 = atof(argv[4]);
    pstop1 = atof(argv[5]);
    pstop2 = atof(argv[6]);
    ObjectHeader header;

    // Read first curve from file
    ifstream input(argv[1]);
    if (input.bad()) {
	cerr << "File #1 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input);
    shared_ptr<SplineCurve> curve1(new SplineCurve());
    curve1->read(input);
    input.close();

   
    
    // Read second curve from file
    ifstream input2(argv[2]);
    if (input2.bad()) {
	cerr << "File #2 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input2);
    shared_ptr<SplineCurve> curve2(new SplineCurve());
    curve2->read(input2);
    input.close();

//     int prec = std::cout.precision(16);
    cout << "\nFile : " << argv[1] << " Parameter range: "
	 << curve1->startparam() <<" " << curve1->endparam();
    cout << "  Start: " << pstart1 << "  Stop: " << pstop1;
    cout << "\nFile : " << argv[2] << " Parameter range: "
	 << curve2->startparam() <<" " << curve2->endparam();
    cout << "  Start: " << pstart2 << "  Stop: " << pstop2 << endl;

    const double eps = 1.e-4;
    cout << "  Eps= " << eps << endl;

//     SplineCurveInt sci1(curve1);

//     SplineCurveInt sci2(curve2);

//     int istat;
//     istat = sci1.checkCoincidence(pstart1, pstop1, eps, &sci2,
// 				  pstart2, pstop2);

//     cout << "\nistat = " << istat;

//     if (istat==0)
// 	cout << "  Curves are not coinciding." << endl;
//     else
// 	cout << "  Curves are coinciding." << endl;

//     std::cout.precision(prec);  

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

示例6: main

int main(int argc, char** argv)
{
#ifndef _MSC_VER
    setenv("DEBUG", "1", 1);
    setenv("DEBUG_PAR", "1", 1);
    setenv("DEBUG_FINISH", "1", 1);
    setenv("DEBUG_IMPL", "1", 1);
    setenv("SUBDIV_SFCV", "1", 1);

    if (getenv("DEBUG") && (*getenv("DEBUG"))=='1')
	cout << "DEBUG=1" << endl;
    if (getenv("DEBUG_PAR") && (*getenv("DEBUG_PAR"))=='1')
	cout << "DEBUG_PAR=1" << endl;
    if (getenv("DEBUG_FINISH") && (*getenv("DEBUG_FINISH"))=='1')
	cout << "DEBUG_FINISH=1" << endl;
    if (getenv("DEBUG_IMPL") && (*getenv("DEBUG_IMPL"))=='1')
	cout << "DEBUG_IMPL=1" << endl;
    if (getenv("SUBDIV_SFCV") && (*getenv("SUBDIV_SFCV"))=='1')
	cout << "SUBDIV_SFCV=1" << endl;
#endif // _MSC_VER
 
    if (argc != 5 && argc != 6) {
	cout << "Usage: test_CvCvIntersector FileSf FileCv"
	     << " aepsge switch-order (OutputFile)" << endl;
	return 0;
    }

    ObjectHeader header;

    // Read the first curve from file
    ifstream input1(argv[1]);
    if (input1.bad()) {
	cerr << "File #1 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input1);
    shared_ptr<ParamSurface> surf(new SplineSurface());
    surf->read(input1);
    input1.close();
    
    // Read the second curve from file
    ifstream input2(argv[2]);
    if (input2.bad()) {
	cerr << "File #2 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input2);
    shared_ptr<ParamCurve> curve(new SplineCurve());
    curve->read(input2);
    input2.close();

    double aepsge;
    aepsge = atof(argv[3]);

    int seq;
    seq = atoi(argv[4]);

    ofstream tmpout;
    if (argc == 6)
	tmpout.open(argv[5]);
    ostream& out = (argc == 6) ? tmpout : cout;
    out << setprecision(8);

    // Setup the SplineSurfaceInt and SplineCurveInt objects
    shared_ptr<ParamGeomInt> ssurfint =
	shared_ptr<ParamGeomInt>(new SplineSurfaceInt (surf));
    shared_ptr<ParamGeomInt> scurveint =
	shared_ptr<ParamGeomInt>(new SplineCurveInt (curve));

    // Set up and run the intersection algorithm
    if (seq)
    {
	SfCvIntersector sfcvintersect(scurveint, ssurfint, aepsge);
	sfcvintersect.compute();

	// Get the results
	vector<shared_ptr<IntersectionPoint> > intpts;
	vector<shared_ptr<IntersectionCurve> > intcrv;
	sfcvintersect.getResult(intpts, intcrv);

	cout << "Number of points: " << intpts.size() << endl;
	cout << "Number of curves: " << intcrv.size() << endl;

	for (int ki = 0; ki < int(intpts.size()); ki++) {
	    double dist = intpts[ki]->getDist();
	    vector<double> par = intpts[ki]->getPar();
	    for (int kj = 0; kj < int(par.size()); kj++)
		cout << par[kj] << " ";
	    cout << ": dist = " << dist << endl;
	}

	// Write regression test data
	int npoints = (int)intpts.size();
	int ncurves = (int)intcrv.size();
	vector<double> par;
	out << "-1 ______________Case sf-cv intersector______________"
	    << endl;
	out << "0 Surf-Curve:    npoints = " << npoints
//.........这里部分代码省略.........
开发者ID:99731,项目名称:GoTools,代码行数:101,代码来源:test_SfCvIntersector.C

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: main

int main(int argc, char** argv)
{
    if (argc != 4) {
	cout << "Usage: " << argv[0] << " FileSf FileCv aepsge" << endl;
	return 0;
    }

    ObjectHeader header;

    // Read the first curve from file
    ifstream input1(argv[1]);
    if (input1.bad()) {
	cerr << "File #1 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input1);
    SplineSurface surf;
    surf.read(input1);
    input1.close();
    
    // Read the second curve from file
    ifstream input2(argv[2]);
    if (input2.bad()) {
	cerr << "File #2 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input2);
    SplineCurve curve;
    curve.read(input2);
    input2.close();

    double aepsge;
    aepsge = atof(argv[3]);

    // Set up and run the intersection algorithm
    SISLCurve* pcurve = Curve2SISL(curve);
    SISLSurf* psurf = GoSurf2SISL(surf);

    double astart1 = curve.startparam();
    double estart2[] = { surf.startparam_u(), surf.startparam_v() };
    double aend1 = curve.endparam();
    double eend2[] = { surf.endparam_u(), surf.endparam_v() };
    cout << "astart1 = " << astart1 << endl
	 << "estart2[] = { " << estart2[0] << ", "
	 << estart2[1] << " }" << endl
	 << "aend1 = " << aend1 << endl
	 << "eend2[] = { " << eend2[0] << ", " 
	 << eend2[1] << " }" << endl;

    double anext1 = astart1;
    double enext2[] = { estart2[0], estart2[1] };
//     double anext1 = 0.0;
//     double enext2[] = { 2.0, 0.0 };
    cout << "anext1 = " << anext1 << endl
	 << "enext2[] = { " << enext2[0] << ", "
	 << enext2[1] << " }" << endl;

    double cpos1;
    double gpos2[2];
    int jstat = 0;
    cout << "jstat = " << jstat << endl;

    s1772(pcurve, psurf, aepsge, astart1, estart2, aend1, eend2,
	  anext1, enext2, &cpos1, gpos2, &jstat);

    // Write the results
    cout << "Results s1772:" << endl
	 << "jstat = " << jstat << endl
	 << "cpos1 = " << cpos1 << endl
	 << "gpos2[] = { " << gpos2[0] << ", "
	 << gpos2[1] << " }" << endl;

    return 0;

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

示例12: main

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

  std::ifstream filein(argv[1]); // Input lr spline.
  int ind_u_min = atoi(argv[2]);
  int ind_v_min = atoi(argv[3]);

  ObjectHeader header;
  header.read(filein);
  SplineSurface spline_sf;
  spline_sf.read(filein);

  // We write to screen some info about the spline.
  int dim = spline_sf.dimension();
  int order_u = spline_sf.order_u();
  int order_v = spline_sf.order_v();
  int num_coefs_u = spline_sf.numCoefs_u();
  int num_coefs_v = spline_sf.numCoefs_v();
  std::cout << "Spline sf info:  dim = " << dim << ", order_u = " << order_u << ", order_v = " << order_v << std::endl;
  std::cout << "                 num_coefs_u = " << num_coefs_u << ", num_coefs_v = " << num_coefs_v << std::endl;


  shared_ptr<SplineSurface> bez_sf;
  double umin, umax, vmin, vmax;
  if (ind_u_min == -1 && ind_v_min == -1)
  {
      puts("We use the global bezier refinement matrix code!");
      bez_sf = SplineUtils::refineToBezier(spline_sf);
      umin = bez_sf->startparam_u();
      umax = bez_sf->endparam_u();
      vmin = bez_sf->startparam_v();
      vmax = bez_sf->endparam_v();
  }
  else
  {
      const BsplineBasis& basis_u = spline_sf.basis_u();
      vector<double>::const_iterator iter = basis_u.begin() + ind_u_min;
      umin = *iter;
      while (*iter == umin)
	  ++iter;
      umax = *iter;
      ind_u_min = iter - basis_u.begin() - 1;

      const BsplineBasis& basis_v = spline_sf.basis_v();
      iter = basis_v.begin() + ind_v_min;
      vmin = *iter;
      while (*iter == vmin)
	  ++iter;
      vmax = *iter;
      ind_v_min = iter - basis_v.begin() - 1;

      vector<double> bez_coefs, bez_coefs2;
      Go::SplineUtils::refinedBezierCoefsCubic(spline_sf,
					       ind_u_min, ind_v_min,
					       bez_coefs);

      int num_bez_coefs_u = order_u;
      int num_bez_coefs_v = order_v;
      vector<double> knots_u(order_u, umin);
      knots_u.insert(knots_u.end(), order_u, umax);
      vector<double> knots_v(order_v, vmin);
      knots_v.insert(knots_v.end(), order_v, vmax);
      bez_sf = shared_ptr<SplineSurface>
	  (new SplineSurface(num_bez_coefs_u, num_bez_coefs_v,
			     order_u, order_v,
			     knots_u.begin(), knots_v.begin(),
			     bez_coefs.begin(),
			     dim));

#if 0
      refinedBezierCoefs(spline_sf,
			 ind_u_min, ind_v_min,
			 bez_coefs2);
      SplineSurface bez_sf2(num_bez_coefs_u, num_bez_coefs_v,
			    order_u, order_v,
			    knots_u.begin(), knots_v.begin(),
			    bez_coefs2.begin(),
			    dim);
#endif
  }

  // And finally we compare the distance in a number of sample params.
  const int num_samples_u = 137;
  const int num_samples_v = 143;
  double ustep = (umax - umin)/(num_samples_u -1);
  double vstep = (vmax - vmin)/(num_samples_v -1);
  Point spline_pt(dim), bez_pt(dim), bez_pt2(dim);
  double max_dist = -1.0;
  double max_dist2 = -1.0;
  for (size_t kj = 0; kj < num_samples_v; ++kj)
  {
      double vpar = vmin + kj*vstep;
      for (size_t ki = 0; ki < num_samples_u; ++ki)
      {
	  double upar = umin + ki*ustep;
	  spline_sf.point(spline_pt, upar, vpar);
//.........这里部分代码省略.........
开发者ID:99731,项目名称:GoTools,代码行数:101,代码来源:test_refinedBezierCoefsCubic.C

示例13: main

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

#ifndef _MSC_VER
//     _putenv("DEBUG=1");
//     _putenv("DEBUG_PAR=1");
//     _putenv("DEBUG_FINISH=1");
//     _putenv("DEBUG_IMPL=1");
    setenv("DEBUG", "1", 1);
    setenv("DEBUG_PAR", "1", 1);
    setenv("DEBUG_FINISH", "1", 1);
    //setenv("DEBUG_IMPL", "1", 1);
    setenv("SUBDIV_SFSF", "1", 1);
    setenv("DEBUG_MOVE", "1", 1);
    //setenv("DO_REPAIR", "1", 1);

    if (getenv("DEBUG") && (*getenv("DEBUG"))=='1')
	cout << "DEBUG=1" << endl;
    if (getenv("DEBUG_PAR") && (*getenv("DEBUG_PAR"))=='1')
	cout << "DEBUG_PAR=1" << endl;
    if (getenv("DEBUG_FINISH") && (*getenv("DEBUG_FINISH"))=='1')
	cout << "DEBUG_FINISH=1" << endl;
    if (getenv("DEBUG_IMPL") && (*getenv("DEBUG_IMPL"))=='1')
	cout << "DEBUG_IMPL=1" << endl;
    if (getenv("SUBDIV_SFSF") && (*getenv("SUBDIV_SFSF"))=='1')
	cout << "SUBDIV_SFSF=1" << endl;
    if (getenv("DEBUG_MOVE") && (*getenv("DEBUG_MOVE"))=='1')
	cout << "DEBUG_MOVE=1" << endl;
    if (getenv("DO_REPAIR") && (*getenv("DO_REPAIR"))=='1')
	cout << "DO_REPAIR=1" << endl;
#endif // _MSC_VER


    if (argc != 4 && argc != 5 && argc != 6) {
	cout << "Usage: test_SfSfIntersector FileSf1 FileSf2 "
	     <<" aepsge (OutputFile)(selfintflag)"
	     << endl;
	return 0;
    }


    ObjectHeader header;

    // Read the first curve from file
    ifstream input1(argv[1]);
    if (input1.bad()) {
	cerr << "File #1 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input1);
    shared_ptr<ParamSurface> surf1(new SplineSurface());
    surf1->read(input1);
    input1.close();
    
    // Read the second curve from file
    ifstream input2(argv[2]);
    if (input2.bad()) {
	cerr << "File #2 error (no file or corrupt file specified)."
	     << std::endl;
	return 1;
    }
    header.read(input2);
    shared_ptr<ParamSurface> surf2(new SplineSurface());
    surf2->read(input2);
    input2.close();

    double aepsge;
    aepsge = atof(argv[3]);

    ofstream tmpout;
    if (argc >= 5)
	tmpout.open(argv[4]);
    ostream& out = tmpout;//(argc == 6) ? tmpout : cout;

    int selfint_flag = 0;
    if (argc == 6)
      selfint_flag = atoi(argv[5]);

    int has_sing = false;
//     if (argc == 5)
// 	has_sing = atoi(argv[4]);
    double sing[4];
//     if (has_sing) {
// 	printf("Give singularity: ");
// 	scanf("%lf",sing);
// 	scanf("%lf",sing+1);
// 	sing[2] = sing[0];
// 	sing[3] = sing[1];
//     }

//     cout << setprecision(15);

    // Setup the SplineSurfaceInt objects
    shared_ptr<ParamGeomInt> ssurfint1 =
	shared_ptr<ParamGeomInt>(new SplineSurfaceInt (surf1));
    shared_ptr<ParamGeomInt> ssurfint2 =
	shared_ptr<ParamGeomInt>(new SplineSurfaceInt (surf2));

    // Set up and run the intersection algorithm
//.........这里部分代码省略.........
开发者ID:99731,项目名称:GoTools,代码行数:101,代码来源:test_SfSfIntersector.C


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