]> SALOME platform Git repositories - plugins/blsurfplugin.git/commitdiff
Salome HOME
NGE: Add Group management
authornge <nge>
Tue, 21 Jul 2009 13:13:56 +0000 (13:13 +0000)
committernge <nge>
Tue, 21 Jul 2009 13:13:56 +0000 (13:13 +0000)
src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx
src/PluginUtils/GeomSelectionTools.cxx
src/PluginUtils/GeomSelectionTools.h

index a6036a34ac015222790dd8b1884235f8a8ad4510..77b603bca0820eb6430f84e5cf3397aecdb17f8a 100644 (file)
@@ -464,6 +464,27 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu
         MESSAGE("blsurf_set_sizeMap(): " << smIt->first << " = " << smIt->second);
         GeomShape = entryToShape(smIt->first);
         GeomType  = GeomShape.ShapeType();
+        MESSAGE("Geomtype is " << GeomType);
+        // Group Management
+        if (GeomType == TopAbs_COMPOUND){
+          for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){
+            if (it.Value().ShapeType() == TopAbs_FACE){
+              HasSizeMapOnFace = true;
+              FaceId2SizeMap[TopoDS::Face(it.Value()).HashCode(471662)] = smIt->second;
+            }
+            if (it.Value().ShapeType() == TopAbs_EDGE){
+              HasSizeMapOnEdge = true;
+              HasSizeMapOnFace = true;
+              EdgeId2SizeMap[TopoDS::Edge(it.Value()).HashCode(471662)] = smIt->second;
+            }
+            if (it.Value().ShapeType() == TopAbs_VERTEX){
+              HasSizeMapOnVertex = true;
+              HasSizeMapOnEdge = true;
+              HasSizeMapOnFace = true;
+              VertexId2SizeMap[TopoDS::Vertex(it.Value()).HashCode(471662)] = smIt->second;
+            }
+          }
+        }
         if (GeomType == TopAbs_FACE){
           HasSizeMapOnFace = true;
           FaceId2SizeMap[TopoDS::Face(GeomShape).HashCode(471662)] = smIt->second;
index dfaf627bbf3a8ef9af50452d685f80e0f0435f16..4aafa29a48723e7adbb6109f09ff12d4e7ee6d89 100644 (file)
@@ -724,7 +724,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
       QString sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
       that->mySMPMap[fullSizeMapList[0]] = sizeMap;
       MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
-      that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShape(fullSizeMapList[0].toStdString()).ShapeType();
+      that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
       MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
     }
   }
@@ -739,7 +739,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
     QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
     if ( fullCustomSizeMapList.count() > 1 ) {
       that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
-      that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShape(fullCustomSizeMapList[0].toStdString()).ShapeType();
+      that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
       MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
       MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
     }
@@ -754,7 +754,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
     QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
     if ( myAttractorList.count() > 1 ) {
       that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
-      that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShape(myAttractorList[0].toStdString()).ShapeType();
+      that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
       MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
       MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
     }
@@ -1158,7 +1158,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS
 
   BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
 
-  TopoDS_Shape S;
+  TopAbs_ShapeEnum shapeType;
   string entry, shapeName;
   GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
 
@@ -1174,8 +1174,9 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS
       Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
       entry     = myGeomToolSelected->getEntryOfObject(anObject);
       shapeName = anObject->getName();
-      S         = myGeomToolSelected->entryToShape(entry);
-      if ((! S.IsNull()) && (S.ShapeType() == typeShapeAsked))
+      shapeType         = myGeomToolSelected->entryToShapeType(entry);
+      MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType);
+      if (shapeType == typeShapeAsked)
       {
         mySizeMapTable->setFocus();
         QString shapeEntry;
index ebe8694a2c653860d402529de37dee14567e4f09..18995826bd44f060135a861df9c261e8202cc318 100644 (file)
@@ -33,6 +33,7 @@
 #include <GEOM_Client.hxx>
 #include <SMESHGUI_Utils.h>
 #include <boost/shared_ptr.hpp>
+#include <GEOMImpl_Types.hxx>
 
 #include <TopoDS.hxx>
 #include <BRep_Tool.hxx>
@@ -195,23 +196,13 @@ std::string GeomSelectionTools::getFirstSelectedComponentDataType()
 }
 
 /*!
- *  Retrieve the TopoDS shape from the first selected object
- *  @return the TopoDS shape from the first selected object, empty TopoDS Shape if a shape is not selected.
+ * Retrieve the shape type from the entry
+ * @return the shape type from the entry, return TopAbs_SHAPE if the object does not define a shape or a group.
  */
-TopoDS_Shape GeomSelectionTools::getFirstSelectedTopoDSShape()
-{
- Handle(SALOME_InteractiveObject) anIO;
- anIO=GeomSelectionTools::getFirstSelectedSalomeObject();
- return entryToShape(anIO->getEntry());
-}
-
-/*!
- * Retrieve the TopoDS shape from the entry
- * @return the TopoDS shape from the entry, empty TopoDS Shape if the entry does not define a shape.
- */
-TopoDS_Shape GeomSelectionTools::entryToShape(std::string entry){
-  MESSAGE("GeomSelectionTools::entryToShape"<<entry );
+TopAbs_ShapeEnum GeomSelectionTools::entryToShapeType(std::string entry){
+  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;
@@ -224,42 +215,53 @@ TopoDS_Shape GeomSelectionTools::entryToShape(std::string entry){
     if (  strcmp(aSO->GetFatherComponent()->ComponentDataType().c_str(),"GEOM") == 0)
       aShape = SMESH::SObjectToInterface<GEOM::GEOM_Object>(aSO);
     if ( !aShape->_is_nil() ){
-      MESSAGE("Got a Shape as Geom Object ");
-
-     SalomeApp_Application* anApp = GetSalomeApplication();
-     if (anApp) {
-       MESSAGE("Got Application");
-       Engines::Component_var component = anApp->lcc()->FindOrLoad_Component( "FactoryServer","GEOM" );
-       GEOM::GEOM_Gen_var _geomEngine = GEOM::GEOM_Gen::_narrow(component);
-       MESSAGE("Got GEOM engine");
-       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 );
-       }
-     }
+      MESSAGE("Got the Geom Object ");
+      MESSAGE("Geom Object Type "<< aShape->GetType());
+      SalomeApp_Application* anApp = GetSalomeApplication();
+      if (anApp) {
+        MESSAGE("Got Application");
+        Engines::Component_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();
+          }
+        }
+      }
     }
   }
-  return S;
+  MESSAGE("ShapeType returned is " << ShapeType);
+  return ShapeType;
 }
 
 
+
 /*!
  * Gives the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape.
  * @return the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape.
  */
 TopAbs_ShapeEnum GeomSelectionTools:: getFirstSelectedShapeType()
 {
- TopoDS_Shape S=getFirstSelectedTopoDSShape();
- if (!S.IsNull())
-   return S.ShapeType();
- else
-   return TopAbs_SHAPE;
+ Handle(SALOME_InteractiveObject) anIO;
+ anIO=GeomSelectionTools::getFirstSelectedSalomeObject();
+ return entryToShapeType(anIO->getEntry());
 }
 
 /*!
- *  Print information to std output of the face (if the first selected object is a face)
+ *  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
+ *  @param TopoDS_Shape S Face we want information about.
  *  @return 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 :
@@ -269,9 +271,8 @@ TopAbs_ShapeEnum GeomSelectionTools:: getFirstSelectedShapeType()
  *  U or V is Rational ?
  *
  */
-GeomAbs_SurfaceType GeomSelectionTools::getFaceInformation()
+GeomAbs_SurfaceType GeomSelectionTools::getFaceInformation(TopoDS_Shape S)
 {
-  TopoDS_Shape S=getFirstSelectedTopoDSShape();
   GeomAbs_SurfaceType surf_type=GeomAbs_OtherSurface ;
   if (!S.IsNull() &&  S.ShapeType()==TopAbs_FACE){
     TopoDS_Face f=TopoDS::Face(S);
index 8abdf3c0b265b7505a86d6e3ebe1721413ef5b26..d7adf6a67f6a70b72bb1a9f27c0ecdae9fb69eb0 100644 (file)
@@ -59,12 +59,11 @@ public:
   std::string getEntryOfObject(Handle(SALOME_InteractiveObject));
   std::string getNameFromEntry(std::string);
   std::string getFirstSelectedComponentDataType();
-  TopoDS_Shape getFirstSelectedTopoDSShape();
   TopAbs_ShapeEnum getFirstSelectedShapeType();
-  TopoDS_Shape entryToShape(std::string );
-  GeomAbs_SurfaceType getFaceInformation();
+  TopAbs_ShapeEnum entryToShapeType(std::string );
+  GeomAbs_SurfaceType getFaceInformation(TopoDS_Shape);
   _PTR(Study) getMyStudy();
 };
 
 
-#endif // _GEOMSELECTIONTOOLS_H_
\ No newline at end of file
+#endif // _GEOMSELECTIONTOOLS_H_