how can i get the Geom_Object form a selected TDF_Label

i use the salome geom module ported to WIN32, and i created a vertex
CPointDlg Dlg;
if(Dlg.DoModal()!=IDOK) return;

Handle(TDocStd_Document) D = GetOcafDoc();

//get point
Handle(GEOM_Object) the_point = Basic->MakePointXYZ(Dlg.m_x, Dlg.m_y, Dlg.m_z);
char str[25];

//set label
TDF_Label aResultLabel;
Handle(TPrsStd_AISPresentation) prs;
aResultLabel = the_point->GetLastFunction()->GetEntry().FindChild(RESULT_LABEL);
prs= TPrsStd_AISPresentation::Set(aResultLabel, TNaming_NamedShape::GetID());
TDataStd_Integer::Set(aResultLabel, Dlg.m_id);


i can select the TDF_Label of the vertex just created, but i cannot get the Geom_Object, what can i do to get the Geom_Object of the TDF_Label.

Handle(TDocStd_Document) D = GetOcafDoc();


// Get the selected interactive object
Handle(AIS_InteractiveObject) curAISObject = myAISContext->Current();

// Get the main label of the selected object
Handle(TPrsStd_AISPresentation) ObjectPrs =
TDF_Label LabObject = ObjectPrs->Label();

thanks for some suggestion

Fotis Sioutis's picture

The "ObjectPrs->Label();" is the Label containing the TPrsStd_AISPresentation object, which actually is a descendant of the Label containing the GEOM_Object.

In case you have the TDF_Label of the GEOM_Object (maybe bound with an application tree leaf) you can get the GEOM_Object using :
a) GEOM_Object::GEOM_Object(TDF_Label& theLabel);
b) static Handle(GEOM_Object) GEOM_Object::GetObject(TDF_Label& theLabel);

In case you want to know how you can search the parents of your "ObjectPrs->Label();" to get the GEOM_Object, following code may be usefull:

Handle(GEOM_Object) GetGEOMFromStdAIS(Handle(TPrsStd_AISPresentation) anStdAISobj)
TDF_Label Label = anStdAISobj->Label();

Handle(GEOM_Object) anObj;

bool isFound = false;
bool isRoot = false;

while (!isFound && !isRoot)
anObj = GEOM_Object::GetObject(Label);
if (!anObj.IsNull())
isFound = true;
if (Label.IsRoot())
isRoot = true;
Label = Label.Father();
return anObj;


Fotis's picture

thank you very much, it really works.
now i want to add lofting shape to salome geom module ported to win32, do you have some advise?

Fotis Sioutis's picture

"Lofting" feature can be performed by use of GEOMImpl_I3DPrimOperations::MakeThruSections method.

The first parameter can be initialized as following :

Handle(TColStd_HSequenceOfTransient) theSeqSections = new TColStd_HSequenceOfTransient;
theSeqSections->Append(aSection); (for each section you may have)

The second parameter controls if the result will be a solid or a shell, face.
The fourth parameters controls if the result will have smooth transition from section to section or not.

Fotis's picture

u r a nice man, thank you very much