raises (SALOME::SALOME_Exception);
/*!
- * Return all information abour a part.
+ * Return all information about a part.
* Assume this object encapsulates a distributed MED file.
*/
string getPartInfo(in string partName)
raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Remove the given part from the distributed MED file.
+ * Assume this object encapsulates a distributed MED file.
+ */
+ void removePart(in string partName)
+ raises (SALOME::SALOME_Exception);
//---------------------------------------------------------------------
// Algorithms
Mesh* pMesh,
int pPosition)
{
+ // debug
+ //cout << "INSERT PARTS BEFORE: " << endl;
+ //cout << (*this) << endl;
+
MeshDisPart* part = new MeshDisPart();
part->create(
// rename id of following parts
for (unsigned i = pPosition + 1 ; i < mParts.size() ; i++)
{
- mParts[i]->mId = i + 1;
+ mParts[i]->mId++;
+ }
+
+ // debug
+ //cout << "INSERT PARTS AFTER: " << endl;
+ //cout << (*this) << endl;
+}
+
+
+void MeshDis::removeParts(const char* pPrefixPartName)
+{
+ // debug
+ //cout << "REMOVE PARTS BEFORE: " << endl;
+ //cout << (*this) << endl;
+
+ if (pPrefixPartName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+
+ for (vector<MeshDisPart*>::iterator itPart = mParts.begin() ; itPart != mParts.end() ; itPart++)
+ {
+ MeshDisPart* currentPart = (*itPart);
+
+ if (startWith(currentPart->getPartName(), pPrefixPartName))
+ {
+ mParts.erase(itPart);
+
+ // decrement id of following parts
+ for (vector<MeshDisPart*>::iterator itPart2 = itPart ; itPart2 != mParts.end() ; itPart2++)
+ {
+ (*itPart2)->mId--;
+ }
+
+ itPart--;
+ if (currentPart->mMEDFileName != NULL)
+ {
+ remove(currentPart->mMEDFileName);
+ }
+
+ delete currentPart;
+ }
}
+
+ // debug
+ //cout << "REMOVE PARTS AFTER: " << endl;
+ //cout << (*this) << endl;
}
const char* originalFilename = part->getMEDFileName();
string strPrefix = removeExtension(originalFilename, ".med");
+cout << (*this) << endl;
//---------------------------------------------------------------------
// Decimates the given mesh
//---------------------------------------------------------------------
meshLow,
part->mId + 1);
}
+
+cout << (*this) << endl;
}
const char* pMEDFileName,
Mesh* pMesh,
int pPosition);
-
+
+ /**
+ * Removes all the part beginning by pPrefixPartName from this distributed mesh.
+ * \param pPrefixPartName name of the part.
+ */
+ void removeParts(const char* pPrefixPartName);
+
/**
* Returns the current number of parts in this distributed mesh.
* \return the current number of parts in this distributed mesh.
}
+void Obj::removeParts(const char* pPrefixPartName)
+{
+ // removePart() is only available for distributed MED file (not sequential MED file)
+ if ((mState != MULTIPR_OBJ_STATE_DIS) &&
+ (mState != MULTIPR_OBJ_STATE_DIS_MEM)) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
+
+ if (mMeshDis == NULL) throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
+
+ mMeshDis->removeParts(pPrefixPartName);
+ mState = MULTIPR_OBJ_STATE_DIS_MEM;
+}
+
+
vector<string> Obj::partitionneDomaine()
{
if (mState == MULTIPR_OBJ_STATE_SEQ_INIT) throw IllegalStateException("use setMesh() before", __FILE__, __LINE__);
* \return all information about a part.
*/
std::string getPartInfo(const char* pPartName) const;
+
+ /**
+ * Removes all the part beginning by pPrefixPartName from the distributed MED file.
+ * Assume this object encapsulates a distributed MED file.
+ * \param pPrefixPartName name of the part.
+ */
+ void removeParts(const char* pPrefixPartName);
+
//---------------------------------------------------------------------
// Algorithms
}
+bool multipr::startWith(const char* pStr, const char* pStrPrefix)
+{
+ int lenStr = strlen(pStr);
+
+ int i = 0;
+ while ((pStr[i] != '\0') && (pStrPrefix[i] != '\0') && (pStr[i] == pStrPrefix[i]))
+ {
+ i++;
+ }
+ return (pStrPrefix[i] == '\0');
+}
+
+
string multipr::removeExtension(const char* pFilename, const char* pExtension)
{
string strPrefix(pFilename);
void trim(char* pStr, char pChar=' ');
+/**
+ * Returns true iff the given string starts by prefix.
+ * \param pStr any valid C string ending with the char '\0'.
+ * \param pStrPrefix any valid C string ending with the char '\0'.
+ * \return true iff the given string starts by prefix.
+ */
+bool startWith(const char* pStr, const char* pStrPrefix);
+
+
/**
* Removes the extension (suffix) of a filename.
* Example: removeExtension("agregat100grains_12pas.med", ".med") -> "agregat100grains_12pas"
char* MULTIPR_Obj_i::getPartInfo(const char* pPartName)
- throw (SALOME::SALOME_Exception)
+ throw (SALOME::SALOME_Exception)
{
if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
}
+void MULTIPR_Obj_i::removePart(const char* pPartName)
+ throw (SALOME::SALOME_Exception)
+{
+ if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
+
+ mObj->removeParts(pPartName);
+}
+
+
MULTIPR_ORB::string_array* MULTIPR_Obj_i::partitionneDomaine()
throw (SALOME::SALOME_Exception)
{
char* getPartInfo(const char* pPartName)
throw (SALOME::SALOME_Exception);
+ /*!
+ * Removes the given part from the distributed MED file.
+ * Assume this object encapsulates a distributed MED file.
+ * \param pPartName name of the part.
+ */
+ void removePart(const char* pPartName)
+ throw (SALOME::SALOME_Exception);
+
+
//---------------------------------------------------------------------
// Algorithms
//---------------------------------------------------------------------
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
+#include <qmessagebox.h>
using namespace std;
false,
this,
SLOT(OnDecimate()));
+
+ createAction(
+ ACTION_REMOVE,
+ tr("TLT_REMOVE"),
+ QIconSet(),
+ tr("MEN_REMOVE"),
+ tr("STS_REMOVE"),
+ 0,
+ aParent,
+ false,
+ this,
+ SLOT(OnRemove()));
QPixmap aPixmapSaveMEDFile = aResourceMgr->loadPixmap("MULTIPR", tr("ICON_SAVE_MED"));
createMenu(ACTION_SAVE, aMenuId, 10);
createMenu(ACTION_SPLIT, aMenuId, 10);
createMenu(ACTION_DECIMATE, aMenuId, 10);
+ createMenu(ACTION_REMOVE, aMenuId, 10);
//-------------------------------------------------------------------------
// create toolbars
QtxPopupMgr* mgr = popupMgr();
mgr->insert( action(ACTION_SPLIT), -1, -1, -1 );
mgr->insert( action(ACTION_DECIMATE), -1, -1, -1 );
+ mgr->insert( action(ACTION_REMOVE), -1, -1, -1 );
mgr->insert( action(ACTION_SAVE), -1, -1, -1 );
QString aRule = "client='ObjectBrowser' and selcount>=1"; // $type in {'VISU::TMESH'}";
mgr->setRule(action(ACTION_SPLIT), aRule, true);
mgr->setRule(action(ACTION_DECIMATE), aRule, true);
+ mgr->setRule(action(ACTION_REMOVE), aRule, true);
mgr->setRule(action(ACTION_SAVE), aRule, true);
//-------------------------------------------------------------------------
catch (...)
{
}
+
+ getApp()->updateObjectBrowser();
}
return;
}
+ // for each selected part, check if there are lower resolution
+ // and then propose to remove them before processing new decimation
+ QStringList partNameLowerResolution;
+ for (QStringList::const_iterator it = mSelectedParts.begin(), last = mSelectedParts.end(); it != last; it++)
+ {
+ const QString& partName = (*it);
+ QString partNameLow = partName + "_LOW";
+ QString partNameMed = partName + "_MED";
+ const char* strPartNameLow = partNameLow.latin1();
+ const char* strPartNameMed = partNameMed.latin1();
+
+ if (isPartExist(strPartNameLow))
+ {
+ partNameLowerResolution.push_back(partNameLow);
+ cout << "Part to be removed: " << partNameLow << endl;
+ }
+
+ if (isPartExist(strPartNameMed))
+ {
+ partNameLowerResolution.push_back(partNameMed);
+ cout << "Part to be removed: " << partNameMed << endl;
+ }
+ }
+
+ if (partNameLowerResolution.count() > 0)
+ {
+ if (QMessageBox::question(
+ getApp()->desktop(),
+ tr("Decimation: remove previous results"),
+ tr("Do you want to remove previous results?"),
+ tr("&Yes"), tr("&No"),
+ QString::null, 0, 1 ) )
+ {
+ return;
+ }
+
+ QApplication::setOverrideCursor(Qt::waitCursor);
+
+ try
+ {
+ for (QStringList::const_iterator it = partNameLowerResolution.begin(), last = partNameLowerResolution.end(); it != last; it++)
+ {
+ const QString& partName = (*it);
+ cout << "Remove " << partName.latin1() << endl;
+ mMULTIPRObj->removePart(partName.latin1());
+ }
+
+ }
+ catch(...)
+ {
+ SUIT_MessageBox::error1(
+ getApp()->desktop(),
+ "Remove error",
+ "Error while removing previous results",
+ tr("OK") );
+ }
+
+ QApplication::restoreOverrideCursor();
+
+ getApp()->updateObjectBrowser();
+ }
+
MULTIPR_GUI_DecimateDlg* dialog = new MULTIPR_GUI_DecimateDlg(this);
dialog->exec();
delete dialog;
}
+void MULTIPR_GUI::OnRemove()
+{
+ retrieveSelectedParts();
+
+ if (mSelectedParts.count() == 0)
+ {
+ SUIT_MessageBox::warn1(
+ getApp()->desktop(),
+ "Remove warning",
+ "No parts selected",
+ tr("OK") );
+ return;
+ }
+
+ if (QMessageBox::question(
+ getApp()->desktop(),
+ tr("Remove selected part(s)"),
+ tr("Do you want to remove selected part(s)?"),
+ tr("&Yes"), tr("&No"),
+ QString::null, 0, 1 ) )
+ {
+ return;
+ }
+
+ QApplication::setOverrideCursor(Qt::waitCursor);
+
+ try
+ {
+ for (QStringList::const_iterator it = mSelectedParts.begin(), last = mSelectedParts.end(); it != last; it++)
+ {
+ const QString& partName = (*it);
+ cout << "Remove " << partName.latin1() << endl;
+ mMULTIPRObj->removePart(partName.latin1());
+ }
+
+ }
+ catch(...)
+ {
+ SUIT_MessageBox::error1(
+ getApp()->desktop(),
+ "Remove error",
+ "Error while removing selected part(s)",
+ tr("OK") );
+ }
+
+ QApplication::restoreOverrideCursor();
+
+ getApp()->updateObjectBrowser();
+}
+
+
void MULTIPR_GUI::OnSave()
{
QApplication::setOverrideCursor(Qt::waitCursor);
}
+bool MULTIPR_GUI::isPartExist(const char* partName)
+{
+ if (mMULTIPRObj == NULL) return false;
+
+ MULTIPR_ORB::string_array* listParts = mMULTIPRObj->getParts();
+ for (int i=0 ; i<listParts->length() ; i++)
+ {
+ const char* strItem = (*listParts)[i];
+ if (strcmp(strItem, partName) == 0)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
//*****************************************************************************
// Super class Data Object implementation
//*****************************************************************************
void OnPartition1();
void OnPartition2();
void OnDecimate();
+ void OnRemove();
void OnSave();
void retrieveSelectedParts();
+ bool isPartExist(const char* partName);
protected:
virtual CAM_DataModel* createDataModel();
{
ACTION_IMPORT_MED = 190,
ACTION_SAVE,
+ ACTION_REMOVE,
ACTION_SPLIT,
ACTION_DECIMATE
};
}
QDialog::accept();
- mModule->getAppli()->updateObjectBrowser();
}
for (QStringList::const_iterator it = partsList.begin(), last = partsList.end(); it != last; it++)
{
const QString& partName = (*it);
- cout << "Split " << partName.latin1() << " #parts=" << nbParts << " splitter=" << strSplitter;
+ cout << "Split " << partName.latin1() << " #parts=" << nbParts << " splitter=" << strSplitter << endl;
mModule->getMULTIPRObj()->partitionneGrain(partName.latin1(), nbParts, partitionner);
}
msgid "STS_DECIMATE"
msgstr "Decimate selected parts (build two new meshes at lower resolution)"
+msgid "TLT_REMOVE"
+msgstr "Remove"
+
+msgid "MEN_REMOVE"
+msgstr "Remove"
+
+msgid "STS_DECIMATE"
+msgstr "Remove selected parts"
+
msgid "TLT_SAVE"
msgstr "Save distributed mesh"