Update vizualized object

Hello,

I'm quite new to OpenCascade.

I've successfully built a simple object from boolean a operation:  a cone cut by a sphere.

I've also been successful in displaying this object using the code:

  // Display Object
        TopoDS_Shape myShape1 = MakeObject();
        Handle(AIS_Shape) AIS_Shape1 = new AIS_Shape( myShape1);
        // mContext->SetMaterial(AISBottle,Graphic3d_NOM_GOLD);      //compile error...
        mContext->SetDisplayMode(AIS_Shape1, 1, Standard_False);
        mContext->Display(AIS_Shape1, Standard_False);
       // mContext->SetCurrentObject(AISBottle,Standard_False);

 

But it's unclear to me how to update the visualized object when its geometry is changed.

For example; if the sphere radius used in the boolean operation is changed , is it mandatory to re-create a new AIS_Shape object or some kind of Update() method can be called ?

Thanks for your help !!

 

 

Kirill Gavrilov's picture

Updating presentation will look like that:

// display original shape
const TopoDS_Shape aShapeOld = MakeObject();
Handle(AIS_Shape) aShapePrs = new AIS_Shape (aShapeOld);
mContext->Display (aShapePrs, AIS_Shaded, 0, false);
// redraw viewer

// display new shape
const TopoDS_Shape aShapeNew = MakeObject();
aShapePrs->SetShape (aShapeNew);
aShapePrs->SetToUpdate();
mContext->Display (aShapePrs, AIS_Shaded, 0, false);
// redraw viewer
mail.chiot_166953's picture

Understood !

Many thanks Kirill for this clarification.

Regards,

Karl