The difficult part is that OCC does not think of your object as a cylinder. Instead, it thinks of it as a group of topology ( 3 faces, two edges ) with underlying geometry ( two planar surfaces, one cylindrical surface, two circular curves. There are multiple ways to get the values you want, but I think the easiest is to get it from the curves. Try this:
Cast the AIS_InteractiveObject to an AIS_Shape
Get the TopoDS_Shape from the AIS_Shape
Use TopExp_Explorer to iterate through the curves
If the curve type is a circle, convert it to a circle
Get the radius and center of the circles
Note: I have not tried this code, but I think the general idea is correct.
double dRadius; // Variables to hold our results
gp_pnt ptEnds[2];
int numEndsFound = 0;
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(objList.First());
if (!aShape.IsNull ())
{
TopoDS_Shape topo = aShape->Shape()
TopExp_Explorer Ex;
// Get the circles at the top and bottom of the cylinder
for (Ex.Init(mWireframeShape,TopAbs_EDGE); Ex.More(); Ex.Next())
{
Handle(Geom_Curve) curve;
double dParamStart;
double dParamEnd;
curve = BRep_Tool::Curve(TopoDS::Edge(Ex.Current()), dParamStart, dParamEnd );
if (curve->IsKind(STANDARD_TYPE(Geom_Circle)))
{
Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(curve);
if (!aCircle .IsNull ())
{
gp_Circ circle = aCircle->Circ();
dRadius = circle.Radius();
ptEnds[numEndsFound] = circle.Location();
numEndsFound++;
if( numEndsFound == 2 )
{
break;
}
}
}
}
}
if( numEndsFound != 2 )
{
// Something didn't work right!!
}
// I'll leave it to you to calculate the position and height from the two end points.