AIS_Dimension & Relation

Hi,
Can someone please help me to understand exactly how the AIS_Dimension and Relation is used to display the dimensions of objects. I have tried by the documentation but am unsuccessful yet in displaying dimensions.
Some example code will be more helpful.
Please help.

N. Sharjith

Yuriy Sernivka's picture

This is almost 18 y.o. question ( it's almost allowed to buy the alcohol drinks :) ), but it still remains unanswered. As was looking for the same code sample too and have just found something on GitHub. So I leave the answer here. Maybe it will help someone else.

  Handle(AIS_Dimension) aDim;
  if (myIsDiameterDimension)
  {
    aDim = new AIS_DiameterDimension (aCircle);
    Handle(AIS_DiameterDimension)::DownCast(aDim)->SetFlyout (aDimDlg->GetFlyout());
  }
  else
  {
    aDim = new AIS_RadiusDimension (aCircle);
    Handle(AIS_RadiusDimension)::DownCast(aDim)->SetFlyout (aDimDlg->GetFlyout());
  }

  Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
  anAspect->MakeArrows3d (Standard_False);
  anAspect->MakeText3d (/* Text goes here */);
  anAspect->TextAspect()->SetHeight (/* Font height goes here */);
  anAspect->MakeTextShaded (/* Shall we select text? */);
  anAspect->SetCommonColor (/* Color? */);
  anAspect->MakeUnitsDisplayed (/* Display Units? */);
  if (/* Display Units? */)
  {
    aDim->SetDisplayUnits (/* Which Units? */);
  }

  aDim->SetDimensionAspect (anAspect);

  // Display dimension in the neutral point
  myAISContext->Display (aDim, Standard_True);

Source: https://github.com/twisted-pair/opencascade/blob/c997ced70a345ad3871cb959cd2ae5a4c28e0b0e/samples/mfc/standard/Common/RadiusParamsPage.cpp#L99

-Yuriy