* Set/unset an attractor given as geom object on another geom object
*/
void SetAttractorGeom(in GEOM::GEOM_Object GeomObj, in GEOM::GEOM_Object AttractorShape, in double StartSize, in double EndSize, in double ActionRadius, in double ConstantRadius);
- void UnsetAttractorGeom(in GEOM::GEOM_Object GeomObj);
+ void UnsetAttractorGeom(in GEOM::GEOM_Object GeomObj, in GEOM::GEOM_Object AttractorShape);
+ void UnsetAttractorEntry(in string entry, in string attractor);
/*!
* Set an attractor given by entry on a geom object given by entry
// MESSAGE("List of attractor is not empty")
// MESSAGE("Attractor empty : "<< FaceIndex2ClassAttractor[face_id]->Empty())
real result = 0;
- //result = 1e100;
+ result = 1e100;
std::vector< BLSURFPlugin_Attractor* > & attVec = f2attVec->second;
for ( size_t i = 0; i < attVec.size(); ++i )
{
- result += attVec[i]->GetSize(uv[0],uv[1]);
- //result = Min( result, attVec[i]->GetSize(uv[0],uv[1]));
+ //result += attVec[i]->GetSize(uv[0],uv[1]);
+ result = Min( result, attVec[i]->GetSize(uv[0],uv[1]));
}
- *size = result / attVec.size(); // mean of sizes defined by all attractors
- //*size = result;
+ //*size = result / attVec.size(); // mean of sizes defined by all attractors
+ *size = result;
}
else {
// MESSAGE("List of attractor is empty !!!")
//=======================================================================
//function : ClearEntry
//=======================================================================
-void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry)
+void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry,
+ const char * attEntry/*=0*/)
{
TSizeMap::iterator it = _sizeMap.find( entry );
TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
if ( it_clAt != _classAttractors.end() ) {
do {
- _classAttractors.erase(it_clAt);
- it_clAt = _classAttractors.find( entry );
+ if ( !attEntry || it_clAt->second->GetAttractorEntry() == attEntry )
+ _classAttractors.erase( it_clAt++ );
+ else
+ ++it_clAt;
}
while ( it_clAt != _classAttractors.end() );
MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
void SetVerbosity(int theVal);
int GetVerbosity() const { return _verb; }
- void ClearEntry(const std::string& entry);
+ void ClearEntry(const std::string& entry, const char * attEntry = 0);
void ClearSizeMaps();
void SetPreCADMergeEdges(bool theVal);
}
MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
//if ( valueChanged )
- SMESH::TPythonDump() << _this() << ".SetAttractorGeom("
- << entry << ", " << att_entry << ", "<<StartSize<<", "<<EndSize<<", "<<ActionRadius<<", "<<ConstantRadius<<" )";
+ SMESH::TPythonDump() << _this() << ".SetAttractorGeom( '"
+ << entry << "', '" << att_entry << "', "<<StartSize<<", "<<EndSize<<", "<<ActionRadius<<", "<<ConstantRadius<<" )";
}
//=============================================================================
SetClassAttractorEntry( theFaceEntry.c_str(), theAttEntry.c_str(), StartSize, EndSize, ActionRadius, ConstantRadius);
}
-void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr theFace)
+void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr theFace,
+ GEOM::GEOM_Object_ptr theAttractor)
{
ASSERT(myBaseImpl);
- string theFaceEntry;
- theFaceEntry = theFace->GetStudyEntry();
+ CORBA::String_var theFaceEntry = theFace->GetStudyEntry();
+ CORBA::String_var theAttrEntry = theAttractor->GetStudyEntry();
- GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
- SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
- string aName;
+ // 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_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
- if (!theSFace->_is_nil())
- theFaceEntry = theSFace->GetID();
- }
- if (theFaceEntry.empty())
+ // if (theFaceEntry.empty()) {
+ // aName = "Face_";
+ // aName += theFace->GetEntry();
+ // SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
+ // if (!theSFace->_is_nil())
+ // theFaceEntry = theSFace->GetID();
+ // }
+ if ( !theFaceEntry.in() || !theFaceEntry[0] ||
+ !theAttrEntry.in() || !theAttrEntry[0] )
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() << " )";
+ GetImpl()->ClearEntry( theFaceEntry.in(), theAttrEntry.in() );
+ SMESH::TPythonDump() << _this() << ".UnsetAttractorGeom( "
+ << theFace << ", " << theAttractor << " )";
}
+void BLSURFPlugin_Hypothesis_i::UnsetAttractorEntry(const char* faceEntry,
+ const char* attractorEntry)
+{
+ GetImpl()->ClearEntry( faceEntry, attractorEntry );
+ SMESH::TPythonDump() << _this() << ".UnsetAttractorEntry( '"
+ << faceEntry << "', '" << attractorEntry << "' )";
+}
+
+
/*
void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
{}
void SetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj, GEOM::GEOM_Object_ptr Attractor, CORBA::Double StartSize, CORBA::Double EndSize, CORBA::Double ActionRadius, CORBA::Double ConstantRadius );
- void UnsetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj);
+ void UnsetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj,
+ GEOM::GEOM_Object_ptr theAttractor);
+ void UnsetAttractorEntry(const char* entry, const char* attractor);
void SetClassAttractorEntry(const char* entry, const char* att_entry, CORBA::Double StartSize, CORBA::Double EndSize, CORBA::Double ActionRadius, CORBA::Double ConstantRadius) throw (SALOME::SALOME_Exception);
BLSURFPlugin::TAttParamsMap* GetAttractorParams();
throw (SALOME::SALOME_Exception);
void AddEdgePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theEdge1,
- GEOM::GEOM_Object_ptr theFace2, GEOM::GEOM_Object_ptr theEdge2, CORBA::Long edge_orientation = 0)
+ GEOM::GEOM_Object_ptr theFace2, GEOM::GEOM_Object_ptr theEdge2, CORBA::Long edge_orientation = 0)
throw (SALOME::SALOME_Exception);
void AddEdgePeriodicityWithoutFaces(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2, CORBA::Long edge_orientation = 0)
const TAttractorVec& attVec = myATTMap[entry];
for ( size_t i = 0; i < attVec.size(); ++i )
{
- h->SetClassAttractorEntry( entry.toLatin1().constData(),
- attVec[i].attEntry.c_str(),
- attVec[i].startSize,
- h->GetPhySize(),
- attVec[i].infDist,
- attVec[i].constDist );
+ if ( attVec[i].IsToDelete() )
+ h->UnsetAttractorEntry( entry.toLatin1().constData(),
+ attVec[i].attEntry.c_str() );
+ else
+ h->SetClassAttractorEntry( entry.toLatin1().constData(),
+ attVec[i].attEntry.c_str(),
+ attVec[i].startSize,
+ h->GetPhySize(),
+ attVec[i].infDist,
+ attVec[i].constDist );
}
}
else {
while ( it.hasPrevious() ) {
item = it.previous();
QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
+ QString parentEntry;
+ if ( QTreeWidgetItem* parent = item->parent() )
+ parentEntry = parent->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
if (that->mySMPMap.contains(entry))
+ {
that->mySMPMap[entry] = "__TO_DELETE__";
+ if ( myATTMap.contains( entry ))
+ {
+ TAttractorVec& attVec = myATTMap[entry];
+ for ( size_t i = 0; i < attVec.size(); ++i )
+ attVec[i].SetToDelete();
+ }
+ }
+ else if ( mySMPMap.contains( parentEntry ) && myATTMap.contains( parentEntry ))
+ {
+ TAttractorVec& attVec = myATTMap[parentEntry];
+ for ( size_t i = 0; i < attVec.size(); ++i )
+ {
+ if ( entry == attVec[i].attEntry.c_str() )
+ attVec[i].SetToDelete();
+ }
+ }
if (that->mySMPShapeTypeMap.contains(entry))
that->mySMPShapeTypeMap.remove(entry);
- if (that->myATTMap.contains(entry))
- that->myATTMap.remove(entry);
// if (that->myDistMap.contains(entry))
// that->myDistMap.remove(entry);
// if (that->myAttDistMap.contains(entry))
// return false;
// }
// }
- item = new QTreeWidgetItem();
+ int rowToChange = findRowFromEntry(shapeEntry);
+ if ( rowToChange < mySizeMapTable->topLevelItemCount() )
+ {
+ item = mySizeMapTable->topLevelItem( rowToChange );
+ }
+ else {
+ item = new QTreeWidgetItem();
+ mySizeMapTable->addTopLevelItem(item);
+ }
child = new QTreeWidgetItem();
- mySizeMapTable->addTopLevelItem(item);
item->addChild(child);
- myATTMap[shapeEntry].push_back( attParams );
+ bool exists = false;
+ TAttractorVec & attVec = myATTMap[shapeEntry];
+ for ( size_t i = 0; i < attVec.size(); ++i )
+ if ( attVec[i].attEntry == attEntry )
+ {
+ attVec[i] = attParams;
+ exists = true;
+ break;
+ }
+ if ( !exists )
+ myATTMap[shapeEntry].push_back( attParams );
}
mySMPMap.insert(shapeEntry,sizeMap);
mySMPShapeTypeMap.insert(shapeEntry,shapeType);
}
int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
- QString entryForChecking;
int endRow = mySizeMapTable->topLevelItemCount()-1;
int row = 0;
- entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
- while (entry != entryForChecking && row <= endRow){
- row++;
- entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
+ for ( ; row <= endRow; ++row )
+ {
+ QString entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
+ if (entry == entryForChecking )
+ break;
}
MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)
return row;
infDist( theInfDist ),
constDist( theConstDist )
{}
+ void SetToDelete() { startSize = -1; }
+ bool IsToDelete() const { return startSize < 0; }
};
typedef std::vector< TAttractor > TAttractorVec;