Does TopoDS_Shape have its own transformation matrix ?

Hi OCC Team,
Every TopoDS_Shape has its own location as a affine matrix. If a composite shape made by 1000s of sub shapes,
Would each of sub TopoDS_Shape will have its own matrix ?

gkv311 n's picture

Transformation of TopoDS_Shape is stored within TopLoc_Location, which is not a single matrix, but rather a sequence of matrices. Within assembly structure, each subshape might have it's own additional transformation, so that final shape location is computed as multiplication of transformation of this shape and all it's parents. Take a look at TopExp_Explorer constructor - it has a flag to accumulate locations or not.

So that returning to your question - it is possible defining assembly structure where every subshape will have it's own location, or all subshapes having no own location, but inheriting some location of their parents. Whether you'll see these locations will depend on how you'll explore your shapes (and with which flags).

Sathiya nathan's picture

Thanks for explanation about where and how the matrix is used. I have an another doubt, If each sub shape of a compound shape holds its own matrix. Would it consume lot of memory ? For an assembly it is useful and necessary. But when a compound shape containing thousands of sub shapes and each shape holds matrix, the memory consumption would be noticeable, as well in most cases we use AIS_Shape to display a TopoDS_Shape and its has its own local matrix. Could you share your thought about it ?

gkv311 n's picture

Yes and no. TopLoc_Location holds transformations via smart pointers, so that an empty location doesn't occupy much space. And you don't need to put location where you don't need to. So the result will depend on assembly structure complexity and operations done on the model.

Sathiya nathan's picture

Wonderful. Nicely designed. I checked the source code, a static identity matrix is used for all the cases when user is not set the location explicitly and it uses smart pointer too. Thanks once again.