Trimming of Geom_BSplineSurface Urgent

I am trying to trim the Nurbs Surface and trim is a code

Handle(Geom_BSplineSurface) bSurface;
bSurface = new Geom_BSplineSurface(PolesArray,WeightArray,UKnotsArray, VKnotsArray, UMultiplicitiesArray, VMultiplicitiesArray,(nurbsSurfaceData->Uorder)-1/*U Degree*/,(nurbsSurfaceData->Vorder)-1/*V Degree*/,Standard_False,Standard_False);

Handle(TopTools_HSequenceOfShape) aHSequenceOfShape = new TopTools_HSequenceOfShape();

BRepBuilderAPI_MakeFace faceMaker(bSurface,Precision::Confusion());
faceMaker.Add(wire) ;
TopoDS_Face Nurbsface = faceMaker.Face();

I am not able to see trim face.I also tried to do it by another way
BRepBuilderAPI_MakeFace faceMaker(bSurface,wire, Precision::Confusion());

still no results plz help

Sharad Verma's picture

Hi Rahul,

BRepBuilderAPI_MakeFace faceMaker(bSurface, wire, Precision::Confusion()); will work!

Just check the following things.

(1). Whether the wire is correct or not? Use the following code.

// Check whether wire is Valid or not
BRepCheck_Analyzer brepCheckWire(wire);
Standard_Boolean isValidWire = brepCheckWire.IsValid();

This should return 1. if it is returning zero, i.e., something is wrong with the wire. Then check whether wire is closed or not?

(2) Check the orientation of the wire in the face. Use the code below.

TopoDS_Face builtFace = faceMaker.Face();

BRepCheck_Face checkFace(builtFace);
BRepCheck_Status orientStatus = checkFace.OrientationOfWires();

if(orientStatus == BRepCheck_BadOrientationOfSubshape)

// Creating OCCT Face
BRepBuilderAPI_MakeFace aFace(bSurface, wire, Precision::Confusion());
builtFace = aFace.Face();

(3) If everything is correct above then use the following code; Try to fix the face, This should definitely solve your problem;

TopoDS_Face builtFace = faceMaker.Face();

// Fixing the resulting face
ShapeFix_Face faceFix(builtFace);

builtFace = faceFix.Face();

Sharad Verma

rahulgalgali's picture

Thanks SharadJi for the reply,
I tried ur first two ways...
first one shows wire is valid.
second one shows the error of BRepCheck_BadOrientationOfSubshape and tried to do it according to ur way,still not working!!

N thank you for Help

rahulgalgali's picture

But ur third solution is working..thanks a lot :D