TopLoc_Location to a gp_Pnt

i want to transform a TopLoc_Location to a gp_Pnt
is that possible with OCC5...
How to do????
thanks lennass elkol!

Rob Bachrach's picture

I don't know if that makes sense to me. A TopLoc_Location is not a point, but a composite transformation. You may get what you are looking for by:

gp_Pnt pt = gp_Pnt(0.,0.,0.).Transformed(myLocation);

Note the automatic conversion from a location to a gp_Trsf. It may also work to convert the location to a gp_Trsf and call the TranslationPart member.

jooog's picture

Thanks Rob;
I really want to translate an object ( specially a surface) from it's location to another point...
the gp_Trsf Translation has as argument (Point1,point2)what I want is that the point1 is the location of the surface and point2 is the destination of the translation...How can I do this????????

Rob Bachrach's picture

I'm not sure I completely understand your question, but I'll tell you what I think will help and you can clarify if necessary...
If you have the two points, you can create your translation transform using SetTranslation on gp_Trsf. Then, if you have a Geom_Surface, you can call the Transform member function (passing your transformation) to translate the surface or Transformed to get a copy of the surface that has been translated, leaving the original in tact. If you have a face, rather than a surface, you should probably consider BRepBuilderAPI_Transform.

Ernest's picture

If you need no copy, just to transforme a TopoDS_Shape a; Use the a.Location(TopLoc_Location(atrsf)) function, where atrsf is the mentioned gp_Trsf. (Note gp_Trsf may contain only rotation, translation, and uniform scale, for nonuniform transformations
BRepBuilderAPI_GTransform shall be used as described above).

jooog's picture

hi Ernest;
I don't have the two point i only have the destination point(the second point)...
the first point is the location of the surface......so that's why i want to get the TopLoc_Location, set it to a point which will be the first point of the transformation...

jooog's picture

thanks for all Ernest I find the solution thanks to you...
i want you to take a look at
http://www.opencascade.org/org/forum/thread_8078/
it's another mad probleme if you still have an idea please help me
thanks alot again..