For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Trimmed Nurbs Surface

Pia Langoth's picture
Forums: 

Hi,

I am new to Opencascade and I hope that someone can help me with my problem:
What I want to do is to read an IGES-File and export the B-Spline surface information of the created shapes
(My aim is to use the spline surface information from Opencascade to create my own spline surfaces in an extern application.).
Ok, my code looks like this:

//Read IGES-File
Standard_Integer nIgesFaces,nTransFaces;
IGESControl_Reader myIgesReader;
IFSelect_ReturnStatus status = myIgesReader.ReadFile ("file.igs");
Handle(TColStd_HSequenceOfTransient) myList = myIgesReader.GiveList("iges-faces");
nIgesFaces = myList->Length();
nTransFaces = myIgesReader.TransferList(myList);

//Conversion of all found Shapes to Nurbs-Surfaces
for (int i=1; i {
TopoDS_Shape testShape = myIgesReader.Shape(i);
BRepBuilderAPI_NurbsConvert nurbs(testShape);
Handle(Geom_Surface) geom_Extrusion = BRepLib_FindSurface(nurbs.Shape()).Surface();
Handle(Geom_BSplineSurface) geombspline_Extrusion = GeomConvert::SurfaceToBSplineSurface(geom_Extrusion);

//Get number of control points in u/v-direction
int myNbUPoles = geombspline_Extrusion->NbUPoles();
int myNbVPoles = geombspline_Extrusion->NbVPoles();

//Get the control points for the spline surface
TColgp_Array2OfPnt aPoles(1, myNbUPoles, 1, myNbVPoles);
geombspline_Extrusion->Poles(aPoles);
}

Ok. The next step is to export the control point positions (poles), the uKnots and the vKnots and so on. I can do this and it works fine. But my problem is that I don't want to construct the "whole" spline surface, but only the "trimmed" surface.
I know that each TopoDS Face has a "loop" of TopoDS Edges which describe the "trimmed" surface.
My code looks like this (e.g.):

TopoDS_Shape testShape = myIgesReader.Shape(1);
TopoDS_Face testFace = TopoDS::Face(testShape);

Handle(Geom2d_Curve) a2DCurve;
TopExp_Explorer anExp(testFace, TopAbs_EDGE);

for (; anExp.More(); anExp.Next()) { // For each edge:

TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current());

Standard_Real First, Last;

a2DCurve = BRep_Tool::CurveOnSurface(anEdge, testFace, First, Last);
}

But I don't know how to use this information for my spline surfaces?! Is there a function that calculates if a given (u,v)-point lies inside the bspline surface (and inside the corresponding loop of edges)?
Maybe someone could give me a hint how to solve my problem?!
Thank you very much for help!

Kind Regards,
Pia

Pia Langoth's picture

Hello,

ok nobody has an idea... maybe I should try again.
My aim is:
1. Read IGES-File
2. Convert all faces to spline surfaces
3. Export the geomtric description (poles, uKnots, vKnots, uDegree, vDegree and so on)

Ok. At the moment I am able to read the IGES-File doing:

Standard_Integer nIgesFaces,nTransFaces;
IGESControl_Reader myIgesReader;
IFSelect_ReturnStatus status = myIgesReader.ReadFile ("file.igs");

Then I look for the faces and convert them to spline surfaces:

Handle(TColStd_HSequenceOfTransient) myList = myIgesReader.GiveList("iges-faces");
nIgesFaces = myList->Length();
nTransFaces = myIgesReader.TransferList(myList);

//Conversion of all found Shapes to Nurbs-Surfaces:
for (int i=1; i {
TopoDS_Shape testShape = myIgesReader.Shape(i);
BRepBuilderAPI_NurbsConvert nurbs(testShape);
Handle(Geom_Surface) geom_Extrusion = BRepLib_FindSurface(nurbs.Shape()).Surface();
Handle(Geom_BSplineSurface) geombspline_Extrusion =
GeomConvert::SurfaceToBSplineSurface(geom_Extrusion);
}

Get spline surface data:
//Get number of control points in u/v-direction
int myNbUPoles = geombspline_Extrusion->NbUPoles();
int myNbVPoles = geombspline_Extrusion->NbVPoles();

//Get the control points for the spline surface
TColgp_Array2OfPnt aPoles(1, myNbUPoles, 1, myNbVPoles);
geombspline_Extrusion->Poles(aPoles);

Ok. But when I construct the spline surfaces in my extern application the surfaces are not equal to the faces in the IGES-file. I think this happens because I do not consider the boundary of the faces.
What I need is a function which tells me if a point lies on the spline surface AND if it is inside the given boundary.
I am quite sure that there exists such a function in Open Cascade (Does someone know where to find the function?) -> I think the triangulation algorithm for a face must use something like this because it must consider the boundary too. Can anybody tell me if my understanding is correct?
It would be great if someone could help me!
Thank you very much!!
Kind Regards,
Pia

Nathaniel Essenberg's picture

I know this is a very old thread, and I don't normally resurrect old threads, but I am in exactly the same situation (except I am importing STEP files).

Did you ever figure out how to do this? I have been trying for some days now, but no success yet. And it is becoming frustrating, especially since I should really get this running asap, and this "trimming" is the only thing keeping me back.