Mon, 04/02/2007 - 18:50

Forums:

Hello,every one,

If I have imported a shape with the iges file, and already displayed in the viewer, how could i retrieve the dimensions of the shape? Such as the width,length, height of a box, the radius of a circle? Must I get the vertices of the shape and compute it along?

Thank you for any suggestion!

Regards!

sparse

Tue, 04/03/2007 - 02:56

Hi everyone,

I've been dying to know the answer to this question for weeks together now. If someone could help me, I would be really grateful. Also, if it is not possible to get the dimensions of the IGES files directly, how do you get the dimensions of the BREP file (after translating the IGES fiel to BREP format).

Thanks a bunch!

-Karthik

Tue, 04/03/2007 - 02:56

Hi everyone,

I've been dying to know the answer to this question for weeks together now. If someone could help me, I would be really grateful. Also, if it is not possible to get the dimensions of the IGES files directly, how do you get the dimensions of the BREP file (after translating the IGES file to BREP format).

Thanks a bunch!

-Karthik

Tue, 02/19/2008 - 11:29

Hi Karthick...

How to get the dimensional data from imported 2D model..please tell me..It will be very helpful for my project.

If possible please send me some sample codes for getting the dimensions of different object....

Regards,

S.Vijayaragavan.

vjyragavan@yahoo.co.in

Tue, 04/03/2007 - 02:56

Hi everyone,

I've been dying to know the answer to this question for weeks together now. If someone could help me, I would be really grateful. Also, if it is not possible to get the dimensions of the IGES files directly, how do you get the dimensions of the BREP file (after translating the IGES file to BREP format).

Thanks a bunch!

-Karthik

Tue, 04/03/2007 - 15:01

Since every shape has different things you want to measure, you would need to look at each shape (most likely edges) individually. Iterate through the edges on your imported shape (TopExp_Explorer). Then, for each edge, you can get the underlying curve (BRep_Tool::Curve). Then, based on the underlying geometry of the curve, you can get the appropriate dimensions.

For example, let's say the curve (c) is a circle:

Handle(Standard_Type) curveType = c->DynamicType();

if (curveType == STANDARD_TYPE(Geom_Circle)) {

Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(c);

gp_Circ circleData = circle->Circ();

cout << circleData.Radius();

}

You would have to do similar things for the different types of curves you might encounter.

Alternatively, you can get the extents of an object in the global X,Y,and Z directions by using Bnd_Box and BRepBndLib:

Bnd_Box bounds;

BRepBndLib::Add(myShape, bounds);

bounds.SetGap(0.0);

Standard_Real fXMin, fYMin, fZMin, fXMax, fYMax, fZMax;

m_boxBound.Get(fXMin, fYMin, fZMin, fXMax, fYMax, fZMax);

Finally, you can always look at vertices and calculate distances from those.

I hope this helps.

Good luck.

Tue, 04/03/2007 - 17:06

Hello,Rob,

I tried your first method, and it works fine and i got some dimensions i needed. Thank you for your advice.

But It is too complicated to retrieve some dimensions like this. Is there any method more easier and more obvious?

And refer to your methods, How do i retrieve some specific dimensions, such as a line in a box or an arc in some compound solid? How do I know the dimensions I got is the one I needed?

Thank you

Sparce

Tue, 04/03/2007 - 17:07

Hello,Rob,

I tried your first method, and it works fine and i got some dimensions i needed. Thank you for your advice.

But It is too complicated to retrieve some dimensions like this. Is there any method more easier and more obvious?

And refer to your methods, How do i retrieve some specific dimensions, such as a line in a box or an arc in some compound solid? How do I know the dimensions I got is the one I needed?

Thank you

Sparce

Tue, 04/03/2007 - 17:21

Sorry, if you are looking for specific dimensions (like radii for circles and lengths of lines), I don't see an easy way. If enclosing dimensions orthogonal to the global axes are acceptable, the Bnd_Box may be ok.

The code I supplied can start with any shape (such as an internal solid or compound). It does not have to start with the top level shape of your import. The hard part is finding which shape to start with. Unless you are importing very predictable geometry or selecting the pertinent geoemtry interactively after import, I don't see how you could make sure you get dimensions for the right object. Likewise, it can be very difficult to identify something as a "box" as this is a combination of other shapes. You would need to find the solid, look through the faces and edges, and make sure they follow the topology of a box. This is no small task.

Tue, 04/03/2007 - 17:32

Hi,Rob,

Do the OCC have some functions or classes for those stuff? I mean if I import some files formated in iges, Do the IGESControl_xxx packages contain something i need? I wonder that and I check it out and find nothing related to this, Do I miss something?

And referring to importing files, how can i distinguish in programming that a box is a box and the spere is another? Do you know something about this?

Regards!

Sparse

Tue, 04/03/2007 - 18:12

There is nothing built-in to the IGESControl stuff to get what you want. The only thing there is to access the underlying IGESData_IGESModel and look at the IGES entities for dimensions. This is very cumbersome and probably not very useful.

Finding a sphere is not too bad, depending on how the sphere was defined. Just as you can look at the types of edges, you can look at the types of surfaces (BRep_Tool::Surface) on faces. So, you can see if a surface is a Geom_SphericalSurface and extract the necessary information from it. You can see a list of surfaces created from IGES entitites in the OCC IGES FORMAT User's Guide. Boxes are a lot harder. You would need to look at all the surfaces, make sure they are planar, their normals are along some orthogonal set of axes, and that they are trimmed to rectangles. It is a lot of work.

Tue, 04/03/2007 - 18:34

Hi,Rob,

Thank you for your detailed explanations and your patience. I will follow your suggestions to retrieve the data imformations in the imported files. And if I have some further puzzles in the future, hope you can give me some hints to get me out!

Best wishes!

Sparse

Tue, 02/19/2008 - 11:26

Hi Sparse...

How to get the dimensional data from imported 2D model..please tell me..It will be very helpful for my project.

If possible please send me some sample codes for getting the dimensions of different object....

Regards,

S.Vijayaragavan.

vjyragavan@yahoo.co.in