how can i get the Geom_Object form a selected TDF_Label
Kaka Li
2009/06/26 05:32
hello,
i use the salome geom module ported to WIN32, and i created a vertex
OnCreatepoint()
{
EraseAll();
CPointDlg Dlg;
if(Dlg.DoModal()!=IDOK) return;
Handle(TDocStd_Document) D = GetOcafDoc();
D->NewCommand();
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.
OnVertexSelect()
{
Handle(TDocStd_Document) D = GetOcafDoc();
D->NewCommand();
// Get the selected interactive object
myAISContext->InitCurrent();
Handle(AIS_InteractiveObject) curAISObject = myAISContext->Current();
// Get the main label of the selected object
Handle(TPrsStd_AISPresentation) ObjectPrs =
Handle(TPrsStd_AISPresentation)::DownCast(curAISObject->GetOwner());
TDF_Label LabObject = ObjectPrs->Label();
}
thanks for some suggestion
Fotis Sioutis
2009/06/26 09:00
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:
while (!isFound && !isRoot)
{
anObj = GEOM_Object::GetObject(Label);
if (!anObj.IsNull())
isFound = true;
if (Label.IsRoot())
isRoot = true;
Label = Label.Father();
}
return anObj;
}
Greetings
Fotis
Kaka Li
2009/06/29 04:11
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
2009/06/29 08:46
"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.