From: gdd Date: Thu, 3 Feb 2011 10:27:22 +0000 (+0000) Subject: merge from branch BR_EDF_PAL_1456 tag mergeto_BR_ATTRACTOR_GEO X-Git-Tag: Geodesic_attractor_20110218~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0d58453114318c2f7ad44b1398f413464adf65f3;p=plugins%2Fblsurfplugin.git merge from branch BR_EDF_PAL_1456 tag mergeto_BR_ATTRACTOR_GEO --- diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 64b34bc..1f577b4 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -37,18 +37,62 @@ module BLSURFPlugin { typedef sequence string_array; + // Enforced vertex name + typedef string TEnfName; // Entry typedef string TEnfEntry; - // Enforced vertex = 3 coordinates - typedef sequence TEnfVertex; + typedef sequence TEnfEntryList; + // Group name + typedef string TEnfGroupName; + + // Coordinates of enforced vertex (old enforced vertex) + typedef sequence TEnfVertexCoords; + // List of coords + typedef sequence TEnfVertexCoordsList; + + // Enforced vertex + struct TEnfVertex { + TEnfName name; + TEnfEntry geomEntry; + TEnfVertexCoords coords; + TEnfEntryList faceEntries; +// TODO GROUPS + TEnfGroupName grpName; + }; // List of enforced vertices typedef sequence TEnfVertexList; - // Map Entry / List of enforced vertices - struct TEntryEnfVertexListMapElement { - TEnfEntry entry; - TEnfVertexList vertexList; + + // Map Coords / Enforced vertex + struct TCoordsEnfVertexElement { + TEnfVertexCoords coords; + TEnfVertex enfVertex; + }; + typedef sequence TCoordsEnfVertexMap; + + // Map Entry / List of coords + struct TEntryCoordsListMapElement { + string entry; + TEnfVertexCoordsList coordsList; }; - typedef sequence TEntryEnfVertexListMap; + typedef sequence TEntryCoordsListMap; + +// // ////////////// OLD ///////////////// +// // typedef sequence OldTEnfVertexList; +// // // Map Entry / List of enforced vertices +// // struct OldTEntryEnfVertexListMapElement { +// // string entry; +// // OldTEnfVertexList vertexList; +// // }; +// // typedef sequence OldTEntryEnfVertexListMap; +// // +// // // Map Enforced vertex / List of face entries +// // struct OldTEnfVertexEntryListMapElement { +// // TEnfVertexCoords vertex; +// // sequence entryList; +// // }; +// // typedef sequence OldTEnfVertexEntryListMap; +// // ////////////// OLD ///////////////// + /* TODO GROUPS // Group name typedef string TEnfGroupName; @@ -239,39 +283,45 @@ module BLSURFPlugin // ENFORCED VERTEXES // /////////////////////// - TEntryEnfVertexListMap GetAllEnforcedVertices(); - void ClearAllEnforcedVertices(); +// TEnfVertexList GetAllEnforcedVertices(); + TEntryCoordsListMap GetAllCoordsByFace(); + TCoordsEnfVertexMap GetAllEnforcedVerticesByCoords(); + void ClearAllEnforcedVertices(); /*! - * Set/get/unset an enforced vertex on geom object + * Set/get/unset an enforced vertex on geom face */ - void SetEnforcedVertex(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertex(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in string enfName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexWithPoint(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex) raises (SALOME::SALOME_Exception); /* TODO GROUPS - void SetEnforcedVertexWithGroup(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); + void SetEnforcedVertexWithGroup(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); */ -// void SetEnforcedVertexList(in GEOM::GEOM_Object GeomObj, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); +// void SetEnforcedVertexList(in GEOM::GEOM_Object theFace, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); - TEnfVertexList GetEnforcedVertices(in GEOM::GEOM_Object GeomObj) raises (SALOME::SALOME_Exception); + TEnfVertexList GetEnforcedVertices(in GEOM::GEOM_Object theFace) raises (SALOME::SALOME_Exception); - void UnsetEnforcedVertex(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexList(in GEOM::GEOM_Object GeomObj, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); - void UnsetEnforcedVertices(in GEOM::GEOM_Object GeomObj) raises (SALOME::SALOME_Exception); + boolean UnsetEnforcedVertex(in GEOM::GEOM_Object theFace, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + boolean UnsetEnforcedVertexWithPoint(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex) raises (SALOME::SALOME_Exception); +// void UnsetEnforcedVertexList(in GEOM::GEOM_Object theFace, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); + boolean UnsetEnforcedVertices(in GEOM::GEOM_Object theFace) raises (SALOME::SALOME_Exception); /*! - * Set/get/unset an enforced vertex on geom object given by entry + * Set/get/unset an enforced vertex on geom face given by entry */ - void SetEnforcedVertexEntry(in TEnfEntry entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexEntry(in string theFaceEntry, in double x, in double y, in double z, in string enfName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexEntryWithPoint(in string theFaceEntry, in string theVertexEntry, in string theVertexName, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); /* TODO GROUPS - void SetEnforcedVertexEntryWithGroup(in TEnfEntry entry, in double x, in double y, in double z, in TEnfGroupName groupName) + void SetEnforcedVertexEntryWithGroup(in string theFaceEntry, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); */ -// void SetEnforcedVertexListEntry(in TEnfEntry entry, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); +// void SetEnforcedVertexListEntry(in string theFaceEntry, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); // - TEnfVertexList GetEnforcedVerticesEntry(in TEnfEntry entry) raises (SALOME::SALOME_Exception); + TEnfVertexList GetEnforcedVerticesEntry(in string theFaceEntry) raises (SALOME::SALOME_Exception); // - void UnsetEnforcedVertexEntry(in TEnfEntry entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexListEntry(in TEnfEntry entry, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); - void UnsetEnforcedVerticesEntry(in TEnfEntry entry) raises (SALOME::SALOME_Exception); + boolean UnsetEnforcedVertexEntry(in string theFaceEntry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + boolean UnsetEnforcedVertexEntryWithPoint(in string theFaceEntry, in string theVertexEntry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); +// void UnsetEnforcedVertexListEntry(in string theFaceEntry, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); + boolean UnsetEnforcedVerticesEntry(in string theFaceEntry) raises (SALOME::SALOME_Exception); /*! * Set/get an enforced vertex on geom object and add it to a group diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index f0ff61e..c75a0d7 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -134,8 +134,8 @@ static PyMethodDef PyStdOut_methods[] = { }; static PyMemberDef PyStdOut_memberlist[] = { - {"softspace", T_INT, offsetof(PyStdOut, softspace), 0, - "flag indicating that a space needs to be printed; used by print"}, + {(char *)"softspace", T_INT, offsetof(PyStdOut, softspace), 0, + (char *)"flag indicating that a space needs to be printed; used by print"}, {NULL} /* Sentinel */ }; @@ -424,22 +424,23 @@ TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry) } ///////////////////////////////////////////////////////// -void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList) +void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis::TEnfVertexCoordsList coordsList) { double xe, ye, ze; - std::vector coords; - std::vector s_coords; - std::vector enfVertex; + BLSURFPlugin_Hypothesis::TEnfVertexCoords coords; + BLSURFPlugin_Hypothesis::TEnfVertexCoords s_coords; + BLSURFPlugin_Hypothesis::TEnfVertexCoords enfVertexCoords; // BLSURFPlugin_Hypothesis::TEnfVertex enfVertex; - BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin(); - for( ; evlIt != enfVertexList.end() ; ++evlIt ) { + BLSURFPlugin_Hypothesis::TEnfVertexCoordsList::const_iterator coordsListIt = coordsList.begin(); + + for( ; coordsListIt != coordsList.end() ; ++coordsListIt ) { coords.clear(); s_coords.clear(); - enfVertex = *evlIt; - xe = enfVertex[0]; - ye = enfVertex[1]; - ze = enfVertex[2]; + enfVertexCoords = *coordsListIt; + xe = enfVertexCoords[0]; + ye = enfVertexCoords[1]; + ze = enfVertexCoords[2]; MESSAGE("Enforced Vertex: " << xe << ", " << ye << ", " << ze); // Get the (u,v) values of the enforced vertex on the face projectionPoint myPoint = getProjectionPoint(TopoDS::Face(GeomShape),gp_XYZ(xe,ye,ze)); @@ -465,7 +466,7 @@ void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis: // Save pair projected vertex / enf vertex MESSAGE("Storing pair projected vertex / enf vertex:"); MESSAGE("("<< x0 << ", " << y0 << ", " << z0 <<") / (" << xe << ", " << ye << ", " << ze<<")"); - EnfVertex2ProjVertex[s_coords] = enfVertex; + EnfVertex2ProjVertex[s_coords] = enfVertexCoords; int key = 0; if (! FacesWithEnforcedVertices.Contains(TopoDS::Face(GeomShape))) { @@ -854,25 +855,25 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, // Enforced Vertices // MESSAGE("Setting Enforced Vertices"); - const BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap entryEnfVertexListMap = BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(hyp); - BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap::const_iterator enfIt = entryEnfVertexListMap.begin(); - for ( ; enfIt != entryEnfVertexListMap.end(); ++enfIt ) { - if ( !enfIt->second.empty() ) { - GeomShape = entryToShape(enfIt->first); + const BLSURFPlugin_Hypothesis::TEntryCoordsListMap entryCoordsListMap = BLSURFPlugin_Hypothesis::GetAllCoordsByFace(hyp); + BLSURFPlugin_Hypothesis::TEntryCoordsListMap::const_iterator coordsIt = entryCoordsListMap.begin(); + for ( ; coordsIt != entryCoordsListMap.end(); ++coordsIt ) { + if ( !coordsIt->second.empty() ) { + GeomShape = entryToShape(coordsIt->first); GeomType = GeomShape.ShapeType(); // Group Management if (GeomType == TopAbs_COMPOUND){ for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){ if (it.Value().ShapeType() == TopAbs_FACE){ HasSizeMapOnFace = true; - createEnforcedVertexOnFace(it.Value(), enfIt->second); + createEnforcedVertexOnFace(it.Value(), coordsIt->second); } } } if (GeomType == TopAbs_FACE){ HasSizeMapOnFace = true; - createEnforcedVertexOnFace(GeomShape, enfIt->second); + createEnforcedVertexOnFace(GeomShape, coordsIt->second); } } } @@ -1714,15 +1715,15 @@ status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data) // assert(Py_IsInitialized()); // PyGILState_STATE gstate; // gstate = PyGILState_Ensure(); -// pyresult = PyObject_CallFunction(FaceId2PythonSmp[face_id],"(f,f)",uv[0],uv[1]); +// pyresult = PyObject_CallFunction(FaceId2PythonSmp[face_id],(char *)"(f,f)",uv[0],uv[1]); // double result; // if ( pyresult == NULL){ // fflush(stderr); // string err_description=""; // new_stderr = newPyStdOut(err_description); -// PySys_SetObject("stderr", new_stderr); +// PySys_SetObject((char *)"stderr", new_stderr); // PyErr_Print(); -// PySys_SetObject("stderr", PySys_GetObject("__stderr__")); +// PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__")); // Py_DECREF(new_stderr); // MESSAGE("Can't evaluate f(" << uv[0] << "," << uv[1] << ")" << " error is " << err_description); // result = *((double*)user_data); @@ -1750,15 +1751,15 @@ status_t size_on_edge(integer edge_id, real t, real *size, void *user_data) assert(Py_IsInitialized()); PyGILState_STATE gstate; gstate = PyGILState_Ensure(); - pyresult = PyObject_CallFunction(EdgeId2PythonSmp[edge_id],"(f)",t); + pyresult = PyObject_CallFunction(EdgeId2PythonSmp[edge_id],(char *)"(f)",t); double result; if ( pyresult == NULL){ fflush(stderr); string err_description=""; new_stderr = newPyStdOut(err_description); - PySys_SetObject("stderr", new_stderr); + PySys_SetObject((char *)"stderr", new_stderr); PyErr_Print(); - PySys_SetObject("stderr", PySys_GetObject("__stderr__")); + PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__")); Py_DECREF(new_stderr); MESSAGE("Can't evaluate f(" << t << ")" << " error is " << err_description); result = *((double*)user_data); @@ -1784,15 +1785,15 @@ status_t size_on_vertex(integer point_id, real *size, void *user_data) assert(Py_IsInitialized()); PyGILState_STATE gstate; gstate = PyGILState_Ensure(); - pyresult = PyObject_CallFunction(VertexId2PythonSmp[point_id],""); + pyresult = PyObject_CallFunction(VertexId2PythonSmp[point_id],(char *)""); double result; if ( pyresult == NULL){ fflush(stderr); string err_description=""; new_stderr = newPyStdOut(err_description); - PySys_SetObject("stderr", new_stderr); + PySys_SetObject((char *)"stderr", new_stderr); PyErr_Print(); - PySys_SetObject("stderr", PySys_GetObject("__stderr__")); + PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__")); Py_DECREF(new_stderr); MESSAGE("Can't evaluate f()" << " error is " << err_description); result = *((double*)user_data); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 3ac6ce4..8c9daf6 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -52,8 +52,9 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId, _sizeMap(GetDefaultSizeMap()), _attractors(GetDefaultSizeMap()), _classAttractors(GetDefaultAttractorMap()), - _enfVertexList(GetDefaultEnfVertexList()), - _entryEnfVertexListMap(GetDefaultEntryEnfVertexListMap()) +// _enfVertexList(GetDefaultEnfVertexList()), + _entryCoordsListMap(GetDefaultEntryCoordsListMap()), + _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()) /* TODO GROUPS _groupNameEnfVertexListMap(GetDefaultGroupNameEnfVertexListMap()), _enfVertexGroupNameMap(GetDefaultEnfVertexGroupNameMap()) @@ -138,8 +139,9 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId, _sizeMap.clear(); _attractors.clear(); - _enfVertexList.clear(); - _entryEnfVertexListMap.clear(); +// _enfVertexList.clear(); + _entryCoordsListMap.clear(); + _coordsEnfVertexMap.clear(); /* TODO GROUPS _groupNameEnfVertexListMap.clear(); _enfVertexGroupNameMap.clear(); @@ -499,31 +501,70 @@ void BLSURFPlugin_Hypothesis::ClearSizeMaps() /* TODO GROUPS void BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEnfEntry& entry, double x, double y, double z, + std::string enfName, const TEnfGroupName& groupName) */ -void BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEnfEntry& entry, - double x, double y, double z) +bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEnfEntry& theFaceEntry, + double x, double y, double z, + std::string enfName, + std::string theVertexEntry) { /* TODO GROUPS - MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex START - entry: " << entry << " vertex: " << x << " " << y << " " << z << " group name: " << groupName); + MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex START - theFaceEntry: " << entry << " vertex: " << x << " " << y << " " << z << " group name: " << groupName); */ - MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex START - entry: " << entry << " vertex: " << x << " " << y << " " << z); - TEnfVertex enfVertex; - enfVertex.push_back(x); - enfVertex.push_back(y); - enfVertex.push_back(z); - + MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex START - theFaceEntry: " << theFaceEntry << " vertex: " << x << " " << y << " " << z + << " name: " << enfName << " theVertexEntry: " << theVertexEntry); + bool toNotify = false; - if (_entryEnfVertexListMap.count(entry)>0) - if (_entryEnfVertexListMap[entry].count(enfVertex)==0) + TEnfVertexCoords coords; + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); + if ( _entryCoordsListMap.count(theFaceEntry)>0 ) + { + TEnfVertexCoordsList coordsList = _entryCoordsListMap[theFaceEntry]; + if ( coordsList.count(coords)==0 ) + { toNotify = true; + if ( _coordsEnfVertexMap.count(coords)>0 ) + { + _coordsEnfVertexMap[coords].faceEntries.insert(theFaceEntry); + } + else + { + TEnfVertex enfVertex; + enfVertex.name = enfName; + enfVertex.geomEntry = theVertexEntry; + enfVertex.coords = coords; + enfVertex.faceEntries.clear(); + enfVertex.faceEntries.insert(theFaceEntry); + + _coordsEnfVertexMap[coords] = enfVertex; + } + coordsList.insert(coords); + _entryCoordsListMap[theFaceEntry].insert(coords); + } + } else + { toNotify = true; - - _enfVertexList.insert(enfVertex); -// _entryEnfVertexListMap[entry].insert(enfVertex); - TEnfVertexList& entryEnfVertexList = _entryEnfVertexListMap[entry]; - entryEnfVertexList.insert(enfVertex); + if ( _coordsEnfVertexMap.count(coords)>0 ) + { + _coordsEnfVertexMap[coords].faceEntries.insert(theFaceEntry); + } + else + { + TEnfVertex enfVertex; + enfVertex.name = enfName; + enfVertex.geomEntry = theVertexEntry; + enfVertex.coords = coords; + enfVertex.faceEntries.clear(); + enfVertex.faceEntries.insert(theFaceEntry); + + _coordsEnfVertexMap[coords] = enfVertex; + } + _entryCoordsListMap[theFaceEntry].insert(coords); + } /* TODO GROUPS bool toNotify2 = _setEnfVertexWithGroup(x,y,z,groupName); @@ -535,6 +576,7 @@ void BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEnfEntry& entry, NotifySubMeshesHypothesisModification(); MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END"); + return toNotify; } /* TODO GROUPS @@ -673,8 +715,35 @@ void BLSURFPlugin_Hypothesis::SetEnforcedVertexList(const TEnfEntry& entry, BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument) { - if (_entryEnfVertexListMap.count(entry)>0) - return _entryEnfVertexListMap[entry]; + TEnfVertexList enfVertexList; + if (_entryCoordsListMap.count(entry)>0) { + TEnfVertexCoordsList coordsList = _entryCoordsListMap[entry]; + if (coordsList.size() != 0) { +// TEnfVertexList enfVertexList; + TEnfVertexCoordsList::iterator it = coordsList.begin(); + for ( ; it != coordsList.end() ; ++it) { + TEnfVertexCoords coords = *it; + TEnfVertex& enfVertex = _coordsEnfVertexMap[coords]; + enfVertexList.insert(enfVertex); + } +// return enfVertexList; + } + } + return enfVertexList; +// std::ostringstream msg ; +// msg << "No enforced vertex for entry " << entry ; +// throw std::invalid_argument(msg.str()); +} + +//======================================================================= +//function : GetCoords +//======================================================================= + +BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetCoords(const TEnfEntry& entry) + throw (std::invalid_argument) +{ + if (_entryCoordsListMap.count(entry)>0) + return _entryCoordsListMap[entry]; std::ostringstream msg ; msg << "No enforced vertex for entry " << entry ; throw std::invalid_argument(msg.str()); @@ -684,113 +753,69 @@ BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnforcedVert //function : ClearEnforcedVertex //======================================================================= -void BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEnfEntry& entry, double x, double y, double z) +bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEnfEntry& entry, double x, double y, double z) throw (std::invalid_argument) { std::ostringstream msg ; - TEnfVertex enfVertex; - enfVertex.push_back(x); - enfVertex.push_back(y); - enfVertex.push_back(z); + TEnfVertexCoords coords; + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); // check that enf vertex with given coords exists - if (_enfVertexList.count(enfVertex) == 0) { - msg << "No enforced vertex for " << entry; + TCoordsEnfVertexMap::iterator it_coords = _coordsEnfVertexMap.find(coords); + if (it_coords == _coordsEnfVertexMap.end()) { + msg << "No enforced vertex at " << x << ", " << y << ", " << z; throw std::invalid_argument(msg.str()); } - - - TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry); - if (it_enf != _entryEnfVertexListMap.end()) { - bool toNotify = false; - TEnfVertexList::iterator it = _entryEnfVertexListMap[entry].find(enfVertex); - if (it != _entryEnfVertexListMap[entry].end()) { - toNotify = true; - - // Update entry2enfList map - _entryEnfVertexListMap[entry].erase(it); - if (_entryEnfVertexListMap[entry].size() == 0) - _entryEnfVertexListMap.erase(it_enf); - - /* TODO GROUPS - // Update groupName2enfCoord map - TEnfGroupName groupName = _enfVertexGroupNameMap[enfVertex]; - if (groupName != "") { - TGroupNameEnfVertexListMap::iterator it_grp =_groupNameEnfVertexListMap.find(groupName); - if (it_grp != _groupNameEnfVertexListMap.end()) { - _groupNameEnfVertexListMap[groupName].erase(enfVertex); - if (_groupNameEnfVertexListMap[groupName].size() == 0) - _groupNameEnfVertexListMap.erase(it_grp); - } - } - - // Update _enfVertexGroupNameMap - _enfVertexGroupNameMap.erase(enfVertex); - */ - - // Update _enfVertexList - _enfVertexList.erase(enfVertex); - - } - if (toNotify) - NotifySubMeshesHypothesisModification(); - return; + + TEnfVertex enfVertex = it_coords->second; + TEnfEntryList::iterator it_entry_list = enfVertex.faceEntries.find(entry); + if (it_entry_list == enfVertex.faceEntries.end()) { + msg << "No enforced vertex at " << x << ", " << y << ", " << z << " for " << entry; + throw std::invalid_argument(msg.str()); } - msg << "No enforced vertex for " << entry; - throw std::invalid_argument(msg.str()); + // If we get here, it means that the face has an enforced vertex with given coords + // suppress entry from list of entries + enfVertex.faceEntries.erase(it_entry_list); + // if no more face, remove enforced vertex from list + if (enfVertex.faceEntries.size() == 0) { +// _enfVertexList.erase(enfVertex); + // remove coords from map + _coordsEnfVertexMap.erase(it_coords); + } + + // suppress coords from list of coords of given face entry + TEntryCoordsListMap::iterator it_entry = _entryCoordsListMap.find(entry); +// TEnfVertexCoordsList coordsList = it_entry->second; +// TEnfVertexCoordsList::iterator it = coordsList.find(coords); +// coordsList.erase(it); + TEnfVertexCoordsList& coordsList = _entryCoordsListMap[entry]; + coordsList.erase(coords); + // if no more coords, remove entry from map + if (coordsList.size() == 0) + _entryCoordsListMap.erase(it_entry); + + NotifySubMeshesHypothesisModification(); + return true; } -/* -//======================================================================= -//function : ClearEnforcedVertexList -//======================================================================= - -void BLSURFPlugin_Hypothesis::ClearEnforcedVertexList(const std::string& entry, TEnfVertexList vertexList) - throw (std::invalid_argument) -{ - TEnfVertex coord; - TEnfVertexList::const_iterator it_toRemove; - TEnfVertexList::iterator it; - bool toNotify = false; - TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry); - if (it_enf != _entryEnfVertexListMap.end()) { - for (it_toRemove = vertexList.begin() ; it_toRemove != vertexList.end() ; ++it_toRemove) { - coord = *it_toRemove; - it = _entryEnfVertexListMap[entry].find(coord); - if (it != _entryEnfVertexListMap[entry].end()) { - toNotify = true; - _entryEnfVertexListMap[entry].erase(it); - _enfVertexList.erase(it); - } - } - if (_entryEnfVertexListMap[entry].size() == 0) { - toNotify = true; - _entryEnfVertexListMap.erase(it_enf); - } - if (toNotify) - NotifySubMeshesHypothesisModification(); - return; - } - std::ostringstream msg ; - msg << "No enforced vertex for " << entry; - throw std::invalid_argument(msg.str()); -} -*/ //======================================================================= //function : ClearEnforcedVertices //======================================================================= -void BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEnfEntry& entry) +bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument) { - TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry); - if (it_enf != _entryEnfVertexListMap.end()) { - TEnfVertexList enfList = it_enf->second; - TEnfVertexList::iterator it; - for(it = enfList.begin();it!=enfList.end();++it) { + TEntryCoordsListMap::iterator it_entry = _entryCoordsListMap.find(entry); + if (it_entry != _entryCoordsListMap.end()) { + TEnfVertexCoordsList coordsList = it_entry->second; + TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin(); + for( ; it_coordsList != coordsList.end() ; ++it_coordsList) { + TEnfVertexCoords coords = (*it_coordsList); /* TODO GROUPS TEnfGroupName groupName = _enfVertexGroupNameMap[*it]; if (groupName != "") { @@ -803,11 +828,23 @@ void BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEnfEntry& entry) } _enfVertexGroupNameMap.erase(*it); */ - _enfVertexList.erase(it); +// _enfVertexList.erase(it); + + TCoordsEnfVertexMap::iterator it_coords = _coordsEnfVertexMap.find(coords); + TEnfVertex enfVertex = it_coords->second; +// TEnfVertex enfVertex = _coordsEnfVertexMap[coords]; + TEnfEntryList::iterator it2 = enfVertex.faceEntries.find(entry); + if (it2 != enfVertex.faceEntries.end()) { + enfVertex.faceEntries.erase(it2); + if (enfVertex.faceEntries.size() == 0) { +// _enfVertexList.erase(enfVertex); + _coordsEnfVertexMap.erase(it_coords); + } + } } - _entryEnfVertexListMap.erase(it_enf); + _entryCoordsListMap.erase(it_entry); NotifySubMeshesHypothesisModification(); - return; + return true; } std::ostringstream msg ; @@ -820,13 +857,10 @@ void BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEnfEntry& entry) //======================================================================= void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() { - _enfVertexList.clear(); - _entryEnfVertexListMap.clear(); - /* TODO GROUPS - _groupNameEnfVertexListMap.clear(); - _enfVertexGroupNameMap.clear(); - */ - NotifySubMeshesHypothesisModification(); +// _enfVertexList.clear(); + _entryCoordsListMap.clear(); + _coordsEnfVertexMap.clear(); + NotifySubMeshesHypothesisModification(); } //================================================================================ @@ -835,12 +869,21 @@ void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() */ //================================================================================ -BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp) + +// BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp) +// { +// return hyp ? hyp->_GetAllEnforcedVertices():GetDefaultEnfVertexList(); +// } + +BLSURFPlugin_Hypothesis::TEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp) { - return hyp ? hyp->_GetAllEnforcedVertices():GetDefaultEntryEnfVertexListMap(); + return hyp ? hyp->_GetAllCoordsByFace():GetDefaultEntryCoordsListMap(); } - +BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetAllEnforcedVerticesByCoords():GetDefaultCoordsEnfVertexMap(); +} //============================================================================= std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) @@ -891,17 +934,19 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) save << " " << "__ATTRACTORS_END__"; } - TEntryEnfVertexListMap::const_iterator it_enf = _entryEnfVertexListMap.begin(); - if (it_enf != _entryEnfVertexListMap.end()) { + TEntryCoordsListMap::const_iterator it_enf = _entryCoordsListMap.begin(); + if (it_enf != _entryCoordsListMap.end()) { save << " " << "__ENFORCED_VERTICES_BEGIN__"; - for ( ; it_enf != _entryEnfVertexListMap.end(); ++it_enf ) { + for ( ; it_enf != _entryCoordsListMap.end(); ++it_enf ) { save << " " << it_enf->first; - TEnfVertexList evl = it_enf->second; - TEnfVertexList::const_iterator it_evl = evl.begin(); - for ( ; it_evl != evl.end() ; ++it_evl) { - save << " " << (*it_evl)[0]; - save << " " << (*it_evl)[1]; - save << " " << (*it_evl)[2]; + TEnfVertexCoordsList coordsList = it_enf->second; + TEnfVertexCoordsList::const_iterator it_coordsList = coordsList.begin(); + for ( ; it_coordsList != coordsList.end() ; ++it_coordsList) { + TEnfVertex enfVertex = _coordsEnfVertexMap[(*it_coordsList)]; + save << " " << enfVertex.name; + save << " " << enfVertex.coords[0]; + save << " " << enfVertex.coords[1]; + save << " " << enfVertex.coords[2]; /* TODO GROUPS TEnfVertexGroupNameMap::const_iterator it_enfGroup = _enfVertexGroupNameMap.find(*it_evl); if (it_enfGroup != _enfVertexGroupNameMap.end()) { @@ -1157,14 +1202,17 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) enfValue = "begin"; int len4 = enfValue.size(); - TEnfVertexList & evl = _entryEnfVertexListMap[enfEntry]; - evl.clear(); + TEnfVertexCoordsList & coordsList = _entryCoordsListMap[enfEntry]; + coordsList.clear(); + TEnfVertexCoords coords; TEnfVertex enfVertex; // continue reading until "#" encountered while ( enfValue[len4-1] != '#') { // New vector begin - enfVertex.clear(); + coords.clear(); + enfVertex.coords.clear(); + while ( enfValue[len4-1] != '$') { isOK = (load >> enfValue); if (isOK) { @@ -1198,7 +1246,28 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) */ if (enfValue[len4-1] != '$') { // Add to vertex - enfVertex.push_back(atof(enfValue.c_str())); + // name + enfVertex.name = enfValue; + isOK = (load >> enfValue); + len4 = enfValue.size(); + } + if (enfValue[len4-1] != '$') { + // X coord + enfVertex.coords.push_back(atof(enfValue.c_str())); + isOK = (load >> enfValue); + len4 = enfValue.size(); + } + if (enfValue[len4-1] != '$') { + // Y coord + enfVertex.coords.push_back(atof(enfValue.c_str())); + isOK = (load >> enfValue); + len4 = enfValue.size(); + } + if (enfValue[len4-1] != '$') { + // Z coord + enfVertex.coords.push_back(atof(enfValue.c_str())); + isOK = (load >> enfValue); + len4 = enfValue.size(); } } else @@ -1216,10 +1285,12 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) } */ enfValue[len4-1] = '\0'; //cut off "$#" - enfVertex.push_back(atof(enfValue.c_str())); + enfVertex.coords.push_back(atof(enfValue.c_str())); MESSAGE("Add vertex to list"); // Add vertex to list of vertex - evl.insert(enfVertex); + coordsList.insert(enfVertex.coords); + _coordsEnfVertexMap[enfVertex.coords] = enfVertex; +// _enfVertexList.insert(enfVertex); } } if (enfValue[len4-1] == '#') { @@ -1232,9 +1303,11 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) */ // Remove '$#' and add to vertex enfValue[len4-2] = '\0'; //cut off "$#" - enfVertex.push_back(atof(enfValue.c_str())); + enfVertex.coords.push_back(atof(enfValue.c_str())); // Add vertex to list of vertex - evl.insert(enfVertex); + coordsList.insert(enfVertex.coords); + _coordsEnfVertexMap[enfVertex.coords] = enfVertex; +// _enfVertexList.insert(enfVertex); } } else diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 0a64884..b30789d 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -143,44 +143,90 @@ public: /*! * To set/get/unset an enforced vertex */ + // Name + typedef std::string TEnfName; // Entry typedef std::string TEnfEntry; - // Enforced vertex = 3 coordinates - typedef std::vector TEnfVertex; + // Group name + typedef std::string TEnfGroupName; + // List of entries + typedef std::set TEnfEntryList; + // Coordinates + typedef std::vector TEnfVertexCoords; + typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList; + // Enforced vertex + typedef struct { + TEnfName name; + TEnfEntry geomEntry; + TEnfVertexCoords coords; + TEnfEntryList faceEntries; + bool manualInput; + // TODO GROUPS + TEnfGroupName grpName; + } TEnfVertex; + struct _TEnforcedVertexCmp + { + bool operator () (const TEnfVertex e1, const TEnfVertex e2) const + { + const bool cmpCoords = ( &e1 && &e2 && e1.coords.size() && e2.coords.size() ); + return cmpCoords ? ( e1.coords < e2.coords) : ( &e1 < &e2 ); + } + }; // List of enforced vertices - typedef std::set< TEnfVertex > TEnfVertexList; + typedef std::set< TEnfVertex, _TEnforcedVertexCmp > TEnfVertexList; + + // Map Coords / Enforced vertex + typedef std::map< TEnfVertexCoords, TEnfVertex > TCoordsEnfVertexMap; + + // Map Entry / List of coords + typedef std::map< TEnfEntry, TEnfVertexCoordsList > TEntryCoordsListMap; + // Map Entry / List of enforced vertices - typedef std::map< TEnfEntry , TEnfVertexList > TEntryEnfVertexListMap; + typedef std::map< TEnfEntry, TEnfVertexList > TEntryEnfVertexListMap; + + + ////////////// OLD ///////////////// + // List of enforced vertices + typedef std::set< TEnfVertexCoords > OldTEnfVertexList; + // Map Entry / List of enforced vertices + typedef std::map< TEnfEntry , OldTEnfVertexList > OldTEntryEnfVertexListMap; + // Map Enforced vertex / List of face entries + typedef std::map< TEnfVertexCoords , TEnfEntryList > OldTEnfVertexEntryListMap; + ////////////// OLD ///////////////// + + /* TODO GROUPS - // Group name - typedef std::string TEnfGroupName; // Map Group Name / List of enforced vertices typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap; - // Map Enforced vertex / Group Name - typedef std::map< TEnfVertex , TEnfGroupName > TEnfVertexGroupNameMap; */ - /* TODO GROUPS - void SetEnforcedVertex(const TEnfEntry& entry, double x, double y, double z, const TEnfGroupName& groupName=""); - */ - void SetEnforcedVertex(const TEnfEntry& entry, double x, double y, double z); +// TODO GROUPS +// void SetEnforcedVertex(const TEnfEntry& entry, double x, double y, double z, const TEnfGroupName& groupName=""); + + bool SetEnforcedVertex(const TEnfEntry& theFaceEntry, double x, double y, double z, std::string enfName="", std::string theVertexEntry=""); // void SetEnforcedVertexList(const TEnfEntry& entry, const TEnfVertexList vertexList); - TEnfVertexList GetEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument); - void ClearEnforcedVertex(const TEnfEntry& entry, double x, double y, double z) throw (std::invalid_argument); + TEnfVertexList GetEnforcedVertices(const TEnfEntry& theFaceEntry) throw (std::invalid_argument); + TEnfVertexCoordsList GetCoords(const TEnfEntry& theFaceEntry) throw (std::invalid_argument); + + bool ClearEnforcedVertex(const TEnfEntry& theFaceEntry, double x, double y, double z) throw (std::invalid_argument); // void ClearEnforcedVertexList(const TEnfEntry& entry, TEnfVertexList vertexList) throw (std::invalid_argument); - void ClearEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument); - - void ClearAllEnforcedVertices(); - const TEntryEnfVertexListMap _GetAllEnforcedVertices() const { return _entryEnfVertexListMap; } - /* TODO GROUPS - const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; } - */ + bool ClearEnforcedVertices(const TEnfEntry& theFaceEntry) throw (std::invalid_argument); + + void ClearAllEnforcedVertices(); +// const TEnfVertexList _GetAllEnforcedVertices() const { return _enfVertexList; } + const TEntryCoordsListMap _GetAllCoordsByFace() const { return _entryCoordsListMap; } + const TCoordsEnfVertexMap _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; } +// TODO GROUPS +// const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; } + /*! * \brief Return the enforced vertices */ - static TEntryEnfVertexListMap GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp); +// static TEnfVertexList GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp); + static TEntryCoordsListMap GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp); + static TCoordsEnfVertexMap GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp); /*! * \brief Set/get node group to an enforced vertex @@ -203,10 +249,11 @@ public: static bool GetDefaultQuadAllowed(); static bool GetDefaultDecimesh(); static int GetDefaultVerbosity() { return 10; } - static TSizeMap GetDefaultSizeMap() { return TSizeMap(); } + static TSizeMap GetDefaultSizeMap() { return TSizeMap();} static TAttractorMap GetDefaultAttractorMap() { return TAttractorMap(); } - static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); } - static TEntryEnfVertexListMap GetDefaultEntryEnfVertexListMap() { return TEntryEnfVertexListMap(); } +// static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); } + static TEntryCoordsListMap GetDefaultEntryCoordsListMap() { return TEntryCoordsListMap(); } + static TCoordsEnfVertexMap GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); } /* TODO GROUPS static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); } static TEnfVertexGroupNameMap GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); } @@ -263,11 +310,11 @@ private: TSizeMap _sizeMap; TSizeMap _attractors; TAttractorMap _classAttractors; - TEnfVertexList _enfVertexList; - TEntryEnfVertexListMap _entryEnfVertexListMap; +// TEnfVertexList _enfVertexList; + TEntryCoordsListMap _entryCoordsListMap; + TCoordsEnfVertexMap _coordsEnfVertexMap; /* TODO GROUPS TGroupNameEnfVertexListMap _groupNameEnfVertexListMap; - TEnfVertexGroupNameMap _enfVertexGroupNameMap; */ // TSizeMap _customSizeMap; }; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index df1f321..05e0061 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -25,6 +25,7 @@ // #include "BLSURFPlugin_Hypothesis_i.hxx" #include "SMESH_Gen.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_PythonDump.hxx" #include "GEOM_Object.hxx" @@ -784,46 +785,87 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries() */ -/////////////////////// -// ENFORCED VERTEXES // -/////////////////////// - -BLSURFPlugin::TEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices() -{ - MESSAGE("IDL: GetAllEnforcedVertices()"); +// /////////////////////// +// // ENFORCED VERTICES // +// /////////////////////// + +// BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices() +// { +// MESSAGE("IDL: GetAllEnforcedVertices()"); +// ASSERT(myBaseImpl); +// BLSURFPlugin::TEnfVertexList_var resultMap = new BLSURFPlugin::TEnfVertexList(); +// const ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList = this->GetImpl()->_GetAllEnforcedVertices(); +// resultMap->length(enfVertexList.size()); +// MESSAGE("Enforced Vertex map size is " << enfVertexList.size()); +// +// ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin(); +// for ( int i = 0 ; evlIt != enfVertexList.end(); ++evlIt, ++i ) { +// MESSAGE("Enforced Vertex #" << i); +// BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); +// +// // Name +// enfVertex->name = CORBA::string_dup(evlIt->name.c_str()); +// +// // Coords +// BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); +// coords->length(3); +// coords[0] = evlIt->coords[0]; +// coords[1] = evlIt->coords[1]; +// coords[2] = evlIt->coords[2]; +// enfVertex->coords = coords; +// MESSAGE("Enforced vertex: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2]); +// +// // List of face entries +// BLSURFPlugin::TEnfEntryList_var faceEntries = new BLSURFPlugin::TEnfEntryList(); +// faceEntries->length(evlIt->faceEntries.size()); +// ::BLSURFPlugin_Hypothesis::TEnfEntryList::const_iterator eelIt = evlIt->faceEntries.begin(); +// for ( int j = 0 ; eelIt != evlIt->faceEntries.end(); ++eelIt, ++j ) +// faceEntries[j] = CORBA::string_dup(eelIt->c_str()); +// enfVertex->faceEntries = faceEntries; +// +// // Group name +// enfVertex->grpName = CORBA::string_dup(evlIt->grpName.c_str()); +// +// resultMap[i] = enfVertex; +// } +// return resultMap._retn(); +// +// } + +BLSURFPlugin::TEntryCoordsListMap* BLSURFPlugin_Hypothesis_i::GetAllCoordsByFace() +{ + MESSAGE("IDL: GetAllCoordsByFace()"); ASSERT(myBaseImpl); - BLSURFPlugin::TEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TEntryEnfVertexListMap(); - const ::BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap entryEnfVertexListMap = this->GetImpl()->_GetAllEnforcedVertices(); - resultMap->length(entryEnfVertexListMap.size()); - MESSAGE("Enforced Vertex map size is " << entryEnfVertexListMap.size()); - - ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList; - ::BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap::const_iterator evmIt = entryEnfVertexListMap.begin(); - for ( int i = 0 ; evmIt != entryEnfVertexListMap.end(); ++evmIt, ++i ) { - std::string entry = evmIt->first; - MESSAGE("Entry: " << entry); - enfVertexList = evmIt->second; - - BLSURFPlugin::TEntryEnfVertexListMapElement_var mapElement = new BLSURFPlugin::TEntryEnfVertexListMapElement(); - - BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList(); - vertexList->length(enfVertexList.size()); - MESSAGE("Number of enforced vertices: " << enfVertexList.size()); - - ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin(); - for ( int j = 0 ; evlIt != enfVertexList.end(); ++evlIt, ++j ) { - MESSAGE("Enforced Vertex #" << j); - BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); - enfVertex->length(3); - enfVertex[0] = (*evlIt)[0]; - enfVertex[1] = (*evlIt)[1]; - enfVertex[2] = (*evlIt)[2]; - vertexList[j] = enfVertex; - MESSAGE("Enforced vertex: " << enfVertex[0] << ", " << enfVertex[1] << ", " << enfVertex[2]); + + BLSURFPlugin::TEntryCoordsListMap_var resultMap = new BLSURFPlugin::TEntryCoordsListMap(); + + const ::BLSURFPlugin_Hypothesis::TEntryCoordsListMap entryCoordsListMap = this->GetImpl()->_GetAllCoordsByFace(); + resultMap->length(entryCoordsListMap.size()); + MESSAGE("Enforced Vertex map size is " << resultMap->length()); + + ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList _coordsList; + ::BLSURFPlugin_Hypothesis::TEntryCoordsListMap::const_iterator it_entry = entryCoordsListMap.begin(); + for ( int i = 0 ; it_entry != entryCoordsListMap.end(); ++it_entry, ++i ) { + BLSURFPlugin::TEntryCoordsListMapElement_var mapElement = new BLSURFPlugin::TEntryCoordsListMapElement(); + mapElement->entry = CORBA::string_dup(it_entry->first.c_str()); + MESSAGE("Entry: " << mapElement->entry); + + _coordsList = it_entry->second; + BLSURFPlugin::TEnfVertexCoordsList_var coordsList = new BLSURFPlugin::TEnfVertexCoordsList(); + coordsList->length(_coordsList.size()); + MESSAGE("Number of coords: " << coordsList->length()); + + ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList::const_iterator it_coords = _coordsList.begin(); + for ( int j = 0 ; it_coords != _coordsList.end(); ++it_coords, ++j ) { + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(3); + coords[0] = (*it_coords)[0]; + coords[1] = (*it_coords)[1]; + coords[2] = (*it_coords)[2]; + coordsList[j] = coords; + MESSAGE("Coords #" << j << ": " << coords[0] << ", " << coords[1] << ", " << coords[2]); } - - mapElement->entry = CORBA::string_dup(entry.c_str()); - mapElement->vertexList = vertexList; + mapElement->coordsList = coordsList; resultMap[i] = mapElement; @@ -831,6 +873,17 @@ BLSURFPlugin::TEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedV return resultMap._retn(); } +BLSURFPlugin::TCoordsEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByCoords() +{ + MESSAGE("IDL: GetAllEnforcedVerticesByCoords()"); + ASSERT(myBaseImpl); + +// BLSURFPlugin::TCoordsEnfVertexMap_var resultMap = new BLSURFPlugin::TCoordsEnfVertexMap(); +// const ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap coordsEnfVertexMap = this->GetImpl()->_GetAllEnforcedVerticesByCoords(); +// resultMap->length(coordsEnfVertexMap.size()); +// MESSAGE("Enforced Vertex map size is " << entryEnfVertexListMap.size()); +} + void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices() { ASSERT(myBaseImpl); @@ -841,17 +894,67 @@ void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices() /*! * Set/get/unset an enforced vertex on geom object */ -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* enfName) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - // TODO check that GeomObj is a face => in engine ? + + if (theFace->GetShapeType() != GEOM::FACE) + { + MESSAGE("theFace shape type is not FACE"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE", SALOME::BAD_PARAM); + } + // TODO Affecter un nom de groupe vide - string entry = GeomObj->GetStudyEntry(); - MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : SetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")"); + string theFaceEntry = theFace->GetStudyEntry(); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : SetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << enfName << ")"); try { - SetEnforcedVertexEntry(entry.c_str(), x, y, z); + return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, enfName); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +/*! + * Set/get/unset an enforced vertex on geom object + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithPoint(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + + if (theFace->GetShapeType() != GEOM::FACE) + { + MESSAGE("theFace shape type is not FACE"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE", SALOME::BAD_PARAM); + } + + if (theVertex->GetShapeType() != GEOM::VERTEX) + { + MESSAGE("theVertex shape type is not VERTEX"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX", SALOME::BAD_PARAM); + } + + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( this->GetImpl()->GetStudyId() ); + if (CORBA::is_nil(measureOp)) + return false; + + CORBA::Double x,y,z; + x = y = z = 0.; + measureOp->PointCoordinates (theVertex, x, y, z); + + // TODO Affecter un nom de groupe vide + string theFaceEntry = theFace->GetStudyEntry(); + string theVertexEntry = theVertex->GetStudyEntry(); + string theVertexName = theVertex->GetName(); + MESSAGE("IDL : theFace->GetName : " << theFace->GetName()); + MESSAGE("IDL : theVertex->GetName : " << theVertexName); + MESSAGE("IDL : SetEnforcedVertexWithPoint ( "<< theFaceEntry << ", " << theVertexEntry<< ", " << theVertexName<< ", " << x << ", " << y << ", " << z << ")"); + try { + return SetEnforcedVertexEntryWithPoint(theFaceEntry.c_str(), theVertexEntry.c_str(), theVertexName.c_str(), x, y, z); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -862,32 +965,46 @@ void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, * Set/get/unset an enforced vertex on geom object with group name */ /* TODO GROUPS -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr GeomObj, +void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - // TODO check that GeomObj is a face => in engine ? - string entry = GeomObj->GetStudyEntry(); - MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : SetEnforcedVertexWithGroup ( "<< entry << ", " << x << ", " << y << ", " << z << ", " << groupName <<")"); + + if (theFace->GetShapeType() != GEOM::FACE) + { + MESSAGE("theFace shape type is not FACE"); + return; + } + + // TODO check that theFace is a face => in engine ? + string theFaceEntry = theFace->GetStudyEntry(); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : SetEnforcedVertexWithGroup ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << groupName <<")"); try { - SetEnforcedVertexEntryWithGroup(entry.c_str(), x, y, z, groupName); + SetEnforcedVertexEntryWithGroup(theFaceEntry.c_str(), x, y, z, groupName); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } */ -BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) +BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - string entry = GeomObj->GetStudyEntry(); - MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : GetEnforcedVertexList ( "<< entry << ")"); + + if (theFace->GetShapeType() != GEOM::FACE) + { + MESSAGE("theFace shape type is not FACE"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE", SALOME::BAD_PARAM); + } + + string theFaceEntry = theFace->GetStudyEntry(); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : GetEnforcedVertexList ( "<< theFaceEntry << ")"); try { - return GetEnforcedVerticesEntry(entry.c_str()); + return GetEnforcedVerticesEntry(theFaceEntry.c_str()); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -895,33 +1012,60 @@ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEO } -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - string entry = GeomObj->GetStudyEntry(); - MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : UnsetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")"); + + if (theFace->GetShapeType() != GEOM::FACE) + { + MESSAGE("theFace shape type is not FACE"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE", SALOME::BAD_PARAM); + } + + string theFaceEntry = theFace->GetStudyEntry(); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : UnsetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")"); try { - UnsetEnforcedVertexEntry(entry.c_str(), x, y, z); + return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } - -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexWithPoint(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) throw (SALOME::SALOME_Exception) { - ASSERT(myBaseImpl);; - string entry = GeomObj->GetStudyEntry(); - MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : UnsetEnforcedVertices ( "<< entry << ")"); + ASSERT(myBaseImpl); + + if (theFace->GetShapeType() != GEOM::FACE) + { + MESSAGE("theFace shape type is not FACE"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE", SALOME::BAD_PARAM); + } + if (theVertex->GetShapeType() != GEOM::VERTEX) + { + MESSAGE("theVertex shape type is not VERTEX"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX", SALOME::BAD_PARAM); + } + + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( this->GetImpl()->GetStudyId() ); + if (CORBA::is_nil(measureOp)) + return false; + + CORBA::Double x,y,z; + x = y = z = 0.; + measureOp->PointCoordinates (theVertex, x, y, z); + + std::string theFaceEntry = theFace->GetStudyEntry(); + std::string theVertexEntry = theVertex->GetStudyEntry(); + MESSAGE("IDL : UnsetEnforcedVertexWithPoint ( "<< theFaceEntry << ", " << theVertexEntry << ")"); try { - UnsetEnforcedVerticesEntry(entry.c_str()); + return UnsetEnforcedVertexEntryWithPoint(theFaceEntry.c_str(), theVertexEntry.c_str(), x, y, z); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); @@ -929,47 +1073,126 @@ void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr Geom } -/*! - * Set/get/unset an enforced vertex on geom object given by entry - */ -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* entry, double x, double y, double z) +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("IDL : SETENFORCEDVERTEX START - ENTRY: " << entry << " VERTEX: " << x << " " << y << " " << z); + + if (theFace->GetShapeType() != GEOM::FACE) + { + MESSAGE("theFace shape type is not FACE"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE", SALOME::BAD_PARAM); + } + + string theFaceEntry = theFace->GetStudyEntry(); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : UnsetEnforcedVertices ( "<< theFaceEntry << ")"); + + try { + return UnsetEnforcedVerticesEntry(theFaceEntry.c_str()); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +bool BLSURFPlugin_Hypothesis_i::_setEnfVertex(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* theVertexEntry, const char* enfName) +{ + ASSERT(myBaseImpl); + MESSAGE("_setEnfVertex(" << theFaceEntry << "," << x << "," << y << "," << z << "," << theVertexEntry<< "," << enfName << ")"); bool newValue = false; try { - ::BLSURFPlugin_Hypothesis::TEnfVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry); - ::BLSURFPlugin_Hypothesis::TEnfVertex vertex; - vertex.push_back(x); - vertex.push_back(y); - vertex.push_back(z); - if (vertexList.find(vertex) == vertexList.end()) { - MESSAGE("Vertex not found: add it in vertexList") + ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList coordsList = this->GetImpl()->GetCoords(theFaceEntry); + ::BLSURFPlugin_Hypothesis::TEnfVertexCoords coords; + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); + if (coordsList.find(coords) == coordsList.end()) { + MESSAGE("Coords not found: add it in coordsList") newValue = true; } else - MESSAGE("Vertex already found") + MESSAGE("Coords already found") } catch (const std::invalid_argument& ex) { // no enforced vertex for entry - MESSAGE("Entry not found : add it to the list") + MESSAGE("Face entry not found : add it to the list") newValue = true; } + + if ( newValue ) + this->GetImpl()->SetEnforcedVertex(theFaceEntry, x, y, z, enfName, theVertexEntry); + + return newValue; +} + +bool BLSURFPlugin_Hypothesis_i::_unsetEnfVertex(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z) +{ + ASSERT(myBaseImpl); + MESSAGE("_unsetEnfVertex(" << theFaceEntry << "," << x << "," << y << "," << z << ")"); + + try { + this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); + return true; + } + catch (const std::invalid_argument& ex) { + return false; + } +} + +/*! + * Set/get/unset an enforced vertex on geom object given by entry + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* enfName) + throw (SALOME::SALOME_Exception) +{ + MESSAGE("IDL : SetEnforcedVertexEntry START"); + bool newValue = false; + try { + newValue = _setEnfVertex(theFaceEntry, x, y, z, "", enfName); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - if ( newValue ) { - this->GetImpl()->SetEnforcedVertex(entry, x, y, z); + if ( newValue ) SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" - << entry << ", " - << x << ", " - << y << ", " - << z << ")"; + << theFaceEntry << ", " + << x << ", " + << y << ", " + << z << ", \"" + << enfName << "\")"; + MESSAGE("IDL : SetEnforcedVertexEntry END"); + return newValue; +} + +/*! + * Set/get/unset an enforced vertex on geom object given by entry + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntryWithPoint(const char* theFaceEntry, const char* theVertexEntry, const char* theVertexName, + CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception) +{ + MESSAGE("IDL : SetEnforcedVertexEntryWithPoint START - theFaceEntry=" << theFaceEntry << ", theVertexEntry=" << theVertexEntry); + + bool newValue = false; + + try { + newValue = _setEnfVertex(theFaceEntry, x, y, z, theVertexEntry, theVertexName); } - MESSAGE("IDL : SETENFORCEDVERTEX END - ENTRY: " << entry); + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + + if ( newValue ) + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithPoint(" + << theFaceEntry << ", " + << theVertexEntry << ")"; + + MESSAGE("IDL : SetEnforcedVertexEntryWithPoint END - FACE ENTRY: " << theFaceEntry); + return newValue; } /*! @@ -1045,7 +1268,7 @@ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntr throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("ENGINE : GETENFORCEDVERTICES START ENTRY : " << entry); + MESSAGE("ENGINE : GetEnforcedVerticesEntry START ENTRY : " << entry); try { BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList(); @@ -1054,14 +1277,34 @@ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntr MESSAGE("Number of enforced vertices: " << _vList.size()); ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin(); for ( int i = 0; evlIt != _vList.end() ; ++evlIt, ++i ) { + ::BLSURFPlugin_Hypothesis::TEnfVertex _enfVertex = (*evlIt); + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); - enfVertex->length(3); - MESSAGE("Enforced vertex #" << i << ": "<< (*evlIt)[0] << ", " << (*evlIt)[1] << ", " << (*evlIt)[2]); - enfVertex[0] = (*evlIt)[0]; - enfVertex[1] = (*evlIt)[1]; - enfVertex[2] = (*evlIt)[2]; + + // Name + enfVertex->name = CORBA::string_dup(_enfVertex.name.c_str()); + // Geom Vertex Entry + enfVertex->geomEntry = CORBA::string_dup(_enfVertex.geomEntry.c_str()); + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(3); + coords[0] = _enfVertex.coords[0]; + coords[1] = _enfVertex.coords[1]; + coords[2] = _enfVertex.coords[2]; + enfVertex->coords = coords; + // List of face entries + BLSURFPlugin::TEnfEntryList_var faceEntries = new BLSURFPlugin::TEnfEntryList(); + faceEntries->length(_enfVertex.faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEnfEntryList::const_iterator entryIt = _enfVertex.faceEntries.begin(); + for (int j=0 ; entryIt != _enfVertex.faceEntries.end() ; ++entryIt, ++j) { + faceEntries[j] = CORBA::string_dup(entryIt->c_str()); + } + enfVertex->faceEntries = faceEntries; + vertexList[i] = enfVertex; + MESSAGE("Enforced vertex #" << i << ": " << enfVertex->name << " = " << coords[0] << ", " << coords[1] << ", " << coords[2]); } + MESSAGE("ENGINE : GetEnforcedVerticesEntry END ENTRY : " << entry); return vertexList._retn(); } catch (const std::invalid_argument& ex) { @@ -1069,44 +1312,60 @@ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntr ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)"; - ExDescription.lineNumber = 1048; + ExDescription.lineNumber = 1265; throw SALOME::SALOME_Exception(ExDescription); } catch(const std::exception& ex) { + std::cout << "Exception: " << ex.what() << std::endl; THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - - MESSAGE("ENGINE : GETENFORCEDVERTICES END ENTRY : " << entry); } -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z) +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception) { - ASSERT(myBaseImpl); - MESSAGE("ENGINE : UNSETENFORCEDVERTEX START ENTRY : " << entry); - + MESSAGE("ENGINE : UnsetEnforcedVertexEntry START ENTRY : " << theFaceEntry); + bool ret = false; try { - this->GetImpl()->ClearEnforcedVertex(entry, x, y, z); + ret = _unsetEnfVertex(theFaceEntry, x, y, z); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + + if (ret) SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex(" - << entry << ", " + << theFaceEntry << ", " << x << ", " << y << ", " << z << ")"; + + MESSAGE("ENGINE : UnsetEnforcedVertexEntry END ENTRY : " << theFaceEntry); + return ret; +} + +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntryWithPoint(const char* theFaceEntry, const char* theVertexEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception) +{ + MESSAGE("IDL : UnsetEnforcedVertexEntryWithPoint START theFaceEntry=" << theFaceEntry << ", theVertexEntry=" << theVertexEntry); + + bool ret = false; + + try { + ret = _unsetEnfVertex(theFaceEntry, x, y, z); } - catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(entry,x,y,z)"; - ExDescription.lineNumber = 1086; - throw SALOME::SALOME_Exception(ExDescription); - } - catch(const std::exception& ex) { + catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } + + if (ret) + SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertexWithPoint(" + << theFaceEntry << ", " + << theVertexEntry << ")"; - MESSAGE("ENGINE : UNSETENFORCEDVERTEX END ENTRY : " << entry); + MESSAGE("IDL : UnsetEnforcedVertexEntryWithPoint END ENTRY : " << theFaceEntry); + return ret; } /* void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) @@ -1115,29 +1374,25 @@ void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, ASSERT(myBaseImpl); } */ -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* entry) +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("ENGINE : UNSETENFORCEDVERTICES START ENTRY : " << entry); + MESSAGE("IDL : UnsetEnforcedVerticesEntry START ENTRY : " << theFaceEntry); try { - this->GetImpl()->ClearEnforcedVertices(entry); - SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << entry << ")"; + this->GetImpl()->ClearEnforcedVertices(theFaceEntry); + SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << theFaceEntry << ")"; } catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(entry)"; - ExDescription.lineNumber = 1121; - throw SALOME::SALOME_Exception(ExDescription); + return false; } catch(const std::exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - MESSAGE("ENGINE : UNSETENFORCEDVERTICES END ENTRY : " << entry); + MESSAGE("IDL : UnsetEnforcedVerticesEntry END ENTRY : " << theFaceEntry); + return true; } /* TODO GROUPS diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index fc22a46..e3c2c60 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -145,67 +145,58 @@ class BLSURFPlugin_Hypothesis_i: // ENFORCED VERTEXES // /////////////////////// - BLSURFPlugin::TEntryEnfVertexListMap* GetAllEnforcedVertices(); - void ClearAllEnforcedVertices(); +// BLSURFPlugin::TEnfVertexList* GetAllEnforcedVertices(); + BLSURFPlugin::TEntryCoordsListMap* GetAllCoordsByFace(); + BLSURFPlugin::TCoordsEnfVertexMap* GetAllEnforcedVerticesByCoords(); + void ClearAllEnforcedVertices(); /*! * Set/get/unset an enforced vertex on geom object */ - void SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception); - /* TODO GROUPS - void SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr GeomObj, - CORBA::Double x, CORBA::Double y, CORBA::Double z, - const char* groupName) - throw (SALOME::SALOME_Exception); - */ -// void SetEnforcedVertexList(GEOM::GEOM_Object_ptr GeomObj, const BLSURFPlugin::TEnfVertexList& vertexList) -// throw (SALOME::SALOME_Exception); + bool SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* enfName="") throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexWithPoint(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) throw (SALOME::SALOME_Exception); +// TODO GROUPS +// void SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) throw (SALOME::SALOME_Exception); + +// void SetEnforcedVertexList(GEOM::GEOM_Object_ptr theFace, const BLSURFPlugin::TEnfVertexList& vertexList) throw (SALOME::SALOME_Exception); - BLSURFPlugin::TEnfVertexList* GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) - throw (SALOME::SALOME_Exception); + BLSURFPlugin::TEnfVertexList* GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) throw (SALOME::SALOME_Exception); - void UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception); + bool UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception); + bool UnsetEnforcedVertexWithPoint(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) throw (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexList(GEOM::GEOM_Object_ptr GeomObj, BLSURFPlugin::TEnfVertexList& vertexList) -// throw (SALOME::SALOME_Exception); +// void UnsetEnforcedVertexList(GEOM::GEOM_Object_ptr theFace, BLSURFPlugin::TEnfVertexList& vertexList) throw (SALOME::SALOME_Exception); - void UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) - throw (SALOME::SALOME_Exception); + bool UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) throw (SALOME::SALOME_Exception); /*! * Set/get/unset an enforced vertex on geom object given by entry */ - void SetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception); - /* TODO GROUPS - void SetEnforcedVertexEntryWithGroup(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z, - const char* groupName) - throw (SALOME::SALOME_Exception); - */ -// void SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) -// throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* enfName="") throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexEntryWithPoint(const char* theFaceEntry, const char* theVertexEntry, const char* theVertexName, + CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception); +// TODO GROUPS +// void SetEnforcedVertexEntryWithGroup(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) throw (SALOME::SALOME_Exception); + +// void SetEnforcedVertexListEntry(const char* theFaceEntry, BLSURFPlugin::TEnfVertexList& vertexList) throw (SALOME::SALOME_Exception); + + BLSURFPlugin::TEnfVertexList* GetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception); - BLSURFPlugin::TEnfVertexList* GetEnforcedVerticesEntry(const char* entry) - throw (SALOME::SALOME_Exception); + bool UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception); + bool UnsetEnforcedVertexEntryWithPoint(const char* theFaceEntry, const char* theVertexEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception); +// void UnsetEnforcedVertexListEntry(const char* theFaceEntry, BLSURFPlugin::TEnfVertexList& vertexList) throw (SALOME::SALOME_Exception); + bool UnsetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception); - void UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) -// throw (SALOME::SALOME_Exception); - void UnsetEnforcedVerticesEntry(const char* entry) - throw (SALOME::SALOME_Exception); + bool _setEnfVertex(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* theVertexEntry="", const char* enfName=""); + bool _unsetEnfVertex(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z); /*! * Set/get node group to an enforced vertex */ /* TODO GROUPS - void SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, - const char* groupName) - throw (SALOME::SALOME_Exception); - char* GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception); + void SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) throw (SALOME::SALOME_Exception); + char* GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception); */ /////////////////////// diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 33569f0..da754af 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -27,10 +27,13 @@ #include "BLSURFPluginGUI_HypothesisCreator.h" // #include +#include "GeometryGUI.h" + #include #include #include #include "SMESHGUI_SpinBox.h" +#include "SMESH_NumberFilter.hxx" #include #include @@ -65,13 +68,14 @@ #include #include #include +#include "SALOME_LifeCycleCORBA.hxx" -#include #include #include #include #include #include +#include #define WITH_SIZE_BOUNDARIES @@ -109,10 +113,11 @@ enum { SMP_NB_COLUMNS, // Enforced vertices array columns ENF_VER_NAME_COLUMN = 0, - ENF_VER_ENTRY_COLUMN, + ENF_VER_FACE_ENTRY_COLUMN, ENF_VER_X_COLUMN, ENF_VER_Y_COLUMN, ENF_VER_Z_COLUMN, + ENF_VER_ENTRY_COLUMN, // ENF_VER_GROUP_COLUMN, ENF_VER_NB_COLUMNS }; @@ -131,9 +136,9 @@ enum { // Enforced vertices inputs enum { -// ENF_VER_FACE = 0, -// ENF_VER_VERTEX, - ENF_VER_X_COORD = 0, + ENF_VER_FACE = 0, + ENF_VER_VERTEX, + ENF_VER_X_COORD, ENF_VER_Y_COORD, ENF_VER_Z_COORD, // ENF_VER_GROUP, @@ -183,8 +188,8 @@ static PyMethodDef PyStdOut_methods[] = { }; static PyMemberDef PyStdOut_memberlist[] = { - {"softspace", T_INT, offsetof(PyStdOut, softspace), 0, - "flag indicating that a space needs to be printed; used by print"}, + {(char *)"softspace", T_INT, offsetof(PyStdOut, softspace), 0, + (char *)"flag indicating that a space needs to be printed; used by print"}, {NULL} /* Sentinel */ }; @@ -460,6 +465,19 @@ GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() return that->GeomToolSelected; } +GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine() +{ + return GeometryGUI::GetGeomGen(); +// GEOM::GEOM_Gen_var _geomEngine = NULL; +// SalomeApp_Application* anApp = getGeomSelectionTool()->GetSalomeApplication(); +// if (anApp) { +// MESSAGE("Got Application"); +// Engines::Component_var component = anApp->lcc()->FindOrLoad_Component( "FactoryServer","GEOM" ); +// _geomEngine = GEOM::GEOM_Gen::_narrow(component); +// } +// return _geomEngine; +} + namespace { inline bool isDouble( const QString& theText, const bool emptyOK=false ) { QString str = theText.trimmed(); @@ -768,9 +786,11 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS ); myEnforcedTreeWidget->setSortingEnabled(true); QStringList enforcedHeaders; - enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_X_COLUMN" )<< tr( "BLSURF_ENF_VER_Y_COLUMN" ) << tr( "BLSURF_ENF_VER_Z_COLUMN" ); + enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN") + << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN") + << tr("BLSURF_ENF_VER_ENTRY_COLUMN"); /* TODO GROUPS - enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_X_COLUMN" )<< tr( "BLSURF_ENF_VER_Y_COLUMN" ) << tr( "BLSURF_ENF_VER_Z_COLUMN" ) << tr( "BLSURF_ENF_VER_GROUP_COLUMN" ); + << tr( "BLSURF_ENF_VER_GROUP_COLUMN" ); */ myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders); myEnforcedTreeWidget->setAlternatingRowColors(true); @@ -782,28 +802,27 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive); myEnforcedTreeWidget->resizeColumnToContents(column); } + myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN); myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN); myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate()); - /* TODO FACE AND VERTEX SELECTION - selectFaceButton = new QPushButton(myEnfGroup); - QPixmap imageSel1(SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "BLSURF_ICON_SELECT"))); - selectFaceButton->setIcon(imageSel1); +// FACE AND VERTEX SELECTION + TColStd_MapOfInteger shapeTypes1, shapeTypes2; + shapeTypes1.Add( TopAbs_FACE ); + shapeTypes1.Add( TopAbs_COMPOUND ); + shapeTypes2.Add( TopAbs_VERTEX ); + shapeTypes2.Add( TopAbs_COMPOUND ); + + SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1); + myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true); + myEnfFaceWdg->SetDefaultText("Select Faces", "QLineEdit { color: grey }"); + + SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX); + myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true); + myEnfVertexWdg->SetDefaultText("Select Vertices", "QLineEdit { color: grey }"); + + myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg); - mySelectedFace = new QLineEdit(myEnfGroup); - mySelectedFace->setReadOnly(true); - mySelectedFace->setText(tr( "BLSURF_ENF_SELECT_FACE")); - mySelectedFace->setStyleSheet("QLineEdit { color: grey }"); - - selectVertexButton = new QPushButton(myEnfGroup); - QPixmap imageSel2(SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "BLSURF_ICON_SELECT"))); - selectVertexButton->setIcon(imageSel2); - - mySelectedEnforcedVertex = new QLineEdit(myEnfGroup); - mySelectedEnforcedVertex->setReadOnly(true); - mySelectedEnforcedVertex->setText(tr( "BLSURF_ENF_SELECT_VERTEX")); - mySelectedEnforcedVertex->setStyleSheet("QLineEdit { color: grey }"); - */ QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup ); myXCoord = new SMESHGUI_SpinBox(myEnfGroup); myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); @@ -839,12 +858,10 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES+1, 1); - /* TODO FACE AND VERTEX SELECTION - anEnfLayout->addWidget(selectFaceButton, ENF_VER_FACE, 1, 1, 1); - anEnfLayout->addWidget(mySelectedFace, ENF_VER_FACE, 2, 1, 1); - anEnfLayout->addWidget(selectVertexButton, ENF_VER_VERTEX, 1, 1, 1); - anEnfLayout->addWidget(mySelectedEnforcedVertex, ENF_VER_VERTEX, 2, 1, 1); - */ +// FACE AND VERTEX SELECTION + anEnfLayout->addWidget(myEnfFaceWdg, ENF_VER_FACE, 1, 1, 2); + anEnfLayout->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 1, 1, 2); + anEnfLayout->addWidget(myXCoordLabel, ENF_VER_X_COORD, 1, 1, 1); anEnfLayout->addWidget(myXCoord, ENF_VER_X_COORD, 2, 1, 1); anEnfLayout->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 1, 1, 1); @@ -867,7 +884,6 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) ); tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) ); tab->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) ); -// tab->insertTab( ENF_TAB, myEnforcedVertexWidget, tr( "BLSURF_ENF_VER" ) ); tab->setCurrentIndex( STD_TAB ); @@ -889,6 +905,9 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) ); connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) ); connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) ); + connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) ); +// connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) ); +// connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) ); return fr; } @@ -927,6 +946,34 @@ void BLSURFPluginGUI_HypothesisCreator::update(QTreeWidgetItem* item, int column } } +void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() { + int nbSelEnfVertex = myEnfVertexWdg->NbObjects(); + if (nbSelEnfVertex != 0) + { + if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() ) + return ; + + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() ); + if (CORBA::is_nil(measureOp)) + return; + + for (int i=0; iGetObject< GEOM::GEOM_Object >(i); + CORBA::Double x,y,z; + x = y = z = 0.; + measureOp->PointCoordinates (myEnfVertex, x, y, z); + if ( measureOp->IsDone() ) + { + myXCoord->SetValue(x); + myYCoord->SetValue(y); + myZCoord->SetValue(z); + } + } + } +} + /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates of the enforced vertex clicked in the tree widget. @@ -958,19 +1005,19 @@ void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() { This method adds an enforced vertex (x,y,z) to shapeName in the tree widget. */ /* TODO GROUPS -void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std::string shapeName, - double x, double y, double z, std::string groupName) { +void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEntry, std::string theFaceName, + double x, double y, double z, std::string vertexName, std::string groupName) { */ -void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std::string shapeName, - double x, double y, double z) { - // Find entry item - QList theItemList = myEnforcedTreeWidget->findItems(QString(entry.c_str()),Qt::MatchExactly,ENF_VER_ENTRY_COLUMN); +void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEntry, std::string theFaceName, + double x, double y, double z, std::string vertexName, std::string geomEntry) { + // Find theFaceEntry item + QList theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN); QTreeWidgetItem* theItem; if (theItemList.empty()) { theItem = new QTreeWidgetItem(); - theItem->setData(ENF_VER_ENTRY_COLUMN, Qt::EditRole, QVariant(entry.c_str())); - theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(shapeName.c_str())); - theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(entry.c_str())); + theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str())); + theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str())); + theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str())); myEnforcedTreeWidget->addTopLevelItem(theItem); } else { @@ -1002,32 +1049,39 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std } } if (okToCreate) { - MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z<< " is created"); + MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created"); QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem); vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); int vertexIndex=1; - QString vertexName; + QString myVertexName; int indexRef = 0; while(indexRef != vertexIndex) { indexRef = vertexIndex; - vertexName = QString("Vertex #%1").arg(vertexIndex); + if (vertexName == "") + myVertexName = QString("Vertex #%1").arg(vertexIndex); + else + myVertexName = QString(vertexName.c_str()); + + for (int row = 0;rowchild(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString(); - if (vertexName == name) { + if (myVertexName == name) { vertexIndex++; break; } } } - vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, vertexName ); + vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName ); vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) ); vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) ); vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) ); + vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) ); + /* TODO GROUPS vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str())); */ - QString toolTip = QString(shapeName.c_str())+QString(": ")+vertexName; + QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName; toolTip += QString(" (%1, ").arg(x); toolTip += QString("%1, ").arg(y); toolTip += QString("%1)").arg(z); @@ -1037,10 +1091,10 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std } else /* TODO GROUPS - MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z << + MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again, only group name is updated with " << groupName); */ - MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again"); + MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again"); } /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() @@ -1049,50 +1103,104 @@ This method is called when a item is added into the enforced vertices tree widge void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() { // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices"); + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + + that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myEnfFaceWdg->deactivateSelection(); + myEnfVertexWdg->deactivateSelection(); + for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column) myEnforcedTreeWidget->resizeColumnToContents(column); - BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + // Vertex selection + int selEnfFace = myEnfFaceWdg->NbObjects(); + int selEnfVertex = myEnfVertexWdg->NbObjects(); + bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty()); - if ((myXCoord->text().isEmpty()) || - (myYCoord->text().isEmpty()) || - (myZCoord->text().isEmpty())) return; - - double x = myXCoord->GetValue(); - double y = myYCoord->GetValue(); - double z = myZCoord->GetValue(); - - /* TODO GROUPS - std::string groupName = myGroupName->text().toStdString(); - if (makeGroupsCheck->isChecked()) - groupName = myGlobalGroupName->text().toStdString(); - - if (boost::trim_copy(groupName) == "") - groupName = ""; - */ + if (selEnfFace == 0) + return; - TopAbs_ShapeEnum shapeType; + if ((selEnfVertex == 0) && coordsEmpty) + return; + string entry, shapeName; - GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool(); - LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr(); - SALOME_ListIO ListSelectedObjects; - mySel->selectedObjects(ListSelectedObjects, NULL, false ); - if (!ListSelectedObjects.IsEmpty()) { - SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects); - for (; Object_It.More(); Object_It.Next()) { - Handle(SALOME_InteractiveObject) anObject = Object_It.Value(); - entry = myGeomToolSelected->getEntryOfObject(anObject); - shapeName = anObject->getName(); - shapeType = myGeomToolSelected->entryToShapeType(entry); -// MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType); - if (shapeType == TopAbs_FACE) { - /* TODO GROUPS - addEnforcedVertex(entry, shapeName, x, y, z, groupName); - */ + + for (int i = 0 ; i < selEnfFace ; i++) { + myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i); + entry = myEnfFace->GetStudyEntry(); + shapeName = myEnfFace->GetName(); + +// // TODO GROUPS +// std::string groupName = myGroupName->text().toStdString(); +// if (makeGroupsCheck->isChecked()) +// groupName = myGlobalGroupName->text().toStdString(); +// +// if (boost::trim_copy(groupName) == "") +// groupName = ""; + + if (selEnfVertex <= 1) + { + double x,y,z; + x = myXCoord->GetValue(); + y = myYCoord->GetValue(); + z = myZCoord->GetValue(); +// // TODO GROUPS +// addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertexWdg->GetObject< GEOM::GEOM_Object >()->GetName(), groupName); + if (selEnfVertex == 1) { + myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(); + addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry()); + } + else +// // TODO GROUPS +// addEnforcedVertex(entry, shapeName, x, y, z, groupName); addEnforcedVertex(entry, shapeName, x, y, z); + } + else + { + if ( CORBA::is_nil(getGeomEngine())) + return; + + GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() ); + if (CORBA::is_nil(measureOp)) + return; + + CORBA::Double x,y,z; + x = y = z = 0.; + for (int j = 0 ; j < selEnfVertex ; j++) + { + myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j); + measureOp->PointCoordinates (myEnfVertex, x, y, z); + if ( measureOp->IsDone() ) + { +// // TODO GROUPS +// addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(), groupName); + addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry()); + } } } } + +// TopAbs_ShapeEnum shapeType; +// GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool(); +// LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr(); +// SALOME_ListIO ListSelectedObjects; +// mySel->selectedObjects(ListSelectedObjects, NULL, false ); +// if (!ListSelectedObjects.IsEmpty()) { +// SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects); +// for (; Object_It.More(); Object_It.Next()) { +// Handle(SALOME_InteractiveObject) anObject = Object_It.Value(); +// entry = myGeomToolSelected->getEntryOfObject(anObject); +// shapeName = anObject->getName(); +// shapeType = myGeomToolSelected->entryToShapeType(entry); +// // MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType); +// if (shapeType == TopAbs_FACE) { +// /* TODO GROUPS +// addEnforcedVertex(entry, shapeName, x, y, z, groupName); +// */ +// addEnforcedVertex(entry, shapeName, x, y, z); +// } +// } +// } for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column) myEnforcedTreeWidget->resizeColumnToContents(column); @@ -1239,34 +1347,40 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); // Enforced vertices -// MESSAGE("retrieveParams(): data.entryEnfVertexListMap.size() = " << data.entryEnfVertexListMap.size()); - std::map > >::const_iterator evmIt = data.entryEnfVertexListMap.begin(); - for ( ; evmIt != data.entryEnfVertexListMap.end() ; ++evmIt) { - std::string entry = (*evmIt).first; + MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.entryCoordsListMap.size()); + TEntryCoordsListMap::const_iterator evmIt = data.entryCoordsListMap.begin(); + for ( ; evmIt != data.entryCoordsListMap.end() ; ++evmIt) { + TEnfEntry entry = (*evmIt).first; std::string shapeName = myGeomToolSelected->getNameFromEntry(entry); + MESSAGE("Face entry: " << entry); + MESSAGE("Face name: " << shapeName); - std::set > evs; - std::set >::const_iterator evsIt; + TEnfVertexCoordsList evs; try { evs = (*evmIt).second; } catch(...) { -// MESSAGE("evs = (*evmIt)[entry]: FAIL"); + MESSAGE("evs = (*evmIt).second: FAIL"); break; } - evsIt = evs.begin(); + TEnfVertexCoordsList::const_iterator evsIt = evs.begin(); + TEnfVertex enfVertex; for ( ; evsIt != evs.end() ; ++evsIt) { - double x, y, z; - x = (*evsIt)[0]; - y = (*evsIt)[1]; - z = (*evsIt)[2]; - /* TODO GROUPS - std::string groupName = data.enfVertexGroupNameMap[(*evsIt)]; - MESSAGE("Vertex "<addEnforcedVertex(entry, shapeName, x, y, z, groupName); - */ - that->addEnforcedVertex(entry, shapeName, x, y, z); + TEnfVertexCoords coords = (*evsIt); + MESSAGE("Found coords: "<< coords[0] << ", " << coords[1] << ", " << coords[2]); + TCoordsEnfVertexMap::const_iterator it = data.coordsEnfVertexMap.find(coords); + if (it != data.coordsEnfVertexMap.end()) { + MESSAGE("Found enforced vertex"); + enfVertex = it->second; + MESSAGE("Name: " << enfVertex.name); + MESSAGE("Geom entry: " << enfVertex.geomEntry); + that->addEnforcedVertex(entry, shapeName, coords[0], coords[1], coords[2], enfVertex.name, enfVertex.geomEntry); + } + else { + MESSAGE("Enforced vertex NOT found") + that->addEnforcedVertex(entry, shapeName, coords[0], coords[1], coords[2]); + } } } for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column) @@ -1395,34 +1509,44 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData } // Enforced vertices - h_data.enfVertexList.clear(); - h_data.entryEnfVertexListMap.clear(); + h_data.coordsList.clear(); + h_data.entryCoordsListMap.clear(); + h_data.coordsEnfVertexMap.clear(); /* TODO GROUPS h_data.groupNameEnfVertexListMap.clear(); // h_data.enfVertexGroupNameMap.clear(); */ - BLSURFPlugin::TEntryEnfVertexListMap_var entryEnfVertexListMap = h->GetAllEnforcedVertices(); -// MESSAGE("entryEnfVertexListMap->length() = " << entryEnfVertexListMap->length()); + BLSURFPlugin::TEntryCoordsListMap_var entryCoordsListMap = h->GetAllCoordsByFace(); + MESSAGE("entryCoordsListMap->length() = " << entryCoordsListMap->length()); - for ( int i = 0;ilength(); ++i ) { - std::string entry = entryEnfVertexListMap[i].entry.in(); + for ( int i = 0;ilength(); ++i ) { + std::string entry = entryCoordsListMap[i].entry.in(); BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str()); - std::set > evs; + + TEnfVertexCoordsList& coordsList = h_data.entryCoordsListMap[entry]; /* TODO GROUPS std::string groupName = ""; */ for (int j=0 ; jlength(); ++j) { - double x = vertexList[j][0]; - double y = vertexList[j][1]; - double z = vertexList[j][2]; - std::vector ev; - ev.push_back(x); - ev.push_back(y); - ev.push_back(z); - evs.insert(ev); - h_data.enfVertexList.insert(ev); + BLSURFPlugin::TEnfVertexCoords _coords = vertexList[j].coords; + + TEnfVertexCoords coords; + coords.push_back(_coords[0]); + coords.push_back(_coords[1]); + coords.push_back(_coords[2]); + coordsList.insert(coords); + h_data.coordsList.insert(coords); + + TEnfVertex& enfVertex = h_data.coordsEnfVertexMap[coords]; + + enfVertex.name = vertexList[j].name.in(); + enfVertex.coords = coords; + enfVertex.faceEntries.insert(entry); + enfVertex.geomEntry = vertexList[j].geomEntry.in(); + /* TODO GROUPS + enfVertex.grpName = vertexList[j].grpName.in(); groupName.assign(h->GetEnforcedVertexGroupName(x, y, z)); MESSAGE("readParamsFromHypo, groupName = "< > >::const_iterator evmIt = h_data.entryEnfVertexListMap.begin(); - for ( ; evmIt != h_data.entryEnfVertexListMap.end() ; ++evmIt) { - std::string entry = evmIt->first; - std::set > evs; - std::set >::const_iterator evsIt; - double x, y, z; - /* TODO GROUPS - std::string groupName = ""; - */ - BLSURFPlugin::TEnfVertexList_var hypVertexList; - int hypNbVertex = 0; - try { - hypVertexList = h->GetEnforcedVerticesEntry(entry.c_str()); - hypNbVertex = hypVertexList->length(); - } - catch(...) { + bool ret; + int hypNbVertex; + double x, y, z; + std::string enfName; + /* TODO GROUPS + std::string groupName = ""; + */ + + TEntryCoordsListMap::const_iterator evmIt = h_data.entryCoordsListMap.begin(); + + BLSURFPlugin::TEntryCoordsListMap_var allCoordsByFace = h->GetAllCoordsByFace(); + hypNbVertex = allCoordsByFace->length(); + + // All enforced vertices were deleted + if (evmIt == h_data.entryCoordsListMap.end() && hypNbVertex!=0) + h->ClearAllEnforcedVertices(); + + // All enforced vertices for a specific entry were deleted + for (int i=0 ; iUnsetEnforcedVerticesEntry(entry.c_str()); } + } + + // One or several enforced vertices are added or removed for a specific entry + TEnfVertexCoordsList coordsFromHyp; + BLSURFPlugin::TEnfVertexList_var hypCoordsList; + TEnfName entry; + TEnfVertexCoordsList evs; + TEnfVertexCoordsList::const_iterator evsIt, coordsToRemove; + for ( ; evmIt != h_data.entryCoordsListMap.end() ; ++evmIt) { + MESSAGE("Enforced vertices for face entry " << evmIt->first); + entry = evmIt->first; evs = evmIt->second; evsIt = evs.begin(); - for ( ; evsIt != evs.end() ; ++evsIt) { - x = (*evsIt)[0]; - y = (*evsIt)[1]; - z = (*evsIt)[2]; + hypCoordsList = h->GetEnforcedVerticesEntry(entry.c_str()); + hypNbVertex = hypCoordsList->length(); + MESSAGE("Number of enforced vertices from hypothesis: " << hypNbVertex); + coordsFromHyp.clear(); + for (int i =0 ; isecond; + x = enfVertex.coords[0]; + y = enfVertex.coords[1]; + z = enfVertex.coords[2]; + if (enfVertex.geomEntry == "") + ret = h->SetEnforcedVertexEntry( entry.c_str(), x, y, z, enfVertex.name.c_str() ); + else + ret = h->SetEnforcedVertexEntryWithPoint( entry.c_str(), enfVertex.geomEntry.c_str(), enfVertex.name.c_str(), x, y, z ); + /* TODO GROUPS - std::map , std::string >::const_iterator grpIt = h_data.enfVertexGroupNameMap.find(*evsIt); - if (grpIt != h_data.enfVertexGroupNameMap.end()) - groupName = grpIt->second; -// MESSAGE("SetEnforcedVertexEntry("<SetEnforcedVertexEntryWithGroup( entry.c_str(), x, y, z, groupName.c_str() ); */ - h->SetEnforcedVertexEntry( entry.c_str(), x, y, z ); + + if (coordsFromHyp.find(coords) != coordsFromHyp.end()) { + MESSAGE("Coords "<0) { - for (int i =0 ; i vertex; - vertex.push_back(x); - vertex.push_back(y); - vertex.push_back(z); - if (evs.find(vertex) == evs.end()) { -// MESSAGE("UnsetEnforcedVertexEntry("<UnsetEnforcedVertexEntry( entry.c_str(), x, y, z ); - } + coordsToRemove = coordsFromHyp.begin(); + for ( ; coordsToRemove!=coordsFromHyp.end() ; ++coordsToRemove) { + coords = (*coordsToRemove); + x = coords[0]; + y = coords[1]; + z = coords[2]; + + it = h_data.coordsEnfVertexMap.find(coords); + if (it == h_data.coordsEnfVertexMap.end()) { + MESSAGE("Error vertex not found"); + throw std::runtime_error("Error vertex not found"); + } + enfVertex = it->second; + if (enfVertex.geomEntry == "") { + ret = h->UnsetEnforcedVertexEntry( entry.c_str(), x, y, z ); + } + else { + ret = h->UnsetEnforcedVertexEntryWithPoint( entry.c_str(), enfVertex.geomEntry.c_str(), x, y, z ); } + if (ret) + MESSAGE("SUCCESS"); } +// if (hypNbVertex >0) { +// for (int i =0 ; iUnsetEnforcedVertexEntry( entry.c_str(), x, y, z ); +// } +// } +// } } } - catch(const SALOME::SALOME_Exception& ex) - { - SalomeApp_Tools::QtCatchCorbaException(ex); - ok = false; + catch(const std::exception& ex) { + std::cout << "Exception: " << ex.what() << std::endl; + throw ex; } +// catch(const SALOME::SALOME_Exception& ex) +// { +// throw ex; +// // SalomeApp_Tools::QtCatchCorbaException(ex); +// // ok = false; +// } return ok; } @@ -1676,12 +1879,9 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes } // Enforced vertices - h_data.enfVertexList.clear(); - h_data.entryEnfVertexListMap.clear(); - /* TODO GROUPS - h_data.groupNameEnfVertexListMap.clear(); - h_data.enfVertexGroupNameMap.clear(); - */ + h_data.coordsList.clear(); + h_data.entryCoordsListMap.clear(); + h_data.coordsEnfVertexMap.clear(); int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount(); int nbEnforcedVertices = 0; @@ -1690,25 +1890,37 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes for (int i=0 ; itopLevelItem(i); if (shapeItem) { - std::string entry = shapeItem->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString(); + std::string entry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString(); nbEnforcedVertices = shapeItem->childCount(); if (nbEnforcedVertices >0) { double childValueX,childValueY,childValueZ; + std::string childName, vertexEntry; QTreeWidgetItem* child; - std::set > evs; + TEnfVertexCoordsList evs; for (row = 0;rowchild(row); + childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString(); childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble(); childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble(); childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble(); - std::vector vertex; - vertex.push_back(childValueX); - vertex.push_back(childValueY); - vertex.push_back(childValueZ); - evs.insert(vertex); - h_data.enfVertexList.insert(vertex); + vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString(); + TEnfVertexCoords coords; + coords.push_back(childValueX); + coords.push_back(childValueY); + coords.push_back(childValueZ); + evs.insert(coords); + h_data.coordsList.insert(coords); + + TEnfVertex enfVertex; + enfVertex.name = childName; + enfVertex.coords = coords; + enfVertex.faceEntries.insert(entry); + enfVertex.geomEntry = vertexEntry; + /* TODO GROUPS groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString(); + enfVertex.grpName = groupName; + // Group if (makeGroupsCheck->isChecked()) groupName = myGlobalGroupName->text().toStdString(); @@ -1716,8 +1928,9 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes if (groupName != "") h_data.groupNameEnfVertexListMap[groupName].insert(vertex); */ + h_data.coordsEnfVertexMap[coords] = enfVertex; } - h_data.entryEnfVertexListMap[entry] = evs; + h_data.entryCoordsListMap[entry] = evs; } } } @@ -1962,13 +2175,12 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis()); BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - - TopAbs_ShapeEnum shapeType; - string entry, shapeName; GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool(); LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr(); + TopAbs_ShapeEnum shapeType; + string entry, shapeName; SALOME_ListIO ListSelectedObjects; mySel->selectedObjects(ListSelectedObjects, NULL, false ); if (!ListSelectedObjects.IsEmpty()) @@ -2063,12 +2275,8 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt } else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) { // MESSAGE("Attractor" ); -// if ((that->mySMPMap[myEntry].count(QRegExp("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$")) != 1)) { if ((that->mySMPMap[myEntry].count(QRegExp("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$")) != 1)) { -// if ((that->mySMPMap[myEntry].count('(') != 1) or -// (that->mySMPMap[myEntry].count(')') != 1) or -// (that->mySMPMap[myEntry].count(';') != 4) or -// (that->mySMPMap[myEntry].size() == 15)){ + if (displayError) SUIT_MessageBox::warning( dlg(),"Definition of attractor : Error" ,"An attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False[;d])" ); return false; @@ -2105,9 +2313,9 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt fflush(stderr); err_description=""; new_stderr=newPyStdOut(err_description); - PySys_SetObject("stderr", new_stderr); + PySys_SetObject((char *)"stderr", new_stderr); PyErr_Print(); - PySys_SetObject("stderr", PySys_GetObject("__stderr__")); + PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__")); Py_DECREF(new_stderr); if (displayError) SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() ); @@ -2122,9 +2330,9 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt fflush(stderr); err_description=""; new_stderr=newPyStdOut(err_description); - PySys_SetObject("stderr", new_stderr); + PySys_SetObject((char *)"stderr", new_stderr); PyErr_Print(); - PySys_SetObject("stderr", PySys_GetObject("__stderr__")); + PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__")); Py_DECREF(new_stderr); if (displayError) SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() ); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index 63d105e..ffb57e2 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -50,6 +50,7 @@ #include #include +#include "StdMeshersGUI_ObjectReferenceParamWdg.h" #include #include #include @@ -57,6 +58,7 @@ #include #include #include +#include #include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm) class QGroupBox; @@ -75,6 +77,35 @@ class SMESHGUI_SpinBox; class LightApp_SelectionMgr; // class DlgBlSurfHyp_Enforced; +// Name +typedef std::string TEnfName; +// Entry +typedef std::string TEnfEntry; +// List of entries +typedef std::set TEnfEntryList; +// Enforced vertex = 3 coordinates +typedef std::vector TEnfVertexCoords; +// List of enforced vertices +typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList; + // Enforced vertex + typedef struct { + TEnfName name; + TEnfEntry geomEntry; + TEnfVertexCoords coords; + TEnfEntryList faceEntries; + // TODO GROUPS + TEnfName grpName; + } TEnfVertex; + +// List of enforced vertices +typedef std::set< TEnfVertex > TEnfVertexList; + + // Map Coords / Enforced vertex +typedef std::map< TEnfVertexCoords, TEnfVertex > TCoordsEnfVertexMap; + +// Map Entry / List of coords +typedef std::map< TEnfEntry, TEnfVertexCoordsList > TEntryCoordsListMap; + typedef struct { int myTopology, myVerbosity; @@ -82,11 +113,12 @@ typedef struct double myAngleMeshS, myAngleMeshC, myGradation; double myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax; bool myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex; - std::set > enfVertexList; - std::map > > entryEnfVertexListMap; + TEnfVertexCoordsList coordsList; + TEntryCoordsListMap entryCoordsListMap; + TCoordsEnfVertexMap coordsEnfVertexMap; /* TODO GROUPS - std::map > > groupNameEnfVertexListMap; - std::map , std::string > enfVertexGroupNameMap; + TGroupNameEnfVertexListMap groupNameEnfVertexListMap; + TEnfVertexGroupNameMap enfVertexGroupNameMap; */ QString myName; } BlsurfHypothesisData; @@ -131,13 +163,14 @@ protected slots: void onSetSizeMap(int,int); /* TODO GROUPS - void addEnforcedVertex(std::string, std::string, double, double, double, std::string); + void addEnforcedVertex(std::string, std::string, double, double, double, std::string, std::string); */ - void addEnforcedVertex(std::string, std::string, double, double, double); + void addEnforcedVertex(std::string theFaceEntry, std::string theFaceName, double x, double y, double z, std::string vertexName = "", std::string geomEntry = ""); void onAddEnforcedVertices(); void onRemoveEnforcedVertex(); void synchronizeCoords(); void update(QTreeWidgetItem* , int ); + void onSelectEnforcedVertex(); private: bool readParamsFromHypo( BlsurfHypothesisData& ) const; @@ -147,6 +180,7 @@ private: bool sizeMapValidationFromRow(int,bool displayError = true); bool sizeMapValidationFromEntry(QString,bool displayError = true); GeomSelectionTools* getGeomSelectionTool(); + GEOM::GEOM_Gen_var getGeomEngine(); private: QWidget* myStdGroup; @@ -178,14 +212,12 @@ private: QPushButton *removeButton; QWidget* myEnfGroup; - /* TODO FACE AND VERTEX SELECTION - QPushButton* selectFaceButton; - QLineEdit* mySelectedFace; -// GEOM::GEOM_Object_var myEnfFace; - QPushButton* selectVertexButton; - QLineEdit* mySelectedEnforcedVertex; -// GEOM::GEOM_Object_var myEnfVertex; - */ +// TODO FACE AND VERTEX SELECTION + StdMeshersGUI_ObjectReferenceParamWdg *myEnfFaceWdg; + GEOM::GEOM_Object_var myEnfFace; + StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg; + GEOM::GEOM_Object_var myEnfVertex; + // DlgBlSurfHyp_Enforced* myEnforcedVertexWidget; QTreeWidget* myEnforcedTreeWidget; SMESHGUI_SpinBox* myXCoord; diff --git a/src/GUI/BLSURFPlugin_msg_en.ts b/src/GUI/BLSURFPlugin_msg_en.ts index 5be52ec..a3e21dd 100644 --- a/src/GUI/BLSURFPlugin_msg_en.ts +++ b/src/GUI/BLSURFPlugin_msg_en.ts @@ -172,8 +172,8 @@ Enforced vertices - BLSURF_ENF_VER_ENTRY_COLUMN - Entry + BLSURF_ENF_VER_FACE_ENTRY_COLUMN + Face Entry BLSURF_ENF_VER_NAME_COLUMN @@ -191,6 +191,10 @@ BLSURF_ENF_VER_Z_COLUMN Z + + BLSURF_ENF_VER_ENTRY_COLUMN + Vertex Entry + BLSURF_ENF_VER_GROUP_COLUMN Group diff --git a/src/GUI/BLSURFPlugin_msg_fr.ts b/src/GUI/BLSURFPlugin_msg_fr.ts index 8ec88de..d509736 100755 --- a/src/GUI/BLSURFPlugin_msg_fr.ts +++ b/src/GUI/BLSURFPlugin_msg_fr.ts @@ -172,8 +172,8 @@ Points de passage - BLSURF_ENF_VER_ENTRY_COLUMN - Entrée + BLSURF_ENF_VER_FACE_ENTRY_COLUMN + ID de face BLSURF_ENF_VER_NAME_COLUMN @@ -191,6 +191,10 @@ BLSURF_ENF_VER_Z_COLUMN Z + + BLSURF_ENF_VER_ENTRY_COLUMN + ID de point + BLSURF_ENF_VER_GROUP_COLUMN Groupe diff --git a/src/GUI/Makefile.am b/src/GUI/Makefile.am index b77c1dd..ea115f0 100644 --- a/src/GUI/Makefile.am +++ b/src/GUI/Makefile.am @@ -64,7 +64,7 @@ libBLSURFPluginGUI_la_LDFLAGS = \ $(QT_LIBS) \ ../BLSURFPlugin/libBLSURFEngine.la \ $(GUI_LDFLAGS) -lqtx -lSalomeApp -lsuit -lSalomeObject -lLightApp \ - ${SMESH_LDFLAGS} -lSMESH -lGeomSelectionTools \ + ${SMESH_LDFLAGS} -lSMESH -lGeomSelectionTools -lStdMeshersGUI \ $(CAS_KERNEL) $(BLSURF_LIBS) # resources files