Hi,
I need to build mesh out of some surfaces with curved boundaries. I can use IStdShape_DG to create a surface, but I do not understand how to set the constraints on the boundaries: I have boundaries as B-spline curves (lines, ellipses, ...). How can I add these boundaries to the surface and get a mesh in the end?
Best regards,
Boundries on a bspline surface
Re: Boundries on a bspline surface
This is what the brep structures are for. They mix surfaces and curves to form faces, which can be converted to mesh.
Create an entity with BRep geometry:
Code from DGKernel_7_2\Samples\NET\C#\ObjArray\NewGenericObjectForm.cs.
Add a face and attach the surface:
Adding the boundary (wire)
This assumes you have a single closed curve. For a multi-edge case repeat AddNewEdge() and SetCurve() calls.
Also, this needs the curves to be located exactly on the surface, otherwise you will have exceptions at some point. One way to ensure that is to define the curve(s) in the surface's u,v parameters and use IBRepEdge_DG.SetPCurve().
Another way is using projections like IUVSurface_DG.GetCurveProjection().
In case of multiple edges, ends of the curves must coincide up to like e-8 tolerance.
To get the mesh use entity.SetGeometryTypeEx()
and query IMesh_DG either out of the return or the entity.
Or add the entity to a new model instead and save as a mesh format: vrml, stl, obj.
Regards
Create an entity with BRep geometry:
Code: Select all
IEntity_DG entity = m_gen.Create<IEntity_DG>("BRep").As<IEntity_DG>();
IGeometry_DG geometry = entity.GetGeometry().As<IGeometry_DG>();
IBRepGeometry_DG brepGeom = geometry.As<IBRepGeometry_DG>();
Add a face and attach the surface:
Code: Select all
IBRepShape_DG shape = iGeomBRep.CreateShape(ShapeType_DG.Face);
IBRepFace_DG face = shape.As<IBRepFace_DG>();
face.Surface = yourIUVSurface_DG;
Code: Select all
IBRepWire_DG wire = face.AddNewWire();
IBRepEdge_DG edge = wire.AddNewEdge(true);
edge.SetCurve(yourICurve_DG);
Also, this needs the curves to be located exactly on the surface, otherwise you will have exceptions at some point. One way to ensure that is to define the curve(s) in the surface's u,v parameters and use IBRepEdge_DG.SetPCurve().
Another way is using projections like IUVSurface_DG.GetCurveProjection().
In case of multiple edges, ends of the curves must coincide up to like e-8 tolerance.
To get the mesh use entity.SetGeometryTypeEx()
and query IMesh_DG either out of the return or the entity.
Or add the entity to a new model instead and save as a mesh format: vrml, stl, obj.
Regards