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

How to set axis in STEP

Anna Kliuchnikova's picture
Forums: 

Hello! I'm new in OCCS so I have too many questions.. I want to set Axis to the left down corner of my STEP model. How can I do it?

I import my STEP model with the help of MFC example in C++ and now I can see the plan of my room. I want to set axis at the left down corner of this room,

because I want to add a box into this room related to this corner. Now I see, that axis some where in the fix point and I don't know how far from the point of origin my imported objects are. 

I added the STEP file that I import to my example.

Attachments: 
Anna Kliuchnikova's picture

I suppose that I can get the minimal coordinates of all my shapes (but I don't know how) and set axis at this point (may be it is somewhere in Context in viewer?)

qa qa's picture

Hi,

As I can see you have axis-aligned model, so you can use axis-aligned bounding box of the model via BRepBndLib class:

https://www.opencascade.com/doc/occt-7.3.0/refman/html/class_b_rep_bnd_l...

Unfortunately, don't know much about OCCT visualization.

qaqa

Anna Kliuchnikova's picture

Hi, qaqa!

I already use axis-aligned box and can add it to my model.

But problem is I want to know coordinates of the most left and the most down shape from my model to set these coordinates as a new point of origin.

Now I can add a box related to standard point of origin and I don't know how to change it

In the picture you can see a model (very small room - I only load it it is standard loading) and then I add a box with coordinates (-3500, 8500, 0) these coordinates are related the global (0,0,,0) but I want to change (0,0,0) on some coordinates at the left down corner of my room

Attachments: 
qa qa's picture

Usually, box has several constructors. One of them builds box from origin point (0, 0, 0), other accept two corner points:

https://www.opencascade.com/doc/occt-7.3.0/refman/html/class_b_rep_prim_...

What class did you use to generate this box?

Anna Kliuchnikova's picture

I use class BRepPrimAPI_MakeBox  : public BRepBuilderAPI_MakeShape from MFC example

I know how to use it:

//! Make a box with a corner at 0,0,0 and the other dx,dy,dz
  Standard_EXPORT BRepPrimAPI_MakeBox(const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);
  
  //! Make a box with a corner at P and size dx, dy, dz.
  Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Pnt& P, const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);
  
  //! Make a box with corners P1,P2.
  Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Pnt& P1, const gp_Pnt& P2);
  
  //! Ax2 is the left corner and the axis.
  //! Constructs a box such that its sides are parallel to the axes of
  //! -   the global coordinate system, or
  //! -   the local coordinate system Axis. and
  //! -   with a corner at (0, 0, 0) and of size (dx, dy, dz), or
  //! -   with a corner at point P and of size (dx, dy, dz), or
  //! -   with corners at points P1 and P2.
  //! Exceptions
  //! Standard_DomainError if: dx, dy, dz are less than or equal to
  //! Precision::Confusion(), or
  //! -   the vector joining the points P1 and P2 has a
  //! component projected onto the global coordinate
  //! system less than or equal to Precision::Confusion().
  //! In these cases, the box would be flat.
  Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Ax2& Axes, const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);

 but I need to change the origin point for my model because I want to give coordinates related to left down corner of my room.

I try to do next thing

auto axis = myAISContext->CurrentViewer()->PrivilegedPlane();

axis.SetLocation(gp_Pnt(-3600., 8500., 0.));

myAISContext->CurrentViewer()->SetPrivilegedPlane(axis);

but nothing happend

Anna Kliuchnikova's picture

I use class BRepPrimAPI_MakeBox  : public BRepBuilderAPI_MakeShape from MFC example

I know how to use it:

//! Make a box with a corner at 0,0,0 and the other dx,dy,dz
  Standard_EXPORT BRepPrimAPI_MakeBox(const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);
  
  //! Make a box with a corner at P and size dx, dy, dz.
  Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Pnt& P, const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);
  
  //! Make a box with corners P1,P2.
  Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Pnt& P1, const gp_Pnt& P2);
  
  //! Ax2 is the left corner and the axis.
  //! Constructs a box such that its sides are parallel to the axes of
  //! -   the global coordinate system, or
  //! -   the local coordinate system Axis. and
  //! -   with a corner at (0, 0, 0) and of size (dx, dy, dz), or
  //! -   with a corner at point P and of size (dx, dy, dz), or
  //! -   with corners at points P1 and P2.
  //! Exceptions
  //! Standard_DomainError if: dx, dy, dz are less than or equal to
  //! Precision::Confusion(), or
  //! -   the vector joining the points P1 and P2 has a
  //! component projected onto the global coordinate
  //! system less than or equal to Precision::Confusion().
  //! In these cases, the box would be flat.
  Standard_EXPORT BRepPrimAPI_MakeBox(const gp_Ax2& Axes, const Standard_Real dx, const Standard_Real dy, const Standard_Real dz);

 but I need to change the origin point for my model because I want to give coordinates related to left down corner of my room.

I try to do next thing

auto axis = myAISContext->CurrentViewer()->PrivilegedPlane();

axis.SetLocation(gp_Pnt(-3600., 8500., 0.));

myAISContext->CurrentViewer()->SetPrivilegedPlane(axis);

but nothing happend

Kirill Gavrilov's picture

 I want to set Axis to the left down corner of my STEP model. How can I do it?

What do you mean by "set Axis" in this context?
Do you want to display model moved to another origin (e.g. to virtually reset it to 0,0,0), or draw something considering this origin?

Probably you might find method AIS_InteractiveContext::SetLocation() helpful in your case...

qa qa's picture

You cannot change global coordinate system, only thing you can do is to apply transformation to the model.

Anna Kliuchnikova's picture

I want to change the position of origin for all model, because I need to add boxes on given coordinates and coordinates will be calculated from left down origin

But as I understood  AIS_InteractiveContext::SetLocation()  is for special object, but I don't know which object at the left down corner

Кирилл, я импортирую степ файл, а затем добавляю коробочку. Начальные координаты коробочки и её размеры я задаю. Но начальные координаты (её угол) отсчитываются откуда-то из середины - видимо там начало координат. Так вот я хочу сменить это начало координат в левый нижний угол комнаты. Чтобы пользователь знал, откуда отсчитывать положение коробочки. 

Anna Kliuchnikova's picture

Oh, ok, qaqa, I see. Thanks I'll think about it

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.