天天看點

opencascade中的幾種類型轉換将Geom_BSplineSurface轉化成TopoDS_Face:将TopoDS_Face 轉化為Geom_Surface普通曲線轉化為NURBS曲線Geom_Surface 轉 Geom_BsplineSurface點雲轉 Geom_BsplineSurface

opencascade中的幾種類型轉換

  • 将Geom_BSplineSurface轉化成TopoDS_Face:
  • 将TopoDS_Face 轉化為Geom_Surface
  • 普通曲線轉化為NURBS曲線
  • Geom_Surface 轉 Geom_BsplineSurface
  • 點雲轉 Geom_BsplineSurface

————————————————

版權聲明:本文為CSDN部落客「Damons_Sun」的原創文章,遵循CC 4.0 BY-SA版權協定,轉載請附上原文出處連結及本聲明。

原文連結:https://blog.csdn.net/shlkl99/article/details/8175206

将Geom_BSplineSurface轉化成TopoDS_Face:

Handle_Geom_BSplineSurface BSurface;
BRep_Builder builder;
TopoDS_Face Face;
builder.MakeFace(Face,BSurface,Tolerance);
           

将TopoDS_Face 轉化為Geom_Surface

Handle_Geom_Surface  currentSur;
TopExp_Explorer Ex; 
Ex.Init(shape,TopAbs_FACE); 
TopoDS_Face currentVt = TopoDS::Face(Ex.Current());
currentSur = BRep_Tool::Surface(currentVt);
           

普通曲線轉化為NURBS曲線

Handle(Geom_Curve) ResCurve ;
Handle(Geom_TrimmedCurve) myTrimmed = new Geom_TrimmedCurve(ResCurve, 0, 1);
NurbsCurve = GeomConvert::CurveToBSplineCurve(myTrimmed); //必須指定曲線的類型如Geom_TrimmedCurve

           

OCC的說明如下:

– Purpose : This function converts a non infinite curve from

– Geom into a B-spline curve.C must be an ellipse or a

– circle or a trimmed conic or a trimmed line or a Bezier

– curve or a trimmed Bezier curve or a BSpline curve or a

– trimmed BSpline curve or an OffsetCurve. The returned B-spline is

– not periodic except if C is a Circle or an Ellipse.

Geom_Surface 轉 Geom_BsplineSurface

其中surface必須為Geom_Surface 中的某一具體類型

OCC的說明如下:

— Purpose : This algorithm converts a non infinite surface from Geom

– into a B-spline surface.

– S must be a trimmed plane or a trimmed cylinder or a trimmed cone

– or a trimmed sphere or a trimmed torus or a sphere or a torus or

– a Bezier surface of a trimmed Bezier surface or a trimmed swept

–surface with a corresponding basis curve which can be turned into

– a B-spline curve

點雲轉 Geom_BsplineSurface

Handle_Geom_BSplineSurface CMiniCADTool::BuildSurface(const TColgp_SequenceOfXYZ& seqOfXYZ)
{
	// Build the surface:
	// points are projected on plane z = 0
	// the projection vector for each point is computed 
	// These data give the input constraints loaded into plate algorithm
 
	const Standard_Integer nbPnt = seqOfXYZ.Length();
	Standard_Integer i;
 
	//Filling plate
	Plate_Plate myPlate;
	for (i=1; i<= nbPnt; i += 4) {
		gp_Vec aVec(0., 0., seqOfXYZ.Value(i).Z());
		gp_XY  pntXY(seqOfXYZ.Value(i).X(),seqOfXYZ.Value(i).Y());
		Plate_PinpointConstraint PCst( pntXY,aVec.XYZ() );
		myPlate.Load(PCst); // Load a pinpoint constraint
	}
	myPlate.SolveTI(2, 1.); // Solving plate equations
	if (!myPlate.IsDone()) {
		return Handle(Geom_BSplineSurface)();
	}
 
	// Computation of plate surface
	gp_Pnt Or(0,0,0.);
	gp_Dir Norm(0., 0., 1.);
	Handle(Geom_Plane) myPlane = new Geom_Plane(Or, Norm);// Plane of normal Oz
	Handle(GeomPlate_Surface) myPlateSurf = new GeomPlate_Surface(myPlane, myPlate);//plate surface
 
	GeomPlate_MakeApprox aMKS(myPlateSurf, Precision::Approximation(), 4, 7, 0.001, 0);//bspline surface
	return aMKS.Surface();
 
}
           

繼續閱讀