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

Casting Shape handle to void *

Hugues De Cougny's picture


I would like to cast handle to TopoDS_Shape to something like void *, so that I can store the reference to the Shape in some C structures, that is completely independent of CAS.

This is what I have tried but, of course, it does not work since I am quite clueless in C++.

BRepTools::Read(aShape,file,aBuilder) (where file is some .brep file)

handle= reinterpret_cast(&aShape) (where handle is of type void *)

TopoDS_Shape& aShape= reinterpret_cast(handle);

The above is not correct but gives an idea of what I am trying to do. Question is: what is the correct way to get back to the TopoDS_Shape from the C style handle ?

Any help is greatly appreciated.

Alexander KARTOMIN's picture

You can easily cast a reference to the Handle object to void*:

void *pointer;

Handle(Some_Class) aHandle;


// Here only a pointer will be copied

pointer = &aHandle;

// Here the Handle object will be copied

aHandle = *(Handle(Some_Class) *)pointer;

Best regards,


Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.