- Compilation with option --without-gui is OK (engine does not depend on GUI anymore ...)
- Multi-study now fully available
- Works with stand-alone CPP container
#include <SMESH_Gen.hxx>
#include <SMESH_Mesh.hxx>
#include <SMESH_ControlsDef.hxx>
-#include <SMESHGUI_Utils.h>
#include <SMESHDS_Mesh.hxx>
#include <SMDS_MeshElement.hxx>
#include <fenv.h>
#endif
-#include <GeomSelectionTools.h>
-
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <gp_XY.hxx>
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
_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());
PyRun_SimpleString("from math import *");
PyGILState_Release(gstate);
-
+
FaceId2SizeMap.clear();
EdgeId2SizeMap.clear();
VertexId2SizeMap.clear();
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
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;
throw;
return projector.LowerDistanceParameter();
}
+
+/////////////////////////////////////////////////////////
+TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry)
+{
+ MESSAGE("BLSURFPlugin_BLSURF::entryToShape"<<entry );
+ TopoDS_Shape S = TopoDS_Shape();
+ SALOMEDS::SObject_var aSO = myStudy->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)
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();
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;
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;
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){
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();
ostringstream attractorFunction;
attractorFunction << "def f(u,v): return ";
attractorFunction << _smp_phy_size << "-(" << _smp_phy_size <<"-" << a << ")";
- attractorFunction << "*exp(-((u-("<<u0<<"))*(u-("<<u0<<"))+(v-("<<v0<<"))*(v-("<<v0<<")))/(" << b << "*" << b <<"))";
+ attractorFunction << "*exp(-((u-("<<u0<<"))*(u-("<<u0<<"))+(v-("<<v0<<"))*(v-("<<v0<<")))/(" << b << "*" << b <<"))";
MESSAGE("Python function for attractor:" << std::endl << attractorFunction.str());
}
*/
}
- }
+ }
// if (HasSizeMapOnFace){
context_set_message_callback(ctx, message_callback, &_comment);
cad_t *c = cad_new(ctx);
-
+
blsurf_session_t *bls = blsurf_session_new(ctx);
-
+
SetParameters(_hypothesis, bls);
Standard_Real v_max;
*/
int iface = 0;
- string bad_end = "return";
+ string bad_end = "return";
for (TopExp_Explorer face_iter(aShape,TopAbs_FACE);face_iter.More();face_iter.Next()) {
TopoDS_Face f=TopoDS::Face(face_iter.Current());
if (fmap.FindIndex(f) > 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());
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()){
}
}
if (npts != 2) {
- // should not happen
+ // should not happen
MESSAGE("An edge does not have 2 extremities.");
} else {
if (d1 < d2)
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];
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){
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)));
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)));
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)));
// 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
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
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();
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;
#include <Python.h>
#include "SMESH_2D_Algo.hxx"
#include "SMESH_Mesh.hxx"
+#include <SMESH_Gen_i.hxx>
+#include <SALOMEconfig.h>
+#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,
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
//=============================================================================
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 ),
{
MESSAGE( "BLSURFPlugin_BLSURF_i::BLSURFPlugin_BLSURF_i" );
myBaseImpl = new ::BLSURFPlugin_BLSURF( theGenImpl->GetANewId(),
- theStudyId,
- theGenImpl );
+ theStudyId,
+ theGenImpl );
}
//=============================================================================
public:
// Constructor
BLSURFPlugin_BLSURF_i( PortableServer::POA_ptr thePOA,
- int theStudyId,
- ::SMESH_Gen* theGenImpl );
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl );
// Destructor
virtual ~BLSURFPlugin_BLSURF_i();
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
-# header files
+# header files
salomeinclude_HEADERS = \
BLSURFPlugin_BLSURF.hxx \
BLSURFPlugin_BLSURF_i.hxx \
$(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
#include <QRadioButton>
#include <LightApp_SelectionMgr.h>
-#include <SalomeApp_Application.h>
+#include <SalomeApp_Application.h>
#include <SALOME_ListIO.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
#include <GEOM_Client.hxx>
#include <TopoDS_Shape.hxx>
#include <SMESH_Gen_i.hxx>
-#include <boost/shared_ptr.hpp>
+#include <boost/shared_ptr.hpp>
#include <structmember.h>
// #include <GeomSelectionTools.h>
};
/**************************************************
- Begin initialization Python structures and objects
+ Begin initialization Python structures and objects
***************************************************/
typedef struct {
}
/*************************************************
-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;
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);
* */
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;
}
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() )
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 );
myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup );
aStdLayout->addWidget( myDecimesh, row++, 0, 1, 2 );
-
+
// advanced parameters
myAdvGroup = new QWidget();
QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
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);
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" ) );
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()));
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 ) {
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 );
Qt::ItemIsEditable |
Qt::ItemIsEnabled );
}
-
+
mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
guiHyp += name + " = " + value + "; ";
}
}
-
+
// SizeMap
row = 0, nbRows = mySizeMapTable->rowCount();
for ( ; row < nbRows; ++row )
if ( that->mySMPMap.contains(entry) )
guiHyp += entry + " = " + that->mySMPMap[entry] + "; ";
}
-
+
MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
return guiHyp;
{
myOptionTable->setFocus();
QMenu* menu = (QMenu*)( a->parent() );
-
+
int idx = menu->actions().indexOf( a );
QString idStr = QString("%1").arg( idx );
QString option = myOptions[idx].in();
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 );
}
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<int> selectedRows;
- QList<QTableWidgetItem*> selected = myOptionTable->selectedItems();
+ QList<QTableWidgetItem*> selected = myOptionTable->selectedItems();
QTableWidgetItem* item;
foreach( item, selected ) {
int row = item->row();
int row;
foreach( item, selected ) {
row = item->row();
- if ( !selectedRows.contains( row ) )
+ if ( !selectedRows.contains( row ) )
selectedRows.append( row );
}
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);
}
}
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 ) );
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)
MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
-
+
if (not that->mySMPMap.contains(myEntry)) {
MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
return false;
else if (that->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)){
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){
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() );
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());
// 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(),
}
}
}*/
-
+
QString BLSURFPluginGUI_HypothesisCreator::caption() const
{
return tr( "BLSURF_TITLE" );
else
return 0;
}
+
#
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
#include "GeomSelectionTools.h"
-#include <sstream>
-#include <LightApp_SelectionMgr.h>
-#include <SalomeApp_Application.h>
-#include <SUIT_Session.h>
+#include <LightApp_SelectionMgr.h>
+#include <SalomeApp_Application.h>
+#include <SUIT_Session.h>
-#include <SALOME_ListIteratorOfListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
#include <GEOM_Client.hxx>
-#include <SMESH_Gen_i.hxx>
#include <SMESHGUI_Utils.h>
-#include <boost/shared_ptr.hpp>
+#include <boost/shared_ptr.hpp>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <Handle_Geom_Surface.hxx>
#include <BRepAdaptor_Surface.hxx>
+#include "utilities.h"
+
+#include "SALOME_LifeCycleCORBA.hxx"
+#include <sstream>
/*!
- * Constructor
+ * Constructor
* @param aStudy pointer to the Study
*
*/
}
/*!
- * 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<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
if (anApp)
- return dynamic_cast<LightApp_SelectionMgr*>( 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<LightApp_SelectionMgr*>( 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
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();
/*!
* Return the entry of the first selected Object
* @return the entry of the first selected Object
- */
+ */
std::string GeomSelectionTools::getFirstSelectedEntry()
{
Handle(SALOME_InteractiveObject) anIO;
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 ))
}
return entry;
}
-
+
/*!
* Retrieve the name from the entry of the object
* @param entry the entry of the object
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;
* @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"<<entry );
TopoDS_Shape S = TopoDS_Shape();
_PTR(SObject) aSO = myStudy->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<GEOM::GEOM_Object>(aRefSObj);
- }
- // If selected object is a reference is not a reference
- else {
- if ( aSO->GetFatherComponent()->ComponentDataType() == "GEOM")
- aShape = SMESH::SObjectToInterface<GEOM::GEOM_Object>(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<GEOM::GEOM_Object>(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.
* 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();
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;
}
+
+
+
// File : GeomSelectionTools.h
// Authors : Nicolas GEIMER (OCC)
// ---
-
-
+#ifndef _GEOMSELECTIONTOOLS_H_
+#define _GEOMSELECTIONTOOLS_H_
#include "SALOMEDSClient.hxx"
#include "SALOME_InteractiveObject.hxx"
#include <SALOME_ListIO.hxx>
+#include <SalomeApp_Application.h>
#include <TopoDS_Shape.hxx>
#include <GeomAbs_SurfaceType.hxx>
-class LightApp_SelectionMgr;
+class LightApp_SelectionMgr;
/*!
{
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();
};
+#endif // _GEOMSELECTIONTOOLS_H_
\ No newline at end of file