From: gdd Date: Mon, 14 Feb 2011 10:44:02 +0000 (+0000) Subject: rnc : working prototype with idl interface and a computation time of the distance... X-Git-Tag: Geodesic_attractor_20110218~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=81165da06f438806b72052184b4a7c9489a85fdc;p=plugins%2Fblsurfplugin.git rnc : working prototype with idl interface and a computation time of the distance map reduced by a factor 3 --- diff --git a/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx b/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx index 47e8c24..eabda47 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx @@ -13,14 +13,19 @@ BLSURFPlugin_Attractor::BLSURFPlugin_Attractor () _known(), _trial(), _mapGrid(-1), - _i0(-1), - _j0(-1), _u1 (0.), _u2 (0.), _v1 (0.), - _v2 (0.){MESSAGE("construction d'un attracteur vide");} + _v2 (0.), + _startSize(-1), + _endSize(-1), + _actionRadius(-1), + _constantRadius(-1), + _type(-1), + _isMapBuilt(false), + _isEmpty(true){ MESSAGE("construction of a void attractor"); } -BLSURFPlugin_Attractor::BLSURFPlugin_Attractor (TopoDS_Face Face, TopoDS_Shape Attractor) +BLSURFPlugin_Attractor::BLSURFPlugin_Attractor (const TopoDS_Face& Face, const TopoDS_Shape& Attractor, int MapGrid) : _face(), _attractorShape(), _vectU(), @@ -28,17 +33,22 @@ BLSURFPlugin_Attractor::BLSURFPlugin_Attractor (TopoDS_Face Face, TopoDS_Shape A _DMap(), _known(), _trial(), - _mapGrid(-1), - _i0(-1), - _j0(-1), + _mapGrid(MapGrid), _u1 (0.), _u2 (0.), _v1 (0.), - _v2 (0.) + _v2 (0.), + _startSize(-1), + _endSize(-1), + _actionRadius(-1), + _constantRadius(-1), + _type(0), + _isMapBuilt(false), + _isEmpty(false) { _face = Face; _attractorShape = Attractor; - _mapGrid = 200; + //_mapGrid = 200; init(); } @@ -47,7 +57,7 @@ bool BLSURFPlugin_Attractor::init(){ MESSAGE("construction d'un attracteur"); Standard_Real u0,v0; int i,j ; - _known.clear(); + //_known.clear(); _trial.clear(); Handle(Geom_Surface) aSurf = BRep_Tool::Surface(_face); Trial_Pnt TPnt(3,0); //TPnt(0,0,0); @@ -89,13 +99,26 @@ bool BLSURFPlugin_Attractor::init(){ for (i=0; i<=_mapGrid; i++){ _DMap.push_back(temp); } + std::vector temp2(_mapGrid+1,false); + for (i=0; i<=_mapGrid; i++){ + _known.push_back(temp2); + } MESSAGE("DMap(0,0) : "<< _DMap[0][0]); _DMap[i0][j0] = 0.; // Set distance of starting point to 0. - _buildMap(); // Computes the distance for all points of the discrete surface + // _buildMap(); // Computes the distance for all points of the discrete surface } -double BLSURFPlugin_Attractor::GetSize(double u, double v){ + +void BLSURFPlugin_Attractor::SetParameters(double Start_Size, double End_Size, double Action_Radius, double Constant_Radius){ + _startSize = Start_Size; + _endSize = End_Size; + _actionRadius = Action_Radius; + _constantRadius = Constant_Radius; + MESSAGE("_startSize = "<<_startSize<<"; _endSize = "<<_endSize<<" ; _actionRadius = "<<_actionRadius<<" ; _constantRadius = "<<_constantRadius) +} + +double BLSURFPlugin_Attractor::_distance(double u, double v){ // // calcul des coins du carre // int i_sup = floor ( (u - _u1) * _mapGrid / (_u2 - _u1) + 1. ); @@ -136,18 +159,34 @@ double BLSURFPlugin_Attractor::GetSize(double u, double v){ int i = floor ( (u - _u1) * _mapGrid / (_u2 - _u1) + 0.5 ); int j = floor ( (v - _v1) * _mapGrid / (_v2 - _v1) + 0.5 ); - double d = _DMap[i][j]; - - return 1 + ( 0.5 * (d - 20. + abs(d - 20.)) ) ; // more generally: function of _DMap + return _DMap[i][j]; + +} +double BLSURFPlugin_Attractor::GetSize(double u, double v){ + + double myDist = 0.5 * (_distance(u,v) - _constantRadius + abs(_distance(u,v) - _constantRadius)); + switch(_type) + { + case TYPE_EXP: + return _endSize - (_endSize - _startSize) * exp(- myDist * myDist / (_actionRadius * _actionRadius) ); + break; + case TYPE_LIN: + return _startSize + ( 0.5 * (_distance(u,v) - _constantRadius + abs(_distance(u,v) - _constantRadius)) ) ; + break; + } + //return 1 + ( 0.5 * (_distance(u,v) - _constantRadius + abs(_distance(u,v) - _constantRadius)) ) ; + //return 30 - 29 * exp( - 0.5 * (_distance(u,v) - _constantRadius + abs(_distance(u,v) - _constantRadius)) / _actionRadius ) ; + } -bool BLSURFPlugin_Attractor::_buildMap(){ + +void BLSURFPlugin_Attractor::BuildMap(){ MESSAGE("building the map"); int i, j, k, n; int count = 0; - TPointSet::iterator pIt; + //TPointSet::iterator pIt; int ip, jp, kp, np; int i0, j0; gp_Pnt P; @@ -164,7 +203,7 @@ bool BLSURFPlugin_Attractor::_buildMap(){ //TPointSet::iterator kn_found; Handle(Geom_Surface) aSurf = BRep_Tool::Surface(_face); - while (_trial.size() > 0 && count < 40000){ + while (_trial.size() > 0 && count < 1000000){ count++; MESSAGE("boucle while : "<Tj;//static_cast((*min)[2]); MESSAGE("i0 = "< probleme"); - break; - } - _known.insert(Current_Pnt); // Move it to _known and remove it from _trial +// if (pIt != _known.end()){ +// MESSAGE("point "<<(*pIt)[0]<<" , "<<(*pIt)[1]<<" deja dans _known -> probleme"); +// break; +// } +// _known.insert(Current_Pnt); // Move it to _known and remove it from _trial + _known[i0][j0] = true; // Move point to "Known" //MESSAGE(Current_Pnt[0]<<" , "<D1(_vectU[ip],_vectV[jp],P,D1U,D1V); // Calculate the metric at (i,j) Guu = D1U.X()*D1U.X() + D1U.Y()*D1U.Y() + D1U.Z()*D1U.Z(); // Guu = ||dS/du||**2 G(i,j)= | ||dS/du||**2 * | @@ -274,9 +314,9 @@ bool BLSURFPlugin_Attractor::_buildMap(){ } np = (n + _mapGrid + 1) % (_mapGrid+1); //MESSAGE(" n = "< #include #include +#include // OPENCASCADE includes #include @@ -72,6 +79,9 @@ #include #include +#define TYPE_EXP 0 +#define TYPE_LIN 1 + // class IJ_Pnt{ // public: @@ -123,19 +133,27 @@ class BLSURFPlugin_Attractor { public: BLSURFPlugin_Attractor (); // TODO ~BLSURFPlugin_Attractor (); - BLSURFPlugin_Attractor (TopoDS_Face Face, TopoDS_Shape Attractor); - bool init(); // Calculates the discrete points correponding to attractor, initialises the map and calls _buildMap + BLSURFPlugin_Attractor (const TopoDS_Face& Face, const TopoDS_Shape& Attractor, int MapGrid = 200); + bool init(); // Calculates the discrete points correponding to attractor, initialises the map and calls _buildMap double GetSize (double u, double v); - TopoDS_Face GetFace(){ return _face; } - TopoDS_Shape GetAttractorShape(){ return _attractorShape; } + TopoDS_Face GetFace() const { return _face; } + TopoDS_Shape GetAttractorShape() const { return _attractorShape; } + + void SetParameters(double Start_Size, double End_Size, double Action_Radius, double Constant_Radius); + void SetType(int type){ _type = type; } // bool SetAttractorShape(TopoDS_Shape Attractor){ // _attractorShape = Attractor; // } + void BuildMap(); // Builds the map of distances between source point and any point P(u,v) + bool IsMapBuilt() const { return _isMapBuilt; } + bool Empty() const { return _isEmpty; } + typedef std::vector TDiscreteParam; typedef std::vector< std::vector > TDistMap; - typedef std::set< std::vector > TPointSet; + //typedef std::set< std::vector > TPointSet; + typedef std::vector< std::vector > TPointSet; typedef std::set< std::vector > TTrialSet; //typedef std::set< Trial_Pnt, Trial_comp > TTrialSet; typedef std::vector Trial_Pnt; @@ -150,11 +168,16 @@ class BLSURFPlugin_Attractor { TDistMap _DMap; TPointSet _known; TTrialSet _trial; - int _mapGrid; // Number of grid points in U and V directions - double _u1, _u2, _v1, _v2; // Bounds of the parametric space of the face - int _i0, _j0; // Indices of the starting point + int _type; // Type of function used to calculate the size from the distance + int _mapGrid; // Number of grid points in U and V directions + double _u1, _u2, _v1, _v2; // Bounds of the parametric space of the face + double _startSize, _endSize; + double _actionRadius, _constantRadius; - bool _buildMap(); // Builds the map of distances between source point and any point P(u,v) + //bool _buildMap(); // Builds the map of distances between source point and any point P(u,v) + bool _isMapBuilt; + bool _isEmpty; + double _distance(double u, double v); }; diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 89391e1..d7cc9bd 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -215,6 +215,7 @@ std::map VertexId2PythonSmp; std::map > FaceId2AttractorCoords; std::map FaceId2ClassAttractor; +std::map FaceIndex2ClassAttractor; TopTools_IndexedMapOfShape FacesWithEnforcedVertices; std::map< int, std::set< std::vector > > FaceId2EnforcedVertexCoords; @@ -223,7 +224,7 @@ std::map< std::vector, std::vector > EnfVertex2ProjVertex; bool HasSizeMapOnFace=false; bool HasSizeMapOnEdge=false; bool HasSizeMapOnVertex=false; -bool HasAttractorOnFace=false; +//bool HasAttractorOnFace=false; //============================================================================= /*! @@ -279,6 +280,7 @@ BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId, EdgeId2PythonSmp.clear(); VertexId2PythonSmp.clear(); FaceId2AttractorCoords.clear(); + FaceId2ClassAttractor.clear(); FacesWithEnforcedVertices.Clear(); FaceId2EnforcedVertexCoords.clear(); EnfVertex2ProjVertex.clear(); @@ -587,8 +589,8 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction attractorFunctionStream << "def f(u,v): return "; attractorFunctionStream << _smp_phy_size << "-(" << _smp_phy_size <<"-" << a << ")"; //attractorFunctionStream << "*exp(-((u-("< define a bool _mapbuilt in the class that is set to false by default and set to true when calling _buildmap() OK -// BLSURFPlugin_Attractor myAttractor; -// const BLSURFPlugin_Hypothesis::TAttractorMap class_attractors = BLSURFPlugin_Hypothesis::GetClassAttractorEntries(hyp); -// BLSURFPlugin_Hypothesis::TSizeMap::const_iterator AtIt = class_attractors.begin(); -// for ( ; AtIt != class_attractors.end(); ++atIt ) { -// if ( !AtIt->second.empty() ) { -// // MESSAGE("blsurf_set_attractor(): " << AtIt->first << " = " << AtIt->second); -// GeomShape = entryToShape(AtIt->first); -// AttShape = entryToShape(AtIt->second); -// GeomType = GeomShape.ShapeType(); -// // Group Management -// // if (GeomType == TopAbs_COMPOUND){ -// // for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){ -// // if (it.Value().ShapeType() == TopAbs_FACE){ -// // HasAttractorOnFace = true; -// // myAttractor = BLSURFPluginAttractor(GeomShape, AttShape); -// // } -// // } -// // } -// -// if (GeomType == TopAbs_FACE){ -// HasAttractorOnFace = true; -// myAttractor = BLSURFPlugin_Attractor(TopoDS::Face(GeomShape), AttShape); + const BLSURFPlugin_Hypothesis::TAttractorMap class_attractors = BLSURFPlugin_Hypothesis::GetClassAttractorEntries(hyp); + int key=-1; + BLSURFPlugin_Hypothesis::TAttractorMap::const_iterator AtIt = class_attractors.begin(); + for ( ; AtIt != class_attractors.end(); ++AtIt ) { + if ( !AtIt->second.Empty() ) { + // MESSAGE("blsurf_set_attractor(): " << AtIt->first << " = " << AtIt->second); + GeomShape = entryToShape(AtIt->first); + AttShape = AtIt->second.GetAttractorShape(); + GeomType = GeomShape.ShapeType(); + // Group Management +// if (GeomType == TopAbs_COMPOUND){ +// for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){ +// if (it.Value().ShapeType() == TopAbs_FACE){ +// HasAttractorOnFace = true; +// myAttractor = BLSURFPluginAttractor(GeomShape, AttShape); +// } +// } // } -// -// } -// } + + if (GeomType == TopAbs_FACE && AttShape.ShapeType() == TopAbs_VERTEX){ + HasSizeMapOnFace = true; + if (! FacesWithSizeMap.Contains(TopoDS::Face(GeomShape)) ) { + key = FacesWithSizeMap.Add(TopoDS::Face(GeomShape) ); + } + else { + key = FacesWithSizeMap.FindIndex(TopoDS::Face(GeomShape)); +// MESSAGE("Face with key " << key << " already in map"); + } + FaceId2ClassAttractor[key] = AtIt->second; + } + else{ + MESSAGE("Wrong shape type !!") + } + + } + } + // @@ -957,6 +981,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) FacesWithSizeMap.Clear(); FaceId2SizeMap.clear(); + FaceId2ClassAttractor.clear(); EdgesWithSizeMap.Clear(); EdgeId2SizeMap.clear(); VerticesWithSizeMap.Clear(); @@ -1002,6 +1027,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) string bad_end = "return"; int faceKey = -1; int ienf = 0; + BLSURFPlugin_Attractor myAttractor; for (TopExp_Explorer face_iter(aShape,TopAbs_FACE);face_iter.More();face_iter.Next()) { TopoDS_Face f=TopoDS::Face(face_iter.Current()); @@ -1035,6 +1061,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) } if (HasSizeMapOnFace){ + MESSAGE("A size map is defined on a face") // std::cout << "A size map is defined on a face" << std::endl; // Classic size map faceKey = FacesWithSizeMap.FindIndex(f); @@ -1094,6 +1121,16 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) } } + // Class Attractors + std::map::iterator clAttractor_iter = FaceId2ClassAttractor.find(faceKey); + if (clAttractor_iter != FaceId2ClassAttractor.end()){ + MESSAGE("Face indice: " << iface); + MESSAGE("Adding attractor"); + FaceIndex2ClassAttractor[iface]=clAttractor_iter->second; + FaceId2ClassAttractor.erase(clAttractor_iter); + } + } + // Enforced Vertices faceKey = FacesWithEnforcedVertices.FindIndex(f); std::map > >::const_iterator evmIt = FaceId2EnforcedVertexCoords.find(faceKey); @@ -1152,7 +1189,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) } // else // std::cout << "No enforced vertex defined" << std::endl; - } +// } /**************************************************************************************** @@ -1721,34 +1758,40 @@ status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data) } if (FaceId2PythonSmp.count(face_id) != 0){ -// PyObject * pyresult = NULL; -// PyObject* new_stderr = NULL; -// assert(Py_IsInitialized()); -// PyGILState_STATE gstate; -// gstate = PyGILState_Ensure(); -// pyresult = PyObject_CallFunction(FaceId2PythonSmp[face_id],(char *)"(f,f)",uv[0],uv[1]); -// double result; -// if ( pyresult == NULL){ -// fflush(stderr); -// string err_description=""; -// new_stderr = newPyStdOut(err_description); -// PySys_SetObject((char *)"stderr", new_stderr); -// PyErr_Print(); -// PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__")); -// Py_DECREF(new_stderr); -// MESSAGE("Can't evaluate f(" << uv[0] << "," << uv[1] << ")" << " error is " << err_description); -// result = *((double*)user_data); -// } -// else { -// result = PyFloat_AsDouble(pyresult); -// Py_DECREF(pyresult); -// } - double result = FaceId2ClassAttractor[face_id].GetSize(uv[0],uv[1]); - *size = result; + PyObject * pyresult = NULL; + PyObject* new_stderr = NULL; + assert(Py_IsInitialized()); + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); + pyresult = PyObject_CallFunction(FaceId2PythonSmp[face_id],(char *)"(f,f)",uv[0],uv[1]); + double result; + if ( pyresult == NULL){ + fflush(stderr); + string err_description=""; + new_stderr = newPyStdOut(err_description); + PySys_SetObject((char *)"stderr", new_stderr); + PyErr_Print(); + PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__")); + Py_DECREF(new_stderr); + MESSAGE("Can't evaluate f(" << uv[0] << "," << uv[1] << ")" << " error is " << err_description); + result = *((double*)user_data); + } + else { + result = PyFloat_AsDouble(pyresult); + Py_DECREF(pyresult); + } //MESSAGE("f(" << uv[0] << "," << uv[1] << ")" << " = " << result); //PyGILState_Release(gstate); } + if (FaceIndex2ClassAttractor.count(face_id) !=0){ + MESSAGE("List of attractor is not empty") + MESSAGE("Attractor empty : "<< FaceIndex2ClassAttractor[face_id].Empty()) + double result = FaceIndex2ClassAttractor[face_id].GetSize(uv[0],uv[1]); + *size = result; + MESSAGE("f(" << uv[0] << "," << uv[1] << ")" << " = " << result); + } else { + MESSAGE("List of attractor is empty !!!") *size = *((double*)user_data); } return STATUS_OK; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 8c9daf6..0b2bbb2 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -425,28 +425,54 @@ BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(c //======================================================================= //function : SetClassAttractorEntry //======================================================================= -void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry,const std::string& att_entry) // TODO finir +void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, const TopoDS_Face& FaceShape, const TopoDS_Shape& AttractorShape, double StartSize, double EndSize, double ActionRadius, double ConstantRadius) // TODO finir { - if (!_classAttractors[entry].compare(att_entry)){ - _classAttractors[entry] = att_entry; + + // The new attractor can't be defined on the same face as another sizemap + 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(); + } + } + BLSURFPlugin_Attractor myAttractor; + if (!_classAttractors[entry].GetAttractorShape().IsSame(AttractorShape)){ + myAttractor = BLSURFPlugin_Attractor(FaceShape, AttractorShape); //TODO calculer MapGrid + myAttractor.BuildMap(); + myAttractor.SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius); + _classAttractors[entry] = myAttractor; + NotifySubMeshesHypothesisModification(); + } + else { + _classAttractors[entry].SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius); + if (!myAttractor.IsMapBuilt()){ + myAttractor.BuildMap(); + } + NotifySubMeshesHypothesisModification(); + } + } -//======================================================================= -//function : GetClassAttractorEntry -//======================================================================= -std::string BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry) -{ - TAttractorMap::iterator it = _classAttractors.find( entry ); - if ( it != _classAttractors.end() ) - return it->second; - else - return "No_Such_Entry"; -} - +// //======================================================================= +// //function : GetClassAttractorEntry +// //======================================================================= +// std::string BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry) +// { +// TAttractorMap::iterator it = _classAttractors.find( entry ); +// if ( it != _classAttractors.end() ) +// return it->second; +// else +// return "No_Such_Entry"; +// } +// /*! - * \brief Return the attractor instances + * \brief Return the map of attractor instances */ BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) { diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index b30789d..743f90d 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -33,6 +33,7 @@ #include #include #include +#include "BLSURFPlugin_Attractor.hxx" // Parameters for work of BLSURF @@ -129,16 +130,15 @@ public: const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; } */ - typedef std::map TAttractorMap; + typedef std::map TAttractorMap; - void SetClassAttractorEntry(const std::string& entry,const std::string& att_entry); + void SetClassAttractorEntry(const std::string& entry, const TopoDS_Face& FaceShape, const TopoDS_Shape& AttractorShape, double StartSize, double EndSize, double ActionRadius, double ConstantRadius); std::string GetClassAttractorEntry(const std::string& entry); const TAttractorMap& _GetClassAttractorEntries() const { return _classAttractors; } /*! * \brief Return the attractors entries */ static TAttractorMap GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp); - /*! * To set/get/unset an enforced vertex diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 05e0061..4e5a339 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -579,6 +579,36 @@ void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* } +//============================================================================= + +void BLSURFPlugin_Hypothesis_i::SetClassAttractorEntry(const char* entry, const TopoDS_Face& FaceShape, const TopoDS_Shape& AttractorShape, double StartSize, double EndSize, double ActionRadius, double ConstantRadius) //TODO à finir + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + MESSAGE("ENGINE : SETATTRACTOR START ENTRY : " << entry); + // bool valueChanged = false; + try { + this->GetImpl()->SetClassAttractorEntry(entry, FaceShape, AttractorShape, StartSize, EndSize, ActionRadius, ConstantRadius); + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetClassAttractorEntry(entry,att_entry)"; + ExDescription.lineNumber = 0; + throw SALOME::SALOME_Exception(ExDescription); + } + 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 << "' )"; + // TODO enable dump +} + + //============================================================================= char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) @@ -627,6 +657,31 @@ char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry) //============================================================================= +// TODO coder cette fonction (utilisée pour savoir si la valeur a changé + +// char* BLSURFPlugin_Hypothesis_i::GetClassAttractorEntry(const char* entry) +// throw (SALOME::SALOME_Exception) +// { +// ASSERT(myBaseImpl); +// try { +// return CORBA::string_dup( this->GetImpl()->GetClassAttractorEntry(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::GetClassAttractorEntry(name)"; +// ExDescription.lineNumber = 0; +// throw SALOME::SALOME_Exception(ExDescription); +// } +// catch (SALOME_Exception& ex) { +// THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); +// } +// return 0; +// } + +//============================================================================= + void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry) { ASSERT(myBaseImpl); @@ -756,6 +811,30 @@ void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj) } +void BLSURFPlugin_Hypothesis_i::SetAttractor_Geom(GEOM::GEOM_Object_ptr GeomObj, GEOM::GEOM_Object_ptr Attractor, double StartSize, double EndSize, double ActionRadius, double ConstantRadius) +{ + ASSERT(myBaseImpl); + string entry; +// string att_entry; + entry=GeomObj->GetStudyEntry(); +// att_entry=Attractor->GetStudyEntry(); + TopoDS_Face FaceShape = TopoDS::Face(SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( GeomObj )); + TopoDS_Shape AttractorShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( Attractor ); + MESSAGE("IDL : GetName : " << GeomObj->GetName()); + MESSAGE("IDL : SETATTRACTOR () ");//<< entry << " , " << att_entry << ")"); + SetClassAttractorEntry( entry.c_str(), FaceShape, AttractorShape, StartSize, EndSize, ActionRadius, ConstantRadius); +} + +void BLSURFPlugin_Hypothesis_i::UnsetAttractor_Geom(GEOM::GEOM_Object_ptr GeomObj) +{ + ASSERT(myBaseImpl); + string entry; + entry=GeomObj->GetStudyEntry(); + MESSAGE("IDL : GetName : " << GeomObj->GetName()); + MESSAGE("IDL : UNSETATTRACTOR ( "<< entry << ")"); + UnsetEntry( entry.c_str()); + SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )"; +} /* @@ -1113,8 +1192,9 @@ bool BLSURFPlugin_Hypothesis_i::_setEnfVertex(const char* theFaceEntry, CORBA::D MESSAGE("Coords not found: add it in coordsList") newValue = true; } - else - MESSAGE("Coords already found") + else { + MESSAGE("Coords already found"); + } } catch (const std::invalid_argument& ex) { // no enforced vertex for entry diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index e3c2c60..8c9e2a6 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -127,6 +127,17 @@ class BLSURFPlugin_Hypothesis_i: char* GetAttractorEntry(const char* entry) throw (SALOME::SALOME_Exception); BLSURFPlugin::string_array* GetAttractorEntries(); + + + void SetAttractor_Geom(GEOM::GEOM_Object_ptr GeomObj, GEOM::GEOM_Object_ptr Attractor, double StartSize, double EndSize, double ActionRadius, double ConstantRadius ); + + void UnsetAttractor_Geom(GEOM::GEOM_Object_ptr GeomObj); + + void SetClassAttractorEntry(const char* entry,const TopoDS_Face& FaceShape, const TopoDS_Shape& AttractorShape, double StartSize, double EndSize, double ActionRadius, double ConstantRadius) throw (SALOME::SALOME_Exception); + + //char* GetAttractorEntry(const char* entry) throw (SALOME::SALOME_Exception); + + //BLSURFPlugin_Attractor GetClassAttractorEntries(); /*