Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Open CASCADEShowroomGet it!Developer CornerSupportAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forum
Open Source community
Training and e-learning
A la Carte Support
Value-added software
CD-ROM
Company Profile
Contacts and Locations
Customers
News
Home / Developer Corner / Forum / how can i get the Geom_Object form a selected TDF_Label

Forum

how can i get the Geom_Object form a selected TDF_Label
Kaka Li2009/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();

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

     //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());
     prs->Display(1);
     TDataStd_Integer::Set(aResultLabel, Dlg.m_id);
     TDataStd_AsciiString::Set(aResultLabel,"vertex");

     //show
     Fit3DViews();
     myAISContext->UpdateCurrentViewer();
     D->CommitCommand();
}

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 Sioutis2009/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:

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;
}

Greetings

Fotis
Kaka Li2009/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 Sioutis2009/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.

Fotis
Kaka Li2009/06/30 04:34
u r a nice man, thank you very much
 
 
Latest news
  • Open CASCADE Technology: Ten Years in Open Source
  • Principia - AvPro Success Story
  • AREVA NP - Charm Success Story

  • © Open CASCADE 2000 - 2010  |  Search  |  Contacts