From dc72655700b558b8f4e5114ec2bccc5624cf2a7d Mon Sep 17 00:00:00 2001 From: gdd Date: Thu, 17 Feb 2011 15:19:35 +0000 Subject: [PATCH] Update GUI Several debug There are still some issues about the groups and the dump --- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 11 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 236 +----------------- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 19 -- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 130 +++++----- src/GUI/BLSURFPluginGUI_HypothesisCreator.h | 37 +-- 5 files changed, 88 insertions(+), 345 deletions(-) diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index c407b30..eb6e9a7 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -1320,6 +1320,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) // Create group of enforced vertices if requested if(_hypothesis) { BLSURFPlugin_Hypothesis::TEnfVertexCoords projVertex; + projVertex.clear(); projVertex.push_back((double)xyz[0]); projVertex.push_back((double)xyz[1]); projVertex.push_back((double)xyz[2]); @@ -1342,12 +1343,17 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) bool groupDone = false; const set& allGroups = meshDS->GetGroups(); set::const_iterator grIt; + MESSAGE("currentEnfVertex->grpName: " << currentEnfVertex->grpName); MESSAGE("Parsing the groups of the mesh"); for ( grIt = allGroups.begin(); grIt != allGroups.end(); ++grIt ) { SMESHDS_Group* group = dynamic_cast( *grIt ); - if (group) + if (group) { MESSAGE("Group: " << group->GetStoreName()); - if ( group && group->SMDSGroup().GetType()==SMDSAbs_Node + MESSAGE("group->SMDSGroup().GetType(): " << (group->SMDSGroup().GetType())); + MESSAGE("group->SMDSGroup().GetType()==SMDSAbs_Node: " << (group->SMDSGroup().GetType()==SMDSAbs_Node)); + MESSAGE("currentEnfVertex->grpName.compare(group->GetStoreName())==0: " << (currentEnfVertex->grpName.compare(group->GetStoreName())==0)); + } + if ( group && (group->SMDSGroup().GetType()==SMDSAbs_Node || group->SMDSGroup().GetType()==SMDSAbs_All) && currentEnfVertex->grpName.compare(group->GetStoreName())==0) { group->SMDSGroup().Add(nodes[iv]); // int id = // recuperer l'id SMESH du noeud @@ -1364,6 +1370,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) if ( aGroup ) { SMESHDS_Group* aGroupDS = dynamic_cast( aGroup->GetGroupDS() ); if ( aGroupDS ) { + aGroupDS->SetType( SMDSAbs_Node ); aGroupDS->SetStoreName( currentEnfVertex->grpName.c_str() ); aGroupDS->SMDSGroup().Add(nodes[iv]); MESSAGE("Successfully created enforced vertex group " << currentEnfVertex->grpName); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index b014d82..baeca85 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -444,81 +444,7 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName th } } } - - -// TEnfVertexList::iterator it = _enfVertexList.begin(); -// for ( ; it != _enfVertexList.end() ; ++it) { -// if (TEnfVertexCmp(&(*it),&newEnfVertex)) { -// // Found enf vertex -// TEntryList::const_iterator it_entry = it->faceEntries.begin(); -// for (;it_entryfaceEntries.end();++it_entry) { -// std::string currentFaceEntry = (*it_entry); -// -// if (_faceEntryCoordsListMap.count(currentFaceEntry)) -// _faceEntryCoordsListMap[currentFaceEntry].erase(it->coords); -// -// if (_faceEntryEnfVertexEntryListMap.count(currentFaceEntry)) -// _faceEntryEnfVertexEntryListMap[currentFaceEntry].erase(it->geomEntry); -// -// if (_faceEntryEnfVertexListMap.count(currentFaceEntry)) { -// TEnfVertexList newEnfVertexList; -// TEnfVertexList::const_iterator it_enfVertexList = _faceEntryEnfVertexListMap[currentFaceEntry].begin(); -// for (;it_enfVertexList != _faceEntryEnfVertexListMap[currentFaceEntry].end(); ++it_enfVertexList) { -// if (!TEnfVertexCmp(&(*it),&(*it_enfVertexList))) -// newEnfVertexList.insert(*it_enfVertexList); -// } -// _faceEntryEnfVertexListMap.erase(currentFaceEntry); -// _faceEntryEnfVertexListMap[currentFaceEntry] = newEnfVertexList; -// } -// } -// _coordsEnfVertexMap.erase(it->coords); -// _enfVertexEntryEnfVertexMap.erase(it->geomEntry); -// _enfVertexList.erase(it); -// // toCreate = false; -// // oldEnVertex = (*it); -// // break; -// } -// } - -// //////// UPDATE //////////// -// if (!toCreate) { -// // Update list of face entries -// -// TEntryList::const_iterator it_faceEntries = oldEnVertex.faceEntries.begin(); -// for (;it_faceEntries!=oldEnVertex.faceEntries.end();++it_faceEntries) -// newEnfVertex.faceEntries.insert(*it_faceEntries); -// // _faceEntries.insert(theFaceEntry); -// // (*it).faceEntries.insert(theFaceEntry); -// if (oldEnVertex.faceEntries.find(theFaceEntry) == oldEnVertex.faceEntries.end()) { -// MESSAGE("Update enf vertex faceEntries by adding " << theFaceEntry); -// _faceEntryEnfVertexListMap[theFaceEntry].insert((*it)); -// toNotify = true; -// } -// -// -// if ((*it).name != newEnfVertex.name) { -// MESSAGE("Update enf vertex name from \"" << (*it).name << "\" to \"" << newEnfVertex.name << "\""); -// (*it).name = newEnfVertex.name; -// toNotify = true; -// } -// -// if ((*it).grpName != newEnfVertex.grpName) { -// MESSAGE("Update enf vertex group name from \"" << (*it).grpName << "\" to \"" << newEnfVertex.grpName << "\""); -// (*it).grpName = newEnfVertex.grpName; -// toNotify = true; -// } -// -// if (toNotify) { -// // update map coords / enf vertex if needed -// if ((*it).coords.size()) -// _coordsEnfVertexMap[(*it).coords] = (*it); -// -// // update map geom entry / enf vertex if needed -// if ((*it).geomEntry != "") -// _enfVertexEntryEnfVertexMap[(*it).geomEntry] = (*it); -// } -// } -// + // //////// CREATE //////////// if (toCreate) { toNotify = true; @@ -541,129 +467,7 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName th MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END"); return toNotify; } - -// TEnfVertex oldEnfVertex; -// // If "manual" enf vertex (theVertexEntry="") maybe an existing enf vertex needs to be update with new name or new group name -// TCoordsEnfVertexMap::iterator it_CoordsEnfVertex = _coordsEnfVertexMap.find(newEnfVertex.coords); -// if (it_CoordsEnfVertex != _coordsEnfVertexMap.end()) { -// toCreate = false; -// if ((it_CoordsEnfVertex->second.name != theVertexName) || (it_CoordsEnfVertex->second.grpName != theGroupName)) { -// oldEnfVertex = it_CoordsEnfVertex->second; -// MESSAGE("Update enf vertex name from " << oldEnfVertex.name << " to " << newEnfVertex.name); -// MESSAGE("Update enf vertex group name from " << oldEnfVertex.grpName << " to " << newEnfVertex.grpName); -// -// // update _faceEntryEnfVertexListMap -// TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; -// for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { -// if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { -// currentEnfVertexList.erase(it); -// currentEnfVertexList.insert(newEnfVertex); -// break; -// } -// } -// -// // update _enfVertexList -// for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { -// -// if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { -// -// _enfVertexList.erase(it); -// _enfVertexList.insert(newEnfVertex); -// break; -// } -// } -// -// // update _coordsEnfVertexMap -// _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex; -// -// toNotify = true; -// } -// if (it_CoordsEnfVertex->second.grpName != theGroupName) { -// MESSAGE("Update enf vertex group name from " << it_CoordsEnfVertex->second.grpName << " to " << theGroupName); -// oldEnfVertex = it_CoordsEnfVertex->second; -// -// // update _faceEntryEnfVertexListMap -// TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; -// for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { -// if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { -// currentEnfVertexList.erase(it); -// currentEnfVertexList.insert(newEnfVertex); -// break; -// } -// } -// -// // update _enfVertexList -// for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { -// if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { -// _enfVertexList.erase(it); -// _enfVertexList.insert(newEnfVertex); -// break; -// } -// } -// -// // update _coordsEnfVertexMap -// _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex; -// toNotify = true; -// } -// } -// -// // If "selected" enf vertex (theVertexEntry!="") maybe an existing enf vertex needs to be update with new group name -// TEnfVertexEntryEnfVertexMap::iterator it_EnfEntryEnfVertex = _enfVertexEntryEnfVertexMap.find(theVertexEntry); -// if (it_EnfEntryEnfVertex != _enfVertexEntryEnfVertexMap.end()) { -// toCreate = false; -// if (it_EnfEntryEnfVertex->second.grpName != theGroupName) { -// oldEnfVertex = it_EnfEntryEnfVertex->second; -// MESSAGE("Update enf vertex group name from " << oldEnfVertex.grpName << " to " << newEnfVertex.grpName); -// -// // update _faceEntryEnfVertexListMap -// TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; -// for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { -// if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { -// currentEnfVertexList.erase(it); -// currentEnfVertexList.insert(newEnfVertex); -// break; -// } -// } -// -// // update _enfVertexList -// for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { -// if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { -// _enfVertexList.erase(it); -// _enfVertexList.insert(newEnfVertex); -// break; -// } -// } -// -// _enfVertexEntryEnfVertexMap[theVertexEntry] = newEnfVertex; -// -// toNotify = true; -// } -// } -// //////// CREATE //////////// -// if (toCreate) { -// MESSAGE("Creating new enforced vertex"); -// std::pair res = _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex); -// toNotify = res.second; -// -// if (toNotify) { -// _enfVertexList.insert(newEnfVertex); -// if (theVertexEntry == "") { -// _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex.coords); -// _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex; -// } else { -// _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex.geomEntry); -// _enfVertexEntryEnfVertexMap[newEnfVertex.geomEntry] = newEnfVertex; -// } -// } -// } -// -// if (toNotify) -// NotifySubMeshesHypothesisModification(); -// -// MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END"); -// return toNotify; -// } //======================================================================= //function : GetEnforcedVertices @@ -674,6 +478,8 @@ BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexLis if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0) return _faceEntryEnfVertexListMap[theFaceEntry]; + else + return GetDefaultEnfVertexList(); std::ostringstream msg; msg << "No enforced vertex for face entry " << theFaceEntry; @@ -817,29 +623,11 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do } MESSAGE("Done"); } - -// for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { -// if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { -// (*it).faceEntries.erase(theFaceEntry); -// if ((*it).faceEntries.size() == 0){ -// _enfVertexList.erase(it); -// toNotify = true; -// } -// MESSAGE("Done"); -// break; -// } -// } // update _faceEntryEnfVertexListMap TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; currentEnfVertexList.erase(oldEnfVertex); -// for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { -// if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { -// currentEnfVertexList.erase(it); -// toNotify = true; -// break; -// } -// } + if (currentEnfVertexList.size() == 0) { MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]"); _faceEntryEnfVertexListMap.erase(theFaceEntry); @@ -880,14 +668,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) } MESSAGE("Done"); } -// for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { -// if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { -// (*it).faceEntries.erase(theFaceEntry); -// if ((*it).faceEntries.size() == 0) -// _enfVertexList.erase(it); -// break; -// } -// } } _faceEntryCoordsListMap.erase(it_entry_coords); _faceEntryEnfVertexListMap.erase(theFaceEntry); @@ -912,14 +692,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) } MESSAGE("Done"); } -// for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { -// if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { -// (*it).faceEntries.erase(theFaceEntry); -// if ((*it).faceEntries.size() == 0) -// _enfVertexList.erase(it); -// break; -// } -// } } _faceEntryEnfVertexEntryListMap.erase(it_entry_entry); _faceEntryEnfVertexListMap.erase(theFaceEntry); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 15d7176..0ccbfa2 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -169,19 +169,6 @@ public: } }; - // if coords or geom entry are identical => same enforced vertex - int TEnfVertexCmp(const TEnfVertex *e1, const TEnfVertex *e2) { - if (e1 && e2) { - bool sameCoords = true; - if (e1->coords.size() && e2->coords.size()) - sameCoords = (e1->coords[0] == e2->coords[0]) && (e1->coords[1] == e2->coords[1]) && (e1->coords[2] - == e2->coords[2]); - return ( sameCoords && (e1->geomEntry == e2->geomEntry));// && (e1->grpName == e2->grpName) -// && (e1->name == e2->name)); - } - return false; - } - // List of enforced vertices typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList; @@ -217,8 +204,6 @@ public: TEnfVertex* GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument); bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument); -// bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0) throw (std::invalid_argument); -// bool ClearEnforcedVertex(const TEntry& theFaceEntry, const TEntry& theVertexEntry) throw (std::invalid_argument); bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument); void ClearAllEnforcedVertices(); @@ -315,10 +300,6 @@ public: */ virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); -/* TODO GROUPS -private: - bool _setEnfVertexWithGroup(double x, double y, double z, const std::string groupName) throw (std::invalid_argument); -*/ private: Topology _topology; diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 797c88e..cb0f1a4 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -832,7 +832,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() myEnforcedTreeWidget->resizeColumnToContents(column); } myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN); - myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN); +// myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN); myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate()); // FACE AND VERTEX SELECTION @@ -1423,17 +1423,17 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const // } TEnfVertexList::const_iterator evsIt = evs.begin(); - TEnfVertex enfVertex; + TEnfVertex *enfVertex; for ( ; evsIt != evs.end() ; ++evsIt) { enfVertex = (*evsIt); - MESSAGE("Name: " << enfVertex.name); + MESSAGE("Name: " << enfVertex->name); double x, y, z = 0; - if (enfVertex.coords.size()) { - x = enfVertex.coords[0]; - y = enfVertex.coords[1]; - z = enfVertex.coords[2]; + if (enfVertex->coords.size()) { + x = enfVertex->coords[0]; + y = enfVertex->coords[1]; + z = enfVertex->coords[2]; } - that->addEnforcedVertex(entry, shapeName, x, y, z, enfVertex.name, enfVertex.geomEntry, enfVertex.grpName); + that->addEnforcedVertex(entry, shapeName, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName); } } @@ -1578,18 +1578,18 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList; // BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str()); - TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry]; +// TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry]; for (int j=0 ; jname = CORBA::string_dup(vertexList[j].name.in()); + enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in()); + enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in()); for (int k=0 ; k< vertexList[j].coords.length();k++) - enfVertex.coords.push_back(vertexList[j].coords[k]); + enfVertex->coords.push_back(vertexList[j].coords[k]); - enfVertexList.insert(enfVertex); + h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex); /* TODO GROUPS if (groupName != "") { @@ -1600,7 +1600,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData // h_data.enfVertMap[entry] = evs; // h_data.entryCoordsListMap[entry] = coordsList; - if (enfVertexList.size() == 0) { + if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) { h_data.faceEntryEnfVertexListMap.erase(entry); } } @@ -1608,18 +1608,6 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData return true; } -bool TEnfVertexGUICmp(const TEnfVertex *e1, const TEnfVertex *e2) { - if (e1 && e2) { - bool sameCoords = true; - if (e1->coords.size() && e2->coords.size()) - sameCoords = (e1->coords[0] == e2->coords[0]) && (e1->coords[1] == e2->coords[1]) && (e1->coords[2] - == e2->coords[2]); - return ( sameCoords && (e1->geomEntry == e2->geomEntry) && (e1->grpName == e2->grpName) - && (e1->name == e2->name)); - } else - return (e1 < e2); -} - /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data) Saves the hypothesis data to hypothesis values. */ @@ -1747,8 +1735,8 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi TEnfVertexList::const_iterator evsIt, enfVertexToRemove; for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt) { faceEntry = evmIt->first; - MESSAGE("Enforced vertices for face entry " << faceEntry); evs = evmIt->second; + MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size()); evsIt = evs.begin(); hypEnfVertexList = h->GetEnforcedVerticesEntry(faceEntry.c_str()); @@ -1756,53 +1744,57 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi MESSAGE("Number of enforced vertices from hypothesis: " << hypNbVertex); enfVertexFromHyp.clear(); for (int i =0 ; iname = CORBA::string_dup(hypEnfVertexList[i].name.in()); + _enfVertex->geomEntry = CORBA::string_dup(hypEnfVertexList[i].geomEntry.in()); + _enfVertex->grpName = CORBA::string_dup(hypEnfVertexList[i].grpName.in()); for (int j=0 ; j< hypEnfVertexList[i].coords.length() ; j++) - _enfVertex.coords.push_back(hypEnfVertexList[i].coords[j]); - _enfVertex.grpName = hypEnfVertexList[i].grpName.in(); + _enfVertex->coords.push_back(hypEnfVertexList[i].coords[j]); enfVertexFromHyp.insert(_enfVertex); - MESSAGE("From hyp: enf vertex " << _enfVertex.name); + MESSAGE("From hyp: enf vertex " << _enfVertex->name); // MESSAGE("From hyp: enf. vertex at " << _coords[0]<<", "<<_coords[1]<<", "<<_coords[2]); } - TEnfVertex enfVertex; +// TEnfVertex *enfVertex; for ( ; evsIt != evs.end() ; ++evsIt) { - enfVertex = (*evsIt); - if (enfVertex.coords.size()) { - x = enfVertex.coords[0]; - y = enfVertex.coords[1]; - z = enfVertex.coords[2]; + x =y =z = 0; +// enfVertex = (*evsIt); + if ((*evsIt)->coords.size()) { + x = (*evsIt)->coords[0]; + y = (*evsIt)->coords[1]; + z = (*evsIt)->coords[2]; } - ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, enfVertex.name.c_str(), enfVertex.geomEntry.c_str(), enfVertex.grpName.c_str()); + ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str()); + enfVertexFromHyp.erase((*evsIt)); - for (enfVertexToRemove = enfVertexFromHyp.begin() ; enfVertexToRemove != enfVertexFromHyp.end() ; ++enfVertexToRemove) { - if (!TEnfVertexGUICmp(&enfVertex, &(*enfVertexToRemove))) { - MESSAGE("Enf vertex " << enfVertex.name << " must not be deleted") - enfVertexFromHyp.erase(enfVertexToRemove); - } - } +// for (enfVertexToRemove = enfVertexFromHyp.begin() ; enfVertexToRemove != enfVertexFromHyp.end() ; ++enfVertexToRemove) { +// if (!TEnfVertexGUICmp(&enfVertex, &(*enfVertexToRemove))) { +// MESSAGE("Enf vertex " << enfVertex.name << " must not be deleted") +// enfVertexFromHyp.erase(enfVertexToRemove); +// } +// } } // Remove old vertices enfVertexToRemove = enfVertexFromHyp.begin(); for ( ; enfVertexToRemove!=enfVertexFromHyp.end() ; ++enfVertexToRemove) { - enfVertex = (*enfVertexToRemove); +// enfVertex = (*enfVertexToRemove); + if (h_data.enfVertexList.find((*enfVertexToRemove)) != h_data.enfVertexList.end()) { - for ( evsIt=h_data.enfVertexList.begin();evsIt!=h_data.enfVertexList.end();evsIt++) { - if (TEnfVertexGUICmp(&(*evsIt),&enfVertex)) { - MESSAGE("Remove enf vertex " << enfVertex.name); - if (enfVertex.coords.size()) { - x = enfVertex.coords[0]; - y = enfVertex.coords[1]; - z = enfVertex.coords[2]; +// for ( evsIt=h_data.enfVertexList.begin();evsIt!=h_data.enfVertexList.end();evsIt++) { +// if (TEnfVertexGUICmp(&(*evsIt),&enfVertex)) { + MESSAGE("Remove enf vertex " << (*enfVertexToRemove)->name); + if ((*enfVertexToRemove)->coords.size()) { + x = (*enfVertexToRemove)->coords[0]; + y = (*enfVertexToRemove)->coords[1]; + z = (*enfVertexToRemove)->coords[2]; } - ret = h->UnsetEnforcedVertexEntry(faceEntry.c_str(), x, y, z, enfVertex.geomEntry.c_str()); + ret = h->UnsetEnforcedVertexEntry(faceEntry.c_str(), x, y, z, (*enfVertexToRemove)->geomEntry.c_str()); if (ret) MESSAGE("SUCCESS"); - } // if - } // for +// } // if +// } // for + } // if } // for } // for } // else @@ -1904,6 +1896,7 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes std::string childName, vertexEntry; QTreeWidgetItem* child; TEnfVertexList evs; + evs.clear(); for (row = 0;rowchild(row); childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString(); @@ -1916,17 +1909,20 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes else groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString(); - TEnfVertex enfVertex; - enfVertex.name = childName; - enfVertex.geomEntry = vertexEntry; + TEnfVertex *enfVertex = new TEnfVertex(); + enfVertex->name = childName; if (vertexEntry == "") { - enfVertex.coords.push_back(childValueX); - enfVertex.coords.push_back(childValueY); - enfVertex.coords.push_back(childValueZ); + enfVertex->coords.push_back(childValueX); + enfVertex->coords.push_back(childValueY); + enfVertex->coords.push_back(childValueZ); } - enfVertex.grpName = groupName; - + else + enfVertex->geomEntry = vertexEntry; + enfVertex->grpName = groupName; +// TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex); +// if (it == h_data.enfVertexList.end()) h_data.enfVertexList.insert(enfVertex); + evs.insert(enfVertex); /* TODO GROUPS if (groupName != "") h_data.groupNameEnfVertexListMap[groupName].insert(vertex); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index 40c63e4..84c402a 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -88,45 +88,34 @@ typedef std::vector TEnfVertexCoords; // List of enforced vertices typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList; // Enforced vertex -typedef struct { +struct TEnfVertex{ TEnfName name; TEntry geomEntry; TEnfVertexCoords coords; TEnfName grpName; -} TEnfVertex; +}; -bool TEnfVertexGUICmp(const TEnfVertex *e1, const TEnfVertex *e2); -// { -// if (e1 && e2) { -// bool sameCoords = true; -// if (e1->coords.size() && e2->coords.size()) -// sameCoords = (e1->coords[0] == e2->coords[0]) && (e1->coords[1] == e2->coords[1]) && (e1->coords[2] -// == e2->coords[2]); -// return ( sameCoords && (e1->geomEntry == e2->geomEntry) && (e1->grpName == e2->grpName) -// && (e1->name == e2->name)); -// } else -// return (e1 < e2); -// } +// TODO remove all TEnfVertexGUICmp struct CompareEnfVertices { - bool operator () (const TEnfVertex &e1, const TEnfVertex &e2) const { - return true; + bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const { + if (e1 && e2) { + if (e1->coords.size() && e2->coords.size()) + return (e1->coords < e2->coords); + else + return (e1->geomEntry < e2->geomEntry); + } + return false; } }; // List of enforced vertices -typedef std::set< TEnfVertex, CompareEnfVertices > TEnfVertexList; +typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList; // Map Face Entry / List of enforced vertices typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap; -// // Map Coords / Enforced vertex -// typedef std::map< TEnfVertexCoords, TEnfVertex > TCoordsEnfVertexMap; -// -// // Map Entry / List of coords -// typedef std::map< TEntry, TEnfVertexCoordsList > TEntryCoordsListMap; - typedef struct { int myTopology, myVerbosity; @@ -136,8 +125,6 @@ typedef struct bool myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex; TEnfVertexList enfVertexList; TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap; -// TEntryCoordsListMap entryCoordsListMap; -// TCoordsEnfVertexMap coordsEnfVertexMap; /* TODO GROUPS TGroupNameEnfVertexListMap groupNameEnfVertexListMap; */ -- 2.39.2