From 7f69c41b372bffc189ccad95099599374fb41205 Mon Sep 17 00:00:00 2001 From: nge Date: Fri, 29 May 2009 14:06:57 +0000 Subject: [PATCH] No more unordered map !! --- idl/BLSURFPlugin_Algorithm.idl | 16 +- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 157 +++++++----------- src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx | 3 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 1 + src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 1 + .../BLSURFPlugin_Hypothesis_i.cxx | 25 +-- .../BLSURFPlugin_Hypothesis_i.hxx | 1 + src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 124 ++++++++------ src/GUI/BLSURFPluginGUI_HypothesisCreator.h | 1 + src/GUI/Makefile.am | 3 - src/PluginUtils/GeomSelectionTools.cxx | 99 ++++++++--- src/PluginUtils/GeomSelectionTools.h | 13 +- 12 files changed, 248 insertions(+), 196 deletions(-) diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index f1be50d..470dffc 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -19,6 +19,7 @@ // --- // File : BLSURFPlugin_Algorithm.idl // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA) +// Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE) // --- // #ifndef _SMESH_BLSURFALGORITHM_IDL_ @@ -170,19 +171,32 @@ module BLSURFPlugin void UnsetEntry(in string entry); + /*! + * Set a SizeMap on geom object + */ void SetSizeMap(in GEOM::GEOM_Object GeomObj, in string sizeMap); void UnsetSizeMap(in GEOM::GEOM_Object GeomObj); + + /*! + * Set a SizeMap on geom object given by entry + */ void SetSizeMapEntry(in string entry, in string sizeMap); string GetSizeMapEntry(in string entry); string_array GetSizeMapEntries(); + /*! + * Set an attractor on geom object + */ void SetAttractor(in GEOM::GEOM_Object GeomObj, in string attractor); void UnsetAttractor(in GEOM::GEOM_Object GeomObj); + + /*! + * Set an attractor on geom object given by entry + */ void SetAttractorEntry(in string entry, in string attractor); string GetAttractorEntry(in string entry); string_array GetAttractorEntries(); - /* void SetCustomSizeMapEntry(in string entry, in string sizeMap); string GetCustomSizeMapEntry(in string entry); diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 078dfb8..ad1dd02 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -20,6 +20,7 @@ // File : BLSURFPlugin_BLSURF.cxx // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA) // & Aurelien ALLEAUME (DISTENE) +// Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE) // --- // #include "BLSURFPlugin_BLSURF.hxx" @@ -42,7 +43,6 @@ #include #include #include -#include #include #include @@ -187,44 +187,10 @@ PyObject * newPyStdOut( std::string& out ) ////////////////////////END PYTHON/////////////////////////// - -//////////////////TO WELL DEFINE UNORDERED TOPODS_MAP//////// - -namespace std { -namespace tr1 { -template<> - struct hash - : public std::unary_function - { - std::size_t operator() (const TopoDS_Face & Face) const - { return Face.HashCode(471662);} - // { return Face.HashCode(std::numeric_limits::max());} -}; - -template<> - struct hash - : public std::unary_function - { - std::size_t operator() (const TopoDS_Edge & Edge) const - { return Edge.HashCode(471662);} - // { return Face.HashCode(std::numeric_limits::max());} -}; - -template<> - struct hash - : public std::unary_function - { - std::size_t operator() (const TopoDS_Vertex & Vertex) const - { return Vertex.HashCode(471662);} - // { return Face.HashCode(std::numeric_limits::max());} -}; -} -} - //////////////////MY MAPS//////////////////////////////////////// -std::tr1::unordered_map Face2SizeMap; -std::tr1::unordered_map Edge2SizeMap; -std::tr1::unordered_map Vertex2SizeMap; +std::map FaceId2SizeMap; +std::map EdgeId2SizeMap; +std::map VertexId2SizeMap; std::map FaceId2PythonSmp; std::map EdgeId2PythonSmp; std::map VertexId2PythonSmp; @@ -267,7 +233,13 @@ BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId, PyRun_SimpleString("from math import *"); PyGILState_Release(gstate); - + + FaceId2SizeMap.clear(); + EdgeId2SizeMap.clear(); + VertexId2SizeMap.clear(); + FaceId2PythonSmp.clear(); + EdgeId2PythonSmp.clear(); + VertexId2PythonSmp.clear(); } //============================================================================= @@ -420,9 +392,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt; for ( opIt = opts.begin(); opIt != opts.end(); ++opIt ) if ( !opIt->second.empty() ) { -#ifdef _DEBUG_ - cout << "blsurf_set_param(): " << opIt->first << " = " << opIt->second << endl; -#endif + MESSAGE("blsurf_set_param(): " << opIt->first << " = " << opIt->second); blsurf_set_param(bls, opIt->first.c_str(), opIt->second.c_str()); } @@ -439,9 +409,6 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu // blsurf_set_param(bls, "hphy_flag", "2"); if ((to_string(_physicalMesh))=="2"){ GeomSelectionTools* GeomST = new GeomSelectionTools::GeomSelectionTools( SMESH::GetActiveStudyDocument()); - Face2SizeMap.clear(); - Edge2SizeMap.clear(); - Vertex2SizeMap.clear(); TopoDS_Shape GeomShape; TopAbs_ShapeEnum GeomType; @@ -451,28 +418,26 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu MESSAGE("Setting a Size Map"); const BLSURFPlugin_Hypothesis::TSizeMap & sizeMaps = hyp->GetSizeMapEntries(); BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt; - + int i=0; for ( smIt = sizeMaps.begin(); smIt != sizeMaps.end(); ++smIt ) { if ( !smIt->second.empty() ) { -#ifdef _DEBUG_ - cout << "blsurf_set_sizeMap(): " << smIt->first << " = " << smIt->second << endl; -#endif + MESSAGE("blsurf_set_sizeMap(): " << smIt->first << " = " << smIt->second); GeomShape = GeomST->entryToShape(smIt->first); GeomType = GeomShape.ShapeType(); if (GeomType == TopAbs_FACE){ HasSizeMapOnFace = true; - Face2SizeMap[TopoDS::Face(GeomShape)] = smIt->second; + FaceId2SizeMap[TopoDS::Face(GeomShape).HashCode(471662)] = smIt->second; } if (GeomType == TopAbs_EDGE){ HasSizeMapOnEdge = true; HasSizeMapOnFace = true; - Edge2SizeMap[TopoDS::Edge(GeomShape)] = smIt->second; + EdgeId2SizeMap[TopoDS::Edge(GeomShape).HashCode(471662)] = smIt->second; } if (GeomType == TopAbs_VERTEX){ HasSizeMapOnVertex = true; HasSizeMapOnEdge = true; HasSizeMapOnFace = true; - Vertex2SizeMap[TopoDS::Vertex(GeomShape)] = smIt->second; + VertexId2SizeMap[TopoDS::Vertex(GeomShape).HashCode(471662)] = smIt->second; } } } @@ -485,9 +450,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt; for ( atIt = attractors.begin(); atIt != attractors.end(); ++atIt ) { if ( !atIt->second.empty() ) { -#ifdef _DEBUG_ - cout << "blsurf_set_attractor(): " << atIt->first << " = " << atIt->second << endl; -#endif + MESSAGE("blsurf_set_attractor(): " << atIt->first << " = " << atIt->second); GeomShape = GeomST->entryToShape(atIt->first); GeomType = GeomShape.ShapeType(); @@ -529,21 +492,21 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu attractorFunction << _smp_phy_size << "-(" << _smp_phy_size <<"-" << a << ")"; attractorFunction << "*exp(-((u-("<second; + EdgeId2SizeMap[TopoDS::Edge(GeomShape).HashCode(471662)] = atIt->second; } if (GeomType == TopAbs_VERTEX){ HasSizeMapOnVertex = true; HasSizeMapOnEdge = true; HasSizeMapOnFace = true; - Vertex2SizeMap[TopoDS::Vertex(GeomShape)] = atIt->second; + VertexId2SizeMap[TopoDS::Vertex(GeomShape).HashCode(471662)] = atIt->second; } */ } @@ -552,16 +515,16 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu // if (HasSizeMapOnFace){ // In all size map cases (hphy_flag = 2), at least map on face must be defined - std::cout << "Setting Size Map on FACES " << std::endl; + MESSAGE("Setting Size Map on FACES "); blsurf_data_set_sizemap_iso_cad_face(bls, size_on_surface, &_smp_phy_size); // } if (HasSizeMapOnEdge){ - std::cout << "Setting Size Map on EDGES " << std::endl; + MESSAGE("Setting Size Map on EDGES "); blsurf_data_set_sizemap_iso_cad_edge(bls, size_on_edge, &_smp_phy_size); } if (HasSizeMapOnVertex){ - std::cout << "Setting Size Map on VERTICES " << std::endl; + MESSAGE("Setting Size Map on VERTICES "); blsurf_data_set_sizemap_iso_cad_point(bls, size_on_vertex, &_smp_phy_size); } } @@ -591,10 +554,10 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) MESSAGE("BLSURFPlugin_BLSURF::Compute"); if (aShape.ShapeType() == TopAbs_COMPOUND) { - cout << " the shape is a COMPOUND" << endl; + MESSAGE(" the shape is a COMPOUND"); } else { - cout << " the shape is UNKNOWN" << endl; + MESSAGE(" the shape is UNKNOWN"); }; context_t *ctx = context_new(); @@ -645,22 +608,23 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) surfaces.push_back(BRep_Tool::Surface(f)); // Get bound values of uv surface //BRep_Tool::Surface(f)->Bounds(u_min,u_max,v_min,v_max); - //std::cout << "BRep_Tool::Surface(f)->Bounds(u_min,u_max,v_min,v_max): " << u_min << ", " << u_max << ", " << v_min << ", " << v_max << std::endl; - if ((HasSizeMapOnFace) && Face2SizeMap.find(f)!=Face2SizeMap.end()){ - cout << "Face2SizeMap[f].find(bad_end): " << Face2SizeMap[f].find(bad_end) << endl; - cout << "Face2SizeMap[f].size(): " << Face2SizeMap[f].size() << endl; - cout << "bad_end.size(): " << bad_end.size() << endl; + //MESSAGE("BRep_Tool::Surface(f)->Bounds(u_min,u_max,v_min,v_max): " << u_min << ", " << u_max << ", " << v_min << ", " << v_max); + + if ((HasSizeMapOnFace) && FaceId2SizeMap.find(f.HashCode(471662))!=FaceId2SizeMap.end()){ + MESSAGE("FaceId2SizeMap[f.HashCode(471662)].find(bad_end): " << FaceId2SizeMap[f.HashCode(471662)].find(bad_end)); + MESSAGE("FaceId2SizeMap[f.HashCode(471662)].size(): " << FaceId2SizeMap[f.HashCode(471662)].size()); + MESSAGE("bad_end.size(): " << bad_end.size()); // check if function ends with "return" - if (Face2SizeMap[f].find(bad_end) == (Face2SizeMap[f].size()-bad_end.size()-1)) + if (FaceId2SizeMap[f.HashCode(471662)].find(bad_end) == (FaceId2SizeMap[f.HashCode(471662)].size()-bad_end.size()-1)) continue; // Expr To Python function, verification is performed at validation in GUI PyObject * obj = NULL; - obj= PyRun_String(Face2SizeMap[f].c_str(), Py_file_input, main_dict, NULL); + obj= PyRun_String(FaceId2SizeMap[f.HashCode(471662)].c_str(), Py_file_input, main_dict, NULL); Py_DECREF(obj); PyObject * func = NULL; func = PyObject_GetAttrString(main_mod, "f"); FaceId2PythonSmp[iface]=func; - Face2SizeMap.erase(f); + FaceId2SizeMap.erase(f.HashCode(471662)); } cad_face_t *fce = cad_face_new(c, iface, surf_fun, surfaces.back()); cad_face_set_tag(fce, iface); @@ -678,17 +642,17 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) double tmin,tmax; curves.push_back(BRep_Tool::CurveOnSurface(e, f, tmin, tmax)); - if ((HasSizeMapOnEdge) && Edge2SizeMap.find(e)!=Edge2SizeMap.end()){ - if (Edge2SizeMap[e].find(bad_end) == (Edge2SizeMap[e].size()-bad_end.size()-1)) + if ((HasSizeMapOnEdge) && EdgeId2SizeMap.find(e.HashCode(471662))!=EdgeId2SizeMap.end()){ + if (EdgeId2SizeMap[e.HashCode(471662)].find(bad_end) == (EdgeId2SizeMap[e.HashCode(471662)].size()-bad_end.size()-1)) continue; // Expr To Python function, verification is performed at validation in GUI PyObject * obj = NULL; - obj= PyRun_String(Edge2SizeMap[e].c_str(), Py_file_input, main_dict, NULL); + obj= PyRun_String(EdgeId2SizeMap[e.HashCode(471662)].c_str(), Py_file_input, main_dict, NULL); Py_DECREF(obj); PyObject * func = NULL; func = PyObject_GetAttrString(main_mod, "f"); EdgeId2PythonSmp[ic]=func; - Edge2SizeMap.erase(e); + EdgeId2SizeMap.erase(e.HashCode(471662)); } cad_edge_t *edg = cad_edge_new(fce, ic, tmin, tmax, curv_fun, curves.back()); cad_edge_set_tag(edg, ic); @@ -714,22 +678,22 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) *ip = pmap.FindIndex(v); if(*ip <= 0) *ip = pmap.Add(v); - if ((HasSizeMapOnVertex) && Vertex2SizeMap.find(v)!=Vertex2SizeMap.end()){ - if (Vertex2SizeMap[v].find(bad_end) == (Vertex2SizeMap[v].size()-bad_end.size()-1)) + if ((HasSizeMapOnVertex) && VertexId2SizeMap.find(v.HashCode(471662))!=VertexId2SizeMap.end()){ + if (VertexId2SizeMap[v.HashCode(471662)].find(bad_end) == (VertexId2SizeMap[v.HashCode(471662)].size()-bad_end.size()-1)) continue; // Expr To Python function, verification is performed at validation in GUI PyObject * obj = NULL; - obj= PyRun_String(Vertex2SizeMap[v].c_str(), Py_file_input, main_dict, NULL); + obj= PyRun_String(VertexId2SizeMap[v.HashCode(471662)].c_str(), Py_file_input, main_dict, NULL); Py_DECREF(obj); PyObject * func = NULL; func = PyObject_GetAttrString(main_mod, "f"); VertexId2PythonSmp[*ip]=func; - Vertex2SizeMap.erase(v); + VertexId2SizeMap.erase(v.HashCode(471662)); } } if (npts != 2) { // should not happen - cout << "An edge does not have 2 extremities." << endl; + MESSAGE("An edge does not have 2 extremities."); } else { if (d1 < d2) cad_edge_set_extremities(edg, ip1, ip2); @@ -744,9 +708,9 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) blsurf_data_set_cad(bls, c); - cout << endl; - cout << "Beginning of Surface Mesh generation" << endl; - cout << endl; + std::cout << std::endl; + std::cout << "Beginning of Surface Mesh generation" << std::endl; + std::cout << std::endl; // Issue 0019864. On DebianSarge, FE signals do not obey to OSD::SetSignal(false) #ifndef WNT @@ -784,14 +748,9 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) return error(_comment); } - cout << endl; - cout << "End of Surface Mesh generation" << endl; - cout << endl; - - cout << "****************** U MIN: " << my_u_min << endl; - cout << "****************** V MIN: " << my_v_min << endl; - cout << "****************** U MAX: " << my_u_max << endl; - cout << "****************** V MAX: " << my_v_max << endl; + std::cout << std::endl; + std::cout << "End of Surface Mesh generation" << std::endl; + std::cout << std::endl; mesh_t *msh; blsurf_data_get_mesh(bls, &msh); @@ -1019,19 +978,15 @@ status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data) if (face_id == 1) { if (my_u_min > uv[0]) { my_u_min = uv[0]; -// cout << "****************** FACE ID / U MIN: " << face_id << " / " << my_u_min << endl; } if (my_v_min > uv[1]) { my_v_min = uv[1]; -// cout << "****************** FACE ID / V MIN: " << face_id << " / " << my_v_min << endl; } if (my_u_max < uv[0]) { my_u_max = uv[0]; -// cout << "****************** FACE ID / U MAX: " << face_id << " / " << my_u_max << endl; } if (my_v_max < uv[1]) { my_v_max = uv[1]; -// cout << "****************** FACE ID / V MAX: " << face_id << " / " << my_v_max << endl; } } @@ -1051,7 +1006,7 @@ status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data) PyErr_Print(); PySys_SetObject("stderr", PySys_GetObject("__stderr__")); Py_DECREF(new_stderr); - std::cout << "Can't evaluate f(" << uv[0] << "," << uv[1] << ")" << " error is " << err_description << std::endl; + MESSAGE("Can't evaluate f(" << uv[0] << "," << uv[1] << ")" << " error is " << err_description); result = *((double*)user_data); } else { @@ -1059,7 +1014,7 @@ status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data) Py_DECREF(pyresult); } *size = result; - //std::cout << "f(" << uv[0] << "," << uv[1] << ")" << " = " << result << std::endl; + //MESSAGE("f(" << uv[0] << "," << uv[1] << ")" << " = " << result); PyGILState_Release(gstate); } else { @@ -1086,7 +1041,7 @@ status_t size_on_edge(integer edge_id, real t, real *size, void *user_data) PyErr_Print(); PySys_SetObject("stderr", PySys_GetObject("__stderr__")); Py_DECREF(new_stderr); - std::cout << "Can't evaluate f(" << t << ")" << " error is " << err_description << std::endl; + MESSAGE("Can't evaluate f(" << t << ")" << " error is " << err_description); result = *((double*)user_data); } else { @@ -1120,7 +1075,7 @@ status_t size_on_vertex(integer point_id, real *size, void *user_data) PyErr_Print(); PySys_SetObject("stderr", PySys_GetObject("__stderr__")); Py_DECREF(new_stderr); - std::cout << "Can't evaluate f()" << " error is " << err_description << std::endl; + MESSAGE("Can't evaluate f()" << " error is " << err_description); result = *((double*)user_data); } else { @@ -1153,7 +1108,7 @@ status_t message_callback(message_t *msg, void *user_data) error->append( desc, len ); } else { - cout << desc; + std::cout << desc << std::endl; } return STATUS_OK; } diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index 67eb80f..8f442fb 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -20,6 +20,7 @@ // File : BLSURFPlugin_BLSURF.hxx // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA) // & Aurelien ALLEAUME (DISTENE) +// Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE) // --- // #ifndef _BLSURFPlugin_BLSURF_HXX_ @@ -60,7 +61,7 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { private: PyObject * main_mod; PyObject * main_dict; - + }; #endif diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 221e48e..e3120bd 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -20,6 +20,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) // --- // #include diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 1898545..de5af16 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -20,6 +20,7 @@ // File : BLSURFPlugin_Hypothesis.hxx // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA) // & Aurelien ALLEAUME (DISTENE) +// Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE) // --- // #ifndef _BLSURFPlugin_Hypothesis_HXX_ diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 6046d23..815ea9d 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -19,6 +19,7 @@ // --- // File : BLSURFPlugin_Hypothesis.cxx // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA) +// Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE) // --- // #include "BLSURFPlugin_Hypothesis_i.hxx" @@ -514,7 +515,7 @@ void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* si throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - std::cout << "ENGINE : SETSIZEMAP START ENTRY : " << entry << std::endl; + MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry); bool valueChanged = false; try { valueChanged = ( this->GetImpl()->GetSizeMapEntry(entry) != sizeMap ); @@ -532,7 +533,7 @@ void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* si catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - std::cout << "ENGINE : SETSIZEMAP END ENTRY : " << entry << std::endl; + MESSAGE("ENGINE : SETSIZEMAP END ENTRY : " << entry); if ( valueChanged ) SMESH::TPythonDump() << _this() << ".SetSizeMap(" << entry << ", '" << sizeMap << "' )"; @@ -544,7 +545,7 @@ void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - std::cout << "ENGINE : SETATTRACTOR START ENTRY : " << entry << std::endl; + MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry); bool valueChanged = false; try { valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor ); @@ -562,7 +563,7 @@ void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } - std::cout << "ENGINE : SETATTRACTOR END ENTRY : " << entry << std::endl; + MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry); if ( valueChanged ) SMESH::TPythonDump() << _this() << ".SetAttractor(" << entry << ", '" << attractor << "' )"; @@ -706,8 +707,8 @@ void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj,c ASSERT(myBaseImpl); string entry; entry=GeomObj->GetStudyEntry(); - std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl; - std::cout << "IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")" << std::endl; + MESSAGE("IDL : GetName : " << GeomObj->GetName()); + MESSAGE("IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")"); SetSizeMapEntry( entry.c_str(),sizeMap); } @@ -717,8 +718,8 @@ void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj ASSERT(myBaseImpl); string entry; entry=GeomObj->GetStudyEntry(); - std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl; - std::cout << "IDL : UNSETSIZEMAP ( "<< entry << ")" << std::endl; + MESSAGE("IDL : GetName : " << GeomObj->GetName()); + MESSAGE("IDL : UNSETSIZEMAP ( "<< entry << ")"); UnsetEntry( entry.c_str()); SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )"; } @@ -729,8 +730,8 @@ void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, cons ASSERT(myBaseImpl); string entry; entry=GeomObj->GetStudyEntry(); - std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl; - std::cout << "IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")" << std::endl; + MESSAGE("IDL : GetName : " << GeomObj->GetName()); + MESSAGE("IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")"); SetAttractorEntry( entry.c_str(),attractor); } @@ -739,8 +740,8 @@ void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj) ASSERT(myBaseImpl); string entry; entry=GeomObj->GetStudyEntry(); - std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl; - std::cout << "IDL : UNSETATTRACTOR ( "<< entry << ")" << std::endl; + MESSAGE("IDL : GetName : " << GeomObj->GetName()); + MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")"); UnsetEntry( entry.c_str()); SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )"; } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index c0af1f4..eef9617 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -19,6 +19,7 @@ // --- // File : BLSURFPlugin_Hypothesis.hxx // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA) +// Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE) // --- // #ifndef _BLSURFPlugin_Hypothesis_i_HXX_ diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 0a4a8bb..ab94476 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -110,6 +110,10 @@ enum { SMP_REMOVE_BTN, }; +/************************************************** + Begin initialization Python structures and objects +***************************************************/ + typedef struct { PyObject_HEAD int softspace; @@ -208,22 +212,29 @@ PyObject * newPyStdOut( std::string& out ) return (PyObject*)self; } - +/************************************************* +End initialization Python structures and objects +**************************************************/ + +/** + * \brief {BLSURFPluginGUI_HypothesisCreator constructor} + * @param theHypType Name of the hypothesis type (here BLSURF_Parameters) + * + * */ BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType ) : SMESHGUI_GenericHypothesisCreator( theHypType ) { - cout << "BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator" << endl; + MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator"); this->mySMPMap.clear(); - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - GeomToolSelected = new GeomSelectionTools(aStudy); + GeomToolSelected = NULL; + GeomToolSelected = getGeomSelectionTool(); aSel = GeomToolSelected->selectionMgr(); /* Initialize the Python interpreter */ - //assert(Py_IsInitialized()); if (not Py_IsInitialized()) - throw ("Erreur: Python interpreter is not initialized"); + throw ("Error: Python interpreter is not initialized"); PyGILState_STATE gstate; gstate = PyGILState_Ensure(); @@ -242,14 +253,20 @@ BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator() { } +/** + * \brief {Get or create the geom selection tool for active study} + * */ GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() { + MESSAGE("BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool"); BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - if (that->GeomToolSelected == NULL) { - cout << "GeomToolSelected is created" << endl; - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + if (that->GeomToolSelected == NULL or that->GeomToolSelected->getMyStudy() != aStudy) { + MESSAGE("GeomToolSelected is created"); that->GeomToolSelected = new GeomSelectionTools(aStudy); } + else + MESSAGE("GeomToolSelected already exists"); return that->GeomToolSelected; } @@ -265,9 +282,10 @@ namespace { } } + bool BLSURFPluginGUI_HypothesisCreator::checkParams() const { - cout << "BLSURFPluginGUI_HypothesisCreator::checkParams" << endl; + MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams"); bool ok = true; if ( !isDouble( myPhySize->text(), false )) { if ( myPhySize->text().isEmpty() ) @@ -362,7 +380,7 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() { - cout << "BLSURFPluginGUI_HypothesisCreator::buildFrame" << endl; + MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame"); QFrame* fr = new QFrame( 0 ); QVBoxLayout* lay = new QVBoxLayout( fr ); lay->setMargin( 5 ); @@ -562,7 +580,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const { - cout << "BLSURFPluginGUI_HypothesisCreator::retrieveParams" << endl; + MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams"); BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; BlsurfHypothesisData data; @@ -614,10 +632,11 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const printf("retrieveParams():that->mySMPMap.size()=%d\n",that->mySMPMap.size()); QMapIterator i(that->mySMPMap); + GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool(); while (i.hasNext()) { i.next(); const QString entry = i.key(); - string shapeName = GeomToolSelected->getNameFromEntry(entry.toStdString()); + string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString()); const QString sizeMap = i.value(); int row = mySizeMapTable->rowCount(); mySizeMapTable->setRowCount( row+1 ); @@ -647,13 +666,12 @@ QString BLSURFPluginGUI_HypothesisCreator::storeParams() const QString guiHyp = that->readParamsFromWidgets( data ); that->storeParamsToHypo( data ); - //cout<<"BLSURFPluginGUI_HypothesisCreator::storeParams(), guiHyp: "<GetSizeMapEntries(); - cout << "mySizeMaps->length() = " << mySizeMaps->length() << endl; - + MESSAGE("mySizeMaps->length() = " << mySizeMaps->length()); + QString fullSizeMaps; + QStringList fullSizeMapList; + GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool(); for ( int i = 0;ilength(); ++i ) { - QString fullSizeMaps = mySizeMaps[i].in(); - QStringList fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts ); + fullSizeMaps = mySizeMaps[i].in(); + MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString()); + fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts ); if ( fullSizeMapList.count() > 1 ) { string fullSizeMap = fullSizeMapList[1].toStdString(); int pos = fullSizeMap.find("return")+7; QString sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos)); that->mySMPMap[fullSizeMapList[0]] = sizeMap; - that->mySMPShapeTypeMap[fullSizeMapList[0]] = GeomToolSelected->entryToShape(fullSizeMapList[0].toStdString()).ShapeType(); MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString()); + that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShape(fullSizeMapList[0].toStdString()).ShapeType(); MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]); } } @@ -709,7 +730,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData // custom size maps /* BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries(); - cout << "myCustomSizeMaps->length() = " << myCustomSizeMaps->length() << endl; + MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length()); for ( int i = 0;ilength(); ++i ) { QString fullCustomSizeMaps = myCustomSizeMaps[i].in(); @@ -724,14 +745,14 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData */ // attractor BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries(); - cout << "myAttractors->length() = " << allMyAttractors->length() << endl; + MESSAGE("myAttractors->length() = " << allMyAttractors->length()); for ( int i = 0;ilength(); ++i ) { QString myAttractors = allMyAttractors[i].in(); QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts ); if ( myAttractorList.count() > 1 ) { that->mySMPMap[myAttractorList[0]] = myAttractorList[1]; - that->mySMPShapeTypeMap[myAttractorList[0]] = GeomToolSelected->entryToShape(myAttractorList[0].toStdString()).ShapeType(); + that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShape(myAttractorList[0].toStdString()).ShapeType(); MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString()); MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]); } @@ -742,7 +763,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const { - cout << "BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo" << endl; + MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo"); BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() ); @@ -807,23 +828,16 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi const QString entry = i.key(); const QString sizeMap = i.value(); -/* - if (not that->sizeMapValidationFromEntry(entry,false)) { - cout << "Size map for entry " << entry.toStdString() << " is not valid" << endl; - ok = false; - continue; - } -*/ if (sizeMap == "__TO_DELETE__") { - cout << "Delete entry " << entry.toStdString() << " from engine" << endl; + MESSAGE("Delete entry " << entry.toStdString() << " from engine"); h->UnsetEntry(entry.toLatin1().constData()); } else if (sizeMap.startsWith("ATTRACTOR")) { - cout << "SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString() << endl; + MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString()); h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() ); } else if (sizeMap.startsWith("def")) { - cout << "SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString() << endl; + MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString()); // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() ); } else { @@ -836,7 +850,7 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX) fullSizeMap = QString("def f(): return ") + sizeMap; - cout << "SetSizeMapEntry("<text() : ""; h_data.myTopology = myTopology->currentIndex(); h_data.myPhysicalMesh = myPhysicalMesh->currentIndex(); @@ -912,13 +926,13 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes guiHyp += entry + " = " + that->mySMPMap[entry] + "; "; } - cout << "guiHyp : " << guiHyp.toLatin1().data() << endl; + MESSAGE("guiHyp : " << guiHyp.toLatin1().data()); return guiHyp; } void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() { - cout << "BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged" << endl; + MESSAGE("BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged"); bool isCustom = ((myPhysicalMesh->currentIndex() == PhysicalUserDefined) || (myPhysicalMesh->currentIndex() == SizeMap)) ; myPhySize->setEnabled(isCustom); myPhyMax->setEnabled(isCustom); @@ -945,7 +959,7 @@ void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() { } void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() { - cout << "BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged" << endl; + MESSAGE("BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged"); bool isCustom = (myGeometricMesh->currentIndex() == UserDefined); myAngleMeshS->setEnabled(isCustom); myAngleMeshC->setEnabled(isCustom); @@ -1055,7 +1069,7 @@ void BLSURFPluginGUI_HypothesisCreator::onDeleteOption() void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() { - cout<<"BLSURFPluginGUI_HypothesisCreator::onRemoveMap()"< selectedRows; QList selected = mySizeMapTable->selectedItems(); QTableWidgetItem* item; @@ -1073,7 +1087,6 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() it.toBack(); while ( it.hasPrevious() ) { row = it.previous(); - cout << "delete row #"<< row <item(row,SMP_ENTRY_COLUMN)->text(); if (that->mySMPMap.contains(entry)) that->mySMPMap[entry] = "__TO_DELETE__"; @@ -1087,12 +1100,12 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col) { - cout<<"BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< row << "," << col << ")"<mySizeMapTable->item(row, SMP_ENTRY_COLUMN)->text(); QString sizeMap = that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->text().trimmed(); - cout << "entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString() << endl; + MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString()); if (not that->mySMPShapeTypeMap.contains(entry)) return; if (that->mySMPMap.contains(entry)) @@ -1108,7 +1121,7 @@ void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col) } } else { - cout << "Size map empty: reverse to precedent value" << endl; + MESSAGE("Size map empty: reverse to precedent value" ); that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setText(that->mySMPMap[entry]); } that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setBackground(QBrush(*bgColor)); @@ -1136,7 +1149,7 @@ void BLSURFPluginGUI_HypothesisCreator::onAddMapOnPoint() void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeShapeAsked) { - cout<<"BLSURFPluginGUI_HypothesisCreator::insertElementType()"<getEntryOfObject(anObject); + entry = myGeomToolSelected->getEntryOfObject(anObject); shapeName = anObject->getName(); - S = GeomToolSelected->entryToShape(entry); + S = myGeomToolSelected->entryToShape(entry); if ((! S.IsNull()) && (S.ShapeType() == typeShapeAsked)) { mySizeMapTable->setFocus(); @@ -1200,7 +1214,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation() { - cout<<"BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()"<rowCount(); for ( ; row < nbRows; ++row ) if (not sizeMapValidationFromRow(row)) @@ -1210,7 +1224,7 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation() bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError) { - cout<<"BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow()"<item( myRow, SMP_ENTRY_COLUMN )->text(); bool res = sizeMapValidationFromEntry(myEntry,displayError); mySizeMapTable->setFocus(); @@ -1219,27 +1233,27 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError) { - cout<<"BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()"<mySMPMap.contains(myEntry)) { - cout<<"Geometry with entry "<mySMPShapeTypeMap.contains(myEntry)) { - cout<<"Shape type with entry "<mySMPMap[myEntry].startsWith("def")) { - cout << "custom function" << endl; + MESSAGE("custom function" ); expr = that->mySMPMap[myEntry].toStdString(); } else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) { - cout << "Attractor" << endl; + MESSAGE("Attractor" ); // if ((that->mySMPMap[myEntry].count(QRegExp("ATTRACTOR([0-9])")) != 1)) if ((that->mySMPMap[myEntry].count('(') != 1) or (that->mySMPMap[myEntry].count(')') != 1) or @@ -1309,7 +1323,7 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt PyGILState_Release(gstate); - cout<<"SizeMap expression "< #include #include -#include + +/*! + * Constructor + * @param aStudy pointer to the Study + * + */ GeomSelectionTools::GeomSelectionTools(_PTR(Study) aStudy) { myStudy = aStudy; } - +/*! + * Accessor to the Study used by this GeomSelectionTools object + * @return The study used by the GeomSelectionTools class + */ +_PTR(Study) GeomSelectionTools::getMyStudy() +{ + return myStudy; +} +/*! + * Allows to get the selection manager from LightApp + * @return A LightApp_SelectionMgr Pointer or 0 if it can't get it. + */ LightApp_SelectionMgr* GeomSelectionTools::selectionMgr() { SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); @@ -57,7 +73,11 @@ LightApp_SelectionMgr* GeomSelectionTools::selectionMgr() else return 0; } - + +/*! + * Return the list of the selected Salome Interactive Object (SALOME_ListIO*) + * @return the list of the selected Salome Interactive Object + */ SALOME_ListIO* GeomSelectionTools::getSelectedSalomeObjects() { SALOME_ListIO* selected; @@ -66,7 +86,10 @@ SALOME_ListIO* GeomSelectionTools::getSelectedSalomeObjects() return selected; } - +/*! + * Return the first selected Salome Interactive Object (Handle(Salome_InteractiveObject)) + * @return the first selected Salome Interactive Object + */ Handle(SALOME_InteractiveObject) GeomSelectionTools::getFirstSelectedSalomeObject() { SALOME_ListIO selected; @@ -81,6 +104,10 @@ Handle(SALOME_InteractiveObject) GeomSelectionTools::getFirstSelectedSalomeObjec return NULL; } +/*! + * Return the entry of the first selected Object + * @return the entry of the first selected Object + */ std::string GeomSelectionTools::getFirstSelectedEntry() { Handle(SALOME_InteractiveObject) anIO; @@ -89,6 +116,11 @@ std::string GeomSelectionTools::getFirstSelectedEntry() return GeomSelectionTools::getEntryOfObject(anIO); } +/*! + * Return the entry of a Salome Interactive Object + * @param anIO the Handle of the Salome Interactive Object + * @return the entry of the Salome Interactive Object + */ std::string GeomSelectionTools::getEntryOfObject(Handle(SALOME_InteractiveObject) anIO){ std::string entry=""; _PTR(SObject) aSO = myStudy->FindObjectID(anIO->getEntry()); @@ -104,7 +136,11 @@ std::string GeomSelectionTools::getEntryOfObject(Handle(SALOME_InteractiveObject return entry; } - +/*! + * Retrieve the name from the entry of the object + * @param entry the entry of the object + * @return the name of the object + */ std::string GeomSelectionTools::getNameFromEntry(std::string entry){ std::string name = ""; _PTR(SObject) aSO = myStudy->FindObjectID(entry); @@ -120,6 +156,11 @@ std::string GeomSelectionTools::getNameFromEntry(std::string entry){ return name; } + +/*! + * Retrieve the component type of the first selected object, it manages successfully references. + * @return the component type of the first selected object + */ std::string GeomSelectionTools::getFirstSelectedComponentDataType() { Handle(SALOME_InteractiveObject) anIO; @@ -138,6 +179,10 @@ std::string GeomSelectionTools::getFirstSelectedComponentDataType() return DataType; } +/*! + * Retrieve the TopoDS shape from the first selected object + * @return the TopoDS shape from the first selected object, empty TopoDS Shape if a shape is not selected. + */ TopoDS_Shape GeomSelectionTools::getFirstSelectedTopoDSShape() { Handle(SALOME_InteractiveObject) anIO; @@ -145,6 +190,10 @@ TopoDS_Shape GeomSelectionTools::getFirstSelectedTopoDSShape() return entryToShape(anIO->getEntry()); } +/*! + * Retrieve the TopoDS shape from the entry + * @return the TopoDS shape from the entry, empty TopoDS Shape if the entry does not define a shape. + */ TopoDS_Shape GeomSelectionTools::entryToShape(std::string entry){ TopoDS_Shape S = TopoDS_Shape(); _PTR(SObject) aSO = myStudy->FindObjectID(entry); @@ -169,20 +218,35 @@ TopoDS_Shape GeomSelectionTools::entryToShape(std::string entry){ return S; } +/*! + * Gives the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape. + * @return the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape. + */ TopAbs_ShapeEnum GeomSelectionTools:: getFirstSelectedShapeType() { TopoDS_Shape S=getFirstSelectedTopoDSShape(); if (!S.IsNull()) return S.ShapeType(); else - // FIXME : Gérer l'exception de manière correct si la shape est nulle return TopAbs_SHAPE; - } -void GeomSelectionTools::getFaceInformation() +/*! + * Print information to std output of the face (if the first selected object is a face) + * and return the OCC type of face: Plane, Cylinder,Cone, Sphere, Torus, BezierSurface,BSplineSurface, SurfaceOfRevolution,SurfaceOfExtrusion, OtherSurface + * @return the OCC type of face: Plane, Cylinder,Cone, Sphere, Torus, BezierSurface,BSplineSurface, SurfaceOfRevolution,SurfaceOfExtrusion, OtherSurface + * return Other_Surface if the selected face is not a face. + * Information printed is : + * U and V degrees + * U and V number of poles + * U and V number of knots + * U or V is Rational ? + * + */ +GeomAbs_SurfaceType GeomSelectionTools::getFaceInformation() { TopoDS_Shape S=getFirstSelectedTopoDSShape(); + GeomAbs_SurfaceType surf_type=GeomAbs_OtherSurface ; if (!S.IsNull() && S.ShapeType()==TopAbs_FACE){ TopoDS_Face f=TopoDS::Face(S); Handle(Geom_Surface) surf = BRep_Tool::Surface(f); @@ -195,24 +259,15 @@ void GeomSelectionTools::getFaceInformation() buffer << "Degre U : " << surf_adap.UDegree(); //conversion nécessaire pour affichage cout << buffer.str() << endl; -/* cout << " Degre V : " << surf_adap.VDegree() << endl; + cout << " Degre V : " << surf_adap.VDegree() << endl; cout << " Nb Poles U : " << surf_adap.NbUPoles() << endl; cout << " Nb Poles V : " << surf_adap.NbVPoles() << endl; cout << " Nb Noeuds U : " << surf_adap.NbUKnots() << endl; cout << " Nb Noeuds V : " << surf_adap.NbVKnots() << endl; cout << " U Rationnel ? " << surf_adap.IsURational() << endl; - cout << " V Rationnel ? " << surf_adap.IsVRational() << endl; */ - - GeomAbs_SurfaceType surf_type=surf_adap.GetType(); - /* - Returns the type of the surface : Plane, Cylinder, - Cone, Sphere, Torus, BezierSurface, - BSplineSurface, SurfaceOfRevolution, - SurfaceOfExtrusion, OtherSurface - */ - - - + cout << " V Rationnel ? " << surf_adap.IsVRational() << endl; + + surf_type=surf_adap.GetType(); } - return; + return surf_type; } diff --git a/src/PluginUtils/GeomSelectionTools.h b/src/PluginUtils/GeomSelectionTools.h index 1196571..7b491fb 100644 --- a/src/PluginUtils/GeomSelectionTools.h +++ b/src/PluginUtils/GeomSelectionTools.h @@ -27,9 +27,19 @@ #include #include +#include class LightApp_SelectionMgr; + +/*! + * The GeomSelectionTools class gives high level tools to select Geom (and other objects) + * A specific attention has been given to analyze selected GEOM objects. + * + * @param myStudy This class is specific to the study ! + * + */ + class GeomSelectionTools { @@ -50,7 +60,8 @@ public: TopoDS_Shape getFirstSelectedTopoDSShape(); TopAbs_ShapeEnum getFirstSelectedShapeType(); TopoDS_Shape entryToShape(std::string ); - void getFaceInformation(); + GeomAbs_SurfaceType getFaceInformation(); + _PTR(Study) getMyStudy(); }; -- 2.39.2