Dislaying B-Spline Surface

Everything DG Kernel: Technical discussions and issues
Post Reply
Mike_Blinn
Posts: 2
Joined: Fri Jun 28, 2024 2:09 am

Dislaying B-Spline Surface

Post by Mike_Blinn »

Hi all,

The problem, I'm currently on is to display a IBSplineSurface_DG in the view. It seems I need an entity to display anything. it would mean that there must be a way to prepare the IBSplineSurface_DG as a IEntity_DG. Any suggestions on working around this please, or if my reasoning is incorrect.

Thanks very much,
Mike
gerard12
Posts: 20
Joined: Tue Jun 18, 2024 6:09 am

Re: Dislaying B-Spline Surface

Post by gerard12 »

Hi Mike

You need to construct a BRep face and attach your surface to it, then add it to a new BRep geometry as its shape. The geometry can be attached to a new entity, which in turn can be added to the control's model.

A shortcut for this is to use code from Face sample:

Code: Select all

// Your surface
IUVSurface_DG iSurface;
IEntity_DG iEntity = m_iModel.AddNewBRepShape(ShapeType_DG.Face);
IBRepFace_DG iFace = iEntity.As<IBRepFace_DG>();
iFace.Surface = iSurface;
All faces have to have at least one wire of the outer edge(s). It is the way to define which part of the surface belongs to the face There are many ways to build them. Search for IBRepWire_DG in samples to find suitable one.

In FaceForm.BuildFace() it is done like

Code: Select all

IBRepWire_DG iWire = iFace.AddNewWire();			// Add new empty
IBRepEdge_DG iEdge0, iEdge1, iEdge2;
iEdge0 = iWire.AddNewEdge(true);		//.....
Like surfaces are attached to faces, edges must be defined with a curve. The easy way is to define the curve as PCurve, which is 2D curve is space of face's parameters. Often the PCurve can be constructed as a straight line defined by two 2D points. It can be attached to the edge with IBRepEdge_DG.SetPCurve(). Little messy thing is to ensure ends of PCurves are joined to each other to make a closed 2D polygon.

Look at the sample's code for details

Regards
Post Reply