-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// ---
try {
valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
if ( valueChanged ) {
- //boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$");
boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$");
if (!boost::regex_match(string(attractor), re))
throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False;d(opt.))");
//=============================================================================
+void BLSURFPlugin_Hypothesis_i::SetClassAttractorEntry(const char* entry, const char* att_entry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius) //TODO à finir
+ throw (SALOME::SALOME_Exception)
+{
+ ASSERT(myBaseImpl);
+ MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry);
+ bool valueChanged = false;
+ try {
+ this->GetImpl()->SetClassAttractorEntry(entry, att_entry, StartSize, EndSize, ActionRadius, ConstantRadius);
+ }
+ catch (const std::invalid_argument& ex) {
+ SALOME::ExceptionStruct ExDescription;
+ ExDescription.text = ex.what();
+ ExDescription.type = SALOME::BAD_PARAM;
+ ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetClassAttractorEntry(entry, att_entry, StartSize, EndSize, ActionRadius, ConstantRadius)";
+ ExDescription.lineNumber = 0;
+ throw SALOME::SALOME_Exception(ExDescription);
+ } catch (SALOME_Exception& ex) {
+ THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+ }
+ MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
+ //if ( valueChanged )
+ SMESH::TPythonDump() << _this() << ".SetAttractorGeom("
+ << entry << ", " << att_entry << ", "<<StartSize<<", "<<EndSize<<", "<<ActionRadius<<", "<<ConstantRadius<<" )";
+}
+
+//=============================================================================
+
char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception) {
ASSERT(myBaseImpl);
try {
return 0;
}
+// //=============================================================================
+//
+// // TODO coder cette fonction (utilisée pour savoir si la valeur a changé
+// // A finir pour le dump
+// char* BLSURFPlugin_Hypothesis_i::GetClassAttractorEntry(const char* entry)
+// throw (SALOME::SALOME_Exception)
+// {
+// ASSERT(myBaseImpl);
+// try {
+// return CORBA::string_dup( this->GetImpl()->GetClassAttractorEntry(entry).c_str());
+// }
+// catch (const std::invalid_argument& ex) {
+// SALOME::ExceptionStruct ExDescription;
+// ExDescription.text = ex.what();
+// ExDescription.type = SALOME::BAD_PARAM;
+// ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetClassAttractorEntry(name)";
+// ExDescription.lineNumber = 0;
+// throw SALOME::SALOME_Exception(ExDescription);
+// }
+// catch (SALOME_Exception& ex) {
+// THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+// }
+// return 0;
+// }
+
//=============================================================================
void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry) {
//=============================================================================
+BLSURFPlugin::TAttParamsMap* BLSURFPlugin_Hypothesis_i::GetAttractorParams()
+{
+ ASSERT(myBaseImpl);
+ BLSURFPlugin::TAttParamsMap_var result = new BLSURFPlugin::TAttParamsMap();
+
+ const ::BLSURFPlugin_Hypothesis::TAttractorMap attractors= this->GetImpl()->_GetClassAttractorEntries();
+ result->length( attractors.size() );
+
+ ::BLSURFPlugin_Hypothesis::TAttractorMap::const_iterator atIt = attractors.begin();
+ for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) {
+ string faceEntry = atIt->first;
+ string attEntry;
+ double startSize, endSize, infDist, constDist;
+ if ( !atIt->second->Empty() ) {
+ attEntry = atIt->second->GetAttractorEntry();
+ MESSAGE("GetAttractorParams : attEntry ="<<attEntry)
+ std::vector<double> params = atIt->second->GetParameters();
+ startSize = params[0];
+ endSize = params[1];
+ infDist = params[2];
+ constDist = params[3];
+ }
+ result[i].faceEntry = CORBA::string_dup(faceEntry.c_str());
+ result[i].attEntry = CORBA::string_dup(attEntry.c_str());
+ result[i].startSize = startSize;
+ result[i].endSize = endSize;
+ result[i].infDist = infDist;
+ result[i].constDist = constDist;
+ MESSAGE("GetAttractorParams : result[i].attEntry ="<<result[i].attEntry)
+ MESSAGE("GetAttractorParams : result[i].faceEntry ="<<result[i].faceEntry)
+ }
+ return result._retn();
+}
+
+//=============================================================================
+
void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
throw (SALOME::SALOME_Exception) {
ASSERT(myBaseImpl);
SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
}
+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 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( theFaceEntry.c_str(), theAttEntry.c_str(), StartSize, EndSize, ActionRadius, ConstantRadius);
+}
+
+void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr theFace)
+{
+ ASSERT(myBaseImpl);
+ 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() << " )";
+}
+
/*
void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
{}
ASSERT(myBaseImpl);
MESSAGE("IDL : UnsetEnforcedVertexEntry(" << theFaceEntry << "," << x << "," << y << "," << z << ", " << theVertexEntry << ")");
+ bool res = false;
try {
- this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z, theVertexEntry);
+ res = this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z, theVertexEntry);
if (string(theVertexEntry).empty())
- SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z
+ SMESH::TPythonDump() << "isDone = " << _this() << ".UnsetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z
<< ")";
else
- SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")";
+ SMESH::TPythonDump() << "isDone = " << _this() << ".UnsetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")";
} catch (const std::invalid_argument& ex) {
return false;
}
MESSAGE("ENGINE : UnsetEnforcedVertexEntry END ENTRY : " << theFaceEntry);
- return true;
+ return res;
}
//bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntryWithPoint(const char* theFaceEntry, const char* theVertexEntry,