From 1ce46b9787f3d66d906b7d3e10b51baa3d5c3d84 Mon Sep 17 00:00:00 2001 From: nge Date: Thu, 16 Jul 2009 12:31:04 +0000 Subject: [PATCH] Manual Merge from V5_1_main 16July09 --- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 253 +++++++++++++++--- src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx | 15 +- src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.cxx | 8 +- src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.hxx | 4 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 2 +- src/BLSURFPlugin/Makefile.am | 6 +- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 120 +++++---- src/Makefile.am | 4 +- src/PluginUtils/GeomSelectionTools.cxx | 123 +++++---- src/PluginUtils/GeomSelectionTools.h | 15 +- src/PluginUtils/Makefile.am | 6 - src/PluginUtils/PluginUtils.h | 28 -- src/PluginUtils/SizeMapPython.cxx | 0 src/PluginUtils/SizeMapPython.h | 1 - 14 files changed, 383 insertions(+), 202 deletions(-) delete mode 100644 src/PluginUtils/PluginUtils.h delete mode 100644 src/PluginUtils/SizeMapPython.cxx delete mode 100644 src/PluginUtils/SizeMapPython.h diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index ad1dd02..a6036a3 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -70,13 +69,14 @@ extern "C"{ #include #include #include +#include +#include +#include #ifndef WNT #include #endif -#include - #include #include #include @@ -202,7 +202,7 @@ bool HasSizeMapOnVertex=false; //============================================================================= /*! - * + * */ //============================================================================= @@ -219,6 +219,15 @@ BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId, _onlyUnaryInput = false; _hypothesis = NULL; + smeshGen_i = SMESH_Gen_i::GetSMESHGen(); + CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject); + + MESSAGE("studyid = " << _studyId); + + myStudy = NULL; + myStudy = aStudyMgr->GetStudyByID(_studyId); + MESSAGE("myStudy->StudyId() = " << myStudy->StudyId()); /* Initialize the Python interpreter */ assert(Py_IsInitialized()); @@ -233,7 +242,7 @@ BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId, PyRun_SimpleString("from math import *"); PyGILState_Release(gstate); - + FaceId2SizeMap.clear(); EdgeId2SizeMap.clear(); VertexId2SizeMap.clear(); @@ -244,7 +253,7 @@ BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId, //============================================================================= /*! - * + * */ //============================================================================= @@ -256,7 +265,7 @@ BLSURFPlugin_BLSURF::~BLSURFPlugin_BLSURF() //============================================================================= /*! - * + * */ //============================================================================= @@ -322,7 +331,7 @@ inline std::string to_string(int i) double _smp_phy_size; status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data); -status_t size_on_edge(integer edge_id, real t, real *size, void *user_data); +status_t size_on_edge(integer edge_id, real t, real *size, void *user_data); status_t size_on_vertex(integer vertex_id, real *size, void *user_data); double my_u_min=1e6,my_v_min=1e6,my_u_max=-1e6,my_v_max=-1e6; @@ -351,6 +360,39 @@ double getT(const TopoDS_Edge& edge, const gp_XYZ& point) throw; return projector.LowerDistanceParameter(); } + +///////////////////////////////////////////////////////// +TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry) +{ + MESSAGE("BLSURFPlugin_BLSURF::entryToShape"<FindObjectID(entry.c_str()); + SALOMEDS::GenericAttribute_var anAttr; + if (!aSO->_is_nil()){ + SALOMEDS::SObject_var aRefSObj; + GEOM::GEOM_Object_var aShape; + SALOMEDS::AttributeIOR_var myAttribute; + CORBA::String_var myAttrValue; + CORBA::Object_var myCorbaObj; + // If selected object is a reference + if ( aSO->ReferencedObject( aRefSObj )) + aSO = aRefSObj; + SALOMEDS::SComponent_var myFatherCpnt = aSO->GetFatherComponent(); + CORBA::String_var myFatherCpntDataType = myFatherCpnt->ComponentDataType(); + if ( strcmp(myFatherCpntDataType,"GEOM")==0) { + MESSAGE("aSO father component is GEOM"); + if (!aSO->FindAttribute(anAttr, "AttributeIOR")) return S; + myAttribute=SALOMEDS::AttributeIOR::_narrow(anAttr); + myAttrValue=myAttribute->Value(); + MESSAGE("aSO IOR: "<< myAttrValue); + myCorbaObj=smeshGen_i->GetORB()->string_to_object(myAttrValue); + aShape = GEOM::GEOM_Object::_narrow(myCorbaObj); + } + if ( !aShape->_is_nil() ) + S=smeshGen_i->GeomObjectToShape( aShape.in() ); + } + return S; +} ///////////////////////////////////////////////////////// void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_session_t *bls) @@ -365,7 +407,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu bool _quadAllowed = BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed(); bool _decimesh = BLSURFPlugin_Hypothesis::GetDefaultDecimesh(); int _verb = BLSURFPlugin_Hypothesis::GetDefaultVerbosity(); - + if (hyp) { MESSAGE("BLSURFPlugin_BLSURF::SetParameters"); _topology = (int) hyp->GetTopology(); @@ -408,7 +450,6 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu blsurf_set_param(bls, "hphy_flag", to_string(_physicalMesh).c_str()); // blsurf_set_param(bls, "hphy_flag", "2"); if ((to_string(_physicalMesh))=="2"){ - GeomSelectionTools* GeomST = new GeomSelectionTools::GeomSelectionTools( SMESH::GetActiveStudyDocument()); TopoDS_Shape GeomShape; TopAbs_ShapeEnum GeomType; @@ -418,11 +459,10 @@ 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() ) { MESSAGE("blsurf_set_sizeMap(): " << smIt->first << " = " << smIt->second); - GeomShape = GeomST->entryToShape(smIt->first); + GeomShape = entryToShape(smIt->first); GeomType = GeomShape.ShapeType(); if (GeomType == TopAbs_FACE){ HasSizeMapOnFace = true; @@ -451,7 +491,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu for ( atIt = attractors.begin(); atIt != attractors.end(); ++atIt ) { if ( !atIt->second.empty() ) { MESSAGE("blsurf_set_attractor(): " << atIt->first << " = " << atIt->second); - GeomShape = GeomST->entryToShape(atIt->first); + GeomShape = entryToShape(atIt->first); GeomType = GeomShape.ShapeType(); if (GeomType == TopAbs_FACE){ @@ -481,7 +521,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu pos1 = pos2; pos2 = atIt->second.find(")"); b = atof(atIt->second.substr(pos1+1, pos2-pos1-1).c_str()); - + // Get the (u,v) values of the attractor on the face gp_XY uvPoint = getUV(TopoDS::Face(GeomShape),gp_XYZ(xa,ya,za)); Standard_Real u0 = uvPoint.X(); @@ -490,7 +530,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu ostringstream attractorFunction; attractorFunction << "def f(u,v): return "; attractorFunction << _smp_phy_size << "-(" << _smp_phy_size <<"-" << a << ")"; - attractorFunction << "*exp(-((u-("< 0) continue; - + fmap.Add(f); iface++; 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); //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()); @@ -626,20 +666,20 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) FaceId2PythonSmp[iface]=func; FaceId2SizeMap.erase(f.HashCode(471662)); } - cad_face_t *fce = cad_face_new(c, iface, surf_fun, surfaces.back()); + cad_face_t *fce = cad_face_new(c, iface, surf_fun, surfaces.back()); cad_face_set_tag(fce, iface); if(f.Orientation() != TopAbs_FORWARD){ cad_face_set_orientation(fce, CAD_ORIENTATION_REVERSED); } else { cad_face_set_orientation(fce, CAD_ORIENTATION_FORWARD); } - + for (TopExp_Explorer edge_iter(f,TopAbs_EDGE);edge_iter.More();edge_iter.Next()) { TopoDS_Edge e = TopoDS::Edge(edge_iter.Current()); int ic = emap.FindIndex(e); if (ic <= 0) ic = emap.Add(e); - + double tmin,tmax; curves.push_back(BRep_Tool::CurveOnSurface(e, f, tmin, tmax)); if ((HasSizeMapOnEdge) && EdgeId2SizeMap.find(e.HashCode(471662))!=EdgeId2SizeMap.end()){ @@ -692,7 +732,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) } } if (npts != 2) { - // should not happen + // should not happen MESSAGE("An edge does not have 2 extremities."); } else { if (d1 < d2) @@ -758,11 +798,11 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) blsurf_session_delete(bls); cad_delete(c); context_delete(ctx); - + return error(_comment); //return false; } - + integer nv, ne, nt, nq, vtx[4], tag; real xyz[3]; @@ -771,14 +811,14 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) mesh_get_triangle_count(msh, &nt); mesh_get_quadrangle_count(msh, &nq); - + SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); SMDS_MeshNode** nodes = new SMDS_MeshNode*[nv+1]; bool* tags = new bool[nv+1]; for(int iv=1;iv<=nv;iv++) { mesh_get_vertex_coordinates(msh, iv, xyz); - mesh_get_vertex_tag(msh, iv, &tag); + mesh_get_vertex_tag(msh, iv, &tag); nodes[iv] = meshDS->AddNode(xyz[0], xyz[1], xyz[2]); // internal point are tagged to zero if(tag){ @@ -792,7 +832,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) for(int it=1;it<=ne;it++) { mesh_get_edge_vertices(msh, it, vtx); SMDS_MeshEdge* edg = meshDS->AddEdge(nodes[vtx[0]], nodes[vtx[1]]); - mesh_get_edge_tag(msh, it, &tag); + mesh_get_edge_tag(msh, it, &tag); if (tags[vtx[0]]) { meshDS->SetNodeOnEdge(nodes[vtx[0]], TopoDS::Edge(emap(tag))); @@ -803,13 +843,13 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) tags[vtx[1]] = false; }; meshDS->SetMeshElementOnShape(edg, TopoDS::Edge(emap(tag))); - + } for(int it=1;it<=nt;it++) { mesh_get_triangle_vertices(msh, it, vtx); SMDS_MeshFace* tri = meshDS->AddFace(nodes[vtx[0]], nodes[vtx[1]], nodes[vtx[2]]); - mesh_get_triangle_tag(msh, it, &tag); + mesh_get_triangle_tag(msh, it, &tag); meshDS->SetMeshElementOnShape(tri, TopoDS::Face(fmap(tag))); if (tags[vtx[0]]) { meshDS->SetNodeOnFace(nodes[vtx[0]], TopoDS::Face(fmap(tag))); @@ -828,7 +868,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) for(int it=1;it<=nq;it++) { mesh_get_quadrangle_vertices(msh, it, vtx); SMDS_MeshFace* quad = meshDS->AddFace(nodes[vtx[0]], nodes[vtx[1]], nodes[vtx[2]], nodes[vtx[3]]); - mesh_get_quadrangle_tag(msh, it, &tag); + mesh_get_quadrangle_tag(msh, it, &tag); meshDS->SetMeshElementOnShape(quad, TopoDS::Face(fmap(tag))); if (tags[vtx[0]]) { meshDS->SetNodeOnFace(nodes[vtx[0]], TopoDS::Face(fmap(tag))); @@ -861,7 +901,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) // Issue 0019864. On DebianSarge, FE signals do not obey to OSD::SetSignal(false) #ifndef WNT - if ( oldFEFlags > 0 ) + if ( oldFEFlags > 0 ) feenableexcept( oldFEFlags ); feclearexcept( FE_ALL_EXCEPT ); #endif @@ -871,7 +911,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) //============================================================================= /*! - * + * */ //============================================================================= @@ -882,7 +922,7 @@ ostream & BLSURFPlugin_BLSURF::SaveTo(ostream & save) //============================================================================= /*! - * + * */ //============================================================================= @@ -893,7 +933,7 @@ istream & BLSURFPlugin_BLSURF::LoadFrom(istream & load) //============================================================================= /*! - * + * */ //============================================================================= @@ -904,7 +944,7 @@ ostream & operator << (ostream & save, BLSURFPlugin_BLSURF & hyp) //============================================================================= /*! - * + * */ //============================================================================= @@ -952,7 +992,7 @@ status_t surf_fun(real *uv, real *xyz, real*du, real *dv, if(du && dv){ gp_Pnt P; gp_Vec D1U,D1V; - + geometry->D1(uv[0],uv[1],P,D1U,D1V); du[0]=D1U.X(); du[1]=D1U.Y(); du[2]=D1U.Z(); dv[0]=D1V.X(); dv[1]=D1V.Y(); dv[2]=D1V.Z(); @@ -962,11 +1002,11 @@ status_t surf_fun(real *uv, real *xyz, real*du, real *dv, gp_Pnt P; gp_Vec D1U,D1V; gp_Vec D2U,D2V,D2UV; - + geometry->D2(uv[0],uv[1],P,D1U,D1V,D2U,D2V,D2UV); duu[0]=D2U.X(); duu[1]=D2U.Y(); duu[2]=D2U.Z(); duv[0]=D2UV.X(); duv[1]=D2UV.Y(); duv[2]=D2UV.Z(); - dvv[0]=D2V.X(); dvv[1]=D2V.Y(); dvv[2]=D2V.Z(); + dvv[0]=D2V.X(); dvv[1]=D2V.Y(); dvv[2]=D2V.Z(); } return 0; @@ -1112,3 +1152,134 @@ status_t message_callback(message_t *msg, void *user_data) } return STATUS_OK; } + + +//============================================================================= +/*! + * + */ +//============================================================================= +bool BLSURFPlugin_BLSURF::Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap) +{ + int _physicalMesh = BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh(); + double _phySize = BLSURFPlugin_Hypothesis::GetDefaultPhySize(); + //int _geometricMesh = BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh(); + //double _angleMeshS = BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS(); + double _angleMeshC = BLSURFPlugin_Hypothesis::GetDefaultAngleMeshC(); + if(_hypothesis) { + _physicalMesh = (int) _hypothesis->GetPhysicalMesh(); + _phySize = _hypothesis->GetPhySize(); + //_geometricMesh = (int) hyp->GetGeometricMesh(); + //_angleMeshS = hyp->GetAngleMeshS(); + _angleMeshC = _hypothesis->GetAngleMeshC(); + } + + bool IsQuadratic = false; + + // ---------------- + // evaluate 1D + // ---------------- + TopTools_DataMapOfShapeInteger EdgesMap; + double fullLen = 0.0; + double fullNbSeg = 0; + for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge( exp.Current() ); + if( EdgesMap.IsBound(E) ) + continue; + SMESH_subMesh *sm = aMesh.GetSubMesh(E); + double aLen = SMESH_Algo::EdgeLength(E); + fullLen += aLen; + int nb1d = 0; + if(_physicalMesh==1) { + nb1d = (int)( aLen/_phySize + 1 ); + } + else { + // use geometry + double f,l; + Handle(Geom_Curve) C = BRep_Tool::Curve(E,f,l); + double fullAng = 0.0; + double dp = (l-f)/200; + gp_Pnt P1,P2,P3; + C->D0(f,P1); + C->D0(f+dp,P2); + gp_Vec V1(P1,P2); + for(int j=2; j<=200; j++) { + C->D0(f+dp*j,P3); + gp_Vec V2(P2,P3); + fullAng += fabs(V1.Angle(V2)); + V1 = V2; + P2 = P3; + } + nb1d = (int)( fullAng/_angleMeshC + 1 ); + } + fullNbSeg += nb1d; + std::vector aVec(17); + for(int i=0; i<17; i++) aVec[i]=0; + if( IsQuadratic > 0 ) { + aVec[0] = 2*nb1d - 1; + aVec[2] = nb1d; + } + else { + aVec[0] = nb1d - 1; + aVec[1] = nb1d; + } + aResMap.insert(std::make_pair(sm,aVec)); + EdgesMap.Bind(E,nb1d); + } + double ELen = fullLen/fullNbSeg; + // ---------------- + // evaluate 2D + // ---------------- + // try to evaluate as in MEFISTO + for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face F = TopoDS::Face( exp.Current() ); + SMESH_subMesh *sm = aMesh.GetSubMesh(F); + GProp_GProps G; + BRepGProp::SurfaceProperties(F,G); + double anArea = G.Mass(); + int nb1d = 0; + for (TopExp_Explorer exp1(F,TopAbs_EDGE); exp1.More(); exp1.Next()) { + nb1d += EdgesMap.Find(exp1.Current()); + } + int nbFaces = (int) ( anArea/( ELen*ELen*sqrt(3.) / 4 ) ); + int nbNodes = (int) ( ( nbFaces*3 - (nb1d-1)*2 ) / 6 + 1 ); + std::vector aVec(17); + for(int i=0; i<17; i++) aVec[i]=0; + if( IsQuadratic ) { + int nb1d_in = (nbFaces*3 - nb1d) / 2; + aVec[0] = nbNodes + nb1d_in; + aVec[4] = nbFaces; + } + else { + aVec[0] = nbNodes; + aVec[3] = nbFaces; + } + aResMap.insert(std::make_pair(sm,aVec)); + } + + // ---------------- + // evaluate 3D + // ---------------- + GProp_GProps G; + BRepGProp::VolumeProperties(aShape,G); + double aVolume = G.Mass(); + double tetrVol = 0.1179*ELen*ELen*ELen; + int nbVols = (int)aVolume/tetrVol; + int nb1d_in = (int) ( ( nbVols*6 - fullNbSeg ) / 6 ); + std::vector aVec(17); + for(int i=0; i<17; i++) aVec[i]=0; + if( IsQuadratic ) { + aVec[0] = nb1d_in/3 + 1 + nb1d_in; + aVec[9] = nbVols; + } + else { + aVec[0] = nb1d_in/3 + 1; + aVec[8] = nbVols; + } + SMESH_subMesh *sm = aMesh.GetSubMesh(aShape); + aResMap.insert(std::make_pair(sm,aVec)); + + return true; +} diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index 8f442fb..5c9bc67 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -29,17 +29,24 @@ #include #include "SMESH_2D_Algo.hxx" #include "SMESH_Mesh.hxx" +#include +#include +#include CORBA_CLIENT_HEADER(SALOMEDS) +#include CORBA_CLIENT_HEADER(GEOM_Gen) #include "Utils_SALOME_Exception.hxx" extern "C"{ #include "distene/api.h" } class BLSURFPlugin_Hypothesis; +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, @@ -50,18 +57,22 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); + virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap); + ostream & SaveTo(ostream & save); istream & LoadFrom(istream & load); friend ostream & operator << (ostream & save, BLSURFPlugin_BLSURF & hyp); friend istream & operator >> (istream & load, BLSURFPlugin_BLSURF & hyp); - + protected: const BLSURFPlugin_Hypothesis* _hypothesis; private: PyObject * main_mod; PyObject * main_dict; - + SALOMEDS::Study_var myStudy; + SMESH_Gen_i* smeshGen_i; }; #endif diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.cxx index 24fa3c2..808321d 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.cxx @@ -36,8 +36,8 @@ //============================================================================= BLSURFPlugin_BLSURF_i::BLSURFPlugin_BLSURF_i( PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl ) + int theStudyId, + ::SMESH_Gen* theGenImpl ) : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ), SMESH_Algo_i( thePOA ), @@ -45,8 +45,8 @@ BLSURFPlugin_BLSURF_i::BLSURFPlugin_BLSURF_i( PortableServer::POA_ptr thePOA, { MESSAGE( "BLSURFPlugin_BLSURF_i::BLSURFPlugin_BLSURF_i" ); myBaseImpl = new ::BLSURFPlugin_BLSURF( theGenImpl->GetANewId(), - theStudyId, - theGenImpl ); + theStudyId, + theGenImpl ); } //============================================================================= diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.hxx index 85bb614..bf66433 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF_i.hxx @@ -40,8 +40,8 @@ class BLSURFPlugin_BLSURF_i: public: // Constructor BLSURFPlugin_BLSURF_i( PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl ); + int theStudyId, + ::SMESH_Gen* theGenImpl ); // Destructor virtual ~BLSURFPlugin_BLSURF_i(); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index e3120bd..ae1d60e 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -23,7 +23,7 @@ // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE) // --- // -#include +#include "BLSURFPlugin_Hypothesis.hxx" #include #include diff --git a/src/BLSURFPlugin/Makefile.am b/src/BLSURFPlugin/Makefile.am index 5e7b1b3..ab7d026 100644 --- a/src/BLSURFPlugin/Makefile.am +++ b/src/BLSURFPlugin/Makefile.am @@ -23,7 +23,7 @@ # include $(top_srcdir)/adm_local/unix/make_common_starter.am -# header files +# header files salomeinclude_HEADERS = \ BLSURFPlugin_BLSURF.hxx \ BLSURFPlugin_BLSURF_i.hxx \ @@ -53,15 +53,13 @@ libBLSURFEngine_la_CPPFLAGS = \ $(CORBA_CXXFLAGS) \ $(CORBA_INCLUDES) \ $(BOOST_CPPFLAGS) \ - -I$(srcdir)/../PluginUtils \ -I$(top_builddir)/idl \ - -I$(top_builddir)/salome_adm/unix + -I$(top_builddir)/salome_adm/unix #Qt uniquement necessaire pour le getActiveStudyDocument de SMeshGuiUtils.h libBLSURFEngine_la_LDFLAGS = \ ../../idl/libSalomeIDLBLSURFPLUGIN.la \ - ../PluginUtils/libGeomSelectionTools.la \ $(BLSURF_LIBS) \ $(SMESH_LDFLAGS) -lSMESHimpl -lSMESHEngine -lStdMeshersEngine \ $(KERNEL_LDFLAGS) -lSalomeGenericObj diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index ab94476..dfaf627 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -53,14 +53,14 @@ #include #include -#include +#include #include #include #include #include #include -#include +#include #include // #include @@ -111,7 +111,7 @@ enum { }; /************************************************** - Begin initialization Python structures and objects + Begin initialization Python structures and objects ***************************************************/ typedef struct { @@ -213,18 +213,18 @@ PyObject * newPyStdOut( std::string& out ) } /************************************************* -End initialization Python structures and objects +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 ) { - MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator"); + MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator"); this->mySMPMap.clear(); GeomToolSelected = NULL; @@ -237,13 +237,13 @@ BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QStr throw ("Error: Python interpreter is not initialized"); PyGILState_STATE gstate; gstate = PyGILState_Ensure(); - + main_mod = NULL; main_mod = PyImport_AddModule("__main__"); - + main_dict = NULL; main_dict = PyModule_GetDict(main_mod); - + PyRun_SimpleString("from math import *"); PyGILState_Release(gstate); @@ -258,15 +258,17 @@ BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator() * */ GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() { - MESSAGE("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 or 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; } @@ -285,7 +287,7 @@ namespace { bool BLSURFPluginGUI_HypothesisCreator::checkParams() const { - MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams"); + MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams"); bool ok = true; if ( !isDouble( myPhySize->text(), false )) { if ( myPhySize->text().isEmpty() ) @@ -440,14 +442,14 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() myAngleMeshS->setMinimum( 0 ); myAngleMeshS->setMaximum( 16 ); myAngleMeshS->setSingleStep( 0.5 ); - + aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ), row, 0, 1, 1 ); myAngleMeshC = new QtxDoubleSpinBox( myStdGroup ); aStdLayout->addWidget( myAngleMeshC, row++, 1, 1, 1 ); myAngleMeshC->setMinimum( 0 ); myAngleMeshC->setMaximum( 16 ); myAngleMeshC->setSingleStep( 0.5 ); - + aStdLayout->addWidget( new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ), row, 0, 1, 1 ); myGradation = new QtxDoubleSpinBox( myStdGroup ); aStdLayout->addWidget( myGradation, row++, 1, 1, 1 ); @@ -470,7 +472,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup ); aStdLayout->addWidget( myDecimesh, row++, 0, 1, 2 ); - + // advanced parameters myAdvGroup = new QWidget(); QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup ); @@ -513,14 +515,14 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() anAdvLayout->setColumnStretch( 1, 5 ); // Size Maps parameters - + mySmpGroup = new QWidget(); QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup); mySizeMapTable = new QTableWidget( 0, SMP_NB_COLUMNS, mySmpGroup ); anSmpLayout->addWidget(mySizeMapTable, 1, 0, 8, 1); QStringList sizeMapHeaders; - sizeMapHeaders << tr( "SMP_ENTRY_COLUMN" )<< tr( "SMP_NAME_COLUMN" ) << tr( "SMP_SIZEMAP_COLUMN" ); + sizeMapHeaders << tr( "SMP_ENTRY_COLUMN" )<< tr( "SMP_NAME_COLUMN" ) << tr( "SMP_SIZEMAP_COLUMN" ); mySizeMapTable->setHorizontalHeaderLabels(sizeMapHeaders); mySizeMapTable->horizontalHeader()->hideSection( SMP_ENTRY_COLUMN ); mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN); @@ -553,7 +555,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() removeButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup); anSmpLayout->addWidget(removeButton, SMP_REMOVE_BTN, 1, 1, 1); - + // --- tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) ); @@ -568,7 +570,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) ); connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) ); connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) ); - + connect(addSurfaceButton, SIGNAL(clicked()), this, SLOT(onAddMapOnSurface())); connect(addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddMapOnEdge())); connect(addPointButton, SIGNAL(clicked()), this, SLOT(onAddMapOnPoint())); @@ -607,7 +609,7 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const myAllowQuadrangles->setChecked( data.myAllowQuadrangles ); myDecimesh->setChecked( data.myDecimesh ); myVerbosity->setValue( data.myVerbosity ); - + if ( myOptions.operator->() ) { printf("retrieveParams():myOptions->length()=%d\n",myOptions->length()); for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) { @@ -622,11 +624,11 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) ); myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 ); myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) ); - myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable | - Qt::ItemIsEditable | + myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable | + Qt::ItemIsEditable | Qt::ItemIsEnabled ); } - } + } } myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN ); @@ -649,7 +651,7 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const Qt::ItemIsEditable | Qt::ItemIsEnabled ); } - + mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); @@ -916,7 +918,7 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes guiHyp += name + " = " + value + "; "; } } - + // SizeMap row = 0, nbRows = mySizeMapTable->rowCount(); for ( ; row < nbRows; ++row ) @@ -925,7 +927,7 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes if ( that->mySMPMap.contains(entry) ) guiHyp += entry + " = " + that->mySMPMap[entry] + "; "; } - + MESSAGE("guiHyp : " << guiHyp.toLatin1().data()); return guiHyp; @@ -1009,7 +1011,7 @@ void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a ) { myOptionTable->setFocus(); QMenu* menu = (QMenu*)( a->parent() ); - + int idx = menu->actions().indexOf( a ); QString idStr = QString("%1").arg( idx ); QString option = myOptions[idx].in(); @@ -1028,8 +1030,8 @@ void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a ) myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) ); myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 ); myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) ); - myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable | - Qt::ItemIsEditable | + myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable | + Qt::ItemIsEditable | Qt::ItemIsEnabled ); myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN ); } @@ -1039,12 +1041,12 @@ void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a ) myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN ); //myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) ); } - + void BLSURFPluginGUI_HypothesisCreator::onDeleteOption() { // clear option values and remember selected row QList selectedRows; - QList selected = myOptionTable->selectedItems(); + QList selected = myOptionTable->selectedItems(); QTableWidgetItem* item; foreach( item, selected ) { int row = item->row(); @@ -1076,7 +1078,7 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() int row; foreach( item, selected ) { row = item->row(); - if ( !selectedRows.contains( row ) ) + if ( !selectedRows.contains( row ) ) selectedRows.append( row ); } @@ -1158,22 +1160,23 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS TopoDS_Shape S; string entry, shapeName; -// LightApp_SelectionMgr* aSel = GeomToolSelected->selectionMgr(); + GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool(); + + LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr(); SALOME_ListIO ListSelectedObjects; - aSel->selectedObjects(ListSelectedObjects, NULL, false ); + mySel->selectedObjects(ListSelectedObjects, NULL, false ); if (!ListSelectedObjects.IsEmpty()) { SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects); - GeomSelectionTools* myGeomToolSelected = getGeomSelectionTool(); - for (; Object_It.More(); Object_It.Next()) + for (; Object_It.More(); Object_It.Next()) { Handle(SALOME_InteractiveObject) anObject = Object_It.Value(); entry = myGeomToolSelected->getEntryOfObject(anObject); shapeName = anObject->getName(); S = myGeomToolSelected->entryToShape(entry); - if ((! S.IsNull()) && (S.ShapeType() == typeShapeAsked)) - { + if ((! S.IsNull()) && (S.ShapeType() == typeShapeAsked)) + { mySizeMapTable->setFocus(); QString shapeEntry; shapeEntry = QString::fromStdString(entry); @@ -1189,7 +1192,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS } } that->mySMPMap[shapeEntry] = sizeMap; - that->mySMPShapeTypeMap[shapeEntry] = typeShapeAsked; + that->mySMPShapeTypeMap[shapeEntry] = typeShapeAsked; int row = mySizeMapTable->rowCount() ; mySizeMapTable->setRowCount( row+1 ); mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( shapeEntry ) ); @@ -1228,7 +1231,7 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool QString myEntry = mySizeMapTable->item( myRow, SMP_ENTRY_COLUMN )->text(); bool res = sizeMapValidationFromEntry(myEntry,displayError); mySizeMapTable->setFocus(); - return res; + return res; } bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError) @@ -1236,7 +1239,7 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()"); BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - + if (not that->mySMPMap.contains(myEntry)) { MESSAGE("Geometry with entry "<mySMPMap[myEntry].startsWith("ATTRACTOR")) { MESSAGE("Attractor" ); // if ((that->mySMPMap[myEntry].count(QRegExp("ATTRACTOR([0-9])")) != 1)) - if ((that->mySMPMap[myEntry].count('(') != 1) or + if ((that->mySMPMap[myEntry].count('(') != 1) or (that->mySMPMap[myEntry].count(')') != 1) or (that->mySMPMap[myEntry].count(';') != 4) or (that->mySMPMap[myEntry].size() == 15)){ @@ -1285,9 +1288,9 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt throw ("Erreur: Python interpreter is not initialized"); PyGILState_STATE gstate; gstate = PyGILState_Ensure(); - - PyObject * obj = NULL; - PyObject* new_stderr = NULL; + + PyObject * obj = NULL; + PyObject* new_stderr = NULL; string err_description=""; obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL); if (obj == NULL){ @@ -1304,16 +1307,16 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt return false; } Py_DECREF(obj); - + PyObject * func = NULL; func = PyObject_GetAttrString(main_mod, "f"); if ( func == NULL){ - fflush(stderr); - err_description=""; - new_stderr=newPyStdOut(err_description); - PySys_SetObject("stderr", new_stderr); - PyErr_Print(); - PySys_SetObject("stderr", PySys_GetObject("__stderr__")); + fflush(stderr); + err_description=""; + new_stderr=newPyStdOut(err_description); + PySys_SetObject("stderr", new_stderr); + PyErr_Print(); + PySys_SetObject("stderr", PySys_GetObject("__stderr__")); Py_DECREF(new_stderr); if (displayError) SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() ); @@ -1332,7 +1335,7 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt void BLSURFPluginGUI_HypothesisCreator::OnEditMapFunction(QModelIndex* index) { int myRow = index->row(); int myColumn = index->column(); - + if (myColumn == 2){ if (!myEditor) { myEditor = new BLSURFPluginGUI_MapFunctionEditor(sizeMapModel->item(myRow,0)->text()); @@ -1342,18 +1345,18 @@ void BLSURFPluginGUI_HypothesisCreator::OnEditMapFunction(QModelIndex* index) { // myEditor->show(); // myEditor->raise(); // myEditor->activateWindow(); - + // BLSURFPluginGUI_MapFunctionEditor* myEditor = new BLSURFPluginGUI_MapFunctionEditor(sizeMapModel->item(myRow,0)->text()); // myEditor->exec(); QString myFunction = myEditor->GetFunctionText(); // FIN RECUPERATION FONCTION - + if (! myFunction.isEmpty()) { - + // MAJ DE LA MAP - - BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = + + BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis()); // h->SetSizeMapEntry(sizeMapModel->item(myRow,1)->text().toLatin1().constData(), @@ -1364,7 +1367,7 @@ void BLSURFPluginGUI_HypothesisCreator::OnEditMapFunction(QModelIndex* index) { } } }*/ - + QString BLSURFPluginGUI_HypothesisCreator::caption() const { return tr( "BLSURF_TITLE" ); @@ -1394,3 +1397,4 @@ LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr() else return 0; } + diff --git a/src/Makefile.am b/src/Makefile.am index 2d86256..01a228a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,10 +23,10 @@ # include $(top_srcdir)/adm_local/unix/make_common_starter.am -SUBDIRS = PluginUtils BLSURFPlugin +SUBDIRS = BLSURFPlugin if BLSURFPLUGIN_ENABLE_GUI - SUBDIRS += GUI + SUBDIRS += PluginUtils GUI endif DIST_SUBDIRS = PluginUtils BLSURFPlugin GUI diff --git a/src/PluginUtils/GeomSelectionTools.cxx b/src/PluginUtils/GeomSelectionTools.cxx index 9bdad21..ebe8694 100644 --- a/src/PluginUtils/GeomSelectionTools.cxx +++ b/src/PluginUtils/GeomSelectionTools.cxx @@ -24,26 +24,28 @@ #include "GeomSelectionTools.h" -#include -#include -#include -#include +#include +#include +#include -#include +#include #include -#include #include -#include +#include #include #include #include #include +#include "utilities.h" + +#include "SALOME_LifeCycleCORBA.hxx" +#include /*! - * Constructor + * Constructor * @param aStudy pointer to the Study * */ @@ -62,18 +64,31 @@ _PTR(Study) GeomSelectionTools::getMyStudy() } /*! - * Allows to get the selection manager from LightApp + * Allows to get the Salome Application * @return A LightApp_SelectionMgr Pointer or 0 if it can't get it. */ -LightApp_SelectionMgr* GeomSelectionTools::selectionMgr() +SalomeApp_Application* GeomSelectionTools::GetSalomeApplication() { SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); if (anApp) - return dynamic_cast( anApp->selectionMgr() ); - else + return anApp; + else return 0; } +/*! + * 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 = GetSalomeApplication(); + if (anApp) + return dynamic_cast( anApp->selectionMgr() ); + else + return 0; +} + /*! * Return the list of the selected Salome Interactive Object (SALOME_ListIO*) * @return the list of the selected Salome Interactive Object @@ -95,7 +110,7 @@ Handle(SALOME_InteractiveObject) GeomSelectionTools::getFirstSelectedSalomeObjec SALOME_ListIO selected; LightApp_SelectionMgr* aSel = selectionMgr(); aSel->selectedObjects( selected, NULL, false ); - if (!selected.IsEmpty()){ + if (!selected.IsEmpty()){ SALOME_ListIteratorOfListIO anIt(selected); Handle(SALOME_InteractiveObject) anIO; anIO = anIt.Value(); @@ -107,7 +122,7 @@ Handle(SALOME_InteractiveObject) GeomSelectionTools::getFirstSelectedSalomeObjec /*! * Return the entry of the first selected Object * @return the entry of the first selected Object - */ + */ std::string GeomSelectionTools::getFirstSelectedEntry() { Handle(SALOME_InteractiveObject) anIO; @@ -124,7 +139,7 @@ std::string GeomSelectionTools::getFirstSelectedEntry() std::string GeomSelectionTools::getEntryOfObject(Handle(SALOME_InteractiveObject) anIO){ std::string entry=""; _PTR(SObject) aSO = myStudy->FindObjectID(anIO->getEntry()); - if (aSO){ + if (aSO){ _PTR(SObject) aRefSObj; // If selected object is a reference if ( aSO->ReferencedObject( aRefSObj )) @@ -135,7 +150,7 @@ 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 @@ -166,14 +181,14 @@ std::string GeomSelectionTools::getFirstSelectedComponentDataType() Handle(SALOME_InteractiveObject) anIO; std::string DataType=""; anIO=GeomSelectionTools::getFirstSelectedSalomeObject(); - _PTR(SObject) aSO = myStudy->FindObjectID(anIO->getEntry()); + _PTR(SObject) aSO = myStudy->FindObjectID(anIO->getEntry()); if (aSO){ _PTR(SObject) aRefSObj; - // If selected object is a reference + // If selected object is a reference if ( aSO->ReferencedObject( aRefSObj )) DataType= aRefSObj->GetFatherComponent()->ComponentDataType(); - // If selected object is a reference is not a reference - else + // If selected object is a reference is not a reference + else DataType=anIO->getComponentDataType(); } return DataType; @@ -195,29 +210,40 @@ TopoDS_Shape GeomSelectionTools::getFirstSelectedTopoDSShape() * @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){ + MESSAGE("GeomSelectionTools::entryToShape"<FindObjectID(entry); - if (aSO){ + if (aSO){ _PTR(SObject) aRefSObj; GEOM::GEOM_Object_var aShape; - // If selected object is a reference - if ( aSO->ReferencedObject( aRefSObj )){ - if (aRefSObj->GetFatherComponent()->ComponentDataType() == "GEOM") - aShape=SMESH::SObjectToInterface(aRefSObj); - } - // If selected object is a reference is not a reference - else { - if ( aSO->GetFatherComponent()->ComponentDataType() == "GEOM") - aShape = SMESH::SObjectToInterface(aSO); + MESSAGE("Got a SO"); + // If selected object is a reference + if ( aSO->ReferencedObject( aRefSObj )) + aSO = aRefSObj; + MESSAGE("aSO->GetFatherComponent()->ComponentDataType(): " << aSO->GetFatherComponent()->ComponentDataType()); + if ( strcmp(aSO->GetFatherComponent()->ComponentDataType().c_str(),"GEOM") == 0) + aShape = SMESH::SObjectToInterface(aSO); + if ( !aShape->_is_nil() ){ + MESSAGE("Got a Shape as Geom Object "); + + SalomeApp_Application* anApp = GetSalomeApplication(); + if (anApp) { + MESSAGE("Got Application"); + Engines::Component_var component = anApp->lcc()->FindOrLoad_Component( "FactoryServer","GEOM" ); + GEOM::GEOM_Gen_var _geomEngine = GEOM::GEOM_Gen::_narrow(component); + MESSAGE("Got GEOM engine"); + GEOM_Client* aClient = new GEOM_Client(); + if ( aClient && !_geomEngine->_is_nil() ) { + MESSAGE("GEOM client is OK and GEOM engine is not null"); + S = aClient->GetShape( _geomEngine, aShape ); + } } - if ( !aShape->_is_nil() ){ - if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) - S=gen->GeomObjectToShape( aShape.in() ); } } 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. @@ -241,8 +267,8 @@ TopAbs_ShapeEnum GeomSelectionTools:: getFirstSelectedShapeType() * 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(); @@ -251,23 +277,26 @@ GeomAbs_SurfaceType GeomSelectionTools::getFaceInformation() TopoDS_Face f=TopoDS::Face(S); Handle(Geom_Surface) surf = BRep_Tool::Surface(f); BRepAdaptor_Surface surf_adap=BRepAdaptor_Surface::BRepAdaptor_Surface(f); - + /* Global Information */ - cout << "GLOBAL INFORMATION" << endl; - cout << "******************" << endl; - stringstream buffer; + std::cout << "GLOBAL INFORMATION" << std::endl; + std::cout << "******************" << std::endl; + std::stringstream buffer; buffer << "Degre U : " << surf_adap.UDegree(); //conversion nécessaire pour affichage - cout << buffer.str() << 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; + std::cout << buffer.str() << std::endl; + std::cout << " Degre V : " << surf_adap.VDegree() << std::endl; + std::cout << " Nb Poles U : " << surf_adap.NbUPoles() << std::endl; + std::cout << " Nb Poles V : " << surf_adap.NbVPoles() << std::endl; + std::cout << " Nb Noeuds U : " << surf_adap.NbUKnots() << std::endl; + std::cout << " Nb Noeuds V : " << surf_adap.NbVKnots() << std::endl; + std::cout << " U Rationnel ? " << surf_adap.IsURational() << std::endl; + std::cout << " V Rationnel ? " << surf_adap.IsVRational() << std::endl; surf_type=surf_adap.GetType(); } return surf_type; } + + + diff --git a/src/PluginUtils/GeomSelectionTools.h b/src/PluginUtils/GeomSelectionTools.h index 7b491fb..7f770ff 100644 --- a/src/PluginUtils/GeomSelectionTools.h +++ b/src/PluginUtils/GeomSelectionTools.h @@ -19,17 +19,18 @@ // File : GeomSelectionTools.h // Authors : Nicolas GEIMER (OCC) // --- - - +#ifndef _GEOMSELECTIONTOOLS_H_ +#define _GEOMSELECTIONTOOLS_H_ #include "SALOMEDSClient.hxx" #include "SALOME_InteractiveObject.hxx" #include +#include #include #include -class LightApp_SelectionMgr; +class LightApp_SelectionMgr; /*! @@ -44,12 +45,13 @@ class GeomSelectionTools { private: - - _PTR(Study) myStudy; + + _PTR(Study) myStudy; public: - GeomSelectionTools(_PTR(Study)); + GeomSelectionTools(_PTR(Study)); + static SalomeApp_Application* GetSalomeApplication(); static LightApp_SelectionMgr* selectionMgr(); SALOME_ListIO* getSelectedSalomeObjects(); Handle(SALOME_InteractiveObject) getFirstSelectedSalomeObject(); @@ -65,3 +67,4 @@ public: }; +#endif // _GEOMSELECTIONTOOLS_H_ diff --git a/src/PluginUtils/Makefile.am b/src/PluginUtils/Makefile.am index 6ba3947..27d9ca5 100644 --- a/src/PluginUtils/Makefile.am +++ b/src/PluginUtils/Makefile.am @@ -33,12 +33,6 @@ dist_libGeomSelectionTools_la_SOURCES = \ GeomSelectionTools.h \ GeomSelectionTools.cxx -MOC_FILES = \ - BLSURFPluginGUI_HypothesisCreator_moc.cxx - -nodist_GeomSelectionTools_la_SOURCES = \ - $(MOC_FILES) - # additionnal information to compil and link file libGeomSelectionTools_la_CPPFLAGS = \ diff --git a/src/PluginUtils/PluginUtils.h b/src/PluginUtils/PluginUtils.h deleted file mode 100644 index 69c2e86..0000000 --- a/src/PluginUtils/PluginUtils.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : PluginUtils.h -// Author : Nicolas GEIMER (OCC) -// Module : BLSURFPlugin -// - - - diff --git a/src/PluginUtils/SizeMapPython.cxx b/src/PluginUtils/SizeMapPython.cxx deleted file mode 100644 index e69de29..0000000 diff --git a/src/PluginUtils/SizeMapPython.h b/src/PluginUtils/SizeMapPython.h deleted file mode 100644 index 576fc6d..0000000 --- a/src/PluginUtils/SizeMapPython.h +++ /dev/null @@ -1 +0,0 @@ -#include -- 2.39.2