*/
void SetSizeMapVertex(in double x, in double y, in double z, in double size);
double GetSizeMapVertex(in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
+ void RemoveSizeMapVertex(in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
GHS3DSizeMapVertexList GetSizeMapVerteces();
void ClearSizeMapVerteces();
};
#include "GHS3DPlugin_GHS3D.hxx"
#include "GHS3DPlugin_Hypothesis.hxx"
-#include <gp_Pnt.hxx>
-#include <TopAbs_State.hxx>
-#include <BRepClass3d_SolidClassifier.hxx>
+
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
}
map <int,int> aSmdsToGhs3dIdMap;
map <int,const SMDS_MeshNode*> aGhs3dIdToNodeMap;
-
- GHS3DPlugin_Hypothesis::TSizeMapVertexValues enforcedVerteces = GHS3DPlugin_Hypothesis::GetEnforcedVerteces(_hyp);
- int nbEnforcedVerteces = enforcedVerteces.size();
+ GHS3DPlugin_Hypothesis::TSizeMapVertexValues enforcedVerteces;
+ int nbEnforcedVerteces;
+ try {
+ enforcedVerteces = GHS3DPlugin_Hypothesis::GetEnforcedVerteces(_hyp);
+ nbEnforcedVerteces = enforcedVerteces.size();
+ }
+ catch(...) {
+ nbEnforcedVerteces = 0;
+ }
Ok = writePoints( aPointsFile, meshDS, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap, enforcedVerteces) &&
writeFaces ( aFacesFile, meshDS, aSmdsToGhs3dIdMap );
if (!Ok)
return error( SMESH_Comment("Can't write into ") << aPointsFileName);
+
+ GHS3DPlugin_Hypothesis::TSizeMapVertexValues enforcedVerteces;
+ int nbEnforcedVerteces;
+ try {
+ enforcedVerteces = GHS3DPlugin_Hypothesis::GetEnforcedVerteces(_hyp);
+ nbEnforcedVerteces = enforcedVerteces.size();
+ }
+ catch(...) {
+ nbEnforcedVerteces = 0;
+ }
- GHS3DPlugin_Hypothesis::TSizeMapVertexValues enforcedVerteces = GHS3DPlugin_Hypothesis::GetEnforcedVerteces(_hyp);
- int nbEnforcedVerteces = enforcedVerteces.size();
vector <const SMDS_MeshNode*> aNodeByGhs3dId;
Ok = (writeFaces ( aFacesFile, meshDS, aNodeByGhs3dId ) &&
//=======================================================================
GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen)
- : SMESH_Hypothesis(hypId, studyId, gen)
+ : SMESH_Hypothesis(hypId, studyId, gen),
+ myToMeshHoles(DefaultMeshHoles()),
+ myMaximumMemory(-1),
+ myInitialMemory(-1),
+ myOptimizationLevel(DefaultOptimizationLevel()),
+ myWorkingDirectory(DefaultWorkingDirectory()),
+ myKeepFiles(DefaultKeepFiles()),
+ myVerboseLevel(DefaultVerboseLevel()),
+ myToCreateNewNodes(DefaultToCreateNewNodes()),
+ myToUseBoundaryRecoveryVersion(DefaultToUseBoundaryRecoveryVersion()),
+ mySizeMapVerteces(DefaultSizeMapVerteces())
{
_name = "GHS3D_Parameters";
_param_algo_dim = 3;
-
- myToMeshHoles = DefaultMeshHoles();
- myMaximumMemory = -1;//DefaultMaximumMemory();
- myInitialMemory = -1;//DefaultInitialMemory();
- myOptimizationLevel = DefaultOptimizationLevel();
- myWorkingDirectory = DefaultWorkingDirectory();
- myKeepFiles = DefaultKeepFiles();
- myVerboseLevel = DefaultVerboseLevel();
- myToCreateNewNodes = DefaultToCreateNewNodes();
- myToUseBoundaryRecoveryVersion = DefaultToUseBoundaryRecoveryVersion();
- mySizeMapVerteces = DefaultSizeMapVerteces();
}
//=======================================================================
void GHS3DPlugin_Hypothesis::SetSizeMapVertex(double x, double y, double z, double size)
{
std::cout << "GHS3DPlugin_Hypothesis::SetSizeMapVertex(x,y,z,size)" << std::endl;
-// std::vector<double> coord (x,y,z);
- GHS3DSizeMapVertex* coord = new GHS3DSizeMapVertex;
- coord->x = x;
- coord->y = y;
- coord->z = z;
-// double coord[] = {x,y,z};
- mySizeMapVerteces[coord] = size;
+ bool found = false;
+ TSizeMapVertexValues::iterator it;
+ for (it = mySizeMapVerteces.begin() ; it != mySizeMapVerteces.end() ; ++it)
+ if ((it->first->x == x) and (it->first->y == y) and (it->first->z == z)) {
+ it->second = size;
+ found = true;
+ break;
+ }
+ if (not found) {
+ GHS3DSizeMapVertex* coord = new GHS3DSizeMapVertex;
+ coord->x = x;
+ coord->y = y;
+ coord->z = z;
+ mySizeMapVerteces[coord] = size;
+ }
NotifySubMeshesHypothesisModification();
}
throw std::invalid_argument(msg.str());
}
+//=======================================================================
+//function : RemoveSizeMapVertex
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::RemoveSizeMapVertex(double x, double y, double z)
+ throw (std::invalid_argument)
+{
+ TSizeMapVertexValues::const_iterator it;
+ bool found = false;
+ for (it = mySizeMapVerteces.begin() ; it != mySizeMapVerteces.end() ; ++it)
+ if ((it->first->x == x) and (it->first->y == y) and (it->first->z == z)) {
+ found = true;
+ break;
+ }
+ if (found) {
+ mySizeMapVerteces.erase(it->first);
+ NotifySubMeshesHypothesisModification();
+ }
+ else {
+ ostringstream msg ;
+ msg << "No enforced vertex at " << x << ", " << y << ", " << z;
+ throw std::invalid_argument(msg.str());
+ }
+}
+
//=======================================================================
//function : ClearSizeMapVerteces
//=======================================================================
GHS3DPlugin_Hypothesis::TSizeMapVertexValues GHS3DPlugin_Hypothesis::DefaultSizeMapVerteces()
{
std::cout << "GHS3DPlugin_Hypothesis::DefaultSizeMapVerteces()" << std::endl;
- GHS3DPlugin_Hypothesis::TSizeMapVertexValues myVerteces;
- return myVerteces;
+ return GHS3DPlugin_Hypothesis::TSizeMapVertexValues();
}
GHS3DPlugin_Hypothesis::TSizeMapVertexValues GHS3DPlugin_Hypothesis::GetEnforcedVerteces(const GHS3DPlugin_Hypothesis* hyp)
{
- return hyp->GetSizeMapVerteces();
+ return hyp ? hyp->GetSizeMapVerteces():DefaultSizeMapVerteces();
}
typedef std::map<GHS3DSizeMapVertex*,double> TSizeMapVertexValues;
void SetSizeMapVertex(double x, double y, double z, double size);
double GetSizeMapVertex(double x, double y, double z) throw (std::invalid_argument);
+ void RemoveSizeMapVertex(double x, double y, double z) throw (std::invalid_argument);
const TSizeMapVertexValues GetSizeMapVerteces() const { return mySizeMapVerteces; }
void ClearSizeMapVerteces();
const ::GHS3DPlugin_Hypothesis::TSizeMapVertexValues sizeMaps = this->GetImpl()->GetSizeMapVerteces();
int size = sizeMaps.size();
- std::cout << "size: " << size << std::endl;
+// std::cout << "size: " << size << std::endl;
result->length( size );
::GHS3DPlugin_Hypothesis::TSizeMapVertexValues::const_iterator it;
return result._retn();
}
+//=======================================================================
+//function : RemoveSizeMapVertex
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::RemoveSizeMapVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
+ throw (SALOME::SALOME_Exception)
+{
+ ASSERT(myBaseImpl);
+ try {
+ this->GetImpl()->RemoveSizeMapVertex(x,y,z);
+ SMESH::TPythonDump() << _this() << ".RemoveSizeMapVertex( " << x << ", " << y << ", " << z << " )";
+ }
+ catch (const std::invalid_argument& ex) {
+ SALOME::ExceptionStruct ExDescription;
+ ExDescription.text = ex.what();
+ ExDescription.type = SALOME::BAD_PARAM;
+ ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::RemoveSizeMapVertex(x,y,z)";
+ ExDescription.lineNumber = 0;
+ throw SALOME::SALOME_Exception(ExDescription);
+ }
+ catch (SALOME_Exception& ex) {
+ THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+ }
+}
+
//=======================================================================
//function : ClearSizeMapVerteces
//=======================================================================
*/
void SetSizeMapVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size);
CORBA::Double GetSizeMapVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception);
+ void RemoveSizeMapVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception);
GHS3DPlugin::GHS3DSizeMapVertexList* GetSizeMapVerteces();
void ClearSizeMapVerteces();
mySmpModel = new QStandardItemModel(0, SMP_NB_COLUMNS);
mySizeMapTableView = new QTableView(mySmpGroup);
mySizeMapTableView->setModel(mySmpModel);
+ mySizeMapTableView->setSortingEnabled(true);
mySizeMapTableView->setItemDelegateForColumn(SMP_SIZE_COLUMN,new DoubleLineEditDelegate(this));
anSmpLayout->addWidget(mySizeMapTableView, 1, 0, 9, 1);
QStringList sizeMapHeaders;
mySmpModel->setData(mySmpModel->index(row, SMP_SIZE_COLUMN),size);
mySmpModel->setItem( row, SMP_SIZE_COLUMN, new QStandardItem(QString::number(size,'f')) );
- std::cout << "mySmpModel->data(mySmpModel->index("<<row<<","<<SMP_X_COLUMN<<")).toDouble(): "
- << mySmpModel->data(mySmpModel->index(row,SMP_X_COLUMN)).toDouble() << std::endl;
- std::cout << "mySmpModel->data(mySmpModel->index("<<row<<","<<SMP_Y_COLUMN<<")).toDouble(): "
- << mySmpModel->data(mySmpModel->index(row,SMP_Y_COLUMN)).toDouble() << std::endl;
- std::cout << "mySmpModel->data(mySmpModel->index("<<row<<","<<SMP_Z_COLUMN<<")).toDouble(): "
- << mySmpModel->data(mySmpModel->index(row,SMP_Z_COLUMN)).toDouble() << std::endl;
- std::cout << "mySmpModel->data(mySmpModel->index("<<row<<","<<SMP_SIZE_COLUMN<<")).toDouble(): "
- << mySmpModel->data(mySmpModel->index(row,SMP_SIZE_COLUMN)).toDouble() << std::endl;
+// std::cout << "mySmpModel->data(mySmpModel->index("<<row<<","<<SMP_X_COLUMN<<")).toDouble(): "
+// << mySmpModel->data(mySmpModel->index(row,SMP_X_COLUMN)).toDouble() << std::endl;
+// std::cout << "mySmpModel->data(mySmpModel->index("<<row<<","<<SMP_Y_COLUMN<<")).toDouble(): "
+// << mySmpModel->data(mySmpModel->index(row,SMP_Y_COLUMN)).toDouble() << std::endl;
+// std::cout << "mySmpModel->data(mySmpModel->index("<<row<<","<<SMP_Z_COLUMN<<")).toDouble(): "
+// << mySmpModel->data(mySmpModel->index(row,SMP_Z_COLUMN)).toDouble() << std::endl;
+// std::cout << "mySmpModel->data(mySmpModel->index("<<row<<","<<SMP_SIZE_COLUMN<<")).toDouble(): "
+// << mySmpModel->data(mySmpModel->index(row,SMP_SIZE_COLUMN)).toDouble() << std::endl;
mySizeMapTableView->clearSelection();
mySizeMapTableView->scrollTo( mySmpModel->item( row, SMP_SIZE_COLUMN )->index() );
int row = 0;
for(it = data.mySizeMapVerteces.begin() ; it != data.mySizeMapVerteces.end(); it++ )
{
- double x = (*it).first->x;
- double y = (*it).first->y;
- double z = (*it).first->z;
- double size = (*it).second;
+ double x = it->first->x;
+ double y = it->first->y;
+ double z = it->first->z;
+ double size = it->second;
// SMP_X_COLUMN
mySmpModel->setData(mySmpModel->index(row, SMP_X_COLUMN),x);
mySmpModel->setItem( row, SMP_X_COLUMN, new QStandardItem(QString::number(x)) );
h->SetToUseBoundaryRecoveryVersion( h_data.myBoundaryRecovery );
if ( h->GetTextOption() != h_data.myTextOption )
h->SetTextOption ( h_data.myTextOption.toLatin1().constData() );
- std::cout << "Store params for size maps: " << (int) h_data.mySizeMapVerteces.size() << " enforced verteces" << std::endl;
+
+ int nbVertex = (int) h_data.mySizeMapVerteces.size();
+ GHS3DPlugin::GHS3DSizeMapVertexList_var vertexHyp = h->GetSizeMapVerteces();
+ int nbVertexHyp = vertexHyp->length();
+
+ std::cout << "Store params for size maps: " << nbVertex << " enforced verteces" << std::endl;
+ std::cout << "h->GetSizeMapVerteces()->length(): " << nbVertexHyp << std::endl;
+
+ // Some verteces were removed
+ if (nbVertex < nbVertexHyp) {
+ if (nbVertex == 0)
+ h->ClearSizeMapVerteces();
+ else {
+ // iterate over verteces of hypo
+// GHS3DPlugin_Hypothesis::TSizeMapVertexValues::const_iterator vertexHypIt;
+ for(int i = 0 ; i <nbVertexHyp ; i++) {
+// for(vertexHypIt = vertexHyp.begin() ; vertexHypIt != vertexHyp.end(); vertexHypIt++ ) {
+ double x = vertexHyp[i].x;
+ double y = vertexHyp[i].y;
+ double z = vertexHyp[i].z;
+ // vertex is removed
+ if (!smpVertexExists(x,y,z))
+ h->RemoveSizeMapVertex(x,y,z);
+ }
+ }
+ }
+
+// if ((int) h_data.mySizeMapVerteces.size() == 0)
+// if (h->GetSizeMapVerteces()->length() > 0)
+// h->ClearSizeMapVerteces();
+// else
+// h->ClearSizeMapVerteces();
+
TSizeMapVertexValues::const_iterator it;
- if (h_data.mySizeMapVerteces.size() == 0)
- if (h->GetSizeMapVerteces()->length() > 0)
- h->ClearSizeMapVerteces();
- else
- h->ClearSizeMapVerteces();
for(it = h_data.mySizeMapVerteces.begin() ; it != h_data.mySizeMapVerteces.end(); it++ ) {
double x = it->first->x;
double y = it->first->y;