From: gdd Date: Mon, 7 Feb 2011 00:41:06 +0000 (+0000) Subject: Update internal structure of engine X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fd44bab1ffbbdbcd30a299e652ee9bbc3cb20c3f;p=plugins%2Fblsurfplugin.git Update internal structure of engine More easy to make distinction between an enforced vertex set by coords or another one set by an existing vertex/group/compound. TODO: - Update the GUI - Update the Save/Load methods --- diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 1f577b4..f1faa49 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -37,15 +37,15 @@ module BLSURFPlugin { typedef sequence string_array; + // Entry + typedef string TEntry; + typedef sequence TEntryList; // Enforced vertex name typedef string TEnfName; - // Entry - typedef string TEnfEntry; - typedef sequence TEnfEntryList; // 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,45 +89,20 @@ 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; - -// // ////////////// 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 ///////////////// + typedef sequence TEnfVertexEntryEnfVertexMap; /* 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; */ @@ -283,45 +278,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); + 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); /* 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 SetEnforcedVertexGeomWithGroup(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); */ -// void SetEnforcedVertexList(in GEOM::GEOM_Object theFace, in TEnfVertexList vertexList) 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 e4832d5..fbd2488 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -25,7 +25,6 @@ // --- // #include "BLSURFPlugin_BLSURF.hxx" -#include "BLSURFPlugin_Hypothesis.hxx" extern "C"{ #include @@ -210,11 +209,11 @@ std::map FaceId2PythonSmp; std::map EdgeId2PythonSmp; std::map VertexId2PythonSmp; -std::map > FaceId2AttractorCoords; +std::map FaceId2AttractorCoords; 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 > EnfVertex2ProjVertex; bool HasSizeMapOnFace=false; bool HasSizeMapOnEdge=false; @@ -369,7 +368,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); @@ -388,7 +387,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); @@ -418,85 +417,109 @@ 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) { - 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()<<")"); + EnfVertex2ProjVertex[s_coords] = enf_coords; + + 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); } - 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); + } + // 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); + } + } + } } } } @@ -555,7 +578,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(); @@ -802,25 +825,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); } } } @@ -1032,23 +1055,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); @@ -1076,7 +1096,6 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) { // Point is inside face and not on border MESSAGE("Point is in face: node is created"); -// double uvCoords[2] = {ev[0],ev[1]}; double uvCoords[2] = {evlIt->at(0),evlIt->at(1)}; ienf++; MESSAGE("Add cad point on (u,v)=(" << uvCoords[0] << "," << uvCoords[1] << ") with id = " << ienf); @@ -1163,7 +1182,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()){ @@ -1292,19 +1310,19 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) /* TODO GROUPS // Create group of enforced vertices if requested if(_hypothesis) { - std::vector projVertex; + BLSURFPlugin_Hypothesis::TEnfVertexCoords projVertex; 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); + std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexCoords >::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); +// double x = (projIt->second)[0]; +// double y = (projIt->second)[1]; +// double z = (projIt->second)[2]; + BLSURFPlugin_Hypothesis::TEnfVertexCoords enfVertex = projIt->second; +// 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); 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 ec4ee1d..d5dc6b5 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" @@ -31,124 +31,74 @@ #include //============================================================================= -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()), -// _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()), _faceEntryEnfVertexListMap( + GetDefaultFaceEntryEnfVertexListMap()), _enfVertexList(GetDefaultEnfVertexList()), _faceEntryCoordsListMap( + GetDefaultFaceEntryCoordsListMap()), _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()), + _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()), _enfVertexEntryEnfVertexMap( + GetDefaultEnfVertexEntryEnfVertexMap()) + +/* 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(); + /* TODO GROUPS - _groupNameEnfVertexListMap.clear(); - _enfVertexGroupNameMap.clear(); - */ + _groupNameEnfVertexListMap.clear(); + _enfVertexGroupNameMap.clear(); + */ } //============================================================================= -void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) -{ +void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) { if (theTopology != _topology) { _topology = theTopology; NotifySubMeshesHypothesisModification(); @@ -156,24 +106,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(); @@ -181,8 +129,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(); @@ -190,18 +137,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(); @@ -209,8 +153,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(); @@ -218,24 +161,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(); @@ -243,8 +184,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(); @@ -252,8 +192,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(); @@ -261,8 +200,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(); @@ -270,8 +208,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(); @@ -279,57 +216,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; @@ -338,11 +268,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); @@ -351,20 +279,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(); } } @@ -372,30 +298,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(); } } @@ -403,306 +326,287 @@ 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(); } //======================================================================= //function : ClearEntry //======================================================================= -void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry) -{ - TSizeMap::iterator it = _sizeMap.find( entry ); - if ( it != _sizeMap.end() ) { - _sizeMap.erase(it); - NotifySubMeshesHypothesisModification(); - } - else { - TSizeMap::iterator itAt = _attractors.find( entry ); - if ( itAt != _attractors.end() ) { - _attractors.erase(itAt); - NotifySubMeshesHypothesisModification(); - } - else - std::cout<<"No_Such_Entry"<0 ) - { - TEnfVertexCoordsList coordsList = _entryCoordsListMap[theFaceEntry]; - if ( coordsList.count(coords)==0 ) - { + bool toCreate = true; + + TEnfVertex oldEnfVertex; + TEnfVertex newEnfVertex; + newEnfVertex.name = theVertexName; + newEnfVertex.coords.clear(); + if (theVertexEntry == "") { + newEnfVertex.coords.push_back(x); + newEnfVertex.coords.push_back(y); + newEnfVertex.coords.push_back(z); + } + newEnfVertex.geomEntry = theVertexEntry; + newEnfVertex.grpName = theGroupName; + + //////// UPDATE //////////// + // If "manual" enf vertex (theVertexEntry="") maybe an existing enf vertex needs to be update with new name or new group name + TCoordsEnfVertexMap::iterator it_CoordsEnfVertex = _coordsEnfVertexMap.find(newEnfVertex.coords); + if (it_CoordsEnfVertex != _coordsEnfVertexMap.end()) { + if (it_CoordsEnfVertex->second.name != theVertexName) { + MESSAGE("Update enf vertex name from " << it_CoordsEnfVertex->second.name << " to " << theVertexName); + + // update _faceEntryEnfVertexListMap + TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; + for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { + if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + currentEnfVertexList.erase(it); + currentEnfVertexList.insert(newEnfVertex); + break; + } + } + + // update _enfVertexList + for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { + if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + _enfVertexList.erase(it); + _enfVertexList.insert(newEnfVertex); + break; + } + } + + // update _coordsEnfVertexMap + _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex; + + toCreate = false; toNotify = true; - if ( _coordsEnfVertexMap.count(coords)>0 ) - { - _coordsEnfVertexMap[coords].faceEntries.insert(theFaceEntry); + } + if (it_CoordsEnfVertex->second.grpName != theGroupName) { + MESSAGE("Update enf vertex group name from " << it_CoordsEnfVertex->second.grpName << " to " << theGroupName); + oldEnfVertex = it_CoordsEnfVertex->second; + + // update _faceEntryEnfVertexListMap + TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; + for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { + if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + currentEnfVertexList.erase(it); + currentEnfVertexList.insert(newEnfVertex); + break; + } } - else - { - TEnfVertex enfVertex; - enfVertex.name = enfName; - enfVertex.geomEntry = theVertexEntry; - enfVertex.coords = coords; - enfVertex.faceEntries.clear(); - enfVertex.faceEntries.insert(theFaceEntry); - - _coordsEnfVertexMap[coords] = enfVertex; + + // update _enfVertexList + for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { + if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + _enfVertexList.erase(it); + _enfVertexList.insert(newEnfVertex); + break; + } } - coordsList.insert(coords); - _entryCoordsListMap[theFaceEntry].insert(coords); + + // update _coordsEnfVertexMap + _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex; + toCreate = false; + toNotify = true; } } - else - { - toNotify = true; - if ( _coordsEnfVertexMap.count(coords)>0 ) - { - _coordsEnfVertexMap[coords].faceEntries.insert(theFaceEntry); - } - else - { - TEnfVertex enfVertex; - enfVertex.name = enfName; - enfVertex.geomEntry = theVertexEntry; - enfVertex.coords = coords; - enfVertex.faceEntries.clear(); - enfVertex.faceEntries.insert(theFaceEntry); - - _coordsEnfVertexMap[coords] = enfVertex; + + // If "selected" enf vertex (theVertexEntry!="") maybe an existing enf vertex needs to be update with new group name + TEnfVertexEntryEnfVertexMap::iterator it_EnfEntryEnfVertex = _enfVertexEntryEnfVertexMap.find(theVertexEntry); + if (it_EnfEntryEnfVertex != _enfVertexEntryEnfVertexMap.end()) { + if (it_EnfEntryEnfVertex->second.grpName != theGroupName) { + MESSAGE("Update enf vertex group name from " << it_EnfEntryEnfVertex->second.grpName << " to " << theGroupName); + oldEnfVertex = it_EnfEntryEnfVertex->second; + + // update _faceEntryEnfVertexListMap + TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; + for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { + if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + currentEnfVertexList.erase(it); + currentEnfVertexList.insert(newEnfVertex); + break; + } + } + + // update _enfVertexList + for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { + if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + _enfVertexList.erase(it); + _enfVertexList.insert(newEnfVertex); + break; + } + } + + _enfVertexEntryEnfVertexMap[theVertexEntry] = newEnfVertex; + + toCreate = false; + toNotify = true; } - _entryCoordsListMap[theFaceEntry].insert(coords); } - /* TODO GROUPS - bool toNotify2 = _setEnfVertexWithGroup(x,y,z,groupName); + //////// CREATE //////////// + if (toCreate) { + MESSAGE("Creating new enforced vertex"); + std::pair res = _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex); + toNotify = res.second; + + if (toNotify) { + _enfVertexList.insert(newEnfVertex); + if (theVertexEntry == "") { + _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex.coords); + _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex; + } else { + _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex.geomEntry); + _enfVertexEntryEnfVertexMap[newEnfVertex.geomEntry] = newEnfVertex; + } + } + } - if (toNotify || 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; - } +//======================================================================= +//function : GetEnforcedVertices +//======================================================================= - std::ostringstream msg ; - msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ; +BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry) + throw (std::invalid_argument) { + + if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0) + return _faceEntryEnfVertexListMap[theFaceEntry]; + + std::ostringstream msg; + msg << "No enforced vertex for face entry " << theFaceEntry; throw std::invalid_argument(msg.str()); } //======================================================================= -//function : SetEnforcedVertexGroupName +//function : GetEnfVertexCoordsList //======================================================================= -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()); -} - -//======================================================================= -//function : GetEnforcedVertexGroupName -//======================================================================= -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); +BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList( + const TEntry& theFaceEntry) throw (std::invalid_argument) { - if (_enfVertexGroupNameMap.find(enfVertex) != _enfVertexGroupNameMap.end()) - return _enfVertexGroupNameMap[enfVertex]; + 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()); } @@ -710,208 +614,259 @@ 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; +// oldEnfVertex.name = it_enfVertexEntry->second.name; +// oldEnfVertex.geomEntry = it_enfVertexEntry->second.geomEntry; +// oldEnfVertex.grpName = it_enfVertexEntry->second.grpName; +// oldEnfVertex.coords = it_enfVertexEntry->second.coords; + + _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 + for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { + if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + _enfVertexList.erase(it); + toNotify = true; + MESSAGE("Done"); + break; + } } - // 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]; + for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { + if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + currentEnfVertexList.erase(it); + toNotify = true; + break; + } + } + 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 enfVertex; + + 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); - } - } - _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); - } - } + enfVertex = _coordsEnfVertexMap[coords]; + _enfVertexList.erase(enfVertex); + _coordsEnfVertexMap.erase(coords); } - _entryCoordsListMap.erase(it_entry); - NotifySubMeshesHypothesisModification(); - return true; + _faceEntryCoordsListMap.erase(it_entry_coords); + _faceEntryEnfVertexListMap.erase(theFaceEntry); } - std::ostringstream msg ; - msg << "No enforced vertex for " << entry; - throw std::invalid_argument(msg.str()); + 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); + enfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry]; + _enfVertexList.erase(enfVertex); + _enfVertexEntryEnfVertexMap.erase(enfVertexEntry); + } + _faceEntryEnfVertexEntryListMap.erase(it_entry_entry); + _faceEntryEnfVertexListMap.erase(theFaceEntry); + } + + if (toNotify) + NotifySubMeshesHypothesisModification(); + + return toNotify; + // std::ostringstream msg; + // msg << "No enforced vertex for " << theFaceEntry; + // throw std::invalid_argument(msg.str()); } //======================================================================= //function : ClearAllEnforcedVertices //======================================================================= -void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() -{ -// _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) -{ - return hyp ? hyp->_GetAllCoordsByFace():GetDefaultEntryCoordsListMap(); +BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList(); } -BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp) -{ - return hyp ? hyp->_GetAllEnforcedVerticesByCoords():GetDefaultCoordsEnfVertexMap(); +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::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; +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()) { + TFaceEntryCoordsListMap::const_iterator it_enf = _faceEntryCoordsListMap.begin(); + if (it_enf != _faceEntryCoordsListMap.end()) { save << " " << "__ENFORCED_VERTICES_BEGIN__"; - for ( ; it_enf != _entryCoordsListMap.end(); ++it_enf ) { + for (; it_enf != _faceEntryCoordsListMap.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) { + 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__"; - } - */ + 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 } save << "#"; // "#" is a mark of enforced shape end @@ -923,8 +878,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; @@ -1039,23 +993,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 "%#" } } @@ -1079,23 +1031,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 "%#" } } @@ -1117,157 +1067,153 @@ 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; } - - std::string enfEntry, enfValue, enfGroup, trace; + + std::string enfVertexEntry, enfValue, enfGroup, trace; std::ostringstream oss; while (isOK && hasEnforcedVertex) { - isOK = (load >> enfEntry); + isOK = (load >> enfVertexEntry); if (isOK) { - MESSAGE("enfEntry: " <> enfValue); if (isOK) { MESSAGE("enfValue: " <> enfGroup); - MESSAGE("enfGroup: " <> enfGroup); - if (isOK) { - MESSAGE("enfGroup: " <> enfGroup); + MESSAGE("enfGroup: " <> enfGroup); + if (isOK) { + MESSAGE("enfGroup: " <> enfValue); len4 = enfValue.size(); } - if (enfValue[len4-1] != '$') { + if (enfValue[len4 - 1] != '$') { // X coord enfVertex.coords.push_back(atof(enfValue.c_str())); isOK = (load >> enfValue); len4 = enfValue.size(); } - if (enfValue[len4-1] != '$') { + if (enfValue[len4 - 1] != '$') { // Y coord enfVertex.coords.push_back(atof(enfValue.c_str())); isOK = (load >> enfValue); len4 = enfValue.size(); } - if (enfValue[len4-1] != '$') { + if (enfValue[len4 - 1] != '$') { // Z coord enfVertex.coords.push_back(atof(enfValue.c_str())); isOK = (load >> enfValue); len4 = enfValue.size(); } - } - else + } else break; } - if (enfValue[len4-1] == '$') { + if (enfValue[len4 - 1] == '$') { MESSAGE("enfValue is $"); - enfValue[len4-1] = '\0'; //cut off "$" + 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())); - } - */ - enfValue[len4-1] = '\0'; //cut off "$#" + if (!hasGroup) { + MESSAGE("no group: remove $"); + // Remove '$' and add to vertex + // enfValue[len4-1] = '\0'; //cut off "$#" + enfVertex.push_back(atof(enfValue.c_str())); + } + */ + 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); + // _enfVertexList.insert(enfVertex); } } - if (enfValue[len4-1] == '#') { + 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 (!hasGroup) { + // Remove '$#' and add to vertex + enfValue[len4-2] = '\0'; //cut off "$#" + enfVertex.push_back(atof(enfValue.c_str())); + } + */ // Remove '$#' and add to vertex - enfValue[len4-2] = '\0'; //cut off "$#" + 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); + // _enfVertexList.insert(enfVertex); } - } - else + } else break; } @@ -1275,15 +1221,13 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & 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); } //================================================================================ @@ -1292,9 +1236,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; } @@ -1305,68 +1247,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 f5bc8f0..65799bf 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -33,6 +33,9 @@ #include #include #include +#include +#include +#include // Parameters for work of BLSURF @@ -132,57 +135,65 @@ public: /*! * To set/get/unset an enforced vertex */ + // Entry + typedef std::string TEntry; + // List of entries + typedef std::set TEntryList; // Name typedef std::string TEnfName; - // Entry - typedef std::string TEnfEntry; // 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 { + typedef struct TEnfVertex{ TEnfName name; - TEnfEntry geomEntry; + TEntry geomEntry; TEnfVertexCoords coords; - TEnfEntryList faceEntries; - bool manualInput; - // TODO GROUPS TEnfGroupName grpName; + // TEntryList faceEntries; // any use ? } TEnfVertex; - struct _TEnforcedVertexCmp + struct CompareEnfVertices { - bool operator () (const TEnfVertex e1, const TEnfVertex e2) const + 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 ); +// MESSAGE("Comparing 2 enf vertices"); + return true; } }; + + int TEnfVertexCmp(const TEnfVertex *e1, const TEnfVertex *e2) { + if (e1 && e2) { + bool sameCoords = true; + if (e1->coords.size() && e2->coords.size()) + sameCoords = (e1->coords[0] == e2->coords[0]) && (e1->coords[1] == e2->coords[1]) && (e1->coords[2] + == e2->coords[2]); + if( sameCoords && (e1->geomEntry == e2->geomEntry) && (e1->grpName == e2->grpName) + && (e1->name == e2->name)) + return 0; + } else + return (e1 < e2); + } + // List of enforced vertices - typedef std::set< TEnfVertex, _TEnforcedVertexCmp > TEnfVertexList; + typedef std::set< TEnfVertex, CompareEnfVertices > TEnfVertexList; + + // Map Face Entry / List of enforced vertices + typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap; + + // 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 Entry / List of coords - typedef std::map< TEnfEntry, TEnfVertexCoordsList > TEntryCoordsListMap; - - // 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 Vertex entry / Enforced vertex + typedef std::map< TEntry, TEnfVertex > TEnfVertexEntryEnfVertexMap; /* TODO GROUPS // Map Group Name / List of enforced vertices @@ -191,21 +202,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(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, + const TEnfName& theVertexName="", const TEntry& theVertexEntry="", + const TEnfGroupName& theGroupName=""); + 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); - 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 ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0) throw (std::invalid_argument); +// bool ClearEnforcedVertex(const TEntry& theFaceEntry, const TEntry& theVertexEntry) throw (std::invalid_argument); + bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument); + + void ClearAllEnforcedVertices(); + + 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; } @@ -213,9 +235,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 @@ -239,9 +267,14 @@ public: static bool GetDefaultDecimesh(); static int GetDefaultVerbosity() { return 10; } static TSizeMap GetDefaultSizeMap() { return TSizeMap();} -// 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(); } + /* TODO GROUPS static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); } static TEnfVertexGroupNameMap GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); } @@ -297,9 +330,15 @@ private: TOptionNames _doubleOptions, _charOptions; TSizeMap _sizeMap; TSizeMap _attractors; -// 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; /* TODO GROUPS TGroupNameEnfVertexListMap _groupNameEnfVertexListMap; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 0e8803f..0680bd1 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,108 +445,94 @@ 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; try { - valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor ); - if ( valueChanged ) { + valueChanged = (this->GetImpl()->GetAttractorEntry(entry) != attractor); + if (valueChanged) { boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$"); if (!boost::regex_match(string(attractor), re)) - throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False)"); + throw std::invalid_argument( + "Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False)"); 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 << "' )"; } - //============================================================================= -char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) - throw (SALOME::SALOME_Exception) -{ +char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception) { 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; @@ -603,22 +540,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; @@ -626,27 +559,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; } @@ -657,18 +588,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; } @@ -680,187 +610,250 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries() //============================================================================= 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::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap) + {} + 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::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap) -{} + char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception) + {} -void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj) -{} + void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry) + { + ASSERT(myBaseImpl); + this->GetImpl()->UnsetCustomSizeMap(entry); + SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )"; + } -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) -{} + BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries() + {} + + */ + +// /////////////////////// +// // ENFORCED VERTICES // +// /////////////////////// -void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry) -{ + +/** + * 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); - this->GetImpl()->UnsetCustomSizeMap(entry); - SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )"; -} + BLSURFPlugin::TFaceEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexListMap(); -BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries() -{} + 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()); -// /////////////////////// -// // ENFORCED VERTICES // -// /////////////////////// + ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator it_enfVertex = _enfVertexList.begin(); + for (int j = 0; it_enfVertex != _enfVertexList.end(); ++it_enfVertex, ++j) { -// 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() -{ + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + + // Name + enfVertex->name = CORBA::string_dup(it_enfVertex->name.c_str()); + + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(it_enfVertex->geomEntry.c_str()); + + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(it_enfVertex->coords.size()); + for (int i=0;ilength();i++) + coords[i] = it_enfVertex->coords[i]; + enfVertex->coords = coords; + + // Group name + enfVertex->grpName = CORBA::string_dup(it_enfVertex->grpName.c_str()); + + 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(); + 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()); + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(evlIt->geomEntry.c_str()); + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(evlIt->coords.size()); + for (int ind = 0; ind < coords->length(); ind++) + coords[ind] = evlIt->coords[ind]; + enfVertex->coords = coords; + // Group name + enfVertex->grpName = CORBA::string_dup(evlIt->grpName.c_str()); + + 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]); } @@ -872,521 +865,575 @@ 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(); + for (int i = 0; it_coords != coordsEnfVertexMap.end(); ++it_coords, ++i) { + MESSAGE("Enforced Vertex #" << i); + 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(it_coords->second.name.c_str()); + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(it_coords->second.geomEntry.c_str()); + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords2 = new BLSURFPlugin::TEnfVertexCoords(); + coords2->length(it_coords->second.coords.size()); + for (int ind=0;indlength();ind++) + coords2[ind] = it_coords->second.coords[ind]; + enfVertex->coords = coords2; + // Group name + enfVertex->grpName = CORBA::string_dup(it_coords->second.grpName.c_str()); + 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(); +} + +/** + * 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(); } -void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices() -{ +/** + * 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(); + for (int i = 0; it_enfVertexEntry != enfVertexEntryEnfVertexMap.end(); ++it_enfVertexEntry, ++i) { + MESSAGE("Enforced Vertex #" << i); + 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(it_enfVertexEntry->second.name.c_str()); + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(it_enfVertexEntry->second.geomEntry.c_str()); + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(it_enfVertexEntry->second.coords.size()); + for (int ind=0;indlength();ind++) + coords[ind] = it_enfVertexEntry->second.coords[ind]; + enfVertex->coords = coords; + // Group name + enfVertex->grpName = CORBA::string_dup(it_enfVertexEntry->second.grpName.c_str()); + + 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) -{ - 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); + * 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) && (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 == "") + 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) -{ - 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); + * 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) && (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); } - - GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); - GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( this->GetImpl()->GetStudyId() ); - if (CORBA::is_nil(measureOp)) - return false; - - CORBA::Double x,y,z; - x = y = z = 0.; - measureOp->PointCoordinates (theVertex, x, y, z); - + // TODO Affecter un nom de groupe vide string theFaceEntry = theFace->GetStudyEntry(); - string theVertexEntry = theVertex->GetStudyEntry(); - string theVertexName = theVertex->GetName(); - MESSAGE("IDL : theFace->GetName : " << theFace->GetName()); - MESSAGE("IDL : theVertex->GetName : " << theVertexName); - MESSAGE("IDL : SetEnforcedVertexWithPoint ( "<< theFaceEntry << ", " << theVertexEntry<< ", " << theVertexName<< ", " << x << ", " << y << ", " << z << ")"); + if (theFaceEntry == "") + 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 << ", " << theVertexName << ")"); try { - return SetEnforcedVertexEntryWithPoint(theFaceEntry.c_str(), theVertexEntry.c_str(), theVertexName.c_str(), x, y, z); - } - catch (SALOME_Exception& ex) { + 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 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) -{ - ASSERT(myBaseImpl); - - if (theFace->GetShapeType() != GEOM::FACE) - { - MESSAGE("theFace shape type is not FACE"); - return; + * 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); } - - // TODO check that theFace is a face => in engine ? + + // GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + // GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations(this->GetImpl()->GetStudyId()); + // if (CORBA::is_nil(measureOp)) + // return false; + // + // CORBA::Double x, y, z; + // x = y = z = 0.; + // measureOp->PointCoordinates(theVertex, x, y, z); + + // TODO publish geom objects it not published string theFaceEntry = theFace->GetStudyEntry(); - MESSAGE("IDL : GetName : " << theFace->GetName()); - MESSAGE("IDL : SetEnforcedVertexWithGroup ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << groupName <<")"); + string theVertexEntry = theVertex->GetStudyEntry(); + if (theVertexEntry == "") { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); + MESSAGE("Publish"); +// geomGen->AddInStudy(smeshGen->GetCurrentStudy(), theVertex, aName.c_str(), NULL); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + MESSAGE("Done, study entry: " << theVertexEntry); + } + +// if ((theFaceEntry == "") || (theVertexEntry == "")) + if (theFaceEntry == "") + 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 : SetEnforcedVertexGeom ( "<< theFaceEntry << ", " << theVertexEntry<< ")"); try { - SetEnforcedVertexEntryWithGroup(theFaceEntry.c_str(), x, y, z, groupName); - } - 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 with group name on face + */ +/* TODO GROUPS + void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroup(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) && (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 publish geom objects it not published + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry == "") + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : SetEnforcedVertexGroup ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theGroupName <<")"); + try { + SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, "", "", theGroupName.c_str()); + } + 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) -{ - 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); + 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(); + if (theFaceEntry == "") + 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 GetEnforcedVerticesEntry(theFaceEntry.c_str()); - } - catch (SALOME_Exception& ex) { + } 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) -{ +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 == "") + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); MESSAGE("IDL : GetName : " << theFace->GetName()); MESSAGE("IDL : UnsetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")"); try { return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z); - } - catch (SALOME_Exception& ex) { + } 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) -{ +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - - if (theFace->GetShapeType() != GEOM::FACE) - { - MESSAGE("theFace shape type is not FACE"); - THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE", SALOME::BAD_PARAM); + + if ((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) - { - MESSAGE("theVertex shape type is not VERTEX"); - THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX", 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); - + + // 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 == "") || (theVertexEntry == "")) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + MESSAGE("IDL : UnsetEnforcedVertexGeom ( "<< theFaceEntry << ", " << theVertexEntry << ")"); try { - return UnsetEnforcedVertexEntryWithPoint(theFaceEntry.c_str(), theVertexEntry.c_str(), x, y, z); - } - 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 ); } } - -bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) - throw (SALOME::SALOME_Exception) -{ +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(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 ((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 == "") + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); MESSAGE("IDL : GetName : " << theFace->GetName()); MESSAGE("IDL : UnsetEnforcedVertices ( "<< theFaceEntry << ")"); try { return UnsetEnforcedVerticesEntry(theFaceEntry.c_str()); - } - catch (SALOME_Exception& ex) { + } 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) -{ +/*! + * 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("_setEnfVertex(" << theFaceEntry << "," << x << "," << y << "," << z << "," << theVertexEntry<< "," << enfName << ")"); + MESSAGE("IDL : SetEnforcedVertexEntry(" << theFaceEntry << "," << x << "," << y << "," << z << ", \"" << theVertexName << "\"," << theVertexEntry << ", \"" << theGroupName << "\")"); 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") + + if (theVertexEntry == "") { + 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("Coords already found") - } - 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 (theVertexName == "") + SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z + << ")"; + else + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamed(" << theFaceEntry << ", " << x << ", " << y << ", " + << z << ", \"" << theVertexName << "\")"; + } else { + try { + ::BLSURFPlugin_Hypothesis::TEntryList enfVertexEntryList = this->GetImpl()->GetEnfVertexEntryList(theFaceEntry); + if (enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) { + MESSAGE("Geom entry not found: add it in enfVertexEntryList"); + newValue = true; + } else + MESSAGE("Geom entry already found"); + } 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) + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")"; } - - if ( newValue ) - this->GetImpl()->SetEnforcedVertex(theFaceEntry, x, y, z, enfName, theVertexEntry); - - return newValue; -} -bool BLSURFPlugin_Hypothesis_i::_unsetEnfVertex(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z) -{ - ASSERT(myBaseImpl); - MESSAGE("_unsetEnfVertex(" << theFaceEntry << "," << x << "," << y << "," << z << ")"); - - try { - this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); - return true; - } - catch (const std::invalid_argument& ex) { - return false; - } -} + if (newValue) + this->GetImpl()->SetEnforcedVertex(theFaceEntry, x, y, z, theVertexName, theVertexEntry, theGroupName); -/*! - * Set/get/unset an enforced vertex on geom object given by entry - */ -bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* enfName) - throw (SALOME::SALOME_Exception) -{ - MESSAGE("IDL : SetEnforcedVertexEntry START"); - bool newValue = false; - try { - newValue = _setEnfVertex(theFaceEntry, x, y, z, "", enfName); - } - catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } - - if ( newValue ) - 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 newValue = false; - - try { - newValue = _setEnfVertex(theFaceEntry, x, y, z, theVertexEntry, theVertexName); - } - 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) -{ - ASSERT(myBaseImpl); - MESSAGE("IDL : SETENFORCEDVERTEXWITHGROUP START - ENTRY: " << entry << " VERTEX: " - << x << " " << y << " " << z << " group name: " << groupName); - 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"); - 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 << "')"; - } - } - MESSAGE("IDL : SETENFORCEDVERTEXWITHGROUP END - ENTRY: " << entry); -} -*/ -/* -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) - throw (SALOME::SALOME_Exception) -{ - ASSERT(myBaseImpl); -} -*/ - 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 ) { + 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()); // Geom Vertex Entry enfVertex->geomEntry = CORBA::string_dup(_enfVertex.geomEntry.c_str()); // Coords BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); - coords->length(3); - coords[0] = _enfVertex.coords[0]; - coords[1] = _enfVertex.coords[1]; - coords[2] = _enfVertex.coords[2]; + 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()); + 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 (theVertexEntry == "") + 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) -{ - ASSERT(myBaseImpl); -} -*/ -bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* theFaceEntry) - throw (SALOME::SALOME_Exception) -{ +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 ); } @@ -1395,62 +1442,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 @@ -1458,22 +1502,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 e3c2c60..6553cd4 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,94 +112,100 @@ 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(); + /* + 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); - -// void SetEnforcedVertexList(GEOM::GEOM_Object_ptr theFace, const BLSURFPlugin::TEnfVertexList& vertexList) 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); + // TODO GROUPS + // void SetEnforcedVertexGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName) throw (SALOME::SALOME_Exception); + // void SetEnforcedVertexNamedGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName, const char* theVertexName = "") throw (SALOME::SALOME_Exception); + // void SetEnforcedVertexGeomGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName) 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); + // bool SetEnforcedVertexEntryNamed(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName="") throw (SALOME::SALOME_Exception); + // bool SetEnforcedVertexEntryGeom(const char* theFaceEntry, const char* theVertexEntry, const char* theVertexName) 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 UnsetEnforcedVertexEntryGeom(const char* theFaceEntry, 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=""); + const char* theVertexEntry = "", const char* enfName = "", const char* theGroupName = ""); 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 374c79a..726f0d8 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -849,10 +849,25 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() 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*))); return fr; } +/** 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 != myEnfVertexWdg) and (now != myEnfFaceWdg)) { + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myEnfFaceWdg->deactivateSelection(); + myEnfVertexWdg->deactivateSelection(); + } +} + + /** BLSURFPluginGUI_HypothesisCreator::update(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. @@ -1288,7 +1303,7 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const 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; + TEntry entry = (*evmIt).first; std::string shapeName = myGeomToolSelected->getNameFromEntry(entry); MESSAGE("Face entry: " << entry); MESSAGE("Face name: " << shapeName); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index ffb57e2..98ebfaa 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -80,9 +80,9 @@ 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 @@ -90,10 +90,8 @@ typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList; // Enforced vertex typedef struct { TEnfName name; - TEnfEntry geomEntry; + TEntry geomEntry; TEnfVertexCoords coords; - TEnfEntryList faceEntries; - // TODO GROUPS TEnfName grpName; } TEnfVertex; @@ -104,7 +102,7 @@ typedef std::set< TEnfVertex > TEnfVertexList; typedef std::map< TEnfVertexCoords, TEnfVertex > TCoordsEnfVertexMap; // Map Entry / List of coords -typedef std::map< TEnfEntry, TEnfVertexCoordsList > TEntryCoordsListMap; +typedef std::map< TEntry, TEnfVertexCoordsList > TEntryCoordsListMap; typedef struct { @@ -144,7 +142,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,6 +169,7 @@ protected slots: void synchronizeCoords(); void update(QTreeWidgetItem* , int ); void onSelectEnforcedVertex(); + void deactivateSelection(QWidget*, QWidget*); private: bool readParamsFromHypo( BlsurfHypothesisData& ) const; @@ -217,7 +216,7 @@ private: GEOM::GEOM_Object_var myEnfFace; StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg; GEOM::GEOM_Object_var myEnfVertex; - + // DlgBlSurfHyp_Enforced* myEnforcedVertexWidget; QTreeWidget* myEnforcedTreeWidget; SMESHGUI_SpinBox* myXCoord; @@ -260,7 +259,7 @@ public: void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; - + bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const; };