Salome HOME
rnc: Small modification to ensure that objects used in setClassAttractorGeom have... BR_Dev_For_6_3_1 V6_3_0 V6_3_0b2 V6_3_0rc1
authorgdd <gdd>
Fri, 13 May 2011 13:05:13 +0000 (13:05 +0000)
committergdd <gdd>
Fri, 13 May 2011 13:05:13 +0000 (13:05 +0000)
Useful if the method is called on a parameter object. In such a case the IDL method is called directly and not trough th python method.

src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx

index c62fdfabbba3fe58c183955de09d301d99c623ab..2d4885a9dcb9a0d724bf4aeff9d107517cdfb331 100644 (file)
@@ -762,29 +762,76 @@ void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj) {
   SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
 }
 
-void BLSURFPlugin_Hypothesis_i::SetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj, GEOM::GEOM_Object_ptr Attractor, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
+void BLSURFPlugin_Hypothesis_i::SetAttractorGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theAttractor, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
 {
   ASSERT(myBaseImpl);
-  string entry;
-  string att_entry;
-  entry=GeomObj->GetStudyEntry();
-  att_entry=Attractor->GetStudyEntry();
-  TopoDS_Face FaceShape = TopoDS::Face(SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( GeomObj ));
-  TopoDS_Shape AttractorShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( Attractor );
-  MESSAGE("IDL : GetName : " << GeomObj->GetName());
+  string theFaceEntry;
+  string theAttEntry;
+  theFaceEntry = theFace->GetStudyEntry();
+  theAttEntry  = theAttractor->GetStudyEntry();
+  
+  GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+  SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+  string aName;
+  
+  if (theFaceEntry.empty()) {
+    aName = "Face_";
+    aName += theFace->GetEntry();
+    SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
+    if (!theSFace->_is_nil())
+      theFaceEntry = theSFace->GetID();
+  }
+  if (theFaceEntry.empty())
+    THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+  
+  if (theAttEntry.empty()) {
+    if (theAttractor->GetShapeType() == GEOM::VERTEX)
+      aName = "Vertex_";
+    if (theAttractor->GetShapeType() == GEOM::EDGE)
+      aName = "Edge_";
+    if (theAttractor->GetShapeType() == GEOM::WIRE)
+      aName = "Wire_";
+    if (theAttractor->GetShapeType() == GEOM::COMPOUND)
+      aName = "Compound_";
+    aName += theAttractor->GetEntry();
+    SALOMEDS::SObject_ptr theSAtt = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theAttractor, aName.c_str());
+    if (!theSAtt->_is_nil())
+      theAttEntry = theSAtt->GetID();
+  }
+  if (theAttEntry.empty())
+    THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+  
+  TopoDS_Face FaceShape = TopoDS::Face(SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theFace ));
+  TopoDS_Shape AttractorShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theAttractor );
+  MESSAGE("IDL : GetName : " << theFace->GetName());
   MESSAGE("IDL : SETATTRACTOR () ");//<< entry << " , " << att_entry << ")");
-  SetClassAttractorEntry( entry.c_str(), att_entry.c_str(), StartSize, EndSize, ActionRadius, ConstantRadius);
+  SetClassAttractorEntry( theFaceEntry.c_str(), theAttEntry.c_str(), StartSize, EndSize, ActionRadius, ConstantRadius);
 }
 
-void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj)
+void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr theFace)
 {
   ASSERT(myBaseImpl);
-  string entry;
-  entry = GeomObj->GetStudyEntry();
-  MESSAGE("IDL : GetName : " << GeomObj->GetName());
-  MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")");
-  UnsetEntry( entry.c_str());
-  SMESH::TPythonDump() << _this() << ".UnsetAttractorGeom( " << entry.c_str() << " )";
+  string theFaceEntry;
+  theFaceEntry = theFace->GetStudyEntry();
+  
+  GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+  SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+  string aName;
+  
+  if (theFaceEntry.empty()) {
+    aName = "Face_";
+    aName += theFace->GetEntry();
+    SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
+    if (!theSFace->_is_nil())
+      theFaceEntry = theSFace->GetID();
+  }
+  if (theFaceEntry.empty())
+    THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+  
+  MESSAGE("IDL : GetName : " << theFace->GetName());
+  MESSAGE("IDL : UNSETATTRACTOR ( "<< theFaceEntry << ")");
+  UnsetEntry( theFaceEntry.c_str());
+  SMESH::TPythonDump() << _this() << ".UnsetAttractorGeom( " << theFaceEntry.c_str() << " )";
 }
 
 /*