Recognizing IGES objects, and each object properties

I took a look on the sample import/export demo source code. I couldn't find much help there becuase the result of

TopoDS_Shape aShape = Reader.OneShape();

is one shape. I want to be able to recognize all the shapes inside (aShape) and recognize the properties of each one of these objects.

I took a look on the "TopoDS_Shape Class" documentation, but couldn't find any function that allows me to do this.

My final goal is to be able to read each single object in the IGES file and get its properties.

I hope anyone can help me

Jeanmi B's picture

Hello,

Did your try reading the "Modeling Data" User's Guide ?
I suggest you Chapter 5 "Topology" that describes the basics (and more) of TopoDS_Shape.

Regards. Jean Michel.

Subhi Jamal's picture

Isn't there any single example that shows at least how to get one of the objects included in a compound object such as that we get from

TopoDS_Shape aShape = Reader.OneShape();

and then get the properties of this object.

Patrik Mueller's picture

Hi,

look for "TopExp_Explorer" in the OCC docs!

Regards,

Patrik

Subhi Jamal's picture

Hi,
thanks very much, your hint helped me alot.

I understood that I can get from the one shape
all the sub objects inside it and go to the level of vertex.

But sill I have this problem: suppose I was able to get all the faces inside the retrieved shape, how can I get the properties of this surface:
-ordered points in 3d space
-filling of this face

Can you help me?

Patrik Mueller's picture

Hi,

you can, for example, convert a face to a Handle_GeomSurface via "BRep_Tool::Surface(..).
After that you can get some of the properties you need.

HTH,

Patrik

Subhi Jamal's picture

Ok, I have an IGES file that contains only a solid cylinder.
-If I got all the faces from this shape.
-And used BRep_Tool::Surface() to convert the face to surface.

How can I know what type of surface I have got?

My final goal is to know what are the surfaces( cylinders,shperes,...) that exist in the file, and extract their properties to give it to an SDK to draw them object by object.

Patrik Mueller's picture

Hi,

how about that:

for (Ex.Init(myShape,TopAbs_FACE); Ex.More(); Ex.Next())
{
Surface = BRep_Tool::Surface(TopoDS::Face(Ex.Current()));
if (Surface->IsKind(STANDARD_TYPE(Geom_Plane)))
// your code
}

?

If you only want the points take a look at the Geom_Surface documentation.

Greets,

Patrik

Subhi Jamal's picture

I checked the documentaion of
"Geom_Surface"
but I couldn't find any method that lets me extract the points of the surface.

Subhi Jamal's picture

I used the following code to get the poles of a Geom_BSplineSurface surface:
if (Surface->IsKind(STANDARD_TYPE(Geom_BSplineSurface)))
{
TColgp_HArray2OfPnt arrayOfPoints;
Handle(Geom_BSplineSurface) spline = Handle (Geom_BSplineSurface)::DownCast(Surface);
spline->Poles(arrayOfPoints);
}

But the compiler complains about:
TColgp_HArray2OfPnt arrayOfPoints;

What should I do?

Patrik Mueller's picture

Hi,

Poles need an array of TColgp_Array2OfPnt instead of TColgp_HArray2OfPnt. Apart from that you have to initialize the array size.

Regards,

Patrik

Subhi Jamal's picture

Ok I have changed the code to:
if (Surface->IsKind(STANDARD_TYPE(Geom_BSplineSurface)))
{
TColgp_HArray2OfPnt arrayOfPoints(RowStart,RowEnd,ColStart,ColEnd);
Handle(Geom_BSplineSurface) spline = Handle(Geom_BSplineSurface)::DownCast(Surface);
spline->Poles(arrayOfPoints);
}

But I still get complaining about spline->Poles.

Here is the error message:
"cannot convert parameter 1 from 'class TColgp_HArray2OfPnt' to 'class TColgp_Array2OfPnt &"

Subhi Jamal's picture

Ok, I have an IGES file that contains only a solid cylinder.
-If I got all the faces from this shape.
-And used BRep_Tool::Surface() to convert the face to surface.

1. How can I know what type of surface I have got?

My final goal is to know what are the surfaces( cylinders,shperes,...) that exist in the file, and extract their properties to give it to an SDK to draw them object by object.

And it would be far more easier to me if I can get these surfaces as a series of 3D points.

2. Can I do so?

Francois Lauzon's picture

Hi Subhi,
Here is some code that you could use to get a list of IGES root entities (instead of one compound that include everything). From there you can do whatever you want (get the color, level, name, ...)
Good Luck. Francois.

// read file in memory
IGESControl_Controller::Init();
IGESControl_Reader aReader;
IFSelect_ReturnStatus stat=aReader.ReadFile(aFilename);

if (stat!=IFSelect_RetDone) {
return;
}

aReader.Check(Standard_True);
aReader.PrintCheckLoad(Standard_True,IFSelect_GeneralInfo);

// get all root shapes
Handle(TColStd_HSequenceOfTransient) aList=aReader.GiveList("xst-transferrable-roots");

// transfert all the iges entity
for (Standard_Integer j=1; j<=aList->Length(); j++) {
Handle(IGESData_IGESEntity) igesEntity=Handle(IGESData_IGESEntity)::DownCast(aList->Value(j));

aReader.Clear();
if (aReader.TransferEntity(igesEntity)) {
// do whatever you want with you iges entity,

// get the shape
TopoDS_Shape aShape=aReader.OneShape();

// get the name
Handle(TCollection_HAsciiString) aLabel;
if (igesEntity->HasShortLabel()) {
aLabel=igesEntity->ShortLabel();
}

// here I output the real type of this iges entity
cout << "IGES entity Name:"Name() <<" Type:"