+BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
+ throw (std::invalid_argument) {
+
+ if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
+ return _faceEntryEnfVertexListMap[theFaceEntry];
+ else
+ return GetDefaultEnfVertexList();
+
+ std::ostringstream msg;
+ msg << "No enforced vertex for face entry " << theFaceEntry;
+ throw std::invalid_argument(msg.str());
+}
+
+//=======================================================================
+//function : GetEnfVertexCoordsList
+//=======================================================================
+
+BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
+ const TEntry& theFaceEntry) throw (std::invalid_argument) {
+
+ if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
+ return _faceEntryCoordsListMap[theFaceEntry];
+
+ std::ostringstream msg;
+ msg << "No enforced vertex coords for face entry " << theFaceEntry;
+ throw std::invalid_argument(msg.str());
+}
+
+//=======================================================================
+//function : GetEnfVertexEntryList
+//=======================================================================
+
+BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
+ throw (std::invalid_argument) {
+
+ if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
+ return _faceEntryEnfVertexEntryListMap[theFaceEntry];
+
+ std::ostringstream msg;
+ msg << "No enforced vertex entry for face entry " << theFaceEntry;
+ throw std::invalid_argument(msg.str());
+}
+
+//=======================================================================
+//function : GetEnfVertex(TEnfVertexCoords coords)
+//=======================================================================
+
+BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
+ throw (std::invalid_argument) {
+
+ if (_coordsEnfVertexMap.count(coords) > 0)
+ return _coordsEnfVertexMap[coords];
+
+ std::ostringstream msg;
+ msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")";
+ throw std::invalid_argument(msg.str());
+}
+
+//=======================================================================
+//function : GetEnfVertex(const TEntry& theEnfVertexEntry)
+//=======================================================================
+
+BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
+ throw (std::invalid_argument) {
+
+ if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
+ return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
+
+ std::ostringstream msg;
+ msg << "No enforced vertex with entry " << theEnfVertexEntry;
+ throw std::invalid_argument(msg.str());
+}
+
+//=======================================================================
+//function : ClearEnforcedVertex
+//=======================================================================
+
+bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
+ const TEntry& theVertexEntry) throw (std::invalid_argument) {
+
+ bool toNotify = false;
+ std::ostringstream msg;
+ TEnfVertex *oldEnfVertex;
+ TEnfVertexCoords coords;
+ coords.clear();
+ coords.push_back(x);
+ coords.push_back(y);
+ coords.push_back(z);
+
+ // check that enf vertex with given enf vertex entry exists
+ TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
+ if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
+ // Success
+ MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
+ oldEnfVertex = it_enfVertexEntry->second;
+
+ _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
+
+ TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry];
+ enfVertexEntryList.erase(theVertexEntry);
+ if (enfVertexEntryList.size() == 0)
+ _faceEntryEnfVertexEntryListMap.erase(theFaceEntry);
+ // TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
+ // TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry);
+ // it_entry_entry->second.erase(it_entryList);
+ // if (it_entry_entry->second.size() == 0)
+ // _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
+ } else {
+ // Fail
+ MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
+ msg << "No enforced vertex with geom entry " << theVertexEntry;
+ // check that enf vertex with given coords exists
+ TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
+ if (it_coords_enf != _coordsEnfVertexMap.end()) {
+ // Success
+ MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
+ oldEnfVertex = it_coords_enf->second;
+
+ _coordsEnfVertexMap.erase(it_coords_enf);
+
+ TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry];
+ enfVertexCoordsList.erase(coords);
+ if (enfVertexCoordsList.size() == 0)
+ _faceEntryCoordsListMap.erase(theFaceEntry);
+ // TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
+ // TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords);
+ // it_entry_coords->second.erase(it_coordsList);
+ // if (it_entry_coords->second.size() == 0)
+ // _faceEntryCoordsListMap.erase(it_entry_coords);
+ } else {
+ // Fail
+ MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
+ msg << std::endl;
+ msg << "No enforced vertex at " << x << ", " << y << ", " << z;
+ throw std::invalid_argument(msg.str());
+ }
+ }
+
+ MESSAGE("Remove enf vertex from _enfVertexList");
+
+ // update _enfVertexList
+ TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
+ if (it != _enfVertexList.end()) {
+ (*it)->faceEntries.erase(theFaceEntry);
+ if ((*it)->faceEntries.size() == 0){
+ _enfVertexList.erase(it);
+ toNotify = true;
+ }
+ MESSAGE("Done");
+ }
+
+ // update _faceEntryEnfVertexListMap
+ TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
+ currentEnfVertexList.erase(oldEnfVertex);
+
+ if (currentEnfVertexList.size() == 0) {
+ MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
+ _faceEntryEnfVertexListMap.erase(theFaceEntry);
+ MESSAGE("Done");
+ }
+
+ if (toNotify)
+ NotifySubMeshesHypothesisModification();
+
+ return toNotify;
+}
+
+//=======================================================================
+//function : ClearEnforcedVertices
+//=======================================================================
+
+bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
+
+ bool toNotify = false;
+ TEnfVertex *oldEnfVertex;
+
+ TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
+ if (it_entry_coords != _faceEntryCoordsListMap.end()) {
+ toNotify = true;
+ TEnfVertexCoordsList coordsList = it_entry_coords->second;
+ TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
+ for (; it_coordsList != coordsList.end(); ++it_coordsList) {
+ TEnfVertexCoords coords = (*it_coordsList);
+ oldEnfVertex = _coordsEnfVertexMap[coords];
+ _coordsEnfVertexMap.erase(coords);
+ // update _enfVertexList
+ TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
+ if (it != _enfVertexList.end()) {
+ (*it)->faceEntries.erase(theFaceEntry);
+ if ((*it)->faceEntries.size() == 0){
+ _enfVertexList.erase(it);
+ toNotify = true;
+ }
+ MESSAGE("Done");
+ }
+ }
+ _faceEntryCoordsListMap.erase(it_entry_coords);
+ _faceEntryEnfVertexListMap.erase(theFaceEntry);
+ }
+
+ TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
+ if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) {
+ toNotify = true;
+ TEntryList enfVertexEntryList = it_entry_entry->second;
+ TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
+ for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
+ TEntry enfVertexEntry = (*it_enfVertexEntryList);
+ oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
+ _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
+ // update _enfVertexList
+ TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
+ if (it != _enfVertexList.end()) {
+ (*it)->faceEntries.erase(theFaceEntry);
+ if ((*it)->faceEntries.size() == 0){
+ _enfVertexList.erase(it);
+ toNotify = true;
+ }
+ MESSAGE("Done");
+ }
+ }
+ _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
+ _faceEntryEnfVertexListMap.erase(theFaceEntry);
+ }
+
+ if (toNotify)
+ NotifySubMeshesHypothesisModification();
+
+ return toNotify;
+ // std::ostringstream msg;
+ // msg << "No enforced vertex for " << theFaceEntry;
+ // throw std::invalid_argument(msg.str());
+}
+
+//=======================================================================
+//function : ClearAllEnforcedVertices
+//=======================================================================
+void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() {
+ _faceEntryEnfVertexListMap.clear();
+ _enfVertexList.clear();
+ _faceEntryCoordsListMap.clear();
+ _coordsEnfVertexMap.clear();
+ _faceEntryEnfVertexEntryListMap.clear();
+ _enfVertexEntryEnfVertexMap.clear();
+ NotifySubMeshesHypothesisModification();
+}
+
+//================================================================================
+/*!
+ * \brief Return the enforced vertices
+ */
+//================================================================================
+
+
+BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
+ const BLSURFPlugin_Hypothesis* hyp) {
+ return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
+}
+
+BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
+ const BLSURFPlugin_Hypothesis* hyp) {
+ return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
+}
+
+BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
+ const BLSURFPlugin_Hypothesis* hyp) {
+ return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
+}
+
+BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
+ const BLSURFPlugin_Hypothesis* hyp) {
+ return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
+}
+
+BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
+ const BLSURFPlugin_Hypothesis* hyp) {
+ return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
+}
+
+BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
+ const BLSURFPlugin_Hypothesis* hyp) {
+ return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
+}
+
+std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)