From: eap Date: Tue, 5 Aug 2014 11:29:02 +0000 (+0400) Subject: 22625: [CEA 1195] Several attractors per face X-Git-Tag: V7_5_0a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fcd5b4c14d6cdffe92399d6e9f13de5b72c339b6;p=plugins%2Fblsurfplugin.git 22625: [CEA 1195] Several attractors per face 1) Use "minimal of all sizes" approach to size maps superposing 2) Fix removal of attractors --- diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 7cc9833..830cf4f 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -361,7 +361,8 @@ module BLSURFPlugin * 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 diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 559cb79..4989987 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -3305,15 +3305,15 @@ status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data) // 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 !!!") diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 4560042..2b55557 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -681,7 +681,8 @@ BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttracto //======================================================================= //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 ); @@ -699,8 +700,10 @@ void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& 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()) diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 6b2660b..0e10ac7 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -128,7 +128,7 @@ public: 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); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 088b838..f59e470 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -994,8 +994,8 @@ void BLSURFPlugin_Hypothesis_i::SetClassAttractorEntry(const char* entry, const } MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry); //if ( valueChanged ) - SMESH::TPythonDump() << _this() << ".SetAttractorGeom(" - << entry << ", " << att_entry << ", "<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) {} diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index cd573b4..7832e7f 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -168,8 +168,10 @@ public: 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(); @@ -294,7 +296,7 @@ public: 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) diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index ba14abb..662fa38 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -2342,12 +2342,16 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi 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 { @@ -2962,12 +2966,30 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() 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)) @@ -3226,11 +3248,28 @@ bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF // 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); @@ -3420,13 +3459,13 @@ CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry } 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 = "<