From 858e2c6e4d2c193439bb843c75a22ba93801a8d1 Mon Sep 17 00:00:00 2001 From: gdd Date: Fri, 18 Feb 2011 09:31:55 +0000 Subject: [PATCH] Merge from BR_EDF_PAL_1456 --- clean_configure | 10 + idl/BLSURFPlugin_Algorithm.idl | 123 +- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 310 ++-- src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx | 7 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 1272 +++++++------ src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 144 +- .../BLSURFPlugin_Hypothesis_i.cxx | 1631 +++++++++++------ .../BLSURFPlugin_Hypothesis_i.hxx | 136 +- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 1095 ++++++----- src/GUI/BLSURFPluginGUI_HypothesisCreator.h | 104 +- src/GUI/BLSURFPlugin_msg_en.ts | 8 +- src/GUI/BLSURFPlugin_msg_fr.ts | 8 +- src/GUI/Makefile.am | 2 +- 13 files changed, 2911 insertions(+), 1939 deletions(-) diff --git a/clean_configure b/clean_configure index 4ce737c..05683d1 100755 --- a/clean_configure +++ b/clean_configure @@ -35,5 +35,15 @@ find idl -name Makefile.in | xargs rm -f find resources -name Makefile.in | xargs rm -f find adm_local -name Makefile.in | xargs rm -f find src -name Makefile.in | xargs rm -f +rm -f adm_local/unix/config_files/config* +rm -f adm_local/unix/config_files/depcomp +rm -f adm_local/unix/config_files/install-sh +rm -f adm_local/unix/config_files/libtool.m4 +rm -f adm_local/unix/config_files/ltmain.sh +rm -f adm_local/unix/config_files/ltoptions.m4 +rm -f adm_local/unix/config_files/ltsugar.m4 +rm -f adm_local/unix/config_files/ltversion.m4 +rm -f adm_local/unix/config_files/lt~obsolete.m4 +rm -f adm_local/unix/config_files/missing rm -f Makefile.in rm -Rf salome_adm diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 64b34bc..44de731 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -38,32 +38,71 @@ module BLSURFPlugin typedef sequence string_array; // Entry - typedef string TEnfEntry; - // Enforced vertex = 3 coordinates - typedef sequence TEnfVertex; + typedef string TEntry; + typedef sequence TEntryList; + // Enforced vertex name + typedef string TEnfName; + // Group name + typedef string TEnfGroupName; + + // Coordinates of enforced vertex + typedef sequence TEnfVertexCoords; + // List of coords + typedef sequence TEnfVertexCoordsList; + + // Enforced vertex + struct TEnfVertex { + TEnfName name; + TEntry geomEntry; + TEnfVertexCoords coords; + TEnfGroupName grpName; + TEntryList faceEntries; + }; // List of enforced vertices typedef sequence TEnfVertexList; - // Map Entry / List of enforced vertices - struct TEntryEnfVertexListMapElement { - TEnfEntry entry; - TEnfVertexList vertexList; + + // 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 { + TEnfVertexCoords coords; + TEnfVertex enfVertex; }; - typedef sequence TEntryEnfVertexListMap; + typedef sequence TCoordsEnfVertexMap; + + // Map Enf Vertex Entry / Enforced vertex + struct TEnfVertexEntryEnfVertexElement { + TEntry enfVertexEntry; + TEnfVertex enfVertex; + }; + 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; */ @@ -239,39 +278,51 @@ module BLSURFPlugin // ENFORCED VERTEXES // /////////////////////// - TEntryEnfVertexListMap GetAllEnforcedVertices(); - void ClearAllEnforcedVertices(); + TFaceEntryEnfVertexListMap GetAllEnforcedVerticesByFace(); + TEnfVertexList GetAllEnforcedVertices(); + + TFaceEntryCoordsListMap GetAllCoordsByFace(); + TCoordsEnfVertexMap GetAllEnforcedVerticesByCoords(); + + TFaceEntryEnfVertexEntryListMap GetAllEnfVertexEntriesByFace(); + TEnfVertexEntryEnfVertexMap GetAllEnforcedVerticesByEnfVertexEntry(); + + void ClearAllEnforcedVertices(); /*! - * Set/get/unset an enforced vertex on geom object + * Set/get/unset an enforced vertex on geom face */ - void SetEnforcedVertex(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); - /* TODO GROUPS - void SetEnforcedVertexWithGroup(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); - */ -// void SetEnforcedVertexList(in GEOM::GEOM_Object GeomObj, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertex(in GEOM::GEOM_Object theFace, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexNamed(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfName theVertexName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexGeom(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexWithGroup(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexNamedWithGroup(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfName theVertexName, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexGeomWithGroup(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); + - TEnfVertexList GetEnforcedVertices(in GEOM::GEOM_Object GeomObj) raises (SALOME::SALOME_Exception); + TEnfVertexList GetEnforcedVertices(in GEOM::GEOM_Object theFace) raises (SALOME::SALOME_Exception); - void UnsetEnforcedVertex(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexList(in GEOM::GEOM_Object GeomObj, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); - void UnsetEnforcedVertices(in GEOM::GEOM_Object GeomObj) raises (SALOME::SALOME_Exception); + boolean UnsetEnforcedVertex(in GEOM::GEOM_Object theFace, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + boolean 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 object given by entry + * Set/get/unset an enforced vertex on geom face given by entry */ - void SetEnforcedVertexEntry(in TEnfEntry entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexEntry(in 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 TEnfEntry entry, in double x, in double y, in double z, in TEnfGroupName groupName) + void SetEnforcedVertexEntryWithGroup(in string theFaceEntry, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); */ -// void SetEnforcedVertexListEntry(in TEnfEntry entry, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); // - TEnfVertexList GetEnforcedVerticesEntry(in TEnfEntry entry) raises (SALOME::SALOME_Exception); + TEnfVertexList GetEnforcedVerticesEntry(in TEntry theFaceEntry) raises (SALOME::SALOME_Exception); // - void UnsetEnforcedVertexEntry(in TEnfEntry entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexListEntry(in TEnfEntry entry, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); - void UnsetEnforcedVerticesEntry(in TEnfEntry entry) raises (SALOME::SALOME_Exception); + boolean UnsetEnforcedVertexEntry(in 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 1bd4d93..cb5ec5c 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,12 @@ 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 > EnfVertexCoords2ProjVertex; +std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexList > EnfVertexCoords2EnfVertexList; bool HasSizeMapOnFace=false; bool HasSizeMapOnEdge=false; @@ -276,7 +276,8 @@ BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId, FaceId2AttractorCoords.clear(); FacesWithEnforcedVertices.Clear(); FaceId2EnforcedVertexCoords.clear(); - EnfVertex2ProjVertex.clear(); + EnfVertexCoords2ProjVertex.clear(); + EnfVertexCoords2EnfVertexList.clear(); } //============================================================================= @@ -369,7 +370,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 +389,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,84 +419,111 @@ TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry) return S; } -///////////////////////////////////////////////////////// -void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList) +void _createEnforcedVertexOnFace(TopoDS_Face faceShape, gp_Pnt aPnt, BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex) { - double xe, ye, ze; - std::vector coords; - std::vector s_coords; - std::vector enfVertex; -// BLSURFPlugin_Hypothesis::TEnfVertex enfVertex; - BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin(); - - for( ; evlIt != enfVertexList.end() ; ++evlIt ) { - coords.clear(); - s_coords.clear(); - enfVertex = *evlIt; - xe = enfVertex[0]; - ye = enfVertex[1]; - ze = enfVertex[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] = enfVertex; - - int key = 0; - if (! FacesWithEnforcedVertices.Contains(TopoDS::Face(GeomShape))) { - key = FacesWithEnforcedVertices.Add(TopoDS::Face(GeomShape)); - } - else { - key = FacesWithEnforcedVertices.FindIndex(TopoDS::Face(GeomShape)); + BLSURFPlugin_Hypothesis::TEnfVertexCoords enf_coords, coords, s_coords; + enf_coords.clear(); + coords.clear(); + s_coords.clear(); + + // Get the (u,v) values of the enforced vertex on the face + projectionPoint myPoint = getProjectionPoint(faceShape,aPnt); + + MESSAGE("Enforced Vertex: " << aPnt.X() << ", " << aPnt.Y() << ", " << aPnt.Z()); + MESSAGE("Projected Vertex: " << myPoint.xyz.X() << ", " << myPoint.xyz.Y() << ", " << myPoint.xyz.Z()); + MESSAGE("Parametric coordinates: " << myPoint.uv.X() << ", " << myPoint.uv.Y() ); + + enf_coords.push_back(aPnt.X()); + enf_coords.push_back(aPnt.Y()); + enf_coords.push_back(aPnt.Z()); + + coords.push_back(myPoint.uv.X()); + coords.push_back(myPoint.uv.Y()); + coords.push_back(myPoint.xyz.X()); + coords.push_back(myPoint.xyz.Y()); + coords.push_back(myPoint.xyz.Z()); + + s_coords.push_back(myPoint.xyz.X()); + s_coords.push_back(myPoint.xyz.Y()); + s_coords.push_back(myPoint.xyz.Z()); + + // Save pair projected vertex / enf vertex + MESSAGE("Storing pair projected vertex / enf vertex:"); + MESSAGE("("<< myPoint.xyz.X() << ", " << myPoint.xyz.Y() << ", " << myPoint.xyz.Z() <<") / (" << aPnt.X() << ", " << aPnt.Y() << ", " << aPnt.Z()<<")"); + EnfVertexCoords2ProjVertex[s_coords] = enf_coords; + MESSAGE("Group name is: \"" << enfVertex->grpName << "\""); + EnfVertexCoords2EnfVertexList[s_coords].insert(enfVertex); + + int key = 0; + if (! FacesWithEnforcedVertices.Contains(faceShape)) { + key = FacesWithEnforcedVertices.Add(faceShape); + } + else { + key = FacesWithEnforcedVertices.FindIndex(faceShape); + } + + // If a node is already created by an attractor, do not create enforced vertex + int attractorKey = FacesWithSizeMap.FindIndex(faceShape); + bool sameAttractor = false; + if (attractorKey >= 0) + if (FaceId2AttractorCoords.count(attractorKey) > 0) + if (FaceId2AttractorCoords[attractorKey] == coords) + sameAttractor = true; + + if (FaceId2EnforcedVertexCoords.find(key) != FaceId2EnforcedVertexCoords.end()) { + MESSAGE("Map of enf. vertex has key " << key) + MESSAGE("Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size()) + if (! sameAttractor) + FaceId2EnforcedVertexCoords[key].insert(coords); // there should be no redondant coords here (see std::set management) + else + MESSAGE("An attractor node is already defined: I don't add the enforced vertex"); + MESSAGE("New Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size()) + } + else { + MESSAGE("Map of enf. vertex has not key " << key << ": creating it") + if (! sameAttractor) { + BLSURFPlugin_Hypothesis::TEnfVertexCoordsList ens; + ens.insert(coords); + FaceId2EnforcedVertexCoords[key] = ens; } + else + MESSAGE("An attractor node is already defined: I don't add the enforced vertex"); + } +} - // If a node is already created by an attractor, do not create enforced vertex - int attractorKey = FacesWithSizeMap.FindIndex(TopoDS::Face(GeomShape)); - bool sameAttractor = false; - if (attractorKey >= 0) - if (FaceId2AttractorCoords.count(attractorKey) > 0) - if (FaceId2AttractorCoords[attractorKey] == coords) - sameAttractor = true; - - if (FaceId2EnforcedVertexCoords.find(key) != FaceId2EnforcedVertexCoords.end()) { - MESSAGE("Map of enf. vertex has key " << key) - MESSAGE("Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size()) - if (! sameAttractor) - FaceId2EnforcedVertexCoords[key].insert(coords); // there should be no redondant coords here (see std::set management) - else - MESSAGE("An attractor node is already defined: I don't add the enforced vertex"); - MESSAGE("New Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size()) +///////////////////////////////////////////////////////// +void BLSURFPlugin_BLSURF::createEnforcedVertexOnFace(TopoDS_Shape faceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList) +{ + BLSURFPlugin_Hypothesis::TEnfVertex* enfVertex; + gp_Pnt aPnt; + + BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator enfVertexListIt = enfVertexList.begin(); + + for( ; enfVertexListIt != enfVertexList.end() ; ++enfVertexListIt ) { + enfVertex = *enfVertexListIt; + // Case of manual coords + if (enfVertex->coords.size() != 0) { + aPnt.SetCoord(enfVertex->coords[0],enfVertex->coords[1],enfVertex->coords[2]); + _createEnforcedVertexOnFace( TopoDS::Face(faceShape), aPnt, enfVertex); } - else { - MESSAGE("Map of enf. vertex has not key " << key << ": creating it") - if (! sameAttractor) { - std::set< std::vector > ens; - ens.insert(coords); - FaceId2EnforcedVertexCoords[key] = ens; - } - else - MESSAGE("An attractor node is already defined: I don't add the enforced vertex"); + + // Case of geom vertex coords + if (enfVertex->geomEntry != "") { + TopoDS_Shape GeomShape = entryToShape(enfVertex->geomEntry); + TopAbs_ShapeEnum GeomType = GeomShape.ShapeType(); + if (GeomType == TopAbs_VERTEX){ + aPnt = BRep_Tool::Pnt(TopoDS::Vertex(GeomShape)); + _createEnforcedVertexOnFace( TopoDS::Face(faceShape), aPnt, enfVertex); + } + // Group Management + if (GeomType == TopAbs_COMPOUND){ + for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){ + if (it.Value().ShapeType() == TopAbs_VERTEX){ + aPnt = BRep_Tool::Pnt(TopoDS::Vertex(it.Value())); + _createEnforcedVertexOnFace( TopoDS::Face(faceShape), aPnt, enfVertex); + } + } + } } } } @@ -562,7 +590,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(); @@ -813,8 +841,8 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, // Enforced Vertices // MESSAGE("Setting Enforced Vertices"); - const BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap entryEnfVertexListMap = BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(hyp); - BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap::const_iterator enfIt = entryEnfVertexListMap.begin(); + 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); @@ -1043,23 +1071,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); @@ -1069,25 +1094,30 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) TopAbs_State result = scl.State(); MESSAGE("Position of point on face: "<at(0),evlIt->at(1)}; ienf++; MESSAGE("Add cad point on (u,v)=(" << uvCoords[0] << "," << uvCoords[1] << ") with id = " << ienf); @@ -1174,7 +1204,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()){ @@ -1300,73 +1329,64 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) } nodes[iv] = meshDS->AddNode(xyz[0], xyz[1], xyz[2]); - /* TODO GROUPS // Create group of enforced vertices if requested if(_hypothesis) { - std::vector projVertex; + BLSURFPlugin_Hypothesis::TEnfVertexCoords projVertex; + projVertex.clear(); projVertex.push_back((double)xyz[0]); projVertex.push_back((double)xyz[1]); projVertex.push_back((double)xyz[2]); - std::map< std::vector, std::vector >::const_iterator projIt = EnfVertex2ProjVertex.find(projVertex); - if (projIt != EnfVertex2ProjVertex.end()) { - double x = (projIt->second)[0]; - double y = (projIt->second)[1]; - double z = (projIt->second)[2]; - BLSURFPlugin_Hypothesis::TEnfVertex enfVertex; - enfVertex.push_back(x); - enfVertex.push_back(y); - enfVertex.push_back(z); - - BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap groupNameMap = _hypothesis->_GetEnforcedVertexGroupNameMap(); - BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap::const_iterator groupNameMapIt = groupNameMap.find(enfVertex); - if (groupNameMapIt != groupNameMap.end()) { - MESSAGE("Found enforced vertex @ " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]) - BLSURFPlugin_Hypothesis::TEnfGroupName groupName = groupNameMapIt->second; - if (groupName != "") { + std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexList >::const_iterator enfCoordsIt = EnfVertexCoords2EnfVertexList.find(projVertex); + if (enfCoordsIt != EnfVertexCoords2EnfVertexList.end()) { + MESSAGE("Found enforced vertex @ " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]) + BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator enfListIt = enfCoordsIt->second.begin(); + BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex; + for (; enfListIt != enfCoordsIt->second.end(); ++enfListIt) { + currentEnfVertex = (*enfListIt); + if (currentEnfVertex->grpName != "") { bool groupDone = false; - const set& allGroups = meshDS->GetGroups(); - set::const_iterator grIt; + SMESH_Mesh::GroupIteratorPtr grIt = aMesh.GetGroups(); + MESSAGE("currentEnfVertex->grpName: " << currentEnfVertex->grpName); MESSAGE("Parsing the groups of the mesh"); - for ( grIt = allGroups.begin(); grIt != allGroups.end(); ++grIt ) { - SMESHDS_Group* group = dynamic_cast( *grIt ); - MESSAGE("Group: " << group->GetStoreName()); - if ( group && group->SMDSGroup().GetType()==SMDSAbs_Node - && groupName.compare(group->GetStoreName())==0) { - group->SMDSGroup().Add(nodes[iv]); -// int id = // recuperer l'id SMESH du noeud -// _hypothesis->AddEnfVertexIDs(groupName,id) + while (grIt->more()) { + SMESH_Group * group = grIt->next(); + if ( !group ) continue; + MESSAGE("Group: " << group->GetName()); + SMESHDS_GroupBase* groupDS = group->GetGroupDS(); + if ( !groupDS ) continue; + MESSAGE("group->SMDSGroup().GetType(): " << (groupDS->GetType())); + MESSAGE("group->SMDSGroup().GetType()==SMDSAbs_Node: " << (groupDS->GetType()==SMDSAbs_Node)); + MESSAGE("currentEnfVertex->grpName.compare(group->GetStoreName())==0: " << (currentEnfVertex->grpName.compare(group->GetName())==0)); + if ( groupDS->GetType()==SMDSAbs_Node && currentEnfVertex->grpName.compare(group->GetName())==0) { + SMESHDS_Group* aGroupDS = static_cast( groupDS ); + aGroupDS->SMDSGroup().Add(nodes[iv]); + MESSAGE("Node ID: " << nodes[iv]->GetID()); + // How can I inform the hypothesis ? +// _hypothesis->AddEnfVertexNodeID(currentEnfVertex->grpName,nodes[iv]->GetID()); groupDone = true; - MESSAGE("Successfully added enforced vertex to existing group " << groupName); + MESSAGE("Successfully added enforced vertex to existing group " << currentEnfVertex->grpName); break; } } if (!groupDone) { int groupId; - SMESH_Group* aGroup = aMesh.AddGroup(SMDSAbs_Node, groupName.c_str(), groupId); - if ( aGroup ) { - SMESHDS_Group* aGroupDS = dynamic_cast( aGroup->GetGroupDS() ); - if ( aGroupDS ) { - aGroupDS->SetStoreName( groupName.c_str() ); - aGroupDS->SMDSGroup().Add(nodes[iv]); - MESSAGE("Successfully created enforced vertex group " << groupName); - groupDone = true; - } - } + SMESH_Group* aGroup = aMesh.AddGroup(SMDSAbs_Node, currentEnfVertex->grpName.c_str(), groupId); + aGroup->SetName( currentEnfVertex->grpName.c_str() ); + SMESHDS_Group* aGroupDS = static_cast( aGroup->GetGroupDS() ); + aGroupDS->SMDSGroup().Add(nodes[iv]); + MESSAGE("Successfully created enforced vertex group " << currentEnfVertex->grpName); + groupDone = true; } if (!groupDone) throw SALOME_Exception(LOCALIZED("A enforced vertex node was not added to a group")); } else - MESSAGE("Group name is empty: '"< group is not created"); + MESSAGE("Group name is empty: '"<grpName<<"' => group is not created"); } - else - MESSAGE("No group name for projected vertex ("< 0 && tag <= pmap.Extent() ){ 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 bcb0a0e..b9bc8c0 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,122 +31,88 @@ #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()), - _entryEnfVertexListMap(GetDefaultEntryEnfVertexListMap()) - /* 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()), + _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap()) + +/* TODO GROUPS + _groupNameEnfVertexListMap(GetDefaultGroupNameEnfVertexListMap()), + _enfVertexGroupNameMap(GetDefaultEnfVertexGroupNameMap()) + */ { _name = "BLSURF_Parameters"; _param_algo_dim = 2; - // to desable writing boundaries + // to disable writing boundaries //_phyMin = _phyMax = _hgeoMin = _hgeoMax = undefinedDouble(); - const char* intOptionNames[] = { - "addsurf_ivertex", - "background", - "CheckAdjacentEdges", - "CheckCloseEdges", - "CheckWellDefined", - "coiter", - "communication", - "decim", - "export_flag", - "file_h", - "frontal", - "gridnu", - "gridnv", - "hinterpol_flag", - "hmean_flag", - "intermedfile", - "memory", - "normals", - "optim", - "pardom_flag", - "pinch", - "refs", - "rigid", - "surforient", - "tconf", - "topo_collapse", - "" // mark of end - }; - const char* doubleOptionNames[] = { - "addsurf_angle", - "addsurf_R", - "addsurf_H", - "addsurf_FG", - "addsurf_r", - "addsurf_PA", - "angle_compcurv", - "angle_ridge", - "CoefRectangle", - "eps_collapse", - "eps_ends", - "eps_pardom", - "LSS", - "topo_eps1", - "topo_eps2", - "" // mark of end - }; - const char* charOptionNames[] = { - "export_format", - "export_option", - "import_option", - "prefix", - "" // mark of end - }; + const char* intOptionNames[] = { "addsurf_ivertex", "background", "CheckAdjacentEdges", "CheckCloseEdges", + "CheckWellDefined", "coiter", "communication", "decim", "export_flag", "file_h", "frontal", "gridnu", "gridnv", + "hinterpol_flag", "hmean_flag", "intermedfile", "memory", "normals", "optim", "pardom_flag", "pinch", "refs", + "rigid", "surforient", "tconf", "topo_collapse", "" // mark of end + }; + const char* doubleOptionNames[] = { "addsurf_angle", "addsurf_R", "addsurf_H", "addsurf_FG", "addsurf_r", + "addsurf_PA", "angle_compcurv", "angle_ridge", "CoefRectangle", "eps_collapse", "eps_ends", "eps_pardom", "LSS", + "topo_eps1", "topo_eps2", "" // mark of end + }; + const char* charOptionNames[] = { "export_format", "export_option", "import_option", "prefix", "" // mark of end + }; int i = 0; - while ( intOptionNames[i][0] ) - _option2value[ intOptionNames[i++] ].clear(); + while (intOptionNames[i][0]) + _option2value[intOptionNames[i++]].clear(); i = 0; - while ( doubleOptionNames[i][0] ) { - _doubleOptions.insert( doubleOptionNames[i] ); - _option2value[ doubleOptionNames[i++] ].clear(); + while (doubleOptionNames[i][0]) { + _doubleOptions.insert(doubleOptionNames[i]); + _option2value[doubleOptionNames[i++]].clear(); } i = 0; - while ( charOptionNames[i][0] ) { - _charOptions.insert( charOptionNames[i] ); - _option2value[ charOptionNames[i++] ].clear(); + while (charOptionNames[i][0]) { + _charOptions.insert(charOptionNames[i]); + _option2value[charOptionNames[i++]].clear(); } _sizeMap.clear(); _attractors.clear(); + _faceEntryEnfVertexListMap.clear(); _enfVertexList.clear(); - _entryEnfVertexListMap.clear(); + _faceEntryCoordsListMap.clear(); + _coordsEnfVertexMap.clear(); + _faceEntryEnfVertexEntryListMap.clear(); + _enfVertexEntryEnfVertexMap.clear(); + _groupNameNodeIDMap.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(); @@ -154,24 +120,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(); @@ -179,8 +143,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(); @@ -188,18 +151,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(); @@ -207,8 +167,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(); @@ -216,24 +175,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(); @@ -241,8 +198,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(); @@ -250,8 +206,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(); @@ -259,8 +214,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(); @@ -268,8 +222,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(); @@ -277,57 +230,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; @@ -336,11 +282,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); @@ -349,20 +293,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(); } } @@ -370,30 +312,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(); } } @@ -401,239 +340,211 @@ 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) - if (_entryEnfVertexListMap[entry].count(enfVertex)==0) + bool toCreate = true; + + TEnfVertex *oldEnVertex; + TEnfVertex *newEnfVertex = new TEnfVertex(); + newEnfVertex->name = theVertexName; + newEnfVertex->geomEntry = theVertexEntry; + newEnfVertex->coords.clear(); + if (theVertexEntry == "") { + newEnfVertex->coords.push_back(x); + newEnfVertex->coords.push_back(y); + newEnfVertex->coords.push_back(z); + } + newEnfVertex->grpName = theGroupName; + newEnfVertex->faceEntries.clear(); + newEnfVertex->faceEntries.insert(theFaceEntry); + + + // update _enfVertexList + TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex); + if (it != _enfVertexList.end()) { + toCreate = false; + oldEnVertex = (*it); + MESSAGE("Enforced Vertex was found => Update"); + if (oldEnVertex->name != theVertexName) { + MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\""); + oldEnVertex->name = theVertexName; toNotify = true; - else - toNotify = true; + } + if (oldEnVertex->grpName != theGroupName) { + MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\""); + oldEnVertex->grpName = theGroupName; + toNotify = true; + } + TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry); + if (it_faceEntries == oldEnVertex->faceEntries.end()) { + MESSAGE("Update face list by adding \"" << theFaceEntry << "\""); + oldEnVertex->faceEntries.insert(theFaceEntry); + _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex); + toNotify = true; + } + if (toNotify) { + // update map coords / enf vertex if needed + if (oldEnVertex->coords.size()) { + _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex; + _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords); + } - _enfVertexList.insert(enfVertex); -// _entryEnfVertexListMap[entry].insert(enfVertex); - TEnfVertexList& entryEnfVertexList = _entryEnfVertexListMap[entry]; - entryEnfVertexList.insert(enfVertex); + // update map geom entry / enf vertex if needed + if (oldEnVertex->geomEntry != "") { + _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex; + _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry); + } + } + } - /* TODO GROUPS - bool toNotify2 = _setEnfVertexWithGroup(x,y,z,groupName); +// //////// CREATE //////////// + if (toCreate) { + toNotify = true; + MESSAGE("Creating new enforced vertex"); + _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex); + _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; - } - std::ostringstream msg ; - msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ; +//======================================================================= +//function : GetEnforcedVertices +//======================================================================= + +BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry) + throw (std::invalid_argument) { + + if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0) + return _faceEntryEnfVertexListMap[theFaceEntry]; + else + return GetDefaultEnfVertexList(); + + std::ostringstream msg; + msg << "No enforced vertex for face entry " << theFaceEntry; throw std::invalid_argument(msg.str()); } //======================================================================= -//function : 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()); -} +BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList( + const TEntry& theFaceEntry) throw (std::invalid_argument) { + + if (_faceEntryCoordsListMap.count(theFaceEntry) > 0) + return _faceEntryCoordsListMap[theFaceEntry]; + + std::ostringstream msg; + msg << "No enforced vertex coords for face entry " << theFaceEntry; + throw std::invalid_argument(msg.str()); +} //======================================================================= -//function : GetEnforcedVertexGroupName +//function : GetEnfVertexEntryList //======================================================================= -BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetEnforcedVertexGroupName(double x, double y, double z) - throw (std::invalid_argument) -{ - TEnfVertex enfVertex; - enfVertex.push_back(x); - enfVertex.push_back(y); - enfVertex.push_back(z); - if (_enfVertexGroupNameMap.find(enfVertex) != _enfVertexGroupNameMap.end()) - return _enfVertexGroupNameMap[enfVertex]; +BLSURFPlugin_Hypothesis::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 at (" << x << "," << y << "," << z << ")" ; + std::ostringstream msg; + msg << "No enforced vertex entry for face entry " << theFaceEntry; throw std::invalid_argument(msg.str()); } -*/ -/* //======================================================================= -//function : SetEnforcedVertexList +//function : GetEnfVertex(TEnfVertexCoords coords) //======================================================================= -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::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 : GetEnforcedVertices +//function : GetEnfVertex(const TEntry& theEnfVertexEntry) //======================================================================= -BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnforcedVertices(const TEnfEntry& entry) - throw (std::invalid_argument) -{ - if (_entryEnfVertexListMap.count(entry)>0) - return _entryEnfVertexListMap[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()); } @@ -641,232 +552,298 @@ BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnforcedVert //function : ClearEnforcedVertex //======================================================================= -void BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEnfEntry& entry, double x, double y, double z) - throw (std::invalid_argument) -{ - std::ostringstream msg ; - - TEnfVertex enfVertex; - enfVertex.push_back(x); - enfVertex.push_back(y); - enfVertex.push_back(z); - - // check that enf vertex with given coords exists - if (_enfVertexList.count(enfVertex) == 0) { - msg << "No enforced vertex for " << entry; - throw std::invalid_argument(msg.str()); +bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z, + const TEntry& theVertexEntry) throw (std::invalid_argument) { + + bool toNotify = false; + std::ostringstream msg; + TEnfVertex *oldEnfVertex; + TEnfVertexCoords coords; + coords.clear(); + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); + + // check that enf vertex with given enf vertex entry exists + TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry); + if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) { + // Success + MESSAGE("Found enforced vertex with geom entry " << theVertexEntry); + oldEnfVertex = it_enfVertexEntry->second; + + _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry); + + TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry]; + enfVertexEntryList.erase(theVertexEntry); + if (enfVertexEntryList.size() == 0) + _faceEntryEnfVertexEntryListMap.erase(theFaceEntry); + // TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry); + // TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry); + // it_entry_entry->second.erase(it_entryList); + // if (it_entry_entry->second.size() == 0) + // _faceEntryEnfVertexEntryListMap.erase(it_entry_entry); + } else { + // Fail + MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found"); + msg << "No enforced vertex with geom entry " << theVertexEntry; + // check that enf vertex with given coords exists + TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords); + if (it_coords_enf != _coordsEnfVertexMap.end()) { + // Success + MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z); + oldEnfVertex = it_coords_enf->second; + + _coordsEnfVertexMap.erase(it_coords_enf); + + TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry]; + enfVertexCoordsList.erase(coords); + if (enfVertexCoordsList.size() == 0) + _faceEntryCoordsListMap.erase(theFaceEntry); + // TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry); + // TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords); + // it_entry_coords->second.erase(it_coordsList); + // if (it_entry_coords->second.size() == 0) + // _faceEntryCoordsListMap.erase(it_entry_coords); + } else { + // Fail + MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found"); + msg << std::endl; + msg << "No enforced vertex at " << x << ", " << y << ", " << z; + throw std::invalid_argument(msg.str()); + } } + MESSAGE("Remove enf vertex from _enfVertexList"); - TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry); - if (it_enf != _entryEnfVertexListMap.end()) { - bool toNotify = false; - TEnfVertexList::iterator it = _entryEnfVertexListMap[entry].find(enfVertex); - if (it != _entryEnfVertexListMap[entry].end()) { + // update _enfVertexList + TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex); + if (it != _enfVertexList.end()) { + (*it)->faceEntries.erase(theFaceEntry); + if ((*it)->faceEntries.size() == 0){ + _enfVertexList.erase(it); toNotify = true; + } + MESSAGE("Done"); + } - // Update entry2enfList map - _entryEnfVertexListMap[entry].erase(it); - if (_entryEnfVertexListMap[entry].size() == 0) - _entryEnfVertexListMap.erase(it_enf); - - /* TODO GROUPS - // Update groupName2enfCoord map - TEnfGroupName groupName = _enfVertexGroupNameMap[enfVertex]; - if (groupName != "") { - TGroupNameEnfVertexListMap::iterator it_grp =_groupNameEnfVertexListMap.find(groupName); - if (it_grp != _groupNameEnfVertexListMap.end()) { - _groupNameEnfVertexListMap[groupName].erase(enfVertex); - if (_groupNameEnfVertexListMap[groupName].size() == 0) - _groupNameEnfVertexListMap.erase(it_grp); - } - } - - // Update _enfVertexGroupNameMap - _enfVertexGroupNameMap.erase(enfVertex); - */ - - // Update _enfVertexList - _enfVertexList.erase(enfVertex); + // update _faceEntryEnfVertexListMap + TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; + currentEnfVertexList.erase(oldEnfVertex); - } - if (toNotify) - NotifySubMeshesHypothesisModification(); - return; + if (currentEnfVertexList.size() == 0) { + MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]"); + _faceEntryEnfVertexListMap.erase(theFaceEntry); + MESSAGE("Done"); } - msg << "No enforced vertex for " << entry; - throw std::invalid_argument(msg.str()); + if (toNotify) + NotifySubMeshesHypothesisModification(); + + return toNotify; } -/* + //======================================================================= -//function : ClearEnforcedVertexList +//function : ClearEnforcedVertices //======================================================================= -void BLSURFPlugin_Hypothesis::ClearEnforcedVertexList(const std::string& entry, TEnfVertexList vertexList) - throw (std::invalid_argument) -{ - TEnfVertex coord; - TEnfVertexList::const_iterator it_toRemove; - TEnfVertexList::iterator it; +bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) { + bool toNotify = false; + TEnfVertex *oldEnfVertex; - TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry); - if (it_enf != _entryEnfVertexListMap.end()) { - for (it_toRemove = vertexList.begin() ; it_toRemove != vertexList.end() ; ++it_toRemove) { - coord = *it_toRemove; - it = _entryEnfVertexListMap[entry].find(coord); - if (it != _entryEnfVertexListMap[entry].end()) { - toNotify = true; - _entryEnfVertexListMap[entry].erase(it); - _enfVertexList.erase(it); + TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry); + if (it_entry_coords != _faceEntryCoordsListMap.end()) { + toNotify = true; + TEnfVertexCoordsList coordsList = it_entry_coords->second; + TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin(); + for (; it_coordsList != coordsList.end(); ++it_coordsList) { + TEnfVertexCoords coords = (*it_coordsList); + oldEnfVertex = _coordsEnfVertexMap[coords]; + _coordsEnfVertexMap.erase(coords); + // update _enfVertexList + TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex); + if (it != _enfVertexList.end()) { + (*it)->faceEntries.erase(theFaceEntry); + if ((*it)->faceEntries.size() == 0){ + _enfVertexList.erase(it); + toNotify = true; + } + MESSAGE("Done"); } } - if (_entryEnfVertexListMap[entry].size() == 0) { - toNotify = true; - _entryEnfVertexListMap.erase(it_enf); - } - if (toNotify) - NotifySubMeshesHypothesisModification(); - return; + _faceEntryCoordsListMap.erase(it_entry_coords); + _faceEntryEnfVertexListMap.erase(theFaceEntry); } - std::ostringstream msg ; - msg << "No enforced vertex for " << entry; - throw std::invalid_argument(msg.str()); -} -*/ -//======================================================================= -//function : ClearEnforcedVertices -//======================================================================= - -void BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEnfEntry& entry) - throw (std::invalid_argument) -{ - TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry); - if (it_enf != _entryEnfVertexListMap.end()) { - TEnfVertexList enfList = it_enf->second; - TEnfVertexList::iterator it; - for(it = enfList.begin();it!=enfList.end();++it) { - /* 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); + TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry); + if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) { + toNotify = true; + TEntryList enfVertexEntryList = it_entry_entry->second; + TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin(); + for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) { + TEntry enfVertexEntry = (*it_enfVertexEntryList); + oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry]; + _enfVertexEntryEnfVertexMap.erase(enfVertexEntry); + // update _enfVertexList + TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex); + if (it != _enfVertexList.end()) { + (*it)->faceEntries.erase(theFaceEntry); + if ((*it)->faceEntries.size() == 0){ + _enfVertexList.erase(it); + toNotify = true; } + MESSAGE("Done"); } - _enfVertexGroupNameMap.erase(*it); - */ - _enfVertexList.erase(it); } - _entryEnfVertexListMap.erase(it_enf); - NotifySubMeshesHypothesisModification(); - return; + _faceEntryEnfVertexEntryListMap.erase(it_entry_entry); + _faceEntryEnfVertexListMap.erase(theFaceEntry); } - std::ostringstream msg ; - msg << "No enforced vertex for " << entry; - throw std::invalid_argument(msg.str()); + if (toNotify) + NotifySubMeshesHypothesisModification(); + + return toNotify; + // std::ostringstream msg; + // msg << "No enforced vertex for " << theFaceEntry; + // throw std::invalid_argument(msg.str()); } //======================================================================= //function : ClearAllEnforcedVertices //======================================================================= -void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() -{ - _enfVertexList.clear(); - _entryEnfVertexListMap.clear(); - /* TODO GROUPS - _groupNameEnfVertexListMap.clear(); - _enfVertexGroupNameMap.clear(); - */ - NotifySubMeshesHypothesisModification(); +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::TEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp) + +BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap(); +} + +BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList(); +} + +BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap(); +} + +BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap(); +} + +BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap(); +} + +BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry( + const BLSURFPlugin_Hypothesis* hyp) { + return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap(); +} + +std::set BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument) { - return hyp ? hyp->_GetAllEnforcedVertices():GetDefaultEntryEnfVertexListMap(); + TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName); + if (it != _groupNameNodeIDMap.end()) { + return it->second; + } + std::ostringstream msg; + msg << "No group " << theGroupName; + throw std::invalid_argument(msg.str()); } +void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) +{ + _groupNameNodeIDMap[theGroupName].insert(theNodeID); +} +void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument) +{ + TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName); + if (it != _groupNameNodeIDMap.end()) { + std::set::iterator IDit = it->second.find(theNodeID); + if (IDit != it->second.end()) + it->second.erase(IDit); + std::ostringstream msg; + msg << "No node IDs " << theNodeID << " for group " << theGroupName; + throw std::invalid_argument(msg.str()); + } + std::ostringstream msg; + msg << "No group " << theGroupName; + throw std::invalid_argument(msg.str()); +} //============================================================================= -std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) -{ - save << " " << (int)_topology - << " " << (int)_physicalMesh - << " " << (int)_geometricMesh - << " " << _phySize - << " " << _angleMeshS - << " " << _gradation - << " " << (int)_quadAllowed - << " " << (int)_decimesh; - save << " " << _phyMin - << " " << _phyMax - << " " << _angleMeshC - << " " << _hgeoMin - << " " << _hgeoMax - << " " << _verb; +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__"; } - TEntryEnfVertexListMap::const_iterator it_enf = _entryEnfVertexListMap.begin(); - if (it_enf != _entryEnfVertexListMap.end()) { + TFaceEntryEnfVertexListMap::const_iterator it_enf = _faceEntryEnfVertexListMap.begin(); + if (it_enf != _faceEntryEnfVertexListMap.end()) { save << " " << "__ENFORCED_VERTICES_BEGIN__"; - for ( ; it_enf != _entryEnfVertexListMap.end(); ++it_enf ) { + for (; it_enf != _faceEntryEnfVertexListMap.end(); ++it_enf) { save << " " << it_enf->first; - TEnfVertexList evl = it_enf->second; - TEnfVertexList::const_iterator it_evl = evl.begin(); - for ( ; it_evl != evl.end() ; ++it_evl) { - save << " " << (*it_evl)[0]; - save << " " << (*it_evl)[1]; - save << " " << (*it_evl)[2]; - /* 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__"; + TEnfVertexList enfVertexList = it_enf->second; + TEnfVertexList::const_iterator it_enfVertexList = enfVertexList.begin(); + for (; it_enfVertexList != enfVertexList.end(); ++it_enfVertexList) { + TEnfVertex *enfVertex = (*it_enfVertexList); + save << " " << enfVertex->name << ";"; + save << " " << enfVertex->geomEntry << ";"; + if (enfVertex->coords.size()) { + save << " " << enfVertex->coords[0] << ";"; + save << " " << enfVertex->coords[1] << ";"; + save << " " << enfVertex->coords[2] << ";"; } - */ + else { + save <<" ; ; ;"; + } + save << " " << enfVertex->grpName; save << " " << "$"; // "$" is a mark of enforced vertex end } save << "#"; // "#" is a mark of enforced shape end @@ -878,8 +855,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; @@ -994,23 +970,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 "%#" } } @@ -1034,23 +1008,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 "%#" } } @@ -1072,129 +1044,163 @@ 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; + +// MAPS TO FILL +// 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; + + std::string enfVertexEntry, enfValue, enfGroup, trace; std::ostringstream oss; while (isOK && hasEnforcedVertex) { - isOK = (load >> enfEntry); + isOK = (load >> enfVertexEntry); if (isOK) { - MESSAGE("enfEntry: " <coords.clear(); + + while (enfValue[len4 - 1] != '$') { isOK = (load >> enfValue); if (isOK) { MESSAGE("enfValue: " <> enfGroup); - MESSAGE("enfGroup: " <> enfGroup); - if (isOK) { - MESSAGE("enfGroup: " <> enfGroup); + MESSAGE("enfGroup: " <> enfGroup); + if (isOK) { + MESSAGE("enfGroup: " <name = enfValue; + isOK = (load >> enfValue); + len4 = enfValue.size(); } - */ - if (enfValue[len4-1] != '$') { - // Add to vertex - enfVertex.push_back(atof(enfValue.c_str())); + if (enfValue[len4 - 1] != '$') { + // X coord + enfVertex->coords.push_back(atof(enfValue.c_str())); + isOK = (load >> enfValue); + len4 = enfValue.size(); + } + if (enfValue[len4 - 1] != '$') { + // Y coord + enfVertex->coords.push_back(atof(enfValue.c_str())); + isOK = (load >> enfValue); + len4 = enfValue.size(); + } + if (enfValue[len4 - 1] != '$') { + // Z coord + enfVertex->coords.push_back(atof(enfValue.c_str())); + isOK = (load >> enfValue); + len4 = enfValue.size(); } - } - else + } 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 "$#" - enfVertex.push_back(atof(enfValue.c_str())); + 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 - evl.insert(enfVertex); + coordsList.insert(enfVertex->coords); + _coordsEnfVertexMap[enfVertex->coords] = 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 "$#" - enfVertex.push_back(atof(enfValue.c_str())); + enfValue[len4 - 2] = '\0'; //cut off "$#" + enfVertex->coords.push_back(atof(enfValue.c_str())); // Add vertex to list of vertex - evl.insert(enfVertex); + coordsList.insert(enfVertex->coords); + _coordsEnfVertexMap[enfVertex->coords] = enfVertex; + // _enfVertexList.insert(enfVertex); } - } - else + } else break; } @@ -1202,15 +1208,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); } //================================================================================ @@ -1219,9 +1223,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; } @@ -1232,68 +1234,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 58874ab..28c6911 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 @@ -133,43 +136,107 @@ public: * To set/get/unset an enforced vertex */ // Entry - typedef std::string TEnfEntry; - // Enforced vertex = 3 coordinates - typedef std::vector TEnfVertex; - // List of enforced vertices - typedef std::set< TEnfVertex > TEnfVertexList; - // Map Entry / List of enforced vertices - typedef std::map< TEnfEntry , TEnfVertexList > TEntryEnfVertexListMap; - /* TODO GROUPS + typedef std::string TEntry; + // List of entries + typedef std::set TEntryList; + // Name + typedef std::string TEnfName; // Group name typedef std::string TEnfGroupName; + // Coordinates + typedef std::vector TEnfVertexCoords; + typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList; + + // Enforced vertex + struct TEnfVertex { + TEnfName name; + TEntry geomEntry; + TEnfVertexCoords coords; + TEnfGroupName grpName; + TEntryList faceEntries; + }; + + struct CompareEnfVertices + { + bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const { + if (e1 && e2) { + if (e1->coords.size() && e2->coords.size()) + return (e1->coords < e2->coords); + else + return (e1->geomEntry < e2->geomEntry); + } + return false; + } + }; + + // List of enforced vertices + 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 Vertex entry / Enforced vertex + typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap; + + typedef std::map< TEnfGroupName, std::set > TGroupNameNodeIDMap; + /* TODO GROUPS // Map Group Name / List of enforced vertices typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap; - // Map Enforced vertex / Group Name - typedef std::map< TEnfVertex , TEnfGroupName > TEnfVertexGroupNameMap; */ - /* TODO GROUPS - void SetEnforcedVertex(const TEnfEntry& entry, double x, double y, double z, const TEnfGroupName& groupName=""); - */ - void SetEnforcedVertex(const TEnfEntry& entry, double x, double y, double z); -// void SetEnforcedVertexList(const TEnfEntry& entry, const TEnfVertexList vertexList); - TEnfVertexList GetEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument); - void ClearEnforcedVertex(const TEnfEntry& entry, double x, double y, double z) throw (std::invalid_argument); -// void ClearEnforcedVertexList(const TEnfEntry& entry, TEnfVertexList vertexList) throw (std::invalid_argument); - void ClearEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument); +// TODO GROUPS +// void SetEnforcedVertex(const TEntry& entry, double x, double y, double z, const TEnfGroupName& groupName=""); + bool SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName, + double x = 0.0, double y = 0.0, double z = 0.0); + TEnfVertexList GetEnfVertexList(const TEntry& theFaceEntry) throw (std::invalid_argument); + TEnfVertexCoordsList GetEnfVertexCoordsList(const TEntry& theFaceEntry) throw (std::invalid_argument); + TEntryList GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument); + TEnfVertex* GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument); + TEnfVertex* GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument); + void AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID); + std::set GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument); + void RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument); + + bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument); + bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument); void ClearAllEnforcedVertices(); - const TEntryEnfVertexListMap _GetAllEnforcedVertices() const { return _entryEnfVertexListMap; } - /* TODO GROUPS - const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; } - */ + + 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; } + /*! * \brief Return the enforced vertices */ - static TEntryEnfVertexListMap GetAllEnforcedVertices(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 @@ -193,8 +260,15 @@ public: static bool GetDefaultDecimesh(); static int GetDefaultVerbosity() { return 10; } static TSizeMap GetDefaultSizeMap() { return TSizeMap();} - static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); } - static TEntryEnfVertexListMap GetDefaultEntryEnfVertexListMap() { return TEntryEnfVertexListMap(); } + + static TFaceEntryEnfVertexListMap GetDefaultFaceEntryEnfVertexListMap() { return TFaceEntryEnfVertexListMap(); } + static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); } + static TFaceEntryCoordsListMap GetDefaultFaceEntryCoordsListMap() { return TFaceEntryCoordsListMap(); } + static TCoordsEnfVertexMap GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); } + static TFaceEntryEnfVertexEntryListMap GetDefaultFaceEntryEnfVertexEntryListMap() { return TFaceEntryEnfVertexEntryListMap(); } + static TEnfVertexEntryEnfVertexMap GetDefaultEnfVertexEntryEnfVertexMap() { return TEnfVertexEntryEnfVertexMap(); } + static TGroupNameNodeIDMap GetDefaultGroupNameNodeIDMap() { return TGroupNameNodeIDMap(); } + /* TODO GROUPS static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); } static TEnfVertexGroupNameMap GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); } @@ -231,10 +305,6 @@ public: */ virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); -/* TODO GROUPS -private: - bool _setEnfVertexWithGroup(double x, double y, double z, const std::string groupName) throw (std::invalid_argument); -*/ private: Topology _topology; @@ -250,11 +320,19 @@ private: TOptionNames _doubleOptions, _charOptions; TSizeMap _sizeMap; TSizeMap _attractors; - TEnfVertexList _enfVertexList; - TEntryEnfVertexListMap _entryEnfVertexListMap; + + TFaceEntryEnfVertexListMap _faceEntryEnfVertexListMap; + TEnfVertexList _enfVertexList; + // maps to get "manual" enf vertex (through their coordinates) + TFaceEntryCoordsListMap _faceEntryCoordsListMap; + TCoordsEnfVertexMap _coordsEnfVertexMap; + // maps to get "geom" enf vertex (through their geom entries) + TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap; + TEnfVertexEntryEnfVertexMap _enfVertexEntryEnfVertexMap; + TGroupNameNodeIDMap _groupNameNodeIDMap; + /* TODO GROUPS TGroupNameEnfVertexListMap _groupNameEnfVertexListMap; - TEnfVertexGroupNameMap _enfVertexGroupNameMap; */ // TSizeMap _customSizeMap; }; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index df1f321..2488854 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -25,6 +25,7 @@ // #include "BLSURFPlugin_Hypothesis_i.hxx" #include "SMESH_Gen.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESH_PythonDump.hxx" #include "GEOM_Object.hxx" @@ -42,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); } //============================================================================= @@ -62,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" ); } @@ -74,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 << " )"; } @@ -89,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(); @@ -106,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 << " )"; } @@ -121,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(); @@ -135,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); @@ -150,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 @@ -201,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 << " )"; } @@ -216,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(); @@ -230,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); @@ -245,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(); } @@ -308,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); @@ -323,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(); @@ -337,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); @@ -352,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(); @@ -366,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); @@ -381,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 << " )"; @@ -401,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; @@ -461,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 << "' )"; @@ -470,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; } @@ -493,60 +445,53 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() //============================================================================= void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options) - throw (SALOME::SALOME_Exception) -{ + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - for (int i = 0; i < options.length(); ++i) - { + for (int i = 0; i < options.length(); ++i) { string name_value = options[i].in(); - int colonPos = name_value.find( ':' ); + int colonPos = name_value.find(':'); string name, value; - if ( colonPos == string::npos ) // ':' not found + if (colonPos == string::npos) // ':' not found name = name_value; else { - name = name_value.substr( 0, colonPos); - if ( colonPos < name_value.size()-1 && name_value[colonPos] != ' ') - value = name_value.substr( colonPos+1 ); + name = name_value.substr(0, colonPos); + if (colonPos < name_value.size() - 1 && name_value[colonPos] != ' ') + value = name_value.substr(colonPos + 1); } - SetOptionValue( name.c_str(), value.c_str() ); + SetOptionValue(name.c_str(), value.c_str()); } } //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* sizeMap) - throw (SALOME::SALOME_Exception) -{ +void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry, const char* sizeMap) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry); + MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry); bool valueChanged = false; try { - valueChanged = ( this->GetImpl()->GetSizeMapEntry(entry) != sizeMap ); - if ( valueChanged ) + valueChanged = (this->GetImpl()->GetSizeMapEntry(entry) != sizeMap); + if (valueChanged) this->GetImpl()->SetSizeMapEntry(entry, sizeMap); - } - catch (const std::invalid_argument& ex) { + } catch (const std::invalid_argument& ex) { SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)"; ExDescription.lineNumber = 0; throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } MESSAGE("ENGINE : SETSIZEMAP END ENTRY : " << entry); - if ( valueChanged ) - SMESH::TPythonDump() << _this() << ".SetSizeMap(" - << entry << ", '" << sizeMap << "' )"; + if (valueChanged) + SMESH::TPythonDump() << _this() << ".SetSizeMap(" << entry << ", '" << sizeMap << "' )"; } //============================================================================= -void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* attractor ) - throw (SALOME::SALOME_Exception) -{ +void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry, const char* attractor) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry); bool valueChanged = false; @@ -559,43 +504,35 @@ void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False;d(opt.))"); this->GetImpl()->SetAttractorEntry(entry, attractor); } - } - catch (const std::invalid_argument& ex) { + } catch (const std::invalid_argument& ex) { SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)"; ExDescription.lineNumber = 0; throw SALOME::SALOME_Exception(ExDescription); - } - catch (SALOME_Exception& ex) { + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry); - if ( valueChanged ) - SMESH::TPythonDump() << _this() << ".SetAttractor(" - << entry << ", '" << attractor << "' )"; + if (valueChanged) + SMESH::TPythonDump() << _this() << ".SetAttractor(" << entry << ", '" << attractor << "' )"; } - //============================================================================= -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,150 +610,380 @@ 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() + {} -void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry) -{ + */ + +// /////////////////////// +// // ENFORCED VERTICES // +// /////////////////////// + + +/** + * 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 VERTEXES // -/////////////////////// + ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator it_enfVertex = _enfVertexList.begin(); + ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex; + for (int j = 0; it_enfVertex != _enfVertexList.end(); ++it_enfVertex, ++j) { + currentEnfVertex = (*it_enfVertex); -BLSURFPlugin::TEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices() -{ + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + + // Name + enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str()); + + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str()); + + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(currentEnfVertex->coords.size()); + for (int i=0;ilength();i++) + coords[i] = currentEnfVertex->coords[i]; + enfVertex->coords = coords; + + // Group name + enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str()); + + // Face entry list + BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList(); + faceEntryList->length(currentEnfVertex->faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin(); + for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind) + faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str()); + enfVertex->faceEntries = faceEntryList; + + ostringstream msg; + msg << "Enforced vertex: \n" + << "Name: " << enfVertex->name << "\n"; + if (coords->length()) + msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n"; + msg << "Geom entry: " << enfVertex->geomEntry << "\n" + << "Group Name: " << enfVertex->grpName; + MESSAGE(msg.str()); + + enfVertexList[j] = enfVertex; + } + mapElement->enfVertexList = enfVertexList; + + resultMap[i] = mapElement; + + } + return resultMap._retn(); +} + +/** + * Returns the list of all enforced vertices + * @return a list of enforced vertices + * + */ +BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices() { MESSAGE("IDL: GetAllEnforcedVertices()"); ASSERT(myBaseImpl); - BLSURFPlugin::TEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TEntryEnfVertexListMap(); - const ::BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap entryEnfVertexListMap = this->GetImpl()->_GetAllEnforcedVertices(); - resultMap->length(entryEnfVertexListMap.size()); - MESSAGE("Enforced Vertex map size is " << entryEnfVertexListMap.size()); - - ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList; - ::BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap::const_iterator evmIt = entryEnfVertexListMap.begin(); - for ( int i = 0 ; evmIt != entryEnfVertexListMap.end(); ++evmIt, ++i ) { - std::string entry = evmIt->first; - MESSAGE("Entry: " << entry); - enfVertexList = evmIt->second; + BLSURFPlugin::TEnfVertexList_var resultMap = new BLSURFPlugin::TEnfVertexList(); + const ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList = this->GetImpl()->_GetAllEnforcedVertices(); + resultMap->length(enfVertexList.size()); + MESSAGE("Enforced Vertex map size is " << resultMap->length()); + + ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin(); + ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex; + for (int i = 0; evlIt != enfVertexList.end(); ++evlIt, ++i) { + MESSAGE("Enforced Vertex #" << i); + currentEnfVertex = (*evlIt); + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + // Name + enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str()); + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str()); + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(currentEnfVertex->coords.size()); + for (int ind = 0; ind < coords->length(); ind++) + coords[ind] = currentEnfVertex->coords[ind]; + enfVertex->coords = coords; + // Group name + enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str()); + // Face entry list + BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList(); + faceEntryList->length(currentEnfVertex->faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin(); + for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind) + faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str()); + enfVertex->faceEntries = faceEntryList; + + ostringstream msg; + msg << "Enforced vertex: \n" + << "Name: " << enfVertex->name << "\n"; + if (coords->length()) + msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n"; + msg << "Geom entry: " << enfVertex->geomEntry << "\n" + << "Group Name: " << enfVertex->grpName; + MESSAGE(msg.str()); + + resultMap[i] = enfVertex; + } + return resultMap._retn(); - BLSURFPlugin::TEntryEnfVertexListMapElement_var mapElement = new BLSURFPlugin::TEntryEnfVertexListMapElement(); +} - BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList(); - vertexList->length(enfVertexList.size()); - MESSAGE("Number of enforced vertices: " << enfVertexList.size()); +/** + * 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_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin(); - for ( int j = 0 ; evlIt != enfVertexList.end(); ++evlIt, ++j ) { - MESSAGE("Enforced Vertex #" << j); - BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); - enfVertex->length(3); - enfVertex[0] = (*evlIt)[0]; - enfVertex[1] = (*evlIt)[1]; - enfVertex[2] = (*evlIt)[2]; - vertexList[j] = enfVertex; - MESSAGE("Enforced vertex: " << enfVertex[0] << ", " << enfVertex[1] << ", " << enfVertex[2]); + BLSURFPlugin::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::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) { + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + 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]); } + mapElement->coordsList = coordsList; - mapElement->entry = CORBA::string_dup(entry.c_str()); - mapElement->vertexList = vertexList; + resultMap[i] = mapElement; + + } + return resultMap._retn(); +} + +/** + * 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 " << resultMap->length()); + + ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap::const_iterator it_coords = coordsEnfVertexMap.begin(); + ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex; + for (int i = 0; it_coords != coordsEnfVertexMap.end(); ++it_coords, ++i) { + MESSAGE("Enforced Vertex #" << i); + currentEnfVertex = (it_coords->second); + BLSURFPlugin::TCoordsEnfVertexElement_var mapElement = new BLSURFPlugin::TCoordsEnfVertexElement(); + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(it_coords->first.size()); + for (int ind=0;indlength();ind++) + coords[ind] = it_coords->first[ind]; + mapElement->coords = coords; + MESSAGE("Coords: " << mapElement->coords[0] << ", " << mapElement->coords[1] << ", " << mapElement->coords[2]); + + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + // Name + enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str()); + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str()); + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords2 = new BLSURFPlugin::TEnfVertexCoords(); + coords2->length(currentEnfVertex->coords.size()); + for (int ind=0;indlength();ind++) + coords2[ind] = currentEnfVertex->coords[ind]; + enfVertex->coords = coords2; + // Group name + enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str()); + // Face entry list + BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList(); + faceEntryList->length(currentEnfVertex->faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin(); + for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind) + faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str()); + enfVertex->faceEntries = faceEntryList; + + mapElement->enfVertex = enfVertex; + ostringstream msg; + msg << "Enforced vertex: \n" + << "Name: " << enfVertex->name << "\n"; + if (coords->length()) + msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n"; + msg << "Geom entry: " << enfVertex->geomEntry << "\n" + << "Group Name: " << enfVertex->grpName; + MESSAGE(msg.str()); + + resultMap[i] = mapElement; + } + return resultMap._retn(); +} + +/** + * 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; @@ -831,370 +991,793 @@ BLSURFPlugin::TEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedV 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(); + ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex; + for (int i = 0; it_enfVertexEntry != enfVertexEntryEnfVertexMap.end(); ++it_enfVertexEntry, ++i) { + MESSAGE("Enforced Vertex #" << i); + currentEnfVertex = it_enfVertexEntry->second; + BLSURFPlugin::TEnfVertexEntryEnfVertexElement_var mapElement = new BLSURFPlugin::TEnfVertexEntryEnfVertexElement(); + mapElement->enfVertexEntry = CORBA::string_dup(it_enfVertexEntry->first.c_str());; + MESSAGE("Enf Vertex Entry #" << i << ": " << mapElement->enfVertexEntry); + + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + // Name + enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str()); + // Geom entry + enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str()); + // Coords + BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords(); + coords->length(currentEnfVertex->coords.size()); + for (int ind=0;indlength();ind++) + coords[ind] = currentEnfVertex->coords[ind]; + enfVertex->coords = coords; + // Group name + enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str()); + // Face entry list + BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList(); + faceEntryList->length(currentEnfVertex->faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin(); + for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind) + faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str()); + enfVertex->faceEntries = faceEntryList; + + ostringstream msg; + msg << "Enforced vertex: \n" + << "Name: " << enfVertex->name << "\n"; + if (coords->length()) + msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n"; + msg << "Geom entry: " << enfVertex->geomEntry << "\n" + << "Group Name: " << enfVertex->grpName; + MESSAGE(msg.str()); + + mapElement->enfVertex = enfVertex; + resultMap[i] = mapElement; + } + return resultMap._retn(); +} + +/** + * Erase all enforced vertices + */ +void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices() { ASSERT(myBaseImpl); this->GetImpl()->ClearAllEnforcedVertices(); SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()"; } /*! - * Set/get/unset an enforced vertex on geom object - */ -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception) -{ + * Set/get/unset an enforced vertex on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, + CORBA::Double z) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - // TODO check that GeomObj is a face => in engine ? - // TODO Affecter un nom de groupe vide - string entry = GeomObj->GetStudyEntry(); - MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : SetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")"); - try { - SetEnforcedVertexEntry(entry.c_str(), x, y, z); + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); + } + + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); } - catch (SALOME_Exception& ex) { + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : SetEnforcedVertex( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")"); + try { + 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 with group name - */ -/* TODO GROUPS -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr GeomObj, - CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) - throw (SALOME::SALOME_Exception) -{ + * Set/get/unset an enforced vertex with name on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, + CORBA::Double z, const char* theVertexName) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - // TODO check that GeomObj is a face => in engine ? - string entry = GeomObj->GetStudyEntry(); - MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : SetEnforcedVertexWithGroup ( "<< entry << ", " << x << ", " << y << ", " << z << ", " << groupName <<")"); - try { - SetEnforcedVertexEntryWithGroup(entry.c_str(), x, y, z, groupName); + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); + } + + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); } - catch (SALOME_Exception& ex) { + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : SetEnforcedVertexNamed( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ")"); + try { + return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } -*/ -BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) - throw (SALOME::SALOME_Exception) -{ + +/*! + * 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); - string entry = GeomObj->GetStudyEntry(); - MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : GetEnforcedVertexList ( "<< entry << ")"); - try { - return GetEnforcedVerticesEntry(entry.c_str()); + + 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); } - catch (SALOME_Exception& ex) { + + // GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + // GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations(this->GetImpl()->GetStudyId()); + // if (CORBA::is_nil(measureOp)) + // return false; + // + // CORBA::Double x, y, z; + // x = y = z = 0.; + // measureOp->PointCoordinates(theVertex, x, y, z); + + string theFaceEntry = theFace->GetStudyEntry(); + string theVertexEntry = theVertex->GetStudyEntry(); + + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + + if (theFaceEntry.empty()) { + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + if (theVertexEntry.empty()) { + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + string theVertexName = theVertex->GetName(); + MESSAGE("IDL : theFace->GetName : " << theFace->GetName()); + MESSAGE("IDL : theVertex->GetName : " << theVertexName); + MESSAGE("IDL : SetEnforcedVertexGeom( "<< theFaceEntry << ", " << theVertexEntry<< ")"); + try { + 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 ); } } - -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception) +/*! + * Set an enforced vertex with group name on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - string entry = GeomObj->GetStudyEntry(); - MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : UnsetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")"); - try { - UnsetEnforcedVertexEntry(entry.c_str(), x, y, z); + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); + } + + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); } - catch (SALOME_Exception& ex) { + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theGroupName << ")"); + try { + return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, "", "", theGroupName); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } - -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) - throw (SALOME::SALOME_Exception) +/*! + * Set an enforced vertex with name and group name on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* theVertexName, const char* theGroupName) + throw (SALOME::SALOME_Exception) { - ASSERT(myBaseImpl);; - string entry = GeomObj->GetStudyEntry(); - MESSAGE("IDL : GetName : " << GeomObj->GetName()); - MESSAGE("IDL : UnsetEnforcedVertices ( "<< entry << ")"); + ASSERT(myBaseImpl); - try { - UnsetEnforcedVerticesEntry(entry.c_str()); + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); + } + + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); } - catch (SALOME_Exception& ex) { + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theGroupName << ")"); + try { + return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName, "", theGroupName); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } - /*! - * Set/get/unset an enforced vertex on geom object given by entry - */ -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* entry, double x, double y, double z) - throw (SALOME::SALOME_Exception) + * Set an enforced vertex with geom entry and group name on face + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("IDL : SETENFORCEDVERTEX START - ENTRY: " << entry << " VERTEX: " << x << " " << y << " " << z); - bool newValue = false; - - try { - ::BLSURFPlugin_Hypothesis::TEnfVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry); - ::BLSURFPlugin_Hypothesis::TEnfVertex vertex; - vertex.push_back(x); - vertex.push_back(y); - vertex.push_back(z); - if (vertexList.find(vertex) == vertexList.end()) { - MESSAGE("Vertex not found: add it in vertexList") - newValue = true; - } - else - MESSAGE("Vertex already found") + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - catch (const std::invalid_argument& ex) { - // no enforced vertex for entry - MESSAGE("Entry not found : add it to the list") - newValue = true; + + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); } - catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + + string theFaceEntry = theFace->GetStudyEntry(); + string theVertexEntry = theVertex->GetStudyEntry(); + + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + + if (theFaceEntry.empty()) { + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); } + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); - if ( newValue ) { - this->GetImpl()->SetEnforcedVertex(entry, x, y, z); - SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" - << entry << ", " - << x << ", " - << y << ", " - << z << ")"; + if (theVertexEntry.empty()) { + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + string theVertexName = theVertex->GetName(); + MESSAGE("IDL : theFace->GetName : " << theFace->GetName()); + MESSAGE("IDL : theVertex->GetName : " << theVertexName); + MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theFaceEntry << ", " << theVertexEntry<< ", " << theGroupName<< ")"); + try { + return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName); + } catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - MESSAGE("IDL : SETENFORCEDVERTEX END - ENTRY: " << entry); } /*! - * 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) -{ + * Get the list of all enforced vertices + */ +BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) + 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; - } + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - catch (const std::invalid_argument& ex) { - // no enforced vertex for entry - MESSAGE("Entry not found : add it to the list"); - newValue = true; + + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); } - catch (SALOME_Exception& ex) { + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : GetEnforcedVertexList ( "<< theFaceEntry << ")"); + try { + return GetEnforcedVerticesEntry(theFaceEntry.c_str()); + } 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) { + 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 ( newValue ) { - this->GetImpl()->SetEnforcedVertex(entry, x, y, z, groupName); - SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup(" - << entry << ", " - << x << ", " - << y << ", " - << z << ", '" - << groupName << "')"; + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); } - else { - if (newGroupName) { - this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName); - SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName(" - << x << ", " - << y << ", " - << z << ", '" - << groupName << "')"; - } + if (theFaceEntry.empty()) + 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) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - 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) -{ +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("ENGINE : GETENFORCEDVERTICES START ENTRY : " << entry); + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); + } + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); + } + + // GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + // GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations(this->GetImpl()->GetStudyId()); + // if (CORBA::is_nil(measureOp)) + // return false; + // + // CORBA::Double x, y, z; + // x = y = z = 0.; + // measureOp->PointCoordinates(theVertex, x, y, z); + + std::string theFaceEntry = theFace->GetStudyEntry(); + std::string theVertexEntry = theVertex->GetStudyEntry(); - try { - BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList(); - ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnforcedVertices(entry); - vertexList->length(_vList.size()); - MESSAGE("Number of enforced vertices: " << _vList.size()); - ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin(); - for ( int i = 0; evlIt != _vList.end() ; ++evlIt, ++i ) { - BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); - enfVertex->length(3); - MESSAGE("Enforced vertex #" << i << ": "<< (*evlIt)[0] << ", " << (*evlIt)[1] << ", " << (*evlIt)[2]); - enfVertex[0] = (*evlIt)[0]; - enfVertex[1] = (*evlIt)[1]; - enfVertex[2] = (*evlIt)[2]; - vertexList[i] = enfVertex; - } - return vertexList._retn(); + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + + if (theFaceEntry.empty()) { + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); } - 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 = 1048; - throw SALOME::SALOME_Exception(ExDescription); + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + if (theVertexEntry.empty()) { + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); } - catch(const std::exception& ex) { + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + MESSAGE("IDL : UnsetEnforcedVertexGeom ( "<< theFaceEntry << ", " << theVertexEntry << ")"); + + try { + return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexEntry.c_str()); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - - MESSAGE("ENGINE : GETENFORCEDVERTICES END ENTRY : " << entry); } - -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception) -{ +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("ENGINE : UNSETENFORCEDVERTEX START ENTRY : " << entry); - - try { - this->GetImpl()->ClearEnforcedVertex(entry, x, y, z); - SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex(" - << entry << ", " - << x << ", " - << y << ", " - << z << ")"; + + if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theFace shape type is not FACE or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - catch (const std::invalid_argument& ex) { - SALOME::ExceptionStruct ExDescription; - ExDescription.text = ex.what(); - ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(entry,x,y,z)"; - ExDescription.lineNumber = 1086; - throw SALOME::SALOME_Exception(ExDescription); + + string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); } - catch(const std::exception& ex) { + if (theFaceEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + MESSAGE("IDL : GetName : " << theFace->GetName()); + MESSAGE("IDL : UnsetEnforcedVertices ( "<< theFaceEntry << ")"); + + try { + return UnsetEnforcedVerticesEntry(theFaceEntry.c_str()); + } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - - MESSAGE("ENGINE : UNSETENFORCEDVERTEX END ENTRY : " << entry); } -/* -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) - throw (SALOME::SALOME_Exception) -{ + +/*! + * Set/get/unset an enforced vertex on geom object given by entry + */ +bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, + CORBA::Double z, const char* theVertexName, const char* theVertexEntry, const char* theGroupName) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); + MESSAGE("IDL : SetEnforcedVertexEntry(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\")"); + bool newValue = false; + + if (string(theVertexEntry).empty()) { + try { + ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList coordsList = + this->GetImpl()->GetEnfVertexCoordsList(theFaceEntry); + ::BLSURFPlugin_Hypothesis::TEnfVertexCoords coords; + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); + if (coordsList.find(coords) == coordsList.end()) { + MESSAGE("Coords not found: add it in coordsList"); + newValue = true; + } else { + MESSAGE("Coords already found, compare names"); + ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex(coords); + if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) { + MESSAGE("The names are different: update"); +// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); + newValue = true; + } + else { + MESSAGE("The names are identical"); + } + } + } catch (const std::invalid_argument& ex) { + // no enforced vertex for entry + MESSAGE("Face entry not found : add it to the list"); + newValue = true; + } + if (newValue) + if (string(theVertexName).empty()) + if (string(theGroupName).empty()) + SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ")"; + else + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theGroupName << "\")"; + else + if (string(theGroupName).empty()) + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamed(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\")"; + else + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamedWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" + << theVertexName << "\", \"" << theGroupName << "\")"; + } else { + try { + ::BLSURFPlugin_Hypothesis::TEntryList enfVertexEntryList = this->GetImpl()->GetEnfVertexEntryList(theFaceEntry); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it = enfVertexEntryList.find(theVertexEntry); + if ( it == enfVertexEntryList.end()) { + MESSAGE("Geom entry not found: add it in enfVertexEntryList"); + newValue = true; + } + else { + MESSAGE("Geom entry already found, compare names"); + ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex((*it)); + if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) { + MESSAGE("The names are different: update"); +// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); + newValue = true; + } + else { + MESSAGE("The names are identical"); + } + } + } catch (const std::invalid_argument& ex) { + // no enforced vertex for entry + MESSAGE("Face entry not found : add it to the list"); + newValue = true; + } + if (newValue) + if (string(theGroupName).empty()) + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")"; + else + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeomWithGroup(" << theFaceEntry << ", " << theVertexEntry << ", \"" << theGroupName << "\")"; + } + + if (newValue) + this->GetImpl()->SetEnforcedVertex(theFaceEntry, theVertexName, theVertexEntry, theGroupName, x, y, z); + + MESSAGE("IDL : SetEnforcedVertexEntry END"); + return newValue; } -*/ -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* entry) - throw (SALOME::SALOME_Exception) -{ + +BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry) + throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("ENGINE : UNSETENFORCEDVERTICES START ENTRY : " << entry); - + MESSAGE("ENGINE : GetEnforcedVerticesEntry START ENTRY : " << entry); + try { - this->GetImpl()->ClearEnforcedVertices(entry); - SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << entry << ")"; - } - catch (const std::invalid_argument& ex) { + BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList(); + ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnfVertexList(entry); + vertexList->length(_vList.size()); + MESSAGE("Number of enforced vertices: " << vertexList->length()); + ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin(); + for (int i = 0; evlIt != _vList.end(); ++evlIt, ++i) { + ::BLSURFPlugin_Hypothesis::TEnfVertex *_enfVertex = (*evlIt); + + 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(_enfVertex->coords.size()); + for (int ind=0;indlength();ind++) + coords[ind] = _enfVertex->coords[ind]; + enfVertex->coords = coords; + // Group Name + enfVertex->grpName = CORBA::string_dup(_enfVertex->grpName.c_str()); + // Face entry list + BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList(); + faceEntryList->length(_enfVertex->faceEntries.size()); + ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = _enfVertex->faceEntries.begin(); + for (int ind = 0; it_entry != _enfVertex->faceEntries.end();++it_entry, ++ind) + faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str()); + enfVertex->faceEntries = faceEntryList; + + vertexList[i] = enfVertex; + } + MESSAGE("ENGINE : GetEnforcedVerticesEntry END ENTRY : " << entry); + return vertexList._retn(); + } catch (const std::invalid_argument& ex) { SALOME::ExceptionStruct ExDescription; ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; - ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(entry)"; - ExDescription.lineNumber = 1121; + ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)"; + 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 ); } - - MESSAGE("ENGINE : UNSETENFORCEDVERTICES END ENTRY : " << entry); } -/* TODO GROUPS -char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z) - throw (SALOME::SALOME_Exception) -{ +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("ENGINE : GetEnforcedVertexGroupName START "); + MESSAGE("IDL : UnsetEnforcedVertexEntry(" << theFaceEntry << "," << x << "," << y << "," << z << ", " << theVertexEntry << ")"); + 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) { + this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z, theVertexEntry); + + if (string(theVertexEntry).empty()) + SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z + << ")"; + else + SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")"; + + } catch (const std::invalid_argument& ex) { + return false; + } catch (const std::exception& ex) { + std::cout << "Exception: " << ex.what() << std::endl; THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - MESSAGE("ENGINE : GetEnforcedVertexGroupName END "); - return 0; + + MESSAGE("ENGINE : UnsetEnforcedVertexEntry END ENTRY : " << theFaceEntry); + 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 +// << ")"; +// +// MESSAGE("IDL : UnsetEnforcedVertexEntryWithPoint END ENTRY : " << theFaceEntry); +// return ret; +//} -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) - throw (SALOME::SALOME_Exception) -{ +bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("ENGINE : SetEnforcedVertexGroupName START "); + MESSAGE("IDL : UnsetEnforcedVerticesEntry(" << theFaceEntry << ")"); + 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) { + this->GetImpl()->ClearEnforcedVertices(theFaceEntry); + SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertices(" << theFaceEntry << ")"; + } catch (const std::invalid_argument& ex) { + return false; + } catch (const std::exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName(" - << x << ", " << y << ", " << z << ", '" << groupName << "' )"; - - MESSAGE("ENGINE : SetEnforcedVertexGroupName END "); + MESSAGE("IDL : UnsetEnforcedVerticesEntry END ENTRY : " << theFaceEntry); + return true; } -*/ -/////////////////////// - - +/* 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 "); + } + */ +/////////////////////// //============================================================================= @@ -1204,22 +1787,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 fc22a46..6de292d 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,103 +112,94 @@ 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::TEntryEnfVertexListMap* GetAllEnforcedVertices(); - 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 - */ - void SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) + * 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); - /* TODO GROUPS - void SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr GeomObj, - CORBA::Double x, CORBA::Double y, CORBA::Double z, - const char* groupName) + bool SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName) throw (SALOME::SALOME_Exception); - */ -// void SetEnforcedVertexList(GEOM::GEOM_Object_ptr GeomObj, const BLSURFPlugin::TEnfVertexList& vertexList) -// throw (SALOME::SALOME_Exception); - - BLSURFPlugin::TEnfVertexList* GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) + bool SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) throw (SALOME::SALOME_Exception); - - void UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) + bool SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName) throw (SALOME::SALOME_Exception); - -// void UnsetEnforcedVertexList(GEOM::GEOM_Object_ptr GeomObj, BLSURFPlugin::TEnfVertexList& vertexList) -// throw (SALOME::SALOME_Exception); - - void UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) + bool SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName, const char* theGroupName) throw (SALOME::SALOME_Exception); - - /*! - * Set/get/unset an enforced vertex on geom object given by entry - */ - void SetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z) + bool SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName) throw (SALOME::SALOME_Exception); - /* TODO GROUPS - void SetEnforcedVertexEntryWithGroup(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z, - const char* groupName) - throw (SALOME::SALOME_Exception); - */ -// void SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) -// throw (SALOME::SALOME_Exception); - - BLSURFPlugin::TEnfVertexList* GetEnforcedVerticesEntry(const char* entry) + + 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); - - void UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z) + bool UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex) throw (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) -// throw (SALOME::SALOME_Exception); - void UnsetEnforcedVerticesEntry(const char* entry) + 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 = 0, CORBA::Double y = 0, CORBA::Double z = 0, + const char* theVertexName = "", const char* theVertexEntry = "", const char* theGroupName = "") throw (SALOME::SALOME_Exception); - + + BLSURFPlugin::TEnfVertexList* GetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception); + + bool UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* theVertexEntry = "") throw (SALOME::SALOME_Exception); + bool UnsetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception); + /*! - * 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 2cdf62d..12951a8 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -27,10 +27,13 @@ #include "BLSURFPluginGUI_HypothesisCreator.h" // #include +#include "GeometryGUI.h" + #include #include #include #include "SMESHGUI_SpinBox.h" +#include "SMESH_NumberFilter.hxx" #include #include @@ -65,13 +68,14 @@ #include #include #include +#include "SALOME_LifeCycleCORBA.hxx" -#include #include #include #include #include #include +#include #define WITH_SIZE_BOUNDARIES @@ -109,11 +113,12 @@ enum { SMP_NB_COLUMNS, // Enforced vertices array columns ENF_VER_NAME_COLUMN = 0, - ENF_VER_ENTRY_COLUMN, + ENF_VER_FACE_ENTRY_COLUMN, ENF_VER_X_COLUMN, ENF_VER_Y_COLUMN, ENF_VER_Z_COLUMN, -// ENF_VER_GROUP_COLUMN, + ENF_VER_ENTRY_COLUMN, + ENF_VER_GROUP_COLUMN, ENF_VER_NB_COLUMNS }; @@ -131,16 +136,16 @@ enum { // Enforced vertices inputs enum { -// ENF_VER_FACE = 0, -// ENF_VER_VERTEX, - ENF_VER_X_COORD = 0, + ENF_VER_FACE = 0, + ENF_VER_VERTEX, + ENF_VER_X_COORD, ENF_VER_Y_COORD, ENF_VER_Z_COORD, -// ENF_VER_GROUP, + ENF_VER_GROUP, ENF_VER_VERTEX_BTN, ENF_VER_REMOVE_BTN, // ENF_VER_SEPARATOR, -// ENF_VER_GROUP_CHECK, + ENF_VER_GROUP_CHECK, ENF_VER_NB_LINES }; @@ -176,9 +181,9 @@ PyStdOut_write(PyStdOut *self, PyObject *args) return Py_None; } -static PyMethodDef PyStdOut_methods[] = { +static PyMethodDef PyStdOut_methods[] = { {"write", (PyCFunction)PyStdOut_write, METH_VARARGS, - PyDoc_STR("write(string) -> None")}, + PyDoc_STR("write(string) -> None")}, {NULL, NULL} /* sentinel */ }; @@ -252,8 +257,6 @@ End initialization Python structures and objects **************************************************/ -class QDoubleValidator; - // // BEGIN EnforcedTreeWidgetDelegate // @@ -267,35 +270,42 @@ QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & option , const QModelIndex & index ) const { -// QLineEdit *editor = new QLineEdit(parent); + QModelIndex father = index.parent(); + QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString(); + if (index.column() == ENF_VER_X_COLUMN || \ - index.column() == ENF_VER_Y_COLUMN || \ - index.column() == ENF_VER_Z_COLUMN) + index.column() == ENF_VER_Y_COLUMN || \ + index.column() == ENF_VER_Z_COLUMN) { SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent); editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + editor->setReadOnly(!entry.isEmpty()); + editor->setDisabled(!entry.isEmpty()); return editor; } -// editor->setValidator(new QDoubleValidator(parent)); else { QLineEdit *editor = new QLineEdit(parent); + if (index.column() != ENF_VER_GROUP_COLUMN) { + editor->setReadOnly(!entry.isEmpty()); + editor->setDisabled(!entry.isEmpty()); + } return editor; } -// return editor; } void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString value = index.model()->data(index, Qt::EditRole).toString(); - if (index.column() == ENF_VER_X_COLUMN || \ - index.column() == ENF_VER_Y_COLUMN || \ - index.column() == ENF_VER_Z_COLUMN) { + + if (index.column() == ENF_VER_X_COLUMN || + index.column() == ENF_VER_Y_COLUMN || + index.column() == ENF_VER_Z_COLUMN) + { SMESHGUI_SpinBox *lineEdit = static_cast(editor); lineEdit->setText(value); -// lineEdit->editor()->setText(value); } else { QLineEdit *lineEdit = static_cast(editor); @@ -306,32 +316,26 @@ void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor, void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { -// QLineEdit *lineEdit = static_cast(editor); - - if (index.column() == ENF_VER_X_COLUMN || \ - index.column() == ENF_VER_Y_COLUMN || \ - index.column() == ENF_VER_Z_COLUMN) - { + QModelIndex parent = index.parent(); + QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString(); + if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) { SMESHGUI_SpinBox *lineEdit = static_cast(editor); - if (! vertexExists(model, index, lineEdit->GetString())) { + if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString())) model->setData(index, lineEdit->GetValue(), Qt::EditRole); - } - } - else if (index.column() == ENF_VER_NAME_COLUMN) { + } else if (index.column() == ENF_VER_NAME_COLUMN) { QLineEdit *lineEdit = static_cast(editor); QString value = lineEdit->text(); - if (! vertexExists(model, index, value)) { + if (entry.isEmpty() && !vertexExists(model, index, value)) model->setData(index, value, Qt::EditRole); - } -// MESSAGE("Value " << value.toString().toStdString() << " was set at index(" << index.row() << "," << index.column() << ")"); - } - /* TODO GROUPS - else if (index.column() == ENF_VER_GROUP_COLUMN) { + } else if (index.column() == ENF_VER_ENTRY_COLUMN) { + QLineEdit *lineEdit = static_cast(editor); + QString value = lineEdit->text(); + if (! vertexExists(model, index, value)) + model->setData(index, value, Qt::EditRole); + } else if (index.column() == ENF_VER_GROUP_COLUMN) { QLineEdit *lineEdit = static_cast(editor); model->setData(index, lineEdit->text(), Qt::EditRole); -// MESSAGE("Value " << value.toString().toStdString() << " was set at index(" << index.row() << "," << index.column() << ")"); } - */ } void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor, @@ -347,8 +351,8 @@ bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model, QModelIndex parent = index.parent(); int row = index.row(); int col = index.column(); - - if (parent.isValid()) { + + if (parent.isValid() && !value.isEmpty()) { if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) { double x, y, z; if (col == ENF_VER_X_COLUMN) { @@ -366,23 +370,36 @@ bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model, x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble(); y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble(); } - // MESSAGE("Checking for existing vertex " << x << ", " << y << "," << z); int nbChildren = model->rowCount(parent); for (int i = 0 ; i < nbChildren ; i++) { if (i != row) { double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble(); double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble(); double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble(); -// MESSAGE("Vertex: " << childX << ", " << childY << "," << childZ); if ((childX == x) && (childY == y) && (childZ == z)) { -// MESSAGE("Found !"); exists = true; break; } } } } - else if (index.column() == ENF_VER_NAME_COLUMN) { +// else if (col == ENF_VER_ENTRY_COLUMN) { +// // Compare entries if no coords (= selected geom) +// xString = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toString(); +// if (xString.isEmpty) { +// int nbChildren = model->rowCount(parent); +// for (int i = 0 ; i < nbChildren ; i++) { +// if (i != row) { +// QString childName = parent.child(i, ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString(); +// if (childName == value) { +// exists = true; +// break; +// } +// } +// } +// } +// } + else if (col == ENF_VER_NAME_COLUMN) { int nbChildren = model->rowCount(parent); for (int i = 0 ; i < nbChildren ; i++) { if (i != row) { @@ -403,6 +420,75 @@ bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model, // END EnforcedTreeWidgetDelegate // +// +// BEGIN BLSURFPluginGUI_ObjectReferenceParamWdg +// +//================================================================================ + +// BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg +// ( SUIT_SelectionFilter* f, QWidget* parent, bool multiSelection) +// : StdMeshersGUI_ObjectReferenceParamWdg(f, parent, multiSelection) +// { +// init(); +// } +// +// +// BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg +// ( MeshObjectType objType, QWidget* parent, bool multiSelection ) +// : StdMeshersGUI_ObjectReferenceParamWdg( objType, parent, multiSelection ) +// { +// init(); +// } +// +// BLSURFPluginGUI_ObjectReferenceParamWdg::~BLSURFPluginGUI_ObjectReferenceParamWdg() +// { +// if ( myFilter ) +// { +// mySelectionMgr->removeFilter( myFilter ); +// delete myFilter; +// } +// } +// +// void BLSURFPluginGUI_ObjectReferenceParamWdg::init() +// { +// StdMeshersGUI_ObjectReferenceParamWdg::init(); +// disconnect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection())); +// connect( mySelButton, SIGNAL(toggled(bool)), SLOT(setActivationStatus(bool))); +// } +// +// void BLSURFPluginGUI_ObjectReferenceParamWdg::setActivationStatus(bool status) +// { +// if (status) +// activateSelection(); +// else +// deactivateSelection(); +// } +// +// void BLSURFPluginGUI_ObjectReferenceParamWdg::activateSelectionOnly() +// { +// if ( !mySelectionActivated && mySelectionMgr ) +// { +// mySelectionActivated = true; +// mySelectionMgr->clearFilters(); +// if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) +// aViewWindow->SetSelectionMode(ActorSelection); +// if ( myFilter ) +// mySelectionMgr->installFilter( myFilter ); +// connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); +// } +// emit selectionActivated(); +// } +// +// void BLSURFPluginGUI_ObjectReferenceParamWdg::deactivateSelectionOnly() +// { +// mySelectionActivated = false; +// disconnect(mySelectionMgr, 0, this, 0 ); +// mySelectionMgr->removeFilter( myFilter ); +// } +// +// +// END BLSURFPluginGUI_ObjectReferenceParamWdg +// /** * \brief {BLSURFPluginGUI_HypothesisCreator constructor} @@ -434,7 +520,7 @@ BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QStr PyRun_SimpleString("from math import *"); PyGILState_Release(gstate); - + } BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator() @@ -446,30 +532,17 @@ BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator() * */ GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() { -// MESSAGE("BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool"); BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); -// MESSAGE("aStudy->StudyId(): " << aStudy->StudyId()); if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) { -// MESSAGE("GeomToolSelected is created"); that->GeomToolSelected = new GeomSelectionTools(aStudy); } -// else -// MESSAGE("GeomToolSelected already exists"); -// MESSAGE("that->GeomToolSelected->getMyStudy()->StudyId(): " << that->GeomToolSelected->getMyStudy()->StudyId()); return that->GeomToolSelected; } -namespace { - inline bool isDouble( const QString& theText, const bool emptyOK=false ) { - QString str = theText.trimmed(); - bool isOk = true; - if ( !str.isEmpty() ) - str.toDouble(&isOk); - else - isOk = emptyOK; - return isOk; - } +GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine() +{ + return GeometryGUI::GetGeomGen(); } @@ -477,28 +550,7 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const { MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams"); bool ok = true; -// if ( !isDouble( myPhySize->text(), false )) { -// if ( myPhySize->text().isEmpty() ) -// myPhySize->setText(tr("OBLIGATORY_VALUE")); -// myPhySize->selectAll(); -// ok = false; -// } -// if ( !isDouble( myPhyMin->text(), true )) { -// myPhyMin->selectAll(); -// ok = false; -// } -// if ( !isDouble( myPhyMax->text(), true )) { -// myPhyMax->selectAll(); -// ok = false; -// } -// if ( !isDouble( myGeoMin->text(), true )) { -// myGeoMin->selectAll(); -// ok = false; -// } -// if ( !isDouble( myGeoMin->text(), true )) { -// myGeoMin->selectAll(); -// ok = false; -// } + if ( ok ) { myOptionTable->setFocus(); @@ -567,14 +619,14 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const // Enforced vertices // TODO - + return ok; } QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() { MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame"); - + QFrame* fr = new QFrame( 0 ); QVBoxLayout* lay = new QVBoxLayout( fr ); lay->setMargin( 5 ); @@ -637,7 +689,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() #endif myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup ); myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup ); - + // ADD WIDGETS (STANDARD TAB) int row = 0; if( isCreation() ) { @@ -702,8 +754,8 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() QPushButton* addBtn = new QPushButton( tr( "ADD_OPTION"), myAdvGroup ); addBtn->setMenu( new QMenu() ); QPushButton* rmBtn = new QPushButton( tr( "REMOVE_OPTION"), myAdvGroup ); - - + + // ADD WIDGETS (ADVANCED TAB) anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ), 0, 0, 1, 1 ); anAdvLayout->addWidget( myTopology, 0, 1, 1, 1 ); @@ -742,8 +794,8 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() line2->setFrameShape(QFrame::HLine); line2->setFrameShadow(QFrame::Sunken); removeButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup); - - + + // ADD WIDGETS (SIZEMAP TAB) anSmpLayout->addWidget(mySizeMapTable, SMP_POINT_BTN, 0, SMP_NB_LINES+1, 1); // anSmpLayout->addWidget(addAttractorButton, SMP_ATTRACTOR_BTN, 1, 1, 1); @@ -758,20 +810,20 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() // Enforced vertices parameters myEnfGroup = new QWidget(); QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup); -// +// // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup); // anEnfLayout->addWidget(myEnforcedVertexWidget); // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance"); // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(); - + myEnforcedTreeWidget = new QTreeWidget(myEnfGroup); myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS ); myEnforcedTreeWidget->setSortingEnabled(true); QStringList enforcedHeaders; - enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_X_COLUMN" )<< tr( "BLSURF_ENF_VER_Y_COLUMN" ) << tr( "BLSURF_ENF_VER_Z_COLUMN" ); - /* TODO GROUPS - enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_X_COLUMN" )<< tr( "BLSURF_ENF_VER_Y_COLUMN" ) << tr( "BLSURF_ENF_VER_Z_COLUMN" ) << tr( "BLSURF_ENF_VER_GROUP_COLUMN" ); - */ + enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN") + << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN") + << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" ); + myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders); myEnforcedTreeWidget->setAlternatingRowColors(true); myEnforcedTreeWidget->setUniformRowHeights(true); @@ -782,52 +834,48 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive); myEnforcedTreeWidget->resizeColumnToContents(column); } + myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN); myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN); myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate()); - - /* TODO FACE AND VERTEX SELECTION - selectFaceButton = new QPushButton(myEnfGroup); - QPixmap imageSel1(SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "BLSURF_ICON_SELECT"))); - selectFaceButton->setIcon(imageSel1); - mySelectedFace = new QLineEdit(myEnfGroup); - mySelectedFace->setReadOnly(true); - mySelectedFace->setText(tr( "BLSURF_ENF_SELECT_FACE")); - mySelectedFace->setStyleSheet("QLineEdit { color: grey }"); - - selectVertexButton = new QPushButton(myEnfGroup); - QPixmap imageSel2(SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "BLSURF_ICON_SELECT"))); - selectVertexButton->setIcon(imageSel2); - - mySelectedEnforcedVertex = new QLineEdit(myEnfGroup); - mySelectedEnforcedVertex->setReadOnly(true); - mySelectedEnforcedVertex->setText(tr( "BLSURF_ENF_SELECT_VERTEX")); - mySelectedEnforcedVertex->setStyleSheet("QLineEdit { color: grey }"); - */ +// FACE AND VERTEX SELECTION + TColStd_MapOfInteger shapeTypes1, shapeTypes2; + shapeTypes1.Add( TopAbs_FACE ); + shapeTypes1.Add( TopAbs_COMPOUND ); + shapeTypes2.Add( TopAbs_VERTEX ); + shapeTypes2.Add( TopAbs_COMPOUND ); + + SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1); + myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true); + myEnfFaceWdg->SetDefaultText("Select Faces", "QLineEdit { color: grey }"); + + SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2); + myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true); + myEnfVertexWdg->SetDefaultText("Select Vertices", "QLineEdit { color: grey }"); + + myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg); + QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup ); myXCoord = new SMESHGUI_SpinBox(myEnfGroup); myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); - + QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup ); myYCoord = new SMESHGUI_SpinBox(myEnfGroup); myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); - + QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup ); myZCoord = new SMESHGUI_SpinBox(myEnfGroup); myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); - /* TODO GROUPS QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup ); myGroupName = new QLineEdit(myEnfGroup); - */ - + addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup); // QFrame *line = new QFrame(myEnfGroup); // line->setFrameShape(QFrame::HLine); // line->setFrameShadow(QFrame::Sunken); removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup); - /* TODO GROUPS // CheckBox for groups generation makeGroupsCheck = new QGroupBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup); makeGroupsCheck->setCheckable(true); @@ -835,39 +883,32 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() QGridLayout* aGroupLayout = new QGridLayout(makeGroupsCheck); myGlobalGroupName = new QLineEdit(makeGroupsCheck); aGroupLayout->addWidget(myGlobalGroupName); - */ - - + anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES+1, 1); - /* TODO FACE AND VERTEX SELECTION - anEnfLayout->addWidget(selectFaceButton, ENF_VER_FACE, 1, 1, 1); - anEnfLayout->addWidget(mySelectedFace, ENF_VER_FACE, 2, 1, 1); - anEnfLayout->addWidget(selectVertexButton, ENF_VER_VERTEX, 1, 1, 1); - anEnfLayout->addWidget(mySelectedEnforcedVertex, ENF_VER_VERTEX, 2, 1, 1); - */ - anEnfLayout->addWidget(myXCoordLabel, ENF_VER_X_COORD, 1, 1, 1); - anEnfLayout->addWidget(myXCoord, ENF_VER_X_COORD, 2, 1, 1); - anEnfLayout->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 1, 1, 1); - anEnfLayout->addWidget(myYCoord, ENF_VER_Y_COORD, 2, 1, 1); - anEnfLayout->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 1, 1, 1); - anEnfLayout->addWidget(myZCoord, ENF_VER_Z_COORD, 2, 1, 1); - /* TODO GROUPS - anEnfLayout->addWidget(myGroupNameLabel, ENF_VER_GROUP, 1, 1, 1); - anEnfLayout->addWidget(myGroupName, ENF_VER_GROUP, 2, 1, 1); - */ - anEnfLayout->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 1, 1, 2); - anEnfLayout->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 1, 1, 2); -// anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 1, 1, 2); - /* TODO GROUPS - anEnfLayout->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 1, 1, 2); - */ - + QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup); +// FACE AND VERTEX SELECTION + anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2); + anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2); + + anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1); + anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1); + anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1); + anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1); + anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1); + anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1); + anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1); + anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1); + anEnfLayout2->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 0, 1, 2); + anEnfLayout2->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 0, 1, 2); +// anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 0, 1, 2); + anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2); + anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2); + // --- tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) ); tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) ); tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) ); tab->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) ); -// tab->insertTab( ENF_TAB, myEnforcedVertexWidget, tr( "BLSURF_ENF_VER" ) ); tab->setCurrentIndex( STD_TAB ); @@ -885,45 +926,112 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) ); connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) ); - connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) ); + connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) ); connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) ); connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) ); connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) ); + connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) ); +// connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) ); +// connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) ); +// connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(deactivateSelection(QWidget*, QWidget*))); return fr; } -/** BLSURFPluginGUI_HypothesisCreator::update(item, column) +/** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*) +This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg +*/ +void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now) +{ + if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord) + || (now = myGroupName) || (now = makeGroupsCheck) || (now = myEnforcedTreeWidget)) { + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myEnfFaceWdg->deactivateSelection(); + myEnfVertexWdg->deactivateSelection(); + } +} + +/** + * This method resets the content of the X, Y, Z and GroupNAme widgets; +**/ +void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets() +{ + myXCoord->setCleared(true); + myYCoord->setCleared(true); + myZCoord->setCleared(true); + myXCoord->setText(""); + myYCoord->setText(""); + myZCoord->setText(""); + myGroupName->setText(""); +} + +/** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column) This method updates the tooltip of a modified item. The QLineEdit widgets content is synchronized with the coordinates of the enforced vertex clicked in the tree widget. */ -void BLSURFPluginGUI_HypothesisCreator::update(QTreeWidgetItem* item, int column) { -// MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateVertexList"); +void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) { +// MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues"); + QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole); QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole); - if (! x.isNull()) { - QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole); - QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole); - QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole); - /* TODO GROUPS - QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString(); - */ - - QTreeWidgetItem* parent = item->parent(); - if (parent) { + QVariant y = item->data(ENF_VER_X_COLUMN, Qt::EditRole); + QVariant z = item->data(ENF_VER_X_COLUMN, Qt::EditRole); + QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole); + QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString(); + QTreeWidgetItem* parent = item->parent(); + + clearEnforcedVertexWidgets(); + + if (parent && (!x.isNull() || !entry.isNull())) { QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString(); QString toolTip = shapeName + QString(": ") + vertexName.toString(); - toolTip += QString("(") + x.toString(); - toolTip += QString(", ") + y.toString(); - toolTip += QString(", ") + z.toString(); - toolTip += QString(")"); + if (entry.isNull()) { + toolTip += QString("(") + x.toString(); + toolTip += QString(", ") + y.toString(); + toolTip += QString(", ") + z.toString(); + toolTip += QString(")"); + } + + if (!groupName.isEmpty()) + toolTip += QString(" [") + groupName + QString("]"); + item->setToolTip(ENF_VER_NAME_COLUMN,toolTip); + + if (!x.isNull()) { + myXCoord->SetValue(x.toDouble()); + myYCoord->SetValue(y.toDouble()); + myZCoord->SetValue(z.toDouble()); + } + + if (!groupName.isEmpty()) + myGroupName->setText(groupName); + } +} + +void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() { + int nbSelEnfVertex = myEnfVertexWdg->NbObjects(); + clearEnforcedVertexWidgets(); + if (nbSelEnfVertex == 1) + { + if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() ) + return ; + + myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1); + if (myEnfVertex->GetShapeType() == GEOM::VERTEX) { + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() ); + if (CORBA::is_nil(measureOp)) + return; + + CORBA::Double x,y,z; + measureOp->PointCoordinates (myEnfVertex, x, y, z); + if ( measureOp->IsDone() ) + { + myXCoord->SetValue(x); + myYCoord->SetValue(y); + myZCoord->SetValue(z); + } } - myXCoord->SetValue(x.toDouble()); - myYCoord->SetValue(y.toDouble()); - myZCoord->SetValue(z.toDouble()); - /* TODO GROUPS - myGroupName->setText(groupName); - */ } } @@ -932,45 +1040,42 @@ This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the of the enforced vertex clicked in the tree widget. */ void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() { -// MESSAGE("BLSURFPluginGUI_HypothesisCreator::synchronizeCoords"); + clearEnforcedVertexWidgets(); QList items = myEnforcedTreeWidget->selectedItems(); - if (! items.isEmpty()) { - QTreeWidgetItem *item; - for (int i=0 ; i < items.size() ; i++) { - item = items[i]; + if (! items.isEmpty() && items.size() == 1) { + QTreeWidgetItem *item = items[0]; +// for (int i=0 ; i < items.size() ; i++) { +// item = items[i]; QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole); - if (! x.isNull()) { - QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole); - QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole); + QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole); + QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole); + QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole); + QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole); + if (!x.isNull()/* && entry.isNull()*/) { myXCoord->SetValue(x.toDouble()); myYCoord->SetValue(y.toDouble()); myZCoord->SetValue(z.toDouble()); - /* TODO GROUPS - myGroupName->setText(item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString()); - */ - break; +// break; } - } + if (!group.isNull() && (!x.isNull() || !entry.isNull())) + myGroupName->setText(group.toString()); +// } } } /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z) This method adds an enforced vertex (x,y,z) to shapeName in the tree widget. */ -/* TODO GROUPS -void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std::string shapeName, - double x, double y, double z, std::string groupName) { -*/ -void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std::string shapeName, - double x, double y, double z) { - // Find entry item - QList theItemList = myEnforcedTreeWidget->findItems(QString(entry.c_str()),Qt::MatchExactly,ENF_VER_ENTRY_COLUMN); +void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEntry, std::string theFaceName, + double x, double y, double z, std::string vertexName, std::string geomEntry, std::string groupName) { + // Find theFaceEntry item + QList theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN); QTreeWidgetItem* theItem; if (theItemList.empty()) { theItem = new QTreeWidgetItem(); - theItem->setData(ENF_VER_ENTRY_COLUMN, Qt::EditRole, QVariant(entry.c_str())); - theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(shapeName.c_str())); - theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(entry.c_str())); + theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str())); + theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str())); + theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str())); myEnforcedTreeWidget->addTopLevelItem(theItem); } else { @@ -984,63 +1089,91 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std // MESSAGE("Number of child rows: " << nbVert); if (nbVert >0) { double childValueX,childValueY,childValueZ; -// QString childGrouName; + QString childEntry, childGroupName; QTreeWidgetItem* child; for (int row = 0;rowchild(row); + childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString(); + childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString(); childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble(); childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble(); childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble(); - if ((childValueX == x) && (childValueY == y) && (childValueZ == z)) { - /* TODO GROUPS + if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) { // update group name - child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str())); - */ + if (childGroupName.toStdString() != groupName) { + MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\""); + child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str())); + } okToCreate = false; break; - } + } // if + } // for + } // if + if (!okToCreate) { + if (geomEntry.empty()) { + MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again"); + } + else { + MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again"); } + return; } - if (okToCreate) { - MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z<< " is created"); - QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem); - vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); - int vertexIndex=1; - QString vertexName; - int indexRef = 0; - while(indexRef != vertexIndex) { - indexRef = vertexIndex; - vertexName = QString("Vertex #%1").arg(vertexIndex); - for (int row = 0;rowchild(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString(); - if (vertexName == name) { - vertexIndex++; - break; - } + if (geomEntry.empty()) { + MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created"); + } + else { + MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created"); + } + + QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem); + vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); + QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QSize iconSize = iconSelect.size()*0.7; + + int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem); + QString myVertexName; + int indexRef = -1; + while(indexRef != vertexIndex) { + indexRef = vertexIndex; + if (vertexName.empty()) + myVertexName = QString("Vertex #%1").arg(vertexIndex); + else + myVertexName = QString(vertexName.c_str()); + + for (int row = 0;rowchild(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString(); + if (myVertexName == name) { + vertexIndex++; + break; } } - vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, vertexName ); + } + vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName ); + if (geomEntry.empty()) { vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) ); vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) ); vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) ); - /* TODO GROUPS + } + else { + vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation))); + vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) ); + } + if (groupName != "") vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str())); - */ - QString toolTip = QString(shapeName.c_str())+QString(": ")+vertexName; + + QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName; + if (geomEntry.empty()) { toolTip += QString(" (%1, ").arg(x); toolTip += QString("%1, ").arg(y); toolTip += QString("%1)").arg(z); - vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip); - theItem->setExpanded(true); - myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN); } - else - /* TODO GROUPS - MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z << - " already exist: dont create again, only group name is updated with " << groupName); - */ - MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again"); + if (groupName != "") + toolTip += QString(" [%1]").arg(groupName.c_str()); + + vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip); + theItem->setExpanded(true); + myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN); } /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() @@ -1049,53 +1182,84 @@ This method is called when a item is added into the enforced vertices tree widge void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() { // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices"); + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + + that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myEnfFaceWdg->deactivateSelection(); + myEnfVertexWdg->deactivateSelection(); + for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column) myEnforcedTreeWidget->resizeColumnToContents(column); - - BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - - if ((myXCoord->text().isEmpty()) || - (myYCoord->text().isEmpty()) || - (myZCoord->text().isEmpty())) return; - double x = myXCoord->GetValue(); - double y = myYCoord->GetValue(); - double z = myZCoord->GetValue(); + // Vertex selection + int selEnfFace = myEnfFaceWdg->NbObjects(); + int selEnfVertex = myEnfVertexWdg->NbObjects(); + bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty()); - /* TODO GROUPS - std::string groupName = myGroupName->text().toStdString(); - if (makeGroupsCheck->isChecked()) - groupName = myGlobalGroupName->text().toStdString(); + if (selEnfFace == 0) + return; + + if ((selEnfVertex == 0) && coordsEmpty) + return; - if (boost::trim_copy(groupName) == "") - groupName = ""; - */ - - TopAbs_ShapeEnum shapeType; string entry, shapeName; - GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool(); - LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr(); - SALOME_ListIO ListSelectedObjects; - mySel->selectedObjects(ListSelectedObjects, NULL, false ); - if (!ListSelectedObjects.IsEmpty()) { - SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects); - for (; Object_It.More(); Object_It.Next()) { - Handle(SALOME_InteractiveObject) anObject = Object_It.Value(); - entry = myGeomToolSelected->getEntryOfObject(anObject); - shapeName = anObject->getName(); - shapeType = myGeomToolSelected->entryToShapeType(entry); -// MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType); - if (shapeType == TopAbs_FACE) { - /* TODO GROUPS - addEnforcedVertex(entry, shapeName, x, y, z, groupName); - */ - addEnforcedVertex(entry, shapeName, x, y, z); + + for (int i = 0 ; i < selEnfFace ; i++) { + myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i); + entry = myEnfFace->GetStudyEntry(); + shapeName = myEnfFace->GetName(); + + std::string groupName = myGroupName->text().toStdString(); + if (makeGroupsCheck->isChecked()) + groupName = myGlobalGroupName->text().toStdString(); + + if (boost::trim_copy(groupName).empty()) + groupName = ""; + + if (selEnfVertex <= 1) + { + double x,y,z; + x = myXCoord->GetValue(); + y = myYCoord->GetValue(); + z = myZCoord->GetValue(); + if (selEnfVertex == 1) { + myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(); + addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName); + } + else + addEnforcedVertex(entry, shapeName, x, y, z, "", "", groupName); + } + else + { + if ( CORBA::is_nil(getGeomEngine())) + return; + + GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() ); + if (CORBA::is_nil(measureOp)) + return; + + CORBA::Double x,y,z; + x = y = z = 0.; + for (int j = 0 ; j < selEnfVertex ; j++) + { + myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j); + if (myEnfVertex->GetShapeType() == GEOM::VERTEX) { + measureOp->PointCoordinates (myEnfVertex, x, y, z); + if ( measureOp->IsDone() ) + addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName); + } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) { + addEnforcedVertex(entry, shapeName, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName); + } } } } + + myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil()); + myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil()); + for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column) myEnforcedTreeWidget->resizeColumnToContents(column); - + if ( myPhysicalMesh->currentIndex() != SizeMap ) { myPhysicalMesh->setCurrentIndex( SizeMap ); onPhysicalMeshChanged(); @@ -1116,8 +1280,13 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() { QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole); if (! value.isNull()) selectedVertices.append(item); - else - selectedEntries.insert(item); + else { + value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole); + if (! value.isNull()) + selectedVertices.append(item); + else + selectedEntries.insert(item); + } } foreach(item,selectedVertices) { @@ -1239,39 +1408,41 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); // Enforced vertices -// MESSAGE("retrieveParams(): data.entryEnfVertexListMap.size() = " << data.entryEnfVertexListMap.size()); - std::map > >::const_iterator evmIt = data.entryEnfVertexListMap.begin(); - for ( ; evmIt != data.entryEnfVertexListMap.end() ; ++evmIt) { - std::string entry = (*evmIt).first; + MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size()); + TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin(); + for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) { + TEntry entry = (*evmIt).first; std::string shapeName = myGeomToolSelected->getNameFromEntry(entry); - - std::set > evs; - std::set >::const_iterator evsIt; - try { - evs = (*evmIt).second; - } - catch(...) { -// MESSAGE("evs = (*evmIt)[entry]: FAIL"); - break; - } - - evsIt = evs.begin(); + MESSAGE("Face entry: " << entry); + MESSAGE("Face name: " << shapeName); + + TEnfVertexList evs = (*evmIt).second; +// try { +// evs = (*evmIt).second; +// } +// catch(...) { +// MESSAGE("evs = (*evmIt).second: FAIL"); +// break; +// } + + TEnfVertexList::const_iterator evsIt = evs.begin(); + TEnfVertex *enfVertex; for ( ; evsIt != evs.end() ; ++evsIt) { - double x, y, z; - x = (*evsIt)[0]; - y = (*evsIt)[1]; - z = (*evsIt)[2]; - /* TODO GROUPS - std::string groupName = data.enfVertexGroupNameMap[(*evsIt)]; - MESSAGE("Vertex "<addEnforcedVertex(entry, shapeName, x, y, z, groupName); - */ - that->addEnforcedVertex(entry, shapeName, x, y, z); + enfVertex = (*evsIt); + MESSAGE("Name: " << enfVertex->name); + double x, y, z = 0; + if (enfVertex->coords.size()) { + x = enfVertex->coords[0]; + y = enfVertex->coords[1]; + z = enfVertex->coords[2]; + } + that->addEnforcedVertex(entry, shapeName, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName); } } + for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column) myEnforcedTreeWidget->resizeColumnToContents(column); - + // update widgets that->onPhysicalMeshChanged(); that->onGeometricMeshChanged(); @@ -1393,54 +1564,50 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]); } } - + // Enforced vertices h_data.enfVertexList.clear(); - h_data.entryEnfVertexListMap.clear(); + h_data.faceEntryEnfVertexListMap.clear(); /* TODO GROUPS h_data.groupNameEnfVertexListMap.clear(); -// h_data.enfVertexGroupNameMap.clear(); */ - - BLSURFPlugin::TEntryEnfVertexListMap_var entryEnfVertexListMap = h->GetAllEnforcedVertices(); -// MESSAGE("entryEnfVertexListMap->length() = " << entryEnfVertexListMap->length()); - for ( int i = 0;ilength(); ++i ) { - std::string entry = entryEnfVertexListMap[i].entry.in(); - BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str()); - std::set > evs; - /* TODO GROUPS - std::string groupName = ""; - */ - for (int j=0 ; jlength(); ++j) { - double x = vertexList[j][0]; - double y = vertexList[j][1]; - double z = vertexList[j][2]; - std::vector ev; - ev.push_back(x); - ev.push_back(y); - ev.push_back(z); - evs.insert(ev); - h_data.enfVertexList.insert(ev); + BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace(); + MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length()); + + for ( int i = 0;ilength(); ++i ) { + std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in(); +// BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in(); + BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList; +// BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str()); + +// TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry]; + + for (int j=0 ; jname = CORBA::string_dup(vertexList[j].name.in()); + enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in()); + enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in()); + for (int k=0 ; k< vertexList[j].coords.length();k++) + enfVertex->coords.push_back(vertexList[j].coords[k]); + + h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex); + /* TODO GROUPS - groupName.assign(h->GetEnforcedVertexGroupName(x, y, z)); - MESSAGE("readParamsFromHypo, groupName = "<SetAngleMeshC( h_data.myAngleMeshC ); } #ifdef WITH_SIZE_BOUNDARIES -// if ( !isDouble( h_data.myPhyMin )) -// h->SetPhyMin( -1 ); -// else if ( h->GetPhyMin() != h_data.myPhyMin.toDouble() ) -// h->SetPhyMin( h_data.myPhyMin.toDouble() ); -// if ( !isDouble( h_data.myPhyMax )) -// h->SetPhyMax( -1 ); -// else if ( h->GetPhyMax() != h_data.myPhyMax.toDouble() ) -// h->SetPhyMax( h_data.myPhyMax.toDouble() ); -// if ( !isDouble( h_data.myGeoMin )) -// h->SetGeoMin( -1 ); -// else if ( h->GetGeoMin() != h_data.myGeoMin.toDouble() ) -// h->SetGeoMin( h_data.myGeoMin.toDouble() ); -// if ( !isDouble( h_data.myGeoMax )) -// h->SetGeoMax( -1 ); -// else if ( h->GetGeoMax() != h_data.myGeoMax.toDouble() ) -// h->SetGeoMax( h_data.myGeoMax.toDouble() ); if (h_data.myPhyMin > 0) h->SetPhyMin( h_data.myPhyMin ); if (h_data.myPhyMax > 0) @@ -1511,7 +1662,6 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi h->SetGeoMax( h_data.myGeoMax ); #endif - //printf("storeParamsToHypo():myOptions->length()=%d\n",myOptions->length()); h->SetOptionValues( myOptions ); // is set in checkParams() BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; @@ -1548,64 +1698,123 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() ); } } - + // Enforced vertices - std::map > >::const_iterator evmIt = h_data.entryEnfVertexListMap.begin(); - for ( ; evmIt != h_data.entryEnfVertexListMap.end() ; ++evmIt) { - std::string entry = evmIt->first; - std::set > evs; - std::set >::const_iterator evsIt; - double x, y, z; - /* TODO GROUPS - std::string groupName = ""; - */ - BLSURFPlugin::TEnfVertexList_var hypVertexList; - int hypNbVertex = 0; - try { - hypVertexList = h->GetEnforcedVerticesEntry(entry.c_str()); - hypNbVertex = hypVertexList->length(); - } - catch(...) { - } - evs = evmIt->second; - evsIt = evs.begin(); - for ( ; evsIt != evs.end() ; ++evsIt) { - x = (*evsIt)[0]; - y = (*evsIt)[1]; - z = (*evsIt)[2]; - - /* TODO GROUPS - std::map , std::string >::const_iterator grpIt = h_data.enfVertexGroupNameMap.find(*evsIt); - if (grpIt != h_data.enfVertexGroupNameMap.end()) - groupName = grpIt->second; -// MESSAGE("SetEnforcedVertexEntry("<SetEnforcedVertexEntryWithGroup( entry.c_str(), x, y, z, groupName.c_str() ); - */ - h->SetEnforcedVertexEntry( entry.c_str(), x, y, z ); + bool ret; + int hypNbVertex; + double x, y, z = 0; + std::string enfName; + /* TODO GROUPS + std::string groupName = ""; + */ + + TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin(); + + BLSURFPlugin::TFaceEntryEnfVertexListMap_var allEnforcedVerticesByFace = h->GetAllEnforcedVerticesByFace(); + hypNbVertex = allEnforcedVerticesByFace->length(); + + + // All enforced vertices were deleted + if (evmIt == h_data.faceEntryEnfVertexListMap.end() && hypNbVertex!=0) { + h->ClearAllEnforcedVertices(); + ok = true; + } + else { + // All enforced vertices for a specific entry were deleted + for (int i=0 ; iUnsetEnforcedVerticesEntry(entry.c_str()); + } } - // Remove old vertices - if (hypNbVertex >0) { + + // One or several enforced vertices are added or removed for a specific entry + TEnfVertexList enfVertexFromHyp; + BLSURFPlugin::TEnfVertexList_var hypEnfVertexList; + TEnfName faceEntry; + TEnfVertexList evs; + TEnfVertexList::const_iterator evsIt, enfVertexToRemove; + for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt) { + faceEntry = evmIt->first; + evs = evmIt->second; + MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size()); + evsIt = evs.begin(); + + hypEnfVertexList = h->GetEnforcedVerticesEntry(faceEntry.c_str()); + hypNbVertex = hypEnfVertexList->length(); + MESSAGE("Number of enforced vertices from hypothesis: " << hypNbVertex); + enfVertexFromHyp.clear(); for (int i =0 ; i vertex; - vertex.push_back(x); - vertex.push_back(y); - vertex.push_back(z); - if (evs.find(vertex) == evs.end()) { -// MESSAGE("UnsetEnforcedVertexEntry("<UnsetEnforcedVertexEntry( entry.c_str(), x, y, z ); + TEnfVertex *_enfVertex = new TEnfVertex(); + _enfVertex->name = string(""); + _enfVertex->name = CORBA::string_dup(hypEnfVertexList[i].name.in()); + _enfVertex->geomEntry = string(""); + _enfVertex->geomEntry = CORBA::string_dup(hypEnfVertexList[i].geomEntry.in()); + _enfVertex->grpName = string(""); + _enfVertex->grpName = CORBA::string_dup(hypEnfVertexList[i].grpName.in()); + for (int j=0 ; j< hypEnfVertexList[i].coords.length() ; j++) + _enfVertex->coords.push_back(hypEnfVertexList[i].coords[j]); + enfVertexFromHyp.insert(_enfVertex); + MESSAGE("From hyp: enf vertex " << _enfVertex->name); +// MESSAGE("From hyp: enf. vertex at " << _coords[0]<<", "<<_coords[1]<<", "<<_coords[2]); + } + +// TEnfVertex *enfVertex; + for ( ; evsIt != evs.end() ; ++evsIt) { + x =y =z = 0; +// enfVertex = (*evsIt); + if ((*evsIt)->coords.size()) { + x = (*evsIt)->coords[0]; + y = (*evsIt)->coords[1]; + z = (*evsIt)->coords[2]; } + ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str()); + enfVertexFromHyp.erase((*evsIt)); + +// for (enfVertexToRemove = enfVertexFromHyp.begin() ; enfVertexToRemove != enfVertexFromHyp.end() ; ++enfVertexToRemove) { +// if (!TEnfVertexGUICmp(&enfVertex, &(*enfVertexToRemove))) { +// MESSAGE("Enf vertex " << enfVertex.name << " must not be deleted") +// enfVertexFromHyp.erase(enfVertexToRemove); +// } +// } } - } - } - } - catch(const SALOME::SALOME_Exception& ex) - { - SalomeApp_Tools::QtCatchCorbaException(ex); - ok = false; + + // Remove old vertices + enfVertexToRemove = enfVertexFromHyp.begin(); + for ( ; enfVertexToRemove!=enfVertexFromHyp.end() ; ++enfVertexToRemove) { +// enfVertex = (*enfVertexToRemove); + if (h_data.enfVertexList.find((*enfVertexToRemove)) != h_data.enfVertexList.end()) { + +// for ( evsIt=h_data.enfVertexList.begin();evsIt!=h_data.enfVertexList.end();evsIt++) { +// if (TEnfVertexGUICmp(&(*evsIt),&enfVertex)) { + MESSAGE("Remove enf vertex " << (*enfVertexToRemove)->name); + if ((*enfVertexToRemove)->coords.size()) { + x = (*enfVertexToRemove)->coords[0]; + y = (*enfVertexToRemove)->coords[1]; + z = (*enfVertexToRemove)->coords[2]; + } + ret = h->UnsetEnforcedVertexEntry(faceEntry.c_str(), x, y, z, (*enfVertexToRemove)->geomEntry.c_str()); + if (ret) + MESSAGE("SUCCESS"); +// } // if +// } // for + } // if + } // for + } // for + } // else + } // try + catch(const std::exception& ex) { + std::cout << "Exception: " << ex.what() << std::endl; + throw ex; } +// catch(const SALOME::SALOME_Exception& ex) +// { +// throw ex; +// // SalomeApp_Tools::QtCatchCorbaException(ex); +// // ok = false; +// } return ok; } @@ -1677,12 +1886,8 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes // Enforced vertices h_data.enfVertexList.clear(); - h_data.entryEnfVertexListMap.clear(); - /* TODO GROUPS - h_data.groupNameEnfVertexListMap.clear(); - h_data.enfVertexGroupNameMap.clear(); - */ - + h_data.faceEntryEnfVertexListMap.clear(); + int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount(); int nbEnforcedVertices = 0; std::string groupName = ""; @@ -1690,34 +1895,46 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes for (int i=0 ; itopLevelItem(i); if (shapeItem) { - std::string entry = shapeItem->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString(); + std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString(); nbEnforcedVertices = shapeItem->childCount(); if (nbEnforcedVertices >0) { double childValueX,childValueY,childValueZ; + std::string childName, vertexEntry; QTreeWidgetItem* child; - std::set > evs; + TEnfVertexList evs; + evs.clear(); for (row = 0;rowchild(row); + childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString(); childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble(); childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble(); childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble(); - std::vector vertex; - vertex.push_back(childValueX); - vertex.push_back(childValueY); - vertex.push_back(childValueZ); - evs.insert(vertex); - h_data.enfVertexList.insert(vertex); - /* TODO GROUPS - groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString(); - // Group + vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString(); if (makeGroupsCheck->isChecked()) groupName = myGlobalGroupName->text().toStdString(); - h_data.enfVertexGroupNameMap[vertex] = groupName; + else + groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString(); + + TEnfVertex *enfVertex = new TEnfVertex(); + enfVertex->name = childName; + if (vertexEntry.empty()) { + enfVertex->coords.push_back(childValueX); + enfVertex->coords.push_back(childValueY); + enfVertex->coords.push_back(childValueZ); + } + else + enfVertex->geomEntry = vertexEntry; + enfVertex->grpName = groupName; +// TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex); +// if (it == h_data.enfVertexList.end()) + h_data.enfVertexList.insert(enfVertex); + evs.insert(enfVertex); + /* TODO GROUPS if (groupName != "") h_data.groupNameEnfVertexListMap[groupName].insert(vertex); */ } - h_data.entryEnfVertexListMap[entry] = evs; + h_data.faceEntryEnfVertexListMap[faceEntry] = evs; } } } @@ -1732,29 +1949,16 @@ void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() { bool isSizeMap = (myPhysicalMesh->currentIndex() == SizeMap); bool isCustom = (isPhysicalUserDefined || isSizeMap) ; bool geomIsCustom = (myGeometricMesh->currentIndex() == UserDefined); - + myGradation->setEnabled(!isPhysicalUserDefined || geomIsCustom); myPhySize->setEnabled(isCustom); myPhyMax->setEnabled(isCustom); myPhyMin->setEnabled(isCustom); if ( !myGradation->isEnabled()) -// myGradation->setValue( 1.1 ); myGradation->SetValue( 1.1 ); if ( !isCustom ) { -// QString aPhySize = ""; -// switch( myPhysicalMesh->currentIndex() ) { -// case DefaultSize: -// default: -// aPhySize = "10"; -// break; -// } -// myPhySize->setText( aPhySize ); -// if ( !isDouble( myPhyMin->text(), true )) -// myPhyMin->setText(""); -// if ( !isDouble( myPhyMax->text(), true )) -// myPhyMax->setText(""); if ( myGeometricMesh->currentIndex() == DefaultGeom ) { myGeometricMesh->setCurrentIndex( UserDefined ); onGeometricMeshChanged(); @@ -1766,7 +1970,7 @@ void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() { MESSAGE("BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged"); bool isCustom = (myGeometricMesh->currentIndex() == UserDefined); bool phyIsSizemap = (myPhysicalMesh->currentIndex() == SizeMap); - + myAngleMeshS->setEnabled(isCustom); myAngleMeshC->setEnabled(isCustom); myGradation->setEnabled(isCustom || phyIsSizemap); @@ -1777,19 +1981,6 @@ void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() { myGradation->SetValue( 1.1 ); if ( ! isCustom ) { -// double aAngleMeshS; -// switch( myGeometricMesh->currentIndex() ) { -// case DefaultGeom: -// default: -// aAngleMeshS = 8; -// break; -// } -// myAngleMeshS->SetValue( aAngleMeshS ); -// myAngleMeshC->SetValue( aAngleMeshS ); -// if ( !isDouble( myGeoMin->text(), true )) -// myGeoMin->setText(""); -// if ( !isDouble( myGeoMax->text(), true )) -// myGeoMax->setText(""); // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec) if ( myPhysicalMesh->currentIndex() == DefaultSize ) { myPhysicalMesh->setCurrentIndex( PhysicalUserDefined ); @@ -1962,13 +2153,12 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis()); BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - - TopAbs_ShapeEnum shapeType; - string entry, shapeName; GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool(); LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr(); + TopAbs_ShapeEnum shapeType; + string entry, shapeName; SALOME_ListIO ListSelectedObjects; mySel->selectedObjects(ListSelectedObjects, NULL, false ); if (!ListSelectedObjects.IsEmpty()) @@ -2063,12 +2253,7 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt } else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) { // MESSAGE("Attractor" ); -// if ((that->mySMPMap[myEntry].count(QRegExp("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$")) != 1)) { - if ((that->mySMPMap[myEntry].count(QRegExp("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$")) != 1)) { -// if ((that->mySMPMap[myEntry].count('(') != 1) or -// (that->mySMPMap[myEntry].count(')') != 1) or -// (that->mySMPMap[myEntry].count(';') != 4) or -// (that->mySMPMap[myEntry].size() == 15)){ + if ((that->mySMPMap[myEntry].count(QRegExp("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$")) != 1)) { if (displayError) SUIT_MessageBox::warning( dlg(),"Definition of attractor : Error" ,"An attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False[;d])" ); return false; diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index 63d105e..84c402a 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -50,6 +50,7 @@ #include #include +#include "StdMeshersGUI_ObjectReferenceParamWdg.h" #include #include #include @@ -57,6 +58,7 @@ #include #include #include +#include #include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm) class QGroupBox; @@ -75,6 +77,45 @@ class SMESHGUI_SpinBox; class LightApp_SelectionMgr; // class DlgBlSurfHyp_Enforced; +// Name +typedef std::string TEnfName; +// Entry +typedef std::string TEntry; +// List of entries +typedef std::set TEntryList; +// Enforced vertex = 3 coordinates +typedef std::vector TEnfVertexCoords; +// List of enforced vertices +typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList; +// Enforced vertex +struct TEnfVertex{ + TEnfName name; + TEntry geomEntry; + TEnfVertexCoords coords; + TEnfName grpName; +}; + +// TODO remove all TEnfVertexGUICmp + +struct CompareEnfVertices +{ + bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const { + if (e1 && e2) { + if (e1->coords.size() && e2->coords.size()) + return (e1->coords < e2->coords); + else + return (e1->geomEntry < e2->geomEntry); + } + return false; + } +}; + +// List of enforced vertices +typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList; + +// Map Face Entry / List of enforced vertices +typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap; + typedef struct { int myTopology, myVerbosity; @@ -82,16 +123,37 @@ typedef struct double myAngleMeshS, myAngleMeshC, myGradation; double myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax; bool myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex; - std::set > enfVertexList; - std::map > > entryEnfVertexListMap; + TEnfVertexList enfVertexList; + TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap; /* TODO GROUPS - std::map > > groupNameEnfVertexListMap; - std::map , std::string > enfVertexGroupNameMap; + TGroupNameEnfVertexListMap groupNameEnfVertexListMap; */ QString myName; } BlsurfHypothesisData; + +// class BLSURFPluginGUI_ObjectReferenceParamWdg: public StdMeshersGUI_ObjectReferenceParamWdg +// { +// Q_OBJECT +// public: +// BLSURFPluginGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter, +// QWidget* parent, +// bool multiSelection=false); +// BLSURFPluginGUI_ObjectReferenceParamWdg( MeshObjectType objType, +// QWidget* parent, +// bool multiSelection=false); +// ~BLSURFPluginGUI_ObjectReferenceParamWdg(); +// +// private: +// void init(); +// +// public slots: +// void activateSelectionOnly(); +// void deactivateSelectionOnly(); +// void setActivationStatus(bool status); +// }; + /*! * \brief Class for creation of BLSURF hypotheses */ @@ -112,7 +174,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; @@ -130,14 +192,15 @@ protected slots: void onRemoveMap(); void onSetSizeMap(int,int); - /* TODO GROUPS - void addEnforcedVertex(std::string, std::string, double, double, double, std::string); - */ - void addEnforcedVertex(std::string, std::string, double, double, double); + void addEnforcedVertex(std::string theFaceEntry, std::string theFaceName, double x=0, double y=0, double z=0, + std::string vertexName = "", std::string geomEntry = "", std::string groupName = ""); void onAddEnforcedVertices(); void onRemoveEnforcedVertex(); void synchronizeCoords(); - void update(QTreeWidgetItem* , int ); + void updateEnforcedVertexValues(QTreeWidgetItem* , int ); + void onSelectEnforcedVertex(); + void deactivateSelection(QWidget*, QWidget*); + void clearEnforcedVertexWidgets(); private: bool readParamsFromHypo( BlsurfHypothesisData& ) const; @@ -147,6 +210,7 @@ private: bool sizeMapValidationFromRow(int,bool displayError = true); bool sizeMapValidationFromEntry(QString,bool displayError = true); GeomSelectionTools* getGeomSelectionTool(); + GEOM::GEOM_Gen_var getGeomEngine(); private: QWidget* myStdGroup; @@ -178,24 +242,22 @@ private: QPushButton *removeButton; QWidget* myEnfGroup; - /* TODO FACE AND VERTEX SELECTION - QPushButton* selectFaceButton; - QLineEdit* mySelectedFace; -// GEOM::GEOM_Object_var myEnfFace; - QPushButton* selectVertexButton; - QLineEdit* mySelectedEnforcedVertex; -// GEOM::GEOM_Object_var myEnfVertex; - */ +// TODO FACE AND VERTEX SELECTION + StdMeshersGUI_ObjectReferenceParamWdg *myEnfFaceWdg; + GEOM::GEOM_Object_var myEnfFace; + StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg; + GEOM::GEOM_Object_var myEnfVertex; + // DlgBlSurfHyp_Enforced* myEnforcedVertexWidget; QTreeWidget* myEnforcedTreeWidget; SMESHGUI_SpinBox* myXCoord; SMESHGUI_SpinBox* myYCoord; SMESHGUI_SpinBox* myZCoord; - /* TODO GROUPS + QLineEdit* myGroupName; QGroupBox* makeGroupsCheck; QLineEdit* myGlobalGroupName; - */ + QPushButton* addVertexButton; QPushButton* removeVertexButton; @@ -228,7 +290,7 @@ public: void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; - + bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const; }; diff --git a/src/GUI/BLSURFPlugin_msg_en.ts b/src/GUI/BLSURFPlugin_msg_en.ts index 5be52ec..a3e21dd 100644 --- a/src/GUI/BLSURFPlugin_msg_en.ts +++ b/src/GUI/BLSURFPlugin_msg_en.ts @@ -172,8 +172,8 @@ Enforced vertices - BLSURF_ENF_VER_ENTRY_COLUMN - Entry + BLSURF_ENF_VER_FACE_ENTRY_COLUMN + Face Entry BLSURF_ENF_VER_NAME_COLUMN @@ -191,6 +191,10 @@ BLSURF_ENF_VER_Z_COLUMN Z + + BLSURF_ENF_VER_ENTRY_COLUMN + Vertex Entry + BLSURF_ENF_VER_GROUP_COLUMN Group diff --git a/src/GUI/BLSURFPlugin_msg_fr.ts b/src/GUI/BLSURFPlugin_msg_fr.ts index 8ec88de..d509736 100755 --- a/src/GUI/BLSURFPlugin_msg_fr.ts +++ b/src/GUI/BLSURFPlugin_msg_fr.ts @@ -172,8 +172,8 @@ Points de passage - BLSURF_ENF_VER_ENTRY_COLUMN - Entrée + BLSURF_ENF_VER_FACE_ENTRY_COLUMN + ID de face BLSURF_ENF_VER_NAME_COLUMN @@ -191,6 +191,10 @@ BLSURF_ENF_VER_Z_COLUMN Z + + BLSURF_ENF_VER_ENTRY_COLUMN + ID de point + BLSURF_ENF_VER_GROUP_COLUMN Groupe diff --git a/src/GUI/Makefile.am b/src/GUI/Makefile.am index b77c1dd..ea115f0 100644 --- a/src/GUI/Makefile.am +++ b/src/GUI/Makefile.am @@ -64,7 +64,7 @@ libBLSURFPluginGUI_la_LDFLAGS = \ $(QT_LIBS) \ ../BLSURFPlugin/libBLSURFEngine.la \ $(GUI_LDFLAGS) -lqtx -lSalomeApp -lsuit -lSalomeObject -lLightApp \ - ${SMESH_LDFLAGS} -lSMESH -lGeomSelectionTools \ + ${SMESH_LDFLAGS} -lSMESH -lGeomSelectionTools -lStdMeshersGUI \ $(CAS_KERNEL) $(BLSURF_LIBS) # resources files -- 2.39.2