Version: 6.3.1
Public Member Functions | Static Public Member Functions | Private Member Functions

GeomSelectionTools Class Reference

The GeomSelectionTools class gives high level tools to select Geom (and other objects) A specific attention has been given to analyze selected GEOM objects. More...

#include <GeomSelectionTools.h>

Public Member Functions

 GeomSelectionTools (_PTR(Study))
 Constructor.
SALOME_ListIO * getSelectedSalomeObjects ()
 Return the list of the selected Salome Interactive Object (SALOME_ListIO*)
 Handle (SALOME_InteractiveObject) getFirstSelectedSalomeObject()
std::string getFirstSelectedEntry ()
 Return the entry of the first selected Object.
std::string getEntryOfObject (Handle(SALOME_InteractiveObject))
 Return the entry of a Salome Interactive Object.
std::string getNameFromEntry (std::string)
 Retrieve the name from the entry of the object.
std::string getFirstSelectedComponentDataType ()
 Retrieve the component type of the first selected object, it manages successfully references.
TopAbs_ShapeEnum getFirstSelectedShapeType ()
 Gives the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape.
TopAbs_ShapeEnum entryToShapeType (std::string)
 Retrieve the shape type from the entry.
GeomAbs_SurfaceType getFaceInformation (TopoDS_Shape)
 Print information to std output of the face and return the OCC type of face: Plane, Cylinder,Cone, Sphere, Torus, BezierSurface,BSplineSurface, SurfaceOfRevolution,SurfaceOfExtrusion, OtherSurface.
 _PTR (Study) getMyStudy()

Static Public Member Functions

static SalomeApp_Application * GetSalomeApplication ()
 Allows to get the Salome Application.
static LightApp_SelectionMgr * selectionMgr ()
 Allows to get the selection manager from LightApp.

Private Member Functions

 _PTR (Study) myStudy

Detailed Description

The GeomSelectionTools class gives high level tools to select Geom (and other objects) A specific attention has been given to analyze selected GEOM objects.

Parameters:
myStudyThis class is specific to the study !

Definition at line 57 of file GeomSelectionTools.h.


Constructor & Destructor Documentation

GeomSelectionTools::GeomSelectionTools ( _PTR(Study)  aStudy)

Constructor.

Parameters:
aStudypointer to the Study

Definition at line 52 of file GeomSelectionTools.cxx.

{
  myStudy = aStudy;
}

Member Function Documentation

GeomSelectionTools._PTR ( Study  ) [private]
GeomSelectionTools._PTR ( Study  )
TopAbs_ShapeEnum GeomSelectionTools::entryToShapeType ( std::string  entry)

Retrieve the shape type from the entry.

Returns:
the shape type from the entry, return TopAbs_SHAPE if the object does not define a shape or a group.

Definition at line 201 of file GeomSelectionTools.cxx.

References _PTR(), SMESH_fixation.aShape, and GetSalomeApplication().

Referenced by getFirstSelectedShapeType().

                                                                    {
//   MESSAGE("GeomSelectionTools::entryToShapeType"<<entry );
  TopoDS_Shape S = TopoDS_Shape();
  TopAbs_ShapeEnum ShapeType = TopAbs_SHAPE;
   _PTR(SObject) aSO = myStudy->FindObjectID(entry);
  if (aSO){
    _PTR(SObject) aRefSObj;
    GEOM::GEOM_Object_var aShape;
    // MESSAGE("Got a SO");
    // If selected object is a reference
    if ( aSO->ReferencedObject( aRefSObj ))
      aSO = aRefSObj;
    // MESSAGE("aSO->GetFatherComponent()->ComponentDataType(): " << aSO->GetFatherComponent()->ComponentDataType());
    if (  strcmp(aSO->GetFatherComponent()->ComponentDataType().c_str(),"GEOM") == 0)
      aShape = SMESH::SObjectToInterface<GEOM::GEOM_Object>(aSO);
    if ( !aShape->_is_nil() ){
      // MESSAGE("Got the Geom Object ");
      // MESSAGE("Geom Object Type "<< aShape->GetType());
      SalomeApp_Application* anApp = GetSalomeApplication();
      if (anApp) {
//         MESSAGE("Got Application");
        Engines::EngineComponent_var component = anApp->lcc()->FindOrLoad_Component( "FactoryServer","GEOM" );
        GEOM::GEOM_Gen_var _geomEngine = GEOM::GEOM_Gen::_narrow(component);
//         MESSAGE("Got GEOM engine");
        // if the Geom Object is a group
        if (aShape->GetType() == GEOM_GROUP){
//           MESSAGE("It's a group");
          GEOM::GEOM_IGroupOperations_var aGroupOp = _geomEngine->GetIGroupOperations(myStudy->StudyId());
          ShapeType= (TopAbs_ShapeEnum)aGroupOp->GetType(aShape);
        }
        // if not
        else {
          GEOM_Client* aClient = new GEOM_Client();
          if ( aClient && !_geomEngine->_is_nil() ) {
//             MESSAGE("GEOM client is OK and GEOM engine is not null");
            S = aClient->GetShape( _geomEngine, aShape );
            ShapeType=S.ShapeType();
          }
        }
      }
    }
  }
//   MESSAGE("ShapeType returned is " << ShapeType);
  return ShapeType;
}
std::string GeomSelectionTools::getEntryOfObject ( Handle(SALOME_InteractiveObject)  anIO)

Return the entry of a Salome Interactive Object.

Parameters:
anIOthe Handle of the Salome Interactive Object
Returns:
the entry of the Salome Interactive Object

Definition at line 139 of file GeomSelectionTools.cxx.

References _PTR().

Referenced by getFirstSelectedEntry().

                                                                                   {
  std::string entry="";
  _PTR(SObject) aSO = myStudy->FindObjectID(anIO->getEntry());
  if (aSO){
    _PTR(SObject) aRefSObj;
    // If selected object is a reference
    if ( aSO->ReferencedObject( aRefSObj ))
      entry = aRefSObj->GetID();
    // If selected object is a reference is not a reference
    else
      entry= anIO->getEntry();
  }
  return entry;
}
GeomAbs_SurfaceType GeomSelectionTools::getFaceInformation ( TopoDS_Shape  S)

Print information to std output of the face and return the OCC type of face: Plane, Cylinder,Cone, Sphere, Torus, BezierSurface,BSplineSurface, SurfaceOfRevolution,SurfaceOfExtrusion, OtherSurface.

Parameters:
TopoDS_ShapeS Face we want information about.
Returns:
the OCC type of face: Plane, Cylinder,Cone, Sphere, Torus, BezierSurface,BSplineSurface, SurfaceOfRevolution,SurfaceOfExtrusion, OtherSurface return Other_Surface if the selected face is not a face. Information printed is : U and V degrees U and V number of poles U and V number of knots U or V is Rational ?

Definition at line 271 of file GeomSelectionTools.cxx.

References Handle().

{
  GeomAbs_SurfaceType surf_type=GeomAbs_OtherSurface ;
  if (!S.IsNull() &&  S.ShapeType()==TopAbs_FACE){
    TopoDS_Face f=TopoDS::Face(S);
    Handle(Geom_Surface) surf = BRep_Tool::Surface(f);
    BRepAdaptor_Surface surf_adap(f);

    /* Global Information */
    std::cout << "GLOBAL INFORMATION" << std::endl;
    std::cout << "******************" << std::endl;
    std::stringstream buffer;
    buffer << "Degre U : " <<  surf_adap.UDegree();
   //conversion nécessaire pour affichage
    std::cout << buffer.str() << std::endl;
    std::cout <<  " Degre V : " <<  surf_adap.VDegree() << std::endl;
    std::cout <<  " Nb Poles U : " <<  surf_adap.NbUPoles() << std::endl;
    std::cout <<  " Nb Poles V : " <<  surf_adap.NbVPoles() << std::endl;
    std::cout <<  " Nb Noeuds U : " <<  surf_adap.NbUKnots() << std::endl;
    std::cout <<  " Nb Noeuds V : " <<  surf_adap.NbVKnots() << std::endl;
    std::cout <<  " U Rationnel ? " <<  surf_adap.IsURational() << std::endl;
    std::cout <<  " V Rationnel ? " <<  surf_adap.IsVRational() << std::endl;

    surf_type=surf_adap.GetType();
  }
  return surf_type;
}
std::string GeomSelectionTools::getFirstSelectedComponentDataType ( )

Retrieve the component type of the first selected object, it manages successfully references.

Returns:
the component type of the first selected object

Definition at line 179 of file GeomSelectionTools.cxx.

References _PTR(), and Handle().

{
  Handle(SALOME_InteractiveObject) anIO;
  std::string DataType="";
  anIO=GeomSelectionTools::getFirstSelectedSalomeObject();
  _PTR(SObject) aSO = myStudy->FindObjectID(anIO->getEntry());
  if (aSO){
    _PTR(SObject) aRefSObj;
    // If selected object is a reference
    if ( aSO->ReferencedObject( aRefSObj ))
      DataType= aRefSObj->GetFatherComponent()->ComponentDataType();
    // If selected object is a reference is not a reference
    else
      DataType=anIO->getComponentDataType();
 }
 return DataType;
}
std::string GeomSelectionTools::getFirstSelectedEntry ( )

Return the entry of the first selected Object.

Returns:
the entry of the first selected Object

Definition at line 126 of file GeomSelectionTools.cxx.

References getEntryOfObject(), and Handle().

{
  Handle(SALOME_InteractiveObject) anIO;
  std::string entry="";
  anIO=GeomSelectionTools::getFirstSelectedSalomeObject();
  return GeomSelectionTools::getEntryOfObject(anIO);
}
TopAbs_ShapeEnum GeomSelectionTools::getFirstSelectedShapeType ( )

Gives the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape.

Returns:
the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape.

Definition at line 251 of file GeomSelectionTools.cxx.

References entryToShapeType(), and Handle().

{
 Handle(SALOME_InteractiveObject) anIO;
 anIO=GeomSelectionTools::getFirstSelectedSalomeObject();
 return entryToShapeType(anIO->getEntry());
}
std::string GeomSelectionTools::getNameFromEntry ( std::string  entry)

Retrieve the name from the entry of the object.

Parameters:
entrythe entry of the object
Returns:
the name of the object

Definition at line 159 of file GeomSelectionTools.cxx.

References _PTR(), and ex21_lamp.name.

                                                             {
  std::string name = "";
  _PTR(SObject) aSO = myStudy->FindObjectID(entry);
  if (aSO){
    _PTR(SObject) aRefSObj;
    // If selected object is a reference
    if ( aSO->ReferencedObject( aRefSObj ))
      name = aRefSObj->GetName();
    // If selected object is a reference is not a reference
    else
      name = aSO->GetName();
   }
  return name;
}
SalomeApp_Application * GeomSelectionTools::GetSalomeApplication ( ) [static]

Allows to get the Salome Application.

Returns:
A LightApp_SelectionMgr Pointer or 0 if it can't get it.

Definition at line 70 of file GeomSelectionTools.cxx.

Referenced by entryToShapeType(), and selectionMgr().

{
  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
  if (anApp)
    return anApp;
  else
    return 0;
}
SALOME_ListIO * GeomSelectionTools::getSelectedSalomeObjects ( )

Return the list of the selected Salome Interactive Object (SALOME_ListIO*)

Returns:
the list of the selected Salome Interactive Object

Definition at line 96 of file GeomSelectionTools.cxx.

References selectionMgr().

{
  SALOME_ListIO* selected;
  LightApp_SelectionMgr* aSel = selectionMgr();
  aSel->selectedObjects( *selected, NULL, false );
  return selected;
}
GeomSelectionTools.Handle ( SALOME_InteractiveObject  )
LightApp_SelectionMgr * GeomSelectionTools::selectionMgr ( ) [static]

Allows to get the selection manager from LightApp.

Returns:
A LightApp_SelectionMgr Pointer or 0 if it can't get it.

Definition at line 83 of file GeomSelectionTools.cxx.

References GetSalomeApplication().

Referenced by getSelectedSalomeObjects().

{
   SalomeApp_Application* anApp = GetSalomeApplication();
   if (anApp)
     return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
   else
     return 0;
}
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS