From: gdd Date: Wed, 16 Mar 2011 15:55:54 +0000 (+0000) Subject: Merge from V6_main X-Git-Tag: GeodesicAttracor_V0_1_20110321 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8ba5f523bbd7c36b4473e67798f44b77e43f44a4;p=plugins%2Fblsurfplugin.git Merge from V6_main --- diff --git a/clean_configure b/clean_configure index 4ce737c..05683d1 100755 --- a/clean_configure +++ b/clean_configure @@ -35,5 +35,15 @@ find idl -name Makefile.in | xargs rm -f find resources -name Makefile.in | xargs rm -f find adm_local -name Makefile.in | xargs rm -f find src -name Makefile.in | xargs rm -f +rm -f adm_local/unix/config_files/config* +rm -f adm_local/unix/config_files/depcomp +rm -f adm_local/unix/config_files/install-sh +rm -f adm_local/unix/config_files/libtool.m4 +rm -f adm_local/unix/config_files/ltmain.sh +rm -f adm_local/unix/config_files/ltoptions.m4 +rm -f adm_local/unix/config_files/ltsugar.m4 +rm -f adm_local/unix/config_files/ltversion.m4 +rm -f adm_local/unix/config_files/lt~obsolete.m4 +rm -f adm_local/unix/config_files/missing rm -f Makefile.in rm -Rf salome_adm diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 12d2440..d476008 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -40,12 +40,12 @@ module BLSURFPlugin // Enforced vertex name typedef string TEnfName; // Entry - typedef string TEnfEntry; - typedef sequence TEnfEntryList; + typedef string TEntry; + typedef sequence TEntryList; // Group name typedef string TEnfGroupName; - // Coordinates of enforced vertex (old enforced vertex) + // Coordinates of enforced vertex typedef sequence TEnfVertexCoords; // List of coords typedef sequence TEnfVertexCoordsList; @@ -53,14 +53,34 @@ module BLSURFPlugin // Enforced vertex struct TEnfVertex { TEnfName name; - TEnfEntry geomEntry; + TEntry geomEntry; TEnfVertexCoords coords; - TEnfEntryList faceEntries; -// TODO GROUPS TEnfGroupName grpName; + TEntryList faceEntries; }; // List of enforced vertices typedef sequence TEnfVertexList; + + // Map Face Entry / List of enforced vertices + struct TFaceEntryEnfVertexListMapElement { + TEntry faceEntry; + TEnfVertexList enfVertexList; + }; + typedef sequence TFaceEntryEnfVertexListMap; + + // Map Face Entry / List of coords + struct TFaceEntryCoordsListMapElement { + TEntry faceEntry; + TEnfVertexCoordsList coordsList; + }; + typedef sequence TFaceEntryCoordsListMap; + + // Map Face Entry / List of enf vertex entries + struct TFaceEntryEnfVertexEntryListMapElement { + TEntry faceEntry; + TEntryList enfVertexEntryList; + }; + typedef sequence TFaceEntryEnfVertexEntryListMap; // Map Coords / Enforced vertex struct TCoordsEnfVertexElement { @@ -69,12 +89,12 @@ module BLSURFPlugin }; typedef sequence TCoordsEnfVertexMap; - // Map Entry / List of coords - struct TEntryCoordsListMapElement { - string entry; - TEnfVertexCoordsList coordsList; + // Map Enf Vertex Entry / Enforced vertex + struct TEnfVertexEntryEnfVertexElement { + TEntry enfVertexEntry; + TEnfVertex enfVertex; }; - typedef sequence TEntryCoordsListMap; + typedef sequence TEnfVertexEntryEnfVertexMap; // Attractors struct TAttractorParams { @@ -86,39 +106,14 @@ module BLSURFPlugin double constDist; }; typedef sequence TAttParamsMap; - -// // ////////////// 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; // Map Group Name / List of enforced vertices struct TGroupNameEnfVertexListMapElement { TEnfGroupName groupName; TEnfVertexList vertexList; }; typedef sequence TGroupNameEnfVertexListMap; - // Map Enforced vertex / Group Name - struct TEnfVertexGroupNameMapElement { - TEnfVertex vertex; - TEnfGroupName groupName; - }; - typedef sequence TEnfVertexGroupNameMap; */ @@ -308,45 +303,51 @@ module BLSURFPlugin // ENFORCED VERTEXES // /////////////////////// -// TEnfVertexList GetAllEnforcedVertices(); - TEntryCoordsListMap GetAllCoordsByFace(); - TCoordsEnfVertexMap GetAllEnforcedVerticesByCoords(); - void ClearAllEnforcedVertices(); + TFaceEntryEnfVertexListMap GetAllEnforcedVerticesByFace(); + TEnfVertexList GetAllEnforcedVertices(); + + TFaceEntryCoordsListMap GetAllCoordsByFace(); + TCoordsEnfVertexMap GetAllEnforcedVerticesByCoords(); + + TFaceEntryEnfVertexEntryListMap GetAllEnfVertexEntriesByFace(); + TEnfVertexEntryEnfVertexMap GetAllEnforcedVerticesByEnfVertexEntry(); + + void ClearAllEnforcedVertices(); /*! * Set/get/unset an enforced vertex on geom face */ - 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 theFace, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); - */ -// void SetEnforcedVertexList(in GEOM::GEOM_Object theFace, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertex(in GEOM::GEOM_Object theFace, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexNamed(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfName theVertexName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexGeom(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexWithGroup(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexNamedWithGroup(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfName theVertexName, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexGeomWithGroup(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); + TEnfVertexList GetEnforcedVertices(in GEOM::GEOM_Object theFace) 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 UnsetEnforcedVertexGeom(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex) raises (SALOME::SALOME_Exception); boolean UnsetEnforcedVertices(in GEOM::GEOM_Object theFace) raises (SALOME::SALOME_Exception); /*! * Set/get/unset an enforced vertex on geom face given by entry */ - 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); + boolean SetEnforcedVertexEntry(in TEntry theFaceEntry, in double x, in double y, in double z, + in TEnfName theVertexName, in TEntry theVertexEntry, in string groupName) raises (SALOME::SALOME_Exception); +// boolean SetEnforcedVertexEntryNamed(in TEntry theFaceEntry, in double x, in double y, in double z, in TEnfName theVertexName) raises (SALOME::SALOME_Exception); +// boolean SetEnforcedVertexEntryGeom(in TEntry theFaceEntry, in TEntry theVertexEntry, in TEnfName theVertexName) raises (SALOME::SALOME_Exception); /* TODO GROUPS void SetEnforcedVertexEntryWithGroup(in string theFaceEntry, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); */ -// void SetEnforcedVertexListEntry(in string theFaceEntry, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); // - TEnfVertexList GetEnforcedVerticesEntry(in string theFaceEntry) raises (SALOME::SALOME_Exception); + TEnfVertexList GetEnforcedVerticesEntry(in TEntry theFaceEntry) 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); + boolean UnsetEnforcedVertexEntry(in TEntry theFaceEntry, in double x, in double y, in double z, in TEntry theVertexEntry) raises (SALOME::SALOME_Exception); +// boolean UnsetEnforcedVertexEntryGeom(in TEntry theFaceEntry, in TEntry theVertexEntry) raises (SALOME::SALOME_Exception); + boolean UnsetEnforcedVerticesEntry(in TEntry 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 c7afef1..6ddda40 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[] = { - {(char *)"softspace", T_INT, offsetof(PyStdOut, softspace), 0, - (char *)"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 */ }; @@ -218,8 +218,9 @@ std::map FaceId2ClassAttractor; std::map FaceIndex2ClassAttractor; TopTools_IndexedMapOfShape FacesWithEnforcedVertices; -std::map< int, std::set< std::vector > > FaceId2EnforcedVertexCoords; -std::map< std::vector, std::vector > EnfVertex2ProjVertex; +std::map< int, BLSURFPlugin_Hypothesis::TEnfVertexCoordsList > FaceId2EnforcedVertexCoords; +std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexCoords > EnfVertexCoords2ProjVertex; +std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexList > EnfVertexCoords2EnfVertexList; bool HasSizeMapOnFace=false; bool HasSizeMapOnEdge=false; @@ -284,7 +285,8 @@ BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId, FaceIndex2ClassAttractor.clear(); FacesWithEnforcedVertices.Clear(); FaceId2EnforcedVertexCoords.clear(); - EnfVertex2ProjVertex.clear(); + EnfVertexCoords2ProjVertex.clear(); + EnfVertexCoords2EnfVertexList.clear(); } //============================================================================= @@ -377,7 +379,7 @@ typedef struct { gp_XYZ xyz; } projectionPoint; ///////////////////////////////////////////////////////// -projectionPoint getProjectionPoint(const TopoDS_Face& face, const gp_XYZ& point) +projectionPoint getProjectionPoint(const TopoDS_Face& face, const gp_Pnt& point) { projectionPoint myPoint; Handle(Geom_Surface) surface = BRep_Tool::Surface(face); @@ -396,7 +398,7 @@ projectionPoint getProjectionPoint(const TopoDS_Face& face, const gp_XYZ& point) ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// -double getT(const TopoDS_Edge& edge, const gp_XYZ& point) +double getT(const TopoDS_Edge& edge, const gp_Pnt& point) { Standard_Real f,l; Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, f,l); @@ -426,85 +428,111 @@ TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry) return S; } -///////////////////////////////////////////////////////// -void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis::TEnfVertexCoordsList coordsList) +void _createEnforcedVertexOnFace(TopoDS_Face faceShape, gp_Pnt aPnt, BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex) { - double xe, ye, ze; - BLSURFPlugin_Hypothesis::TEnfVertexCoords coords; - BLSURFPlugin_Hypothesis::TEnfVertexCoords s_coords; - BLSURFPlugin_Hypothesis::TEnfVertexCoords enfVertexCoords; -// BLSURFPlugin_Hypothesis::TEnfVertex enfVertex; - - BLSURFPlugin_Hypothesis::TEnfVertexCoordsList::const_iterator coordsListIt = coordsList.begin(); - - for( ; coordsListIt != coordsList.end() ; ++coordsListIt ) { - coords.clear(); - s_coords.clear(); - 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)); - gp_XY uvPoint = myPoint.uv; - gp_XYZ xyzPoint = myPoint.xyz; - Standard_Real u0 = uvPoint.X(); - Standard_Real v0 = uvPoint.Y(); - Standard_Real x0 = xyzPoint.X(); - Standard_Real y0 = xyzPoint.Y(); - Standard_Real z0 = xyzPoint.Z(); - MESSAGE("Projected Vertex: " << x0 << ", " << y0 << ", " << z0); - MESSAGE("Parametric coordinates: " << u0 << ", " << v0 ); - coords.push_back(u0); - coords.push_back(v0); - coords.push_back(x0); - coords.push_back(y0); - coords.push_back(z0); - - s_coords.push_back(x0); - s_coords.push_back(y0); - s_coords.push_back(z0); - - // Save pair projected vertex / enf vertex - MESSAGE("Storing pair projected vertex / enf vertex:"); - MESSAGE("("<< x0 << ", " << y0 << ", " << z0 <<") / (" << xe << ", " << ye << ", " << ze<<")"); - EnfVertex2ProjVertex[s_coords] = enfVertexCoords; - - int key = 0; - if (! FacesWithEnforcedVertices.Contains(TopoDS::Face(GeomShape))) { - key = FacesWithEnforcedVertices.Add(TopoDS::Face(GeomShape)); - } - else { - key = FacesWithEnforcedVertices.FindIndex(TopoDS::Face(GeomShape)); + BLSURFPlugin_Hypothesis::TEnfVertexCoords enf_coords, coords, s_coords; + enf_coords.clear(); + coords.clear(); + s_coords.clear(); + + // Get the (u,v) values of the enforced vertex on the face + projectionPoint myPoint = getProjectionPoint(faceShape,aPnt); + + MESSAGE("Enforced Vertex: " << aPnt.X() << ", " << aPnt.Y() << ", " << aPnt.Z()); + MESSAGE("Projected Vertex: " << myPoint.xyz.X() << ", " << myPoint.xyz.Y() << ", " << myPoint.xyz.Z()); + MESSAGE("Parametric coordinates: " << myPoint.uv.X() << ", " << myPoint.uv.Y() ); + + enf_coords.push_back(aPnt.X()); + enf_coords.push_back(aPnt.Y()); + enf_coords.push_back(aPnt.Z()); + + coords.push_back(myPoint.uv.X()); + coords.push_back(myPoint.uv.Y()); + coords.push_back(myPoint.xyz.X()); + coords.push_back(myPoint.xyz.Y()); + coords.push_back(myPoint.xyz.Z()); + + s_coords.push_back(myPoint.xyz.X()); + s_coords.push_back(myPoint.xyz.Y()); + s_coords.push_back(myPoint.xyz.Z()); + + // Save pair projected vertex / enf vertex + MESSAGE("Storing pair projected vertex / enf vertex:"); + MESSAGE("("<< myPoint.xyz.X() << ", " << myPoint.xyz.Y() << ", " << myPoint.xyz.Z() <<") / (" << aPnt.X() << ", " << aPnt.Y() << ", " << aPnt.Z()<<")"); + EnfVertexCoords2ProjVertex[s_coords] = enf_coords; + MESSAGE("Group name is: \"" << enfVertex->grpName << "\""); + EnfVertexCoords2EnfVertexList[s_coords].insert(enfVertex); + + int key = 0; + if (! FacesWithEnforcedVertices.Contains(faceShape)) { + key = FacesWithEnforcedVertices.Add(faceShape); + } + else { + key = FacesWithEnforcedVertices.FindIndex(faceShape); + } + + // If a node is already created by an attractor, do not create enforced vertex + int attractorKey = FacesWithSizeMap.FindIndex(faceShape); + bool sameAttractor = false; + if (attractorKey >= 0) + if (FaceId2AttractorCoords.count(attractorKey) > 0) + if (FaceId2AttractorCoords[attractorKey] == coords) + sameAttractor = true; + + if (FaceId2EnforcedVertexCoords.find(key) != FaceId2EnforcedVertexCoords.end()) { + MESSAGE("Map of enf. vertex has key " << key) + MESSAGE("Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size()) + if (! sameAttractor) + FaceId2EnforcedVertexCoords[key].insert(coords); // there should be no redondant coords here (see std::set management) + else + MESSAGE("An attractor node is already defined: I don't add the enforced vertex"); + MESSAGE("New Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size()) + } + else { + MESSAGE("Map of enf. vertex has not key " << key << ": creating it") + if (! sameAttractor) { + BLSURFPlugin_Hypothesis::TEnfVertexCoordsList ens; + ens.insert(coords); + FaceId2EnforcedVertexCoords[key] = ens; } + else + MESSAGE("An attractor node is already defined: I don't add the enforced vertex"); + } +} - // If a node is already created by an attractor, do not create enforced vertex - int attractorKey = FacesWithSizeMap.FindIndex(TopoDS::Face(GeomShape)); - bool sameAttractor = false; - if (attractorKey >= 0) - if (FaceId2AttractorCoords.count(attractorKey) > 0) - if (FaceId2AttractorCoords[attractorKey] == coords) - sameAttractor = true; - - if (FaceId2EnforcedVertexCoords.find(key) != FaceId2EnforcedVertexCoords.end()) { - MESSAGE("Map of enf. vertex has key " << key) - MESSAGE("Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size()) - if (! sameAttractor) - FaceId2EnforcedVertexCoords[key].insert(coords); // there should be no redondant coords here (see std::set management) - else - MESSAGE("An attractor node is already defined: I don't add the enforced vertex"); - MESSAGE("New Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size()) +///////////////////////////////////////////////////////// +void BLSURFPlugin_BLSURF::createEnforcedVertexOnFace(TopoDS_Shape faceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList) +{ + BLSURFPlugin_Hypothesis::TEnfVertex* enfVertex; + gp_Pnt aPnt; + + BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator enfVertexListIt = enfVertexList.begin(); + + for( ; enfVertexListIt != enfVertexList.end() ; ++enfVertexListIt ) { + enfVertex = *enfVertexListIt; + // Case of manual coords + if (enfVertex->coords.size() != 0) { + aPnt.SetCoord(enfVertex->coords[0],enfVertex->coords[1],enfVertex->coords[2]); + _createEnforcedVertexOnFace( TopoDS::Face(faceShape), aPnt, enfVertex); } - else { - MESSAGE("Map of enf. vertex has not key " << key << ": creating it") - if (! sameAttractor) { - std::set< std::vector > ens; - ens.insert(coords); - FaceId2EnforcedVertexCoords[key] = ens; - } - else - MESSAGE("An attractor node is already defined: I don't add the enforced vertex"); + + // Case of geom vertex coords + if (enfVertex->geomEntry != "") { + TopoDS_Shape GeomShape = entryToShape(enfVertex->geomEntry); + TopAbs_ShapeEnum GeomType = GeomShape.ShapeType(); + if (GeomType == TopAbs_VERTEX){ + aPnt = BRep_Tool::Pnt(TopoDS::Vertex(GeomShape)); + _createEnforcedVertexOnFace( TopoDS::Face(faceShape), aPnt, enfVertex); + } + // Group Management + if (GeomType == TopAbs_COMPOUND){ + for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){ + if (it.Value().ShapeType() == TopAbs_VERTEX){ + aPnt = BRep_Tool::Pnt(TopoDS::Vertex(it.Value())); + _createEnforcedVertexOnFace( TopoDS::Face(faceShape), aPnt, enfVertex); + } + } + } } } } @@ -571,7 +599,7 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction } // Get the (u,v) values of the attractor on the face - projectionPoint myPoint = getProjectionPoint(TopoDS::Face(GeomShape),gp_XYZ(xa,ya,za)); + projectionPoint myPoint = getProjectionPoint(TopoDS::Face(GeomShape),gp_Pnt(xa,ya,za)); gp_XY uvPoint = myPoint.uv; gp_XYZ xyzPoint = myPoint.xyz; Standard_Real u0 = uvPoint.X(); @@ -891,25 +919,25 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, // Enforced Vertices // MESSAGE("Setting Enforced Vertices"); - 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); + const BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap entryEnfVertexListMap = BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(hyp); + BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap::const_iterator enfIt = entryEnfVertexListMap.begin(); + for ( ; enfIt != entryEnfVertexListMap.end(); ++enfIt ) { + if ( !enfIt->second.empty() ) { + GeomShape = entryToShape(enfIt->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(), coordsIt->second); + createEnforcedVertexOnFace(it.Value(), enfIt->second); } } } if (GeomType == TopAbs_FACE){ HasSizeMapOnFace = true; - createEnforcedVertexOnFace(GeomShape, coordsIt->second); + createEnforcedVertexOnFace(GeomShape, enfIt->second); } } } @@ -1137,23 +1165,20 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) // Enforced Vertices faceKey = FacesWithEnforcedVertices.FindIndex(f); - std::map > >::const_iterator evmIt = FaceId2EnforcedVertexCoords.find(faceKey); + std::map::const_iterator evmIt = FaceId2EnforcedVertexCoords.find(faceKey); if (evmIt != FaceId2EnforcedVertexCoords.end()) { MESSAGE("Some enforced vertices are defined"); -// int ienf = 0; - std::set > evl; -// std::vector ev; + BLSURFPlugin_Hypothesis::TEnfVertexCoordsList evl; MESSAGE("Face indice: " << iface); MESSAGE("Adding enforced vertices"); evl = evmIt->second; MESSAGE("Number of vertices to add: "<< evl.size()); - std::set< std::vector >::const_iterator evlIt = evl.begin(); + BLSURFPlugin_Hypothesis::TEnfVertexCoordsList::const_iterator evlIt = evl.begin(); for (; evlIt != evl.end(); ++evlIt) { - std::vector xyzCoords; + BLSURFPlugin_Hypothesis::TEnfVertexCoords xyzCoords; xyzCoords.push_back(evlIt->at(2)); xyzCoords.push_back(evlIt->at(3)); xyzCoords.push_back(evlIt->at(4)); -// double xyzCoords[3] = {evlIt->at(2), evlIt->at(3), evlIt->at(4)}; MESSAGE("Check position of vertex =(" << xyzCoords[0] << "," << xyzCoords[1] << "," << xyzCoords[2] << ")"); gp_Pnt P(xyzCoords[0],xyzCoords[1],xyzCoords[2]); BRepClass_FaceClassifier scl(f,P,1e-7); @@ -1163,25 +1188,30 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) TopAbs_State result = scl.State(); MESSAGE("Position of point on face: "<at(0),evlIt->at(1)}; ienf++; MESSAGE("Add cad point on (u,v)=(" << uvCoords[0] << "," << uvCoords[1] << ") with id = " << ienf); @@ -1268,7 +1298,6 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) if(*ip <= 0) *ip = pmap.Add(v); - //vertexKey = VerticesWithSizeMap.FindIndex(v); if (HasSizeMapOnVertex){ vertexKey = VerticesWithSizeMap.FindIndex(v); if (VertexId2SizeMap.find(vertexKey)!=VertexId2SizeMap.end()){ @@ -1394,73 +1423,64 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) } nodes[iv] = meshDS->AddNode(xyz[0], xyz[1], xyz[2]); - /* TODO GROUPS // Create group of enforced vertices if requested if(_hypothesis) { - std::vector projVertex; + BLSURFPlugin_Hypothesis::TEnfVertexCoords projVertex; + projVertex.clear(); projVertex.push_back((double)xyz[0]); projVertex.push_back((double)xyz[1]); projVertex.push_back((double)xyz[2]); - std::map< std::vector, std::vector >::const_iterator projIt = EnfVertex2ProjVertex.find(projVertex); - if (projIt != EnfVertex2ProjVertex.end()) { - double x = (projIt->second)[0]; - double y = (projIt->second)[1]; - double z = (projIt->second)[2]; - BLSURFPlugin_Hypothesis::TEnfVertex enfVertex; - enfVertex.push_back(x); - enfVertex.push_back(y); - enfVertex.push_back(z); - - BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap groupNameMap = _hypothesis->_GetEnforcedVertexGroupNameMap(); - BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap::const_iterator groupNameMapIt = groupNameMap.find(enfVertex); - if (groupNameMapIt != groupNameMap.end()) { - MESSAGE("Found enforced vertex @ " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]) - BLSURFPlugin_Hypothesis::TEnfGroupName groupName = groupNameMapIt->second; - if (groupName != "") { + std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexList >::const_iterator enfCoordsIt = EnfVertexCoords2EnfVertexList.find(projVertex); + if (enfCoordsIt != EnfVertexCoords2EnfVertexList.end()) { + MESSAGE("Found enforced vertex @ " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]) + BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator enfListIt = enfCoordsIt->second.begin(); + BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex; + for (; enfListIt != enfCoordsIt->second.end(); ++enfListIt) { + currentEnfVertex = (*enfListIt); + if (currentEnfVertex->grpName != "") { bool groupDone = false; - const set& allGroups = meshDS->GetGroups(); - set::const_iterator grIt; + SMESH_Mesh::GroupIteratorPtr grIt = aMesh.GetGroups(); + MESSAGE("currentEnfVertex->grpName: " << currentEnfVertex->grpName); MESSAGE("Parsing the groups of the mesh"); - for ( grIt = allGroups.begin(); grIt != allGroups.end(); ++grIt ) { - SMESHDS_Group* group = dynamic_cast( *grIt ); - MESSAGE("Group: " << group->GetStoreName()); - if ( group && group->SMDSGroup().GetType()==SMDSAbs_Node - && groupName.compare(group->GetStoreName())==0) { - group->SMDSGroup().Add(nodes[iv]); -// int id = // recuperer l'id SMESH du noeud -// _hypothesis->AddEnfVertexIDs(groupName,id) + while (grIt->more()) { + SMESH_Group * group = grIt->next(); + if ( !group ) continue; + MESSAGE("Group: " << group->GetName()); + SMESHDS_GroupBase* groupDS = group->GetGroupDS(); + if ( !groupDS ) continue; + MESSAGE("group->SMDSGroup().GetType(): " << (groupDS->GetType())); + MESSAGE("group->SMDSGroup().GetType()==SMDSAbs_Node: " << (groupDS->GetType()==SMDSAbs_Node)); + MESSAGE("currentEnfVertex->grpName.compare(group->GetStoreName())==0: " << (currentEnfVertex->grpName.compare(group->GetName())==0)); + if ( groupDS->GetType()==SMDSAbs_Node && currentEnfVertex->grpName.compare(group->GetName())==0) { + SMESHDS_Group* aGroupDS = static_cast( groupDS ); + aGroupDS->SMDSGroup().Add(nodes[iv]); + MESSAGE("Node ID: " << nodes[iv]->GetID()); + // How can I inform the hypothesis ? +// _hypothesis->AddEnfVertexNodeID(currentEnfVertex->grpName,nodes[iv]->GetID()); groupDone = true; - MESSAGE("Successfully added enforced vertex to existing group " << groupName); + MESSAGE("Successfully added enforced vertex to existing group " << currentEnfVertex->grpName); break; } } if (!groupDone) { int groupId; - SMESH_Group* aGroup = aMesh.AddGroup(SMDSAbs_Node, groupName.c_str(), groupId); - if ( aGroup ) { - SMESHDS_Group* aGroupDS = dynamic_cast( aGroup->GetGroupDS() ); - if ( aGroupDS ) { - aGroupDS->SetStoreName( groupName.c_str() ); - aGroupDS->SMDSGroup().Add(nodes[iv]); - MESSAGE("Successfully created enforced vertex group " << groupName); - groupDone = true; - } - } + SMESH_Group* aGroup = aMesh.AddGroup(SMDSAbs_Node, currentEnfVertex->grpName.c_str(), groupId); + aGroup->SetName( currentEnfVertex->grpName.c_str() ); + SMESHDS_Group* aGroupDS = static_cast( aGroup->GetGroupDS() ); + aGroupDS->SMDSGroup().Add(nodes[iv]); + MESSAGE("Successfully created enforced vertex group " << currentEnfVertex->grpName); + groupDone = true; } if (!groupDone) throw SALOME_Exception(LOCALIZED("A enforced vertex node was not added to a group")); } else - MESSAGE("Group name is empty: '"< group is not created"); + MESSAGE("Group name is empty: '"<grpName<<"' => group is not created"); } - else - MESSAGE("No group name for projected vertex ("< 0 && tag <= pmap.Extent() ){ @@ -1540,7 +1560,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) if ( SMESH_subMesh* sm = aMesh.GetSubMeshContaining( emap( i ))) sm->SetIsAlwaysComputed( true ); - delete nodes; + delete [] nodes; /* release the mesh object */ blsurf_data_regain_mesh(bls, msh); @@ -1768,15 +1788,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],(char *)"(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((char *)"stderr", new_stderr); + PySys_SetObject((char*)"stderr", new_stderr); PyErr_Print(); - PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__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); @@ -1790,7 +1810,7 @@ status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data) PyGILState_Release(gstate); } else if (FaceIndex2ClassAttractor.count(face_id) !=0 && !FaceIndex2ClassAttractor[face_id]->Empty()){ - MESSAGE("attractor used on face :"<Empty()) double result = FaceIndex2ClassAttractor[face_id]->GetSize(uv[0],uv[1]); @@ -1812,15 +1832,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],(char *)"(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((char *)"stderr", new_stderr); + PySys_SetObject((char*)"stderr", new_stderr); PyErr_Print(); - PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__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); @@ -1846,15 +1866,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],(char *)""); + pyresult = PyObject_CallFunction(VertexId2PythonSmp[point_id],(char*)""); double result; if ( pyresult == NULL){ fflush(stderr); string err_description=""; new_stderr = newPyStdOut(err_description); - PySys_SetObject((char *)"stderr", new_stderr); + PySys_SetObject((char*)"stderr", new_stderr); PyErr_Print(); - PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__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_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index e7f7d3f..70ebef1 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -56,15 +56,14 @@ extern "C"{ #include #include -class BLSURFPlugin_Hypothesis; +#include "BLSURFPlugin_Hypothesis.hxx" + class TopoDS_Shape; class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { public: BLSURFPlugin_BLSURF(int hypId, int studyId, SMESH_Gen* gen); - TopoDS_Shape entryToShape(std::string entry); - virtual ~BLSURFPlugin_BLSURF(); virtual bool CheckHypothesis(SMESH_Mesh& aMesh, @@ -87,6 +86,8 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { const BLSURFPlugin_Hypothesis* _hypothesis; private: + TopoDS_Shape entryToShape(std::string entry); + void createEnforcedVertexOnFace(TopoDS_Shape FaceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList); void Set_NodeOnEdge(SMESHDS_Mesh* meshDS, SMDS_MeshNode* node, const TopoDS_Shape& ed); void BRepClass_FaceClassifierPerform(BRepClass_FaceClassifier* fc, const TopoDS_Face& face, const gp_Pnt& P, const Standard_Real Tol); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 4fdfd31..c26f26f 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -21,7 +21,7 @@ // File : BLSURFPlugin_Hypothesis.cxx // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA) // & Aurelien ALLEAUME (DISTENE) -// Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE) +// Size maps development: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE) // --- // #include "BLSURFPlugin_Hypothesis.hxx" @@ -40,120 +40,84 @@ #include CORBA_CLIENT_HEADER(GEOM_Gen) //============================================================================= -BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId, - SMESH_Gen * gen) - : SMESH_Hypothesis(hypId, studyId, gen), - _topology(GetDefaultTopology()), - _physicalMesh(GetDefaultPhysicalMesh()), - _phySize(GetDefaultPhySize()), - _phyMax(GetDefaultMaxSize()), - _phyMin(GetDefaultMinSize()), - _hgeoMax(GetDefaultMaxSize()), - _hgeoMin(GetDefaultMinSize()), - _geometricMesh(GetDefaultGeometricMesh()), - _angleMeshS(GetDefaultAngleMeshS()), - _angleMeshC(GetDefaultAngleMeshC()), - _gradation(GetDefaultGradation()), - _quadAllowed(GetDefaultQuadAllowed()), - _decimesh(GetDefaultDecimesh()), - _verb( GetDefaultVerbosity() ), - _sizeMap(GetDefaultSizeMap()), - _attractors(GetDefaultSizeMap()), - _classAttractors(GetDefaultAttractorMap()), -// _enfVertexList(GetDefaultEnfVertexList()), - _entryCoordsListMap(GetDefaultEntryCoordsListMap()), - _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()) - /* TODO GROUPS - _groupNameEnfVertexListMap(GetDefaultGroupNameEnfVertexListMap()), - _enfVertexGroupNameMap(GetDefaultEnfVertexGroupNameMap()) - */ +BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen) : + SMESH_Hypothesis(hypId, studyId, gen), _topology(GetDefaultTopology()), + _physicalMesh(GetDefaultPhysicalMesh()), + _phySize(GetDefaultPhySize()), + _phyMax(GetDefaultMaxSize()), + _phyMin(GetDefaultMinSize()), + _hgeoMax(GetDefaultMaxSize()), + _hgeoMin(GetDefaultMinSize()), + _geometricMesh(GetDefaultGeometricMesh()), + _angleMeshS(GetDefaultAngleMeshS()), + _angleMeshC(GetDefaultAngleMeshC()), + _gradation(GetDefaultGradation()), + _quadAllowed(GetDefaultQuadAllowed()), + _decimesh(GetDefaultDecimesh()), + _verb(GetDefaultVerbosity()), + _sizeMap(GetDefaultSizeMap()), + _attractors(GetDefaultSizeMap()), + _classAttractors(GetDefaultAttractorMap()), + _faceEntryEnfVertexListMap(GetDefaultFaceEntryEnfVertexListMap()), + _enfVertexList(GetDefaultEnfVertexList()), + _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()), + _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()), + _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()), + _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap()), + _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap()) +/* TODO GROUPS + _groupNameEnfVertexListMap(GetDefaultGroupNameEnfVertexListMap()), + _enfVertexGroupNameMap(GetDefaultEnfVertexGroupNameMap()) + */ { _name = "BLSURF_Parameters"; _param_algo_dim = 2; - // to desable writing boundaries + // to disable writing boundaries //_phyMin = _phyMax = _hgeoMin = _hgeoMax = undefinedDouble(); - const char* intOptionNames[] = { - "addsurf_ivertex", - "background", - "CheckAdjacentEdges", - "CheckCloseEdges", - "CheckWellDefined", - "coiter", - "communication", - "decim", - "export_flag", - "file_h", - "frontal", - "gridnu", - "gridnv", - "hinterpol_flag", - "hmean_flag", - "intermedfile", - "memory", - "normals", - "optim", - "pardom_flag", - "pinch", - "refs", - "rigid", - "surforient", - "tconf", - "topo_collapse", - "" // mark of end - }; - const char* doubleOptionNames[] = { - "addsurf_angle", - "addsurf_R", - "addsurf_H", - "addsurf_FG", - "addsurf_r", - "addsurf_PA", - "angle_compcurv", - "angle_ridge", - "CoefRectangle", - "eps_collapse", - "eps_ends", - "eps_pardom", - "LSS", - "topo_eps1", - "topo_eps2", - "" // mark of end - }; - const char* charOptionNames[] = { - "export_format", - "export_option", - "import_option", - "prefix", - "" // mark of end - }; + const char* intOptionNames[] = { "addsurf_ivertex", "background", "CheckAdjacentEdges", "CheckCloseEdges", + "CheckWellDefined", "coiter", "communication", "decim", "export_flag", "file_h", "frontal", "gridnu", "gridnv", + "hinterpol_flag", "hmean_flag", "intermedfile", "memory", "normals", "optim", "pardom_flag", "pinch", "refs", + "rigid", "surforient", "tconf", "topo_collapse", "" // mark of end + }; + const char* doubleOptionNames[] = { "addsurf_angle", "addsurf_R", "addsurf_H", "addsurf_FG", "addsurf_r", + "addsurf_PA", "angle_compcurv", "angle_ridge", "CoefRectangle", "eps_collapse", "eps_ends", "eps_pardom", "LSS", + "topo_eps1", "topo_eps2", "" // mark of end + }; + const char* charOptionNames[] = { "export_format", "export_option", "import_option", "prefix", "" // mark of end + }; int i = 0; - while ( intOptionNames[i][0] ) - _option2value[ intOptionNames[i++] ].clear(); + while (intOptionNames[i][0]) + _option2value[intOptionNames[i++]].clear(); i = 0; - while ( doubleOptionNames[i][0] ) { - _doubleOptions.insert( doubleOptionNames[i] ); - _option2value[ doubleOptionNames[i++] ].clear(); + while (doubleOptionNames[i][0]) { + _doubleOptions.insert(doubleOptionNames[i]); + _option2value[doubleOptionNames[i++]].clear(); } i = 0; - while ( charOptionNames[i][0] ) { - _charOptions.insert( charOptionNames[i] ); - _option2value[ charOptionNames[i++] ].clear(); + while (charOptionNames[i][0]) { + _charOptions.insert(charOptionNames[i]); + _option2value[charOptionNames[i++]].clear(); } _sizeMap.clear(); _attractors.clear(); -// _enfVertexList.clear(); - _entryCoordsListMap.clear(); + _faceEntryEnfVertexListMap.clear(); + _enfVertexList.clear(); + _faceEntryCoordsListMap.clear(); _coordsEnfVertexMap.clear(); + _faceEntryEnfVertexEntryListMap.clear(); + _enfVertexEntryEnfVertexMap.clear(); + _groupNameNodeIDMap.clear(); + /* TODO GROUPS - _groupNameEnfVertexListMap.clear(); - _enfVertexGroupNameMap.clear(); - */ + _groupNameEnfVertexListMap.clear(); + _enfVertexGroupNameMap.clear(); + */ } TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry) @@ -179,8 +143,7 @@ TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) -{ +void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) { if (theTopology != _topology) { _topology = theTopology; NotifySubMeshesHypothesisModification(); @@ -188,24 +151,22 @@ void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) -{ +void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) { if (thePhysicalMesh != _physicalMesh) { _physicalMesh = thePhysicalMesh; - switch( _physicalMesh ) { + switch (_physicalMesh) { case DefaultSize: default: _phySize = GetDefaultPhySize(); - _gradation = GetDefaultGradation(); + _gradation = GetDefaultGradation(); break; - } + } NotifySubMeshesHypothesisModification(); } } //============================================================================= -void BLSURFPlugin_Hypothesis::SetPhySize(double theVal) -{ +void BLSURFPlugin_Hypothesis::SetPhySize(double theVal) { if (theVal != _phySize) { _phySize = theVal; NotifySubMeshesHypothesisModification(); @@ -213,8 +174,7 @@ void BLSURFPlugin_Hypothesis::SetPhySize(double theVal) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetPhyMin(double theMinSize) -{ +void BLSURFPlugin_Hypothesis::SetPhyMin(double theMinSize) { if (theMinSize != _phyMin) { _phyMin = theMinSize; NotifySubMeshesHypothesisModification(); @@ -222,18 +182,15 @@ void BLSURFPlugin_Hypothesis::SetPhyMin(double theMinSize) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetPhyMax(double theMaxSize) -{ +void BLSURFPlugin_Hypothesis::SetPhyMax(double theMaxSize) { if (theMaxSize != _phyMax) { _phyMax = theMaxSize; NotifySubMeshesHypothesisModification(); } } - //============================================================================= -void BLSURFPlugin_Hypothesis::SetGeoMin(double theMinSize) -{ +void BLSURFPlugin_Hypothesis::SetGeoMin(double theMinSize) { if (theMinSize != _hgeoMin) { _hgeoMin = theMinSize; NotifySubMeshesHypothesisModification(); @@ -241,8 +198,7 @@ void BLSURFPlugin_Hypothesis::SetGeoMin(double theMinSize) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetGeoMax(double theMaxSize) -{ +void BLSURFPlugin_Hypothesis::SetGeoMax(double theMaxSize) { if (theMaxSize != _hgeoMax) { _hgeoMax = theMaxSize; NotifySubMeshesHypothesisModification(); @@ -250,24 +206,22 @@ void BLSURFPlugin_Hypothesis::SetGeoMax(double theMaxSize) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) -{ +void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) { if (theGeometricMesh != _geometricMesh) { _geometricMesh = theGeometricMesh; - switch( _geometricMesh ) { + switch (_geometricMesh) { case DefaultGeom: default: _angleMeshS = GetDefaultAngleMeshS(); - _gradation = GetDefaultGradation(); + _gradation = GetDefaultGradation(); break; - } + } NotifySubMeshesHypothesisModification(); } } //============================================================================= -void BLSURFPlugin_Hypothesis::SetAngleMeshS(double theVal) -{ +void BLSURFPlugin_Hypothesis::SetAngleMeshS(double theVal) { if (theVal != _angleMeshS) { _angleMeshS = theVal; NotifySubMeshesHypothesisModification(); @@ -275,8 +229,7 @@ void BLSURFPlugin_Hypothesis::SetAngleMeshS(double theVal) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetAngleMeshC(double theVal) -{ +void BLSURFPlugin_Hypothesis::SetAngleMeshC(double theVal) { if (theVal != _angleMeshC) { _angleMeshC = theVal; NotifySubMeshesHypothesisModification(); @@ -284,8 +237,7 @@ void BLSURFPlugin_Hypothesis::SetAngleMeshC(double theVal) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetGradation(double theVal) -{ +void BLSURFPlugin_Hypothesis::SetGradation(double theVal) { if (theVal != _gradation) { _gradation = theVal; NotifySubMeshesHypothesisModification(); @@ -293,8 +245,7 @@ void BLSURFPlugin_Hypothesis::SetGradation(double theVal) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) -{ +void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) { if (theVal != _quadAllowed) { _quadAllowed = theVal; NotifySubMeshesHypothesisModification(); @@ -302,8 +253,7 @@ void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetDecimesh(bool theVal) -{ +void BLSURFPlugin_Hypothesis::SetDecimesh(bool theVal) { if (theVal != _decimesh) { _decimesh = theVal; NotifySubMeshesHypothesisModification(); @@ -311,57 +261,50 @@ void BLSURFPlugin_Hypothesis::SetDecimesh(bool theVal) } //============================================================================= -void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) -{ +void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) { if (theVal != _verb) { _verb = theVal; NotifySubMeshesHypothesisModification(); } } //============================================================================= -void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, - const std::string& optionValue) - throw (std::invalid_argument) -{ - TOptionValues::iterator op_val = _option2value.find( optionName ); - if ( op_val == _option2value.end() ) { +void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue) + throw (std::invalid_argument) { + TOptionValues::iterator op_val = _option2value.find(optionName); + if (op_val == _option2value.end()) { std::string msg = "Unknown BLSURF option: '" + optionName + "'"; throw std::invalid_argument(msg); } - if ( op_val->second != optionValue ) { + if (op_val->second != optionValue) { const char* ptr = optionValue.c_str(); // strip white spaces - while ( ptr[0] == ' ' ) + while (ptr[0] == ' ') ptr++; - int i = strlen( ptr ); - while ( i != 0 && ptr[i-1] == ' ') + int i = strlen(ptr); + while (i != 0 && ptr[i - 1] == ' ') i--; // check value type bool typeOk = true; std::string typeName; - if ( i == 0 ) { + if (i == 0) { // empty string - } - else if ( _charOptions.find( optionName ) != _charOptions.end() ) { + } else if (_charOptions.find(optionName) != _charOptions.end()) { // do not check strings - } - else if ( _doubleOptions.find( optionName ) != _doubleOptions.end() ) { + } else if (_doubleOptions.find(optionName) != _doubleOptions.end()) { // check if value is double char * endPtr; strtod(ptr, &endPtr); - typeOk = ( ptr != endPtr ); + typeOk = (ptr != endPtr); typeName = "real"; - } - else { + } else { // check if value is int char * endPtr; - strtol(ptr, &endPtr,10); - typeOk = ( ptr != endPtr ); + strtol(ptr, &endPtr, 10); + typeOk = (ptr != endPtr); typeName = "integer"; } - if ( !typeOk ) { - std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + - "' but must be " + typeName; + if (!typeOk) { + std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName; throw std::invalid_argument(msg); } op_val->second = optionValue; @@ -370,11 +313,9 @@ void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, } //============================================================================= -std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) - throw (std::invalid_argument) -{ - TOptionValues::iterator op_val = _option2value.find( optionName ); - if ( op_val == _option2value.end() ) { +std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) { + TOptionValues::iterator op_val = _option2value.find(optionName); + if (op_val == _option2value.end()) { std::string msg = "Unknown BLSURF option: <"; msg += optionName + ">"; throw std::invalid_argument(msg); @@ -383,20 +324,18 @@ std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionNam } //============================================================================= -void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) -{ - TOptionValues::iterator op_val = _option2value.find( optionName ); - if ( op_val != _option2value.end() ) +void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) { + TOptionValues::iterator op_val = _option2value.find(optionName); + if (op_val != _option2value.end()) op_val->second.clear(); } //======================================================================= //function : SetSizeMapEntry //======================================================================= -void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry,const std::string& sizeMap) -{ +void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry, const std::string& sizeMap) { if (_sizeMap[entry].compare(sizeMap) != 0) { - _sizeMap[entry]=sizeMap; + _sizeMap[entry] = sizeMap; NotifySubMeshesHypothesisModification(); } } @@ -404,30 +343,27 @@ void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry,const st //======================================================================= //function : GetSizeMapEntry //======================================================================= -std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) -{ - TSizeMap::iterator it = _sizeMap.find( entry ); - if ( it != _sizeMap.end() ) - return it->second; - else - return "No_Such_Entry"; +std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) { + TSizeMap::iterator it = _sizeMap.find(entry); + if (it != _sizeMap.end()) + return it->second; + else + return "No_Such_Entry"; } - /*! - * \brief Return the size maps - */ -BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) -{ - return hyp ? hyp->_GetSizeMapEntries():GetDefaultSizeMap(); +/*! + * \brief Return the size maps + */ +BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetSizeMapEntries() : GetDefaultSizeMap(); } //======================================================================= //function : SetAttractorEntry //======================================================================= -void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry,const std::string& attractor) -{ +void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry, const std::string& attractor) { if (_attractors[entry].compare(attractor) != 0) { - _attractors[entry]=attractor; + _attractors[entry] = attractor; NotifySubMeshesHypothesisModification(); } } @@ -435,21 +371,19 @@ void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry,const //======================================================================= //function : GetAttractorEntry //======================================================================= -std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) -{ - TSizeMap::iterator it = _attractors.find( entry ); - if ( it != _attractors.end() ) - return it->second; - else - return "No_Such_Entry"; +std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) { + TSizeMap::iterator it = _attractors.find(entry); + if (it != _attractors.end()) + return it->second; + else + return "No_Such_Entry"; } - /*! - * \brief Return the attractors - */ -BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) -{ - return hyp ? hyp->_GetAttractorEntries():GetDefaultSizeMap(); +/*! + * \brief Return the attractors + */ +BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAttractorEntries() : GetDefaultSizeMap(); } //======================================================================= @@ -565,266 +499,176 @@ void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry) //======================================================================= //function : ClearSizeMaps //======================================================================= -void BLSURFPlugin_Hypothesis::ClearSizeMaps() -{ +void BLSURFPlugin_Hypothesis::ClearSizeMaps() { _sizeMap.clear(); _attractors.clear(); _classAttractors.clear(); } - - //======================================================================= //function : SetEnforcedVertex //======================================================================= -/* TODO GROUPS -void BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEnfEntry& entry, - double x, double y, double z, - std::string enfName, - const TEnfGroupName& groupName) -*/ -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 - theFaceEntry: " << entry << " vertex: " << x << " " << y << " " << z << " group name: " << groupName); - */ - MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex START - theFaceEntry: " << theFaceEntry << " vertex: " << x << " " << y << " " << z - << " name: " << enfName << " theVertexEntry: " << theVertexEntry); - +bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, + TEnfGroupName theGroupName, double x, double y, double z) { + + MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex("<< theFaceEntry << ", " + << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theVertexEntry << ", " << theGroupName << ")"); + + // TEnfVertexList::iterator it; bool toNotify = false; - 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 ) - { + bool toCreate = true; + + TEnfVertex *oldEnVertex; + TEnfVertex *newEnfVertex = new TEnfVertex(); + newEnfVertex->name = theVertexName; + newEnfVertex->geomEntry = theVertexEntry; + newEnfVertex->coords.clear(); + if (theVertexEntry == "") { + newEnfVertex->coords.push_back(x); + newEnfVertex->coords.push_back(y); + newEnfVertex->coords.push_back(z); + } + newEnfVertex->grpName = theGroupName; + newEnfVertex->faceEntries.clear(); + newEnfVertex->faceEntries.insert(theFaceEntry); + + + // update _enfVertexList + TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex); + if (it != _enfVertexList.end()) { + toCreate = false; + oldEnVertex = (*it); + MESSAGE("Enforced Vertex was found => Update"); + if (oldEnVertex->name != theVertexName) { + MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\""); + oldEnVertex->name = theVertexName; + toNotify = true; + } + if (oldEnVertex->grpName != theGroupName) { + MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\""); + oldEnVertex->grpName = theGroupName; + toNotify = true; + } + TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry); + if (it_faceEntries == oldEnVertex->faceEntries.end()) { + MESSAGE("Update face list by adding \"" << theFaceEntry << "\""); + oldEnVertex->faceEntries.insert(theFaceEntry); + _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex); toNotify = true; - if ( _coordsEnfVertexMap.count(coords)>0 ) - { - _coordsEnfVertexMap[coords].faceEntries.insert(theFaceEntry); + } + if (toNotify) { + // update map coords / enf vertex if needed + if (oldEnVertex->coords.size()) { + _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex; + _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords); } - else - { - TEnfVertex enfVertex; - enfVertex.name = enfName; - enfVertex.geomEntry = theVertexEntry; - enfVertex.coords = coords; - enfVertex.faceEntries.clear(); - enfVertex.faceEntries.insert(theFaceEntry); - - _coordsEnfVertexMap[coords] = enfVertex; + + // update map geom entry / enf vertex if needed + if (oldEnVertex->geomEntry != "") { + _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex; + _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry); } - coordsList.insert(coords); - _entryCoordsListMap[theFaceEntry].insert(coords); } } - else - { + +// //////// CREATE //////////// + if (toCreate) { toNotify = true; - if ( _coordsEnfVertexMap.count(coords)>0 ) - { - _coordsEnfVertexMap[coords].faceEntries.insert(theFaceEntry); + MESSAGE("Creating new enforced vertex"); + _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex); + _enfVertexList.insert(newEnfVertex); + if (theVertexEntry == "") { + _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords); + _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex; } - else - { - TEnfVertex enfVertex; - enfVertex.name = enfName; - enfVertex.geomEntry = theVertexEntry; - enfVertex.coords = coords; - enfVertex.faceEntries.clear(); - enfVertex.faceEntries.insert(theFaceEntry); - - _coordsEnfVertexMap[coords] = enfVertex; + else { + _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry); + _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex; } - _entryCoordsListMap[theFaceEntry].insert(coords); } - /* TODO GROUPS - bool toNotify2 = _setEnfVertexWithGroup(x,y,z,groupName); - - if (toNotify || toNotify2) - NotifySubMeshesHypothesisModification(); - */ if (toNotify) NotifySubMeshesHypothesisModification(); - + MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END"); return toNotify; } -/* TODO GROUPS -bool BLSURFPlugin_Hypothesis::_setEnfVertexWithGroup(double x, double y, double z, const std::string groupName) throw (std::invalid_argument) -{ - bool isModified = false; - std::vector enfVertex; - enfVertex.push_back(x); - enfVertex.push_back(y); - enfVertex.push_back(z); - if (_enfVertexList.find(enfVertex) != _enfVertexList.end()) { - TEnfGroupName oldGroupName = _enfVertexGroupNameMap[enfVertex]; - _enfVertexGroupNameMap[enfVertex] = groupName; - if ((groupName != "") && (groupName != oldGroupName)) { - MESSAGE("Group name is not empty"); - TEnfVertexList& enfVertexList = _groupNameEnfVertexListMap[groupName]; - enfVertexList.insert(enfVertex); - isModified = true; - } - else { - if (oldGroupName != "") { - // groupName = "" => remove group name - TGroupNameEnfVertexListMap::iterator it = _groupNameEnfVertexListMap.find(oldGroupName); - if (it != _groupNameEnfVertexListMap.end()) { - _groupNameEnfVertexListMap[oldGroupName].erase(enfVertex); - if (_groupNameEnfVertexListMap[oldGroupName].size() == 0) - _groupNameEnfVertexListMap.erase(oldGroupName); - isModified = true; - } - } - } - return isModified; - } - - std::ostringstream msg ; - msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ; - throw std::invalid_argument(msg.str()); -} //======================================================================= -//function : SetEnforcedVertexGroupName +//function : GetEnforcedVertices //======================================================================= -void BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(double x, double y, double z, - const TEnfGroupName& groupName) - throw (std::invalid_argument) -{ - bool toNotify = _setEnfVertexWithGroup(x,y,z,groupName); - if (toNotify) - NotifySubMeshesHypothesisModification(); -// bool toNotify = false; -// TEnfVertex enfVertex; -// enfVertex.push_back(x); -// enfVertex.push_back(y); -// enfVertex.push_back(z); -// -// if (_enfVertexList.find(enfVertex) != _enfVertexList.end()) { -// TEnfGroupName oldGroupName = _enfVertexGroupNameMap[enfVertex]; -// _enfVertexGroupNameMap[enfVertex] = groupName; -// if ((groupName != "") && (groupName != oldGroupName)) { -// MESSAGE("Group name is not empty"); -// TEnfVertexList& enfVertexList = _groupNameEnfVertexListMap[groupName]; -// enfVertexList.insert(enfVertex); -// toNotify = true; -// } -// else { -// if (oldGroupName != "") { -// // groupName = "" => remove group name -// TGroupNameEnfVertexListMap::iterator it = _groupNameEnfVertexListMap.find(oldGroupName); -// if (it != _groupNameEnfVertexListMap.end()) { -// _groupNameEnfVertexListMap[oldGroupName].erase(enfVertex); -// if (_groupNameEnfVertexListMap[oldGroupName].size() == 0) -// _groupNameEnfVertexListMap.erase(oldGroupName); -// toNotify = true; -// } -// } -// } -// if (toNotify) -// NotifySubMeshesHypothesisModification(); -// return; -// } -// // std::ostringstream msg ; -// // msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ; -// // throw std::invalid_argument(msg.str()); -} +BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry) + throw (std::invalid_argument) { + if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0) + return _faceEntryEnfVertexListMap[theFaceEntry]; + else + return GetDefaultEnfVertexList(); + + std::ostringstream msg; + msg << "No enforced vertex for face entry " << theFaceEntry; + throw std::invalid_argument(msg.str()); +} //======================================================================= -//function : GetEnforcedVertexGroupName +//function : GetEnfVertexCoordsList //======================================================================= -BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetEnforcedVertexGroupName(double x, double y, double z) - throw (std::invalid_argument) -{ - TEnfVertex enfVertex; - enfVertex.push_back(x); - enfVertex.push_back(y); - enfVertex.push_back(z); - if (_enfVertexGroupNameMap.find(enfVertex) != _enfVertexGroupNameMap.end()) - return _enfVertexGroupNameMap[enfVertex]; +BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList( + const TEntry& theFaceEntry) throw (std::invalid_argument) { + + if (_faceEntryCoordsListMap.count(theFaceEntry) > 0) + return _faceEntryCoordsListMap[theFaceEntry]; - std::ostringstream msg ; - msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ; + std::ostringstream msg; + msg << "No enforced vertex coords for face entry " << theFaceEntry; throw std::invalid_argument(msg.str()); } -*/ -/* //======================================================================= -//function : SetEnforcedVertexList +//function : GetEnfVertexEntryList //======================================================================= -void BLSURFPlugin_Hypothesis::SetEnforcedVertexList(const TEnfEntry& entry, - const TEnfVertexList vertexList) -{ - TEnfVertexList::const_iterator it; - bool toNotify = false; - for(it = vertexList.begin();it!=vertexList.end();++it) { - if (_entryEnfVertexListMap.count(entry)>0) - if (_entryEnfVertexListMap[entry].count(*it)==0) - toNotify = true; - else - toNotify = true; - _entryEnfVertexListMap[entry].insert(*it); - _enfVertexList.insert(*it); - } - if (toNotify) - NotifySubMeshesHypothesisModification(); +BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry) + throw (std::invalid_argument) { + + if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0) + return _faceEntryEnfVertexEntryListMap[theFaceEntry]; + + std::ostringstream msg; + msg << "No enforced vertex entry for face entry " << theFaceEntry; + throw std::invalid_argument(msg.str()); } -*/ //======================================================================= -//function : GetEnforcedVertices +//function : GetEnfVertex(TEnfVertexCoords coords) //======================================================================= -BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnforcedVertices(const TEnfEntry& entry) - throw (std::invalid_argument) -{ - 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()); +BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords) + throw (std::invalid_argument) { + + if (_coordsEnfVertexMap.count(coords) > 0) + return _coordsEnfVertexMap[coords]; + + std::ostringstream msg; + msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")"; + throw std::invalid_argument(msg.str()); } //======================================================================= -//function : GetCoords +//function : GetEnfVertex(const TEntry& theEnfVertexEntry) //======================================================================= -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 ; +BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry) + throw (std::invalid_argument) { + + if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0) + return _enfVertexEntryEnfVertexMap[theEnfVertexEntry]; + + std::ostringstream msg; + msg << "No enforced vertex with entry " << theEnfVertexEntry; throw std::invalid_argument(msg.str()); } @@ -832,211 +676,316 @@ BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetCoords //function : ClearEnforcedVertex //======================================================================= -bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEnfEntry& entry, double x, double y, double z) - throw (std::invalid_argument) -{ - std::ostringstream msg ; - +bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z, + const TEntry& theVertexEntry) throw (std::invalid_argument) { + + bool toNotify = false; + std::ostringstream msg; + TEnfVertex *oldEnfVertex; TEnfVertexCoords coords; + coords.clear(); coords.push_back(x); coords.push_back(y); coords.push_back(z); - // check that enf vertex with given coords exists - 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()); + // check that enf vertex with given enf vertex entry exists + TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry); + if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) { + // Success + MESSAGE("Found enforced vertex with geom entry " << theVertexEntry); + oldEnfVertex = it_enfVertexEntry->second; + + _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry); + + TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry]; + enfVertexEntryList.erase(theVertexEntry); + if (enfVertexEntryList.size() == 0) + _faceEntryEnfVertexEntryListMap.erase(theFaceEntry); + // TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry); + // TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry); + // it_entry_entry->second.erase(it_entryList); + // if (it_entry_entry->second.size() == 0) + // _faceEntryEnfVertexEntryListMap.erase(it_entry_entry); + } else { + // Fail + MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found"); + msg << "No enforced vertex with geom entry " << theVertexEntry; + // check that enf vertex with given coords exists + TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords); + if (it_coords_enf != _coordsEnfVertexMap.end()) { + // Success + MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z); + oldEnfVertex = it_coords_enf->second; + + _coordsEnfVertexMap.erase(it_coords_enf); + + TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry]; + enfVertexCoordsList.erase(coords); + if (enfVertexCoordsList.size() == 0) + _faceEntryCoordsListMap.erase(theFaceEntry); + // TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry); + // TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords); + // it_entry_coords->second.erase(it_coordsList); + // if (it_entry_coords->second.size() == 0) + // _faceEntryCoordsListMap.erase(it_entry_coords); + } else { + // Fail + MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found"); + msg << std::endl; + msg << "No enforced vertex at " << x << ", " << y << ", " << z; + throw std::invalid_argument(msg.str()); + } } - - 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()); + + MESSAGE("Remove enf vertex from _enfVertexList"); + + // update _enfVertexList + TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex); + if (it != _enfVertexList.end()) { + (*it)->faceEntries.erase(theFaceEntry); + if ((*it)->faceEntries.size() == 0){ + _enfVertexList.erase(it); + toNotify = true; + } + MESSAGE("Done"); } - // 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); + // update _faceEntryEnfVertexListMap + TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; + currentEnfVertexList.erase(oldEnfVertex); + + if (currentEnfVertexList.size() == 0) { + MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]"); + _faceEntryEnfVertexListMap.erase(theFaceEntry); + MESSAGE("Done"); } - - // 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; -} + if (toNotify) + NotifySubMeshesHypothesisModification(); + + return toNotify; +} //======================================================================= //function : ClearEnforcedVertices //======================================================================= -bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEnfEntry& entry) - throw (std::invalid_argument) -{ - TEntryCoordsListMap::iterator it_entry = _entryCoordsListMap.find(entry); - if (it_entry != _entryCoordsListMap.end()) { - TEnfVertexCoordsList coordsList = it_entry->second; +bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) { + + bool toNotify = false; + TEnfVertex *oldEnfVertex; + + TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry); + if (it_entry_coords != _faceEntryCoordsListMap.end()) { + toNotify = true; + TEnfVertexCoordsList coordsList = it_entry_coords->second; TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin(); - for( ; it_coordsList != coordsList.end() ; ++it_coordsList) { + for (; it_coordsList != coordsList.end(); ++it_coordsList) { TEnfVertexCoords coords = (*it_coordsList); - /* TODO GROUPS - TEnfGroupName groupName = _enfVertexGroupNameMap[*it]; - if (groupName != "") { - TGroupNameEnfVertexListMap::iterator it_grp =_groupNameEnfVertexListMap.find(groupName); - if (it_grp != _groupNameEnfVertexListMap.end()) { - _groupNameEnfVertexListMap[groupName].erase(it); - if (_groupNameEnfVertexListMap[groupName].size() == 0) - _groupNameEnfVertexListMap.erase(it_grp); + oldEnfVertex = _coordsEnfVertexMap[coords]; + _coordsEnfVertexMap.erase(coords); + // update _enfVertexList + TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex); + if (it != _enfVertexList.end()) { + (*it)->faceEntries.erase(theFaceEntry); + if ((*it)->faceEntries.size() == 0){ + _enfVertexList.erase(it); + toNotify = true; } + MESSAGE("Done"); } - _enfVertexGroupNameMap.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); + } + _faceEntryCoordsListMap.erase(it_entry_coords); + _faceEntryEnfVertexListMap.erase(theFaceEntry); + } + + TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry); + if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) { + toNotify = true; + TEntryList enfVertexEntryList = it_entry_entry->second; + TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin(); + for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) { + TEntry enfVertexEntry = (*it_enfVertexEntryList); + oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry]; + _enfVertexEntryEnfVertexMap.erase(enfVertexEntry); + // update _enfVertexList + TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex); + if (it != _enfVertexList.end()) { + (*it)->faceEntries.erase(theFaceEntry); + if ((*it)->faceEntries.size() == 0){ + _enfVertexList.erase(it); + toNotify = true; } + MESSAGE("Done"); } } - _entryCoordsListMap.erase(it_entry); - NotifySubMeshesHypothesisModification(); - return true; + _faceEntryEnfVertexEntryListMap.erase(it_entry_entry); + _faceEntryEnfVertexListMap.erase(theFaceEntry); } - std::ostringstream msg ; - msg << "No enforced vertex for " << entry; - throw std::invalid_argument(msg.str()); + if (toNotify) + NotifySubMeshesHypothesisModification(); + + return toNotify; + // std::ostringstream msg; + // msg << "No enforced vertex for " << theFaceEntry; + // throw std::invalid_argument(msg.str()); } //======================================================================= //function : ClearAllEnforcedVertices //======================================================================= -void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() -{ -// _enfVertexList.clear(); - _entryCoordsListMap.clear(); +void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() { + _faceEntryEnfVertexListMap.clear(); + _enfVertexList.clear(); + _faceEntryCoordsListMap.clear(); _coordsEnfVertexMap.clear(); + _faceEntryEnfVertexEntryListMap.clear(); + _enfVertexEntryEnfVertexMap.clear(); NotifySubMeshesHypothesisModification(); } //================================================================================ /*! -* \brief Return the enforced vertices -*/ + * \brief Return the enforced vertices + */ //================================================================================ -// BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp) -// { -// return hyp ? hyp->_GetAllEnforcedVertices():GetDefaultEnfVertexList(); -// } +BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap(); +} -BLSURFPlugin_Hypothesis::TEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp) +BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList(); +} + +BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap(); +} + +BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap(); +} + +BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap(); +} + +BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap(); +} + +std::set BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument) { - return hyp ? hyp->_GetAllCoordsByFace():GetDefaultEntryCoordsListMap(); + TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName); + if (it != _groupNameNodeIDMap.end()) { + return it->second; + } + std::ostringstream msg; + msg << "No group " << theGroupName; + throw std::invalid_argument(msg.str()); } -BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp) +void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) { - return hyp ? hyp->_GetAllEnforcedVerticesByCoords():GetDefaultCoordsEnfVertexMap(); + _groupNameNodeIDMap[theGroupName].insert(theNodeID); } -//============================================================================= -std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) +void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument) { - save << " " << (int)_topology - << " " << (int)_physicalMesh - << " " << (int)_geometricMesh - << " " << _phySize - << " " << _angleMeshS - << " " << _gradation - << " " << (int)_quadAllowed - << " " << (int)_decimesh; - save << " " << _phyMin - << " " << _phyMax - << " " << _angleMeshC - << " " << _hgeoMin - << " " << _hgeoMax - << " " << _verb; + TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName); + if (it != _groupNameNodeIDMap.end()) { + std::set::iterator IDit = it->second.find(theNodeID); + if (IDit != it->second.end()) + it->second.erase(IDit); + std::ostringstream msg; + msg << "No node IDs " << theNodeID << " for group " << theGroupName; + throw std::invalid_argument(msg.str()); + } + std::ostringstream msg; + msg << "No group " << theGroupName; + throw std::invalid_argument(msg.str()); +} + +//============================================================================= +std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) { + save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " " + << _angleMeshS << " " << _gradation << " " << (int) _quadAllowed << " " << (int) _decimesh; + save << " " << _phyMin << " " << _phyMax << " " << _angleMeshC << " " << _hgeoMin << " " << _hgeoMax << " " << _verb; TOptionValues::iterator op_val = _option2value.begin(); if (op_val != _option2value.end()) { save << " " << "__OPTIONS_BEGIN__"; - for ( ; op_val != _option2value.end(); ++op_val ) { - if ( !op_val->second.empty() ) - save << " " << op_val->first - << " " << op_val->second << "%#"; // "%#" is a mark of value end + for (; op_val != _option2value.end(); ++op_val) { + if (!op_val->second.empty()) + save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end } save << " " << "__OPTIONS_END__"; } - TSizeMap::iterator it_sm = _sizeMap.begin(); + TSizeMap::iterator it_sm = _sizeMap.begin(); if (it_sm != _sizeMap.end()) { save << " " << "__SIZEMAP_BEGIN__"; - for ( ; it_sm != _sizeMap.end(); ++it_sm ) { - save << " " << it_sm->first - << " " << it_sm->second << "%#"; // "%#" is a mark of value end + for (; it_sm != _sizeMap.end(); ++it_sm) { + save << " " << it_sm->first << " " << it_sm->second << "%#"; // "%#" is a mark of value end } save << " " << "__SIZEMAP_END__"; } - TSizeMap::iterator it_at = _attractors.begin(); + TSizeMap::iterator it_at = _attractors.begin(); if (it_at != _attractors.end()) { save << " " << "__ATTRACTORS_BEGIN__"; - for ( ; it_at != _attractors.end(); ++it_at ) { - save << " " << it_at->first - << " " << it_at->second << "%#"; // "%#" is a mark of value end + for (; it_at != _attractors.end(); ++it_at) { + save << " " << it_at->first << " " << it_at->second << "%#"; // "%#" is a mark of value end } save << " " << "__ATTRACTORS_END__"; } - TEntryCoordsListMap::const_iterator it_enf = _entryCoordsListMap.begin(); - if (it_enf != _entryCoordsListMap.end()) { + TEnfVertexList::const_iterator it_enf = _enfVertexList.begin(); + if (it_enf != _enfVertexList.end()) { save << " " << "__ENFORCED_VERTICES_BEGIN__"; - for ( ; it_enf != _entryCoordsListMap.end(); ++it_enf ) { - save << " " << it_enf->first; - 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()) { - save << " " << "__ENF_GROUP_BEGIN__"; - save << " " << it_enfGroup->second ; - save << " " << "__ENF_GROUP_END__"; - } - */ - save << " " << "$"; // "$" is a mark of enforced vertex end + for (; it_enf != _enfVertexList.end(); ++it_enf) { + TEnfVertex *enfVertex = (*it_enf); + save << " " << "__BEGIN_VERTEX__"; + if (!enfVertex->name.empty()) { + save << " " << "__BEGIN_NAME__"; + save << " " << enfVertex->name; + save << " " << "__END_NAME__"; + } + if (!enfVertex->geomEntry.empty()) { + save << " " << "__BEGIN_ENTRY__"; + save << " " << enfVertex->geomEntry; + save << " " << "__END_ENTRY__"; + } + if (!enfVertex->grpName.empty()) { + save << " " << "__BEGIN_GROUP__"; + save << " " << enfVertex->grpName; + save << " " << "__END_GROUP__"; } - save << "#"; // "#" is a mark of enforced shape end + if (enfVertex->coords.size()) { + save << " " << "__BEGIN_COORDS__"; + for (int i=0;icoords.size();i++) + save << " " << enfVertex->coords[i]; + save << " " << "__END_COORDS__"; + } + TEntryList::const_iterator faceEntriesIt = enfVertex->faceEntries.begin(); + bool hasFaces = false; + if (faceEntriesIt != enfVertex->faceEntries.end()) { + hasFaces = true; + save << " " << "__BEGIN_FACELIST__"; + } + for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt) + save << " " << (*faceEntriesIt); + if (hasFaces) + save << " " << "__END_FACELIST__"; + save << " " << "__END_VERTEX__"; } save << " " << "__ENFORCED_VERTICES_END__"; } @@ -1045,8 +994,7 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) } //============================================================================= -std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) -{ +std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { bool isOK = true; int i; double val; @@ -1161,23 +1109,21 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) isOK = (load >> optValue); } if (isOK) { - std::string & value = _option2value[ optName ]; + std::string & value = _option2value[optName]; value = optValue; int len = value.size(); // continue reading until "%#" encountered - while ( value[len-1] != '#' || value[len-2] != '%' ) - { + while (value[len - 1] != '#' || value[len - 2] != '%') { isOK = (load >> optValue); if (isOK) { value += " "; value += optValue; len = value.size(); - } - else { + } else { break; } } - value[ len-2 ] = '\0'; //cut off "%#" + value[len - 2] = '\0'; //cut off "%#" } } @@ -1201,23 +1147,21 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) isOK = (load >> smValue); } if (isOK) { - std::string & value2 = _sizeMap[ smEntry ]; + std::string & value2 = _sizeMap[smEntry]; value2 = smValue; - int len2= value2.size(); + int len2 = value2.size(); // continue reading until "%#" encountered - while ( value2[len2-1] != '#' || value2[len2-2] != '%' ) - { + while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') { isOK = (load >> smValue); if (isOK) { value2 += " "; value2 += smValue; len2 = value2.size(); - } - else { + } else { break; } } - value2[ len2-2 ] = '\0'; //cut off "%#" + value2[len2 - 2] = '\0'; //cut off "%#" } } @@ -1239,173 +1183,176 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) isOK = (load >> atValue); } if (isOK) { - std::string & value3 = _attractors[ atEntry ]; + std::string & value3 = _attractors[atEntry]; value3 = atValue; - int len3= value3.size(); + int len3 = value3.size(); // continue reading until "%#" encountered - while ( value3[len3-1] != '#' || value3[len3-2] != '%' ) - { + while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') { isOK = (load >> atValue); if (isOK) { value3 += " "; value3 += atValue; len3 = value3.size(); - } - else { + } else { break; } } - value3[ len3-2 ] = '\0'; //cut off "%#" + value3[len3 - 2] = '\0'; //cut off "%#" } } - + if (hasAttractor) { isOK = (load >> option_or_sm); if (isOK) if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__") hasEnforcedVertex = true; } + + +// +// Here is a example of the saved stream: +// __ENFORCED_VERTICES_BEGIN__ +// __BEGIN_VERTEX__ => no name, no entry +// __BEGIN_GROUP__ mon groupe __END_GROUP__ +// __BEGIN_COORDS__ 10 10 10 __END_COORDS__ +// __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__ +// __END_VERTEX__ +// __BEGIN_VERTEX__ => no coords +// __BEGIN_NAME__ mes points __END_NAME__ +// __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__ +// __BEGIN_GROUP__ mon groupe __END_GROUP__ +// __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__ +// __END_VERTEX__ +// __ENFORCED_VERTICES_END__ +// + + std::string enfSeparator; + std::string enfName; + std::string enfGeomEntry; + std::string enfGroup; + TEntryList enfFaceEntryList; + double enfCoords[3]; + bool hasCoords = false; + + _faceEntryEnfVertexListMap.clear(); + _enfVertexList.clear(); + _faceEntryCoordsListMap.clear(); + _coordsEnfVertexMap.clear(); + _faceEntryEnfVertexEntryListMap.clear(); + _enfVertexEntryEnfVertexMap.clear(); + - std::string enfEntry, enfValue, enfGroup, trace; - std::ostringstream oss; while (isOK && hasEnforcedVertex) { - isOK = (load >> enfEntry); - if (isOK) { - MESSAGE("enfEntry: " <> enfValue); - if (isOK) { - MESSAGE("enfValue: " <> enfGroup); - MESSAGE("enfGroup: " <> enfGroup); - if (isOK) { - MESSAGE("enfGroup: " <> 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(); - } + isOK = (load >> enfSeparator); // __BEGIN_VERTEX__ + TEnfVertex *enfVertex = new TEnfVertex(); +// MESSAGE("enfSeparator: " <> enfSeparator); + MESSAGE("enfSeparator: " <name = enfName; + enfVertex->geomEntry = enfGeomEntry; + enfVertex->grpName = enfGroup; + enfVertex->coords.clear(); + if (hasCoords) + enfVertex->coords.assign(enfCoords,enfCoords+3); + enfVertex->faceEntries = enfFaceEntryList; + + _enfVertexList.insert(enfVertex); + + if (enfVertex->coords.size()) { + _coordsEnfVertexMap[enfVertex->coords] = enfVertex; + for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) { + _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords); + _faceEntryEnfVertexListMap[(*it)].insert(enfVertex); } - else - break; } - if (enfValue[len4-1] == '$') { - MESSAGE("enfValue is $"); - enfValue[len4-1] = '\0'; //cut off "$" - /* TODO GROUPS - if (!hasGroup) { - MESSAGE("no group: remove $"); - // Remove '$' and add to vertex -// enfValue[len4-1] = '\0'; //cut off "$#" - enfVertex.push_back(atof(enfValue.c_str())); + if (!enfVertex->geomEntry.empty()) { + _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex; + for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) { + _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry); + _faceEntryEnfVertexListMap[(*it)].insert(enfVertex); } - */ - enfValue[len4-1] = '\0'; //cut off "$#" - enfVertex.coords.push_back(atof(enfValue.c_str())); - MESSAGE("Add vertex to list"); - // Add vertex to list of vertex - coordsList.insert(enfVertex.coords); - _coordsEnfVertexMap[enfVertex.coords] = enfVertex; -// _enfVertexList.insert(enfVertex); } + + enfName.clear(); + enfGeomEntry.clear(); + enfGroup.clear(); + enfFaceEntryList.clear(); + hasCoords = false; + break; // __END_VERTEX__ } - if (enfValue[len4-1] == '#') { - /* TODO GROUPS - if (!hasGroup) { - // Remove '$#' and add to vertex - enfValue[len4-2] = '\0'; //cut off "$#" - enfVertex.push_back(atof(enfValue.c_str())); + + if (enfSeparator == "__BEGIN_NAME__") { // __BEGIN_NAME__ + while (isOK && (enfSeparator != "__END_NAME__")) { + isOK = (load >> enfSeparator); + if (enfSeparator != "__END_NAME__") { + if (!enfName.empty()) + enfName += " "; + enfName += enfSeparator; + } } - */ - // Remove '$#' and add to vertex - enfValue[len4-2] = '\0'; //cut off "$#" - enfVertex.coords.push_back(atof(enfValue.c_str())); - // Add vertex to list of vertex - coordsList.insert(enfVertex.coords); - _coordsEnfVertexMap[enfVertex.coords] = enfVertex; -// _enfVertexList.insert(enfVertex); + MESSAGE("enfName: " <> enfGeomEntry); + isOK = (load >> enfSeparator); // __END_ENTRY__ + if (enfSeparator != "__END_ENTRY__") + throw std::exception(); + MESSAGE("enfGeomEntry: " <> enfSeparator); + if (enfSeparator != "__END_GROUP__") { + if (!enfGroup.empty()) + enfGroup += " "; + enfGroup += enfSeparator; + } + } + MESSAGE("enfGroup: " <> enfCoords[0] >> enfCoords[1] >> enfCoords[2]); + isOK = (load >> enfSeparator); // __END_COORDS__ + if (enfSeparator != "__END_COORDS__") + throw std::exception(); + MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]); + } + + if (enfSeparator == "__BEGIN_FACELIST__") { // __BEGIN_FACELIST__ + while (isOK && (enfSeparator != "__END_FACELIST__")) { + isOK = (load >> enfSeparator); + if (enfSeparator != "__END_FACELIST__") { + enfFaceEntryList.insert(enfSeparator); + MESSAGE(enfSeparator << " was inserted into enfFaceEntryList"); + } + } + } } - else - break; } return load; } //============================================================================= -std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) -{ - return hyp.SaveTo( save ); +std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) { + return hyp.SaveTo(save); } //============================================================================= -std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) -{ - return hyp.LoadFrom( load ); +std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) { + return hyp.LoadFrom(load); } //================================================================================ @@ -1414,9 +1361,7 @@ std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) */ //================================================================================ -bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, - const TopoDS_Shape& theShape) -{ +bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) { return false; } @@ -1427,68 +1372,56 @@ bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, */ //============================================================================= -bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, - const SMESH_Mesh* theMesh) -{ - return bool( _phySize = dflts._elemLength ); +bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) { + return bool(_phySize = dflts._elemLength); } //============================================================================= -BLSURFPlugin_Hypothesis::Topology BLSURFPlugin_Hypothesis::GetDefaultTopology() -{ +BLSURFPlugin_Hypothesis::Topology BLSURFPlugin_Hypothesis::GetDefaultTopology() { return FromCAD; } //============================================================================= -BLSURFPlugin_Hypothesis::PhysicalMesh BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh() -{ +BLSURFPlugin_Hypothesis::PhysicalMesh BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh() { return PhysicalUserDefined; } //============================================================================= -double BLSURFPlugin_Hypothesis::GetDefaultPhySize() -{ +double BLSURFPlugin_Hypothesis::GetDefaultPhySize() { return 10; } //====================================================================== -double BLSURFPlugin_Hypothesis::GetDefaultMaxSize() -{ +double BLSURFPlugin_Hypothesis::GetDefaultMaxSize() { return undefinedDouble(); // 1e+4; } //====================================================================== -double BLSURFPlugin_Hypothesis::GetDefaultMinSize() -{ +double BLSURFPlugin_Hypothesis::GetDefaultMinSize() { return undefinedDouble(); //1e-4; } //====================================================================== -BLSURFPlugin_Hypothesis::GeometricMesh BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh() -{ +BLSURFPlugin_Hypothesis::GeometricMesh BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh() { return DefaultGeom; } //============================================================================= -double BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS() -{ +double BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS() { return 8; } //============================================================================= -double BLSURFPlugin_Hypothesis::GetDefaultGradation() -{ +double BLSURFPlugin_Hypothesis::GetDefaultGradation() { return 1.1; } //============================================================================= -bool BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed() -{ +bool BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed() { return false; } //============================================================================= -bool BLSURFPlugin_Hypothesis::GetDefaultDecimesh() -{ +bool BLSURFPlugin_Hypothesis::GetDefaultDecimesh() { return false; } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 924baa5..7b40c9d 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -33,6 +33,9 @@ #include #include #include +#include +#include +#include #include "BLSURFPlugin_Attractor.hxx" // Parameters for work of BLSURF @@ -149,55 +152,56 @@ public: // Name typedef std::string TEnfName; // Entry - typedef std::string TEnfEntry; + typedef std::string TEntry; + // List of entries + typedef std::set TEntryList; // 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 { + struct TEnfVertex { TEnfName name; - TEnfEntry geomEntry; + TEntry geomEntry; TEnfVertexCoords coords; - TEnfEntryList faceEntries; - bool manualInput; - // TODO GROUPS TEnfGroupName grpName; - } TEnfVertex; - struct _TEnforcedVertexCmp + TEntryList faceEntries; + }; + + struct CompareEnfVertices { - 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 ); + bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const { + if (e1 && e2) { + if (e1->coords.size() && e2->coords.size()) + return (e1->coords < e2->coords); + else + return (e1->geomEntry < e2->geomEntry); + } + return false; } }; + // List of enforced vertices - typedef std::set< TEnfVertex, _TEnforcedVertexCmp > TEnfVertexList; - - // Map Coords / Enforced vertex - typedef std::map< TEnfVertexCoords, TEnfVertex > TCoordsEnfVertexMap; + typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList; - // Map Entry / List of coords - typedef std::map< TEnfEntry, TEnfVertexCoordsList > TEntryCoordsListMap; + // Map Face Entry / List of enforced vertices + typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap; - // Map Entry / List of enforced vertices - 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 ///////////////// + // Map Face Entry / List of coords + typedef std::map< TEntry, TEnfVertexCoordsList > TFaceEntryCoordsListMap; + + // Map Face Entry / List of Vertex entry + typedef std::map< TEntry, TEntryList > TFaceEntryEnfVertexEntryListMap; + // Map Coords / Enforced vertex + typedef std::map< TEnfVertexCoords, TEnfVertex* > TCoordsEnfVertexMap; + + // Map Vertex entry / Enforced vertex + typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap; + typedef std::map< TEnfGroupName, std::set > TGroupNameNodeIDMap; /* TODO GROUPS // Map Group Name / List of enforced vertices typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap; @@ -205,21 +209,32 @@ public: // 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& theFaceEntry) throw (std::invalid_argument); - TEnfVertexCoordsList GetCoords(const TEnfEntry& theFaceEntry) throw (std::invalid_argument); +// void SetEnforcedVertex(const TEntry& entry, double x, double y, double z, const TEnfGroupName& groupName=""); + bool SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName, + double x = 0.0, double y = 0.0, double z = 0.0); + TEnfVertexList GetEnfVertexList(const TEntry& theFaceEntry) throw (std::invalid_argument); + TEnfVertexCoordsList GetEnfVertexCoordsList(const TEntry& theFaceEntry) throw (std::invalid_argument); + TEntryList GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument); + TEnfVertex* GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument); + TEnfVertex* GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument); + void AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID); + std::set GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument); + void RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) 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); - 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; } + bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument); + bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument); + + void ClearAllEnforcedVertices(); + + const TFaceEntryEnfVertexListMap _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; } + const TEnfVertexList _GetAllEnforcedVertices() const { return _enfVertexList; } + + const TFaceEntryCoordsListMap _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; } + const TCoordsEnfVertexMap _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; } + + const TFaceEntryEnfVertexEntryListMap _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; } + const TEnfVertexEntryEnfVertexMap _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; } + // TODO GROUPS // const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; } @@ -227,9 +242,15 @@ public: /*! * \brief Return the enforced vertices */ -// static TEnfVertexList GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp); - static TEntryCoordsListMap GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp); - static TCoordsEnfVertexMap GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp); + static TFaceEntryEnfVertexListMap GetAllEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp); + static TEnfVertexList GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp); + + static TFaceEntryCoordsListMap GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp); + static TCoordsEnfVertexMap GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp); + + static TFaceEntryEnfVertexEntryListMap GetAllEnfVertexEntriesByFace(const BLSURFPlugin_Hypothesis* hyp); + static TEnfVertexEntryEnfVertexMap GetAllEnforcedVerticesByEnfVertexEntry(const BLSURFPlugin_Hypothesis* hyp); + /*! * \brief Set/get node group to an enforced vertex @@ -254,9 +275,15 @@ public: static int GetDefaultVerbosity() { return 10; } static TSizeMap GetDefaultSizeMap() { return TSizeMap();} static TAttractorMap GetDefaultAttractorMap() { return TAttractorMap(); } -// static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); } - static TEntryCoordsListMap GetDefaultEntryCoordsListMap() { return TEntryCoordsListMap(); } - static TCoordsEnfVertexMap GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); } + + static TFaceEntryEnfVertexListMap GetDefaultFaceEntryEnfVertexListMap() { return TFaceEntryEnfVertexListMap(); } + static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); } + static TFaceEntryCoordsListMap GetDefaultFaceEntryCoordsListMap() { return TFaceEntryCoordsListMap(); } + static TCoordsEnfVertexMap GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); } + static TFaceEntryEnfVertexEntryListMap GetDefaultFaceEntryEnfVertexEntryListMap() { return TFaceEntryEnfVertexEntryListMap(); } + static TEnfVertexEntryEnfVertexMap GetDefaultEnfVertexEntryEnfVertexMap() { return TEnfVertexEntryEnfVertexMap(); } + static TGroupNameNodeIDMap GetDefaultGroupNameNodeIDMap() { return TGroupNameNodeIDMap(); } + /* TODO GROUPS static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); } static TEnfVertexGroupNameMap GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); } @@ -293,10 +320,6 @@ public: */ virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); -/* TODO GROUPS -private: - bool _setEnfVertexWithGroup(double x, double y, double z, const std::string groupName) throw (std::invalid_argument); -*/ private: Topology _topology; @@ -315,9 +338,17 @@ private: TAttractorMap _classAttractors; TSizeMap _attEntry; TParamsMap _attParams; -// TEnfVertexList _enfVertexList; - TEntryCoordsListMap _entryCoordsListMap; - TCoordsEnfVertexMap _coordsEnfVertexMap; + + TFaceEntryEnfVertexListMap _faceEntryEnfVertexListMap; + TEnfVertexList _enfVertexList; + // maps to get "manual" enf vertex (through their coordinates) + TFaceEntryCoordsListMap _faceEntryCoordsListMap; + TCoordsEnfVertexMap _coordsEnfVertexMap; + // maps to get "geom" enf vertex (through their geom entries) + TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap; + TEnfVertexEntryEnfVertexMap _enfVertexEntryEnfVertexMap; + TGroupNameNodeIDMap _groupNameNodeIDMap; + /* TODO GROUPS TGroupNameEnfVertexListMap _groupNameEnfVertexListMap; */ diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 573053a..a482a60 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -43,17 +43,11 @@ * Constructor */ //============================================================================= -BLSURFPlugin_Hypothesis_i:: -BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl) - : SALOME::GenericObj_i( thePOA ), - SMESH_Hypothesis_i( thePOA ) -{ +BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i(PortableServer::POA_ptr thePOA, int theStudyId, + ::SMESH_Gen* theGenImpl) : + SALOME::GenericObj_i(thePOA), SMESH_Hypothesis_i(thePOA) { MESSAGE( "BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i" ); - myBaseImpl = new ::BLSURFPlugin_Hypothesis (theGenImpl->GetANewId(), - theStudyId, - theGenImpl); + myBaseImpl = new ::BLSURFPlugin_Hypothesis(theGenImpl->GetANewId(), theStudyId, theGenImpl); } //============================================================================= @@ -63,8 +57,7 @@ BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, * Destructor */ //============================================================================= -BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i() -{ +BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i() { MESSAGE( "BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i" ); } @@ -75,11 +68,10 @@ BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i() */ //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetTopology (CORBA::Long theValue) -{ +void BLSURFPlugin_Hypothesis_i::SetTopology(CORBA::Long theValue) { // MESSAGE("BLSURFPlugin_Hypothesis_i::SetTopology"); ASSERT(myBaseImpl); - this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology)theValue); + this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology) theValue); SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )"; } @@ -90,8 +82,7 @@ void BLSURFPlugin_Hypothesis_i::SetTopology (CORBA::Long theValue) * Get Topology */ //============================================================================= -CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology() -{ +CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology() { // MESSAGE("BLSURFPlugin_Hypothesis_i::GetTopology"); ASSERT(myBaseImpl); return this->GetImpl()->GetTopology(); @@ -107,11 +98,10 @@ CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology() */ //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh (CORBA::Long theValue) -{ +void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh(CORBA::Long theValue) { // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhysicalMesh"); ASSERT(myBaseImpl); - this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh)theValue); + this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh) theValue); SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )"; } @@ -122,8 +112,7 @@ void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh (CORBA::Long theValue) * Get PhysicalMesh */ //============================================================================= -CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh() -{ +CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh() { // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhysicalMesh"); ASSERT(myBaseImpl); return this->GetImpl()->GetPhysicalMesh(); @@ -136,8 +125,7 @@ CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh() * Set PhySize */ //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetPhySize (CORBA::Double theValue) -{ +void BLSURFPlugin_Hypothesis_i::SetPhySize(CORBA::Double theValue) { // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPhySize"); ASSERT(myBaseImpl); this->GetImpl()->SetPhySize(theValue); @@ -151,49 +139,42 @@ void BLSURFPlugin_Hypothesis_i::SetPhySize (CORBA::Double theValue) * Get PhySize */ //============================================================================= -CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize() -{ +CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize() { // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPhySize"); ASSERT(myBaseImpl); return this->GetImpl()->GetPhySize(); } //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize) -{ +void BLSURFPlugin_Hypothesis_i::SetPhyMin(CORBA::Double theMinSize) { ASSERT(myBaseImpl); - if ( GetPhyMin() != theMinSize ) { + if (GetPhyMin() != theMinSize) { this->GetImpl()->SetPhyMin(theMinSize); SMESH::TPythonDump() << _this() << ".SetPhyMin( " << theMinSize << " )"; } } //============================================================================= -CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin() -{ +CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMin() { ASSERT(myBaseImpl); return this->GetImpl()->GetPhyMin(); } - //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize) -{ +void BLSURFPlugin_Hypothesis_i::SetPhyMax(CORBA::Double theMaxSize) { ASSERT(myBaseImpl); - if ( GetPhyMax() != theMaxSize ) { + if (GetPhyMax() != theMaxSize) { this->GetImpl()->SetPhyMax(theMaxSize); SMESH::TPythonDump() << _this() << ".SetPhyMax( " << theMaxSize << " )"; } } //============================================================================= -CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax() -{ +CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax() { ASSERT(myBaseImpl); return this->GetImpl()->GetPhyMax(); } - //============================================================================= /*! * BLSURFPlugin_Hypothesis_i::SetGeometricMesh @@ -202,11 +183,10 @@ CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhyMax() */ //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetGeometricMesh (CORBA::Long theValue) -{ +void BLSURFPlugin_Hypothesis_i::SetGeometricMesh(CORBA::Long theValue) { // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGeometricMesh"); ASSERT(myBaseImpl); - this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh)theValue); + this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh) theValue); SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )"; } @@ -217,8 +197,7 @@ void BLSURFPlugin_Hypothesis_i::SetGeometricMesh (CORBA::Long theValue) * Get GeometricMesh */ //============================================================================= -CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh() -{ +CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh() { // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGeometricMesh"); ASSERT(myBaseImpl); return this->GetImpl()->GetGeometricMesh(); @@ -231,8 +210,7 @@ CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh() * Set AngleMeshS */ //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetAngleMeshS (CORBA::Double theValue) -{ +void BLSURFPlugin_Hypothesis_i::SetAngleMeshS(CORBA::Double theValue) { // MESSAGE("BLSURFPlugin_Hypothesis_i::SetAngleMeshS"); ASSERT(myBaseImpl); this->GetImpl()->SetAngleMeshS(theValue); @@ -246,58 +224,51 @@ void BLSURFPlugin_Hypothesis_i::SetAngleMeshS (CORBA::Double theValue) * Get AngleMeshS */ //============================================================================= -CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS() -{ +CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshS() { // MESSAGE("BLSURFPlugin_Hypothesis_i::GetAngleMeshS"); ASSERT(myBaseImpl); return this->GetImpl()->GetAngleMeshS(); } //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle) -{ +void BLSURFPlugin_Hypothesis_i::SetAngleMeshC(CORBA::Double angle) { ASSERT(myBaseImpl); this->GetImpl()->SetAngleMeshC(angle); SMESH::TPythonDump() << _this() << ".SetAngleMeshC( " << angle << " )"; } //============================================================================= -CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC() -{ +CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMeshC() { ASSERT(myBaseImpl); return this->GetImpl()->GetAngleMeshC(); } //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize) -{ +void BLSURFPlugin_Hypothesis_i::SetGeoMin(CORBA::Double theMinSize) { ASSERT(myBaseImpl); - if ( GetGeoMin() != theMinSize ) { + if (GetGeoMin() != theMinSize) { this->GetImpl()->SetGeoMin(theMinSize); SMESH::TPythonDump() << _this() << ".SetGeoMin( " << theMinSize << " )"; } } //============================================================================= -CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin() -{ +CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMin() { ASSERT(myBaseImpl); return this->GetImpl()->GetGeoMin(); } //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize) -{ +void BLSURFPlugin_Hypothesis_i::SetGeoMax(CORBA::Double theMaxSize) { ASSERT(myBaseImpl); - if ( GetGeoMax() != theMaxSize ) { + if (GetGeoMax() != theMaxSize) { this->GetImpl()->SetGeoMax(theMaxSize); SMESH::TPythonDump() << _this() << ".SetGeoMax( " << theMaxSize << " )"; } } //============================================================================= -CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax() -{ +CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax() { ASSERT(myBaseImpl); return this->GetImpl()->GetGeoMax(); } @@ -309,8 +280,7 @@ CORBA::Double BLSURFPlugin_Hypothesis_i::GetGeoMax() * Set Gradation */ //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetGradation (CORBA::Double theValue) -{ +void BLSURFPlugin_Hypothesis_i::SetGradation(CORBA::Double theValue) { // MESSAGE("BLSURFPlugin_Hypothesis_i::SetGradation"); ASSERT(myBaseImpl); this->GetImpl()->SetGradation(theValue); @@ -324,8 +294,7 @@ void BLSURFPlugin_Hypothesis_i::SetGradation (CORBA::Double theValue) * Get Gradation */ //============================================================================= -CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation() -{ +CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation() { // MESSAGE("BLSURFPlugin_Hypothesis_i::GetGradation"); ASSERT(myBaseImpl); return this->GetImpl()->GetGradation(); @@ -338,8 +307,7 @@ CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation() * Set true or false */ //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue) -{ +void BLSURFPlugin_Hypothesis_i::SetQuadAllowed(CORBA::Boolean theValue) { // MESSAGE("BLSURFPlugin_Hypothesis_i::SetQuadAllowed"); ASSERT(myBaseImpl); this->GetImpl()->SetQuadAllowed(theValue); @@ -353,8 +321,7 @@ void BLSURFPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue) * Get true or false */ //============================================================================= -CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed() -{ +CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed() { // MESSAGE("BLSURFPlugin_Hypothesis_i::GetQuadAllowed"); ASSERT(myBaseImpl); return this->GetImpl()->GetQuadAllowed(); @@ -367,8 +334,7 @@ CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadAllowed() * Set true or false */ //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetDecimesh (CORBA::Boolean theValue) -{ +void BLSURFPlugin_Hypothesis_i::SetDecimesh(CORBA::Boolean theValue) { // MESSAGE("BLSURFPlugin_Hypothesis_i::SetDecimesh"); ASSERT(myBaseImpl); this->GetImpl()->SetDecimesh(theValue); @@ -382,19 +348,16 @@ void BLSURFPlugin_Hypothesis_i::SetDecimesh (CORBA::Boolean theValue) * Get true or false */ //============================================================================= -CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh() -{ +CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetDecimesh() { // MESSAGE("BLSURFPlugin_Hypothesis_i::GetDecimesh"); ASSERT(myBaseImpl); return this->GetImpl()->GetDecimesh(); } //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal) - throw (SALOME::SALOME_Exception) -{ +void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - if ( theVal < 0 || theVal > 100 ) + if (theVal < 0 || theVal > 100) THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM ); this->GetImpl()->SetVerbosity(theVal); SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )"; @@ -402,59 +365,49 @@ void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal) //============================================================================= -CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity() -{ +CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity() { ASSERT(myBaseImpl); return (CORBA::Short) this->GetImpl()->GetVerbosity(); } //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName, - const char* optionValue) - throw (SALOME::SALOME_Exception) -{ +void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); bool valueChanged = false; try { - valueChanged = ( this->GetImpl()->GetOptionValue(optionName) != optionValue ); - if ( valueChanged ) + valueChanged = (this->GetImpl()->GetOptionValue(optionName) != optionValue); + if (valueChanged) this->GetImpl()->SetOptionValue(optionName, optionValue); - } - catch (const std::invalid_argument& ex) { + } catch (const std::invalid_argument& ex) { SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetOptionValue(name,value)"; ExDescription.lineNumber = 0; throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - if ( valueChanged ) - SMESH::TPythonDump() << _this() << ".SetOptionValue( '" - << optionName << "', '" << optionValue << "' )"; + if (valueChanged) + SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )"; } //============================================================================= -char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName) - throw (SALOME::SALOME_Exception) -{ +char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); try { - return CORBA::string_dup( this->GetImpl()->GetOptionValue(optionName).c_str() ); - } - catch (const std::invalid_argument& ex) { + return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName).c_str()); + } catch (const std::invalid_argument& ex) { SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetOptionValue(name)"; ExDescription.lineNumber = 0; throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } return 0; @@ -462,8 +415,7 @@ char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName) //============================================================================= -void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName) -{ +void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName) { ASSERT(myBaseImpl); this->GetImpl()->ClearOption(optionName); SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )"; @@ -471,18 +423,17 @@ void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName) //============================================================================= -BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() -{ +BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() { ASSERT(myBaseImpl); BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array(); const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues(); - result->length( opts.size() ); + result->length(opts.size()); ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin(); - for ( int i = 0 ; opIt != opts.end(); ++opIt, ++i ) { + for (int i = 0; opIt != opts.end(); ++opIt, ++i) { string name_value = opIt->first; - if ( !opIt->second.empty() ) { + if (!opIt->second.empty()) { name_value += ":"; name_value += opIt->second; } @@ -494,60 +445,53 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() //============================================================================= void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options) - throw (SALOME::SALOME_Exception) -{ + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - for (int i = 0; i < options.length(); ++i) - { + for (int i = 0; i < options.length(); ++i) { string name_value = options[i].in(); - int colonPos = name_value.find( ':' ); + int colonPos = name_value.find(':'); string name, value; - if ( colonPos == string::npos ) // ':' not found + if (colonPos == string::npos) // ':' not found name = name_value; else { - name = name_value.substr( 0, colonPos); - if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ') - value = name_value.substr( colonPos+1 ); + name = name_value.substr(0, colonPos); + if (colonPos < name_value.size() - 1 && name_value[colonPos] != ' ') + value = name_value.substr(colonPos + 1); } - SetOptionValue( name.c_str(), value.c_str() ); + SetOptionValue(name.c_str(), value.c_str()); } } //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* sizeMap) - throw (SALOME::SALOME_Exception) -{ +void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry, const char* sizeMap) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry); + MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry); bool valueChanged = false; try { - valueChanged = ( this->GetImpl()->GetSizeMapEntry(entry) != sizeMap ); - if ( valueChanged ) + valueChanged = (this->GetImpl()->GetSizeMapEntry(entry) != sizeMap); + if (valueChanged) this->GetImpl()->SetSizeMapEntry(entry, sizeMap); - } - catch (const std::invalid_argument& ex) { + } catch (const std::invalid_argument& ex) { SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)"; ExDescription.lineNumber = 0; throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } MESSAGE("ENGINE : SETSIZEMAP END ENTRY : " << entry); - if ( valueChanged ) - SMESH::TPythonDump() << _this() << ".SetSizeMap(" - << entry << ", '" << sizeMap << "' )"; + if (valueChanged) + SMESH::TPythonDump() << _this() << ".SetSizeMap(" << entry << ", '" << sizeMap << "' )"; } //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* attractor ) - throw (SALOME::SALOME_Exception) -{ +void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry, const char* attractor) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry); bool valueChanged = false; @@ -559,25 +503,21 @@ void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False;d(opt.))"); this->GetImpl()->SetAttractorEntry(entry, attractor); } - } - catch (const std::invalid_argument& ex) { + } catch (const std::invalid_argument& ex) { SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)"; ExDescription.lineNumber = 0; throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry); - if ( valueChanged ) - SMESH::TPythonDump() << _this() << ".SetAttractor(" - << entry << ", '" << attractor << "' )"; + if (valueChanged) + SMESH::TPythonDump() << _this() << ".SetAttractor(" << entry << ", '" << attractor << "' )"; } - //============================================================================= void BLSURFPlugin_Hypothesis_i::SetClassAttractorEntry(const char* entry, const char* att_entry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius) //TODO à finir @@ -614,17 +554,15 @@ char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) { ASSERT(myBaseImpl); try { - return CORBA::string_dup( this->GetImpl()->GetSizeMapEntry(entry).c_str()); - } - catch (const std::invalid_argument& ex) { + return CORBA::string_dup(this->GetImpl()->GetSizeMapEntry(entry).c_str()); + } catch (const std::invalid_argument& ex) { SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)"; ExDescription.lineNumber = 0; throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } return 0; @@ -632,22 +570,18 @@ char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) //============================================================================= -char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry) - throw (SALOME::SALOME_Exception) -{ +char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); try { - return CORBA::string_dup( this->GetImpl()->GetAttractorEntry(entry).c_str()); - } - catch (const std::invalid_argument& ex) { + return CORBA::string_dup(this->GetImpl()->GetAttractorEntry(entry).c_str()); + } catch (const std::invalid_argument& ex) { SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)"; ExDescription.lineNumber = 0; throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } return 0; @@ -680,27 +614,25 @@ char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry) //============================================================================= -void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry) -{ - ASSERT(myBaseImpl); +void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry) { + ASSERT(myBaseImpl); this->GetImpl()->ClearEntry(entry); -// SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )"; + // SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )"; } //============================================================================= -BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries() -{ +BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries() { ASSERT(myBaseImpl); BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array(); - const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps= this->GetImpl()->_GetSizeMapEntries(); - result->length( sizeMaps.size() ); + const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps = this->GetImpl()->_GetSizeMapEntries(); + result->length(sizeMaps.size()); ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin(); - for ( int i = 0 ; smIt != sizeMaps.end(); ++smIt, ++i ) { + for (int i = 0; smIt != sizeMaps.end(); ++smIt, ++i) { string entry_sizemap = smIt->first; - if ( !smIt->second.empty() ) { + if (!smIt->second.empty()) { entry_sizemap += "|"; entry_sizemap += smIt->second; } @@ -711,18 +643,17 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries() //============================================================================= -BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries() -{ +BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries() { ASSERT(myBaseImpl); BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array(); - const ::BLSURFPlugin_Hypothesis::TSizeMap attractors= this->GetImpl()->_GetAttractorEntries(); - result->length( attractors.size() ); + const ::BLSURFPlugin_Hypothesis::TSizeMap attractors = this->GetImpl()->_GetAttractorEntries(); + result->length(attractors.size()); ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin(); - for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) { + for (int i = 0; atIt != attractors.end(); ++atIt, ++i) { string entry_attractor = atIt->first; - if ( !atIt->second.empty() ) { + if (!atIt->second.empty()) { entry_attractor += "|"; entry_attractor += atIt->second; } @@ -770,81 +701,71 @@ BLSURFPlugin::TAttParamsMap* BLSURFPlugin_Hypothesis_i::GetAttractorParams() //============================================================================= void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps) - throw (SALOME::SALOME_Exception) -{ + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - for (int i = 0; i < sizeMaps.length(); ++i) - { + for (int i = 0; i < sizeMaps.length(); ++i) { string entry_sizemap = sizeMaps[i].in(); - int colonPos = entry_sizemap.find( '|' ); + int colonPos = entry_sizemap.find('|'); string entry, sizemap; - if ( colonPos == string::npos ) // '|' separator not found + if (colonPos == string::npos) // '|' separator not found entry = entry_sizemap; else { - entry = entry_sizemap.substr( 0, colonPos); - if ( colonPos < entry_sizemap.size()-1 && entry_sizemap[colonPos] != ' ') - sizemap = entry_sizemap.substr( colonPos+1 ); + entry = entry_sizemap.substr(0, colonPos); + if (colonPos < entry_sizemap.size() - 1 && entry_sizemap[colonPos] != ' ') + sizemap = entry_sizemap.substr(colonPos + 1); } - this->GetImpl()->SetSizeMapEntry( entry.c_str(), sizemap.c_str() ); + this->GetImpl()->SetSizeMapEntry(entry.c_str(), sizemap.c_str()); } } //============================================================================= -void BLSURFPlugin_Hypothesis_i::ClearSizeMaps() -{ +void BLSURFPlugin_Hypothesis_i::ClearSizeMaps() { ASSERT(myBaseImpl); this->GetImpl()->ClearSizeMaps(); } - //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj,const char* sizeMap) -{ +void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap) { ASSERT(myBaseImpl); string entry; - entry=GeomObj->GetStudyEntry(); + entry = GeomObj->GetStudyEntry(); MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")"); - SetSizeMapEntry( entry.c_str(),sizeMap); + MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")"); + SetSizeMapEntry(entry.c_str(), sizeMap); } - + //============================================================================= -void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj) -{ +void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj) { ASSERT(myBaseImpl); string entry; - entry=GeomObj->GetStudyEntry(); + entry = GeomObj->GetStudyEntry(); MESSAGE("IDL : GetName : " << GeomObj->GetName()); MESSAGE("IDL : UNSETSIZEMAP ( "<< entry << ")"); - UnsetEntry( entry.c_str()); + UnsetEntry(entry.c_str()); SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )"; } - -void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor) -{ +void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor) { ASSERT(myBaseImpl); string entry; - entry=GeomObj->GetStudyEntry(); + entry = GeomObj->GetStudyEntry(); MESSAGE("IDL : GetName : " << GeomObj->GetName()); MESSAGE("IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")"); - SetAttractorEntry( entry.c_str(),attractor); + SetAttractorEntry(entry.c_str(), attractor); } -void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj) -{ +void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj) { ASSERT(myBaseImpl); string entry; - entry=GeomObj->GetStudyEntry(); + entry = GeomObj->GetStudyEntry(); MESSAGE("IDL : GetName : " << GeomObj->GetName()); MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")"); - UnsetEntry( entry.c_str()); + UnsetEntry(entry.c_str()); SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )"; } - void BLSURFPlugin_Hypothesis_i::SetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj, GEOM::GEOM_Object_ptr Attractor, double StartSize, double EndSize, double ActionRadius, double ConstantRadius) { ASSERT(myBaseImpl); @@ -870,111 +791,204 @@ void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj SMESH::TPythonDump() << _this() << ".UnsetAttractorGeom( " << entry.c_str() << " )"; } - /* -void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap) -{} + void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap) + {} -void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj) -{} + void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj) + {} -void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap ) throw (SALOME::SALOME_Exception) -{} + void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap ) throw (SALOME::SALOME_Exception) + {} -char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception) -{} + char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception) + {} -void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry) -{ - ASSERT(myBaseImpl); - this->GetImpl()->UnsetCustomSizeMap(entry); - SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )"; -} + void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry) + { + ASSERT(myBaseImpl); + this->GetImpl()->UnsetCustomSizeMap(entry); + SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )"; + } -BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries() -{} - -*/ + BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries() + {} + */ // /////////////////////// // // 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() -{ +/** + * Returns the list of enforced vertices for a given Face entry + * @return A map of Face entry / List of enforced vertices + * + */ +BLSURFPlugin::TFaceEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByFace() { + MESSAGE("IDL: GetAllEnforcedVerticesByFace()"); + ASSERT(myBaseImpl); + + BLSURFPlugin::TFaceEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexListMap(); + + const ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap = + this->GetImpl()->_GetAllEnforcedVerticesByFace(); + resultMap->length(faceEntryEnfVertexListMap.size()); + MESSAGE("Face entry to Enforced Vertex map size is " << resultMap->length()); + + ::BLSURFPlugin_Hypothesis::TEnfVertexList _enfVertexList; + ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap::const_iterator it_entry = faceEntryEnfVertexListMap.begin(); + for (int i = 0; it_entry != faceEntryEnfVertexListMap.end(); ++it_entry, ++i) { + BLSURFPlugin::TFaceEntryEnfVertexListMapElement_var mapElement = + new BLSURFPlugin::TFaceEntryEnfVertexListMapElement(); + mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str()); + MESSAGE("Face Entry: " << mapElement->faceEntry); + + _enfVertexList = it_entry->second; + BLSURFPlugin::TEnfVertexList_var enfVertexList = new BLSURFPlugin::TEnfVertexList(); + enfVertexList->length(_enfVertexList.size()); + MESSAGE("Number of enf vertex: " << enfVertexList->length()); + + ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator it_enfVertex = _enfVertexList.begin(); + ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex; + for (int j = 0; it_enfVertex != _enfVertexList.end(); ++it_enfVertex, ++j) { + currentEnfVertex = (*it_enfVertex); + + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + + // Name + enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str()); + + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str()); + + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(currentEnfVertex->coords.size()); + for (int i=0;ilength();i++) + coords[i] = currentEnfVertex->coords[i]; + enfVertex->coords = coords; + + // Group name + enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str()); + + // Face entry list + BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList(); + faceEntryList->length(currentEnfVertex->faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin(); + for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind) + faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str()); + enfVertex->faceEntries = faceEntryList; + + ostringstream msg; + msg << "Enforced vertex: \n" + << "Name: " << enfVertex->name << "\n"; + if (coords->length()) + msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n"; + msg << "Geom entry: " << enfVertex->geomEntry << "\n" + << "Group Name: " << enfVertex->grpName; + MESSAGE(msg.str()); + + enfVertexList[j] = enfVertex; + } + mapElement->enfVertexList = enfVertexList; + + resultMap[i] = mapElement; + + } + return resultMap._retn(); +} + +/** + * Returns the list of all enforced vertices + * @return a list of 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 " << resultMap->length()); + + ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin(); + ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex; + for (int i = 0; evlIt != enfVertexList.end(); ++evlIt, ++i) { + MESSAGE("Enforced Vertex #" << i); + currentEnfVertex = (*evlIt); + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + // Name + enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str()); + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str()); + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(currentEnfVertex->coords.size()); + for (int ind = 0; ind < coords->length(); ind++) + coords[ind] = currentEnfVertex->coords[ind]; + enfVertex->coords = coords; + // Group name + enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str()); + // Face entry list + BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList(); + faceEntryList->length(currentEnfVertex->faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin(); + for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind) + faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str()); + enfVertex->faceEntries = faceEntryList; + + ostringstream msg; + msg << "Enforced vertex: \n" + << "Name: " << enfVertex->name << "\n"; + if (coords->length()) + msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n"; + msg << "Geom entry: " << enfVertex->geomEntry << "\n" + << "Group Name: " << enfVertex->grpName; + MESSAGE(msg.str()); + + resultMap[i] = enfVertex; + } + return resultMap._retn(); + +} + +/** + * Returns the list of enforced vertices coords for a given Face entry. + * They are the coords of the "manual" enforced vertices. + * @return A map of Face entry / List of enforced vertices coords + * + */ +BLSURFPlugin::TFaceEntryCoordsListMap* BLSURFPlugin_Hypothesis_i::GetAllCoordsByFace() { MESSAGE("IDL: GetAllCoordsByFace()"); ASSERT(myBaseImpl); - - BLSURFPlugin::TEntryCoordsListMap_var resultMap = new BLSURFPlugin::TEntryCoordsListMap(); - - const ::BLSURFPlugin_Hypothesis::TEntryCoordsListMap entryCoordsListMap = this->GetImpl()->_GetAllCoordsByFace(); + + BLSURFPlugin::TFaceEntryCoordsListMap_var resultMap = new BLSURFPlugin::TFaceEntryCoordsListMap(); + + const ::BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap 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); - + ::BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap::const_iterator it_entry = entryCoordsListMap.begin(); + for (int i = 0; it_entry != entryCoordsListMap.end(); ++it_entry, ++i) { + BLSURFPlugin::TFaceEntryCoordsListMapElement_var mapElement = new BLSURFPlugin::TFaceEntryCoordsListMapElement(); + mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str()); + MESSAGE("Face Entry: " << mapElement->faceEntry); + _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 ) { + 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]; + coords->length((*it_coords).size()); + for (int i=0;ilength();i++) + coords[i] = (*it_coords)[i]; coordsList[j] = coords; MESSAGE("Coords #" << j << ": " << coords[0] << ", " << coords[1] << ", " << coords[2]); } @@ -986,522 +1000,842 @@ BLSURFPlugin::TEntryCoordsListMap* BLSURFPlugin_Hypothesis_i::GetAllCoordsByFace return resultMap._retn(); } -BLSURFPlugin::TCoordsEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByCoords() -{ +/** + * Returns a map of enforced vertices coords / enforced vertex. + * They are the coords of the "manual" enforced vertices. + */ +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()); + + 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 " << resultMap->length()); + + ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap::const_iterator it_coords = coordsEnfVertexMap.begin(); + ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex; + for (int i = 0; it_coords != coordsEnfVertexMap.end(); ++it_coords, ++i) { + MESSAGE("Enforced Vertex #" << i); + currentEnfVertex = (it_coords->second); + BLSURFPlugin::TCoordsEnfVertexElement_var mapElement = new BLSURFPlugin::TCoordsEnfVertexElement(); + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(it_coords->first.size()); + for (int ind=0;indlength();ind++) + coords[ind] = it_coords->first[ind]; + mapElement->coords = coords; + MESSAGE("Coords: " << mapElement->coords[0] << ", " << mapElement->coords[1] << ", " << mapElement->coords[2]); + + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + // Name + enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str()); + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str()); + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords2 = new BLSURFPlugin::TEnfVertexCoords(); + coords2->length(currentEnfVertex->coords.size()); + for (int ind=0;indlength();ind++) + coords2[ind] = currentEnfVertex->coords[ind]; + enfVertex->coords = coords2; + // Group name + enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str()); + // Face entry list + BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList(); + faceEntryList->length(currentEnfVertex->faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin(); + for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind) + faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str()); + enfVertex->faceEntries = faceEntryList; + + mapElement->enfVertex = enfVertex; + ostringstream msg; + msg << "Enforced vertex: \n" + << "Name: " << enfVertex->name << "\n"; + if (coords->length()) + msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n"; + msg << "Geom entry: " << enfVertex->geomEntry << "\n" + << "Group Name: " << enfVertex->grpName; + MESSAGE(msg.str()); + + resultMap[i] = mapElement; + } + return resultMap._retn(); } -void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices() -{ +/** + * Returns the list of enforced vertices entries for a given Face entry. + * They are the geom entries of the enforced vertices based on geom shape (vertex, compound, group). + * @return A map of Face entry / List of enforced vertices geom entries + * + */ +BLSURFPlugin::TFaceEntryEnfVertexEntryListMap* BLSURFPlugin_Hypothesis_i::GetAllEnfVertexEntriesByFace() { + MESSAGE("IDL: GetAllEnfVertexEntriesByFace()"); + ASSERT(myBaseImpl); + + BLSURFPlugin::TFaceEntryEnfVertexEntryListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexEntryListMap(); + + const ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap entryEnfVertexEntryListMap = + this->GetImpl()->_GetAllEnfVertexEntriesByFace(); + resultMap->length(entryEnfVertexEntryListMap.size()); + MESSAGE("Enforced Vertex map size is " << resultMap->length()); + + ::BLSURFPlugin_Hypothesis::TEntryList _enfVertexEntryList; + ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap::const_iterator it_entry = + entryEnfVertexEntryListMap.begin(); + for (int i = 0; it_entry != entryEnfVertexEntryListMap.end(); ++it_entry, ++i) { + BLSURFPlugin::TFaceEntryEnfVertexEntryListMapElement_var mapElement = + new BLSURFPlugin::TFaceEntryEnfVertexEntryListMapElement(); + mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str()); + MESSAGE("Face Entry: " << mapElement->faceEntry); + + _enfVertexEntryList = it_entry->second; + BLSURFPlugin::TEntryList_var enfVertexEntryList = new BLSURFPlugin::TEntryList(); + enfVertexEntryList->length(_enfVertexEntryList.size()); + MESSAGE("Number of enf vertex entries: " << enfVertexEntryList->length()); + + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_enfVertexEntry = _enfVertexEntryList.begin(); + for (int j = 0; it_enfVertexEntry != _enfVertexEntryList.end(); ++it_enfVertexEntry, ++j) { + enfVertexEntryList[j] = CORBA::string_dup((*it_enfVertexEntry).c_str()); + MESSAGE("Enf Vertex Entry #" << j << ": " << enfVertexEntryList[j]); + } + mapElement->enfVertexEntryList = enfVertexEntryList; + + resultMap[i] = mapElement; + + } + return resultMap._retn(); +} + +/** + * Returns a map of enforced vertices geom entry / enforced vertex. + * They are the geom entries of the enforced vertices defined with geom shape (vertex, compound, group). + */ +BLSURFPlugin::TEnfVertexEntryEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByEnfVertexEntry() { + MESSAGE("IDL: GetAllEnforcedVerticesByEnfVertexEntry()"); + ASSERT(myBaseImpl); + + BLSURFPlugin::TEnfVertexEntryEnfVertexMap_var resultMap = new BLSURFPlugin::TEnfVertexEntryEnfVertexMap(); + const ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap enfVertexEntryEnfVertexMap = + this->GetImpl()->_GetAllEnforcedVerticesByEnfVertexEntry(); + resultMap->length(enfVertexEntryEnfVertexMap.size()); + MESSAGE("Enforced Vertex map size is " << resultMap->length()); + + ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap::const_iterator it_enfVertexEntry = enfVertexEntryEnfVertexMap.begin(); + ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex; + for (int i = 0; it_enfVertexEntry != enfVertexEntryEnfVertexMap.end(); ++it_enfVertexEntry, ++i) { + MESSAGE("Enforced Vertex #" << i); + currentEnfVertex = it_enfVertexEntry->second; + BLSURFPlugin::TEnfVertexEntryEnfVertexElement_var mapElement = new BLSURFPlugin::TEnfVertexEntryEnfVertexElement(); + mapElement->enfVertexEntry = CORBA::string_dup(it_enfVertexEntry->first.c_str());; + MESSAGE("Enf Vertex Entry #" << i << ": " << mapElement->enfVertexEntry); + + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + // Name + enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str()); + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str()); + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(currentEnfVertex->coords.size()); + for (int ind=0;indlength();ind++) + coords[ind] = currentEnfVertex->coords[ind]; + enfVertex->coords = coords; + // Group name + enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str()); + // Face entry list + BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList(); + faceEntryList->length(currentEnfVertex->faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin(); + for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind) + faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str()); + enfVertex->faceEntries = faceEntryList; + + ostringstream msg; + msg << "Enforced vertex: \n" + << "Name: " << enfVertex->name << "\n"; + if (coords->length()) + msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n"; + msg << "Geom entry: " << enfVertex->geomEntry << "\n" + << "Group Name: " << enfVertex->grpName; + MESSAGE(msg.str()); + + mapElement->enfVertex = enfVertex; + resultMap[i] = mapElement; + } + return resultMap._retn(); +} + +/** + * Erase all enforced vertices + */ +void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices() { ASSERT(myBaseImpl); this->GetImpl()->ClearAllEnforcedVertices(); SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()"; } /*! - * Set/get/unset an enforced vertex on geom object - */ -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) -{ + * Set/get/unset an enforced vertex on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, + CORBA::Double z) 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 ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - - // TODO Affecter un nom de groupe vide + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); MESSAGE("IDL : GetName : " << theFace->GetName()); - MESSAGE("IDL : SetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << enfName << ")"); + MESSAGE("IDL : SetEnforcedVertex( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")"); try { - return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, enfName); - } - catch (SALOME_Exception& ex) { + return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z); + } 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) -{ + * Set/get/unset an enforced vertex with name on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, + CORBA::Double z, const char* theVertexName) 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 ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } + + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,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); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : SetEnforcedVertexNamed( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ")"); + try { + return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +/*! + * Set/get/unset an enforced vertex with geom object on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) + throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); + } + + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", 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); + + string theFaceEntry = theFace->GetStudyEntry(); + string theVertexEntry = theVertex->GetStudyEntry(); 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; + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; - CORBA::Double x,y,z; - x = y = z = 0.; - measureOp->PointCoordinates (theVertex, x, y, z); + if (theFaceEntry.empty()) { + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); - // TODO Affecter un nom de groupe vide - string theFaceEntry = theFace->GetStudyEntry(); - string theVertexEntry = theVertex->GetStudyEntry(); + if (theVertexEntry.empty()) { + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + string theVertexName = theVertex->GetName(); MESSAGE("IDL : theFace->GetName : " << theFace->GetName()); MESSAGE("IDL : theVertex->GetName : " << theVertexName); - MESSAGE("IDL : SetEnforcedVertexWithPoint ( "<< theFaceEntry << ", " << theVertexEntry<< ", " << theVertexName<< ", " << x << ", " << y << ", " << z << ")"); + MESSAGE("IDL : SetEnforcedVertexGeom( "<< theFaceEntry << ", " << theVertexEntry<< ")"); try { - return SetEnforcedVertexEntryWithPoint(theFaceEntry.c_str(), theVertexEntry.c_str(), theVertexName.c_str(), x, y, z); - } - catch (SALOME_Exception& ex) { + return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str()); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } /*! - * Set/get/unset an enforced vertex on geom object with group name - */ -/* TODO GROUPS -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) + * Set an enforced vertex with group name on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - - if (theFace->GetShapeType() != GEOM::FACE) - { - MESSAGE("theFace shape type is not FACE"); - return; + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - - // TODO check that theFace is a face => in engine ? + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); MESSAGE("IDL : GetName : " << theFace->GetName()); - MESSAGE("IDL : SetEnforcedVertexWithGroup ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << groupName <<")"); + MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theGroupName << ")"); try { - SetEnforcedVertexEntryWithGroup(theFaceEntry.c_str(), x, y, z, groupName); - } - catch (SALOME_Exception& ex) { + return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, "", "", theGroupName); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } -*/ -BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) - throw (SALOME::SALOME_Exception) + +/*! + * Set an enforced vertex with name and group name on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* theVertexName, const char* theGroupName) + 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 ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); MESSAGE("IDL : GetName : " << theFace->GetName()); - MESSAGE("IDL : GetEnforcedVertexList ( "<< theFaceEntry << ")"); + MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theGroupName << ")"); try { - return GetEnforcedVerticesEntry(theFaceEntry.c_str()); - } - catch (SALOME_Exception& ex) { + return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName, "", theGroupName); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } - -bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception) +/*! + * Set an enforced vertex with geom entry and group name on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName) + 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 ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - + + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); + } + string theFaceEntry = theFace->GetStudyEntry(); - MESSAGE("IDL : GetName : " << theFace->GetName()); - MESSAGE("IDL : UnsetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")"); + string theVertexEntry = theVertex->GetStudyEntry(); + + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + + if (theFaceEntry.empty()) { + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + if (theVertexEntry.empty()) { + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + string theVertexName = theVertex->GetName(); + MESSAGE("IDL : theFace->GetName : " << theFace->GetName()); + MESSAGE("IDL : theVertex->GetName : " << theVertexName); + MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theFaceEntry << ", " << theVertexEntry<< ", " << theGroupName<< ")"); try { - return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z); - } - catch (SALOME_Exception& ex) { + return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } -bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexWithPoint(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) - throw (SALOME::SALOME_Exception) -{ +/*! + * Get the list of all enforced vertices + */ +BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) + 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); + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } + + string theFaceEntry = theFace->GetStudyEntry(); - 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 << ")"); + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : GetEnforcedVertexList ( "<< theFaceEntry << ")"); try { - return UnsetEnforcedVertexEntryWithPoint(theFaceEntry.c_str(), theVertexEntry.c_str(), x, y, z); - } - catch (SALOME_Exception& ex) { + return GetEnforcedVerticesEntry(theFaceEntry.c_str()); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } - -bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) - throw (SALOME::SALOME_Exception) -{ +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); - - 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 ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); MESSAGE("IDL : GetName : " << theFace->GetName()); - MESSAGE("IDL : UnsetEnforcedVertices ( "<< theFaceEntry << ")"); + MESSAGE("IDL : UnsetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")"); try { - return UnsetEnforcedVerticesEntry(theFaceEntry.c_str()); - } - catch (SALOME_Exception& ex) { + return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z); + } 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) -{ +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("_setEnfVertex(" << theFaceEntry << "," << x << "," << y << "," << z << "," << theVertexEntry<< "," << enfName << ")"); - bool newValue = false; - - try { - ::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("Coords already found"); - } + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - catch (const std::invalid_argument& ex) { - // no enforced vertex for entry - MESSAGE("Face entry not found : add it to the list") - newValue = true; + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", 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(); - if ( newValue ) - this->GetImpl()->SetEnforcedVertex(theFaceEntry, x, y, z, enfName, theVertexEntry); + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; - 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 << ")"); + if (theFaceEntry.empty()) { + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); - try { - this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); - return true; - } - catch (const std::invalid_argument& ex) { - return false; - } -} + if (theVertexEntry.empty()) { + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + MESSAGE("IDL : UnsetEnforcedVertexGeom ( "<< theFaceEntry << ", " << theVertexEntry << ")"); -/*! - * 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) { + return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexEntry.c_str()); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - - if ( newValue ) - SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" - << 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 BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); + } + + string theFaceEntry = theFace->GetStudyEntry(); - bool newValue = false; + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : UnsetEnforcedVertices ( "<< theFaceEntry << ")"); + try { - newValue = _setEnfVertex(theFaceEntry, x, y, z, theVertexEntry, theVertexName); - } - catch (SALOME_Exception& ex) { + return UnsetEnforcedVerticesEntry(theFaceEntry.c_str()); + } 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; } /*! - * Set/get/unset an enforced vertex on geom object given by entry - */ -/* TODO GROUPS -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntryWithGroup(const char* entry, - double x, double y, double z, const char* groupName) - throw (SALOME::SALOME_Exception) -{ + * 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* theVertexName, const char* theVertexEntry, const char* theGroupName) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("IDL : SETENFORCEDVERTEXWITHGROUP START - ENTRY: " << entry << " VERTEX: " - << x << " " << y << " " << z << " group name: " << groupName); + MESSAGE("IDL : SetEnforcedVertexEntry(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\")"); bool newValue = false; - bool newGroupName = 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"); + + if (string(theVertexEntry).empty()) { + try { + ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList coordsList = + this->GetImpl()->GetEnfVertexCoordsList(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("Coords already found, compare names"); + ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex(coords); + if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) { + MESSAGE("The names are different: update"); +// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); + newValue = true; + } + else { + MESSAGE("The names are identical"); + } + } + } catch (const std::invalid_argument& ex) { + // no enforced vertex for entry + MESSAGE("Face entry not found : add it to the list"); newValue = true; } - else { - MESSAGE("Vertex already found"); - std::string oldGroupName = this->GetImpl()->GetEnforcedVertexGroupName(x,y,z); - if (strcmp(oldGroupName.c_str(),groupName)!=0) - newGroupName = true; - } - } - catch (const std::invalid_argument& ex) { - // no enforced vertex for entry - MESSAGE("Entry not found : add it to the list"); - newValue = true; - } - catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } - - if ( newValue ) { - this->GetImpl()->SetEnforcedVertex(entry, x, y, z, groupName); - SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup(" - << entry << ", " - << x << ", " - << y << ", " - << z << ", '" - << groupName << "')"; - } - else { - if (newGroupName) { - this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName); - SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName(" - << x << ", " - << y << ", " - << z << ", '" - << groupName << "')"; + if (newValue) + if (string(theVertexName).empty()) + if (string(theGroupName).empty()) + SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ")"; + else + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theGroupName << "\")"; + else + if (string(theGroupName).empty()) + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamed(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\")"; + else + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamedWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" + << theVertexName << "\", \"" << theGroupName << "\")"; + } else { + try { + ::BLSURFPlugin_Hypothesis::TEntryList enfVertexEntryList = this->GetImpl()->GetEnfVertexEntryList(theFaceEntry); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it = enfVertexEntryList.find(theVertexEntry); + if ( it == enfVertexEntryList.end()) { + MESSAGE("Geom entry not found: add it in enfVertexEntryList"); + newValue = true; + } + else { + MESSAGE("Geom entry already found, compare names"); + ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex((*it)); + if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) { + MESSAGE("The names are different: update"); +// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); + newValue = true; + } + else { + MESSAGE("The names are identical"); + } + } + } catch (const std::invalid_argument& ex) { + // no enforced vertex for entry + MESSAGE("Face entry not found : add it to the list"); + newValue = true; } + if (newValue) + if (string(theGroupName).empty()) + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")"; + else + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeomWithGroup(" << theFaceEntry << ", " << theVertexEntry << ", \"" << theGroupName << "\")"; } - MESSAGE("IDL : SETENFORCEDVERTEXWITHGROUP END - ENTRY: " << entry); -} -*/ -/* -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) - throw (SALOME::SALOME_Exception) -{ - ASSERT(myBaseImpl); + + if (newValue) + this->GetImpl()->SetEnforcedVertex(theFaceEntry, theVertexName, theVertexEntry, theGroupName, x, y, z); + + MESSAGE("IDL : SetEnforcedVertexEntry END"); + return newValue; } -*/ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry) - throw (SALOME::SALOME_Exception) -{ + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); MESSAGE("ENGINE : GetEnforcedVerticesEntry START ENTRY : " << entry); - + try { BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList(); - ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnforcedVertices(entry); + ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnfVertexList(entry); vertexList->length(_vList.size()); - MESSAGE("Number of enforced vertices: " << _vList.size()); + MESSAGE("Number of enforced vertices: " << vertexList->length()); ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin(); - for ( int i = 0; evlIt != _vList.end() ; ++evlIt, ++i ) { - ::BLSURFPlugin_Hypothesis::TEnfVertex _enfVertex = (*evlIt); - + for (int i = 0; evlIt != _vList.end(); ++evlIt, ++i) { + ::BLSURFPlugin_Hypothesis::TEnfVertex *_enfVertex = (*evlIt); + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); - + // Name - enfVertex->name = CORBA::string_dup(_enfVertex.name.c_str()); + enfVertex->name = CORBA::string_dup(_enfVertex->name.c_str()); // Geom Vertex Entry - enfVertex->geomEntry = CORBA::string_dup(_enfVertex.geomEntry.c_str()); + 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]; + coords->length(_enfVertex->coords.size()); + for (int ind=0;indlength();ind++) + coords[ind] = _enfVertex->coords[ind]; 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; - + // Group Name + enfVertex->grpName = CORBA::string_dup(_enfVertex->grpName.c_str()); + // Face entry list + BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList(); + faceEntryList->length(_enfVertex->faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = _enfVertex->faceEntries.begin(); + for (int ind = 0; it_entry != _enfVertex->faceEntries.end();++it_entry, ++ind) + faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str()); + enfVertex->faceEntries = faceEntryList; + 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) { + } catch (const std::invalid_argument& ex) { SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)"; - ExDescription.lineNumber = 1265; + ExDescription.lineNumber = 1385; throw SALOME::SALOME_Exception(ExDescription); - } - catch(const std::exception& ex) { + } catch (const std::exception& ex) { std::cout << "Exception: " << ex.what() << std::endl; THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, + CORBA::Double z, const char* theVertexEntry) throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + MESSAGE("IDL : UnsetEnforcedVertexEntry(" << theFaceEntry << "," << x << "," << y << "," << z << ", " << theVertexEntry << ")"); -bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("ENGINE : UnsetEnforcedVertexEntry START ENTRY : " << theFaceEntry); - bool ret = false; try { - ret = _unsetEnfVertex(theFaceEntry, x, y, z); - } - catch (SALOME_Exception& ex) { + this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z, theVertexEntry); + + if (string(theVertexEntry).empty()) + SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z + << ")"; + else + SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")"; + + } catch (const std::invalid_argument& ex) { + return false; + } catch (const std::exception& ex) { + std::cout << "Exception: " << ex.what() << std::endl; THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - - if (ret) - SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex(" - << theFaceEntry << ", " - << x << ", " - << y << ", " - << z << ")"; MESSAGE("ENGINE : UnsetEnforcedVertexEntry END ENTRY : " << theFaceEntry); - return ret; + return true; } -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 (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } - - if (ret) - SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertexWithPoint(" - << theFaceEntry << ", " - << theVertexEntry << ")"; +//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 (SALOME_Exception& ex) { +// THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); +// } +// +// if (ret) +// SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertexWithPoint(" << theFaceEntry << ", " << theVertexEntry +// << ")"; +// +// MESSAGE("IDL : UnsetEnforcedVertexEntryWithPoint END ENTRY : " << theFaceEntry); +// return ret; +//} - MESSAGE("IDL : UnsetEnforcedVertexEntryWithPoint END ENTRY : " << theFaceEntry); - return ret; -} -/* -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) - throw (SALOME::SALOME_Exception) -{ +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); -} -*/ -bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* theFaceEntry) - throw (SALOME::SALOME_Exception) -{ - ASSERT(myBaseImpl); - MESSAGE("IDL : UnsetEnforcedVerticesEntry START ENTRY : " << theFaceEntry); - + MESSAGE("IDL : UnsetEnforcedVerticesEntry(" << theFaceEntry << ")"); + try { this->GetImpl()->ClearEnforcedVertices(theFaceEntry); SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << theFaceEntry << ")"; - } - catch (const std::invalid_argument& ex) { + } catch (const std::invalid_argument& ex) { return false; - } - catch(const std::exception& ex) { + } catch (const std::exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } @@ -1510,62 +1844,59 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* theFaceEn } /* TODO GROUPS -char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception) -{ - ASSERT(myBaseImpl); - MESSAGE("ENGINE : GetEnforcedVertexGroupName START "); - try { - return CORBA::string_dup( this->GetImpl()->GetEnforcedVertexGroupName(x, y, z).c_str()); - } - catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(entry)"; - ExDescription.lineNumber = 1146; - throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } - MESSAGE("ENGINE : GetEnforcedVertexGroupName END "); - return 0; -} - - -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) - throw (SALOME::SALOME_Exception) -{ - ASSERT(myBaseImpl); - MESSAGE("ENGINE : SetEnforcedVertexGroupName START "); - try { - this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName); - } - catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(x,y,z)"; - ExDescription.lineNumber = 1170; - throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } - - SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName(" - << x << ", " << y << ", " << z << ", '" << groupName << "' )"; - - MESSAGE("ENGINE : SetEnforcedVertexGroupName END "); -} -*/ + char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception) + { + ASSERT(myBaseImpl); + MESSAGE("ENGINE : GetEnforcedVertexGroupName START "); + try { + return CORBA::string_dup( this->GetImpl()->GetEnforcedVertexGroupName(x, y, z).c_str()); + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(entry)"; + ExDescription.lineNumber = 1146; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + MESSAGE("ENGINE : GetEnforcedVertexGroupName END "); + return 0; + } + + + void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) + throw (SALOME::SALOME_Exception) + { + ASSERT(myBaseImpl); + MESSAGE("ENGINE : SetEnforcedVertexGroupName START "); + try { + this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName); + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(x,y,z)"; + ExDescription.lineNumber = 1170; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName(" + << x << ", " << y << ", " << z << ", '" << groupName << "' )"; + + MESSAGE("ENGINE : SetEnforcedVertexGroupName END "); + } + */ /////////////////////// - - - //============================================================================= /*! * BLSURFPlugin_Hypothesis_i::GetImpl @@ -1573,22 +1904,20 @@ void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORB * Get implementation */ //============================================================================= -::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl() -{ +::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl() { // MESSAGE("BLSURFPlugin_Hypothesis_i::GetImpl"); - return (::BLSURFPlugin_Hypothesis*)myBaseImpl; + return (::BLSURFPlugin_Hypothesis*) myBaseImpl; } //================================================================================ /*! * \brief Verify whether hypothesis supports given entity type - * \param type - dimension (see SMESH::Dimension enumeration) - * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise * * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ //================================================================================ -CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type ) -{ +CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported(SMESH::Dimension type) { return type == SMESH::DIM_2D; } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index b3d12ee..85c6200 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -37,15 +37,11 @@ class GEOM_Object; // BLSURFPlugin parameters hypothesis -class BLSURFPlugin_Hypothesis_i: - public virtual POA_BLSURFPlugin::BLSURFPlugin_Hypothesis, - public virtual SMESH_Hypothesis_i -{ - public: +class BLSURFPlugin_Hypothesis_i: public virtual POA_BLSURFPlugin::BLSURFPlugin_Hypothesis, + public virtual SMESH_Hypothesis_i { +public: // Constructor - BLSURFPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl); + BLSURFPlugin_Hypothesis_i(PortableServer::POA_ptr thePOA, int theStudyId, ::SMESH_Gen* theGenImpl); // Destructor virtual ~BLSURFPlugin_Hypothesis_i(); @@ -91,8 +87,7 @@ class BLSURFPlugin_Hypothesis_i: void SetVerbosity(CORBA::Short theVal) throw (SALOME::SALOME_Exception); CORBA::Short GetVerbosity(); - void SetOptionValue(const char* optionName, - const char* optionValue) throw (SALOME::SALOME_Exception); + void SetOptionValue(const char* optionName, const char* optionValue) throw (SALOME::SALOME_Exception); char* GetOptionValue(const char* optionName) throw (SALOME::SALOME_Exception); void UnsetOption(const char* optionName); @@ -101,9 +96,9 @@ class BLSURFPlugin_Hypothesis_i: void SetOptionValues(const BLSURFPlugin::string_array& options) throw (SALOME::SALOME_Exception); - void SetSizeMapEntry(const char* entry,const char* sizeMap ) throw (SALOME::SALOME_Exception); - - char* GetSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception); + void SetSizeMapEntry(const char* entry, const char* sizeMap) throw (SALOME::SALOME_Exception); + + char* GetSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception); void UnsetEntry(const char* entry); @@ -117,14 +112,13 @@ class BLSURFPlugin_Hypothesis_i: void ClearSizeMaps(); - void SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor); void UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj); - void SetAttractorEntry(const char* entry,const char* attractor ) throw (SALOME::SALOME_Exception); + void SetAttractorEntry(const char* entry, const char* attractor) throw (SALOME::SALOME_Exception); - char* GetAttractorEntry(const char* entry) throw (SALOME::SALOME_Exception); + char* GetAttractorEntry(const char* entry) throw (SALOME::SALOME_Exception); BLSURFPlugin::string_array* GetAttractorEntries(); @@ -142,83 +136,84 @@ class BLSURFPlugin_Hypothesis_i: BLSURFPlugin::TAttParamsMap* GetAttractorParams(); + /* + void SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap); -/* - void SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap); - - void UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj); + void UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj); - void SetCustomSizeMapEntry(const char* entry,const char* sizeMap ) throw (SALOME::SALOME_Exception); + void SetCustomSizeMapEntry(const char* entry,const char* sizeMap ) throw (SALOME::SALOME_Exception); - char* GetCustomSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception); + char* GetCustomSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception); - BLSURFPlugin::string_array* GetCustomSizeMapEntries(); -*/ + BLSURFPlugin::string_array* GetCustomSizeMapEntries(); + */ /////////////////////// // ENFORCED VERTEXES // /////////////////////// - -// BLSURFPlugin::TEnfVertexList* GetAllEnforcedVertices(); - BLSURFPlugin::TEntryCoordsListMap* GetAllCoordsByFace(); - BLSURFPlugin::TCoordsEnfVertexMap* GetAllEnforcedVerticesByCoords(); - void ClearAllEnforcedVertices(); + + BLSURFPlugin::TFaceEntryEnfVertexListMap* GetAllEnforcedVerticesByFace(); + BLSURFPlugin::TEnfVertexList* GetAllEnforcedVertices(); + + BLSURFPlugin::TFaceEntryCoordsListMap* GetAllCoordsByFace(); + BLSURFPlugin::TCoordsEnfVertexMap* GetAllEnforcedVerticesByCoords(); + + BLSURFPlugin::TFaceEntryEnfVertexEntryListMap* GetAllEnfVertexEntriesByFace(); + BLSURFPlugin::TEnfVertexEntryEnfVertexMap* GetAllEnforcedVerticesByEnfVertexEntry(); + + void ClearAllEnforcedVertices(); /*! - * Set/get/unset an enforced vertex on geom object - */ - 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); + * Set/get/unset an enforced vertex on geom object + */ + bool SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName) + throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) + throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName) + throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName, const char* theGroupName) + throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName) + 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 theFace) 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 theFace, BLSURFPlugin::TEnfVertexList& vertexList) 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 UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) + 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 - */ - 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); - + * Set/get/unset an enforced vertex on geom object given by entry + */ + bool SetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x = 0, CORBA::Double y = 0, CORBA::Double z = 0, + const char* theVertexName = "", const char* theVertexEntry = "", const char* theGroupName = "") + throw (SALOME::SALOME_Exception); + BLSURFPlugin::TEnfVertexList* GetEnforcedVerticesEntry(const char* theFaceEntry) 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 UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* theVertexEntry = "") throw (SALOME::SALOME_Exception); bool UnsetEnforcedVerticesEntry(const char* theFaceEntry) 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 - */ + * 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); + */ /////////////////////// // Get implementation ::BLSURFPlugin_Hypothesis* GetImpl(); // Verify whether hypothesis supports given entity type - CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + CORBA::Boolean IsDimSupported(SMESH::Dimension type); }; #endif diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index f045ca6..d132042 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -120,7 +120,7 @@ enum { ENF_VER_Y_COLUMN, ENF_VER_Z_COLUMN, ENF_VER_ENTRY_COLUMN, -// ENF_VER_GROUP_COLUMN, + ENF_VER_GROUP_COLUMN, ENF_VER_NB_COLUMNS }; @@ -146,7 +146,8 @@ enum { enum { SMP_ATT_SHAPE, SMP_ATT_SIZE, - SMP_ATT_DIST + SMP_ATT_DIST, + SMP_ATT_RAD }; enum { @@ -166,11 +167,11 @@ enum { ENF_VER_X_COORD, ENF_VER_Y_COORD, ENF_VER_Z_COORD, -// ENF_VER_GROUP, + ENF_VER_GROUP, ENF_VER_VERTEX_BTN, ENF_VER_REMOVE_BTN, // ENF_VER_SEPARATOR, -// ENF_VER_GROUP_CHECK, + ENF_VER_GROUP_CHECK, ENF_VER_NB_LINES }; @@ -206,15 +207,15 @@ PyStdOut_write(PyStdOut *self, PyObject *args) return Py_None; } -static PyMethodDef PyStdOut_methods[] = { +static PyMethodDef PyStdOut_methods[] = { {"write", (PyCFunction)PyStdOut_write, METH_VARARGS, - PyDoc_STR("write(string) -> None")}, + PyDoc_STR("write(string) -> None")}, {NULL, NULL} /* sentinel */ }; static PyMemberDef PyStdOut_memberlist[] = { - {(char *)"softspace", T_INT, offsetof(PyStdOut, softspace), 0, - (char *)"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 */ }; @@ -282,8 +283,6 @@ End initialization Python structures and objects **************************************************/ -class QDoubleValidator; - // // BEGIN EnforcedTreeWidgetDelegate // @@ -297,35 +296,42 @@ QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & option , const QModelIndex & index ) const { -// QLineEdit *editor = new QLineEdit(parent); + QModelIndex father = index.parent(); + QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString(); + if (index.column() == ENF_VER_X_COLUMN || \ - index.column() == ENF_VER_Y_COLUMN || \ - index.column() == ENF_VER_Z_COLUMN) + index.column() == ENF_VER_Y_COLUMN || \ + index.column() == ENF_VER_Z_COLUMN) { SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent); editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + editor->setReadOnly(!entry.isEmpty()); + editor->setDisabled(!entry.isEmpty()); return editor; } -// editor->setValidator(new QDoubleValidator(parent)); else { QLineEdit *editor = new QLineEdit(parent); + if (index.column() != ENF_VER_GROUP_COLUMN) { + editor->setReadOnly(!entry.isEmpty()); + editor->setDisabled(!entry.isEmpty()); + } return editor; } -// return editor; } void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString value = index.model()->data(index, Qt::EditRole).toString(); - if (index.column() == ENF_VER_X_COLUMN || \ - index.column() == ENF_VER_Y_COLUMN || \ - index.column() == ENF_VER_Z_COLUMN) { + + if (index.column() == ENF_VER_X_COLUMN || + index.column() == ENF_VER_Y_COLUMN || + index.column() == ENF_VER_Z_COLUMN) + { SMESHGUI_SpinBox *lineEdit = static_cast(editor); lineEdit->setText(value); -// lineEdit->editor()->setText(value); } else { QLineEdit *lineEdit = static_cast(editor); @@ -336,32 +342,26 @@ void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor, void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { -// QLineEdit *lineEdit = static_cast(editor); - - if (index.column() == ENF_VER_X_COLUMN || \ - index.column() == ENF_VER_Y_COLUMN || \ - index.column() == ENF_VER_Z_COLUMN) - { + QModelIndex parent = index.parent(); + QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString(); + if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) { SMESHGUI_SpinBox *lineEdit = static_cast(editor); - if (! vertexExists(model, index, lineEdit->GetString())) { + if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString())) model->setData(index, lineEdit->GetValue(), Qt::EditRole); - } - } - else if (index.column() == ENF_VER_NAME_COLUMN) { + } else if (index.column() == ENF_VER_NAME_COLUMN) { QLineEdit *lineEdit = static_cast(editor); QString value = lineEdit->text(); - if (! vertexExists(model, index, value)) { + if (entry.isEmpty() && !vertexExists(model, index, value)) model->setData(index, value, Qt::EditRole); - } -// MESSAGE("Value " << value.toString().toStdString() << " was set at index(" << index.row() << "," << index.column() << ")"); - } - /* TODO GROUPS - else if (index.column() == ENF_VER_GROUP_COLUMN) { + } else if (index.column() == ENF_VER_ENTRY_COLUMN) { + QLineEdit *lineEdit = static_cast(editor); + QString value = lineEdit->text(); + if (! vertexExists(model, index, value)) + model->setData(index, value, Qt::EditRole); + } else if (index.column() == ENF_VER_GROUP_COLUMN) { QLineEdit *lineEdit = static_cast(editor); model->setData(index, lineEdit->text(), Qt::EditRole); -// MESSAGE("Value " << value.toString().toStdString() << " was set at index(" << index.row() << "," << index.column() << ")"); } - */ } void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor, @@ -377,8 +377,8 @@ bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model, QModelIndex parent = index.parent(); int row = index.row(); int col = index.column(); - - if (parent.isValid()) { + + if (parent.isValid() && !value.isEmpty()) { if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) { double x, y, z; if (col == ENF_VER_X_COLUMN) { @@ -396,23 +396,36 @@ bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model, x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble(); y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble(); } - // MESSAGE("Checking for existing vertex " << x << ", " << y << "," << z); int nbChildren = model->rowCount(parent); for (int i = 0 ; i < nbChildren ; i++) { if (i != row) { double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble(); double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble(); double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble(); -// MESSAGE("Vertex: " << childX << ", " << childY << "," << childZ); if ((childX == x) && (childY == y) && (childZ == z)) { -// MESSAGE("Found !"); exists = true; break; } } } } - else if (index.column() == ENF_VER_NAME_COLUMN) { +// else if (col == ENF_VER_ENTRY_COLUMN) { +// // Compare entries if no coords (= selected geom) +// xString = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toString(); +// if (xString.isEmpty) { +// int nbChildren = model->rowCount(parent); +// for (int i = 0 ; i < nbChildren ; i++) { +// if (i != row) { +// QString childName = parent.child(i, ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString(); +// if (childName == value) { +// exists = true; +// break; +// } +// } +// } +// } +// } + else if (col == ENF_VER_NAME_COLUMN) { int nbChildren = model->rowCount(parent); for (int i = 0 ; i < nbChildren ; i++) { if (i != row) { @@ -433,6 +446,75 @@ bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model, // END EnforcedTreeWidgetDelegate // +// +// BEGIN BLSURFPluginGUI_ObjectReferenceParamWdg +// +//================================================================================ + +// BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg +// ( SUIT_SelectionFilter* f, QWidget* parent, bool multiSelection) +// : StdMeshersGUI_ObjectReferenceParamWdg(f, parent, multiSelection) +// { +// init(); +// } +// +// +// BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg +// ( MeshObjectType objType, QWidget* parent, bool multiSelection ) +// : StdMeshersGUI_ObjectReferenceParamWdg( objType, parent, multiSelection ) +// { +// init(); +// } +// +// BLSURFPluginGUI_ObjectReferenceParamWdg::~BLSURFPluginGUI_ObjectReferenceParamWdg() +// { +// if ( myFilter ) +// { +// mySelectionMgr->removeFilter( myFilter ); +// delete myFilter; +// } +// } +// +// void BLSURFPluginGUI_ObjectReferenceParamWdg::init() +// { +// StdMeshersGUI_ObjectReferenceParamWdg::init(); +// disconnect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection())); +// connect( mySelButton, SIGNAL(toggled(bool)), SLOT(setActivationStatus(bool))); +// } +// +// void BLSURFPluginGUI_ObjectReferenceParamWdg::setActivationStatus(bool status) +// { +// if (status) +// activateSelection(); +// else +// deactivateSelection(); +// } +// +// void BLSURFPluginGUI_ObjectReferenceParamWdg::activateSelectionOnly() +// { +// if ( !mySelectionActivated && mySelectionMgr ) +// { +// mySelectionActivated = true; +// mySelectionMgr->clearFilters(); +// if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) +// aViewWindow->SetSelectionMode(ActorSelection); +// if ( myFilter ) +// mySelectionMgr->installFilter( myFilter ); +// connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); +// } +// emit selectionActivated(); +// } +// +// void BLSURFPluginGUI_ObjectReferenceParamWdg::deactivateSelectionOnly() +// { +// mySelectionActivated = false; +// disconnect(mySelectionMgr, 0, this, 0 ); +// mySelectionMgr->removeFilter( myFilter ); +// } +// +// +// END BLSURFPluginGUI_ObjectReferenceParamWdg +// /** * \brief {BLSURFPluginGUI_HypothesisCreator constructor} @@ -464,7 +546,7 @@ BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QStr PyRun_SimpleString("from math import *"); PyGILState_Release(gstate); - + } BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator() @@ -476,43 +558,17 @@ BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator() * */ GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() { -// MESSAGE("BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool"); BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); -// MESSAGE("aStudy->StudyId(): " << aStudy->StudyId()); if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) { -// MESSAGE("GeomToolSelected is created"); that->GeomToolSelected = new GeomSelectionTools(aStudy); } -// else -// MESSAGE("GeomToolSelected already exists"); -// MESSAGE("that->GeomToolSelected->getMyStudy()->StudyId(): " << that->GeomToolSelected->getMyStudy()->StudyId()); 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(); - bool isOk = true; - if ( !str.isEmpty() ) - str.toDouble(&isOk); - else - isOk = emptyOK; - return isOk; - } } @@ -520,28 +576,7 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const { MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams"); bool ok = true; -// if ( !isDouble( myPhySize->text(), false )) { -// if ( myPhySize->text().isEmpty() ) -// myPhySize->setText(tr("OBLIGATORY_VALUE")); -// myPhySize->selectAll(); -// ok = false; -// } -// if ( !isDouble( myPhyMin->text(), true )) { -// myPhyMin->selectAll(); -// ok = false; -// } -// if ( !isDouble( myPhyMax->text(), true )) { -// myPhyMax->selectAll(); -// ok = false; -// } -// if ( !isDouble( myGeoMin->text(), true )) { -// myGeoMin->selectAll(); -// ok = false; -// } -// if ( !isDouble( myGeoMin->text(), true )) { -// myGeoMin->selectAll(); -// ok = false; -// } + if ( ok ) { myOptionTable->setFocus(); @@ -610,14 +645,14 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const // Enforced vertices // TODO - + return ok; } QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() { MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame"); - + QFrame* fr = new QFrame( 0 ); // fr-> setMinimumSize(600,400); QVBoxLayout* lay = new QVBoxLayout( fr ); @@ -682,7 +717,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() #endif myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup ); myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup ); - + // ADD WIDGETS (STANDARD TAB) int row = 0; if( isCreation() ) { @@ -747,8 +782,8 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() QPushButton* addBtn = new QPushButton( tr( "ADD_OPTION"), myAdvGroup ); addBtn->setMenu( new QMenu() ); QPushButton* rmBtn = new QPushButton( tr( "REMOVE_OPTION"), myAdvGroup ); - - + + // ADD WIDGETS (ADVANCED TAB) anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ), 0, 0, 1, 1 ); anAdvLayout->addWidget( myTopology, 0, 1, 1, 1 ); @@ -788,6 +823,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() mySizeMapTable->resizeColumnToContents(SMP_DIST_COLUMN); mySizeMapTable->setAlternatingRowColors(true); mySizeMapTable->verticalHeader()->hide(); + mySizeMapTable->setShowGrid(true); // Filters of selection @@ -822,8 +858,10 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() // myAttractorGroup->setEnabled(false); QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup); myAttDistSpin = new QDoubleSpinBox(myAttractorGroup); + myAttDistSpin2 = new QDoubleSpinBox(myAttractorGroup); myAttSizeSpin = new QDoubleSpinBox(myAttractorGroup); myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup); + myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup); myAttSizeLabel = new QLabel(tr("BLSURF_ATT_SIZE"),myAttractorGroup); myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false,/*stretch=*/false); myAttSelWdg->SetDefaultText("Select a Shape", "QLineEdit { color: grey }"); @@ -861,14 +899,17 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() // Parameters of SpinBoxes myAttDistSpin->setMaximum(1000); // TODO use preferences of SALOME + myAttDistSpin2->setMaximum(1000); mySmpDistSpin->setMaximum(1000); myAttSizeSpin->setMaximum(1000); mySmpSizeSpin->setMaximum(1000); myAttDistSpin->setDecimals(4); + myAttDistSpin2->setDecimals(4); mySmpDistSpin->setDecimals(4); myAttSizeSpin->setDecimals(4); mySmpSizeSpin->setDecimals(4); myAttDistSpin->setValue(0.); + myAttDistSpin2->setValue(0.); myAttSizeSpin->setValue(0.); mySmpDistSpin->setValue(0.); mySmpSizeSpin->setValue(0.); @@ -890,7 +931,9 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1); anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1); anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1); - anAttLayout->setRowStretch(SMP_ATT_DIST+1, 1); + anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1); + anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1); + anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1); anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1); anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1); @@ -916,22 +959,20 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() // Enforced vertices parameters myEnfGroup = new QWidget(); QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup); -// +// // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup); // anEnfLayout->addWidget(myEnforcedVertexWidget); // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance"); // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(); - + myEnforcedTreeWidget = new QTreeWidget(myEnfGroup); myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS ); myEnforcedTreeWidget->setSortingEnabled(true); QStringList enforcedHeaders; 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 - << tr( "BLSURF_ENF_VER_GROUP_COLUMN" ); - */ + << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" ); + myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders); myEnforcedTreeWidget->setAlternatingRowColors(true); myEnforcedTreeWidget->setUniformRowHeights(true); @@ -945,48 +986,45 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN); myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN); myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate()); - + // 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); + + SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2); myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true); myEnfVertexWdg->SetDefaultText("Select Vertices", "QLineEdit { color: grey }"); - + myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg); - + 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"); - + QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup ); myYCoord = new SMESHGUI_SpinBox(myEnfGroup); myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); - + QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup ); myZCoord = new SMESHGUI_SpinBox(myEnfGroup); myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); - /* TODO GROUPS QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup ); myGroupName = new QLineEdit(myEnfGroup); - */ - + addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup); // QFrame *line = new QFrame(myEnfGroup); // line->setFrameShape(QFrame::HLine); // line->setFrameShadow(QFrame::Sunken); removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup); - /* TODO GROUPS // CheckBox for groups generation makeGroupsCheck = new QGroupBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup); makeGroupsCheck->setCheckable(true); @@ -994,31 +1032,27 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() QGridLayout* aGroupLayout = new QGridLayout(makeGroupsCheck); myGlobalGroupName = new QLineEdit(makeGroupsCheck); aGroupLayout->addWidget(myGlobalGroupName); - */ - - + anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES+1, 1); + QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup); // 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); - anEnfLayout->addWidget(myYCoord, ENF_VER_Y_COORD, 2, 1, 1); - anEnfLayout->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 1, 1, 1); - anEnfLayout->addWidget(myZCoord, ENF_VER_Z_COORD, 2, 1, 1); - /* TODO GROUPS - anEnfLayout->addWidget(myGroupNameLabel, ENF_VER_GROUP, 1, 1, 1); - anEnfLayout->addWidget(myGroupName, ENF_VER_GROUP, 2, 1, 1); - */ - anEnfLayout->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 1, 1, 2); - anEnfLayout->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 1, 1, 2); -// anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 1, 1, 2); - /* TODO GROUPS - anEnfLayout->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 1, 1, 2); - */ - + anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2); + anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2); + + anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1); + anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1); + anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1); + anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1); + anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1); + anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1); + anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1); + anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1); + anEnfLayout2->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 0, 1, 2); + anEnfLayout2->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 0, 1, 2); +// anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 0, 1, 2); + anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2); + anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2); + // --- tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) ); tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) ); @@ -1028,6 +1062,21 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() tab->setCurrentIndex( STD_TAB ); // --- + connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) ); + connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) ); + connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) ); + connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) ); + connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) ); + + connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) ); + connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) ); + 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() ) ); +// connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(deactivateSelection(QWidget*, QWidget*))); connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) ); connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) ); connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) ); @@ -1040,6 +1089,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() connect( mySizeMapTable, SIGNAL( itemClicked (QTableWidgetItem *)),this, SLOT( onItemClicked(QTableWidgetItem *) ) ); connect( myGeomSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) ); connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) ); + connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) ); // Enforced vertices connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) ); @@ -1052,57 +1102,92 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() return fr; } -/** BLSURFPluginGUI_HypothesisCreator::update(item, column) +/** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*) +This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg +*/ +void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now) +{ + if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord) + || (now = myGroupName) || (now = makeGroupsCheck) || (now = myEnforcedTreeWidget)) { + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myEnfFaceWdg->deactivateSelection(); + myEnfVertexWdg->deactivateSelection(); + } +} + +/** + * This method resets the content of the X, Y, Z and GroupNAme widgets; +**/ +void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets() +{ + myXCoord->setCleared(true); + myYCoord->setCleared(true); + myZCoord->setCleared(true); + myXCoord->setText(""); + myYCoord->setText(""); + myZCoord->setText(""); + myGroupName->setText(""); +} + +/** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column) This method updates the tooltip of a modified item. The QLineEdit widgets content is synchronized with the coordinates of the enforced vertex clicked in the tree widget. */ -void BLSURFPluginGUI_HypothesisCreator::update(QTreeWidgetItem* item, int column) { -// MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateVertexList"); +void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) { +// MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues"); + QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole); QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole); - if (! x.isNull()) { - QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole); - QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole); - QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole); - /* TODO GROUPS - QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString(); - */ - - QTreeWidgetItem* parent = item->parent(); - if (parent) { + QVariant y = item->data(ENF_VER_X_COLUMN, Qt::EditRole); + QVariant z = item->data(ENF_VER_X_COLUMN, Qt::EditRole); + QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole); + QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString(); + QTreeWidgetItem* parent = item->parent(); + + clearEnforcedVertexWidgets(); + + if (parent && (!x.isNull() || !entry.isNull())) { QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString(); QString toolTip = shapeName + QString(": ") + vertexName.toString(); - toolTip += QString("(") + x.toString(); - toolTip += QString(", ") + y.toString(); - toolTip += QString(", ") + z.toString(); - toolTip += QString(")"); + if (entry.isNull()) { + toolTip += QString("(") + x.toString(); + toolTip += QString(", ") + y.toString(); + toolTip += QString(", ") + z.toString(); + toolTip += QString(")"); + } + + if (!groupName.isEmpty()) + toolTip += QString(" [") + groupName + QString("]"); + item->setToolTip(ENF_VER_NAME_COLUMN,toolTip); + + if (!x.isNull()) { + myXCoord->SetValue(x.toDouble()); + myYCoord->SetValue(y.toDouble()); + myZCoord->SetValue(z.toDouble()); } - myXCoord->SetValue(x.toDouble()); - myYCoord->SetValue(y.toDouble()); - myZCoord->SetValue(z.toDouble()); - /* TODO GROUPS - myGroupName->setText(groupName); - */ + + if (!groupName.isEmpty()) + myGroupName->setText(groupName); } } void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() { int nbSelEnfVertex = myEnfVertexWdg->NbObjects(); - if (nbSelEnfVertex != 0) + clearEnforcedVertexWidgets(); + if (nbSelEnfVertex == 1) { 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); + + myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1); + if (myEnfVertex->GetShapeType() == GEOM::VERTEX) { + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + 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.; measureOp->PointCoordinates (myEnfVertex, x, y, z); if ( measureOp->IsDone() ) { @@ -1119,37 +1204,34 @@ This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the of the enforced vertex clicked in the tree widget. */ void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() { -// MESSAGE("BLSURFPluginGUI_HypothesisCreator::synchronizeCoords"); + clearEnforcedVertexWidgets(); QList items = myEnforcedTreeWidget->selectedItems(); - if (! items.isEmpty()) { - QTreeWidgetItem *item; - for (int i=0 ; i < items.size() ; i++) { - item = items[i]; + if (! items.isEmpty() && items.size() == 1) { + QTreeWidgetItem *item = items[0]; +// for (int i=0 ; i < items.size() ; i++) { +// item = items[i]; QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole); - if (! x.isNull()) { - QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole); - QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole); + QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole); + QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole); + QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole); + QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole); + if (!x.isNull()/* && entry.isNull()*/) { myXCoord->SetValue(x.toDouble()); myYCoord->SetValue(y.toDouble()); myZCoord->SetValue(z.toDouble()); - /* TODO GROUPS - myGroupName->setText(item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString()); - */ - break; +// break; } - } + if (!group.isNull() && (!x.isNull() || !entry.isNull())) + myGroupName->setText(group.toString()); +// } } } /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z) This method adds an enforced vertex (x,y,z) to shapeName in the tree widget. */ -/* TODO GROUPS -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 theFaceEntry, std::string theFaceName, - double x, double y, double z, std::string vertexName, std::string geomEntry) { + double x, double y, double z, std::string vertexName, std::string geomEntry, std::string groupName) { // Find theFaceEntry item QList theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN); QTreeWidgetItem* theItem; @@ -1171,70 +1253,91 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEnt // MESSAGE("Number of child rows: " << nbVert); if (nbVert >0) { double childValueX,childValueY,childValueZ; -// QString childGrouName; + QString childEntry, childGroupName; QTreeWidgetItem* child; for (int row = 0;rowchild(row); + childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString(); + childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString(); 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(); - if ((childValueX == x) && (childValueY == y) && (childValueZ == z)) { - /* TODO GROUPS + if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) { // update group name - child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str())); - */ + if (childGroupName.toStdString() != groupName) { + MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\""); + child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str())); + } okToCreate = false; break; - } + } // if + } // for + } // if + if (!okToCreate) { + if (geomEntry.empty()) { + MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again"); } + else { + MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again"); + } + return; } - if (okToCreate) { - 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 myVertexName; - int indexRef = 0; - while(indexRef != vertexIndex) { - indexRef = vertexIndex; - if (vertexName == "") - myVertexName = QString("Vertex #%1").arg(vertexIndex); - else - myVertexName = QString(vertexName.c_str()); + if (geomEntry.empty()) { + MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created"); + } + else { + MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created"); + } + QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem); + vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); + QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QSize iconSize = iconSelect.size()*0.7; + + int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem); + QString myVertexName; + int indexRef = -1; + while(indexRef != vertexIndex) { + indexRef = vertexIndex; + if (vertexName.empty()) + 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 (myVertexName == name) { - vertexIndex++; - break; - } + for (int row = 0;rowchild(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString(); + if (myVertexName == name) { + vertexIndex++; + break; } } - vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName ); + } + vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName ); + if (geomEntry.empty()) { 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) ); + } + else { + vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation))); vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) ); - - /* TODO GROUPS + } + if (groupName != "") vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str())); - */ - QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName; + + QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName; + if (geomEntry.empty()) { toolTip += QString(" (%1, ").arg(x); toolTip += QString("%1, ").arg(y); toolTip += QString("%1)").arg(z); - vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip); - theItem->setExpanded(true); - myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN); } - else - /* TODO GROUPS - MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << - " already exist: dont create again, only group name is updated with " << groupName); - */ - MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again"); + if (groupName != "") + toolTip += QString(" [%1]").arg(groupName.c_str()); + + vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip); + theItem->setExpanded(true); + myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN); } /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() @@ -1243,40 +1346,39 @@ 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; - + 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); - + // Vertex selection int selEnfFace = myEnfFaceWdg->NbObjects(); int selEnfVertex = myEnfVertexWdg->NbObjects(); bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty()); - + if (selEnfFace == 0) return; - + if ((selEnfVertex == 0) && coordsEmpty) return; string entry, shapeName; - + 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 = ""; + + std::string groupName = myGroupName->text().toStdString(); + if (makeGroupsCheck->isChecked()) + groupName = myGlobalGroupName->text().toStdString(); + + if (boost::trim_copy(groupName).empty()) + groupName = ""; if (selEnfVertex <= 1) { @@ -1284,16 +1386,12 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() { 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()); + addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName); } else -// // TODO GROUPS -// addEnforcedVertex(entry, shapeName, x, y, z, groupName); - addEnforcedVertex(entry, shapeName, x, y, z); + addEnforcedVertex(entry, shapeName, x, y, z, "", "", groupName); } else { @@ -1309,41 +1407,23 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() { 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()); + if (myEnfVertex->GetShapeType() == GEOM::VERTEX) { + measureOp->PointCoordinates (myEnfVertex, x, y, z); + if ( measureOp->IsDone() ) + addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName); + } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) { + addEnforcedVertex(entry, shapeName, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName); } } } } + + myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil()); + myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil()); -// 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); - + if ( myPhysicalMesh->currentIndex() != SizeMap ) { myPhysicalMesh->setCurrentIndex( SizeMap ); onPhysicalMeshChanged(); @@ -1364,8 +1444,13 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() { QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole); if (! value.isNull()) selectedVertices.append(item); - else - selectedEntries.insert(item); + else { + value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole); + if (! value.isNull()) + selectedVertices.append(item); + else + selectedEntries.insert(item); + } } foreach(item,selectedVertices) { @@ -1517,45 +1602,41 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); // Enforced vertices - 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; + MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size()); + TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin(); + for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) { + TEntry entry = (*evmIt).first; std::string shapeName = myGeomToolSelected->getNameFromEntry(entry); MESSAGE("Face entry: " << entry); MESSAGE("Face name: " << shapeName); - TEnfVertexCoordsList evs; - try { - evs = (*evmIt).second; - } - catch(...) { - MESSAGE("evs = (*evmIt).second: FAIL"); - break; - } + TEnfVertexList evs = (*evmIt).second; +// try { +// evs = (*evmIt).second; +// } +// catch(...) { +// MESSAGE("evs = (*evmIt).second: FAIL"); +// break; +// } - TEnfVertexCoordsList::const_iterator evsIt = evs.begin(); - TEnfVertex enfVertex; + TEnfVertexList::const_iterator evsIt = evs.begin(); + TEnfVertex *enfVertex; for ( ; evsIt != evs.end() ; ++evsIt) { - 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]); + enfVertex = (*evsIt); + MESSAGE("Name: " << enfVertex->name); + double x, y, z = 0; + if (enfVertex->coords.size()) { + x = enfVertex->coords[0]; + y = enfVertex->coords[1]; + z = enfVertex->coords[2]; } + that->addEnforcedVertex(entry, shapeName, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName); } } + for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column) myEnforcedTreeWidget->resizeColumnToContents(column); - + // update widgets that->onPhysicalMeshChanged(); that->onGeometricMeshChanged(); @@ -1701,63 +1782,48 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData } // Enforced vertices - h_data.coordsList.clear(); - h_data.entryCoordsListMap.clear(); - h_data.coordsEnfVertexMap.clear(); + h_data.enfVertexList.clear(); + h_data.faceEntryEnfVertexListMap.clear(); /* TODO GROUPS h_data.groupNameEnfVertexListMap.clear(); -// h_data.enfVertexGroupNameMap.clear(); */ - - BLSURFPlugin::TEntryCoordsListMap_var entryCoordsListMap = h->GetAllCoordsByFace(); - MESSAGE("entryCoordsListMap->length() = " << entryCoordsListMap->length()); - for ( int i = 0;ilength(); ++i ) { - std::string entry = entryCoordsListMap[i].entry.in(); - BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str()); - - TEnfVertexCoordsList& coordsList = h_data.entryCoordsListMap[entry]; - /* TODO GROUPS - std::string groupName = ""; - */ - for (int j=0 ; jlength(); ++j) { - 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]; + BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace(); + MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length()); + + for ( int i = 0;ilength(); ++i ) { + std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in(); +// BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in(); + BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList; +// BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str()); + +// TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry]; + + for (int j=0 ; jname = CORBA::string_dup(vertexList[j].name.in()); + enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in()); + enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in()); + for (int k=0 ; k< vertexList[j].coords.length();k++) + enfVertex->coords.push_back(vertexList[j].coords[k]); + + h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex); /* TODO GROUPS - enfVertex.grpName = vertexList[j].grpName.in(); - groupName.assign(h->GetEnforcedVertexGroupName(x, y, z)); - MESSAGE("readParamsFromHypo, groupName = "<SetAngleMeshC( h_data.myAngleMeshC ); } #ifdef WITH_SIZE_BOUNDARIES -// if ( !isDouble( h_data.myPhyMin )) -// h->SetPhyMin( -1 ); -// else if ( h->GetPhyMin() != h_data.myPhyMin.toDouble() ) -// h->SetPhyMin( h_data.myPhyMin.toDouble() ); -// if ( !isDouble( h_data.myPhyMax )) -// h->SetPhyMax( -1 ); -// else if ( h->GetPhyMax() != h_data.myPhyMax.toDouble() ) -// h->SetPhyMax( h_data.myPhyMax.toDouble() ); -// if ( !isDouble( h_data.myGeoMin )) -// h->SetGeoMin( -1 ); -// else if ( h->GetGeoMin() != h_data.myGeoMin.toDouble() ) -// h->SetGeoMin( h_data.myGeoMin.toDouble() ); -// if ( !isDouble( h_data.myGeoMax )) -// h->SetGeoMax( -1 ); -// else if ( h->GetGeoMax() != h_data.myGeoMax.toDouble() ) -// h->SetGeoMax( h_data.myGeoMax.toDouble() ); if (h_data.myPhyMin > 0) h->SetPhyMin( h_data.myPhyMin ); if (h_data.myPhyMax > 0) @@ -1828,7 +1878,6 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi h->SetGeoMax( h_data.myGeoMax ); #endif - //printf("storeParamsToHypo():myOptions->length()=%d\n",myOptions->length()); h->SetOptionValues( myOptions ); // is set in checkParams() BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; @@ -1882,132 +1931,113 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi } } } - + // Enforced vertices bool ret; int hypNbVertex; - double x, y, z; + double x, y, z = 0; std::string enfName; /* TODO GROUPS std::string groupName = ""; */ + + TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin(); + + BLSURFPlugin::TFaceEntryEnfVertexListMap_var allEnforcedVerticesByFace = h->GetAllEnforcedVerticesByFace(); + hypNbVertex = allEnforcedVerticesByFace->length(); - 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) + if (evmIt == h_data.faceEntryEnfVertexListMap.end() && hypNbVertex!=0) { h->ClearAllEnforcedVertices(); - - // All enforced vertices for a specific entry were deleted - for (int i=0 ; iUnsetEnforcedVerticesEntry(entry.c_str()); - } + ok = true; } - - // 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(); - - 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 - groupName = enfVertex.grpName; - h->SetEnforcedVertexEntryWithGroup( entry.c_str(), x, y, z, groupName.c_str() ); - */ - - if (coordsFromHyp.find(coords) != coordsFromHyp.end()) { - MESSAGE("Coords "<UnsetEnforcedVerticesEntry(entry.c_str()); } } - - // Remove old vertices - 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 ); + + // One or several enforced vertices are added or removed for a specific entry + TEnfVertexList enfVertexFromHyp; + BLSURFPlugin::TEnfVertexList_var hypEnfVertexList; + TEnfName faceEntry; + TEnfVertexList evs; + TEnfVertexList::const_iterator evsIt, enfVertexToRemove; + for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt) { + faceEntry = evmIt->first; + evs = evmIt->second; + MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size()); + evsIt = evs.begin(); + + hypEnfVertexList = h->GetEnforcedVerticesEntry(faceEntry.c_str()); + hypNbVertex = hypEnfVertexList->length(); + MESSAGE("Number of enforced vertices from hypothesis: " << hypNbVertex); + enfVertexFromHyp.clear(); + for (int i =0 ; iname = string(""); + _enfVertex->name = CORBA::string_dup(hypEnfVertexList[i].name.in()); + _enfVertex->geomEntry = string(""); + _enfVertex->geomEntry = CORBA::string_dup(hypEnfVertexList[i].geomEntry.in()); + _enfVertex->grpName = string(""); + _enfVertex->grpName = CORBA::string_dup(hypEnfVertexList[i].grpName.in()); + for (int j=0 ; j< hypEnfVertexList[i].coords.length() ; j++) + _enfVertex->coords.push_back(hypEnfVertexList[i].coords[j]); + enfVertexFromHyp.insert(_enfVertex); + MESSAGE("From hyp: enf vertex " << _enfVertex->name); +// MESSAGE("From hyp: enf. vertex at " << _coords[0]<<", "<<_coords[1]<<", "<<_coords[2]); } - if (ret) - MESSAGE("SUCCESS"); - } -// if (hypNbVertex >0) { -// for (int i =0 ; iUnsetEnforcedVertexEntry( entry.c_str(), x, y, z ); + +// TEnfVertex *enfVertex; + for ( ; evsIt != evs.end() ; ++evsIt) { + x =y =z = 0; +// enfVertex = (*evsIt); + if ((*evsIt)->coords.size()) { + x = (*evsIt)->coords[0]; + y = (*evsIt)->coords[1]; + z = (*evsIt)->coords[2]; + } + ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str()); + enfVertexFromHyp.erase((*evsIt)); + +// for (enfVertexToRemove = enfVertexFromHyp.begin() ; enfVertexToRemove != enfVertexFromHyp.end() ; ++enfVertexToRemove) { +// if (!TEnfVertexGUICmp(&enfVertex, &(*enfVertexToRemove))) { +// MESSAGE("Enf vertex " << enfVertex.name << " must not be deleted") +// enfVertexFromHyp.erase(enfVertexToRemove); +// } // } -// } -// } - } - } + } + + // Remove old vertices + enfVertexToRemove = enfVertexFromHyp.begin(); + for ( ; enfVertexToRemove!=enfVertexFromHyp.end() ; ++enfVertexToRemove) { +// enfVertex = (*enfVertexToRemove); + if (h_data.enfVertexList.find((*enfVertexToRemove)) != h_data.enfVertexList.end()) { + +// for ( evsIt=h_data.enfVertexList.begin();evsIt!=h_data.enfVertexList.end();evsIt++) { +// if (TEnfVertexGUICmp(&(*evsIt),&enfVertex)) { + MESSAGE("Remove enf vertex " << (*enfVertexToRemove)->name); + if ((*enfVertexToRemove)->coords.size()) { + x = (*enfVertexToRemove)->coords[0]; + y = (*enfVertexToRemove)->coords[1]; + z = (*enfVertexToRemove)->coords[2]; + } + ret = h->UnsetEnforcedVertexEntry(faceEntry.c_str(), x, y, z, (*enfVertexToRemove)->geomEntry.c_str()); + if (ret) + MESSAGE("SUCCESS"); +// } // if +// } // for + } // if + } // for + } // for + } // else + } // try catch(const std::exception& ex) { std::cout << "Exception: " << ex.what() << std::endl; throw ex; @@ -2088,10 +2118,9 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes } // Enforced vertices - h_data.coordsList.clear(); - h_data.entryCoordsListMap.clear(); - h_data.coordsEnfVertexMap.clear(); - + h_data.enfVertexList.clear(); + h_data.faceEntryEnfVertexListMap.clear(); + int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount(); int nbEnforcedVertices = 0; std::string groupName = ""; @@ -2099,13 +2128,14 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes for (int i=0 ; itopLevelItem(i); if (shapeItem) { - std::string entry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString(); + std::string faceEntry = 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; - TEnfVertexCoordsList evs; + TEnfVertexList evs; + evs.clear(); for (row = 0;rowchild(row); childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString(); @@ -2113,33 +2143,31 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble(); childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble(); 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(); - h_data.enfVertexGroupNameMap[vertex] = groupName; + else + groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString(); + + TEnfVertex *enfVertex = new TEnfVertex(); + enfVertex->name = childName; + if (vertexEntry.empty()) { + enfVertex->coords.push_back(childValueX); + enfVertex->coords.push_back(childValueY); + enfVertex->coords.push_back(childValueZ); + } + else + enfVertex->geomEntry = vertexEntry; + enfVertex->grpName = groupName; +// TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex); +// if (it == h_data.enfVertexList.end()) + h_data.enfVertexList.insert(enfVertex); + evs.insert(enfVertex); + /* TODO GROUPS if (groupName != "") h_data.groupNameEnfVertexListMap[groupName].insert(vertex); */ - h_data.coordsEnfVertexMap[coords] = enfVertex; } - h_data.entryCoordsListMap[entry] = evs; + h_data.faceEntryEnfVertexListMap[faceEntry] = evs; } } } @@ -2154,29 +2182,16 @@ void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() { bool isSizeMap = (myPhysicalMesh->currentIndex() == SizeMap); bool isCustom = (isPhysicalUserDefined || isSizeMap) ; bool geomIsCustom = (myGeometricMesh->currentIndex() == UserDefined); - + myGradation->setEnabled(!isPhysicalUserDefined || geomIsCustom); myPhySize->setEnabled(isCustom); myPhyMax->setEnabled(isCustom); myPhyMin->setEnabled(isCustom); if ( !myGradation->isEnabled()) -// myGradation->setValue( 1.1 ); myGradation->SetValue( 1.1 ); if ( !isCustom ) { -// QString aPhySize = ""; -// switch( myPhysicalMesh->currentIndex() ) { -// case DefaultSize: -// default: -// aPhySize = "10"; -// break; -// } -// myPhySize->setText( aPhySize ); -// if ( !isDouble( myPhyMin->text(), true )) -// myPhyMin->setText(""); -// if ( !isDouble( myPhyMax->text(), true )) -// myPhyMax->setText(""); if ( myGeometricMesh->currentIndex() == DefaultGeom ) { myGeometricMesh->setCurrentIndex( UserDefined ); onGeometricMeshChanged(); @@ -2188,7 +2203,7 @@ void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() { MESSAGE("BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged"); bool isCustom = (myGeometricMesh->currentIndex() == UserDefined); bool phyIsSizemap = (myPhysicalMesh->currentIndex() == SizeMap); - + myAngleMeshS->setEnabled(isCustom); myAngleMeshC->setEnabled(isCustom); myGradation->setEnabled(isCustom || phyIsSizemap); @@ -2199,19 +2214,6 @@ void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() { myGradation->SetValue( 1.1 ); if ( ! isCustom ) { -// double aAngleMeshS; -// switch( myGeometricMesh->currentIndex() ) { -// case DefaultGeom: -// default: -// aAngleMeshS = 8; -// break; -// } -// myAngleMeshS->SetValue( aAngleMeshS ); -// myAngleMeshC->SetValue( aAngleMeshS ); -// if ( !isDouble( myGeoMin->text(), true )) -// myGeoMin->setText(""); -// if ( !isDouble( myGeoMax->text(), true )) -// myGeoMax->setText(""); // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec) if ( myPhysicalMesh->currentIndex() == DefaultSize ) { myPhysicalMesh->setCurrentIndex( PhysicalUserDefined ); @@ -2359,7 +2361,6 @@ void BLSURFPluginGUI_HypothesisCreator::onItemClicked(QTableWidgetItem * item) if (col == SMP_SIZEMAP_COLUMN){ QString entry = that->mySizeMapTable->item(row, SMP_ENTRY_COLUMN)->text(); QString sizeMap = that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->text().trimmed(); - if (sizeMap.startsWith("Attractor :")){ // myAttractorGroup->setChecked( true ); // myDistanceGroup->setChecked( true ); @@ -2367,6 +2368,7 @@ void BLSURFPluginGUI_HypothesisCreator::onItemClicked(QTableWidgetItem * item) smpTab->setCurrentIndex(ATT_TAB); double phySize = that->mySMPMap[entry].toDouble(); double infDist = that->myAttDistMap[entry]; + double constDist = that->myDistMap[entry]; QString attEntry = that->myATTMap[entry]; CORBA::Object_var attObj = entryToObject(attEntry); CORBA::Object_var obj = entryToObject(entry); @@ -2375,6 +2377,7 @@ void BLSURFPluginGUI_HypothesisCreator::onItemClicked(QTableWidgetItem * item) myAttSelWdg->SetObject(attObj); myAttSizeSpin->setValue(phySize); myAttDistSpin->setValue(infDist); + myAttDistSpin2->setValue(constDist); } else if (sizeMap.startsWith("Const.")){ smpTab->setCurrentIndex(SMP_STD_TAB); @@ -2509,9 +2512,13 @@ void BLSURFPluginGUI_HypothesisCreator::onAddMap() } BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myAttDistSpin->setValue(0.); + myAttSizeSpin->setValue(0.); + myAttDistSpin2->setValue(0.); + mySmpDistSpin->setValue(0.); + mySmpSizeSpin->setValue(0.); myGeomSelWdg->deactivateSelection(); - myAttSizeSpin->clear(); - myAttDistSpin->clear(); + myDistSelWdg->deactivateSelection(); } } @@ -2589,17 +2596,19 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF double phySize = h->GetPhySize(); double infDist = 0. ; - if (influence){ + double constDist = 0. ; + if (smpTab->currentIndex()==ATT_TAB){ // ATTRACTOR infDist = myAttDistSpin->value(); phySize = myAttSizeSpin->value(); + constDist = myAttDistSpin2->value(); } - else{ + else{ // SIZE MAP WITH CONSTANT SIZE AROUND phySize = mySmpSizeSpin->value(); + if (myDistanceGroup->isChecked()){ + constDist = mySmpDistSpin->value(); + } } - double constDist = 0. ; - if (myDistanceGroup->isChecked()){ - constDist = mySmpDistSpin->value(); - } + myGeomSelWdg->SetObject(CORBA::Object::_nil()); std::ostringstream oss; std::ostringstream oss2; std::ostringstream oss3; @@ -2635,19 +2644,21 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF that->mySMPMap.insert(shapeEntry,sizeMap); that->myATTMap.insert(shapeEntry,qAttEntry); that->myAttDistMap.insert(shapeEntry,infDist); + that->myDistMap.insert(shapeEntry,constDist); that->mySMPShapeTypeMap.insert(shapeEntry,shapeType); - if (influence){ + if (smpTab->currentIndex()==ATT_TAB){ mySizeMapTable->item( rowToChange, SMP_ENTRY_COLUMN )->setText(shapeEntry); mySizeMapTable->item( rowToChange, SMP_NAME_COLUMN )->setText( QString::fromStdString(faceName)); mySizeMapTable->item( rowToChange, SMP_SIZEMAP_COLUMN )->setText(QString::fromStdString("Attractor : "+attName)); + mySizeMapTable->item( rowToChange, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled ); + mySizeMapTable->item( rowToChange, SMP_DIST_COLUMN )->setText(constDistString); } else { - that->myDistMap.insert(shapeEntry,constDist); mySizeMapTable->item( rowToChange, SMP_ENTRY_COLUMN )->setText(shapeEntry); mySizeMapTable->item( rowToChange, SMP_NAME_COLUMN )->setText( QString::fromStdString(faceName)); mySizeMapTable->item( rowToChange, SMP_SIZEMAP_COLUMN )->setText(QString::fromStdString("Const. size from : " + attName + " (size = ") + sizeMap + QString::fromStdString(" )")); mySizeMapTable->item( rowToChange, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled ); - mySizeMapTable->item( row, SMP_DIST_COLUMN )->setText(constDistString); + mySizeMapTable->item( rowToChange, SMP_DIST_COLUMN )->setText(constDistString); } mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN ); @@ -2742,9 +2753,9 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt fflush(stderr); err_description=""; new_stderr=newPyStdOut(err_description); - PySys_SetObject((char *)"stderr", new_stderr); + PySys_SetObject((char*)"stderr", new_stderr); PyErr_Print(); - PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__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() ); @@ -2759,9 +2770,9 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt fflush(stderr); err_description=""; new_stderr=newPyStdOut(err_description); - PySys_SetObject((char *)"stderr", new_stderr); + PySys_SetObject((char*)"stderr", new_stderr); PyErr_Print(); - PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__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 971cd59..b98f0f7 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -83,31 +83,41 @@ class LightApp_SelectionMgr; // Name typedef std::string TEnfName; // Entry -typedef std::string TEnfEntry; +typedef std::string TEntry; // List of entries -typedef std::set TEnfEntryList; +typedef std::set TEntryList; // 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; +// Enforced vertex +struct TEnfVertex{ + TEnfName name; + TEntry geomEntry; + TEnfVertexCoords coords; + TEnfName grpName; +}; -// List of enforced vertices -typedef std::set< TEnfVertex > TEnfVertexList; +// TODO remove all TEnfVertexGUICmp + +struct CompareEnfVertices +{ + bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const { + if (e1 && e2) { + if (e1->coords.size() && e2->coords.size()) + return (e1->coords < e2->coords); + else + return (e1->geomEntry < e2->geomEntry); + } + return false; + } +}; - // Map Coords / Enforced vertex -typedef std::map< TEnfVertexCoords, TEnfVertex > TCoordsEnfVertexMap; +// List of enforced vertices +typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList; -// Map Entry / List of coords -typedef std::map< TEnfEntry, TEnfVertexCoordsList > TEntryCoordsListMap; +// Map Face Entry / List of enforced vertices +typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap; typedef struct { @@ -116,17 +126,37 @@ typedef struct double myAngleMeshS, myAngleMeshC, myGradation; double myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax; bool myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex; - TEnfVertexCoordsList coordsList; - TEntryCoordsListMap entryCoordsListMap; - TCoordsEnfVertexMap coordsEnfVertexMap; + TEnfVertexList enfVertexList; + TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap; /* TODO GROUPS TGroupNameEnfVertexListMap groupNameEnfVertexListMap; - TEnfVertexGroupNameMap enfVertexGroupNameMap; */ QString myName; } BlsurfHypothesisData; + +// class BLSURFPluginGUI_ObjectReferenceParamWdg: public StdMeshersGUI_ObjectReferenceParamWdg +// { +// Q_OBJECT +// public: +// BLSURFPluginGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter, +// QWidget* parent, +// bool multiSelection=false); +// BLSURFPluginGUI_ObjectReferenceParamWdg( MeshObjectType objType, +// QWidget* parent, +// bool multiSelection=false); +// ~BLSURFPluginGUI_ObjectReferenceParamWdg(); +// +// private: +// void init(); +// +// public slots: +// void activateSelectionOnly(); +// void deactivateSelectionOnly(); +// void setActivationStatus(bool status); +// }; + /*! * \brief Class for creation of BLSURF hypotheses */ @@ -151,7 +181,7 @@ protected: virtual QFrame* buildFrame (); virtual void retrieveParams() const; virtual QString storeParams () const; - + virtual QString caption() const; virtual QPixmap icon() const; virtual QString type() const; @@ -171,15 +201,15 @@ protected slots: void onRemoveMap(); void onSetSizeMap(int,int); - /* TODO GROUPS - void addEnforcedVertex(std::string, std::string, double, double, double, std::string, std::string); - */ - void addEnforcedVertex(std::string theFaceEntry, std::string theFaceName, double x, double y, double z, std::string vertexName = "", std::string geomEntry = ""); + void addEnforcedVertex(std::string theFaceEntry, std::string theFaceName, double x=0, double y=0, double z=0, + std::string vertexName = "", std::string geomEntry = "", std::string groupName = ""); void onAddEnforcedVertices(); void onRemoveEnforcedVertex(); void synchronizeCoords(); - void update(QTreeWidgetItem* , int ); + void updateEnforcedVertexValues(QTreeWidgetItem* , int ); void onSelectEnforcedVertex(); + void deactivateSelection(QWidget*, QWidget*); + void clearEnforcedVertexWidgets(); private: bool readParamsFromHypo( BlsurfHypothesisData& ) const; @@ -227,9 +257,11 @@ private: QGroupBox *myDistanceGroup; QDoubleSpinBox *myAttSizeSpin; QDoubleSpinBox *myAttDistSpin; + QDoubleSpinBox *myAttDistSpin2; QDoubleSpinBox *mySmpDistSpin; QDoubleSpinBox *mySmpSizeSpin; QLabel *myAttDistLabel; + QLabel *myAttDistLabel2; QLabel *myAttSizeLabel; // Sizemap widgets StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg; @@ -248,19 +280,17 @@ private: GEOM::GEOM_Object_var myEnfFace; StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg; GEOM::GEOM_Object_var myEnfVertex; - - - + // DlgBlSurfHyp_Enforced* myEnforcedVertexWidget; QTreeWidget* myEnforcedTreeWidget; SMESHGUI_SpinBox* myXCoord; SMESHGUI_SpinBox* myYCoord; SMESHGUI_SpinBox* myZCoord; - /* TODO GROUPS + QLineEdit* myGroupName; QGroupBox* makeGroupsCheck; QLineEdit* myGlobalGroupName; - */ + QPushButton* addVertexButton; QPushButton* removeVertexButton; @@ -296,7 +326,7 @@ public: void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; - + bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const; }; diff --git a/src/GUI/BLSURFPlugin_msg_en.ts b/src/GUI/BLSURFPlugin_msg_en.ts index 92000e9..9beb1bc 100644 --- a/src/GUI/BLSURFPlugin_msg_en.ts +++ b/src/GUI/BLSURFPlugin_msg_en.ts @@ -167,6 +167,10 @@ BLSURF_ATT_DIST Influence dist. + + BLSURF_ATT_RADIUS + Const. size over + BLSURF_ATT_SIZE Start size