boolean GetQuadAllowed();
};
+ /*!
+ * interface of "NETGEN 2D parameters" hypothesis used by NETGENPlugin_NETGEN_2D_ONLY algoritm
+ */
+ interface NETGENPlugin_Hypothesis_2D_ONLY : NETGENPlugin_Hypothesis_2D
+ {
+ };
+
+ /*!
+ * interface of "NETGEN 3D parameters" hypothesis used by NETGENPlugin_NETGEN_3D algorithm
+ */
+ interface NETGENPlugin_Hypothesis_3D : NETGENPlugin_Hypothesis
+ {
+ };
+
/*!
* NETGENPlugin_Hypothesis: interface of "NETGEN 2D simple parameters" hypothesis
*/
label-id="NETGEN 2D Parameters"
icon-id="mesh_hypo_netgen_2d.png"
dim="2"/>
+ <hypothesis type="NETGEN_Parameters_3D"
+ label-id="NETGEN 3D Parameters"
+ icon-id="mesh_hypo_netgen.png"
+ dim="3"/>
+ <hypothesis type="NETGEN_Parameters_2D_ONLY"
+ label-id="NETGEN 2D Parameters"
+ icon-id="mesh_hypo_netgen_2d.png"
+ dim="2"/>
<hypothesis type="NETGEN_SimpleParameters_2D"
label-id="NETGEN 2D Simple Parameters"
icon-id="mesh_hypo_netgen_2d.png"
<algorithm type="NETGEN_3D"
label-id="Tetrahedron (Netgen)"
icon-id="mesh_algo_tetra.png"
- hypos="MaxElementVolume"
+ hypos="MaxElementVolume,NETGEN_Parameters_3D"
need-geom="false"
input="TRIA,QUAD"
dim="3"/>
<algorithm type="NETGEN_2D_ONLY"
label-id="Netgen 2D"
icon-id="mesh_algo_netgen_2d.png"
- hypos="LengthFromEdges,MaxElementArea"
+ hypos="LengthFromEdges,MaxElementArea,NETGEN_Parameters_2D_ONLY"
opt-hypos="QuadranglePreference"
input="EDGE"
output="TRIA,QUAD"
SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator( const QString& aHypType )
{
SMESHGUI_GenericHypothesisCreator* aCreator = NULL;
- if( aHypType=="NETGEN_Parameters_2D" || aHypType=="NETGEN_Parameters" )
+ if( aHypType=="NETGEN_Parameters_2D" || aHypType=="NETGEN_Parameters" ||
+ aHypType=="NETGEN_Parameters_2D_ONLY" || aHypType=="NETGEN_Parameters_3D" )
aCreator = new NETGENPluginGUI_HypothesisCreator( aHypType );
else if ( aHypType=="NETGEN_SimpleParameters_2D" ||
aHypType=="NETGEN_SimpleParameters_3D" )
};
NETGENPluginGUI_HypothesisCreator::NETGENPluginGUI_HypothesisCreator( const QString& theHypType )
-: SMESHGUI_GenericHypothesisCreator( theHypType ),
- myIs2D(false)
+: SMESHGUI_GenericHypothesisCreator( theHypType )
{
myGeomSelectionTools = NULL;
myLocalSizeMap.clear();
+ myIs2D = ( theHypType.startsWith("NETGEN_Parameters_2D"));
+ myIsONLY = ( theHypType == "NETGEN_Parameters_2D_ONLY" ||
+ theHypType == "NETGEN_Parameters_3D");
}
NETGENPluginGUI_HypothesisCreator::~NETGENPluginGUI_HypothesisCreator()
res = myMaxSize->isValid(msg,true) && res;
res = myGrowthRate->isValid(msg,true) && res; ;
- res = myNbSegPerEdge->isValid(msg,true) && res;
- res = myNbSegPerRadius->isValid(msg,true) && res;
+ if ( myNbSegPerEdge )
+ res = myNbSegPerEdge->isValid(msg,true) && res;
+ if ( myNbSegPerRadius )
+ res = myNbSegPerRadius->isValid(msg,true) && res;
return res;
}
myMaxSize->RangeStepAndValidator( 1e-07, 1e+06, 10., "length_precision" );
aGroupLayout->addWidget( myMaxSize, row, 1 );
row++;
-
- mySecondOrder = new QCheckBox( tr( "NETGEN_SECOND_ORDER" ), GroupC1 );
- aGroupLayout->addWidget( mySecondOrder, row, 0 );
- row++;
-
+
+ mySecondOrder = 0;
+ if ( !myIsONLY )
+ {
+ mySecondOrder = new QCheckBox( tr( "NETGEN_SECOND_ORDER" ), GroupC1 );
+ aGroupLayout->addWidget( mySecondOrder, row, 0 );
+ row++;
+ }
+
aGroupLayout->addWidget( new QLabel( tr( "NETGEN_FINENESS" ), GroupC1 ), row, 0 );
myFineness = new QComboBox( GroupC1 );
QStringList types;
aGroupLayout->addWidget( myGrowthRate, row, 1 );
row++;
- const double VALUE_MAX = 1.0e+6;
+ myNbSegPerEdge = 0;
+ myNbSegPerRadius = 0;
+ if ( !myIsONLY )
+ {
+ const double VALUE_MAX = 1.0e+6;
- aGroupLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_EDGE" ), GroupC1 ), row, 0 );
- myNbSegPerEdge = new SMESHGUI_SpinBox( GroupC1 );
- myNbSegPerEdge->RangeStepAndValidator( .2, VALUE_MAX, .1, "parametric_precision" );
- aGroupLayout->addWidget( myNbSegPerEdge, row, 1 );
- row++;
-
- aGroupLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_RADIUS" ), GroupC1 ), row, 0 );
- myNbSegPerRadius = new SMESHGUI_SpinBox( GroupC1 );
- myNbSegPerRadius->RangeStepAndValidator( .2, VALUE_MAX, .1, "parametric_precision" );
- aGroupLayout->addWidget( myNbSegPerRadius, row, 1 );
- row++;
+ aGroupLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_EDGE" ), GroupC1 ), row, 0 );
+ myNbSegPerEdge = new SMESHGUI_SpinBox( GroupC1 );
+ myNbSegPerEdge->RangeStepAndValidator( .2, VALUE_MAX, .1, "parametric_precision" );
+ aGroupLayout->addWidget( myNbSegPerEdge, row, 1 );
+ row++;
- if ( hypType()=="NETGEN_Parameters_2D" )
+ aGroupLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_RADIUS" ), GroupC1 ), row, 0 );
+ myNbSegPerRadius = new SMESHGUI_SpinBox( GroupC1 );
+ myNbSegPerRadius->RangeStepAndValidator( .2, VALUE_MAX, .1, "parametric_precision" );
+ aGroupLayout->addWidget( myNbSegPerRadius, row, 1 );
+ row++;
+ }
+ myAllowQuadrangles = 0;
+ if ( myIs2D )
{
myAllowQuadrangles = new QCheckBox( tr( "NETGEN_ALLOW_QUADRANGLES" ), GroupC1 );
aGroupLayout->addWidget( myAllowQuadrangles, row, 0 );
- myIs2D = true;
row++;
}
- myOptimize = new QCheckBox( tr( "NETGEN_OPTIMIZE" ), GroupC1 );
- aGroupLayout->addWidget( myOptimize, row, 0 );
- row++;
-
+ myOptimize = 0;
+ if ( !myIs2D )
+ {
+ myOptimize = new QCheckBox( tr( "NETGEN_OPTIMIZE" ), GroupC1 );
+ aGroupLayout->addWidget( myOptimize, row, 0 );
+ row++;
+ }
connect( myFineness, SIGNAL( activated( int ) ), this, SLOT( onFinenessChanged() ) );
- QWidget* localSizeGroup = new QWidget();
- QGridLayout* localSizeLayout = new QGridLayout(localSizeGroup);
-
- myLocalSizeTable = new QTableWidget(0, LSZ_NB_COLUMNS, localSizeGroup);
- localSizeLayout->addWidget(myLocalSizeTable, 1, 0, 8, 1);
- QStringList localSizeHeaders;
- localSizeHeaders << tr( "LSZ_ENTRY_COLUMN" )<< tr( "LSZ_NAME_COLUMN" ) << tr( "LSZ_LOCALSIZE_COLUMN" );
- myLocalSizeTable->setHorizontalHeaderLabels(localSizeHeaders);
- myLocalSizeTable->horizontalHeader()->hideSection(LSZ_ENTRY_COLUMN);
- myLocalSizeTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
- myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
- myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
- myLocalSizeTable->setAlternatingRowColors(true);
- myLocalSizeTable->verticalHeader()->hide();
-
- QPushButton* addVertexButton = new QPushButton(tr("NETGEN_LSZ_VERTEX"), localSizeGroup);
- localSizeLayout->addWidget(addVertexButton, LSZ_VERTEX_BTN, 1, 1, 1);
- QPushButton* addEdgeButton = new QPushButton(tr("NETGEN_LSZ_EDGE"), localSizeGroup);
- localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 1, 1, 1);
+ myLocalSizeTable = 0;
+ if ( !myIsONLY )
+ {
+ QWidget* localSizeGroup = new QWidget();
+ QGridLayout* localSizeLayout = new QGridLayout(localSizeGroup);
+
+ myLocalSizeTable = new QTableWidget(0, LSZ_NB_COLUMNS, localSizeGroup);
+ localSizeLayout->addWidget(myLocalSizeTable, 1, 0, 8, 1);
+ QStringList localSizeHeaders;
+ localSizeHeaders << tr( "LSZ_ENTRY_COLUMN" )<< tr( "LSZ_NAME_COLUMN" ) << tr( "LSZ_LOCALSIZE_COLUMN" );
+ myLocalSizeTable->setHorizontalHeaderLabels(localSizeHeaders);
+ myLocalSizeTable->horizontalHeader()->hideSection(LSZ_ENTRY_COLUMN);
+ myLocalSizeTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+ myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
+ myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
+ myLocalSizeTable->setAlternatingRowColors(true);
+ myLocalSizeTable->verticalHeader()->hide();
+
+ QPushButton* addVertexButton = new QPushButton(tr("NETGEN_LSZ_VERTEX"), localSizeGroup);
+ localSizeLayout->addWidget(addVertexButton, LSZ_VERTEX_BTN, 1, 1, 1);
+ QPushButton* addEdgeButton = new QPushButton(tr("NETGEN_LSZ_EDGE"), localSizeGroup);
+ localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 1, 1, 1);
#ifdef NETGEN_NEW
- QPushButton* addFaceButton = new QPushButton(tr("NETGEN_LSZ_FACE"), localSizeGroup);
- localSizeLayout->addWidget(addFaceButton, LSZ_FACE_BTN, 1, 1, 1);
+ QPushButton* addFaceButton = new QPushButton(tr("NETGEN_LSZ_FACE"), localSizeGroup);
+ localSizeLayout->addWidget(addFaceButton, LSZ_FACE_BTN, 1, 1, 1);
#endif
-
- QFrame *line2 = new QFrame(localSizeGroup);
- line2->setFrameShape(QFrame::HLine);
- line2->setFrameShadow(QFrame::Sunken);
- localSizeLayout->addWidget(line2, LSZ_SEPARATOR2, 1, 1, 1);
-
- QPushButton* removeButton = new QPushButton(tr("NETGEN_LSZ_REMOVE"), localSizeGroup);
- localSizeLayout->addWidget(removeButton, LSZ_REMOVE_BTN, 1, 1, 1);
-
- connect( addVertexButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnVertex()));
- connect( addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnEdge()));
+
+ QFrame *line2 = new QFrame(localSizeGroup);
+ line2->setFrameShape(QFrame::HLine);
+ line2->setFrameShadow(QFrame::Sunken);
+ localSizeLayout->addWidget(line2, LSZ_SEPARATOR2, 1, 1, 1);
+
+ QPushButton* removeButton = new QPushButton(tr("NETGEN_LSZ_REMOVE"), localSizeGroup);
+ localSizeLayout->addWidget(removeButton, LSZ_REMOVE_BTN, 1, 1, 1);
+
+ connect( addVertexButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnVertex()));
+ connect( addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnEdge()));
#ifdef NETGEN_NEW
- connect( addFaceButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnFace()));
+ connect( addFaceButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnFace()));
#endif
- connect( removeButton, SIGNAL(clicked()), this, SLOT(onRemoveLocalSizeOnShape()));
- connect( myLocalSizeTable, SIGNAL(cellChanged(int, int)), this, SLOT(onSetLocalSize(int, int)));
-
- tab->insertTab(LSZ_TAB, localSizeGroup, tr("NETGEN_LOCAL_SIZE"));
+ connect( removeButton, SIGNAL(clicked()), this, SLOT(onRemoveLocalSizeOnShape()));
+ connect( myLocalSizeTable, SIGNAL(cellChanged(int, int)), this, SLOT(onSetLocalSize(int, int)));
+ tab->insertTab(LSZ_TAB, localSizeGroup, tr("NETGEN_LOCAL_SIZE"));
+ }
return fr;
}
myMaxSize->setValue( data.myMaxSize );
else
myMaxSize->setText( data.myMaxSizeVar );
-
- mySecondOrder->setChecked( data.mySecondOrder );
- myOptimize->setChecked( data.myOptimize );
+
+ if ( mySecondOrder )
+ mySecondOrder->setChecked( data.mySecondOrder );
+ if ( myOptimize )
+ myOptimize->setChecked( data.myOptimize );
myFineness->setCurrentIndex( data.myFineness );
if(data.myGrowthRateVar.isEmpty())
else
myGrowthRate->setText( data.myGrowthRateVar );
- if(data.myNbSegPerEdgeVar.isEmpty())
- myNbSegPerEdge->setValue( data.myNbSegPerEdge );
- else
- myNbSegPerEdge->setText( data.myNbSegPerEdgeVar );
-
- if(data.myNbSegPerRadiusVar.isEmpty())
- myNbSegPerRadius->setValue( data.myNbSegPerRadius );
- else
- myNbSegPerRadius->setText( data.myNbSegPerRadiusVar );
-
- if (myIs2D)
+ if ( myNbSegPerEdge )
+ {
+ if(data.myNbSegPerEdgeVar.isEmpty())
+ myNbSegPerEdge->setValue( data.myNbSegPerEdge );
+ else
+ myNbSegPerEdge->setText( data.myNbSegPerEdgeVar );
+ }
+ if ( myNbSegPerRadius )
+ {
+ if(data.myNbSegPerRadiusVar.isEmpty())
+ myNbSegPerRadius->setValue( data.myNbSegPerRadius );
+ else
+ myNbSegPerRadius->setText( data.myNbSegPerRadiusVar );
+ }
+ if (myAllowQuadrangles)
myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
// update widgets
bool isCustom = (myFineness->currentIndex() == UserDefined);
myGrowthRate->setEnabled(isCustom);
- myNbSegPerEdge->setEnabled(isCustom);
- myNbSegPerRadius->setEnabled(isCustom);
+ if ( myNbSegPerEdge )
+ myNbSegPerEdge->setEnabled(isCustom);
+ if ( myNbSegPerRadius )
+ myNbSegPerRadius->setEnabled(isCustom);
- NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
- QMapIterator<QString, QString> i(myLocalSizeMap);
- GeomSelectionTools* geomSelectionTools = that->getGeomSelectionTools();
- while (i.hasNext()) {
- i.next();
- const QString entry = i.key();
- std::string shapeName = geomSelectionTools->getNameFromEntry(entry.toStdString());
- const QString localSize = i.value();
- int row = myLocalSizeTable->rowCount();
- myLocalSizeTable->setRowCount(row+1);
- myLocalSizeTable->setItem(row, LSZ_ENTRY_COLUMN, new QTableWidgetItem(entry));
- myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN)->setFlags(0);
- myLocalSizeTable->setItem(row, LSZ_NAME_COLUMN, new QTableWidgetItem(QString::fromStdString(shapeName)));
- myLocalSizeTable->item(row, LSZ_NAME_COLUMN)->setFlags(0);
- myLocalSizeTable->setItem(row, LSZ_LOCALSIZE_COLUMN, new QTableWidgetItem(localSize));
- myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled);
+ if ( myLocalSizeTable )
+ {
+ NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
+ QMapIterator<QString, QString> i(myLocalSizeMap);
+ GeomSelectionTools* geomSelectionTools = that->getGeomSelectionTools();
+ while (i.hasNext()) {
+ i.next();
+ const QString entry = i.key();
+ std::string shapeName = geomSelectionTools->getNameFromEntry(entry.toStdString());
+ const QString localSize = i.value();
+ int row = myLocalSizeTable->rowCount();
+ myLocalSizeTable->setRowCount(row+1);
+ myLocalSizeTable->setItem(row, LSZ_ENTRY_COLUMN, new QTableWidgetItem(entry));
+ myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN)->setFlags(0);
+ myLocalSizeTable->setItem(row, LSZ_NAME_COLUMN, new QTableWidgetItem(QString::fromStdString(shapeName)));
+ myLocalSizeTable->item(row, LSZ_NAME_COLUMN)->setFlags(0);
+ myLocalSizeTable->setItem(row, LSZ_LOCALSIZE_COLUMN, new QTableWidgetItem(localSize));
+ myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled);
+ }
+ myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
+ myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
}
- myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
- myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
}
QString NETGENPluginGUI_HypothesisCreator::storeParams() const
h_data.myName = myName ? myName->text() : "";
h_data.myMaxSize = myMaxSize->value();
h_data.myMaxSizeVar = myMaxSize->text();
- h_data.mySecondOrder = mySecondOrder->isChecked();
- h_data.myOptimize = myOptimize->isChecked();
+ if ( mySecondOrder )
+ h_data.mySecondOrder = mySecondOrder->isChecked();
+ if ( myOptimize )
+ h_data.myOptimize = myOptimize->isChecked();
h_data.myFineness = myFineness->currentIndex();
h_data.myGrowthRate = myGrowthRate->value();
- h_data.myNbSegPerEdge = myNbSegPerEdge->value();
- h_data.myNbSegPerRadius = myNbSegPerRadius->value();
+ if ( myNbSegPerEdge )
+ h_data.myNbSegPerEdge = myNbSegPerEdge->value();
+ if ( myNbSegPerRadius )
+ h_data.myNbSegPerRadius = myNbSegPerRadius->value();
- h_data.myGrowthRateVar = myGrowthRate->text();
- h_data.myNbSegPerEdgeVar = myNbSegPerEdge->text();
- h_data.myNbSegPerRadiusVar = myNbSegPerRadius->text();
+ h_data.myGrowthRateVar = myGrowthRate->text();
+ if ( myNbSegPerEdge )
+ h_data.myNbSegPerEdgeVar = myNbSegPerEdge->text();
+ if ( myNbSegPerRadius )
+ h_data.myNbSegPerRadiusVar = myNbSegPerRadius->text();
- if ( myIs2D )
+ if ( myAllowQuadrangles )
h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
-
- NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
- int nbRows = myLocalSizeTable->rowCount();
- for(int row=0 ; row < nbRows ; row++)
+
+ if ( myLocalSizeTable )
+ {
+ NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
+ int nbRows = myLocalSizeTable->rowCount();
+ for(int row=0 ; row < nbRows ; row++)
{
QString entry = myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN)->text();
QString localSize = myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->text().trimmed();
that->myLocalSizeMap[entry] = localSize;
}
-
+ }
return true;
}
bool isCustom = (myFineness->currentIndex() == UserDefined);
myGrowthRate->setEnabled(isCustom);
- myNbSegPerEdge->setEnabled(isCustom);
- myNbSegPerRadius->setEnabled(isCustom);
+ if ( myNbSegPerEdge )
+ myNbSegPerEdge->setEnabled(isCustom);
+ if ( myNbSegPerRadius )
+ myNbSegPerRadius->setEnabled(isCustom);
if (!isCustom)
{
}
myGrowthRate->setValue( aGrowthRate );
- myNbSegPerEdge->setValue( aNbSegPerEdge );
- myNbSegPerRadius->setValue( aNbSegPerRadius );
+ if ( myNbSegPerEdge )
+ myNbSegPerEdge->setValue( aNbSegPerEdge );
+ if ( myNbSegPerRadius )
+ myNbSegPerRadius->setValue( aNbSegPerRadius );
}
}
{
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
if (myGeomSelectionTools == NULL || myGeomSelectionTools->getMyStudy() != aStudy) {
+ delete myGeomSelectionTools;
myGeomSelectionTools = new GeomSelectionTools(aStudy);
}
return myGeomSelectionTools;
QCheckBox* myAllowQuadrangles;
bool myIs2D;
+ bool myIsONLY;
QTableWidget* myLocalSizeTable;
GeomSelectionTools* myGeomSelectionTools;
NETGENPlugin_Hypothesis_i.hxx \
NETGENPlugin_Hypothesis_2D.hxx \
NETGENPlugin_Hypothesis_2D_i.hxx \
+ NETGENPlugin_Hypothesis_3D_i.hxx \
+ NETGENPlugin_Hypothesis_2D_ONLY_i.hxx \
NETGENPlugin_SimpleHypothesis_2D.hxx \
NETGENPlugin_SimpleHypothesis_3D.hxx \
NETGENPlugin_SimpleHypothesis_2D_i.hxx \
NETGENPlugin_Hypothesis_i.cxx \
NETGENPlugin_Hypothesis_2D.cxx \
NETGENPlugin_Hypothesis_2D_i.cxx \
+ NETGENPlugin_Hypothesis_3D_i.cxx \
+ NETGENPlugin_Hypothesis_2D_ONLY_i.cxx \
NETGENPlugin_Mesher.cxx \
NETGENPlugin_SimpleHypothesis_2D.cxx \
NETGENPlugin_SimpleHypothesis_3D.cxx \
// Author : Michael Sazonov (OCN)
// Date : 28/03/2006
// Project : SALOME
-// $Header$
//=============================================================================
//
#include "NETGENPlugin_Hypothesis_2D.hxx"
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// NETGENPlugin : C++ implementation
+// File : NETGENPlugin_Hypothesis_2D_ONLY_i.cxx
+// Project : SALOME
+//=============================================================================
+//
+#include "NETGENPlugin_Hypothesis_2D_ONLY_i.hxx"
+#include "SMESH_Gen.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+NETGENPlugin_Hypothesis_2D_ONLY_i::
+NETGENPlugin_Hypothesis_2D_ONLY_i (PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl)
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA ),
+ NETGENPlugin_Hypothesis_2D_i( thePOA, theStudyId, theGenImpl )
+{
+ MESSAGE( "NETGENPlugin_Hypothesis_2D_ONLY_i::NETGENPlugin_Hypothesis_2D_ONLY_i" );
+ myBaseImpl = new ::NETGENPlugin_Hypothesis_2D (theGenImpl->GetANewId(),
+ theStudyId,
+ theGenImpl);
+}
+
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+
+NETGENPlugin_Hypothesis_2D_ONLY_i::~NETGENPlugin_Hypothesis_2D_ONLY_i()
+{
+ MESSAGE( "NETGENPlugin_Hypothesis_2D_ONLY_i::~NETGENPlugin_Hypothesis_2D_ONLY_i" );
+}
+//================================================================================
+/*!
+ * \brief Redefine hypothesis type
+ */
+//================================================================================
+
+char* NETGENPlugin_Hypothesis_2D_ONLY_i::GetName()
+{
+ return CORBA::string_dup("NETGEN_Parameters_2D_ONLY");
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// NETGENPlugin : C++ implementation
+// File : NETGENPlugin_Hypothesis_2D_ONLY_i.hxx
+// Project : SALOME
+//=============================================================================
+//
+#ifndef _NETGENPlugin_Hypothesis_2D_ONLY_i_HXX_
+#define _NETGENPlugin_Hypothesis_2D_ONLY_i_HXX_
+
+#include "NETGENPlugin_Defs.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm)
+
+#include "NETGENPlugin_Hypothesis_2D_i.hxx"
+
+class SMESH_Gen;
+
+// NETGENPlugin parameters hypothesis ("2D only" case)
+
+class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_2D_ONLY_i:
+ public virtual POA_NETGENPlugin::NETGENPlugin_Hypothesis_2D_ONLY,
+ public NETGENPlugin_Hypothesis_2D_i
+{
+ public:
+ // Constructor
+ NETGENPlugin_Hypothesis_2D_ONLY_i (PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl);
+ // Destructor
+ virtual ~NETGENPlugin_Hypothesis_2D_ONLY_i();
+
+ char* GetName();
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// NETGENPlugin : C++ implementation
+// File : NETGENPlugin_Hypothesis_3D_i.cxx
+// Project : SALOME
+//=============================================================================
+//
+#include "NETGENPlugin_Hypothesis_3D_i.hxx"
+#include "SMESH_Gen.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+using namespace std;
+
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+NETGENPlugin_Hypothesis_3D_i::
+NETGENPlugin_Hypothesis_3D_i (PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl)
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA ),
+ NETGENPlugin_Hypothesis_i( thePOA, theStudyId, theGenImpl )
+{
+ MESSAGE( "NETGENPlugin_Hypothesis_3D_i::NETGENPlugin_Hypothesis_3D_i" );
+}
+
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+NETGENPlugin_Hypothesis_3D_i::~NETGENPlugin_Hypothesis_3D_i()
+{
+ MESSAGE( "NETGENPlugin_Hypothesis_3D_i::~NETGENPlugin_Hypothesis_3D_i" );
+}
+
+//================================================================================
+/*!
+ * \brief Redefine hypothesis type
+ */
+//================================================================================
+
+char* NETGENPlugin_Hypothesis_3D_i::GetName()
+{
+ return CORBA::string_dup("NETGEN_Parameters_3D");
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// NETGENPlugin : C++ implementation
+// File : NETGENPlugin_Hypothesis_2D_i.hxx
+// Project : SALOME
+//=============================================================================
+//
+#ifndef _NETGENPlugin_Hypothesis_3D_i_HXX_
+#define _NETGENPlugin_Hypothesis_3D_i_HXX_
+
+#include "NETGENPlugin_Defs.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm)
+
+#include "NETGENPlugin_Hypothesis_i.hxx"
+
+class SMESH_Gen;
+
+// NETGENPlugin parameters hypothesis (3D "only" case)
+
+class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_3D_i:
+ public virtual POA_NETGENPlugin::NETGENPlugin_Hypothesis_3D,
+ public NETGENPlugin_Hypothesis_i
+{
+ public:
+ // Constructor
+ NETGENPlugin_Hypothesis_3D_i (PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl);
+
+ // Get type name of hypothesis
+ char* GetName();
+
+ // Destructor
+ virtual ~NETGENPlugin_Hypothesis_3D_i();
+};
+
+#endif
#include "NETGENPlugin_NETGEN_2D_ONLY.hxx"
#include "NETGENPlugin_Mesher.hxx"
+#include "NETGENPlugin_Hypothesis_2D.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
_compatibleHypothesis.push_back("MaxElementArea");
_compatibleHypothesis.push_back("LengthFromEdges");
_compatibleHypothesis.push_back("QuadranglePreference");
+ _compatibleHypothesis.push_back("NETGEN_Parameters_2D");
_hypMaxElementArea = 0;
_hypLengthFromEdges = 0;
_hypQuadranglePreference = 0;
+ _hypParameters = 0;
}
//=============================================================================
_hypLengthFromEdges = static_cast<const StdMeshers_LengthFromEdges*> (hyp);
else if ( hypName == "QuadranglePreference" )
_hypQuadranglePreference = static_cast<const StdMeshers_QuadranglePreference*>(hyp);
+ else if ( hypName == "NETGEN_Parameters_2D" )
+ _hypParameters = static_cast<const NETGENPlugin_Hypothesis_2D*>(hyp);
else {
aStatus = HYP_INCOMPATIBLE;
return false;
}
}
- if ( _hypMaxElementArea && _hypLengthFromEdges ) {
+ int nbHyps = bool(_hypMaxElementArea) + bool(_hypLengthFromEdges) + bool(_hypParameters );
+ if ( nbHyps > 1 )
aStatus = HYP_CONCURENT;
- return false;
- }
-
- if ( _hypMaxElementArea || _hypLengthFromEdges || _hypQuadranglePreference)
+ else if ( nbHyps == 1)
aStatus = HYP_OK;
- return aStatus == HYP_OK;
+ return ( aStatus == HYP_OK );
}
//================================================================================
}
ngMesh.AddSegment (seg);
-
+ {
+ netgen::Point3d ngP1(n->X(), n->Y(), n->Z());
+ n = uvPtVec[ i+1 ].node;
+ netgen::Point3d ngP2(n->X(), n->Y(), n->Z());
+ ngMesh.RestrictLocalH( netgen::Center( ngP1,ngP2), Dist(ngP1,ngP2));
+ }
#ifdef DUMP_SEGMENTS
cout << "Segment: " << seg.edgenr << endl
<< "\tp1: " << seg[0] << endl
return error(COMPERR_BAD_INPUT_MESH,
SMESH_Comment("Too few segments: ")<<wires[0]->NbSegments());
+ // --------------------
+ // compute edge length
+ // --------------------
+
+ NETGENPlugin_Mesher aMesher( &aMesh, aShape, /*isVolume=*/false);
+ netgen::OCCGeometry occgeo;
+ aMesher.PrepareOCCgeometry( occgeo, F, aMesh );
+ occgeo.fmap.Clear(); // face can be reversed, which is wrong in this case (issue 19978)
+ occgeo.fmap.Add( F );
+
+ if ( _hypParameters )
+ {
+ aMesher.SetParameters(_hypParameters);
+ }
+ else
+ {
+ double edgeLength = 0;
+ if (_hypLengthFromEdges || (!_hypLengthFromEdges && !_hypMaxElementArea))
+ {
+ int nbSegments = 0;
+ for ( int iW = 0; iW < nbWires; ++iW )
+ {
+ edgeLength += wires[ iW ]->Length();
+ nbSegments += wires[ iW ]->NbSegments();
+ }
+ if ( nbSegments )
+ edgeLength /= nbSegments;
+ }
+ if ( _hypMaxElementArea )
+ {
+ double maxArea = _hypMaxElementArea->GetMaxArea();
+ edgeLength = sqrt(2. * maxArea/sqrt(3.0));
+ }
+ if ( edgeLength < DBL_MIN )
+ edgeLength = occgeo.GetBoundingBox().Diam();
+
+ //cout << " edgeLength = " << edgeLength << endl;
+
+ netgen::mparam.maxh = edgeLength;
+ netgen::mparam.quad = _hypQuadranglePreference ? 1 : 0;
+ //ngMesh->SetGlobalH ( edgeLength );
+ }
+
// -------------------------
// Make input netgen mesh
// -------------------------
NETGENPlugin_NetgenLibWrapper ngLib;
netgen::Mesh * ngMesh = (netgen::Mesh*) ngLib._ngMesh;
- netgen::OCCGeometry occgeo;
- NETGENPlugin_Mesher::PrepareOCCgeometry( occgeo, F, aMesh );
- occgeo.fmap.Clear(); // face can be reversed, which is wrong in this case (issue 19978)
- occgeo.fmap.Add( F );
+ Box<3> bb = occgeo.GetBoundingBox();
+ bb.Increase (bb.Diam()/10);
+ ngMesh->SetLocalH (bb.PMin(), bb.PMax(), netgen::mparam.grading);
+ ngMesh->SetGlobalH (netgen::mparam.maxh);
vector< const SMDS_MeshNode* > nodeVec;
problem = AddSegmentsToMesh( *ngMesh, occgeo, wires, helper, nodeVec );
if ( problem && !problem->IsOK() )
return error( problem );
- // --------------------
- // compute edge length
- // --------------------
-
- double edgeLength = 0;
- if (_hypLengthFromEdges || !_hypLengthFromEdges && !_hypMaxElementArea)
- {
- int nbSegments = 0;
- for ( int iW = 0; iW < nbWires; ++iW )
- {
- edgeLength += wires[ iW ]->Length();
- nbSegments += wires[ iW ]->NbSegments();
- }
- if ( nbSegments )
- edgeLength /= nbSegments;
- }
- if ( _hypMaxElementArea )
- {
- double maxArea = _hypMaxElementArea->GetMaxArea();
- edgeLength = sqrt(2. * maxArea/sqrt(3.0));
- }
- if ( edgeLength < DBL_MIN )
- edgeLength = occgeo.GetBoundingBox().Diam();
-
- //cout << " edgeLength = " << edgeLength << endl;
-
- netgen::mparam.maxh = edgeLength;
- netgen::mparam.quad = _hypQuadranglePreference ? 1 : 0;
- //ngMesh->SetGlobalH ( edgeLength );
-
// -------------------------
// Generate surface mesh
// -------------------------
OCC_CATCH_SIGNALS;
#endif
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
+ if ( err )
+ error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task);
}
- catch (Standard_Failure& ex) {
- string comment = ex.DynamicType()->Name();
- if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) {
- comment += ": ";
- comment += ex.GetMessageString();
- }
- error(COMPERR_OCC_EXCEPTION, comment);
- }
- catch (NgException exc) {
- error( SMESH_Comment("NgException: ") << exc.What() );
+ catch (Standard_Failure& ex)
+ {
+ SMESH_Comment str("Exception in netgen::OCCGenerateMesh()");
+ str << " at " << netgen::multithread.task
+ << ": " << ex.DynamicType()->Name();
+ if ( ex.GetMessageString() && strlen( ex.GetMessageString() ))
+ str << ": " << ex.GetMessageString();
+ error(str);
}
catch (...) {
- error(COMPERR_EXCEPTION,"Exception in netgen::OCCGenerateMesh()");
+ SMESH_Comment str("Exception in netgen::OCCGenerateMesh()");
+ str << " at " << netgen::multithread.task;
+ error(str);
}
// ----------------------------------------------------
// create faces
bool reverse = ( aShape.Orientation() == TopAbs_REVERSED );
- for ( int i = 1; i <= nbFaces ; ++i )
+ int i,j;
+ for ( i = 1; i <= nbFaces ; ++i )
{
const Element2d& elem = ngMesh->SurfaceElement(i);
vector<const SMDS_MeshNode*> nodes( elem.GetNP() );
- for (int j=1; j <= elem.GetNP(); ++j)
+ for (j=1; j <= elem.GetNP(); ++j)
{
int pind = elem.PNum(j);
+ if ( pind-1 < 0 )
+ break;
const SMDS_MeshNode* node = nodeVec.at(pind-1);
if ( reverse )
nodes[ nodes.size()-j ] = node;
meshDS->SetNodeOnFace((SMDS_MeshNode*)node, faceID, pgi.u, pgi.v);
}
}
- SMDS_MeshFace* face = 0;
- if ( elem.GetType() == TRIG )
- face = helper.AddFace(nodes[0],nodes[1],nodes[2]);
- else
- face = helper.AddFace(nodes[0],nodes[1],nodes[2],nodes[3]);
+ if ( j > elem.GetNP() )
+ {
+ SMDS_MeshFace* face = 0;
+ if ( elem.GetType() == TRIG )
+ face = helper.AddFace(nodes[0],nodes[1],nodes[2]);
+ else
+ face = helper.AddFace(nodes[0],nodes[1],nodes[2],nodes[3]);
+ }
}
return !err;
class StdMeshers_MaxElementArea;
class StdMeshers_LengthFromEdges;
class StdMeshers_QuadranglePreference;
+class NETGENPlugin_Hypothesis_2D;
/*!
* \brief Mesher generating 2D elements on a geometrical face taking
virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap);
- /*static TError AddSegmentsToMesh(netgen::Mesh& ngMesh,
- OCCGeometry& geom,
- const TSideVector& wires,
- SMESH_MesherHelper& helper,
- vector< const SMDS_MeshNode* > & nodeVec); //amv*/
-
protected:
const StdMeshers_MaxElementArea* _hypMaxElementArea;
const StdMeshers_LengthFromEdges* _hypLengthFromEdges;
const StdMeshers_QuadranglePreference* _hypQuadranglePreference;
- // const NETGENPlugin_Hypothesis* _hypothesis;
+ const NETGENPlugin_Hypothesis_2D* _hypParameters;
};
#endif
//
#include "NETGENPlugin_NETGEN_3D.hxx"
-#include "NETGENPlugin_Mesher.hxx"
+#include "NETGENPlugin_Hypothesis.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMESH_MesherHelper.hxx"
#include "SMESH_MeshEditor.hxx"
#include "StdMeshers_QuadToTriaAdaptor.hxx"
+#include "StdMeshers_MaxElementVolume.hxx"
#include <BRepGProp.hxx>
#include <BRep_Tool.hxx>
namespace nglib {
#include <nglib.h>
}
+namespace netgen {
+ extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
+ extern MeshingParameters mparam;
+ extern volatile multithreadt multithread;
+}
using namespace nglib;
using namespace std;
_name = "NETGEN_3D";
_shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
_compatibleHypothesis.push_back("MaxElementVolume");
+ _compatibleHypothesis.push_back("NETGEN_Parameters");
+ _requireShape = false; // can work without shape
_maxElementVolume = 0.;
_hypMaxElementVolume = NULL;
-
- _requireShape = false; // can work without shape
+ _hypParameters = NULL;
}
//=============================================================================
MESSAGE("NETGENPlugin_NETGEN_3D::CheckHypothesis");
_hypMaxElementVolume = NULL;
+ _hypParameters = NULL;
_maxElementVolume = DBL_MAX;
list<const SMESHDS_Hypothesis*>::const_iterator itl;
if (!nbHyp)
{
aStatus = SMESH_Hypothesis::HYP_OK;
- //aStatus = SMESH_Hypothesis::HYP_MISSING;
return true; // can work with no hypothesis
}
string hypName = theHyp->GetName();
- bool isOk = false;
-
if (hypName == "MaxElementVolume")
{
_hypMaxElementVolume = static_cast<const StdMeshers_MaxElementVolume*> (theHyp);
- ASSERT(_hypMaxElementVolume);
_maxElementVolume = _hypMaxElementVolume->GetMaxVolume();
- isOk =true;
+ aStatus = SMESH_Hypothesis::HYP_OK;
+ }
+ else if (hypName == "NETGEN_Parameters")
+ {
+ _hypParameters = static_cast<const NETGENPlugin_Hypothesis *> (theHyp);
aStatus = SMESH_Hypothesis::HYP_OK;
}
else
aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
- return isOk;
+ return ( aStatus == SMESH_Hypothesis::HYP_OK );
}
//=============================================================================
helper.SetElementsOnShape( true );
int Netgen_NbOfNodes = 0;
- int Netgen_param2ndOrder = 0;
- double Netgen_paramFine = 1.;
- double Netgen_paramSize = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
double Netgen_point[3];
int Netgen_triangle[3];
- int Netgen_tetrahedron[4];
NETGENPlugin_NetgenLibWrapper ngLib;
Ng_Mesh * Netgen_mesh = ngLib._ngMesh;
(netgen::Mesh&) *Netgen_mesh,
nodeVec,
internals);
- Netgen_NbOfNodes = Ng_GetNP(Netgen_mesh);
}
}
// Generate the volume mesh
// -------------------------
- Ng_Meshing_Parameters Netgen_param;
+ return compute( aMesh, helper, nodeVec, Netgen_mesh);
+}
+
+//================================================================================
+/*!
+ * \brief set parameters and generate the volume mesh
+ */
+//================================================================================
- Netgen_param.secondorder = Netgen_param2ndOrder;
- Netgen_param.fineness = Netgen_paramFine;
- Netgen_param.maxh = Netgen_paramSize;
+bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
+ SMESH_MesherHelper& helper,
+ vector< const SMDS_MeshNode* >& nodeVec,
+ Ng_Mesh * Netgen_mesh)
+{
+ netgen::Mesh* ngMesh = (netgen::Mesh*)Netgen_mesh;
+ int Netgen_NbOfNodes = Ng_GetNP(Netgen_mesh);
- Ng_Result status;
+ char *optstr = 0;
+ int startWith = netgen::MESHCONST_MESHVOLUME;
+ int endWith = netgen::MESHCONST_OPTVOLUME;
+ int err = 1;
- try {
+ NETGENPlugin_Mesher aMesher( &aMesh, helper.GetSubShape(), /*isVolume=*/true );
+ netgen::OCCGeometry occgeo;
+
+ if ( _hypParameters )
+ {
+ aMesher.SetParameters( _hypParameters );
+ if ( !_hypParameters->GetOptimize() )
+ endWith = netgen::MESHCONST_MESHVOLUME;
+ }
+ else if ( _hypMaxElementVolume )
+ {
+ netgen::mparam.maxh = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
+ }
+ else if ( aMesh.HasShapeToMesh() )
+ {
+ aMesher.PrepareOCCgeometry( occgeo, helper.GetSubShape(), aMesh );
+ netgen::mparam.maxh = occgeo.GetBoundingBox().Diam()/2;
+ }
+ else
+ {
+ netgen::Point3d pmin, pmax;
+ ngMesh->GetBox (pmin, pmax);
+ netgen::mparam.maxh = Dist(pmin, pmax)/2;
+ }
+
+ try
+ {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
- status = Ng_GenerateVolumeMesh(Netgen_mesh, &Netgen_param);
- }
- catch (Standard_Failure& exc) {
- error(COMPERR_OCC_EXCEPTION, exc.GetMessageString());
- status = NG_VOLUME_FAILURE;
+ ngMesh->CalcLocalH();
+ err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
+ if ( err )
+ error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task);
}
- catch (...) {
- error("Exception in Ng_GenerateVolumeMesh()");
- status = NG_VOLUME_FAILURE;
+ catch (Standard_Failure& ex)
+ {
+ SMESH_Comment str("Exception in netgen::OCCGenerateMesh()");
+ str << " at " << netgen::multithread.task
+ << ": " << ex.DynamicType()->Name();
+ if ( ex.GetMessageString() && strlen( ex.GetMessageString() ))
+ str << ": " << ex.GetMessageString();
+ error(str);
}
- if ( GetComputeError()->IsOK() ) {
- switch ( status ) {
- case NG_SURFACE_INPUT_ERROR:error( status, "NG_SURFACE_INPUT_ERROR");
- case NG_VOLUME_FAILURE: error( status, "NG_VOLUME_FAILURE");
- case NG_STL_INPUT_ERROR: error( status, "NG_STL_INPUT_ERROR");
- case NG_SURFACE_FAILURE: error( status, "NG_SURFACE_FAILURE");
- case NG_FILE_NOT_FOUND: error( status, "NG_FILE_NOT_FOUND");
- };
+ catch (...)
+ {
+ SMESH_Comment str("Exception in netgen::OCCGenerateMesh()");
+ str << " at " << netgen::multithread.task;
+ error(str);
}
int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh);
int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh);
- MESSAGE("End of Volume Mesh Generation. status=" << status <<
+ MESSAGE("End of Volume Mesh Generation. err=" << err <<
", nb new nodes: " << Netgen_NbOfNodesNew - Netgen_NbOfNodes <<
", nb tetra: " << Netgen_NbOfTetra);
// Feed back the SMESHDS with the generated Nodes and Volume Elements
// -------------------------------------------------------------------
- if ( status == NG_VOLUME_FAILURE )
+ if ( err )
{
- SMESH_ComputeErrorPtr err = NETGENPlugin_Mesher::readErrors(nodeVec);
- if ( err && !err->myBadElements.empty() )
- error( err );
+ SMESH_ComputeErrorPtr ce = NETGENPlugin_Mesher::readErrors(nodeVec);
+ if ( ce && !ce->myBadElements.empty() )
+ error( ce );
}
bool isOK = ( /*status == NG_OK &&*/ Netgen_NbOfTetra > 0 );// get whatever built
if ( isOK )
{
+ double Netgen_point[3];
+ int Netgen_tetrahedron[4];
+
// create and insert new nodes into nodeVec
nodeVec.resize( Netgen_NbOfNodesNew + 1, 0 );
int nodeIndex = Netgen_NbOfNodes + 1;
for ( int elemIndex = 1; elemIndex <= Netgen_NbOfTetra; ++elemIndex )
{
Ng_GetVolumeElement(Netgen_mesh, elemIndex, Netgen_tetrahedron);
- helper.AddVolume (nodeVec.at( Netgen_tetrahedron[0] ),
- nodeVec.at( Netgen_tetrahedron[1] ),
- nodeVec.at( Netgen_tetrahedron[2] ),
- nodeVec.at( Netgen_tetrahedron[3] ));
+ try
+ {
+ helper.AddVolume (nodeVec.at( Netgen_tetrahedron[0] ),
+ nodeVec.at( Netgen_tetrahedron[1] ),
+ nodeVec.at( Netgen_tetrahedron[2] ),
+ nodeVec.at( Netgen_tetrahedron[3] ));
+ }
+ catch (...)
+ {
+ }
}
}
- return (status == NG_OK);
+ return !err;
}
//================================================================================
bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
SMESH_MesherHelper* aHelper)
{
- MESSAGE("NETGENPlugin_NETGEN_3D::Compute with maxElmentsize = " << _maxElementVolume);
+ MESSAGE("NETGENPlugin_NETGEN_3D::Compute with maxElmentsize = " << _maxElementVolume);
const int invalid_ID = -1;
bool _quadraticMesh = false;
typedef map< const SMDS_MeshNode*, int, TIDCompare > TNodeToIDMap;
// Feed the Netgen with surface mesh
// ---------------------------------
- int Netgen_NbOfNodes = 0;
- int Netgen_param2ndOrder = 0;
- double Netgen_paramFine = 1.;
- double Netgen_paramSize = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
-
+ int Netgen_NbOfNodes = 0;
double Netgen_point[3];
- int Netgen_triangle[3];
- int Netgen_tetrahedron[4];
+ int Netgen_triangle[3];
+ int Netgen_tetrahedron[4];
NETGENPlugin_NetgenLibWrapper ngLib;
Ng_Mesh * Netgen_mesh = ngLib._ngMesh;
// Generate the volume mesh
// -------------------------
- Ng_Meshing_Parameters Netgen_param;
-
- Netgen_param.secondorder = Netgen_param2ndOrder;
- Netgen_param.fineness = Netgen_paramFine;
- Netgen_param.maxh = Netgen_paramSize;
-
- Ng_Result status;
-
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- status = Ng_GenerateVolumeMesh(Netgen_mesh, &Netgen_param);
- }
- catch (Standard_Failure& exc) {
- error(COMPERR_OCC_EXCEPTION, exc.GetMessageString());
- status = NG_VOLUME_FAILURE;
- }
- catch (...) {
- error("Exception in Ng_GenerateVolumeMesh()");
- status = NG_VOLUME_FAILURE;
- }
- if ( GetComputeError()->IsOK() ) {
- switch ( status ) {
- case NG_SURFACE_INPUT_ERROR:error( status, "NG_SURFACE_INPUT_ERROR");
- case NG_VOLUME_FAILURE: error( status, "NG_VOLUME_FAILURE");
- case NG_STL_INPUT_ERROR: error( status, "NG_STL_INPUT_ERROR");
- case NG_SURFACE_FAILURE: error( status, "NG_SURFACE_FAILURE");
- case NG_FILE_NOT_FOUND: error( status, "NG_FILE_NOT_FOUND");
- };
- }
-
- int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh);
-
- int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh);
-
- MESSAGE("End of Volume Mesh Generation. status=" << status <<
- ", nb new nodes: " << Netgen_NbOfNodesNew - Netgen_NbOfNodes <<
- ", nb tetra: " << Netgen_NbOfTetra);
-
- // -------------------------------------------------------------------
- // Feed back the SMESHDS with the generated Nodes and Volume Elements
- // -------------------------------------------------------------------
-
- if ( status == NG_VOLUME_FAILURE )
- {
- SMESH_ComputeErrorPtr err = NETGENPlugin_Mesher::readErrors(nodeVec);
- if ( err && !err->myBadElements.empty() )
- error( err );
- }
-
- bool isOK = ( Netgen_NbOfTetra > 0 );// get whatever built
- if ( isOK )
- {
- // create and insert new nodes into nodeVec
- nodeVec.resize( Netgen_NbOfNodesNew + 1 );
- int nodeIndex = Netgen_NbOfNodes + 1;
-
- for ( ; nodeIndex <= Netgen_NbOfNodesNew; ++nodeIndex )
- {
- Ng_GetPoint( Netgen_mesh, nodeIndex, Netgen_point );
- nodeVec.at(nodeIndex) = aHelper->AddNode(Netgen_point[0],Netgen_point[1],Netgen_point[2]);
- }
-
- // create tetrahedrons
- for ( int elemIndex = 1; elemIndex <= Netgen_NbOfTetra; ++elemIndex )
- {
- Ng_GetVolumeElement(Netgen_mesh, elemIndex, Netgen_tetrahedron);
- aHelper->AddVolume (nodeVec.at( Netgen_tetrahedron[0] ),
- nodeVec.at( Netgen_tetrahedron[1] ),
- nodeVec.at( Netgen_tetrahedron[2] ),
- nodeVec.at( Netgen_tetrahedron[3] ));
- }
- }
-
- return (status == NG_OK);
+ return compute( aMesh, *aHelper, nodeVec, Netgen_mesh);
}
-
//=============================================================================
/*!
*
// Created : lundi 27 Janvier 2003
// Author : Nadir BOUHAMOU (CEA)
// Project : SALOME
-// $Header$
//=============================================================================
//
#ifndef _NETGENPlugin_NETGEN_3D_HXX_
#define _NETGENPlugin_NETGEN_3D_HXX_
#include "NETGENPlugin_Defs.hxx"
+#include "NETGENPlugin_Mesher.hxx"
#include "SMESH_3D_Algo.hxx"
#include "SMESH_Mesh.hxx"
-#include "StdMeshers_MaxElementVolume.hxx"
#include "Utils_SALOME_Exception.hxx"
+class NETGENPlugin_Hypothesis;
+class StdMeshers_MaxElementVolume;
+
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
{
public:
MapShapeNbElems& aResMap);
protected:
+
+ bool compute(SMESH_Mesh& mesh,
+ SMESH_MesherHelper& helper,
+ vector< const SMDS_MeshNode* >& nodeVec,
+ nglib::Ng_Mesh* ngMesh);
+
double _maxElementVolume;
const StdMeshers_MaxElementVolume* _hypMaxElementVolume;
+ const NETGENPlugin_Hypothesis* _hypParameters;
};
#endif
//
#include "utilities.h"
-#include "NETGENPlugin_NETGEN_3D_i.hxx"
-#include "NETGENPlugin_NETGEN_2D_i.hxx"
-#include "NETGENPlugin_NETGEN_2D_ONLY_i.hxx"
-#include "NETGENPlugin_NETGEN_2D3D_i.hxx"
-#include "NETGENPlugin_Hypothesis_i.hxx"
+#include "NETGENPlugin_Hypothesis_2D_ONLY_i.hxx"
#include "NETGENPlugin_Hypothesis_2D_i.hxx"
+#include "NETGENPlugin_Hypothesis_3D_i.hxx"
+#include "NETGENPlugin_Hypothesis_i.hxx"
+#include "NETGENPlugin_NETGEN_2D3D_i.hxx"
+#include "NETGENPlugin_NETGEN_2D_ONLY_i.hxx"
+#include "NETGENPlugin_NETGEN_2D_i.hxx"
+#include "NETGENPlugin_NETGEN_3D_i.hxx"
#include "NETGENPlugin_SimpleHypothesis_2D_i.hxx"
#include "NETGENPlugin_SimpleHypothesis_3D_i.hxx"
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_Hypothesis_i>;
else if (strcmp(aHypName, "NETGEN_Parameters_2D") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_Hypothesis_2D_i>;
+ else if (strcmp(aHypName, "NETGEN_Parameters_3D") == 0)
+ aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_Hypothesis_3D_i>;
+ else if (strcmp(aHypName, "NETGEN_Parameters_2D_ONLY") == 0)
+ aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_Hypothesis_2D_ONLY_i>;
else if (strcmp(aHypName, "NETGEN_SimpleParameters_2D") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_SimpleHypothesis_2D_i>;
else if (strcmp(aHypName, "NETGEN_SimpleParameters_3D") == 0)