*/
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
//--------------------------------------------------------------------
in double tlow,
in double radius)
raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Return useful information to configure decimation parameters.
+ * Depends on part, field and filter: generic operation.
+ */
+ string evalDecimationParams(
+ in string partName,
+ in string fieldName,
+ in long fieldIt,
+ in string filterName,
+ in string filterParams)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Remove all the parts starting with the given prefix from the distributed MED file.
+ * Assume this object encapsulates a distributed MED file.
+ */
+ void removeParts(in string prefixPartName)
+ raises (SALOME::SALOME_Exception);
//---------------------------------------------------------------------
// i/o
*pOutGradAvg = 0.0;
int count = 0;
+ cout << "numElements=" << numElements << endl;
+ cout << "num gauss pt by elt=" << numGaussPointsByElt << endl;
// for each element
for (int itElt = 0 ; itElt < numElements ; itElt++)
{
}
-vector<string> Mesh::getNameFields() const
+vector<string> Mesh::getNameScalarFields() const
{
vector<string> res;
for (int itField = 0 ; itField < mFields.size() ; itField++)
{
Field* currentField = mFields[itField];
- res.push_back(currentField->getName());
+
+ // only get scalar fields, not vectorial fields
+ // (because, currently, decimation can only be performed on scalar fields)
+ if (currentField->getNumberOfComponents() == 1)
+ {
+ res.push_back(currentField->getName());
+ }
}
return res;
const char* getName() const { return mMeshName; }
/**
- * Returns the name of all the fields.
- * \return the name of all the fields.
+ * Returns the name of all the scalar fields.
+ * \return the name of all the scalar fields.
*/
- std::vector<std::string> getNameFields() const;
+ std::vector<std::string> getNameScalarFields() const;
/**
* Returns the number of iteration for a given field.
#include "MULTIPR_MeshDis.hxx"
#include "MULTIPR_Mesh.hxx"
+#include "MULTIPR_DecimationFilter.hxx"
#include "MULTIPR_Utils.hxx"
#include "MULTIPR_Globals.hxx"
#include "MULTIPR_API.hxx"
if (pPrefixPartName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ char strPrefix[256];
+ sprintf(strPrefix, "%s_", pPrefixPartName);
+
for (vector<MeshDisPart*>::iterator itPart = mParts.begin() ; itPart != mParts.end() ; itPart++)
{
MeshDisPart* currentPart = (*itPart);
- if (startWith(currentPart->getPartName(), pPrefixPartName))
+ // remove part which have the same name and all sub_parts
+ // e.g. if pPrefixPartName="PART_4" => remove "PART_4" and "PART_4_*", but not "PART41"
+ if ((strcmp(currentPart->getPartName(), pPrefixPartName) == 0) ||
+ startWith(currentPart->getPartName(), strPrefix))
{
mParts.erase(itPart);
case MeshDisPart::MULTIPR_KEEP_AS_IT:
case MeshDisPart::MULTIPR_WRITE_PARTS:
{
- vector<pair<string, int> > tmp = multipr::getListFields(mParts[0]->getMEDFileName());
+ vector<pair<string, int> > tmp = multipr::getListScalarFields(mParts[0]->getMEDFileName());
for (int i = 0 ; i < tmp.size() ; i++)
{
}
case MeshDisPart::MULTIPR_WRITE_MESH:
- return mParts[0]->mMesh->getNameFields();
+ return mParts[0]->mMesh->getNameScalarFields();
default:
throw IllegalStateException("", __FILE__, __LINE__);
case MeshDisPart::MULTIPR_KEEP_AS_IT:
case MeshDisPart::MULTIPR_WRITE_PARTS:
{
- vector<pair<string, int> > tmp = multipr::getListFields(mParts[0]->getMEDFileName());
+ vector<pair<string, int> > tmp = multipr::getListScalarFields(mParts[0]->getMEDFileName());
for (int i = 0 ; i < tmp.size() ; i++)
{
part->mId + 1);
}
-cout << (*this) << endl;
+ // debug
+ //cout << (*this) << endl;
+}
+
+
+string MeshDis::evalDecimationParams(
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ const char* pFilterParams)
+{
+ MeshDisPart* part = findPart(pPartName);
+ if (part == NULL) return "";
+
+ try
+ {
+ if (part->mMesh == NULL)
+ {
+ part->readMED();
+ }
+
+ multipr::DecimationFilter* filter = multipr::DecimationFilter::create(pFilterName);
+ if (filter == NULL) return "";
+
+ multipr::DecimationFilterGradAvg* filterGrad = dynamic_cast<multipr::DecimationFilterGradAvg*>(filter);
+
+ if (filterGrad != NULL)
+ {
+ int mode;
+
+ int ret = sscanf(pFilterParams, "%d", &mode);
+
+ // mode 2 = GET RADIUS
+ if ((ret == 1) && (mode == 2))
+ {
+ double radius = part->mMesh->evalDefaultRadius(8);
+ char res[256];
+ sprintf(res, "%f", radius);
+ return res;
+ }
+
+ float radius;
+ int boxing;
+
+ ret = sscanf(pFilterParams, "%d %f %d", &mode, &radius, &boxing);
+
+ // mode 1 = GET GRADIENT MIN, MAX and AVG
+ if ((ret == 3) && (mode == 1))
+ {
+ double gradMin = 0.1, gradAvg = 0.15, gradMax = 0.2;
+
+ filterGrad->getGradientInfo(
+ part->mMesh,
+ pFieldName,
+ pFieldIt,
+ radius,
+ boxing,
+ &gradMin,
+ &gradAvg,
+ &gradMax);
+
+ char res[2048];
+ sprintf(res, "%f %f %f", gradMin, gradAvg, gradMax);
+ return res;
+ }
+ }
+
+ delete filter;
+ }
+ catch(...)
+ {
+ return "";
+ }
}
/**
* Removes all the part beginning by pPrefixPartName from this distributed mesh.
+ * Example: if pPrefixPartName="PART_4" => remove "PART_4" and all sub-parts "PART_4_*", but not "PART41".
* \param pPrefixPartName name of the part.
*/
void removeParts(const char* pPrefixPartName);
med_float pTLow,
med_float pRadius,
int pBoxing = 100);
+
+ /**
+ * Returns useful information to configure decimation parameters.
+ * Depends on part, field and filter: generic operation.
+ * \param pPartName name of the part.
+ * \param pFieldName name of the field used for decimation.
+ * \param pFieldIt iteration (time step) of the field.
+ * \param pFilterName name of the filter to be used.
+ * \param pFilterParams params to be used with the filter (depends on filter; this string will be parsed).
+ * \return
+ */
+ std::string evalDecimationParams(
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ const char* pFilterParams);
//---------------------------------------------------------------------
// I/O
(mState == MULTIPR_OBJ_STATE_SEQ))
{
// CASE 1: sequential MED file
- vector<pair<string, int> > tmp = multipr::getListFields(mMEDfilename.c_str());
+ vector<pair<string, int> > tmp = multipr::getListScalarFields(mMEDfilename.c_str());
vector<string> res;
for (int i = 0 ; i < tmp.size() ; i++)
(mState == MULTIPR_OBJ_STATE_SEQ))
{
// CASE 1: sequential MED file
- vector<pair<string, int> > tmp = multipr::getListFields(mMEDfilename.c_str());
+ vector<pair<string, int> > tmp = multipr::getListScalarFields(mMEDfilename.c_str());
for (int i = 0 ; i < tmp.size() ; i++)
{
}
+string Obj::evalDecimationParams(
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ const char* pFilterParams)
+{
+ // decimePartition() is only available for distributed MED file (not sequential MED file)
+ if ((mState != MULTIPR_OBJ_STATE_DIS_MEM) &&
+ (mState != MULTIPR_OBJ_STATE_DIS)) throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
+
+ if (mMeshDis == NULL) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
+
+ string res = mMeshDis->evalDecimationParams(
+ pPartName,
+ pFieldName,
+ pFieldIt,
+ pFilterName,
+ pFilterParams);
+
+ return res;
+}
+
+
vector<string> Obj::getListParts() const
{
if (mMeshDis == NULL) throw IllegalStateException("not a distributed mesh", __FILE__, __LINE__);
/**
* Removes all the part beginning by pPrefixPartName from the distributed MED file.
+ * Example: if pPrefixPartName="PART_4" => remove "PART_4" and all sub-parts "PART_4_*", but not "PART41".
* Assume this object encapsulates a distributed MED file.
* \param pPrefixPartName name of the part.
*/
double pRadius,
int pBoxing);
+ /**
+ * Returns useful information to configure decimation parameters.
+ * Depends on part, field and filter: generic operation.
+ * \param pPartName name of the part.
+ * \param pFieldName name of the field used for decimation.
+ * \param pFieldIt iteration (time step) of the field.
+ * \param pFilterName name of the filter to be used.
+ * \param pFilterParams params to be used with the filter (depends on filter; this string will be parsed).
+ */
+ std::string evalDecimationParams(
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ const char* pFilterParams);
+
+
//---------------------------------------------------------------------
// I/O
//---------------------------------------------------------------------
}
-vector<pair<string,int> > multipr::getListFields(const char* pMEDfilename)
+vector<pair<string,int> > multipr::getListScalarFields(const char* pMEDfilename)
{
if (pMEDfilename == NULL) throw multipr::NullArgumentException("", __FILE__, __LINE__);
/**
- * For each field in a sequential MED file, returns its name and the related number of iterations.
- * \param pMEDfilename name of any valid sequential MED file; must not be NULL.
- * \return a list of (name, #iterations).
- * \throw NullArgumentException if pMEDfilename is NULL.
- * \throw IOException if any other error occurs while reading MED file.
- */
- std::vector<std::pair<std::string, int> > getListFields(const char* pMEDfilename);
+ * For each scalar field in a sequential MED file, returns its name and the related number of iterations.
+ * Do not returns info about vectorial fields (because, currently, decimation can only be performed on scalar fields).
+ * \param pMEDfilename name of any valid sequential MED file; must not be NULL.
+ * \return a list of (name, #iterations).
+ * \throw NullArgumentException if pMEDfilename is NULL.
+ * \throw IOException if any other error occurs while reading MED file.
+ */
+ std::vector<std::pair<std::string, int> > getListScalarFields(const char* pMEDfilename);
} // namespace MULTIPR
}
-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* MULTIPR_Obj_i::evalDecimationParams(
+ const char* pPartName,
+ const char* pFieldName,
+ CORBA::Long pFieldIt,
+ const char* pFilterName,
+ const char* pFilterParams)
+ throw (SALOME::SALOME_Exception)
+{
+ if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
+
+ try
+ {
+ string res = mObj->evalDecimationParams(
+ pPartName,
+ pFieldName,
+ pFieldIt,
+ pFilterName,
+ pFilterParams);
+
+ return CORBA::string_dup(res.c_str());
+
+ }
+ catch (multipr::RuntimeException& e)
+ {
+ e.dump(cout);
+ THROW_SALOME_CORBA_EXCEPTION("Unable to evaluate decimation parameters", SALOME::INTERNAL_ERROR);
+ }
+}
+
+
+void MULTIPR_Obj_i::removeParts(const char* pPrefixPartName)
+ throw (SALOME::SALOME_Exception)
+{
+ if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
+
+ mObj->removeParts(pPrefixPartName);
+}
+
+
void MULTIPR_Obj_i::save()
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
CORBA::Double pTlow,
CORBA::Double pRadius)
throw (SALOME::SALOME_Exception);
-
+
+ /**
+ * Returns useful information to configure decimation parameters.
+ * Depends on part, field and filter: generic operation.
+ * \param pPartName name of the part.
+ * \param pFieldName name of the field used for decimation.
+ * \param pFieldIt iteration (time step) of the field.
+ * \param pFilterName name of the filter to be used.
+ * \param pFilterParams params to be used with the filter (depends on filter; this string will be parsed).
+ */
+ char* evalDecimationParams(
+ const char* pPartName,
+ const char* pFieldName,
+ CORBA::Long pFieldIt,
+ const char* pFilterName,
+ const char* pFilterParams)
+ throw (SALOME::SALOME_Exception);
+
+ /*!
+ * Removes all the parts starting with "pPrefixPartName" from the distributed MED file.
+ * Example: if pPrefixPartName="PART_4" => remove "PART_4" and all sub-parts "PART_4_*", but not "PART41".
+ * Assume this object encapsulates a distributed MED file.
+ * \param pPrefixPartName name of the part.
+ */
+ void removeParts(const char* pPrefixPartName)
+ throw (SALOME::SALOME_Exception);
+
//---------------------------------------------------------------------
// I/O
//---------------------------------------------------------------------
{
// display list of fields contained in the MED file
- vector<pair<string,int> > res = multipr::getListFields(g_medFilename);
+ vector<pair<string,int> > res = multipr::getListScalarFields(g_medFilename);
cout << "List of fields in this MED file:" << endl;
for (unsigned i = 0 ; i < res.size() ; i++)
{
this->application()->desktop(),
true,
tr("USE_BUILD_PROGRESS") );
+
fd->setCaption(tr("MEN_IMPORT_FROM_MED_FILE"));
fd->setFilters(aFilter);
fd->exec();
}
QApplication::restoreOverrideCursor();
- try
+ if (mMULTIPRObj != NULL)
{
- if (mMULTIPRObj->isValidSequentialMEDFile())
+ try
{
- OnPartition1();
+ if (mMULTIPRObj->isValidSequentialMEDFile())
+ {
+ OnPartition1();
+ }
}
+ catch (...)
+ {
+ }
+
+ getApp()->updateObjectBrowser();
}
- catch (...)
- {
- }
-
- getApp()->updateObjectBrowser();
}
void MULTIPR_GUI::OnPartition1()
{
+ // check if MULTIPRObj exists
+ if (mMULTIPRObj == NULL)
+ {
+ return;
+ }
+
MULTIPR_GUI_Partition1Dlg* dialog = new MULTIPR_GUI_Partition1Dlg(this);
dialog->exec();
delete dialog;
void MULTIPR_GUI::OnPartition2()
{
+ // check if MULTIPRObj exists
+ if (mMULTIPRObj == NULL)
+ {
+ return;
+ }
+
retrieveSelectedParts();
if (mSelectedParts.count() == 0)
return;
}
+ if (!removeLowerResolution())
+ {
+ return;
+ }
+
MULTIPR_GUI_Partition2Dlg* dialog = new MULTIPR_GUI_Partition2Dlg(this);
dialog->exec();
delete dialog;
void MULTIPR_GUI::OnDecimate()
{
+ // check if MULTIPRObj exists
+ if (mMULTIPRObj == NULL)
+ {
+ return;
+ }
+
retrieveSelectedParts();
if (mSelectedParts.count() == 0)
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++)
+ if (!removeLowerResolution())
{
- 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();
+ return;
}
MULTIPR_GUI_DecimateDlg* dialog = new MULTIPR_GUI_DecimateDlg(this);
void MULTIPR_GUI::OnRemove()
{
+ // check if MULTIPRObj exists
+ if (mMULTIPRObj == NULL)
+ {
+ return;
+ }
+
retrieveSelectedParts();
if (mSelectedParts.count() == 0)
{
const QString& partName = (*it);
cout << "Remove " << partName.latin1() << endl;
- mMULTIPRObj->removePart(partName.latin1());
+ mMULTIPRObj->removeParts(partName.latin1());
}
}
void MULTIPR_GUI::OnSave()
{
+ // check if MULTIPRObj exists
+ if (mMULTIPRObj == NULL)
+ {
+ return;
+ }
+
QApplication::setOverrideCursor(Qt::waitCursor);
try
}
+bool MULTIPR_GUI::removeLowerResolution()
+{
+ // for each selected part, check if there are lower resolution
+ // and then propose to remove them before performing new process
+ 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("Remove previous results"),
+ tr("Do you want to remove previous results?"),
+ tr("&Yes"), tr("&No"),
+ QString::null, 0, 1 ) )
+ {
+ return false;
+ }
+
+ 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->removeParts(partName.latin1());
+ }
+
+ }
+ catch(...)
+ {
+ SUIT_MessageBox::error1(
+ getApp()->desktop(),
+ "Remove error",
+ "Error while removing previous results",
+ tr("OK") );
+ }
+
+ QApplication::restoreOverrideCursor();
+
+ getApp()->updateObjectBrowser();
+ }
+
+ return true;
+}
+
+
//*****************************************************************************
// Super class Data Object implementation
//*****************************************************************************
void MULTIPR_GUI_DataModel::build()
{
- MULTIPR_GUI_DataObject_Module* modelRoot = dynamic_cast<MULTIPR_GUI_DataObject_Module*>(root());
-
- if (!modelRoot)
- {
- // root is not set yet
- modelRoot = new MULTIPR_GUI_DataObject_Module(this, NULL, "MULTIPR");
- setRoot(modelRoot);
- }
-
- MULTIPR_ORB::MULTIPR_Obj_ptr obj = mMULTIPR_GUI->getMULTIPRObj();
-
- if (obj != NULL)
+ try
{
- MULTIPR_ORB::string_array* listParts = obj->getParts();
+ MULTIPR_GUI_DataObject_Module* modelRoot = dynamic_cast<MULTIPR_GUI_DataObject_Module*>(root());
+
+ if (!modelRoot)
+ {
+ // root is not set yet
+ modelRoot = new MULTIPR_GUI_DataObject_Module(this, NULL, "MULTIPR");
+ setRoot(modelRoot);
+ }
- if (listParts->length() >= 1)
+ MULTIPR_ORB::MULTIPR_Obj_ptr obj = mMULTIPR_GUI->getMULTIPRObj();
+
+ if (obj != NULL)
{
- const char* strPartName0 = (*listParts)[0];
- char* strPartInfo0 = obj->getPartInfo(strPartName0);
-
- char lMeshName[256];
- int lId;
- char lPartName[256];
- char lPath[256];
- char lMEDFileName[256];
-
- // parse infos
- int ret = sscanf(strPartInfo0, "%s %d %s %s %s",
- lMeshName,
- &lId,
- lPartName,
- lPath,
- lMEDFileName);
-
- if (ret != 5) return;
+ MULTIPR_ORB::string_array* listParts = obj->getParts();
- MULTIPR_GUI_DataObject_Mesh* dataObjectMesh = new MULTIPR_GUI_DataObject_Mesh(modelRoot, lMeshName);
-
- MULTIPR_GUI_DataObject_Part* dataObjectPart_prev = NULL;
-
- for (int i = 0 ; i < listParts->length() ; i++)
+ if (listParts->length() >= 1)
{
- const char* strItem = (*listParts)[i];
- char* strPartInfo = obj->getPartInfo(strItem);
+ const char* strPartName0 = (*listParts)[0];
+ char* strPartInfo0 = obj->getPartInfo(strPartName0);
+
+ char lMeshName[256];
+ int lId;
+ char lPartName[256];
+ char lPath[256];
+ char lMEDFileName[256];
// parse infos
- int ret = sscanf(strPartInfo, "%s %d %s %s %s",
+ int ret = sscanf(strPartInfo0, "%s %d %s %s %s",
lMeshName,
&lId,
lPartName,
lPath,
lMEDFileName);
-
+
if (ret != 5) return;
-
- //cout << "Part : " << lPartName << endl;
- if ((strstr(lPartName,"_MED") != NULL) || (strstr(lPartName,"_LOW") != NULL))
- {
- //cout << "Found MED/LOW" << endl;
- new MULTIPR_GUI_DataObject_Resolution(dataObjectPart_prev, strItem, strPartInfo);
- }
- else
+
+ MULTIPR_GUI_DataObject_Mesh* dataObjectMesh = new MULTIPR_GUI_DataObject_Mesh(modelRoot, lMeshName);
+
+ MULTIPR_GUI_DataObject_Part* dataObjectPart_prev = NULL;
+
+ for (int i = 0 ; i < listParts->length() ; i++)
{
- dataObjectPart_prev = new MULTIPR_GUI_DataObject_Part(dataObjectMesh, strItem, strPartInfo);
+ const char* strItem = (*listParts)[i];
+ char* strPartInfo = obj->getPartInfo(strItem);
+
+ // parse infos
+ int ret = sscanf(strPartInfo, "%s %d %s %s %s",
+ lMeshName,
+ &lId,
+ lPartName,
+ lPath,
+ lMEDFileName);
+
+ if (ret != 5) return;
+
+ //cout << "Part : " << lPartName << endl;
+ if ((strstr(lPartName,"_MED") != NULL) || (strstr(lPartName,"_LOW") != NULL))
+ {
+ //cout << "Found MED/LOW" << endl;
+ new MULTIPR_GUI_DataObject_Resolution(dataObjectPart_prev, strItem, strPartInfo);
+ }
+ else
+ {
+ dataObjectPart_prev = new MULTIPR_GUI_DataObject_Part(dataObjectMesh, strItem, strPartInfo);
+ }
}
}
}
}
+ catch (...)
+ {
+ }
}
void retrieveSelectedParts();
bool isPartExist(const char* partName);
+ bool removeLowerResolution();
protected:
virtual CAM_DataModel* createDataModel();
{
// evaluates default radius for the first selected part
const QStringList& partsList = mModule->getSelectedParts();
+ const char* strFieldIt = comboBoxSelectFieldIteration->currentText().latin1();
+ int fieldIteration = atoi(strFieldIt);
char* strPartInfo0 = mModule->getMULTIPRObj()->getPartInfo(partsList[0].latin1());
char lMeshName[256];
float defaultRadius = 0.5f;
try
{
- multipr::Mesh* mesh = new multipr::Mesh();
- mesh->readSequentialMED(lMEDFileName, lMeshName);
- const int averageNumberOfNeighbours = 8;
- defaultRadius = mesh->evalDefaultRadius(averageNumberOfNeighbours);
- delete mesh;
+ char strParams[256];
+ sprintf(strParams, "2");
+
+ char* res = mModule->getMULTIPRObj()->evalDecimationParams(
+ lPartName,
+ comboBoxSelectFieldName->currentText().latin1(),
+ fieldIteration,
+ comboBoxSelectFilter->currentText().latin1(),
+ strParams);
+
+ sscanf(res, "%f", &defaultRadius);
}
catch (...)
{
{
// evaluates default radius for the first selected part
const QStringList& partsList = mModule->getSelectedParts();
+ const char* strFieldIt = comboBoxSelectFieldIteration->currentText().latin1();
+ int fieldIteration = atoi(strFieldIt);
char* strPartInfo0 = mModule->getMULTIPRObj()->getPartInfo(partsList[0].latin1());
char lMeshName[256];
lMEDFileName);
QApplication::setOverrideCursor(Qt::waitCursor);
- float defaultRadius = 0.5f;
+
try
{
- multipr::Mesh* mesh = new multipr::Mesh();
- mesh->readSequentialMED(lMEDFileName, lMeshName);
-
- multipr::DecimationFilter* filter =
- multipr::DecimationFilter::create(comboBoxSelectFilter->currentText().latin1());
-
- double gradMin = 0.1, gradAvg = 0.15, gradMax = 0.2;
-
- multipr::DecimationFilterGradAvg* filterGrad = dynamic_cast<multipr::DecimationFilterGradAvg*>(filter);
- if (filterGrad)
+ float radius;
+ ret = sscanf(lineEditRadius->text().latin1(), "%f", &radius);
+ if ((ret != 1) || (radius <= 0.0f))
{
- const char* strFieldIt = comboBoxSelectFieldIteration->currentText().latin1();
- int fieldIteration = atoi(strFieldIt);
-
- double radius;
- ret = sscanf(lineEditRadius->text().latin1(), "%lf", &radius);
- if ((ret != 1) || (radius <= 0.0f))
- {
- SUIT_MessageBox::error1(
- mModule->getAppli()->desktop(),
- "Decimation parameters error",
- "Invalid radius (should be > 0.0)",
- tr("OK") );
-
- return;
- }
-
- filterGrad->getGradientInfo(
- mesh,
- comboBoxSelectFieldName->currentText().latin1(),
- fieldIteration,
- radius,
- spinBoxBoxing->value(),
- &gradMin,
- &gradAvg,
- &gradMax);
+ SUIT_MessageBox::error1(
+ mModule->getAppli()->desktop(),
+ "Decimation parameters error",
+ "Invalid radius (should be > 0.0)",
+ tr("OK") );
+
+ return;
}
- delete filter;
- delete mesh;
+ char strParams[256];
+ sprintf(strParams, "1 %f %d", radius, spinBoxBoxing->value());
+
+ char* res = mModule->getMULTIPRObj()->evalDecimationParams(
+ lPartName,
+ comboBoxSelectFieldName->currentText().latin1(),
+ fieldIteration,
+ comboBoxSelectFilter->currentText().latin1(),
+ strParams);
+
+ float gradMin, gradAvg, gradMax;
+ sscanf(res, "%f %f %f", &gradMin, &gradAvg, &gradMax);
lineEditTMed->setText( QString::number(gradMin) );
lineEditTLow->setText( QString::number(gradMax) );
catch (...)
{
}
+
QApplication::restoreOverrideCursor();
}