STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
SET(${PROJECT_NAME_UC}_MAJOR_VERSION 8)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
Pre-requisites
--------------
-SALOME platform relies on a set of third-party softwares; some of them are needed
-at build time only, while other ones are needed in runtime also.
+SALOME platform relies on a set of third-party software; some of them are needed
+at build time only, while other ones are needed at runtime as well.
For more information about the pre-requisites please visit SALOME platform web
site:
# - Config file for the @PROJECT_NAME@ package
# It defines the following variables.
-# Specific to the pacakge @PROJECT_NAME@ itself:
+# Specific to the package @PROJECT_NAME@ itself:
# @PROJECT_NAME_UC@_ROOT_DIR_EXP - the root path of the installation providing this CMake file
#
\n <b>Additional Hypotheses</b> can be applied as a supplement to
introducing additional concepts to mesh creation.
-Following additional hypotheses can be used together with NETGEN algoritm:
+Following additional hypotheses can be used together with NETGEN algorithm:
<ul>
<li><b>Viscous Layers</b> additional hypothesis can be used together
- Solids are split into tetrahedral elements. Pyramids are
constructed as a transition from quadrangles to tetrahedra.
- Generating 3D meshes from 2D meshes, working without geometrical objects.
+- Generating 2D meshes from 2D meshes, working without geometrical objects.
+
+When working without geometrical objects, Negten requires that the
+input mesh to be a manifold shell.
To manage parameters of the NETGENPLUGIN use
\subpage netgen_2d_3d_hypo_page and \subpage additional_hypo_page.
\image html netgen2d3d_only.png
<center><em>Dialog boxes of <b>NETGEN 2D</b> and <b>NETGEN 3D</b>
algorithms </em></center>
+<br>
+\image html netgen2d_remesher.png
+<center><em>Hypothesis dialog box of <b>NETGEN 2D</b> remesher algorithms</em></center>
+
- <b>Name</b> - allows to define the name for the algorithm (NETGEN
2D (or 3D) Parameters by default).
- <b>Growth rate</b> - allows to define how much the linear dimensions of
two adjacent cells can differ (e.g. 0.3 means 30%).
- <b>Nb. Segs per Edge</b> - allows to define the minimum number of
-mesh segments in which edges will be split. This parameter is used
-only if <b>Limit Size by Surface Curvature</b> is checked.
+mesh segments in which edges will be split. Size of elements computed using
+this value is trimmed between <b>Min Size</b> and <b>Max Size</b>
+bounds. This parameter is used only if <b>Limit Size by Surface
+ Curvature</b> is checked.
- <b>Nb Segs per Radius</b> - allows to define the size of
mesh segments and mesh faces in which curved edges and surfaces will
-be split. This value divided by a radius of curvature gives an element
-size at a given point. This parameter is used only if <b>Limit Size by
- Surface Curvature</b> is checked.
+be split. A radius of local curvature divided by this value gives an element
+size at a given point. Element size computed this way is then trimmed
+between <b>Min Size</b> and <b>Max Size</b> bounds. This parameter is
+used only if <b>Limit Size by Surface Curvature</b> is checked.
+- <b>Chordal Error</b> - allows to define the maximum distance between
+the generated 2D element and the surface. Size of elements computed using
+this criterion is trimmed between <b>Min Size</b> and <b>Max Size</b> bounds.
- <b>Limit Size by Surface Curvature</b> - if this box is checked in,
then size of mesh segments and mesh faces on curved edges and surfaces
is defined using value of <b>Nb Segs per Radius</b> parameter, and
- <b>Fuse Coincident Nodes on Edges and Vertices</b> - allows merging
mesh nodes on vertices and edges which are geometrically coincident
but are topologically different.
+- <b>Ridge angle</b> - allows to define minimum angle in degrees between
+normals of adjacent triangles at which the remesher (Netgen 2D working
+w/o geometry) considers the edge between these triangles as a feature edge.
\image html netgen3d_local_size.png
- <b>Mesh-size File</b> - opens a dialog to select a file defining
size of elements. The file includes two obligatory sections. The first
section defines the size at points. The second section defines the
-size along lines. Let's consider the following sample size file.
+size along lines. Sizes defined in the file are trimmed between <b>Min
+Size</b> and <b>Max Size</b> bounds. Let's consider the following
+sample size file.
\code
2
92.5 92.5 92.5 0.05
"25 25 0 25 25 200 0.3" means that along the line between points (25,
25, 0) and (25, 25, 200) size of elements should be 0.3.
+
\image html netgen2d3d_simple.png
<b>NETGEN 2D simple parameters</b> and <b>NETGEN 3D simple
- The local size of segments influences the size of close triangles.
- The order of elements and their size in the 1D mesh generated by
NETGEN differ from those in the 1D mesh generated by Regular_1D
-algorithm, resulting in different 2D and 3D meshes.
+algorithm, which results in different 2D and 3D meshes at the same 1D
+input parameters.
*/
{
};
+ /*!
+ * NETGENPlugin_Remesher_2D: interface of "NETGEN Remesher" algorithm,
+ * generating 2D elements basing on an existing 2D mesh
+ */
+ interface NETGENPlugin_Remesher_2D : SMESH::SMESH_2D_Algo
+ {
+ };
+
/*!
* NETGENPlugin_Hypothesis: interface of "NETGEN parameters" hypothesis
*/
void SetNbSegPerEdge(in double value);
double GetNbSegPerEdge();
+ void SetChordalErrorEnabled(in boolean value);
+ boolean GetChordalErrorEnabled();
+ void SetChordalError(in double value);
+ double GetChordalError();
+
void SetNbSegPerRadius(in double value);
double GetNbSegPerRadius();
};
/*!
- * interface of "NETGEN 2D parameters" hypothesis used by NETGENPlugin_NETGEN_2D_ONLY algoritm
+ * interface of "NETGEN 2D parameters" hypothesis used by NETGENPlugin_NETGEN_2D_ONLY algorithm
*/
interface NETGENPlugin_Hypothesis_2D_ONLY : NETGENPlugin_Hypothesis_2D
{
{
};
+ /*!
+ * interface of "NETGEN Remesher parameters" hypothesis used by NETGENPlugin_Remesher_2D algorithm
+ */
+ interface NETGENPlugin_RemesherHypothesis_2D : NETGENPlugin_Hypothesis_2D
+ {
+ /*!
+ * \brief Set/get ridge angle
+ */
+ void SetRidgeAngle(in double angle );
+ double GetRidgeAngle();
+ };
+
/*!
* NETGENPlugin_Hypothesis: interface of "NETGEN 2D simple parameters" hypothesis
*/
</accumulative-methods>
</python-wrap>
</hypothesis>
+
<hypothesis type ="NETGEN_Parameters_2D"
label-id="NETGEN 2D Parameters"
icon-id ="mesh_hypo_netgen_2d.png"
</accumulative-methods>
</python-wrap>
</hypothesis>
+
<hypothesis type ="NETGEN_Parameters_3D"
label-id="NETGEN 3D Parameters"
icon-id ="mesh_hypo_netgen.png"
</accumulative-methods>
</python-wrap>
</hypothesis>
+
<hypothesis type ="NETGEN_Parameters_2D_ONLY"
label-id="NETGEN 2D Parameters"
icon-id ="mesh_hypo_netgen_2d.png"
</accumulative-methods>
</python-wrap>
</hypothesis>
+
+ <hypothesis type ="NETGEN_RemesherParameters_2D"
+ 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"
dim ="2"/>
+
<hypothesis type ="NETGEN_SimpleParameters_3D"
label-id="NETGEN 3D Simple Parameters"
icon-id ="mesh_hypo_netgen.png"
</python-wrap>
</algorithm>
+ <algorithm type ="NETGEN_Remesher_2D"
+ label-id ="NETGEN 2D"
+ icon-id ="mesh_algo_netgen_2d.png"
+ opt-hypos ="NETGEN_RemesherParameters_2D"
+ output ="TRIA,QUAD"
+ need-geom ="never"
+ dim ="2">
+ <python-wrap>
+ <algo>NETGEN_Remesher_2D=Triangle(algo=smeshBuilder.NETGEN)</algo>
+ <hypo>NETGEN_RemesherParameters_2D=Parameters()</hypo>
+ </python-wrap>
+ </algorithm>
+
</algorithms>
</meshers-group>
SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator( const QString& aHypType )
{
SMESHGUI_GenericHypothesisCreator* aCreator = NULL;
- if( aHypType=="NETGEN_Parameters_2D" || // 1D-2D
- aHypType=="NETGEN_Parameters" || // 1D-2D-3D
- aHypType=="NETGEN_Parameters_2D_ONLY" || // 2D
- aHypType=="NETGEN_Parameters_3D" ) // 3D
+ if( aHypType=="NETGEN_Parameters_2D" || // 1D-2D
+ aHypType=="NETGEN_Parameters" || // 1D-2D-3D
+ aHypType=="NETGEN_Parameters_2D_ONLY" || // 2D
+ aHypType=="NETGEN_Parameters_3D" || // 3D
+ aHypType=="NETGEN_RemesherParameters_2D" ) // 2D
{
aCreator = new NETGENPluginGUI_HypothesisCreator( aHypType );
}
{
myGeomSelectionTools = NULL;
myLocalSizeMap.clear();
- myIs2D = ( theHypType.startsWith("NETGEN_Parameters_2D"));
+ myIs2D = ( theHypType.startsWith("NETGEN_Parameters_2D") ||
+ theHypType == "NETGEN_RemesherParameters_2D");
myIsONLY = ( theHypType == "NETGEN_Parameters_2D_ONLY" ||
- theHypType == "NETGEN_Parameters_3D");
+ theHypType == "NETGEN_Parameters_3D" ||
+ theHypType == "NETGEN_RemesherParameters_2D");
}
NETGENPluginGUI_HypothesisCreator::~NETGENPluginGUI_HypothesisCreator()
res = myNbSegPerEdge->isValid(msg,true) && res;
if ( myNbSegPerRadius )
res = myNbSegPerRadius->isValid(msg,true) && res;
+ if ( myRidgeAngle )
+ res = myRidgeAngle->isValid(msg,true) && res;
if ( !res ) // -- issue 0021364: Dump of netgen parameters has duplicate lines
storeParamsToHypo( data_old );
QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
{
+ const bool isRemesher = ( hypType() == "NETGEN_RemesherParameters_2D" );
+
QFrame* fr = new QFrame( 0 );
fr->setObjectName( "myframe" );
QVBoxLayout* lay = new QVBoxLayout( fr );
myFineness = new QComboBox( GroupC1 );
QStringList types;
types << tr( "NETGEN_VERYCOARSE" ) << tr( "NETGEN_COARSE" ) << tr( "NETGEN_MODERATE" ) <<
- tr( "NETGEN_FINE" ) << tr( "NETGEN_VERYFINE" ) << tr( "NETGEN_CUSTOM" );
+ tr( "NETGEN_FINE" ) << tr( "NETGEN_VERYFINE" ) << tr( "NETGEN_CUSTOM" );
myFineness->addItems( types );
aGroupLayout->addWidget( myFineness, row, 1 );
connect( myFineness, SIGNAL( activated( int ) ), this, SLOT( onFinenessChanged() ) );
row++;
}
+ myChordalErrorEnabled = 0;
+ myChordalError = 0;
+ if (( myIs2D && !isRemesher ) || !myIsONLY )
+ {
+ myChordalErrorEnabled = new QCheckBox( tr( "NETGEN_CHORDAL_ERROR" ), GroupC1 );
+ aGroupLayout->addWidget( myChordalErrorEnabled, row, 0 );
+ myChordalError = new SMESHGUI_SpinBox( GroupC1 );
+ myChordalError->RangeStepAndValidator( COORD_MIN, COORD_MAX, .1, "length_precision" );
+ aGroupLayout->addWidget( myChordalError, row, 1 );
+ connect( myChordalErrorEnabled, SIGNAL( stateChanged(int)), SLOT( onChordalErrorEnabled()));
+ row++;
+ }
+
+ myRidgeAngle = 0;
+ if ( isRemesher )
+ {
+ aGroupLayout->addWidget( new QLabel( tr( "NETGEN_RIDGE_ANGLE" ), GroupC1 ), row, 0 );
+ myRidgeAngle = new SMESHGUI_SpinBox( GroupC1 );
+ myRidgeAngle->RangeStepAndValidator( 0, 90, 10, "angle_precision" );
+ aGroupLayout->addWidget( myRidgeAngle, row, 1 );
+ row++;
+ }
+
mySurfaceCurvature = 0;
- if ( myIs2D || !myIsONLY )
+ if (( myIs2D && !isRemesher ) || !myIsONLY )
{
mySurfaceCurvature = new QCheckBox( tr( "NETGEN_SURFACE_CURVATURE" ), GroupC1 );
aGroupLayout->addWidget( mySurfaceCurvature, row, 0, 1, 2 );
row++;
}
- myOptimize = new QCheckBox( tr( "NETGEN_OPTIMIZE" ), GroupC1 );
- aGroupLayout->addWidget( myOptimize, row, 0, 1, 2 );
- row++;
+ myOptimize = 0;
+ if ( !isRemesher )
+ {
+ myOptimize = new QCheckBox( tr( "NETGEN_OPTIMIZE" ), GroupC1 );
+ aGroupLayout->addWidget( myOptimize, row, 0, 1, 2 );
+ row++;
+ }
myFuseEdges = 0;
- if (!myIsONLY)
+ if ( !myIsONLY )
{
myFuseEdges = new QCheckBox( tr( "NETGEN_FUSE_EDGES" ), GroupC1 );
aGroupLayout->addWidget( myFuseEdges, row, 0, 1, 2 );
else
myNbSegPerRadius->setText( data.myNbSegPerRadiusVar );
}
+ if ( myChordalError )
+ {
+ myChordalErrorEnabled->setChecked( data.myChordalErrorEnabled && data.myChordalError > 0 );
+ if(data.myChordalErrorVar.isEmpty())
+ myChordalError->setValue( data.myChordalError > 0 ? data.myChordalError : 0.1 );
+ else
+ myChordalError->setText( data.myChordalErrorVar );
+ myChordalError->setEnabled( myChordalErrorEnabled->isChecked() );
+ }
+ if ( myRidgeAngle )
+ {
+ if ( data.myRidgeAngleVar.isEmpty() )
+ myRidgeAngle->setValue( data.myRidgeAngle );
+ else
+ myRidgeAngle->setText( data.myRidgeAngleVar );
+ }
if (myAllowQuadrangles)
myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
readParamsFromWidgets( data );
storeParamsToHypo( data );
- QString valStr = tr("NETGEN_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
- valStr += tr("NETGEN_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
- if ( data.mySecondOrder )
- valStr += tr("NETGEN_SECOND_ORDER") + "; ";
- if ( data.myOptimize )
- valStr += tr("NETGEN_OPTIMIZE") + "; ";
- valStr += myFineness->currentText() + "(" + QString::number( data.myGrowthRate ) + ", " +
- QString::number( data.myNbSegPerEdge ) + ", " +
- QString::number( data.myNbSegPerRadius ) + ")";
+ // QString valStr = tr("NETGEN_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
+ // valStr += tr("NETGEN_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
+ // if ( data.mySecondOrder )
+ // valStr += tr("NETGEN_SECOND_ORDER") + "; ";
+ // if ( data.myOptimize )
+ // valStr += tr("NETGEN_OPTIMIZE") + "; ";
+ // valStr += myFineness->currentText() + "(" + QString::number( data.myGrowthRate ) + ", " +
+ // QString::number( data.myNbSegPerEdge ) + ", " +
+ // QString::number( data.myNbSegPerRadius ) + ")";
- if ( myIs2D && data.myAllowQuadrangles )
- valStr += "; " + tr("NETGEN_ALLOW_QUADRANGLES");
+ // if ( myIs2D && data.myAllowQuadrangles )
+ // valStr += "; " + tr("NETGEN_ALLOW_QUADRANGLES");
- if ( data.mySurfaceCurvature )
- valStr += "; " + tr("NETGEN_SURFACE_CURVATURE");
+ // if ( data.mySurfaceCurvature )
+ // valStr += "; " + tr("NETGEN_SURFACE_CURVATURE");
- if ( data.myFuseEdges )
- valStr += "; " + tr("NETGEN_FUSE_EDGES");
+ // if ( data.myFuseEdges )
+ // valStr += "; " + tr("NETGEN_FUSE_EDGES");
- return valStr;
+ return QString();
}
bool NETGENPluginGUI_HypothesisCreator::readParamsFromHypo( NetgenHypothesisData& h_data ) const
NETGENPlugin::NETGENPlugin_Hypothesis_var h =
NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( initParamsHypothesis() );
- //HypothesisData* data = SMESH::GetHypothesisData( hypType() );
h_data.myName = isCreation() ? hypName() : "";
- h_data.myMaxSize = h->GetMaxSize();
- h_data.myMaxSizeVar = getVariableName("SetMaxSize");
+ h_data.myMaxSize = h->GetMaxSize();
+ h_data.myMaxSizeVar = getVariableName("SetMaxSize");
h_data.mySecondOrder = h->GetSecondOrder();
- h_data.myOptimize = h->GetOptimize();
-
- h_data.myFineness = (int) h->GetFineness();
- h_data.myGrowthRate = h->GetGrowthRate();
- h_data.myGrowthRateVar = getVariableName("SetGrowthRate");
- h_data.myNbSegPerEdge = h->GetNbSegPerEdge();
- h_data.myNbSegPerEdgeVar = getVariableName("SetNbSegPerEdge");
- h_data.myNbSegPerRadius = h->GetNbSegPerRadius();
- h_data.myNbSegPerRadiusVar = getVariableName("SetNbSegPerRadius");
- h_data.myMinSize = h->GetMinSize();
- h_data.myMinSizeVar = getVariableName("SetMinSize");
- h_data.mySurfaceCurvature = h->GetUseSurfaceCurvature();
- h_data.myFuseEdges = h->GetFuseEdges();
- h_data.myMeshSizeFile = h->GetMeshSizeFile();
+ h_data.myOptimize = h->GetOptimize();
+
+ h_data.myFineness = (int) h->GetFineness();
+ h_data.myGrowthRate = h->GetGrowthRate();
+ h_data.myGrowthRateVar = getVariableName("SetGrowthRate");
+ h_data.myNbSegPerEdge = h->GetNbSegPerEdge();
+ h_data.myNbSegPerEdgeVar = getVariableName("SetNbSegPerEdge");
+ h_data.myNbSegPerRadius = h->GetNbSegPerRadius();
+ h_data.myNbSegPerRadiusVar = getVariableName("SetNbSegPerRadius");
+ h_data.myChordalError = h->GetChordalError();
+ h_data.myChordalErrorVar = getVariableName("SetChordalError");
+ h_data.myChordalErrorEnabled = h->GetChordalErrorEnabled();
+ h_data.myMinSize = h->GetMinSize();
+ h_data.myMinSizeVar = getVariableName("SetMinSize");
+ h_data.mySurfaceCurvature = h->GetUseSurfaceCurvature();
+ h_data.myFuseEdges = h->GetFuseEdges();
+ h_data.myMeshSizeFile = h->GetMeshSizeFile();
//if ( myIs2D )
{
- NETGENPlugin::NETGENPlugin_Hypothesis_var h =
- NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( initParamsHypothesis() );
+ // NETGENPlugin::NETGENPlugin_Hypothesis_var h =
+ // NETGENPlugin::NETGENPlugin_Hypothesis::_narrow( initParamsHypothesis() );
if ( !h->_is_nil() )
h_data.myAllowQuadrangles = h->GetQuadAllowed();
}
+ if ( myIs2D )
+ {
+ NETGENPlugin::NETGENPlugin_RemesherHypothesis_2D_var rh =
+ NETGENPlugin::NETGENPlugin_RemesherHypothesis_2D::_narrow( h );
+
+ if ( !rh->_is_nil() )
+ h_data.myRidgeAngle = rh->GetRidgeAngle();
+ }
NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
NETGENPlugin::string_array_var myEntries = h->GetLocalSizeEntries();
SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().data() );
h->SetVarParameter( h_data.myMaxSizeVar.toLatin1().constData(), "SetMaxSize");
h->SetMaxSize ( h_data.myMaxSize );
- h->SetSecondOrder ( h_data.mySecondOrder );
- h->SetOptimize ( h_data.myOptimize );
+ if ( mySecondOrder )
+ h->SetSecondOrder ( h_data.mySecondOrder );
+ if ( myOptimize )
+ h->SetOptimize ( h_data.myOptimize );
int fineness = h_data.myFineness;
h->SetFineness ( fineness );
{
h->SetVarParameter ( h_data.myGrowthRateVar.toLatin1().constData(), "SetGrowthRate");
h->SetGrowthRate ( h_data.myGrowthRate );
- h->SetVarParameter ( h_data.myNbSegPerEdgeVar.toLatin1().constData(), "SetNbSegPerEdge");
- h->SetNbSegPerEdge ( h_data.myNbSegPerEdge );
- h->SetVarParameter ( h_data.myNbSegPerRadiusVar.toLatin1().constData(), "SetNbSegPerRadius");
- h->SetNbSegPerRadius( h_data.myNbSegPerRadius );
+ if ( myNbSegPerEdge )
+ {
+ h->SetVarParameter ( h_data.myNbSegPerEdgeVar.toLatin1().constData(), "SetNbSegPerEdge");
+ h->SetNbSegPerEdge ( h_data.myNbSegPerEdge );
+ }
+ if ( myNbSegPerRadius )
+ {
+ h->SetVarParameter ( h_data.myNbSegPerRadiusVar.toLatin1().constData(), "SetNbSegPerRadius");
+ h->SetNbSegPerRadius( h_data.myNbSegPerRadius );
+ }
+ }
+ if ( myChordalError )
+ {
+ h->SetVarParameter ( h_data.myChordalErrorVar.toLatin1().constData(), "SetChordalError");
+ h->SetChordalError ( h_data.myChordalError );
+ h->SetChordalErrorEnabled( h_data.myChordalErrorEnabled );
}
h->SetVarParameter ( h_data.myMinSizeVar.toLatin1().constData(), "SetMinSize");
h->SetMinSize ( h_data.myMinSize );
- h->SetUseSurfaceCurvature( h_data.mySurfaceCurvature );
- h->SetFuseEdges ( h_data.myFuseEdges );
+ if ( mySurfaceCurvature )
+ h->SetUseSurfaceCurvature( h_data.mySurfaceCurvature );
+ if ( myFuseEdges )
+ h->SetFuseEdges ( h_data.myFuseEdges );
h->SetMeshSizeFile ( h_data.myMeshSizeFile.toUtf8().constData() );
//if ( myIs2D )
{
// NETGENPlugin::NETGENPlugin_Hypothesis_2D_var h_2d =
// NETGENPlugin::NETGENPlugin_Hypothesis_2D::_narrow( h );
-
// if ( !h_2d->_is_nil() )
// h_2d->SetQuadAllowed( h_data.myAllowQuadrangles );
- h->SetQuadAllowed( h_data.myAllowQuadrangles );
+ if ( myAllowQuadrangles )
+ h->SetQuadAllowed( h_data.myAllowQuadrangles );
}
-
- QMapIterator<QString,QString> i(myLocalSizeMap);
- while (i.hasNext()) {
- i.next();
- const QString entry = i.key();
+ if ( myIs2D )
+ {
+ NETGENPlugin::NETGENPlugin_RemesherHypothesis_2D_var rh =
+ NETGENPlugin::NETGENPlugin_RemesherHypothesis_2D::_narrow( h );
+ if ( !rh->_is_nil() )
+ {
+ rh->SetVarParameter( h_data.myRidgeAngleVar.toLatin1().constData(), "SetRidgeAngle");
+ rh->SetRidgeAngle ( h_data.myRidgeAngle );
+ }
+ }
+ for ( QMapIterator<QString,QString> i(myLocalSizeMap); i.hasNext(); i.next() )
+ {
+ const QString entry = i.key();
const QString localSize = i.value();
if (localSize == "__TO_DELETE__")
{
}
else
{
- std::istringstream tmp(localSize.toLatin1().constData());
- double val;
- tmp >> val;
- h->SetLocalSizeOnEntry(entry.toLatin1().constData(), val);
+ h->SetLocalSizeOnEntry(entry.toLatin1().constData(), localSize.toDouble());
}
}
}
h_data.myNbSegPerEdgeVar = myNbSegPerEdge->text();
if ( myNbSegPerRadius )
h_data.myNbSegPerRadiusVar = myNbSegPerRadius->text();
+ if ( myChordalError )
+ {
+ h_data.myChordalErrorVar = myChordalError->text();
+ h_data.myChordalError = myChordalError->value();
+ h_data.myChordalErrorEnabled = myChordalError->isEnabled();
+ }
+ if ( myRidgeAngle )
+ {
+ h_data.myRidgeAngleVar = myRidgeAngle->text();
+ h_data.myRidgeAngle = myRidgeAngle->value();
+ }
-
if ( myAllowQuadrangles )
h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
return true;
}
+void NETGENPluginGUI_HypothesisCreator::onChordalErrorEnabled()
+{
+ myChordalError->setEnabled( myChordalErrorEnabled->isChecked() );
+}
+
void NETGENPluginGUI_HypothesisCreator::onSurfaceCurvatureChanged()
{
bool isSurfaceCurvature = (mySurfaceCurvature ? mySurfaceCurvature->isChecked() : true);
myNbSegPerEdge->setEnabled(isCustom && isSurfaceCurvature);
if ( myNbSegPerRadius )
myNbSegPerRadius->setEnabled(isCustom && isSurfaceCurvature);
+ // if ( myChordalError )
+ // {
+ // myChordalError->setEnabled( isSurfaceCurvature );
+ // myChordalErrorEnabled->setEnabled( isSurfaceCurvature );
+ // }
}
void NETGENPluginGUI_HypothesisCreator::onFinenessChanged()
{
bool isCustom = (myFineness->currentIndex() == UserDefined);
-
+
myGrowthRate->setEnabled(isCustom);
if ( myNbSegPerEdge )
myNbSegPerEdge->setEnabled(isCustom);
myNbSegPerRadius->setEnabled(isCustom);
if (!isCustom)
+ {
+ double aGrowthRate, aNbSegPerEdge, aNbSegPerRadius;
+
+ switch ( myFineness->currentIndex() )
{
- double aGrowthRate, aNbSegPerEdge, aNbSegPerRadius;
-
- switch ( myFineness->currentIndex() )
- {
- case VeryCoarse:
- aGrowthRate = 0.7;
- aNbSegPerEdge = 0.3;
- aNbSegPerRadius = 1;
- break;
- case Coarse:
- aGrowthRate = 0.5;
- aNbSegPerEdge = 0.5;
- aNbSegPerRadius = 1.5;
- break;
- case Fine:
- aGrowthRate = 0.2;
- aNbSegPerEdge = 2;
- aNbSegPerRadius = 3;
- break;
- case VeryFine:
- aGrowthRate = 0.1;
- aNbSegPerEdge = 3;
- aNbSegPerRadius = 5;
- break;
- case Moderate:
- default:
- aGrowthRate = 0.3;
- aNbSegPerEdge = 1;
- aNbSegPerRadius = 2;
- break;
- }
-
- myGrowthRate->setValue( aGrowthRate );
- if ( myNbSegPerEdge )
- myNbSegPerEdge->setValue( aNbSegPerEdge );
- if ( myNbSegPerRadius )
- myNbSegPerRadius->setValue( aNbSegPerRadius );
+ case VeryCoarse:
+ aGrowthRate = 0.7;
+ aNbSegPerEdge = 0.3;
+ aNbSegPerRadius = 1;
+ break;
+ case Coarse:
+ aGrowthRate = 0.5;
+ aNbSegPerEdge = 0.5;
+ aNbSegPerRadius = 1.5;
+ break;
+ case Fine:
+ aGrowthRate = 0.2;
+ aNbSegPerEdge = 2;
+ aNbSegPerRadius = 3;
+ break;
+ case VeryFine:
+ aGrowthRate = 0.1;
+ aNbSegPerEdge = 3;
+ aNbSegPerRadius = 5;
+ break;
+ case Moderate:
+ default:
+ aGrowthRate = 0.3;
+ aNbSegPerEdge = 1;
+ aNbSegPerRadius = 2;
+ break;
}
+
+ myGrowthRate->setValue( aGrowthRate );
+ if ( myNbSegPerEdge )
+ myNbSegPerEdge->setValue( aNbSegPerEdge );
+ if ( myNbSegPerRadius )
+ myNbSegPerRadius->setValue( aNbSegPerRadius );
+ }
}
void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnVertex()
mySel->selectedObjects(ListSelectedObjects, NULL, false );
SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects);
for ( ; Object_It.More() ; Object_It.Next())
+ {
+ Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
+ std::string entry, shapeName;
+ entry = geomSelectionTools->getEntryOfObject(anObject);
+ shapeName = anObject->getName();
+ TopAbs_ShapeEnum shapeType;
+ shapeType = geomSelectionTools->entryToShapeType(entry);
+ if (shapeType == TopAbs_SHAPE)
{
- Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
- std::string entry, shapeName;
- entry = geomSelectionTools->getEntryOfObject(anObject);
- shapeName = anObject->getName();
- TopAbs_ShapeEnum shapeType;
- shapeType = geomSelectionTools->entryToShapeType(entry);
- if (shapeType == TopAbs_SHAPE)
- {
- // E.A. if shapeType == TopAbs_SHAPE, it is NOT a TopoDS_Shape !!!
- continue;
- }
- // --
- if(shapeType != typeShapeAsked)
- {
- continue;
- }
- // --
- myLocalSizeTable->setFocus();
- QString shapeEntry;
- shapeEntry = QString::fromStdString(entry);
- if (myLocalSizeMap.contains(shapeEntry))
- {
- if (myLocalSizeMap[shapeEntry] != "__TO_DELETE__")
- {
- continue;
- }
- }
- double phySize = h->GetMaxSize();
- std::ostringstream oss;
- oss << phySize;
- QString localSize;
- localSize = QString::fromStdString(oss.str());
- // --
- int row = myLocalSizeTable->rowCount() ;
- myLocalSizeTable->setRowCount(row+1);
- myLocalSizeTable->setItem(row, LSZ_ENTRY_COLUMN, new QTableWidgetItem(shapeEntry));
- 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->clearSelection();
- myLocalSizeTable->scrollToItem( myLocalSizeTable->item( row, LSZ_LOCALSIZE_COLUMN ) );
- // --
+ // E.A. if shapeType == TopAbs_SHAPE, it is NOT a TopoDS_Shape !!!
+ continue;
+ }
+ // --
+ if(shapeType != typeShapeAsked)
+ {
+ continue;
+ }
+ // --
+ myLocalSizeTable->setFocus();
+ QString shapeEntry;
+ shapeEntry = QString::fromStdString(entry);
+ if (myLocalSizeMap.contains(shapeEntry))
+ {
+ if (myLocalSizeMap[shapeEntry] != "__TO_DELETE__")
+ {
+ continue;
+ }
}
+ double phySize = h->GetMaxSize();
+ std::ostringstream oss;
+ oss << phySize;
+ QString localSize;
+ localSize = QString::fromStdString(oss.str());
+ // --
+ int row = myLocalSizeTable->rowCount() ;
+ myLocalSizeTable->setRowCount(row+1);
+ myLocalSizeTable->setItem(row, LSZ_ENTRY_COLUMN, new QTableWidgetItem(shapeEntry));
+ 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->clearSelection();
+ myLocalSizeTable->scrollToItem( myLocalSizeTable->item( row, LSZ_LOCALSIZE_COLUMN ) );
+ // --
+ }
}
void NETGENPluginGUI_HypothesisCreator::onRemoveLocalSizeOnShape()
QListIterator<int> it( selectedRows );
it.toBack();
while (it.hasPrevious())
+ {
+ row = it.previous();
+ QString entry = myLocalSizeTable->item(row,LSZ_ENTRY_COLUMN)->text();
+ if (myLocalSizeMap.contains(entry))
{
- row = it.previous();
- QString entry = myLocalSizeTable->item(row,LSZ_ENTRY_COLUMN)->text();
- if (myLocalSizeMap.contains(entry))
- {
- myLocalSizeMap[entry] = "__TO_DELETE__";
- }
- myLocalSizeTable->removeRow(row );
+ myLocalSizeMap[entry] = "__TO_DELETE__";
}
+ myLocalSizeTable->removeRow(row );
+ }
myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN);
myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN);
}
QString NETGENPluginGUI_HypothesisCreator::caption() const
{
- return tr( QString( "NETGEN_%1_TITLE" ).arg(myIs2D?QString("2D"):QString("3D")).toLatin1().data() );
+ return tr( myIs2D ? "NETGEN_2D_TITLE" : "NETGEN_3D_TITLE");
}
QPixmap NETGENPluginGUI_HypothesisCreator::icon() const
{
- QString hypIconName = tr( QString("ICON_DLG_NETGEN_PARAMETERS%1").arg(myIs2D?QString("_2D"):QString("")).toLatin1().data() );
+ QString hypIconName = tr( myIs2D ?
+ "ICON_DLG_NETGEN_PARAMETERS_2D" :
+ "ICON_DLG_NETGEN_PARAMETERS");
return SUIT_Session::session()->resourceMgr()->loadPixmap( "NETGENPlugin", hypIconName );
}
QString NETGENPluginGUI_HypothesisCreator::type() const
{
- return tr( QString( "NETGEN_%1_HYPOTHESIS" ).arg(myIs2D?QString("2D"):QString("3D")).toLatin1().data() );
+ return tr( myIs2D ? "NETGEN_2D_HYPOTHESIS" : "NETGEN_3D_HYPOTHESIS");
}
QString NETGENPluginGUI_HypothesisCreator::helpPage() const
typedef struct
{
- double myMaxSize, myMinSize, myGrowthRate, myNbSegPerEdge, myNbSegPerRadius;
- int myFineness;
- bool mySecondOrder, myAllowQuadrangles, myOptimize, mySurfaceCurvature, myFuseEdges;
- QString myName, myMeshSizeFile;
- QString myMaxSizeVar, myMinSizeVar, myGrowthRateVar, myNbSegPerEdgeVar, myNbSegPerRadiusVar;
+ double myMaxSize, myMinSize, myGrowthRate, myNbSegPerEdge, myNbSegPerRadius, myRidgeAngle, myChordalError;
+ int myFineness;
+ bool mySecondOrder, myAllowQuadrangles, myOptimize, mySurfaceCurvature, myFuseEdges, myChordalErrorEnabled;
+ QString myName, myMeshSizeFile;
+ QString myMaxSizeVar, myMinSizeVar, myGrowthRateVar, myNbSegPerEdgeVar, myNbSegPerRadiusVar, myRidgeAngleVar, myChordalErrorVar;
} NetgenHypothesisData;
/*!
protected slots:
virtual void onFinenessChanged();
+ virtual void onChordalErrorEnabled();
virtual void onSurfaceCurvatureChanged();
virtual void onAddLocalSizeOnVertex();
virtual void onAddLocalSizeOnEdge();
SMESHGUI_SpinBox* myGrowthRate;
SMESHGUI_SpinBox* myNbSegPerEdge;
SMESHGUI_SpinBox* myNbSegPerRadius;
+ SMESHGUI_SpinBox* myRidgeAngle;
+ QCheckBox* myChordalErrorEnabled;
+ SMESHGUI_SpinBox* myChordalError;
QCheckBox* myAllowQuadrangles;
QCheckBox* mySurfaceCurvature;
QCheckBox* myFuseEdges;
- bool myIs2D;
- bool myIsONLY;
+ bool myIs2D; // 2D or 3D
+ bool myIsONLY; // one dim or several
QLineEdit* myMeshSizeFile;
QTableWidget* myLocalSizeTable;
<source>NETGEN_SEG_PER_RADIUS</source>
<translation>Nb. Segs per Radius</translation>
</message>
+ <message>
+ <source>NETGEN_CHORDAL_ERROR</source>
+ <translation>Chordal Error</translation>
+ </message>
+ <message>
+ <source>NETGEN_RIDGE_ANGLE</source>
+ <translation>Ridge Angle</translation>
+ </message>
<message>
<source>NETGEN_SURFACE_CURVATURE</source>
<translation>Limit Size by Surface Curvature</translation>
# ------------------------------------------------------------------
+# Notes about usage of Netgen with SALOME
# ------------------------------------------------------------------
-# Notes for Netgen >= 4.9.13
-# ------------------------------------------------------------------
-# ------------------------------------------------------------------
-Netgen home page: http://sourceforge.net/apps/mediawiki/netgen-mesher.
+-------------------
+1. Netgen home page
+-------------------
+
+Netgen mesher's home page is: https://sourceforge.net/projects/netgen-mesher/.
+
+-----------------------
+2. Minimal requirements
+-----------------------
+
+Minimal version of Netgen required for SALOME is 5.3.1.
-1. Minimal requirements
+----------------------------------------
+3. Build Netgen for SALOME NETGEN Plugin
+----------------------------------------
-Minimal version of Netgen required for SALOME is 4.9.13.
+3.1. Download Netgen archive (here netgen-5.3.1.tar.gz) from the project's site:
-2. How to build Netgen for SALOME NETGEN Plugin
------------------------------------------
+ $ wget https://vorboss.dl.sourceforge.net/project/netgen-mesher/netgen-mesher/5.3/netgen-5.3.1.tar.gz
-2.1. Download Netgen archive (here netgen-4.9.13.tar.gz) and unpack it
+3.2. Unpack an archive:
-2.2. Patch the Netgen distribution for SALOME
+ $ tar xfz netgen-5.3.1.tar.gz
- $ cd netgen45
- $ patch -p1 < patch_directory/netgen49ForSalome.patch
+3.3. Patch the Netgen distribution for SALOME
- Note that patch corresponds to the version of Netgen you use.
- For example, netgen49ForSalome.patch mentioned above is a patch
- file for Netgen 4.9.13. The patch for Netgen can be found in
- NETGENPLUGIN_SRC/src/NETGEN directory.
+ $ cd netgen-5.3.1
+ $ patch -p1 < /path/to/netgenplugin_src_dir/src/NETGEN/netgen53ForSalome.patch
-2.3. Configure the netgen compilation. For example
+ Here, "/path/to/netgenplugin_src_dir" is a path to NETGENPLUGIN source directory.
+ This is the same directory where this Readme file is located.
+ Netgen plugin sources can be retrieved from the Git repository:
+
+ $ git clone http://git.salome-platform.org/gitpub/plugins/netgenplugin.git
- $ cd netgen-4.9.13
- $ ./configure --prefix=THE_INSTALLATION_PATH \
- --with-occ=${CASROOT} \
+3.4. Configure the netgen compilation:
+
+ $ cd netgen-5.3.1
+ $ ./configure --prefix=/path/to/the/installation/directory \
+ --with-occ=${CAS_ROOT_DIR} \
--with-tcl=${TCLHOME}/lib --with-tk=${TCLHOME}/lib \
--with-tclinclude=${TCLHOME}/include
- Note that Netgen depends on some products like Open CASCADE
- Technology and Tcl/Tk. These products should be specified
- to the configure script via options.
+ Note: Netgen depends on some products like Open CASCADE Technology and Tcl/Tk.
+ These products should be specified to the configure script via options.
+
+3.5. Compile and install netgen mesher:
+
+ $ make install
+
+3.6. Patch the installation directory by copying header files
+ needed by NETGEN Plugin. For this purpose you can use the script
+ /path/to/netgenplugin_src_dir/src/NETGEN/netgen_copy_include_for_salome.
-2.4. Compile the netgen product
- $ make
- $ make install
+ $ /path/to/netgenplugin_src_dir/src/NETGEN/netgen_copy_include_for_salome \
+ . /path/to/the/installation/directory
-2.5. Patch the installation directory by copying include files
- needed by NETGEN Plugin. Use the script
- NETGENPLUGIN_SRC/src/NETGEN/netgen_copy_include_for_salome
- to achieve that. The first argument is the directory containing
- the Netgen sources. The second argument is THE_INSTALLATION_PATH
+ The first argument is the directory containing the Netgen sources.
+ The second argument is the installation directory of Netgen mesher.
+++ /dev/null
-diff -Naur netgen-4.9.13_orig/libsrc/meshing/meshtype.cpp netgen-4.9.13_new/libsrc/meshing/meshtype.cpp
---- netgen-4.9.13_orig/libsrc/meshing/meshtype.cpp 2009-09-13 14:28:38.000000000 +0400
-+++ netgen-4.9.13_new/libsrc/meshing/meshtype.cpp 2014-07-22 13:01:28.000000000 +0400
-@@ -1,4 +1,5 @@
- #include <mystdlib.h>
-+#include <float.h> // to get DBL_MIN defined
-
- #include "meshing.hpp"
-
-@@ -650,7 +651,8 @@
-
- double det = trans.Det();
-
-- if (det <= 0)
-+ // if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- err += 1e12;
- else
- err += frob * frob / det;
-@@ -706,7 +708,8 @@
-
- double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1);
-
-- if (det <= 0)
-+ // if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- {
- dd = 0;
- return 1e12;
-@@ -790,7 +793,8 @@
- = dtrans(0,0) * trans(1,1) - trans(0,1) * dtrans(1,0)
- + trans(0,0) * dtrans(1,1) - dtrans(0,1) * trans(1,0);
-
-- if (det <= 0)
-+ // if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- err += 1e12;
- else
- {
-@@ -840,7 +844,8 @@
- frob /= 2;
-
- double det = trans.Det();
-- if (det <= 0)
-+ //if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- err += 1e12;
- else
- err += frob * frob / det;
-@@ -1857,7 +1862,8 @@
- case PYRAMID:
- {
- double noz = 1-p(2);
-- if (noz == 0.0) noz = 1e-10;
-+ //if (noz == 0.0) noz = 1e-10;
-+ if (noz <= DBL_MIN) noz = 1e-10; // avoid FPE
-
- double xi = p(0) / noz;
- double eta = p(1) / noz;
-@@ -2035,7 +2041,8 @@
-
- double det = -trans.Det();
-
-- if (det <= 0)
-+ //if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- err += 1e12;
- else
- err += frob * frob * frob / det;
-@@ -2107,7 +2114,8 @@
- ddet *= -1;
-
-
-- if (det <= 0)
-+ //if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- err += 1e12;
- else
- {
-@@ -2189,7 +2197,7 @@
-
- det *= -1;
-
-- if (det <= 0)
-+ if (det <= DBL_MIN)
- err += 1e12;
- else
- {
-@@ -2522,10 +2530,10 @@
-
- MeshingParameters :: MeshingParameters ()
- {
-- optimize3d = "cmdmustm";
-+ optimize3d = (char*)"cmdmustm"; // optimize3d = "cmdmustm";
- //optimize3d = "cmdmstm";
- optsteps3d = 3;
-- optimize2d = "smsmsmSmSmSm";
-+ optimize2d = (char*)"smsmsmSmSmSm"; // optimize2d = "smsmsmSmSmSm";
- optsteps2d = 3;
- opterrpow = 2;
- blockfill = 1;
-diff -Naur netgen-4.9.13_orig/libsrc/meshing/meshtype.hpp netgen-4.9.13_new/libsrc/meshing/meshtype.hpp
---- netgen-4.9.13_orig/libsrc/meshing/meshtype.hpp 2009-11-09 13:50:43.000000000 +0300
-+++ netgen-4.9.13_new/libsrc/meshing/meshtype.hpp 2014-07-22 13:01:28.000000000 +0400
-@@ -12,6 +12,7 @@
- Classes for NETGEN
- */
-
-+class Mesh; // added due to compilation errors on some platforms
-
- enum ELEMENT_TYPE {
- SEGMENT = 1, SEGMENT3 = 2,
-diff -Naur netgen-4.9.13_orig/libsrc/meshing/smoothing2.cpp netgen-4.9.13_new/libsrc/meshing/smoothing2.cpp
---- netgen-4.9.13_orig/libsrc/meshing/smoothing2.cpp 2009-11-09 13:47:09.000000000 +0300
-+++ netgen-4.9.13_new/libsrc/meshing/smoothing2.cpp 2014-07-22 13:01:28.000000000 +0400
-@@ -302,7 +302,8 @@
- vgrad = 0;
- badness = 0;
-
-- meshthis -> GetNormalVector (surfi, sp1, gi1, n);
-+ //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
-+ n = normal;
- pp1 = sp1 + x(0) * t1 + x(1) * t2;
-
- // meshthis -> ProjectPoint (surfi, pp1);
-@@ -360,7 +361,8 @@
- vgrad = 0;
- badness = 0;
-
-- meshthis -> GetNormalVector (surfi, sp1, gi1, n);
-+ //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
-+ n = normal;
-
- pp1 = sp1 + x(0) * t1 + x(1) * t2;
-
-@@ -514,7 +516,8 @@
- vgrad = 0;
- badness = 0;
-
-- meshthis -> GetNormalVector (surfi, sp1, gi1, n);
-+ //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
-+ n = normal;
-
- pp1 = sp1 + x(0) * t1 + x(1) * t2;
-
-@@ -586,7 +589,8 @@
- vgrad = 0;
- badness = 0;
-
-- meshthis -> GetNormalVector (surfi, sp1, gi1, n);
-+ //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
-+ n = normal;
-
- // pp1 = sp1;
- // pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
-@@ -973,7 +977,7 @@
- {
- mesh[pi] = Point<3> (origp);
- }
--
-+ break; // exit as <fact> is not used anymore
- }
- }
-
-diff -Naur netgen-4.9.13_orig/libsrc/occ/occconstruction.cpp netgen-4.9.13_new/libsrc/occ/occconstruction.cpp
---- netgen-4.9.13_orig/libsrc/occ/occconstruction.cpp 2009-08-24 06:32:47.000000000 +0400
-+++ netgen-4.9.13_new/libsrc/occ/occconstruction.cpp 2014-07-22 13:01:28.000000000 +0400
-@@ -28,7 +28,7 @@
- #include <BRepAlgoAPI_Common.hxx>
- #include <BRepAlgoAPI_Fuse.hxx>
- #include <BRepAlgoAPI_Section.hxx>
--#include <BRepOffsetAPI_Sewing.hxx>
-+//#include <BRepOffsetAPI_Sewing.hxx>
- //#include <BRepAlgo_Sewing.hxx>
- #include <BRepOffsetAPI_MakeOffsetShape.hxx>
- #include <ShapeFix_Shape.hxx>
-diff -Naur netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp
---- netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp 2010-03-16 09:30:07.000000000 +0300
-+++ netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp 2014-07-22 13:01:28.000000000 +0400
-@@ -15,6 +15,8 @@
-
- #define DIVIDEEDGESECTIONS 1000
- #define IGNORECURVELENGTH 1e-4
-+// a small value used to avoid FPE
-+#define VSMALL 1e-10
-
-
- bool merge_solids = 1;
-@@ -26,7 +28,8 @@
- double nq = n*q;
-
- Point<3> p = p0 + 0.5*n;
-- double lambda = (p-l.p0)*n / nq;
-+ // double lambda = (p-l.p0)*n / nq; -- avoid FPE
-+ double lambda = (fabs(nq) > 1e-10) ? (p-l.p0)*n / nq : -1;
-
- if (lambda >= 0 && lambda <= 1)
- {
-@@ -54,6 +57,8 @@
-
-
-
-+
-+ static // useless out of this file
- double ComputeH (double kappa)
- {
- double hret;
-@@ -62,7 +67,8 @@
- if (mparam.maxh * kappa < 1)
- hret = mparam.maxh;
- else
-- hret = 1 / kappa;
-+ // hret = 1 / kappa; -- avoid FPE
-+ hret = 1 / (kappa + VSMALL);
-
- if (mparam.maxh < hret)
- hret = mparam.maxh;
-@@ -71,8 +77,7 @@
- }
-
-
--
--
-+ static // useless out of this file
- void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
- BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h = 0)
- {
-@@ -168,8 +173,8 @@
- if(h < 1e-4*maxside)
- return;
-
--
-- if (h > 30) return;
-+ // commented to restrict H on a large sphere for example
-+ //if (h > 30) return;
- }
-
- if (h < maxside && depth < 10)
-@@ -228,6 +233,7 @@
-
-
-
-+ static // useless out of this file
- void DivideEdge (TopoDS_Edge & edge, Array<MeshPoint> & ps,
- Array<double> & params, Mesh & mesh)
- {
-@@ -247,8 +253,8 @@
- hvalue[0] = 0;
- pnt = c->Value(s0);
-
-- double olddist = 0;
-- double dist = 0;
-+ //double olddist = 0; -- useless variables
-+ //double dist = 0;
-
- int tmpVal = (int)(DIVIDEEDGESECTIONS);
-
-@@ -256,15 +262,19 @@
- {
- oldpnt = pnt;
- pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
-+ // -- no more than 1 segment per <edge length>/DIVIDEEDGESECTIONS
- hvalue[i] = hvalue[i-1] +
-- 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
-- pnt.Distance(oldpnt);
-+ // 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
-+ // pnt.Distance(oldpnt);
-+ min( 1.0,
-+ 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
-+ pnt.Distance(oldpnt));
-
- //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
- // << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
-
-- olddist = dist;
-- dist = pnt.Distance(oldpnt);
-+ //olddist = dist; -- useless variables
-+ //dist = pnt.Distance(oldpnt);
- }
-
- // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
-@@ -279,7 +289,10 @@
- {
- if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)
- {
-- params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
-+ // -- for nsubedges comparable to DIVIDEEDGESECTIONS
-+ //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
-+ double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]);
-+ params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0);
- pnt = c->Value(params[i]);
- ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));
- i++;
-@@ -323,6 +336,9 @@
- (*testout) << "nedges = " << nedges << endl;
-
- double eps = 1e-6 * geom.GetBoundingBox().Diam();
-+ const double eps2 = eps * eps; // -- small optimization
-+
-+ int first_vp = mesh.GetNP()+1; // -- to support SALOME sub-meshes
-
- for (int i = 1; i <= nvertices; i++)
- {
-@@ -332,7 +348,8 @@
- bool exists = 0;
- if (merge_solids)
- for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
-- if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
-+ //if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
-+ if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 ) // -- small optimization
- {
- exists = 1;
- break;
-@@ -362,6 +379,7 @@
- {
- TopoDS_Face face = TopoDS::Face(exp1.Current());
- int facenr = geom.fmap.FindIndex(face);
-+ if ( facenr < 1 ) continue; // -- to support SALOME sub-meshes
-
- if (face2solid[0][facenr-1] == 0)
- face2solid[0][facenr-1] = solidnr;
-@@ -381,6 +399,7 @@
- int facenr = 0;
- int edgenr = 0;
-
-+ edgenr = mesh.GetNSeg(); // to support SALOME sub-meshes
-
- (*testout) << "faces = " << geom.fmap.Extent() << endl;
- int curr = 0;
-@@ -442,6 +461,7 @@
- //(*testout) << "ignoring degenerated edge" << endl;
- continue;
- }
-+ if ( geom.emap.FindIndex(edge) < 1 ) continue; // to support SALOME sub-meshes
-
- if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
- geom.vmap.FindIndex(TopExp::LastVertex (edge)))
-@@ -474,20 +494,104 @@
-
- if (!merge_solids)
- {
-- pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge));
-- pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge));
-+ //pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge));
-+ //pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge));
-+ MeshPoint dfltP ( Point<3> ( 0, 0, 0 ) );
-+ int *ipp[] = { &pnums[0], &pnums[pnums.Size()-1] };
-+ TopoDS_Iterator vIt( edge, false );
-+ TopoDS_Vertex v[2];
-+ v[0] = TopoDS::Vertex( vIt.Value() ); vIt.Next();
-+ v[1] = TopoDS::Vertex( vIt.Value() );
-+ if ( v[0].Orientation() == TopAbs_REVERSED )
-+ std::swap( v[0], v[1] );
-+ for ( int i = 0; i < 2; ++i)
-+ {
-+ int &ip = *ipp[i];
-+ ip = geom.vmap.FindIndex ( v[i] );
-+ if ( ip == 0 || ip > nvertices )
-+ {
-+ int iv = ip;
-+ if ( ip == 0 )
-+ ip = iv = geom.vmap.Add( v[i] );
-+ gp_Pnt pnt = BRep_Tool::Pnt( v[i] );
-+ MeshPoint mp( Point<3>(pnt.X(), pnt.Y(), pnt.Z()) );
-+ for (PointIndex pi = 1; pi < first_vp; pi++)
-+ if ( Dist2 (mesh.Point(pi), Point<3>(mp)) < 1e-100 )
-+ {
-+ ip = pi;
-+ if ( mesh.Point(ip).GetLayer() != dfltP.GetLayer() && mesh.Point(ip).GetLayer() != iv )
-+ continue;
-+ if ( mesh.Point(ip).GetLayer() == dfltP.GetLayer())
-+ mesh.Point(ip) = MeshPoint( mesh.Point(ip), iv );
-+ break;
-+ }
-+ }
-+ else
-+ {
-+ ip += first_vp - 1;
-+ }
-+ }
- }
- else
- {
-- Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
-- Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
-+ TopoDS_Iterator vIt( edge, false );
-+ TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next();
-+ TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() );
-+ if ( v1.Orientation() == TopAbs_REVERSED )
-+ std::swap( v1, v2 );
-+ const bool isClosedEdge = v1.IsSame( v2 );
-+
-+ Point<3> fp = occ2ng (BRep_Tool::Pnt (v1));
-+ Point<3> lp = occ2ng (BRep_Tool::Pnt (v2));
-+ double tol2 = std::min( eps*eps, 1e-6 * Dist2( fp, lp ));
-+ if ( isClosedEdge )
-+ tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 );
-
- pnums[0] = -1;
- pnums.Last() = -1;
- for (PointIndex pi = 1; pi < first_ep; pi++)
- {
-- if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
-- if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
-+ if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi;
-+ if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi;
-+ }
-+ if (( isClosedEdge && pnums[0] != pnums.Last() ) ||
-+ ( !isClosedEdge && pnums[0] == pnums.Last() ))
-+ pnums[0] = pnums.Last() = -1;
-+ if ( pnums[0] == -1 || pnums.Last() == -1 )
-+ {
-+ // take into account a possible large gap between a vertex and an edge curve
-+ // end and a large vertex tolerance covering the whole edge
-+ if ( pnums[0] == -1 )
-+ {
-+ double tol = BRep_Tool::Tolerance( v1 );
-+ for (PointIndex pi = 1; pi < first_ep; pi++)
-+ if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol)
-+ pnums[0] = pi;
-+
-+ if ( pnums[0] == -1 )
-+ pnums[0] = first_ep-1- nvertices + geom.vmap.FindIndex ( v1 );
-+ }
-+ if ( isClosedEdge )
-+ {
-+ pnums.Last() = pnums[0];
-+ }
-+ else
-+ {
-+ if ( pnums.Last() == -1 )
-+ {
-+ double tol = BRep_Tool::Tolerance( v2 );
-+ for (PointIndex pi = 1; pi < first_ep; pi++)
-+ if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol)
-+ pnums.Last() = pi;
-+
-+ if ( pnums.Last() == -1 )
-+ pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 );
-+ }
-+
-+ if ( Dist2( fp, mesh[PointIndex(pnums[0])]) >
-+ Dist2( lp, mesh[PointIndex(pnums.Last())]))
-+ std::swap( pnums[0], pnums.Last() );
-+ }
- }
- }
-
-@@ -497,17 +601,20 @@
- bool exists = 0;
- int j;
- for (j = first_ep; j <= mesh.GetNP(); j++)
-+ {
-+ if (!merge_solids && mesh.Point(j).GetLayer() != geomedgenr ) continue; // to support SALOME fuse edges
- if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
- {
- exists = 1;
- break;
- }
-+ }
-
- if (exists)
- pnums[i] = j;
- else
- {
-- mesh.AddPoint (mp[i-1]);
-+ mesh.AddPoint (mp[i-1], geomedgenr); // to support SALOME fuse edges
- (*testout) << "add meshpoint " << mp[i-1] << endl;
- pnums[i] = mesh.GetNP();
- }
-@@ -591,6 +698,8 @@
- // (*testout) << "edge " << mesh.LineSegment(i).edgenr << " face " << mesh.LineSegment(i).si
- // << " p1 " << mesh.LineSegment(i)[0] << " p2 " << mesh.LineSegment(i)[1] << endl;
- // exit(10);
-+ for (int j = 1; j <= mesh.GetNP(); j++) // to support SALOME fuse edges: set level to zero
-+ mesh.Point(j) = MeshPoint( (Point<3>&) mesh.Point(j) );
-
- mesh.CalcSurfacesOfNode();
- multithread.task = savetask;
-@@ -633,7 +742,8 @@
- }
-
- (*testout) << "mesh face " << k << endl;
-- multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
-+ // multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); -- avoid FPE
-+ multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
- geom.facemeshstatus[k-1] = -1;
-
-
-@@ -901,7 +1011,8 @@
- // if (k != 36) continue;
-
- // (*testout) << "optimize face " << k << endl;
-- multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
-+ //multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); -- avoid FPE
-+ multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
-
- FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
-
-@@ -1456,3 +1567,4 @@
- }
-
- #endif
-+
-diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.cpp netgen-4.9.13_new/libsrc/occ/occgeom.cpp
---- netgen-4.9.13_orig/libsrc/occ/occgeom.cpp 2010-03-05 16:16:21.000000000 +0300
-+++ netgen-4.9.13_new/libsrc/occ/occgeom.cpp 2014-07-22 13:01:28.000000000 +0400
-@@ -8,6 +8,8 @@
- #include "ShapeAnalysis_CheckSmallFace.hxx"
- #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
- #include "ShapeAnalysis_Surface.hxx"
-+#include <BRepTopAdaptor_FClass2d.hxx> // -- to optimize Project() and FastProject()
-+#include <TopAbs_State.hxx>
- #include "BRepAlgoAPI_Fuse.hxx"
- #include "BRepCheck_Analyzer.hxx"
- #include "BRepLib.hxx"
-@@ -16,10 +18,17 @@
- #include "ShapeFix_FixSmallFace.hxx"
- #include "Partition_Spliter.hxx"
-
--
- namespace netgen
- {
-- void OCCGeometry :: PrintNrShapes ()
-+ // free data used to optimize Project() and FastProject()
-+ OCCGeometry::~OCCGeometry()
-+ {
-+ NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
-+ for (; it.More(); it.Next())
-+ delete it.Value();
-+ }
-+
-+ void OCCGeometry :: PrintNrShapes ()
- {
- TopExp_Explorer e;
- int count = 0;
-@@ -951,25 +960,58 @@
- }
-
-
-+ // returns a projector and a classifier for the given surface
-+ void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
-+ BRepTopAdaptor_FClass2d*& cls) const
-+ {
-+ //MSV: organize caching projector in the map
-+ if (fprjmap.IsBound(surfi))
-+ {
-+ proj = fprjmap.Find(surfi);
-+ cls = fclsmap.Find(surfi);
-+ }
-+ else
-+ {
-+ const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
-+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
-+ proj = new ShapeAnalysis_Surface(aSurf);
-+ fprjmap.Bind(surfi, proj);
-+ cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
-+ fclsmap.Bind(surfi, cls);
-+ }
-+ }
-
--
-- void OCCGeometry :: Project (int surfi, Point<3> & p) const
-+ // void OCCGeometry :: Project (int surfi, Point<3> & p) const
-+ bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
- {
- static int cnt = 0;
- if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
-
- gp_Pnt pnt(p(0), p(1), p(2));
-
-- double u,v;
-- Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
-- Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
-- gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
-- suval.Coord( u, v);
-- pnt = thesurf->Value( u, v );
--
--
-+ // -- Optimization: use cached projector and classifier
-+ // double u,v;
-+ // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
-+ // Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
-+ // gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
-+ // suval.Coord( u, v);
-+ // pnt = thesurf->Value( u, v );
-+
-+ Handle(ShapeAnalysis_Surface) proj;
-+ BRepTopAdaptor_FClass2d *cls;
-+ GetFaceTools(surfi, proj, cls);
-+
-+ gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
-+ if (cls->Perform(p2d) == TopAbs_OUT)
-+ {
-+ return false;
-+ }
-+ pnt = proj->Value(p2d);
-+ p2d.Coord(u, v);
-+
- p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
-
-+ return true;
- }
-
-
-@@ -979,54 +1021,69 @@
- {
- gp_Pnt p(ap(0), ap(1), ap(2));
-
-- Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
--
-- gp_Pnt x = surface->Value (u,v);
--
-- if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
--
-- gp_Vec du, dv;
--
-- surface->D1(u,v,x,du,dv);
--
-- int count = 0;
--
-- gp_Pnt xold;
-- gp_Vec n;
-- double det, lambda, mu;
--
-- do {
-- count++;
--
-- n = du^dv;
--
-- det = Det3 (n.X(), du.X(), dv.X(),
-- n.Y(), du.Y(), dv.Y(),
-- n.Z(), du.Z(), dv.Z());
--
-- if (det < 1e-15) return false;
--
-- lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
-- n.Y(), p.Y()-x.Y(), dv.Y(),
-- n.Z(), p.Z()-x.Z(), dv.Z())/det;
--
-- mu = Det3 (n.X(), du.X(), p.X()-x.X(),
-- n.Y(), du.Y(), p.Y()-x.Y(),
-- n.Z(), du.Z(), p.Z()-x.Z())/det;
--
-- u += lambda;
-- v += mu;
--
-- xold = x;
-- surface->D1(u,v,x,du,dv);
--
-- } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
--
-- // (*testout) << "FastProject count: " << count << endl;
--
-- if (count == 50) return false;
--
-- ap = Point<3> (x.X(), x.Y(), x.Z());
-+ // -- Optimization: use cached projector and classifier
-+ // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
-+ //
-+ // gp_Pnt x = surface->Value (u,v);
-+ //
-+ // if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
-+ //
-+ // gp_Vec du, dv;
-+ //
-+ // surface->D1(u,v,x,du,dv);
-+ //
-+ // int count = 0;
-+ //
-+ // gp_Pnt xold;
-+ // gp_Vec n;
-+ // double det, lambda, mu;
-+ //
-+ // do {
-+ // count++;
-+ //
-+ // n = du^dv;
-+ //
-+ // det = Det3 (n.X(), du.X(), dv.X(),
-+ // n.Y(), du.Y(), dv.Y(),
-+ // n.Z(), du.Z(), dv.Z());
-+ //
-+ // if (det < 1e-15) return false;
-+ //
-+ // lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
-+ // n.Y(), p.Y()-x.Y(), dv.Y(),
-+ // n.Z(), p.Z()-x.Z(), dv.Z())/det;
-+ //
-+ // mu = Det3 (n.X(), du.X(), p.X()-x.X(),
-+ // n.Y(), du.Y(), p.Y()-x.Y(),
-+ // n.Z(), du.Z(), p.Z()-x.Z())/det;
-+ //
-+ // u += lambda;
-+ // v += mu;
-+ //
-+ // xold = x;
-+ // surface->D1(u,v,x,du,dv);
-+ //
-+ // } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
-+ //
-+ // // (*testout) << "FastProject count: " << count << endl;
-+ //
-+ // if (count == 50) return false;
-+ //
-+ // ap = Point<3> (x.X(), x.Y(), x.Z());
-+ Handle(ShapeAnalysis_Surface) proj;
-+ BRepTopAdaptor_FClass2d *cls;
-+ GetFaceTools(surfi, proj, cls);
-+
-+ gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
-+ if (cls->Perform(p2d) == TopAbs_OUT)
-+ {
-+ //cout << "Projection fails" << endl;
-+ return false;
-+ }
-+
-+ p = proj->Value(p2d);
-+ p2d.Coord(u, v);
-+ ap = Point<3> (p.X(), p.Y(), p.Z());
-
- return true;
- }
-@@ -1038,9 +1095,9 @@
- {
- cout << "writing stl..."; cout.flush();
- StlAPI_Writer writer;
-- writer.RelativeMode() = Standard_False;
-+ // writer.RelativeMode() = Standard_False;
-
-- writer.SetDeflection(0.02);
-+ // writer.SetDeflection(0.02);
- writer.Write(shape,filename);
-
- cout << "done" << endl;
-diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.hpp netgen-4.9.13_new/libsrc/occ/occgeom.hpp
---- netgen-4.9.13_orig/libsrc/occ/occgeom.hpp 2010-01-14 19:56:19.000000000 +0300
-+++ netgen-4.9.13_new/libsrc/occ/occgeom.hpp 2014-07-22 13:09:03.000000000 +0400
-@@ -15,8 +15,8 @@
- #include "Geom_Curve.hxx"
- #include "Geom2d_Curve.hxx"
- #include "Geom_Surface.hxx"
--#include "GeomAPI_ProjectPointOnSurf.hxx"
--#include "GeomAPI_ProjectPointOnCurve.hxx"
-+// #include "GeomAPI_ProjectPointOnSurf.hxx"
-+// #include "GeomAPI_ProjectPointOnCurve.hxx"
- #include "BRepTools.hxx"
- #include "TopExp.hxx"
- #include "BRepBuilderAPI_MakeVertex.hxx"
-@@ -42,8 +42,8 @@
- #include "Geom_Curve.hxx"
- #include "Geom2d_Curve.hxx"
- #include "Geom_Surface.hxx"
--#include "GeomAPI_ProjectPointOnSurf.hxx"
--#include "GeomAPI_ProjectPointOnCurve.hxx"
-+// #include "GeomAPI_ProjectPointOnSurf.hxx"
-+// #include "GeomAPI_ProjectPointOnCurve.hxx"
- #include "TopoDS_Wire.hxx"
- #include "BRepTools_WireExplorer.hxx"
- #include "BRepTools.hxx"
-@@ -68,18 +68,26 @@
- #include "IGESToBRep_Reader.hxx"
- #include "Interface_Static.hxx"
- #include "GeomAPI_ExtremaCurveCurve.hxx"
--#include "Standard_ErrorHandler.hxx"
-+//#include "Standard_ErrorHandler.hxx"
- #include "Standard_Failure.hxx"
- #include "ShapeUpgrade_ShellSewing.hxx"
- #include "ShapeFix_Shape.hxx"
- #include "ShapeFix_Wireframe.hxx"
-+#include <Standard_Version.hxx>
-+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) <= 0x060702
-+// porting to OCCT6.7.3
- #include "BRepMesh.hxx"
-+#endif
- #include "BRepMesh_IncrementalMesh.hxx"
- #include "BRepBndLib.hxx"
- #include "Bnd_Box.hxx"
- #include "ShapeAnalysis.hxx"
- #include "ShapeBuild_ReShape.hxx"
-
-+// -- Optimization: to use cached projector and classifier
-+#include <NCollection_DataMap.hxx>
-+class Handle_ShapeAnalysis_Surface;
-+class BRepTopAdaptor_FClass2d;
-
- // Philippose - 29/01/2009
- // OpenCascade XDE Support
-@@ -190,6 +198,9 @@
- class OCCGeometry : public NetgenGeometry
- {
- Point<3> center;
-+ // -- Optimization: to use cached projector and classifier
-+ mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
-+ mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
-
- public:
- TopoDS_Shape shape;
-@@ -241,6 +252,8 @@
- vmap.Clear();
- }
-
-+ ~OCCGeometry(); // -- to free cached projector and classifier
-+
- void BuildFMap();
-
- Box<3> GetBoundingBox()
-@@ -260,9 +273,14 @@
- Point<3> Center()
- { return center;}
-
-- void Project (int surfi, Point<3> & p) const;
-+ // void Project (int surfi, Point<3> & p) const; -- optimization
-+ bool Project (int surfi, Point<3> & p, double& u, double& v) const;
- bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
-
-+ // -- Optimization: to use cached projector and classifier
-+ void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
-+ BRepTopAdaptor_FClass2d*& cls) const;
-+
- OCCSurface GetSurface (int surfi)
- {
- cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
-diff -Naur netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp
---- netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp 2009-08-24 06:32:47.000000000 +0400
-+++ netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp 2014-07-22 13:01:28.000000000 +0400
-@@ -6,6 +6,7 @@
- #include <meshing.hpp>
- #include <GeomLProp_SLProps.hxx>
- #include <ShapeAnalysis_Surface.hxx>
-+#include <GeomAPI_ProjectPointOnCurve.hxx> // -- moved here from occgeom.hpp
-
-
- namespace netgen
-@@ -434,23 +435,33 @@
-
- void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
- {
-- geometry.Project (surfind, p);
-+ // geometry.Project (surfind, p); -- signature of Project() changed for optimization
-+ double u, v;
-+ geometry.Project (surfind, p, u, v);
- }
-
-
- int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
- {
-- double u = gi.u;
-- double v = gi.v;
-+ //double u = gi.u;
-+ //double v = gi.v;
-
- Point<3> hp = p;
-- if (geometry.FastProject (surfind, hp, u, v))
-- {
-- p = hp;
-- return 1;
-- }
-- ProjectPoint (surfind, p);
-- return CalcPointGeomInfo (surfind, gi, p);
-+ // -- u and v are computed by FastProject() and Project(), no need to call CalcPointGeomInfo()
-+ // if (geometry.FastProject (surfind, hp, u, v))
-+ // {
-+ // p = hp;
-+ // return 1;
-+ // }
-+ // ProjectPoint (surfind, p);
-+ // return CalcPointGeomInfo (surfind, gi, p);
-+ bool ok;
-+ if (gi.trignum > 0)
-+ ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
-+ else
-+ ok = geometry.Project (surfind, hp, gi.u, gi.v);
-+ p = hp;
-+ return ok;
- }
-
-
-@@ -680,7 +691,8 @@
- if (!geometry.FastProject (surfi, hnewp, u, v))
- {
- // cout << "Fast projection to surface fails! Using OCC projection" << endl;
-- geometry.Project (surfi, hnewp);
-+ // geometry.Project (surfi, hnewp); -- Project() changed for optimization
-+ geometry.Project (surfi, hnewp, u, v);
- }
-
- newgi.trignum = 1;
-@@ -689,7 +701,7 @@
- }
-
- newp = hnewp;
-- }
-+ }//; -- to compile with -Wall -pedantic
-
-
- void OCCRefinementSurfaces ::
-@@ -708,14 +720,18 @@
- hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
- newp = hnewp;
- newgi = ap1;
-- };
-+ }
-
-
- void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi)
- {
- if (surfi > 0)
-- geometry.Project (surfi, p);
-- };
-+ // geometry.Project (surfi, p); -- Project() changed for optimization
-+ {
-+ double u, v;
-+ geometry.Project (surfi, p, u, v);
-+ }
-+ }//; -- to compile with -Wall -pedantic
-
- void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi)
- {
-@@ -723,9 +739,10 @@
- if (!geometry.FastProject (surfi, p, gi.u, gi.v))
- {
- cout << "Fast projection to surface fails! Using OCC projection" << endl;
-- geometry.Project (surfi, p);
-+ double u, v;
-+ geometry.Project (surfi, p, u, v);
- }
-- };
-+ }
-
-
-
-diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Inter3d.cxx netgen-4.9.13_new/libsrc/occ/Partition_Inter3d.cxx
---- netgen-4.9.13_orig/libsrc/occ/Partition_Inter3d.cxx 2009-08-24 06:12:24.000000000 +0400
-+++ netgen-4.9.13_new/libsrc/occ/Partition_Inter3d.cxx 2014-07-22 13:01:28.000000000 +0400
-@@ -86,6 +86,9 @@
- #include <TopOpeBRepTool_OutCurveType.hxx>
- #include <TopOpeBRep_DSFiller.hxx>
- #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
-+
-+#include <Standard_Version.hxx>
-+
- #include <stdio.h>
-
- //=======================================================================
-@@ -243,7 +246,12 @@
- Standard_Integer i, nbExt = anExtPS.NbExt();
- Extrema_POnSurf aPOnSurf;
- for (i = 1; i <= nbExt; ++i )
-+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
-+// porting to OCCT6.5.1
-+ if (anExtPS.SquareDistance( i ) <= TolE * TolE) {
-+#else
- if (anExtPS.Value( i ) <= TolE) {
-+#endif
- aPOnSurf = anExtPS.Point( i );
- break;
- }
-diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Loop2d.cxx netgen-4.9.13_new/libsrc/occ/Partition_Loop2d.cxx
---- netgen-4.9.13_orig/libsrc/occ/Partition_Loop2d.cxx 2009-08-24 06:12:24.000000000 +0400
-+++ netgen-4.9.13_new/libsrc/occ/Partition_Loop2d.cxx 2014-07-22 13:01:28.000000000 +0400
-@@ -22,7 +22,6 @@
- #include <BRepAdaptor_Surface.hxx>
- #include <BRepAlgo_AsDes.hxx>
- #include <BRepAlgo_FaceRestrictor.hxx>
--#include <BRepOffset_DataMapOfShapeReal.hxx>
- #include <BRepTopAdaptor_FClass2d.hxx>
- #include <BRep_Builder.hxx>
- #include <BRep_Tool.hxx>
-@@ -51,6 +50,15 @@
- #include <gp_Pnt.hxx>
- #include <gp_Pnt2d.hxx>
-
-+#include <Standard_Version.hxx>
-+
-+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
-+// porting to OCCT6.5.1
-+#include <TopTools_DataMapOfShapeReal.hxx>
-+#else
-+#include <BRepOffset_DataMapOfShapeReal.hxx>
-+#endif
-+
- //=======================================================================
- //function : Partition_Loop2d
- //purpose :
-@@ -209,7 +217,7 @@
- Cc->D1(uc, PC, CTg1);
- if (!isForward) CTg1.Reverse();
-
-- Standard_Real anglemin = 3 * PI, tolAng = 1.e-8;
-+ Standard_Real anglemin = 3 * M_PI, tolAng = 1.e-8;
-
- // select an edge whose first derivative is most left of CTg1
- // ie an angle between Tg1 and CTg1 is least
-@@ -233,7 +241,7 @@
- // -PI < angle < PI
- Standard_Real angle = Tg1.Angle(CTg1);
-
-- if (PI - Abs(angle) <= tolAng)
-+ if (M_PI - Abs(angle) <= tolAng)
- {
- // an angle is too close to PI; assure that an angle sign really
- // reflects an edge position: +PI - an edge is worst,
-@@ -519,7 +527,12 @@
- DC.Initialize( DegEdge, F );
-
- // avoid intersecting twice the same edge
-+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
-+// porting to OCCT6.5.1
-+ TopTools_DataMapOfShapeReal EUMap ( EdgesList.Extent() );
-+#else
- BRepOffset_DataMapOfShapeReal EUMap ( EdgesList.Extent() );
-+#endif
-
- Standard_Real U, f, l;
- BRep_Tool::Range (DegEdge, f, l);
-diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Loop.cxx netgen-4.9.13_new/libsrc/occ/Partition_Loop.cxx
---- netgen-4.9.13_orig/libsrc/occ/Partition_Loop.cxx 2009-08-24 06:12:24.000000000 +0400
-+++ netgen-4.9.13_new/libsrc/occ/Partition_Loop.cxx 2014-07-22 13:01:28.000000000 +0400
-@@ -178,7 +178,7 @@
- }
- }
-
-- Standard_Real anglemax = - PI;
-+ Standard_Real anglemax = - M_PI;
- TopoDS_Edge SelectedEdge;
- for ( itl.Initialize(LE); itl.More(); itl.Next()) {
- const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
-diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Spliter.cxx netgen-4.9.13_new/libsrc/occ/Partition_Spliter.cxx
---- netgen-4.9.13_orig/libsrc/occ/Partition_Spliter.cxx 2009-08-24 06:12:24.000000000 +0400
-+++ netgen-4.9.13_new/libsrc/occ/Partition_Spliter.cxx 2014-07-22 13:01:28.000000000 +0400
-@@ -79,6 +79,8 @@
- #include <GeomAdaptor_Curve.hxx>
- #include <TopOpeBRepTool_CurveTool.hxx>
-
-+#include <Standard_Version.hxx>
-+
- #ifdef DEB
- //# define PART_PERF
- #endif
-@@ -1169,7 +1171,12 @@
- for (; j<=nbj && ok; ++j) {
- if (Extrema.IsMin(j)) {
- hasMin = Standard_True;
-+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
-+// porting to OCCT6.5.1
-+ ok = Extrema.SquareDistance(j) <= tol * tol;
-+#else
- ok = Extrema.Value(j) <= tol;
-+#endif
- }
- }
- }
-diff -Naur netgen-4.9.13_orig/libsrc/occ/utilities.h netgen-4.9.13_new/libsrc/occ/utilities.h
---- netgen-4.9.13_orig/libsrc/occ/utilities.h 2009-08-24 06:12:24.000000000 +0400
-+++ netgen-4.9.13_new/libsrc/occ/utilities.h 2014-07-22 13:01:28.000000000 +0400
-@@ -33,6 +33,7 @@
-
- #include <string>
- #include <iostream>
-+#include <iomanip>
- #include <cstdlib>
- // #include "SALOME_Log.hxx"
-
-diff -Naur netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp
---- netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp 2009-08-10 15:40:51.000000000 +0400
-+++ netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp 2014-07-22 13:01:28.000000000 +0400
-@@ -1435,7 +1435,8 @@
-
- if (!optstring || strlen(optstring) == 0)
- {
-- mparam.optimize2d = "smcm";
-+ //mparam.optimize2d = (char*)"smcm";
-+ mparam.optimize2d = (char*)"smcm";
- }
- else
- {
-@@ -1451,7 +1452,8 @@
- mparam.grading);
- mesh -> LoadLocalMeshSize (mparam.meshsizefilename);
- mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac);
-- mparam.optimize2d = "cmsmSm";
-+ //mparam.optimize2d = (char*)"cmsmSm";
-+ mparam.optimize2d = (char*)"cmsmSm";
- STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
- #ifdef STAT_STREAM
- (*statout) << GetTime() << " & ";
-@@ -1557,7 +1559,8 @@
-
- if (!optstring || strlen(optstring) == 0)
- {
-- mparam.optimize3d = "cmdmstm";
-+ //mparam.optimize3d = "cmdmstm";
-+ mparam.optimize3d = (char*)"cmdmstm";
- }
- else
- {
-diff -Naur netgen-4.9.13_orig/ng/Makefile.in netgen-4.9.13_new/ng/Makefile.in
---- netgen-4.9.13_orig/ng/Makefile.in 2010-05-21 01:29:28.000000000 +0200
-+++ netgen-4.9.13_new/ng/Makefile.in 2016-05-26 14:39:47.128141997 +0200
-@@ -287,7 +287,7 @@
- $(top_builddir)/libsrc/gprim/libgprim.la \
- $(top_builddir)/libsrc/linalg/libla.la \
- $(top_builddir)/libsrc/general/libgen.la \
-- $(OCCLIBS) -L$(TK_BIN_DIR)/Togl1.7 $(TOGLLIBDIR) -lTogl1.7 $(LIBGLU) $(TK_LIB_SPEC) $(TCL_LIB_SPEC) $(MPI_LIBS) $(FFMPEG_LIBS) $(JPEGLIB_LIBS) $(PKG_LIBS)
-+ $(OCCLIBS) -L$(TK_BIN_DIR)/Togl1.7 $(TOGLLIBDIR) -lTogl $(LIBGLU) $(TK_LIB_SPEC) $(TCL_LIB_SPEC) $(MPI_LIBS) $(FFMPEG_LIBS) $(JPEGLIB_LIBS) $(PKG_LIBS)
-
-
- # add for static linkage of ngsolve:
-diff -Naur netgen-4.9.13_orig/nglib/nglib.h netgen-4.9.13_new/nglib/nglib.h
---- netgen-4.9.13_orig/nglib/nglib.h 2010-05-18 15:20:25.000000000 +0400
-+++ netgen-4.9.13_new/nglib/nglib.h 2014-07-22 13:01:28.000000000 +0400
-@@ -24,7 +24,7 @@
- // Philippose - 14.02.2009
- // Modifications for creating a DLL in Windows
- #ifdef WIN32
-- #ifdef NGLIB_EXPORTS || nglib_EXPORTS
-+ #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
- #define DLL_HEADER __declspec(dllexport)
- #else
- #define DLL_HEADER __declspec(dllimport)
+++ /dev/null
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/meshing/meshtype.cpp netgen-5.0.0.patched/libsrc/meshing/meshtype.cpp
---- netgen-5.0.0.orig/libsrc/meshing/meshtype.cpp 2012-11-09 19:15:04.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/meshing/meshtype.cpp 2013-02-21 17:46:13.000000000 +0400
-@@ -1,4 +1,5 @@
- #include <mystdlib.h>
-+#include <float.h> // to get DBL_MIN defined
-
- #include "meshing.hpp"
-
-@@ -666,7 +667,8 @@
-
- double det = trans.Det();
-
-- if (det <= 0)
-+ // if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- err += 1e12;
- else
- err += frob * frob / det;
-@@ -722,7 +724,8 @@
-
- double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1);
-
-- if (det <= 0)
-+ // if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- {
- dd = 0;
- return 1e12;
-@@ -806,7 +809,8 @@
- = dtrans(0,0) * trans(1,1) - trans(0,1) * dtrans(1,0)
- + trans(0,0) * dtrans(1,1) - dtrans(0,1) * trans(1,0);
-
-- if (det <= 0)
-+ // if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- err += 1e12;
- else
- {
-@@ -856,7 +860,8 @@
- frob /= 2;
-
- double det = trans.Det();
-- if (det <= 0)
-+ //if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- err += 1e12;
- else
- err += frob * frob / det;
-@@ -1864,7 +1869,8 @@
- case PYRAMID:
- {
- double noz = 1-p(2);
-- if (noz == 0.0) noz = 1e-10;
-+ //if (noz == 0.0) noz = 1e-10;
-+ if (noz <= DBL_MIN) noz = 1e-10; // avoid FPE
-
- double xi = p(0) / noz;
- double eta = p(1) / noz;
-@@ -2030,7 +2036,8 @@
-
- double det = -trans.Det();
-
-- if (det <= 0)
-+ //if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- err += 1e12;
- else
- err += frob * frob * frob / det;
-@@ -2102,7 +2109,8 @@
- ddet *= -1;
-
-
-- if (det <= 0)
-+ //if (det <= 0)
-+ if (det <= DBL_MIN) // avoid FPE
- err += 1e12;
- else
- {
-@@ -2184,7 +2192,7 @@
-
- det *= -1;
-
-- if (det <= 0)
-+ if (det <= DBL_MIN)
- err += 1e12;
- else
- {
-@@ -2513,10 +2521,10 @@
-
- MeshingParameters :: MeshingParameters ()
- {
-- optimize3d = "cmdmustm";
-+ optimize3d = (char*)"cmdmustm"; // optimize3d = "cmdmustm";
- //optimize3d = "cmdmstm";
- optsteps3d = 3;
-- optimize2d = "smsmsmSmSmSm";
-+ optimize2d = (char*)"smsmsmSmSmSm"; // optimize2d = "smsmsmSmSmSm";
- optsteps2d = 3;
- opterrpow = 2;
- blockfill = 1;
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/meshing/meshtype.hpp netgen-5.0.0.patched/libsrc/meshing/meshtype.hpp
---- netgen-5.0.0.orig/libsrc/meshing/meshtype.hpp 2012-11-09 19:15:04.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/meshing/meshtype.hpp 2013-02-21 17:46:13.000000000 +0400
-@@ -15,6 +15,7 @@
- Classes for NETGEN
- */
-
-+class Mesh; // added due to compilation errors on some platforms
-
-
- enum ELEMENT_TYPE {
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/meshing/smoothing2.cpp netgen-5.0.0.patched/libsrc/meshing/smoothing2.cpp
---- netgen-5.0.0.orig/libsrc/meshing/smoothing2.cpp 2012-11-09 19:15:04.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/meshing/smoothing2.cpp 2013-02-25 11:20:05.000000000 +0400
-@@ -200,7 +200,8 @@
- vgrad = 0;
- badness = 0;
-
-- ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
-+ //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
-+ n = ld.normal;
- pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
-
- // meshthis -> ProjectPoint (surfi, pp1);
-@@ -258,7 +259,8 @@
- vgrad = 0;
- badness = 0;
-
-- ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
-+ //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
-+ n = ld.normal;
-
- pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
-
-@@ -417,7 +419,8 @@
- vgrad = 0;
- badness = 0;
-
-- ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
-+ //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
-+ n = ld.normal;
-
- pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
-
-@@ -489,7 +492,8 @@
- vgrad = 0;
- badness = 0;
-
-- ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
-+ //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
-+ n = ld.normal;
-
- // pp1 = sp1;
- // pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
-@@ -916,7 +920,7 @@
- {
- mesh[pi] = Point<3> (origp);
- }
--
-+ break; // exit as <fact> is not used anymore
- }
- }
- }
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/Partition_Inter3d.cxx netgen-5.0.0.patched/libsrc/occ/Partition_Inter3d.cxx
---- netgen-5.0.0.orig/libsrc/occ/Partition_Inter3d.cxx 2012-11-09 19:15:02.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/occ/Partition_Inter3d.cxx 2013-02-25 13:51:48.000000000 +0400
-@@ -243,9 +243,11 @@
- Standard_Integer i, nbExt = anExtPS.NbExt();
- Extrema_POnSurf aPOnSurf;
- for (i = 1; i <= nbExt; ++i )
-- if (anExtPS.Value( i ) <= TolE) // V6.3
-- // if (anExtPS.SquareDistance( i ) <= TolE) // V6.5
-- {
-+ // porting to OCCT6.5.1
-+ //if (anExtPS.Value( i ) <= TolE) // V6.3
-+ // if (anExtPS.SquareDistance( i ) <= TolE) // V6.5
-+ if (anExtPS.SquareDistance( i ) <= TolE * TolE)
-+ {
- aPOnSurf = anExtPS.Point( i );
- break;
- }
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/Partition_Loop2d.cxx netgen-5.0.0.patched/libsrc/occ/Partition_Loop2d.cxx
---- netgen-5.0.0.orig/libsrc/occ/Partition_Loop2d.cxx 2012-11-09 19:15:02.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/occ/Partition_Loop2d.cxx 2013-02-25 13:48:15.000000000 +0400
-@@ -210,7 +210,7 @@
- Cc->D1(uc, PC, CTg1);
- if (!isForward) CTg1.Reverse();
-
-- Standard_Real anglemin = 3 * PI, tolAng = 1.e-8;
-+ Standard_Real anglemin = 3 * M_PI, tolAng = 1.e-8;
-
- // select an edge whose first derivative is most left of CTg1
- // ie an angle between Tg1 and CTg1 is least
-@@ -234,7 +234,7 @@
- // -PI < angle < PI
- Standard_Real angle = Tg1.Angle(CTg1);
-
-- if (PI - Abs(angle) <= tolAng)
-+ if (M_PI - Abs(angle) <= tolAng)
- {
- // an angle is too close to PI; assure that an angle sign really
- // reflects an edge position: +PI - an edge is worst,
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/Partition_Spliter.cxx netgen-5.0.0.patched/libsrc/occ/Partition_Spliter.cxx
---- netgen-5.0.0.orig/libsrc/occ/Partition_Spliter.cxx 2012-11-09 19:15:02.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/occ/Partition_Spliter.cxx 2013-02-25 13:55:10.000000000 +0400
-@@ -1169,8 +1169,10 @@
- for (; j<=nbj && ok; ++j) {
- if (Extrema.IsMin(j)) {
- hasMin = Standard_True;
-- ok = Extrema.Value(j) <= tol; // V6.3
-+ // porting to OCCT6.5.1
-+ //ok = Extrema.Value(j) <= tol; // V6.3
- // ok = Extrema.SquareDistance(j) <= tol; // V6.5
-+ ok = Extrema.SquareDistance(j) <= tol * tol;
- }
- }
- }
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/occconstruction.cpp netgen-5.0.0.patched/libsrc/occ/occconstruction.cpp
---- netgen-5.0.0.orig/libsrc/occ/occconstruction.cpp 2012-11-09 19:15:02.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/occ/occconstruction.cpp 2013-02-21 17:46:13.000000000 +0400
-@@ -28,7 +28,7 @@
- #include <BRepAlgoAPI_Common.hxx>
- #include <BRepAlgoAPI_Fuse.hxx>
- #include <BRepAlgoAPI_Section.hxx>
--#include <BRepOffsetAPI_Sewing.hxx>
-+//#include <BRepOffsetAPI_Sewing.hxx>
- //#include <BRepAlgo_Sewing.hxx>
- #include <BRepOffsetAPI_MakeOffsetShape.hxx>
- #include <ShapeFix_Shape.hxx>
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/occgenmesh.cpp netgen-5.0.0.patched/libsrc/occ/occgenmesh.cpp
---- netgen-5.0.0.orig/libsrc/occ/occgenmesh.cpp 2012-11-09 19:15:02.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/occ/occgenmesh.cpp 2013-02-21 17:46:13.000000000 +0400
-@@ -57,6 +57,8 @@
-
-
-
-+
-+ static // useless out of this file
- double ComputeH (double kappa)
- {
- double hret;
-@@ -74,8 +76,7 @@
- }
-
-
--
--
-+ static // useless out of this file
- void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
- BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h = 0)
- {
-@@ -171,8 +172,8 @@
- if(h < 1e-4*maxside)
- return;
-
--
-- if (h > 30) return;
-+ // commented to restrict H on a large sphere for example
-+ //if (h > 30) return;
- }
-
- if (h < maxside && depth < 10)
-@@ -231,6 +232,7 @@
-
-
-
-+ static // useless out of this file
- void DivideEdge (TopoDS_Edge & edge, Array<MeshPoint> & ps,
- Array<double> & params, Mesh & mesh)
- {
-@@ -250,8 +252,8 @@
- hvalue[0] = 0;
- pnt = c->Value(s0);
-
-- double olddist = 0;
-- double dist = 0;
-+ //double olddist = 0; -- useless variables
-+ //double dist = 0;
-
- int tmpVal = (int)(DIVIDEEDGESECTIONS);
-
-@@ -259,15 +261,19 @@
- {
- oldpnt = pnt;
- pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
-+ // -- no more than 1 segment per <edge length>/DIVIDEEDGESECTIONS
- hvalue[i] = hvalue[i-1] +
-- 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
-- pnt.Distance(oldpnt);
-+ // 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
-+ // pnt.Distance(oldpnt);
-+ min( 1.0,
-+ 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
-+ pnt.Distance(oldpnt));
-
- //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
- // << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
-
-- olddist = dist;
-- dist = pnt.Distance(oldpnt);
-+ //olddist = dist; -- useless variables
-+ //dist = pnt.Distance(oldpnt);
- }
-
- // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
-@@ -282,7 +288,10 @@
- {
- if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)
- {
-- params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
-+ // -- for nsubedges comparable to DIVIDEEDGESECTIONS
-+ //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
-+ double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]);
-+ params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0);
- pnt = c->Value(params[i]);
- ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));
- i++;
-@@ -326,6 +335,7 @@
- (*testout) << "nedges = " << nedges << endl;
-
- double eps = 1e-6 * geom.GetBoundingBox().Diam();
-+ const double eps2 = eps * eps; // -- small optimization
-
- for (int i = 1; i <= nvertices; i++)
- {
-@@ -335,7 +345,8 @@
- bool exists = 0;
- if (merge_solids)
- for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
-- if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
-+ //if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
-+ if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 ) // -- small optimization
- {
- exists = 1;
- break;
-@@ -365,6 +376,7 @@
- {
- TopoDS_Face face = TopoDS::Face(exp1.Current());
- int facenr = geom.fmap.FindIndex(face);
-+ if ( facenr < 1 ) continue; // -- to support SALOME sub-meshes
-
- if (face2solid[0][facenr-1] == 0)
- face2solid[0][facenr-1] = solidnr;
-@@ -384,6 +396,7 @@
- int facenr = 0;
- int edgenr = 0;
-
-+ edgenr = mesh.GetNSeg(); // to support SALOME sub-meshes
-
- (*testout) << "faces = " << geom.fmap.Extent() << endl;
- int curr = 0;
-@@ -445,6 +458,7 @@
- //(*testout) << "ignoring degenerated edge" << endl;
- continue;
- }
-+ if ( geom.emap.FindIndex(edge) < 1 ) continue; // to support SALOME sub-meshes
-
- if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
- geom.vmap.FindIndex(TopExp::LastVertex (edge)))
-@@ -482,15 +496,64 @@
- }
- else
- {
-- Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
-- Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
-+ TopoDS_Iterator vIt( edge, false );
-+ TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next();
-+ TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() );
-+ if ( v1.Orientation() == TopAbs_REVERSED )
-+ std::swap( v1, v2 );
-+ const bool isClosedEdge = v1.IsSame( v2 );
-+
-+ Point<3> fp = occ2ng (BRep_Tool::Pnt (v1));
-+ Point<3> lp = occ2ng (BRep_Tool::Pnt (v2));
-+ double tol2 = std::min( eps*eps, 1e-6 * Dist2( fp, lp ));
-+ if ( isClosedEdge )
-+ tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 );
-
- pnums[0] = -1;
- pnums.Last() = -1;
- for (PointIndex pi = 1; pi < first_ep; pi++)
- {
-- if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
-- if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
-+ if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi;
-+ if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi;
-+ }
-+ if (( isClosedEdge && pnums[0] != pnums.Last() ) ||
-+ ( !isClosedEdge && pnums[0] == pnums.Last() ))
-+ pnums[0] = pnums.Last() = -1;
-+ if ( pnums[0] == -1 || pnums.Last() == -1 )
-+ {
-+ // take into account a possible large gap between a vertex and an edge curve
-+ // end and a large vertex tolerance covering the whole edge
-+ if ( pnums[0] == -1 )
-+ {
-+ double tol = BRep_Tool::Tolerance( v1 );
-+ for (PointIndex pi = 1; pi < first_ep; pi++)
-+ if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol)
-+ pnums[0] = pi;
-+
-+ if ( pnums[0] == -1 )
-+ pnums[0] = first_ep-1- nvertices + geom.vmap.FindIndex ( v1 );
-+ }
-+ if ( isClosedEdge )
-+ {
-+ pnums.Last() = pnums[0];
-+ }
-+ else
-+ {
-+ if ( pnums.Last() == -1 )
-+ {
-+ double tol = BRep_Tool::Tolerance( v2 );
-+ for (PointIndex pi = 1; pi < first_ep; pi++)
-+ if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol)
-+ pnums.Last() = pi;
-+
-+ if ( pnums.Last() == -1 )
-+ pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 );
-+ }
-+
-+ if ( Dist2( fp, mesh[PointIndex(pnums[0])]) >
-+ Dist2( lp, mesh[PointIndex(pnums.Last())]))
-+ std::swap( pnums[0], pnums.Last() );
-+ }
- }
- }
-
-@@ -1458,3 +1521,4 @@
- }
-
- #endif
-+
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/occgeom.cpp netgen-5.0.0.patched/libsrc/occ/occgeom.cpp
---- netgen-5.0.0.orig/libsrc/occ/occgeom.cpp 2012-11-09 19:15:02.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/occ/occgeom.cpp 2013-02-21 17:46:13.000000000 +0400
-@@ -8,6 +8,8 @@
- #include "ShapeAnalysis_CheckSmallFace.hxx"
- #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
- #include "ShapeAnalysis_Surface.hxx"
-+#include <BRepTopAdaptor_FClass2d.hxx> // -- to optimize Project() and FastProject()
-+#include <TopAbs_State.hxx>
- #include "BRepAlgoAPI_Fuse.hxx"
- #include "BRepCheck_Analyzer.hxx"
- #include "BRepLib.hxx"
-@@ -16,10 +18,17 @@
- #include "ShapeFix_FixSmallFace.hxx"
- #include "Partition_Spliter.hxx"
-
--
- namespace netgen
- {
-- void OCCGeometry :: PrintNrShapes ()
-+ // free data used to optimize Project() and FastProject()
-+ OCCGeometry::~OCCGeometry()
-+ {
-+ NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
-+ for (; it.More(); it.Next())
-+ delete it.Value();
-+ }
-+
-+ void OCCGeometry :: PrintNrShapes ()
- {
- TopExp_Explorer e;
- int count = 0;
-@@ -951,25 +960,58 @@
- }
-
-
-+ // returns a projector and a classifier for the given surface
-+ void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
-+ BRepTopAdaptor_FClass2d*& cls) const
-+ {
-+ //MSV: organize caching projector in the map
-+ if (fprjmap.IsBound(surfi))
-+ {
-+ proj = fprjmap.Find(surfi);
-+ cls = fclsmap.Find(surfi);
-+ }
-+ else
-+ {
-+ const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
-+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
-+ proj = new ShapeAnalysis_Surface(aSurf);
-+ fprjmap.Bind(surfi, proj);
-+ cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
-+ fclsmap.Bind(surfi, cls);
-+ }
-+ }
-
--
-- void OCCGeometry :: Project (int surfi, Point<3> & p) const
-+ // void OCCGeometry :: Project (int surfi, Point<3> & p) const
-+ bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
- {
- static int cnt = 0;
- if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
-
- gp_Pnt pnt(p(0), p(1), p(2));
-
-- double u,v;
-- Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
-- Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
-- gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
-- suval.Coord( u, v);
-- pnt = thesurf->Value( u, v );
--
--
-+ // -- Optimization: use cached projector and classifier
-+ // double u,v;
-+ // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
-+ // Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
-+ // gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
-+ // suval.Coord( u, v);
-+ // pnt = thesurf->Value( u, v );
-+
-+ Handle(ShapeAnalysis_Surface) proj;
-+ BRepTopAdaptor_FClass2d *cls;
-+ GetFaceTools(surfi, proj, cls);
-+
-+ gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
-+ if (cls->Perform(p2d) == TopAbs_OUT)
-+ {
-+ return false;
-+ }
-+ pnt = proj->Value(p2d);
-+ p2d.Coord(u, v);
-+
- p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
-
-+ return true;
- }
-
-
-@@ -979,54 +1021,69 @@
- {
- gp_Pnt p(ap(0), ap(1), ap(2));
-
-- Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
--
-- gp_Pnt x = surface->Value (u,v);
--
-- if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
--
-- gp_Vec du, dv;
--
-- surface->D1(u,v,x,du,dv);
--
-- int count = 0;
--
-- gp_Pnt xold;
-- gp_Vec n;
-- double det, lambda, mu;
--
-- do {
-- count++;
--
-- n = du^dv;
--
-- det = Det3 (n.X(), du.X(), dv.X(),
-- n.Y(), du.Y(), dv.Y(),
-- n.Z(), du.Z(), dv.Z());
--
-- if (det < 1e-15) return false;
--
-- lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
-- n.Y(), p.Y()-x.Y(), dv.Y(),
-- n.Z(), p.Z()-x.Z(), dv.Z())/det;
--
-- mu = Det3 (n.X(), du.X(), p.X()-x.X(),
-- n.Y(), du.Y(), p.Y()-x.Y(),
-- n.Z(), du.Z(), p.Z()-x.Z())/det;
--
-- u += lambda;
-- v += mu;
--
-- xold = x;
-- surface->D1(u,v,x,du,dv);
--
-- } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
--
-- // (*testout) << "FastProject count: " << count << endl;
--
-- if (count == 50) return false;
--
-- ap = Point<3> (x.X(), x.Y(), x.Z());
-+ // -- Optimization: use cached projector and classifier
-+ // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
-+ //
-+ // gp_Pnt x = surface->Value (u,v);
-+ //
-+ // if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
-+ //
-+ // gp_Vec du, dv;
-+ //
-+ // surface->D1(u,v,x,du,dv);
-+ //
-+ // int count = 0;
-+ //
-+ // gp_Pnt xold;
-+ // gp_Vec n;
-+ // double det, lambda, mu;
-+ //
-+ // do {
-+ // count++;
-+ //
-+ // n = du^dv;
-+ //
-+ // det = Det3 (n.X(), du.X(), dv.X(),
-+ // n.Y(), du.Y(), dv.Y(),
-+ // n.Z(), du.Z(), dv.Z());
-+ //
-+ // if (det < 1e-15) return false;
-+ //
-+ // lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
-+ // n.Y(), p.Y()-x.Y(), dv.Y(),
-+ // n.Z(), p.Z()-x.Z(), dv.Z())/det;
-+ //
-+ // mu = Det3 (n.X(), du.X(), p.X()-x.X(),
-+ // n.Y(), du.Y(), p.Y()-x.Y(),
-+ // n.Z(), du.Z(), p.Z()-x.Z())/det;
-+ //
-+ // u += lambda;
-+ // v += mu;
-+ //
-+ // xold = x;
-+ // surface->D1(u,v,x,du,dv);
-+ //
-+ // } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
-+ //
-+ // // (*testout) << "FastProject count: " << count << endl;
-+ //
-+ // if (count == 50) return false;
-+ //
-+ // ap = Point<3> (x.X(), x.Y(), x.Z());
-+ Handle(ShapeAnalysis_Surface) proj;
-+ BRepTopAdaptor_FClass2d *cls;
-+ GetFaceTools(surfi, proj, cls);
-+
-+ gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
-+ if (cls->Perform(p2d) == TopAbs_OUT)
-+ {
-+ //cout << "Projection fails" << endl;
-+ return false;
-+ }
-+
-+ p = proj->Value(p2d);
-+ p2d.Coord(u, v);
-+ ap = Point<3> (p.X(), p.Y(), p.Z());
-
- return true;
- }
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/occgeom.hpp netgen-5.0.0.patched/libsrc/occ/occgeom.hpp
---- netgen-5.0.0.orig/libsrc/occ/occgeom.hpp 2012-11-09 19:15:02.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/occ/occgeom.hpp 2013-02-21 17:46:13.000000000 +0400
-@@ -15,8 +15,8 @@
- #include "Geom_Curve.hxx"
- #include "Geom2d_Curve.hxx"
- #include "Geom_Surface.hxx"
--#include "GeomAPI_ProjectPointOnSurf.hxx"
--#include "GeomAPI_ProjectPointOnCurve.hxx"
-+// #include "GeomAPI_ProjectPointOnSurf.hxx"
-+// #include "GeomAPI_ProjectPointOnCurve.hxx"
- #include "BRepTools.hxx"
- #include "TopExp.hxx"
- #include "BRepBuilderAPI_MakeVertex.hxx"
-@@ -42,8 +42,8 @@
- #include "Geom_Curve.hxx"
- #include "Geom2d_Curve.hxx"
- #include "Geom_Surface.hxx"
--#include "GeomAPI_ProjectPointOnSurf.hxx"
--#include "GeomAPI_ProjectPointOnCurve.hxx"
-+// #include "GeomAPI_ProjectPointOnSurf.hxx"
-+// #include "GeomAPI_ProjectPointOnCurve.hxx"
- #include "TopoDS_Wire.hxx"
- #include "BRepTools_WireExplorer.hxx"
- #include "BRepTools.hxx"
-@@ -68,7 +68,7 @@
- #include "IGESToBRep_Reader.hxx"
- #include "Interface_Static.hxx"
- #include "GeomAPI_ExtremaCurveCurve.hxx"
--#include "Standard_ErrorHandler.hxx"
-+//#include "Standard_ErrorHandler.hxx"
- #include "Standard_Failure.hxx"
- #include "ShapeUpgrade_ShellSewing.hxx"
- #include "ShapeFix_Shape.hxx"
-@@ -80,6 +80,10 @@
- #include "ShapeAnalysis.hxx"
- #include "ShapeBuild_ReShape.hxx"
-
-+// -- Optimization: to use cached projector and classifier
-+#include <NCollection_DataMap.hxx>
-+class Handle_ShapeAnalysis_Surface;
-+class BRepTopAdaptor_FClass2d;
-
- // Philippose - 29/01/2009
- // OpenCascade XDE Support
-@@ -192,6 +196,9 @@
- class OCCGeometry : public NetgenGeometry
- {
- Point<3> center;
-+ // -- Optimization: to use cached projector and classifier
-+ mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
-+ mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
-
- public:
- TopoDS_Shape shape;
-@@ -247,6 +254,8 @@
- virtual void Save (string filename) const;
-
-
-+ ~OCCGeometry(); // -- to free cached projector and classifier
-+
- void BuildFMap();
-
- Box<3> GetBoundingBox()
-@@ -266,9 +275,14 @@
- Point<3> Center()
- { return center;}
-
-- void Project (int surfi, Point<3> & p) const;
-+ // void Project (int surfi, Point<3> & p) const; -- optimization
-+ bool Project (int surfi, Point<3> & p, double& u, double& v) const;
- bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
-
-+ // -- Optimization: to use cached projector and classifier
-+ void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
-+ BRepTopAdaptor_FClass2d*& cls) const;
-+
- OCCSurface GetSurface (int surfi)
- {
- cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/occmeshsurf.cpp netgen-5.0.0.patched/libsrc/occ/occmeshsurf.cpp
---- netgen-5.0.0.orig/libsrc/occ/occmeshsurf.cpp 2012-11-09 19:15:02.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/occ/occmeshsurf.cpp 2013-02-25 13:27:49.000000000 +0400
-@@ -6,6 +6,7 @@
- #include <meshing.hpp>
- #include <GeomLProp_SLProps.hxx>
- #include <ShapeAnalysis_Surface.hxx>
-+#include <GeomAPI_ProjectPointOnCurve.hxx> // -- moved here from occgeom.hpp
-
-
- namespace netgen
-@@ -434,23 +435,33 @@
-
- void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
- {
-- geometry.Project (surfind, p);
-+ // geometry.Project (surfind, p); -- signature of Project() changed for optimization
-+ double u, v;
-+ geometry.Project (surfind, p, u, v);
- }
-
-
- int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
- {
-- double u = gi.u;
-- double v = gi.v;
-+ //double u = gi.u;
-+ //double v = gi.v;
-
- Point<3> hp = p;
-- if (geometry.FastProject (surfind, hp, u, v))
-- {
-- p = hp;
-- return 1;
-- }
-- ProjectPoint (surfind, p);
-- return CalcPointGeomInfo (surfind, gi, p);
-+ // -- u and v are computed by FastProject() and Project(), no need to call CalcPointGeomInfo()
-+ // if (geometry.FastProject (surfind, hp, u, v))
-+ // {
-+ // p = hp;
-+ // return 1;
-+ // }
-+ // ProjectPoint (surfind, p);
-+ // return CalcPointGeomInfo (surfind, gi, p);
-+ bool ok;
-+ if (gi.trignum > 0)
-+ ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
-+ else
-+ ok = geometry.Project (surfind, hp, gi.u, gi.v);
-+ p = hp;
-+ return ok;
- }
-
-
-@@ -680,7 +691,8 @@
- if (!geometry.FastProject (surfi, hnewp, u, v))
- {
- // cout << "Fast projection to surface fails! Using OCC projection" << endl;
-- geometry.Project (surfi, hnewp);
-+ // geometry.Project (surfi, hnewp); -- Project() changed for optimization
-+ geometry.Project (surfi, hnewp, u, v);
- }
-
- newgi.trignum = 1;
-@@ -689,7 +701,7 @@
- }
-
- newp = hnewp;
-- }
-+ }//; -- to compile with -Wall -pedantic
-
-
- void OCCRefinementSurfaces ::
-@@ -708,14 +720,18 @@
- hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
- newp = hnewp;
- newgi = ap1;
-- };
-+ }
-
-
- void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) const
- {
- if (surfi > 0)
-- geometry.Project (surfi, p);
-- };
-+ // geometry.Project (surfi, p); -- Project() changed for optimization
-+ {
-+ double u, v;
-+ geometry.Project (surfi, p, u, v);
-+ }
-+ }//; -- to compile with -Wall -pedantic
-
- void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const
- {
-@@ -723,9 +739,10 @@
- if (!geometry.FastProject (surfi, p, gi.u, gi.v))
- {
- cout << "Fast projection to surface fails! Using OCC projection" << endl;
-- geometry.Project (surfi, p);
-+ double u, v;
-+ geometry.Project (surfi, p, u, v);
- }
-- };
-+ }
-
-
-
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/utilities.h netgen-5.0.0.patched/libsrc/occ/utilities.h
---- netgen-5.0.0.orig/libsrc/occ/utilities.h 2012-11-09 19:15:02.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/occ/utilities.h 2013-02-21 17:47:08.000000000 +0400
-@@ -33,6 +33,7 @@
-
- #include <string>
- #include <iostream>
-+#include <iomanip>
- #include <cstdlib>
- // #include "SALOME_Log.hxx"
-
-diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/stlgeom/stlgeommesh.cpp netgen-5.0.0.patched/libsrc/stlgeom/stlgeommesh.cpp
---- netgen-5.0.0.orig/libsrc/stlgeom/stlgeommesh.cpp 2012-11-09 19:15:04.000000000 +0400
-+++ netgen-5.0.0.patched/libsrc/stlgeom/stlgeommesh.cpp 2013-02-21 17:52:07.000000000 +0400
-@@ -1435,7 +1435,8 @@
- /*
- if (!optstring || strlen(optstring) == 0)
- {
-- mparam.optimize2d = "smcm";
-+ //mparam.optimize2d = (char*)"smcm";
-+ mparam.optimize2d = (char*)"smcm";
- }
- else
- {
-@@ -1453,7 +1454,7 @@
- mesh -> LoadLocalMeshSize (mparam.meshsizefilename);
- mesh -> CalcLocalHFromSurfaceCurvature (mparam.grading,
- stlparam.resthsurfmeshcurvfac);
-- mparam.optimize2d = "cmsmSm";
-+ mparam.optimize2d = "(char*)cmsmSm";
- STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
- #ifdef STAT_STREAM
- (*statout) << GetTime() << " & ";
-@@ -1560,7 +1561,8 @@
- /*
- if (!optstring || strlen(optstring) == 0)
- {
-- mparam.optimize3d = "cmdmstm";
-+ //mparam.optimize3d = "cmdmstm";
-+ mparam.optimize3d = (char*)"cmdmstm";
- }
- else
- {
-diff -Naur --exclude=CVS netgen-5.0.0.orig/nglib/nglib.h netgen-5.0.0.patched/nglib/nglib.h
---- netgen-5.0.0.orig/nglib/nglib.h 2012-11-09 19:15:00.000000000 +0400
-+++ netgen-5.0.0.patched/nglib/nglib.h 2013-02-21 17:47:08.000000000 +0400
-@@ -24,7 +24,7 @@
- // Philippose - 14.02.2009
- // Modifications for creating a DLL in Windows
- #ifdef WIN32
-- #ifdef NGLIB_EXPORTS || nglib_EXPORTS
-+ #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
- #define DLL_HEADER __declspec(dllexport)
- #else
- #define DLL_HEADER __declspec(dllimport)
-diff -NaurwB netgen-5.3.1_orig/Makefile.am netgen-5.3.1_new/Makefile.am
---- netgen-5.3.1_orig/Makefile.am 2016-10-21 17:32:01.000000000 +0300
-+++ netgen-5.3.1_new/Makefile.am 2016-10-21 17:31:54.000000000 +0300
+diff -Naur netgen-5.3.1_SRC_orig/Makefile.am netgen-5.3.1_SRC_modif/Makefile.am
+--- netgen-5.3.1_SRC_orig/Makefile.am 2014-08-29 13:55:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/Makefile.am 2017-09-11 18:08:21.217313702 +0300
@@ -2,7 +2,7 @@
METASOURCES = AUTO
# TESTS = ng/netgen -batchmode
-diff -NaurwB netgen-5.3.1_orig/Makefile.in netgen-5.3.1_new/Makefile.in
---- netgen-5.3.1_orig/Makefile.in 2014-10-06 15:04:37.000000000 +0400
-+++ netgen-5.3.1_new/Makefile.in 2016-10-03 16:17:10.164707368 +0300
+diff -Naur netgen-5.3.1_SRC_orig/Makefile.in netgen-5.3.1_SRC_modif/Makefile.in
+--- netgen-5.3.1_SRC_orig/Makefile.in 2014-10-06 15:04:37.000000000 +0400
++++ netgen-5.3.1_SRC_modif/Makefile.in 2017-09-11 18:08:21.225312838 +0300
@@ -280,7 +280,7 @@
top_srcdir = @top_srcdir@
ACLOCAL_AMFLAGS = -I m4
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
-diff -NaurwB netgen-5.3.1_orig/configure.ac netgen-5.3.1_new/configure.ac
---- netgen-5.3.1_orig/configure.ac 2014-10-06 15:00:17.000000000 +0400
-+++ netgen-5.3.1_new/configure.ac 2016-09-29 14:34:11.957389447 +0300
+diff -Naur netgen-5.3.1_SRC_orig/configure.ac netgen-5.3.1_SRC_modif/configure.ac
+--- netgen-5.3.1_SRC_orig/configure.ac 2014-10-06 15:00:17.000000000 +0400
++++ netgen-5.3.1_SRC_modif/configure.ac 2017-09-11 18:08:21.226312730 +0300
@@ -20,7 +20,7 @@
CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
# LDFLAGS="$LDFLAGS $OPENMP_CXXFLAGS"
# -lTKDCAF
-diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/findip.hpp netgen-5.3.1_new/libsrc/meshing/findip.hpp
---- netgen-5.3.1_orig/libsrc/meshing/findip.hpp 2014-08-29 13:54:05.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/meshing/findip.hpp 2016-09-30 20:38:56.662234111 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/csg/Makefile.am netgen-5.3.1_SRC_modif/libsrc/csg/Makefile.am
+--- netgen-5.3.1_SRC_orig/libsrc/csg/Makefile.am 2014-08-29 13:54:06.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/csg/Makefile.am 2017-09-11 18:08:21.234311865 +0300
+@@ -8,7 +8,7 @@
+ AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include $(TCL_INCLUDES)
+ METASOURCES = AUTO
+
+-lib_LTLIBRARIES = libcsg.la
++noinst_LTLIBRARIES = libcsg.la
+
+
+ libcsg_la_SOURCES = algprim.cpp brick.cpp \
+@@ -17,12 +17,9 @@
+ manifold.cpp meshsurf.cpp polyhedra.cpp revolution.cpp singularref.cpp \
+ solid.cpp specpoin.cpp spline3d.cpp surface.cpp triapprox.cpp
+
+-libcsg_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
+-
+-
+
+ if NGGUI
+-lib_LTLIBRARIES += libcsgvis.la
++lib_LTLIBRARIES = libcsgvis.la
+
+ libcsgvis_la_SOURCES = vscsg.cpp csgpkg.cpp
+ libcsgvis_la_LIBADD = libcsg.la
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/geom2d/Makefile.am netgen-5.3.1_SRC_modif/libsrc/geom2d/Makefile.am
+--- netgen-5.3.1_SRC_orig/libsrc/geom2d/Makefile.am 2014-08-29 13:54:06.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/geom2d/Makefile.am 2017-09-11 18:08:21.234311865 +0300
+@@ -4,16 +4,15 @@
+
+ METASOURCES = AUTO
+
+-lib_LTLIBRARIES = libgeom2d.la
++noinst_LTLIBRARIES = libgeom2d.la
+
+ if NGGUI
+-lib_LTLIBRARIES += libgeom2dvis.la
++lib_LTLIBRARIES = libgeom2dvis.la
+ endif
+
+
+
+ libgeom2d_la_SOURCES = genmesh2d.cpp geom2dmesh.cpp geometry2d.cpp
+-libgeom2d_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
+
+ libgeom2dvis_la_SOURCES = geom2dpkg.cpp vsgeom2d.cpp
+ libgeom2dvis_la_LIBADD = libgeom2d.la
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/interface/Makefile.am netgen-5.3.1_SRC_modif/libsrc/interface/Makefile.am
+--- netgen-5.3.1_SRC_orig/libsrc/interface/Makefile.am 2014-08-29 13:54:02.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/interface/Makefile.am 2017-09-11 18:08:21.234311865 +0300
+@@ -2,14 +2,11 @@
+
+ AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface $(MPI_INCLUDES) $(TCL_INCLUDES) -DOPENGL
+ METASOURCES = AUTO
+-lib_LTLIBRARIES = libinterface.la
++noinst_LTLIBRARIES = libinterface.la
+ libinterface_la_SOURCES = nginterface.cpp nginterface_v2.cpp \
+ read_fnf_mesh.cpp readtetmesh.cpp readuser.cpp writeabaqus.cpp writediffpack.cpp \
+ writedolfin.cpp writeelmer.cpp writefeap.cpp writefluent.cpp writegmsh.cpp writejcm.cpp \
+ writepermas.cpp writetecplot.cpp writetet.cpp writetochnog.cpp writeuser.cpp \
+ wuchemnitz.cpp writegmsh2.cpp writeOpenFOAM15x.cpp
+
+-
+-libinterface_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
+-
+ # libinterface_la_LDFLAGS = -rdynamic
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/meshing/Makefile.am netgen-5.3.1_SRC_modif/libsrc/meshing/Makefile.am
+--- netgen-5.3.1_SRC_orig/libsrc/meshing/Makefile.am 2014-08-29 13:54:05.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/meshing/Makefile.am 2017-09-11 18:08:21.234311865 +0300
+@@ -15,7 +15,7 @@
+
+ METASOURCES = AUTO
+
+-lib_LTLIBRARIES = libmesh.la
++noinst_LTLIBRARIES = libmesh.la
+
+ libmesh_la_SOURCES = adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp \
+ clusters.cpp curvedelems.cpp delaunay.cpp delaunay2d.cpp \
+@@ -30,8 +30,5 @@
+ topology.cpp triarls.cpp validate.cpp zrefine.cpp bcfunctions.cpp \
+ parallelmesh.cpp paralleltop.cpp paralleltop.hpp basegeom.cpp
+
+-libmesh_la_LIBADD = $(top_builddir)/libsrc/linalg/libla.la \
+- $(top_builddir)/libsrc/gprim/libgprim.la \
+- $(top_builddir)/libsrc/general/libgen.la \
+- -lz
++libmesh_la_LIBADD = -lz
+
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/meshing/findip.hpp netgen-5.3.1_SRC_modif/libsrc/meshing/findip.hpp
+--- netgen-5.3.1_SRC_orig/libsrc/meshing/findip.hpp 2014-08-29 13:54:05.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/meshing/findip.hpp 2017-09-11 18:08:21.226312730 +0300
@@ -75,6 +75,9 @@
static int timer = NgProfiler::CreateTimer ("FindInnerPoint");
NgProfiler::RegionTimer reg (timer);
Array<Vec3d> a;
Array<double> c;
Mat<3> m, inv;
-diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/improve3.cpp netgen-5.3.1_new/libsrc/meshing/improve3.cpp
---- netgen-5.3.1_orig/libsrc/meshing/improve3.cpp 2014-08-29 13:54:05.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/meshing/improve3.cpp 2016-10-03 16:16:57.636639300 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/meshing/improve3.cpp netgen-5.3.1_SRC_modif/libsrc/meshing/improve3.cpp
+--- netgen-5.3.1_SRC_orig/libsrc/meshing/improve3.cpp 2014-08-29 13:54:05.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/meshing/improve3.cpp 2017-09-11 18:08:21.227312622 +0300
@@ -1219,6 +1219,7 @@
tetused = 0;
bad1 = 0;
for (int k = 0; k < nsuround; k++)
-diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc/meshing/meshtype.cpp
---- netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp 2014-08-29 13:54:05.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/meshing/meshtype.cpp 2016-09-29 14:04:51.500148293 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_SRC_modif/libsrc/meshing/meshtype.cpp
+--- netgen-5.3.1_SRC_orig/libsrc/meshing/meshtype.cpp 2014-08-29 13:54:05.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/meshing/meshtype.cpp 2017-09-11 18:08:21.227312622 +0300
@@ -1,4 +1,5 @@
#include <mystdlib.h>
+#include <float.h> // to get DBL_MIN defined
err += 1e12;
else
{
-diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/meshtype.hpp netgen-5.3.1_new/libsrc/meshing/meshtype.hpp
---- netgen-5.3.1_orig/libsrc/meshing/meshtype.hpp 2014-08-29 13:54:05.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/meshing/meshtype.hpp 2016-09-30 14:28:09.147575801 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/meshing/meshtype.hpp netgen-5.3.1_SRC_modif/libsrc/meshing/meshtype.hpp
+--- netgen-5.3.1_SRC_orig/libsrc/meshing/meshtype.hpp 2014-08-29 13:54:05.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/meshing/meshtype.hpp 2017-09-11 18:08:21.228312514 +0300
@@ -15,6 +15,7 @@
Classes for NETGEN
*/
#endif
;
}
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.cxx netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.cxx
---- netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.cxx 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.cxx 2016-09-29 14:44:01.996464598 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Makefile.am netgen-5.3.1_SRC_modif/libsrc/occ/Makefile.am
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Makefile.am 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Makefile.am 2017-09-11 18:08:21.234311865 +0300
+@@ -14,10 +14,10 @@
+
+ METASOURCES = AUTO
+
+-lib_LTLIBRARIES = libocc.la
++noinst_LTLIBRARIES = libocc.la
+
+ if NGGUI
+-lib_LTLIBRARIES += liboccvis.la
++lib_LTLIBRARIES = liboccvis.la
+ endif
+
+
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Inter2d.cxx netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Inter2d.cxx
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Inter2d.cxx 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Inter2d.cxx 2017-09-11 18:08:21.228312514 +0300
@@ -47,9 +47,7 @@
#include <TopOpeBRep_EdgesIntersector.hxx>
#include <TopOpeBRep_Point2d.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.hxx
---- netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.hxx 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.hxx 2016-09-29 14:44:01.996464598 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Inter2d.hxx netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Inter2d.hxx
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Inter2d.hxx 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Inter2d.hxx 2017-09-11 18:08:21.228312514 +0300
@@ -27,7 +27,9 @@
#ifndef _Partition_Inter2d_HeaderFile
#define _Partition_Inter2d_HeaderFile
class TopoDS_Edge;
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.cxx netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.cxx
---- netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.cxx 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.cxx 2016-09-29 14:44:02.000464619 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Inter3d.cxx netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Inter3d.cxx
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Inter3d.cxx 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Inter3d.cxx 2017-09-11 18:08:21.229312406 +0300
@@ -48,7 +48,6 @@
#include <TopOpeBRepTool_BoxSort.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
}
if (!S->IsUPeriodic() && !S->IsVPeriodic())
return;
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.hxx
---- netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.hxx 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.hxx 2016-09-29 14:44:02.000464619 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Inter3d.hxx netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Inter3d.hxx
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Inter3d.hxx 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Inter3d.hxx 2017-09-11 18:08:21.229312406 +0300
@@ -27,7 +27,9 @@
#ifndef _Partition_Inter3d_HeaderFile
#define _Partition_Inter3d_HeaderFile
TopTools_DataMapOfShapeListOfShape mySameDomainFM;
TopTools_DataMapOfShapeShape mySameDomainVM;
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop.hxx netgen-5.3.1_new/libsrc/occ/Partition_Loop.hxx
---- netgen-5.3.1_orig/libsrc/occ/Partition_Loop.hxx 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Partition_Loop.hxx 2016-09-29 14:44:02.000464619 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Loop.hxx netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Loop.hxx
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Loop.hxx 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Loop.hxx 2017-09-11 18:08:21.229312406 +0300
@@ -38,8 +38,6 @@
#endif
class TopoDS_Face;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.cxx netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.cxx
---- netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.cxx 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.cxx 2016-09-29 14:04:51.504148314 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Loop2d.cxx netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Loop2d.cxx
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Loop2d.cxx 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Loop2d.cxx 2017-09-11 18:08:21.229312406 +0300
@@ -210,7 +210,7 @@
Cc->D1(uc, PC, CTg1);
if (!isForward) CTg1.Reverse();
{
// an angle is too close to PI; assure that an angle sign really
// reflects an edge position: +PI - an edge is worst,
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.hxx
---- netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.hxx 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.hxx 2016-09-29 14:44:02.000464619 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Loop2d.hxx netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Loop2d.hxx
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Loop2d.hxx 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Loop2d.hxx 2017-09-11 18:08:21.230312298 +0300
@@ -24,7 +24,6 @@
#endif
class TopoDS_Face;
class BRepAlgo_Image;
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop3d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Loop3d.hxx
---- netgen-5.3.1_orig/libsrc/occ/Partition_Loop3d.hxx 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Partition_Loop3d.hxx 2016-09-29 14:44:02.000464619 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Loop3d.hxx netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Loop3d.hxx
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Loop3d.hxx 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Loop3d.hxx 2017-09-11 18:08:21.230312298 +0300
@@ -13,6 +13,9 @@
#ifndef _TopTools_ListOfShape_HeaderFile
#include <TopTools_ListOfShape.hxx>
class TopoDS_Edge;
class TopoDS_Face;
class gp_Vec;
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.cxx netgen-5.3.1_new/libsrc/occ/Partition_Spliter.cxx
---- netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.cxx 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Partition_Spliter.cxx 2016-09-29 14:44:02.000464619 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Spliter.cxx netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Spliter.cxx
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Spliter.cxx 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Spliter.cxx 2017-09-11 18:08:21.230312298 +0300
@@ -48,7 +48,6 @@
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.hxx netgen-5.3.1_new/libsrc/occ/Partition_Spliter.hxx
---- netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.hxx 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Partition_Spliter.hxx 2016-09-29 14:44:02.004464639 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Spliter.hxx netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Spliter.hxx
+--- netgen-5.3.1_SRC_orig/libsrc/occ/Partition_Spliter.hxx 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/Partition_Spliter.hxx 2017-09-11 18:08:21.231312190 +0300
@@ -28,9 +28,6 @@
#ifndef _TopTools_DataMapOfShapeShape_HeaderFile
#include <TopTools_DataMapOfShapeShape.hxx>
BRepAlgo_Image myImagesFaces;
BRepAlgo_Image myImagesEdges;
BRepAlgo_Image myImageShape;
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occconstruction.cpp netgen-5.3.1_new/libsrc/occ/occconstruction.cpp
---- netgen-5.3.1_orig/libsrc/occ/occconstruction.cpp 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/occconstruction.cpp 2016-09-29 14:04:51.500148293 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/occconstruction.cpp netgen-5.3.1_SRC_modif/libsrc/occ/occconstruction.cpp
+--- netgen-5.3.1_SRC_orig/libsrc/occ/occconstruction.cpp 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/occconstruction.cpp 2017-09-11 18:08:21.231312190 +0300
@@ -28,7 +28,7 @@
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
//#include <BRepAlgo_Sewing.hxx>
#include <BRepOffsetAPI_MakeOffsetShape.hxx>
#include <ShapeFix_Shape.hxx>
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp netgen-5.3.1_new/libsrc/occ/occgenmesh.cpp
---- netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/occgenmesh.cpp 2016-09-29 14:04:51.500148293 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/occgenmesh.cpp netgen-5.3.1_SRC_modif/libsrc/occ/occgenmesh.cpp
+--- netgen-5.3.1_SRC_orig/libsrc/occ/occgenmesh.cpp 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/occgenmesh.cpp 2017-09-11 18:08:21.231312190 +0300
@@ -171,8 +171,8 @@
if(h < 1e-4*maxside)\r
return;\r
\r
mesh.CalcSurfacesOfNode();\r
multithread.task = savetask;\r
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occgeom.cpp netgen-5.3.1_new/libsrc/occ/occgeom.cpp
---- netgen-5.3.1_orig/libsrc/occ/occgeom.cpp 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/occgeom.cpp 2016-09-29 16:22:31.636328123 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/occgeom.cpp netgen-5.3.1_SRC_modif/libsrc/occ/occgeom.cpp
+--- netgen-5.3.1_SRC_orig/libsrc/occ/occgeom.cpp 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/occgeom.cpp 2017-09-11 18:08:32.836058020 +0300
@@ -8,6 +8,8 @@
#include "ShapeAnalysis_CheckSmallFace.hxx"\r
#include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"\r
void OCCGeometry :: PrintNrShapes ()\r
{\r
TopExp_Explorer e;\r
-@@ -112,7 +121,7 @@
+@@ -112,13 +121,13 @@
double surfacecont = 0;\r
\r
{\r
rebuild->Apply(shape);\r
for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())\r
{\r
+ TopoDS_Edge edge = TopoDS::Edge(exp1.Current());\r
+ if ( BRep_Tool::Degenerated(edge) )\r
+- rebuild->Remove(edge, false);\r
++ rebuild->Remove(edge);\r
+ }\r
+ shape = rebuild->Apply(shape);\r
+ }\r
@@ -143,7 +152,7 @@
cout << endl << "- repairing faces" << endl;\r
\r
rebuild->Apply(shape);\r
\r
\r
-@@ -200,7 +209,7 @@
+@@ -187,7 +196,7 @@
+ cout << "(natural bounds added)" <<endl;\r
+ TopoDS_Face newface = sff->Face();\r
+ \r
+- rebuild->Replace(face, newface, Standard_False);\r
++ rebuild->Replace(face, newface);\r
+ }\r
+ \r
+ // Set the original colour of the face to the newly created \r
+@@ -200,13 +209,13 @@
\r
\r
{\r
rebuild->Apply(shape);\r
for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())\r
{\r
+ TopoDS_Edge edge = TopoDS::Edge(exp1.Current());\r
+ if ( BRep_Tool::Degenerated(edge) )\r
+- rebuild->Remove(edge, false);\r
++ rebuild->Remove(edge);\r
+ }\r
+ shape = rebuild->Apply(shape);\r
+ }\r
@@ -217,7 +226,7 @@
cout << endl << "- fixing small edges" << endl;\r
\r
rebuild->Apply(shape);\r
\r
\r
+@@ -270,7 +279,7 @@
+ if(replace)\r
+ {\r
+ TopoDS_Wire newwire = sfw->Wire();\r
+- rebuild->Replace(oldwire, newwire, Standard_False);\r
++ rebuild->Replace(oldwire, newwire);\r
+ }\r
+ \r
+ //delete sfw; sfw = NULL;\r
@@ -284,7 +293,7 @@
\r
{\r
rebuild->Apply(shape);\r
\r
for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())\r
-@@ -312,7 +321,7 @@
+@@ -300,7 +309,7 @@
+ cout << "removing degenerated edge " << emap.FindIndex(edge)\r
+ << " from vertex " << vmap.FindIndex(TopExp::FirstVertex (edge))\r
+ << " to vertex " << vmap.FindIndex(TopExp::LastVertex (edge)) << endl;\r
+- rebuild->Remove(edge, false);\r
++ rebuild->Remove(edge);\r
+ }\r
+ }\r
+ }\r
+@@ -312,13 +321,13 @@
\r
\r
{\r
rebuild->Apply(shape);\r
for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())\r
{\r
-@@ -438,7 +447,7 @@
+ TopoDS_Edge edge = TopoDS::Edge(exp1.Current());\r
+ if ( BRep_Tool::Degenerated(edge) )\r
+- rebuild->Remove(edge, false);\r
++ rebuild->Remove(edge);\r
+ }\r
+ shape = rebuild->Apply(shape);\r
+ }\r
+@@ -438,13 +447,13 @@
\r
\r
{\r
rebuild->Apply(shape);\r
for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())\r
{\r
-@@ -483,7 +492,7 @@
+ TopoDS_Edge edge = TopoDS::Edge(exp1.Current());\r
+ if ( BRep_Tool::Degenerated(edge) )\r
+- rebuild->Remove(edge, false);\r
++ rebuild->Remove(edge);\r
+ }\r
+ shape = rebuild->Apply(shape);\r
+ }\r
+@@ -483,9 +492,9 @@
TopoDS_Solid solid = TopoDS::Solid(exp0.Current());\r
TopoDS_Solid newsolid = solid;\r
BRepLib::OrientClosedSolid (newsolid);\r
- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
+ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
// rebuild->Apply(shape);\r
- rebuild->Replace(solid, newsolid, Standard_False);\r
+- rebuild->Replace(solid, newsolid, Standard_False);\r
++ rebuild->Replace(solid, newsolid);\r
TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_COMPSOLID);//, 1);\r
-@@ -906,7 +915,7 @@
+ // TopoDS_Shape newshape = rebuild->Apply(shape);\r
+ shape = newshape;\r
+@@ -906,8 +915,8 @@
TopoDS_Solid solid = TopoDS::Solid(exp0.Current());\r
TopoDS_Solid newsolid = solid;\r
BRepLib::OrientClosedSolid (newsolid);\r
- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
+- rebuild->Replace(solid, newsolid, Standard_False);\r
+ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
- rebuild->Replace(solid, newsolid, Standard_False);\r
++ rebuild->Replace(solid, newsolid);\r
\r
TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_SHAPE, 1);\r
+ shape = newshape;\r
@@ -951,25 +960,58 @@
}\r
\r
- gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );\r
- suval.Coord( u, v);\r
- pnt = thesurf->Value( u, v );\r
+-\r
+ // -- Optimization: use cached projector and classifier
+ // double u,v;
+ // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
+ Handle(ShapeAnalysis_Surface) proj;
+ BRepTopAdaptor_FClass2d *cls;
+ GetFaceTools(surfi, proj, cls);
- \r
++\r
+ gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
+ if (cls->Perform(p2d) == TopAbs_OUT)
+ {
- if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;\r
-\r
- gp_Vec du, dv;\r
+-\r
+- surface->D1(u,v,x,du,dv);\r
+-\r
+- int count = 0;\r
+-\r
+- gp_Pnt xold;\r
+- gp_Vec n;\r
+- double det, lambda, mu;\r
+-\r
+- do {\r
+- count++;\r
+-\r
+- n = du^dv;\r
+-\r
+- det = Det3 (n.X(), du.X(), dv.X(),\r
+- n.Y(), du.Y(), dv.Y(),\r
+- n.Z(), du.Z(), dv.Z());\r
+-\r
+- if (det < 1e-15) return false;\r
+-\r
+- lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),\r
+- n.Y(), p.Y()-x.Y(), dv.Y(),\r
+- n.Z(), p.Z()-x.Z(), dv.Z())/det;\r
+-\r
+- mu = Det3 (n.X(), du.X(), p.X()-x.X(),\r
+- n.Y(), du.Y(), p.Y()-x.Y(),\r
+- n.Z(), du.Z(), p.Z()-x.Z())/det;\r
+-\r
+- u += lambda;\r
+- v += mu;\r
+-\r
+- xold = x;\r
+- surface->D1(u,v,x,du,dv);\r
+-\r
+- } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);\r
+-\r
+- // (*testout) << "FastProject count: " << count << endl;\r
+-\r
+- if (count == 50) return false;\r
+-\r
+- ap = Point<3> (x.X(), x.Y(), x.Z());\r
+ // -- Optimization: use cached projector and classifier
+ // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
+ //
+ Handle(ShapeAnalysis_Surface) proj;
+ BRepTopAdaptor_FClass2d *cls;
+ GetFaceTools(surfi, proj, cls);
- \r
-- surface->D1(u,v,x,du,dv);\r
--\r
-- int count = 0;\r
--\r
-- gp_Pnt xold;\r
-- gp_Vec n;\r
-- double det, lambda, mu;\r
--\r
-- do {\r
-- count++;\r
--\r
-- n = du^dv;\r
--\r
-- det = Det3 (n.X(), du.X(), dv.X(),\r
-- n.Y(), du.Y(), dv.Y(),\r
-- n.Z(), du.Z(), dv.Z());\r
--\r
-- if (det < 1e-15) return false;\r
--\r
-- lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),\r
-- n.Y(), p.Y()-x.Y(), dv.Y(),\r
-- n.Z(), p.Z()-x.Z(), dv.Z())/det;\r
--\r
-- mu = Det3 (n.X(), du.X(), p.X()-x.X(),\r
-- n.Y(), du.Y(), p.Y()-x.Y(),\r
-- n.Z(), du.Z(), p.Z()-x.Z())/det;\r
--\r
-- u += lambda;\r
-- v += mu;\r
--\r
-- xold = x;\r
-- surface->D1(u,v,x,du,dv);\r
--\r
-- } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);\r
--\r
-- // (*testout) << "FastProject count: " << count << endl;\r
--\r
-- if (count == 50) return false;\r
++\r
+ gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
+ if (cls->Perform(p2d) == TopAbs_OUT)
+ {
+ //cout << "Projection fails" << endl;
+ return false;
+ }
- \r
-- ap = Point<3> (x.X(), x.Y(), x.Z());\r
++\r
+ p = proj->Value(p2d);
+ p2d.Coord(u, v);
+ ap = Point<3> (p.X(), p.Y(), p.Z());
occgeo->face_colours.Nullify();\r
occgeo->changed = 1;\r
occgeo->BuildFMap();\r
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occgeom.hpp netgen-5.3.1_new/libsrc/occ/occgeom.hpp
---- netgen-5.3.1_orig/libsrc/occ/occgeom.hpp 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/occgeom.hpp 2016-09-29 14:44:01.996464598 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/occgeom.hpp netgen-5.3.1_SRC_modif/libsrc/occ/occgeom.hpp
+--- netgen-5.3.1_SRC_orig/libsrc/occ/occgeom.hpp 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/occgeom.hpp 2017-09-11 18:08:21.233311974 +0300
@@ -15,8 +15,8 @@
#include "Geom_Curve.hxx"\r
#include "Geom2d_Curve.hxx"\r
OCCSurface GetSurface (int surfi)\r
{\r
cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;\r
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp netgen-5.3.1_new/libsrc/occ/occmeshsurf.cpp
---- netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/occmeshsurf.cpp 2016-09-29 14:08:00.045144560 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/occmeshsurf.cpp netgen-5.3.1_SRC_modif/libsrc/occ/occmeshsurf.cpp
+--- netgen-5.3.1_SRC_orig/libsrc/occ/occmeshsurf.cpp 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/occmeshsurf.cpp 2017-09-11 18:08:21.233311974 +0300
@@ -6,6 +6,7 @@
#include <meshing.hpp>
#include <GeomLProp_SLProps.hxx>
if(glob_testout)
{
(*testout) << "u " << geominfo.u << " v " << geominfo.v
-@@ -434,23 +435,33 @@
+@@ -434,23 +438,33 @@
void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
{
}
-@@ -680,7 +691,8 @@
+@@ -680,7 +694,8 @@
if (!geometry.FastProject (surfi, hnewp, u, v))
{
// cout << "Fast projection to surface fails! Using OCC projection" << endl;
}
newgi.trignum = 1;
-@@ -689,7 +701,7 @@
+@@ -689,7 +704,7 @@
}
newp = hnewp;
void OCCRefinementSurfaces ::
-@@ -708,14 +720,18 @@
+@@ -708,14 +723,18 @@
hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
newp = hnewp;
newgi = ap1;
void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const
{
-@@ -723,9 +739,10 @@
+@@ -723,9 +742,10 @@
if (!geometry.FastProject (surfi, p, gi.u, gi.v))
{
cout << "Fast projection to surface fails! Using OCC projection" << endl;
-diff -NaurwB netgen-5.3.1_orig/libsrc/occ/utilities.h netgen-5.3.1_new/libsrc/occ/utilities.h
---- netgen-5.3.1_orig/libsrc/occ/utilities.h 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/utilities.h 2016-09-29 14:04:51.504148314 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/occpkg.cpp netgen-5.3.1_SRC_modif/libsrc/occ/occpkg.cpp
+--- netgen-5.3.1_SRC_orig/libsrc/occ/occpkg.cpp 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/occpkg.cpp 2017-09-11 18:08:32.837057913 +0300
+@@ -485,7 +485,7 @@
+ if (strcmp (argv[2], "Wire") == 0) sh = occgeometry->wmap(nr);\r
+ if (strcmp (argv[2], "Edge") == 0) sh = occgeometry->emap(nr);\r
+ \r
+- rebuild->Replace(sh, sh.Reversed(), Standard_False);\r
++ rebuild->Replace(sh, sh.Reversed());\r
+ \r
+ TopoDS_Shape newshape = rebuild->Apply(occgeometry->shape, TopAbs_SHELL, 1);\r
+ occgeometry->shape = newshape;\r
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/occ/utilities.h netgen-5.3.1_SRC_modif/libsrc/occ/utilities.h
+--- netgen-5.3.1_SRC_orig/libsrc/occ/utilities.h 2014-08-29 13:54:03.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/occ/utilities.h 2017-09-11 18:08:21.233311974 +0300
@@ -33,6 +33,7 @@
#include <string>
#include <cstdlib>
// #include "SALOME_Log.hxx"
-diff -NaurwB netgen-5.3.1_orig/nglib/nglib.h netgen-5.3.1_new/nglib/nglib.h
---- netgen-5.3.1_orig/nglib/nglib.h 2014-08-29 13:54:00.000000000 +0400
-+++ netgen-5.3.1_new/nglib/nglib.h 2016-09-29 14:04:51.504148314 +0300
-@@ -24,7 +24,7 @@
- // Philippose - 14.02.2009\r
- // Modifications for creating a DLL in Windows\r
- #ifdef WIN32\r
-- #ifdef NGLIB_EXPORTS || nglib_EXPORTS\r
-+ #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
- #define DLL_HEADER __declspec(dllexport)\r
- #else\r
- #define DLL_HEADER __declspec(dllimport)\r
-diff -Naur netgen-5.3.1_orig/libsrc/csg/Makefile.am netgen-5.3.1_new/libsrc/csg/Makefile.am
---- netgen-5.3.1_orig/libsrc/csg/Makefile.am 2014-08-29 13:54:06.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/csg/Makefile.am 2016-11-08 17:48:02.000000000 +0300
-@@ -8,7 +8,7 @@
- AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include $(TCL_INCLUDES)
- METASOURCES = AUTO
-
--lib_LTLIBRARIES = libcsg.la
-+noinst_LTLIBRARIES = libcsg.la
-
-
- libcsg_la_SOURCES = algprim.cpp brick.cpp \
-@@ -17,12 +17,9 @@
- manifold.cpp meshsurf.cpp polyhedra.cpp revolution.cpp singularref.cpp \
- solid.cpp specpoin.cpp spline3d.cpp surface.cpp triapprox.cpp
-
--libcsg_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
--
--
-
- if NGGUI
--lib_LTLIBRARIES += libcsgvis.la
-+lib_LTLIBRARIES = libcsgvis.la
-
- libcsgvis_la_SOURCES = vscsg.cpp csgpkg.cpp
- libcsgvis_la_LIBADD = libcsg.la
-diff -Naur netgen-5.3.1_orig/libsrc/geom2d/Makefile.am netgen-5.3.1_new/libsrc/geom2d/Makefile.am
---- netgen-5.3.1_orig/libsrc/geom2d/Makefile.am 2014-08-29 13:54:06.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/geom2d/Makefile.am 2016-11-08 17:49:13.000000000 +0300
-@@ -4,16 +4,15 @@
-
- METASOURCES = AUTO
-
--lib_LTLIBRARIES = libgeom2d.la
-+noinst_LTLIBRARIES = libgeom2d.la
-
- if NGGUI
--lib_LTLIBRARIES += libgeom2dvis.la
-+lib_LTLIBRARIES = libgeom2dvis.la
- endif
-
-
-
- libgeom2d_la_SOURCES = genmesh2d.cpp geom2dmesh.cpp geometry2d.cpp
--libgeom2d_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
-
- libgeom2dvis_la_SOURCES = geom2dpkg.cpp vsgeom2d.cpp
- libgeom2dvis_la_LIBADD = libgeom2d.la
-diff -Naur netgen-5.3.1_orig/libsrc/interface/Makefile.am netgen-5.3.1_new/libsrc/interface/Makefile.am
---- netgen-5.3.1_orig/libsrc/interface/Makefile.am 2014-08-29 13:54:02.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/interface/Makefile.am 2016-11-08 17:49:26.000000000 +0300
-@@ -2,14 +2,11 @@
-
- AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface $(MPI_INCLUDES) $(TCL_INCLUDES) -DOPENGL
- METASOURCES = AUTO
--lib_LTLIBRARIES = libinterface.la
-+noinst_LTLIBRARIES = libinterface.la
- libinterface_la_SOURCES = nginterface.cpp nginterface_v2.cpp \
- read_fnf_mesh.cpp readtetmesh.cpp readuser.cpp writeabaqus.cpp writediffpack.cpp \
- writedolfin.cpp writeelmer.cpp writefeap.cpp writefluent.cpp writegmsh.cpp writejcm.cpp \
- writepermas.cpp writetecplot.cpp writetet.cpp writetochnog.cpp writeuser.cpp \
- wuchemnitz.cpp writegmsh2.cpp writeOpenFOAM15x.cpp
-
--
--libinterface_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
--
- # libinterface_la_LDFLAGS = -rdynamic
-diff -Naur netgen-5.3.1_orig/libsrc/meshing/Makefile.am netgen-5.3.1_new/libsrc/meshing/Makefile.am
---- netgen-5.3.1_orig/libsrc/meshing/Makefile.am 2014-08-29 13:54:05.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/meshing/Makefile.am 2016-11-08 17:48:44.000000000 +0300
-@@ -15,7 +15,7 @@
-
- METASOURCES = AUTO
-
--lib_LTLIBRARIES = libmesh.la
-+noinst_LTLIBRARIES = libmesh.la
-
- libmesh_la_SOURCES = adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp \
- clusters.cpp curvedelems.cpp delaunay.cpp delaunay2d.cpp \
-@@ -30,8 +30,5 @@
- topology.cpp triarls.cpp validate.cpp zrefine.cpp bcfunctions.cpp \
- parallelmesh.cpp paralleltop.cpp paralleltop.hpp basegeom.cpp
-
--libmesh_la_LIBADD = $(top_builddir)/libsrc/linalg/libla.la \
-- $(top_builddir)/libsrc/gprim/libgprim.la \
-- $(top_builddir)/libsrc/general/libgen.la \
-- -lz
-+libmesh_la_LIBADD = -lz
-
-diff -Naur netgen-5.3.1_orig/libsrc/occ/Makefile.am netgen-5.3.1_new/libsrc/occ/Makefile.am
---- netgen-5.3.1_orig/libsrc/occ/Makefile.am 2014-08-29 13:54:03.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/occ/Makefile.am 2016-11-08 17:30:53.000000000 +0300
-@@ -14,10 +14,10 @@
-
- METASOURCES = AUTO
-
--lib_LTLIBRARIES = libocc.la
-+noinst_LTLIBRARIES = libocc.la
-
- if NGGUI
--lib_LTLIBRARIES += liboccvis.la
-+lib_LTLIBRARIES = liboccvis.la
- endif
-
-
-diff -Naur netgen-5.3.1_orig/libsrc/stlgeom/Makefile.am netgen-5.3.1_new/libsrc/stlgeom/Makefile.am
---- netgen-5.3.1_orig/libsrc/stlgeom/Makefile.am 2014-08-29 13:54:05.000000000 +0400
-+++ netgen-5.3.1_new/libsrc/stlgeom/Makefile.am 2016-11-08 18:28:09.000000000 +0300
+diff -Naur netgen-5.3.1_SRC_orig/libsrc/stlgeom/Makefile.am netgen-5.3.1_SRC_modif/libsrc/stlgeom/Makefile.am
+--- netgen-5.3.1_SRC_orig/libsrc/stlgeom/Makefile.am 2014-08-29 13:54:05.000000000 +0400
++++ netgen-5.3.1_SRC_modif/libsrc/stlgeom/Makefile.am 2017-09-11 18:08:21.235311757 +0300
@@ -4,10 +4,10 @@
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include $(TCL_INCLUDES)
METASOURCES = AUTO
-libstl_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
# libstlvis_la_LIBADD = libstl.la $(top_builddir)/libsrc/linalg/libla.la
-diff -Naur netgen-5.3.1_orig/nglib/Makefile.am netgen-5.3.1_new/nglib/Makefile.am
---- netgen-5.3.1_orig/nglib/Makefile.am 2014-08-29 13:54:00.000000000 +0400
-+++ netgen-5.3.1_new/nglib/Makefile.am 2016-11-08 19:01:17.000000000 +0300
+diff -Naur netgen-5.3.1_SRC_orig/nglib/Makefile.am netgen-5.3.1_SRC_modif/nglib/Makefile.am
+--- netgen-5.3.1_SRC_orig/nglib/Makefile.am 2014-08-29 13:54:00.000000000 +0400
++++ netgen-5.3.1_SRC_modif/nglib/Makefile.am 2017-09-11 18:08:21.235311757 +0300
@@ -14,6 +14,9 @@
$(top_builddir)/libsrc/stlgeom/libstl.la \
$(top_builddir)/libsrc/occ/libocc.la \
$(OCCLIBS) $(MPI_LIBS)
libnglib_la_LDFLAGS = -avoid-version
+diff -Naur netgen-5.3.1_SRC_orig/nglib/nglib.h netgen-5.3.1_SRC_modif/nglib/nglib.h
+--- netgen-5.3.1_SRC_orig/nglib/nglib.h 2014-08-29 13:54:00.000000000 +0400
++++ netgen-5.3.1_SRC_modif/nglib/nglib.h 2017-09-11 18:08:21.233311974 +0300
+@@ -24,7 +24,7 @@
+ // Philippose - 14.02.2009\r
+ // Modifications for creating a DLL in Windows\r
+ #ifdef WIN32\r
+- #ifdef NGLIB_EXPORTS || nglib_EXPORTS\r
++ #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
+ #define DLL_HEADER __declspec(dllexport)\r
+ #else\r
+ #define DLL_HEADER __declspec(dllimport)\r
#!/bin/sh
-src_dir=$1
-install_dir=$2
+src_dir=${1}
+install_dir=${2}
-if ! test -d $src_dir/libsrc ; then
- echo "No dir $src_dir/libsrc ... Bye"
+if ! test -d ${src_dir}/libsrc ; then
+ echo "No dir ${src_dir}/libsrc ... Bye"
exit 1
fi
-if ! test -d $install_dir/share/netgen ; then
- echo "No dir $install_dir/share/netgen ... Bye"
+if ! test -d ${install_dir} ; then
+ echo "No dir ${install_dir} ... Bye"
exit 1
fi
-dest_dir=$install_dir/share/netgen/include
-mkdir -p $dest_dir > /dev/null 2>&1
-cp -af $src_dir/libsrc/csg/*.hpp $dest_dir
-cp -af $src_dir/libsrc/general/*.hpp $dest_dir
-cp -af $src_dir/libsrc/geom2d/*.hpp $dest_dir
-cp -af $src_dir/libsrc/gprim/*.hpp $dest_dir
-cp -af $src_dir/libsrc/interface/*.hpp $dest_dir
-cp -af $src_dir/libsrc/linalg/*.hpp $dest_dir
-cp -af $src_dir/libsrc/meshing/*.hpp $dest_dir
-cp -af $src_dir/libsrc/stlgeom/*.hpp $dest_dir
-cp -af $src_dir/libsrc/visualization/*.hpp $dest_dir
+dest_dir=${install_dir}/include
+mkdir -p ${dest_dir} > /dev/null 2>&1
-cp -af $src_dir/libsrc/occ/*.hpp $dest_dir
-cp -af $src_dir/libsrc/occ/*.hxx $dest_dir
-cp -af $src_dir/libsrc/occ/*.ixx $dest_dir
-cp -af $src_dir/libsrc/occ/*.jxx $dest_dir
-cp -af $src_dir/libsrc/occ/*.h $dest_dir
-
-cp -af $src_dir/libsrc/include/mystdlib.h $dest_dir
-cp -af $src_dir/libsrc/include/mydefs.hpp $dest_dir
-# cp -af $src_dir/libsrc/include/parallel.hpp $dest_dir
-
-rm -f $dest_dir/ngexception.hpp
-rm -f $dest_dir/paralleltop.hpp
-rm -f $dest_dir/soldata.hpp
+for directory in csg general geom2d gprim interface linalg meshing stlgeom visualization
+do
+ cp -af ${src_dir}/libsrc/${directory}/*.hpp ${dest_dir}
+done
+cp -af ${src_dir}/libsrc/include/mystdlib.h ${dest_dir}
+cp -af ${src_dir}/libsrc/include/mydefs.hpp ${dest_dir}
+cp -af ${src_dir}/libsrc/occ/occgeom.hpp ${dest_dir}
+cp -af ${src_dir}/libsrc/occ/occmeshsurf.hpp ${dest_dir}
+cp -af ${src_dir}/libsrc/general/gzstream.h ${dest_dir}
+test -f ${src_dir}/config.h && cp -af ${src_dir}/config.h ${dest_dir}
NETGENPlugin_SimpleHypothesis_2D_i.hxx
NETGENPlugin_SimpleHypothesis_3D_i.hxx
NETGENPlugin_Mesher.hxx
+ NETGENPlugin_Remesher_2D.hxx
NETGENPlugin_Defs.hxx
)
NETGENPlugin_SimpleHypothesis_3D.cxx
NETGENPlugin_SimpleHypothesis_2D_i.cxx
NETGENPlugin_SimpleHypothesis_3D_i.cxx
+ NETGENPlugin_Remesher_2D.cxx
NETGENPlugin_i.cxx
)
def __init__(self, mesh, geom=0):
Mesh_Algorithm.__init__(self)
if noNETGENPlugin: print("Warning: NETGENPlugin module unavailable")
- self.Create(mesh, geom, self.algoType, LIBRARY)
+ if not mesh.GetMesh().HasShapeToMesh() and \
+ self.meshMethod == "Triangle": # create a 2D remesher
+ self.Create(mesh, geom, "NETGEN_Remesher_2D", LIBRARY)
+ else:
+ self.Create(mesh, geom, self.algoType, LIBRARY)
self.params = None
pass
else:
hypType = "NETGEN_Parameters_3D"
+ if self.algo.GetName() == "NETGEN_Remesher_2D":
+ hypType = "NETGEN_RemesherParameters_2D"
+
if self.params and self.params.GetName() != hypType:
self.mesh.RemoveHypothesis( self.params, self.geom )
self.params = None
if self.Parameters(): self.params.SetNbSegPerRadius(theVal)
pass
+ ## Sets @c ChordalError parameter
+ # @param theVal new value of the @c ChordalError parameter
+ def SetChordalError(self, theVal):
+ if self.Parameters():
+ self.params.SetChordalError(theVal)
+ self.params.SetChordalErrorEnabled( theVal > 0 )
+ pass
+
+ ## Sets @c RidgeAngle parameter
+ # @param theVal new value of the @c RidgeAngle parameter
+ def SetRidgeAngle(self, theVal):
+ if self.Parameters():
+ self.params.SetRidgeAngle(theVal)
+ pass
+
## Sets @c QuadAllowed flag
# @param toAllow new value of the @c QuadAllowed parameter (@c True by default)
def SetQuadAllowed(self, toAllow=True):
//=============================================================================
NETGENPlugin_Hypothesis::NETGENPlugin_Hypothesis (int hypId,
SMESH_Gen * gen)
+
: SMESH_Hypothesis(hypId, gen),
- _maxSize (GetDefaultMaxSize()),
- _minSize (0),
- _growthRate (GetDefaultGrowthRate()),
- _nbSegPerEdge (GetDefaultNbSegPerEdge()),
- _nbSegPerRadius (GetDefaultNbSegPerRadius()),
- _fineness (GetDefaultFineness()),
- _secondOrder (GetDefaultSecondOrder()),
- _optimize (GetDefaultOptimize()),
- _localSize (GetDefaultLocalSize()),
- _quadAllowed (GetDefaultQuadAllowed()),
- _surfaceCurvature(GetDefaultSurfaceCurvature()),
- _fuseEdges (GetDefaultFuseEdges())
+ _maxSize (GetDefaultMaxSize()),
+ _minSize (0),
+ _growthRate (GetDefaultGrowthRate()),
+ _nbSegPerEdge (GetDefaultNbSegPerEdge()),
+ _nbSegPerRadius (GetDefaultNbSegPerRadius()),
+ _fineness (GetDefaultFineness()),
+ _chordalErrorEnabled(GetDefaultChordalError() > 0),
+ _chordalError (GetDefaultChordalError() ),
+ _secondOrder (GetDefaultSecondOrder()),
+ _optimize (GetDefaultOptimize()),
+ _localSize (GetDefaultLocalSize()),
+ _quadAllowed (GetDefaultQuadAllowed()),
+ _surfaceCurvature (GetDefaultSurfaceCurvature()),
+ _fuseEdges (GetDefaultFuseEdges())
{
_name = "NETGEN_Parameters";
_param_algo_dim = 3;
}
}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void NETGENPlugin_Hypothesis::SetChordalErrorEnabled(bool theVal)
+{
+ if (theVal != _chordalErrorEnabled)
+ {
+ _chordalErrorEnabled = theVal;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void NETGENPlugin_Hypothesis::SetChordalError(double theVal)
+{
+ if (theVal != _chordalError)
+ {
+ _chordalError = theVal;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
//=============================================================================
/*!
*
if (it_sm != _localSize.end()) {
save << " " << "__LOCALSIZE_BEGIN__";
for ( ; it_sm != _localSize.end(); ++it_sm ) {
- save << " " << it_sm->first
- << " " << it_sm->second << "%#"; // "%#" is a mark of value end
+ save << " " << it_sm->first
+ << " " << it_sm->second << "%#"; // "%#" is a mark of value end
}
save << " " << "__LOCALSIZE_END__";
}
save << " " << _meshSizeFile.size() << " " << _meshSizeFile;
+ save << " " << ( _chordalErrorEnabled ? _chordalError : 0. );
+
return save;
}
load.get( &_meshSizeFile[0], is+1 );
}
+ isOK = static_cast<bool>(load >> val);
+ if (isOK)
+ _chordalError = val;
+ else
+ load.clear(ios::badbit | load.rdstate());
+ _chordalErrorEnabled = ( _chordalError > 0 );
+
return load;
}
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
ostream & operator <<(ostream & save, NETGENPlugin_Hypothesis & hyp)
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
istream & operator >>(istream & load, NETGENPlugin_Hypothesis & hyp)
{
return 2;
}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+double NETGENPlugin_Hypothesis::GetDefaultChordalError()
+{
+ return -1; // disabled by default
+}
//=============================================================================
/*!
void SetNbSegPerRadius(double theVal);
double GetNbSegPerRadius() const { return _nbSegPerRadius; }
+ void SetChordalErrorEnabled(bool value);
+ double GetChordalErrorEnabled() const { return _chordalErrorEnabled; }
+ void SetChordalError(double value);
+ double GetChordalError() const { return _chordalError; }
+
typedef std::map<std::string, double> TLocalSize;
static TLocalSize GetDefaultLocalSize() { return TLocalSize(); }
void SetLocalSizeOnEntry(const std::string& entry, double localSize);
static double GetDefaultGrowthRate();
static double GetDefaultNbSegPerEdge();
static double GetDefaultNbSegPerRadius();
+ static double GetDefaultChordalError();
static bool GetDefaultSecondOrder();
static bool GetDefaultOptimize();
static bool GetDefaultQuadAllowed();
static bool GetDefaultFuseEdges();
// Persistence
- virtual ostream & SaveTo(ostream & save);
- virtual istream & LoadFrom(istream & load);
- friend NETGENPLUGIN_EXPORT ostream & operator <<(ostream & save, NETGENPlugin_Hypothesis & hyp);
- friend NETGENPLUGIN_EXPORT istream & operator >>(istream & load, NETGENPlugin_Hypothesis & hyp);
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
/*!
* \brief Does nothing
double _nbSegPerEdge;
double _nbSegPerRadius;
Fineness _fineness;
+ bool _chordalErrorEnabled;
+ double _chordalError;
bool _secondOrder;
bool _optimize;
TLocalSize _localSize;
//=============================================================================
//
#include "NETGENPlugin_Hypothesis_2D.hxx"
-#include <utilities.h>
using namespace std;
*
*/
//=============================================================================
-// void NETGENPlugin_Hypothesis_2D::SetQuadAllowed(bool theVal)
-// {
-// if (theVal != _quadAllowed)
-// {
-// _quadAllowed = theVal;
-// NotifySubMeshesHypothesisModification();
-// }
-// }
-
-// //=============================================================================
-// /*!
-// *
-// */
-// //=============================================================================
-// bool NETGENPlugin_Hypothesis_2D::GetDefaultQuadAllowed()
-// {
-// return false;
-// }
-
-// //=============================================================================
-// /*!
-// *
-// */
-// //=============================================================================
-// ostream & NETGENPlugin_Hypothesis_2D::SaveTo(ostream & save)
-// {
-// NETGENPlugin_Hypothesis::SaveTo(save);
-
-// save << " " << (int)_quadAllowed;
-
-// return save;
-// }
-
-// //=============================================================================
-// /*!
-// *
-// */
-// //=============================================================================
-// istream & NETGENPlugin_Hypothesis_2D::LoadFrom(istream & load)
-// {
-// NETGENPlugin_Hypothesis::LoadFrom(load);
-
-// bool isOK = true;
-// int is;
-
-// isOK = (load >> is);
-// if (isOK)
-// _quadAllowed = (bool) is;
-// else
-// load.clear(ios::badbit | load.rdstate());
-
-// return load;
-// }
+NETGENPlugin_RemesherHypothesis_2D::
+NETGENPlugin_RemesherHypothesis_2D (int hypId, SMESH_Gen * gen)
+ : NETGENPlugin_Hypothesis(hypId, gen)
+{
+ _name = "NETGEN_RemesherParameters_2D";
+ _param_algo_dim = 2;
+
+ _ridgeAngle = DefaultRidgeAngle();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void NETGENPlugin_RemesherHypothesis_2D::SetRidgeAngle( double angle )
+{
+ if ( _ridgeAngle != angle )
+ {
+ _ridgeAngle = angle;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+double NETGENPlugin_RemesherHypothesis_2D::GetRidgeAngle() const
+{
+ return _ridgeAngle;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+std::ostream & NETGENPlugin_RemesherHypothesis_2D::SaveTo(std::ostream & save)
+{
+ NETGENPlugin_Hypothesis::SaveTo( save );
+ save << " " << _ridgeAngle;
+
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+std::istream & NETGENPlugin_RemesherHypothesis_2D::LoadFrom(std::istream & load)
+{
+ NETGENPlugin_Hypothesis::LoadFrom( load );
+ if ( !load )
+ load.clear(ios::badbit | load.rdstate());
+
+ load >> _ridgeAngle;
+
+ if ( !load )
+ _ridgeAngle = DefaultRidgeAngle();
+
+ return load;
+}
// bool _quadAllowed;
};
+
+// Parameters of NETGEN remesher
+//
+
+class NETGENPLUGIN_EXPORT NETGENPlugin_RemesherHypothesis_2D: public NETGENPlugin_Hypothesis
+{
+ public:
+
+ NETGENPlugin_RemesherHypothesis_2D(int hypId, SMESH_Gen * gen);
+
+ void SetRidgeAngle( double angle );
+ double GetRidgeAngle() const;
+
+ static double DefaultRidgeAngle() { return 30.; }
+
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+
+ private:
+
+ double _ridgeAngle; // in degrees
+};
+
#endif
#include "SMESH_Gen.hxx"
#include "SMESH_PythonDump.hxx"
-#include "Utils_CorbaException.hxx"
-#include "utilities.h"
-
-using namespace std;
-
//=============================================================================
/*!
* NETGENPlugin_Hypothesis_2D_i::NETGENPlugin_Hypothesis_2D_i
//=============================================================================
/*!
- * NETGENPlugin_Hypothesis_2D_i::SetQuadAllowed
+ * NETGENPlugin_Hypothesis_2D_i::GetImpl
*
- * Set QuadAllowed flag
+ * Get implementation
*/
//=============================================================================
-// void NETGENPlugin_Hypothesis_2D_i::SetQuadAllowed (CORBA::Boolean theValue)
-// {
-// if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetQuadAllowed(),
-// theValue,
-// METH_SetQuadAllowed ))
-// {
-// this->GetImpl()->SetQuadAllowed(theValue);
-// SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
-// }
-// }
+::NETGENPlugin_Hypothesis_2D* NETGENPlugin_Hypothesis_2D_i::GetImpl()
+{
+ return (::NETGENPlugin_Hypothesis_2D*)myBaseImpl;
+}
+
+//================================================================================
+/*!
+ * \brief Verify whether hypothesis supports given entity type
+ * \param type - dimension (see SMESH::Dimension enumeration)
+ * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
+ *
+ * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
+ */
+//================================================================================
+CORBA::Boolean NETGENPlugin_Hypothesis_2D_i::IsDimSupported( SMESH::Dimension type )
+{
+ return type == SMESH::DIM_2D;
+}
+
//=============================================================================
/*!
- * NETGENPlugin_Hypothesis_2D_i::GetQuadAllowed
+ * NETGENPlugin_RemesherHypothesis_2D_i::NETGENPlugin_RemesherHypothesis_2D_i
*
- * Get QuadAllowed flag
+ * Constructor
*/
//=============================================================================
-// CORBA::Boolean NETGENPlugin_Hypothesis_2D_i::GetQuadAllowed()
-// {
-// return this->GetImpl()->GetQuadAllowed();
-// }
+NETGENPlugin_RemesherHypothesis_2D_i::
+NETGENPlugin_RemesherHypothesis_2D_i (PortableServer::POA_ptr thePOA,
+ ::SMESH_Gen* theGenImpl)
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA ),
+ NETGENPlugin_Hypothesis_2D_i( thePOA, theGenImpl )
+{
+ myBaseImpl = new ::NETGENPlugin_RemesherHypothesis_2D (theGenImpl->GetANewId(),
+ theGenImpl);
+}
+
+//================================================================================
+/*!
+ * \brief Verify whether hypothesis supports given entity type
+ * \param type - dimension (see SMESH::Dimension enumeration)
+ * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
+ *
+ * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
+ */
+//================================================================================
+CORBA::Boolean NETGENPlugin_RemesherHypothesis_2D_i::IsDimSupported( SMESH::Dimension type )
+{
+ return type == SMESH::DIM_2D;
+}
//=============================================================================
/*!
- * NETGENPlugin_Hypothesis_2D_i::GetImpl
+ * NETGENPlugin_RemesherHypothesis_2D_i::GetImpl
*
* Get implementation
*/
//=============================================================================
-::NETGENPlugin_Hypothesis_2D* NETGENPlugin_Hypothesis_2D_i::GetImpl()
+::NETGENPlugin_RemesherHypothesis_2D* NETGENPlugin_RemesherHypothesis_2D_i::GetImpl()
{
- return (::NETGENPlugin_Hypothesis_2D*)myBaseImpl;
+ return (::NETGENPlugin_RemesherHypothesis_2D*)myBaseImpl;
}
//================================================================================
/*!
- * \brief Verify whether hypothesis supports given entity type
- * \param type - dimension (see SMESH::Dimension enumeration)
- * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
- *
- * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
+ * \brief Set ridge angle
*/
-//================================================================================
-CORBA::Boolean NETGENPlugin_Hypothesis_2D_i::IsDimSupported( SMESH::Dimension type )
+//================================================================================
+
+void NETGENPlugin_RemesherHypothesis_2D_i::SetRidgeAngle( CORBA::Double angle )
{
- return type == SMESH::DIM_2D;
+ GetImpl()->SetRidgeAngle( angle );
+
+ SMESH::TPythonDump() << _this() << ".SetRidgeAngle( " << SMESH::TVar(angle) << " )";
+}
+
+//================================================================================
+/*!
+ * \brief Return ridge angle
+ */
+//================================================================================
+
+CORBA::Double NETGENPlugin_RemesherHypothesis_2D_i::GetRidgeAngle()
+{
+ return GetImpl()->GetRidgeAngle();
}
// };
};
+// NETGENPlugin_Remesher_2D parameters hypothesis
+
+class NETGENPLUGIN_EXPORT NETGENPlugin_RemesherHypothesis_2D_i:
+ public virtual POA_NETGENPlugin::NETGENPlugin_RemesherHypothesis_2D,
+ public NETGENPlugin_Hypothesis_2D_i
+{
+ public:
+ // Constructor
+ NETGENPlugin_RemesherHypothesis_2D_i( PortableServer::POA_ptr thePOA,
+ ::SMESH_Gen* theGenImpl);
+
+ void SetRidgeAngle( CORBA::Double angle );
+
+ CORBA::Double GetRidgeAngle();
+
+ // Get implementation
+ ::NETGENPlugin_RemesherHypothesis_2D* GetImpl();
+
+ // Verify whether hypothesis supports given entity type
+ CORBA::Boolean IsDimSupported( SMESH::Dimension type );
+};
+
#endif
//=============================================================================
+void NETGENPlugin_Hypothesis_i::SetChordalErrorEnabled(CORBA::Boolean theValue)
+{
+ if ( isToSetParameter( GetChordalErrorEnabled(), theValue, METH_SetChordalErrorEnabled ))
+ {
+ this->GetImpl()->SetChordalErrorEnabled(theValue);
+ SMESH::TPythonDump() << _this() << ".SetChordalErrorEnabled( " << theValue << " )";
+ }
+}
+
+CORBA::Boolean NETGENPlugin_Hypothesis_i::GetChordalErrorEnabled()
+{
+ return GetImpl()->GetChordalErrorEnabled();
+}
+
+void NETGENPlugin_Hypothesis_i::SetChordalError(CORBA::Double theValue)
+{
+ if ( isToSetParameter( GetChordalError(), theValue, METH_SetChordalError ))
+ {
+ this->GetImpl()->SetChordalError(theValue);
+ SMESH::TPythonDump() << _this() << ".SetChordalError( " << SMESH::TVar(theValue) << " )";
+ }
+}
+
+CORBA::Double NETGENPlugin_Hypothesis_i::GetChordalError()
+{
+ return GetImpl()->GetChordalError();
+}
+
+//=============================================================================
+
void NETGENPlugin_Hypothesis_i::SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj,
CORBA::Double localSize)
throw (SALOME::SALOME_Exception)
void SetNbSegPerRadius(CORBA::Double theVal);
CORBA::Double GetNbSegPerRadius();
+ void SetChordalErrorEnabled(CORBA::Boolean value);
+ CORBA::Boolean GetChordalErrorEnabled();
+ void SetChordalError(CORBA::Double value);
+ CORBA::Double GetChordalError();
+
void SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double localSize)
throw (SALOME::SALOME_Exception);
void SetLocalSizeOnEntry(const char* entry, CORBA::Double localSize);
// to remember whether a parameter is already set (issue 0021364)
enum SettingMethod
{
- METH_SetMaxSize = 1,
- METH_SetMinSize = 2,
- METH_SetSecondOrder = 4,
- METH_SetOptimize = 8,
- METH_SetFineness = 16,
- METH_SetGrowthRate = 32,
- METH_SetNbSegPerEdge = 64,
- METH_SetNbSegPerRadius = 128,
- METH_SetLocalSizeOnEntry = 256,
- METH_SetQuadAllowed = METH_SetLocalSizeOnEntry * 2,
- METH_SetSurfaceCurvature = METH_SetQuadAllowed * 2,
- METH_SetFuseEdges = METH_SetSurfaceCurvature * 2,
- METH_LAST = METH_SetFuseEdges
+ METH_SetMaxSize = 1,
+ METH_SetMinSize = 2,
+ METH_SetSecondOrder = 4,
+ METH_SetOptimize = 8,
+ METH_SetFineness = 16,
+ METH_SetGrowthRate = 32,
+ METH_SetNbSegPerEdge = 64,
+ METH_SetNbSegPerRadius = 128,
+ METH_SetLocalSizeOnEntry = 256,
+ METH_SetQuadAllowed = METH_SetLocalSizeOnEntry * 2,
+ METH_SetSurfaceCurvature = METH_SetQuadAllowed * 2,
+ METH_SetFuseEdges = METH_SetSurfaceCurvature * 2,
+ METH_SetChordalErrorEnabled = METH_SetFuseEdges * 2,
+ METH_SetChordalError = METH_SetChordalErrorEnabled * 2,
+ METH_LAST = METH_SetFuseEdges
};
int mySetMethodFlags;
#include <utilities.h>
+#include <BRepAdaptor_Surface.hxx>
#include <BRepBuilderAPI_Copy.hxx>
+#include <BRepLProp_SLProps.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
+#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <Bnd_B3d.hxx>
+#include <GeomLib_IsPlanarSurface.hxx>
#include <NCollection_Map.hxx>
+#include <Poly_Triangulation.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_ProgramError.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
+#include <TopLoc_Location.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopoDS.hxx>
+#include <TopoDS_Compound.hxx>
// Netgen include files
#ifndef OCCGEOMETRY
_optimize(true),
_fineness(NETGENPlugin_Hypothesis::GetDefaultFineness()),
_isViscousLayers2D(false),
+ _chordalError(-1), // means disabled
_ngMesh(NULL),
_occgeom(NULL),
_curShapeIndex(-1),
_fineness = hyp->GetFineness();
mparams.uselocalh = hyp->GetSurfaceCurvature();
netgen::merge_solids = hyp->GetFuseEdges();
+ _chordalError = hyp->GetChordalErrorEnabled() ? hyp->GetChordalError() : -1.;
_simpleHyp = NULL;
// mesh size file
mparams.meshsizefilename= hyp->GetMeshSizeFile().empty() ? 0 : hyp->GetMeshSizeFile().c_str();
- SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
-
- const NETGENPlugin_Hypothesis::TLocalSize localSizes = hyp->GetLocalSizesAndEntries();
- NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
- for ( ; it != localSizes.end() ; it++)
+ const NETGENPlugin_Hypothesis::TLocalSize& localSizes = hyp->GetLocalSizesAndEntries();
+ if ( !localSizes.empty() )
{
- std::string entry = (*it).first;
- double val = (*it).second;
- // --
- GEOM::GEOM_Object_var aGeomObj;
- SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() );
- if ( !aSObj->_is_nil() ) {
- CORBA::Object_var obj = aSObj->GetObject();
- aGeomObj = GEOM::GEOM_Object::_narrow(obj);
- aSObj->UnRegister();
+ SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
+ NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
+ for ( ; it != localSizes.end() ; it++)
+ {
+ std::string entry = (*it).first;
+ double val = (*it).second;
+ // --
+ GEOM::GEOM_Object_var aGeomObj;
+ SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() );
+ if ( !aSObj->_is_nil() ) {
+ CORBA::Object_var obj = aSObj->GetObject();
+ aGeomObj = GEOM::GEOM_Object::_narrow(obj);
+ aSObj->UnRegister();
+ }
+ TopoDS_Shape S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
+ ::SetLocalSize(S, val);
}
- TopoDS_Shape S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
- ::SetLocalSize(S, val);
}
}
}
void setLocalSize(const TopoDS_Edge& edge,
double size,
- netgen::Mesh& mesh)
+ netgen::Mesh& mesh,
+ const bool overrideMinH = true)
{
if ( size <= std::numeric_limits<double>::min() )
return;
TopoDS_Iterator vIt( edge );
if ( !vIt.More() ) return;
gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( vIt.Value() ));
- NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), size );
+ NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), size, overrideMinH );
}
else
{
{
Standard_Real u = u1 + delta*i;
gp_Pnt p = curve->Value(u);
- NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), size );
+ NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), size, overrideMinH );
netgen::Point3d pi(p.X(), p.Y(), p.Z());
double resultSize = mesh.GetH(pi);
if ( resultSize - size > 0.1*size )
// netgen does restriction iff oldH/newH > 1.2 (localh.cpp:136)
- NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), resultSize/1.201 );
+ NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), resultSize/1.201, overrideMinH );
}
}
}
+
+ //================================================================================
+ /*!
+ * \brief Return triangle size for a given chordalError and radius of curvature
+ */
+ //================================================================================
+
+ double elemSizeForChordalError( double chordalError, double radius )
+ {
+ if ( 2 * radius < chordalError )
+ return 1.5 * radius;
+ return Sqrt( 3 ) * Sqrt( chordalError * ( 2 * radius - chordalError ));
+ }
+
} // namespace
//================================================================================
//================================================================================
void NETGENPlugin_Mesher::SetLocalSize( netgen::OCCGeometry& occgeo,
- netgen::Mesh& ngMesh )
+ netgen::Mesh& ngMesh)
{
- for(std::map<int,double>::const_iterator it=EdgeId2LocalSize.begin(); it!=EdgeId2LocalSize.end(); it++)
+ // edges
+ std::map<int,double>::const_iterator it;
+ for( it=EdgeId2LocalSize.begin(); it!=EdgeId2LocalSize.end(); it++)
{
int key = (*it).first;
double hi = (*it).second;
const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key);
setLocalSize( TopoDS::Edge(shape), hi, ngMesh );
}
- for(std::map<int,double>::const_iterator it=VertexId2LocalSize.begin(); it!=VertexId2LocalSize.end(); it++)
+ // vertices
+ for(it=VertexId2LocalSize.begin(); it!=VertexId2LocalSize.end(); it++)
{
int key = (*it).first;
double hi = (*it).second;
gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex(shape) );
NETGENPlugin_Mesher::RestrictLocalSize( ngMesh, p.XYZ(), hi );
}
- for(map<int,double>::const_iterator it=FaceId2LocalSize.begin(); it!=FaceId2LocalSize.end(); it++)
+ // faces
+ for(it=FaceId2LocalSize.begin(); it!=FaceId2LocalSize.end(); it++)
{
int key = (*it).first;
double val = (*it).second;
ShapesWithControlPoints.insert( key );
}
}
- for(map<int,double>::const_iterator it=SolidId2LocalSize.begin(); it!=SolidId2LocalSize.end(); it++)
+ //solids
+ for(it=SolidId2LocalSize.begin(); it!=SolidId2LocalSize.end(); it++)
{
int key = (*it).first;
double val = (*it).second;
for ( size_t i = 0; i < ControlPoints.size(); ++i )
NETGENPlugin_Mesher::RestrictLocalSize( ngMesh, ControlPoints[i].XYZ(), ControlPoints[i].Size() );
}
+ return;
+}
+
+//================================================================================
+/*!
+ * \brief Restrict local size to achieve a required _chordalError
+ */
+//================================================================================
+
+void NETGENPlugin_Mesher::SetLocalSizeForChordalError( netgen::OCCGeometry& occgeo,
+ netgen::Mesh& ngMesh)
+{
+ if ( _chordalError <= 0. )
+ return;
+
+ TopLoc_Location loc;
+ BRepLProp_SLProps surfProp( 2, 1e-6 );
+ const double sizeCoef = 0.95;
+
+ // find non-planar FACEs with non-constant curvature
+ std::vector<int> fInd;
+ for ( int i = 1; i <= occgeo.fmap.Extent(); ++i )
+ {
+ const TopoDS_Face& face = TopoDS::Face( occgeo.fmap( i ));
+ BRepAdaptor_Surface surfAd( face, false );
+ switch ( surfAd.GetType() )
+ {
+ case GeomAbs_Plane:
+ continue;
+ case GeomAbs_Cylinder:
+ case GeomAbs_Sphere:
+ case GeomAbs_Torus: // constant curvature
+ {
+ surfProp.SetSurface( surfAd );
+ surfProp.SetParameters( 0, 0 );
+ double maxCurv = Max( Abs( surfProp.MaxCurvature()), Abs( surfProp.MinCurvature() ));
+ double size = elemSizeForChordalError( _chordalError, 1 / maxCurv );
+ occgeo.SetFaceMaxH( i, size * sizeCoef );
+ // limit size one edges
+ TopTools_MapOfShape edgeMap;
+ for ( TopExp_Explorer eExp( face, TopAbs_EDGE ); eExp.More(); eExp.Next() )
+ if ( edgeMap.Add( eExp.Current() ))
+ setLocalSize( TopoDS::Edge( eExp.Current() ), size, ngMesh, /*overrideMinH=*/false );
+ break;
+ }
+ default:
+ Handle(Geom_Surface) surf = BRep_Tool::Surface( face, loc );
+ if ( GeomLib_IsPlanarSurface( surf ).IsPlanar() )
+ continue;
+ fInd.push_back( i );
+ }
+ }
+ // set local size
+ if ( !fInd.empty() )
+ {
+ BRep_Builder b;
+ TopoDS_Compound allFacesComp;
+ b.MakeCompound( allFacesComp );
+ for ( size_t i = 0; i < fInd.size(); ++i )
+ b.Add( allFacesComp, occgeo.fmap( fInd[i] ));
+
+ // copy the shape to avoid spoiling its triangulation
+ TopoDS_Shape allFacesCompCopy = BRepBuilderAPI_Copy( allFacesComp );
+
+ // create triangulation with desired chordal error
+ BRepMesh_IncrementalMesh( allFacesCompCopy,
+ _chordalError,
+ /*isRelative = */Standard_False,
+ /*theAngDeflection = */ 0.5,
+ /*isInParallel = */Standard_True);
+
+ // loop on FACEs
+ for ( TopExp_Explorer fExp( allFacesCompCopy, TopAbs_FACE ); fExp.More(); fExp.Next() )
+ {
+ const TopoDS_Face& face = TopoDS::Face( fExp.Current() );
+ Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation ( face, loc );
+ if ( triangulation.IsNull() ) continue;
+
+ BRepAdaptor_Surface surf( face, false );
+ surfProp.SetSurface( surf );
+
+ gp_XY uv[3];
+ gp_XYZ p[3];
+ double size[3];
+ for ( int i = 1; i <= triangulation->NbTriangles(); ++i )
+ {
+ Standard_Integer n1,n2,n3;
+ triangulation->Triangles()(i).Get( n1,n2,n3 );
+ p [0] = triangulation->Nodes()(n1).Transformed(loc).XYZ();
+ p [1] = triangulation->Nodes()(n2).Transformed(loc).XYZ();
+ p [2] = triangulation->Nodes()(n3).Transformed(loc).XYZ();
+ uv[0] = triangulation->UVNodes()(n1).XY();
+ uv[1] = triangulation->UVNodes()(n2).XY();
+ uv[2] = triangulation->UVNodes()(n3).XY();
+ surfProp.SetParameters( uv[0].X(), uv[0].Y() );
+ if ( !surfProp.IsCurvatureDefined() )
+ break;
+
+ for ( int n = 0; n < 3; ++n ) // get size at triangle nodes
+ {
+ surfProp.SetParameters( uv[n].X(), uv[n].Y() );
+ double maxCurv = Max( Abs( surfProp.MaxCurvature()), Abs( surfProp.MinCurvature() ));
+ size[n] = elemSizeForChordalError( _chordalError, 1 / maxCurv );
+ }
+ for ( int n1 = 0; n1 < 3; ++n1 ) // limit size along each triangle edge
+ {
+ int n2 = ( n1 + 1 ) % 3;
+ double minSize = size[n1], maxSize = size[n2];
+ if ( size[n1] > size[n2] )
+ minSize = size[n2], maxSize = size[n1];
+
+ if ( maxSize / minSize < 1.2 ) // netgen ignores size difference < 1.2
+ {
+ ngMesh.RestrictLocalHLine ( netgen::Point3d( p[n1].X(), p[n1].Y(), p[n1].Z() ),
+ netgen::Point3d( p[n2].X(), p[n2].Y(), p[n2].Z() ),
+ sizeCoef * minSize );
+ }
+ else
+ {
+ gp_XY uvVec( uv[n2] - uv[n1] );
+ double len = ( p[n1] - p[n2] ).Modulus();
+ int nb = int( len / minSize ) + 1;
+ for ( int j = 0; j <= nb; ++j )
+ {
+ double r = double( j ) / nb;
+ gp_XY uvj = uv[n1] + r * uvVec;
+
+ surfProp.SetParameters( uvj.X(), uvj.Y() );
+ double maxCurv = Max( Abs( surfProp.MaxCurvature()), Abs( surfProp.MinCurvature() ));
+ double h = elemSizeForChordalError( _chordalError, 1 / maxCurv );
+
+ const gp_Pnt& pj = surfProp.Value();
+ netgen::Point3d ngP( pj.X(), pj.Y(), pj.Z());
+ ngMesh.RestrictLocalH( ngP, h * sizeCoef );
+ }
+ }
+ }
+ }
+ }
+ }
}
//================================================================================
netgen::Segment& prevSeg = ngMesh.LineSegment( i-1 );
if ( seg[0] == prevSeg[1] && seg[1] == prevSeg[0] )
{
- cout << "Segment: " << seg.edgenr << endl << "\tis REVRESE of the previous one" << endl;
+ cout << "Segment: " << seg.edgenr << endl << "\tis REVERSE of the previous one" << endl;
continue;
}
}
SMESHDS_Mesh* meshDS = sMesh.GetMeshDS();
// quadHelper is used for either
- // 1) making quadratic elements when a lower dimention mesh is loaded
- // to SMESH before convertion to quadratic by NETGEN
+ // 1) making quadratic elements when a lower dimension mesh is loaded
+ // to SMESH before conversion to quadratic by NETGEN
// 2) sewing of quadratic elements with quadratic elements of sub-meshes
if ( quadHelper && !quadHelper->GetIsQuadratic() && quadHelper->GetTLinkNodeMap().empty() )
quadHelper = 0;
{
// Local size on shapes
SetLocalSize( occgeo, *_ngMesh );
+ SetLocalSizeForChordalError( occgeo, *_ngMesh );
}
// Precompute internal edges (issue 0020676) in order to
sm->GetComputeError().reset( new SMESH_ComputeError( COMPERR_ALGO_FAILED ));
return false;
}
- if ( _simpleHyp )
- {
- // Pass 1D simple parameters to NETGEN
- // --------------------------------
- int nbSeg = _simpleHyp->GetNumberOfSegments();
- double segSize = _simpleHyp->GetLocalLength();
- for ( int iE = 1; iE <= occgeo.emap.Extent(); ++iE )
- {
- const TopoDS_Edge& e = TopoDS::Edge( occgeo.emap(iE));
- if ( nbSeg )
- segSize = SMESH_Algo::EdgeLength( e ) / ( nbSeg - 0.4 );
- setLocalSize( e, segSize, *ngMesh );
- }
- }
- else // if ( ! _simpleHyp )
- {
- // Local size on shapes
- SetLocalSize( occgeo, *ngMesh );
- }
+ // if ( _simpleHyp )
+ // {
+ // // Pass 1D simple parameters to NETGEN
+ // // --------------------------------
+ // int nbSeg = _simpleHyp->GetNumberOfSegments();
+ // double segSize = _simpleHyp->GetLocalLength();
+ // for ( int iE = 1; iE <= occgeo.emap.Extent(); ++iE )
+ // {
+ // const TopoDS_Edge& e = TopoDS::Edge( occgeo.emap(iE));
+ // if ( nbSeg )
+ // segSize = SMESH_Algo::EdgeLength( e ) / ( nbSeg - 0.4 );
+ // setLocalSize( e, segSize, *ngMesh );
+ // }
+ // }
+ // else // if ( ! _simpleHyp )
+ // {
+ // // Local size on shapes
+ // SetLocalSize( occgeo, *ngMesh );
+ // }
// calculate total nb of segments and length of edges
double fullLen = 0.0;
int fullNbSeg = 0;
void SetParameters(const NETGENPlugin_SimpleHypothesis_2D* hyp);
void SetParameters(const StdMeshers_ViscousLayers* hyp );
void SetViscousLayers2DAssigned(bool isAssigned) { _isViscousLayers2D = isAssigned; }
+
+ void SetLocalSizeForChordalError( netgen::OCCGeometry& occgeo, netgen::Mesh& ngMesh );
static void SetLocalSize( netgen::OCCGeometry& occgeo, netgen::Mesh& ngMesh );
bool Compute();
bool _optimize;
int _fineness;
bool _isViscousLayers2D;
+ double _chordalError;
netgen::Mesh* _ngMesh;
netgen::OCCGeometry* _occgeom;
// a pointer to NETGENPlugin_Mesher* field of the holder, that will be
// nullified at destruction of this
- NETGENPlugin_Mesher ** _ptrToMe;
+ NETGENPlugin_Mesher ** _ptrToMe;
};
//=============================================================================
// set local size defined on shapes
aMesher.SetLocalSize( occgeoComm, *ngMeshes[0] );
+ aMesher.SetLocalSizeForChordalError( occgeoComm, *ngMeshes[0] );
try {
ngMeshes[0]->LoadLocalMeshSize( mparam.meshsizefilename );
} catch (NgException & ex) {
bb.Increase (bb.Diam()/10);
ngMesh->SetLocalH (bb.PMin(), bb.PMax(), mparam.grading);
aMesher.SetLocalSize( occgeom, *ngMesh );
+ aMesher.SetLocalSizeForChordalError( occgeoComm, *ngMesh );
try {
ngMesh->LoadLocalMeshSize( mparam.meshsizefilename );
} catch (NgException & ex) {
// $Header$
//
#include "NETGENPlugin_NETGEN_2D_i.hxx"
+#include "NETGENPlugin_Remesher_2D.hxx"
#include "SMESH_Gen.hxx"
-#include "Utils_CorbaException.hxx"
-#include "utilities.h"
-
-using namespace std;
-
//=============================================================================
/*!
* NETGENPlugin_NETGEN_2D_i::NETGENPlugin_NETGEN_2D_i
{
return ( ::NETGENPlugin_NETGEN_2D* )myBaseImpl;
}
+
+
+
+//=============================================================================
+/*!
+ * NETGENPlugin_Remesher_2D_i::NETGENPlugin_Remesher_2D_i
+ *
+ * Constructor
+ */
+//=============================================================================
+
+NETGENPlugin_Remesher_2D_i::NETGENPlugin_Remesher_2D_i( PortableServer::POA_ptr thePOA,
+ ::SMESH_Gen* theGenImpl )
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA ),
+ SMESH_Algo_i( thePOA ),
+ SMESH_2D_Algo_i( thePOA )
+{
+ myBaseImpl = new ::NETGENPlugin_Remesher_2D( theGenImpl->GetANewId(),
+ theGenImpl );
+}
+
+//=============================================================================
+/*!
+ * NETGENPlugin_Remesher_2D_i::~NETGENPlugin_Remesher_2D_i
+ *
+ * Destructor
+ */
+//=============================================================================
+
+NETGENPlugin_Remesher_2D_i::~NETGENPlugin_Remesher_2D_i()
+{
+}
#include "NETGENPlugin_NETGEN_2D.hxx"
// ======================================================
-// NETGEN 3d algorithm
+// NETGEN 1D2D algorithm
// ======================================================
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_2D_i:
public virtual POA_NETGENPlugin::NETGENPlugin_NETGEN_2D,
::NETGENPlugin_NETGEN_2D* GetImpl();
};
+// ======================================================
+// NETGEN 2D remesher algorithm
+// ======================================================
+class NETGENPLUGIN_EXPORT NETGENPlugin_Remesher_2D_i:
+ public virtual POA_NETGENPlugin::NETGENPlugin_Remesher_2D,
+ public virtual SMESH_2D_Algo_i
+{
+public:
+ // Constructor
+ NETGENPlugin_Remesher_2D_i( PortableServer::POA_ptr thePOA,
+ ::SMESH_Gen* theGenImpl );
+ // Destructor
+ virtual ~NETGENPlugin_Remesher_2D_i();
+
+ // Get implementation
+ //::NETGENPlugin_NETGEN_2D* GetImpl();
+};
+
#endif
--- /dev/null
+// Copyright (C) 2007-2016 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, or (at your option) any later version.
+//
+// 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
+//
+// File : NETGENPlugin_Remesher_2D.cxx
+// Created : Thu Sep 21 16:48:46 2017
+// Author : Edward AGAPOV (eap)
+//
+
+#include "NETGENPlugin_Remesher_2D.hxx"
+
+#include "NETGENPlugin_Mesher.hxx"
+#include "NETGENPlugin_Hypothesis_2D.hxx"
+
+#include <SMDS_SetIterator.hxx>
+#include <SMESHDS_Mesh.hxx>
+#include <SMESH_ControlsDef.hxx>
+#include <SMESH_Gen.hxx>
+#include <SMESH_MeshAlgos.hxx>
+#include <SMESH_MesherHelper.hxx>
+#include <SMESH_subMesh.hxx>
+
+#include <Bnd_B3d.hxx>
+#include <Precision.hxx>
+
+#include <occgeom.hpp>
+#include <meshing.hpp>
+#include <stlgeom.hpp>
+//#include <stltool.hxx>
+
+#include <boost/container/flat_set.hpp>
+
+using namespace nglib;
+
+// namespace netgen
+// {
+// #if defined(NETGEN_V5) && defined(WIN32)
+// DLL_HEADER
+// #endif
+// extern STLParameters stlparam;
+// }
+
+namespace
+{
+ //=============================================================================
+ /*!
+ * \brief Fill holes in the mesh, since netgen can remesh only a closed shell mesh.
+ * At destruction, remove triangles filling the holes
+ */
+ class HoleFiller
+ {
+ public:
+ HoleFiller( SMESH_Mesh& meshDS );
+ ~HoleFiller();
+ void AddHoleBorders( Ng_STL_Geometry * ngStlGeo );
+ void KeepHole() { myHole.clear(); myCapElems.clear(); }
+ void ClearCapElements() { myCapElems.clear(); }
+
+ private:
+ SMESHDS_Mesh* myMeshDS;
+ std::vector< std::vector< gp_XYZ > > myHole; // initial border nodes
+ std::vector< gp_XYZ > myInHolePos; // position inside each hole
+ std::vector< const SMDS_MeshElement* > myCapElems; // elements closing holes
+ };
+
+ //================================================================================
+ /*!
+ * \brief Fill holes in the mesh
+ */
+ //================================================================================
+
+ HoleFiller::HoleFiller( SMESH_Mesh& theMesh ):
+ myMeshDS( theMesh.GetMeshDS() )
+ {
+ SMESH_MeshEditor editor( &theMesh );
+ {
+ // // merge nodes
+ // const double tol = Max( 0.1 * netgen::mparam.minh, Precision::Confusion() );
+ // TIDSortedNodeSet allNodes;
+ // SMESH_MeshEditor::TListOfListOfNodes equalNodes;
+ // editor.FindCoincidentNodes( allNodes, tol, equalNodes, true );
+ // editor.MergeNodes( equalNodes, /*noHoles=*/false );
+ }
+
+ // find holes
+ SMESH_MeshAlgos::TFreeBorderVec holes;
+ bool isManifold = true, isGoodOri = true;
+ SMESH_MeshAlgos::FindFreeBorders( *myMeshDS, holes, /*closedOnly=*/true,
+ &isManifold, &isGoodOri );
+
+ if ( !isManifold )
+ {
+ // set bad faces into a compute error
+ const char* text = "Non-manifold mesh. Only manifold mesh can be re-meshed";
+ SMESH_ComputeErrorPtr error = SMESH_ComputeError::New( COMPERR_BAD_INPUT_MESH, text );
+ SMESH::Controls::MultiConnection2D fun;
+ fun.SetMesh( myMeshDS );
+ SMDS_ElemIteratorPtr fIt = myMeshDS->elementsIterator( SMDSAbs_Face );
+ while ( fIt->more() )
+ {
+ const SMDS_MeshElement* f = fIt->next();
+ if ( fun.GetValue( f->GetID() ) > 2 )
+ error->myBadElements.push_back( f );
+ }
+ theMesh.GetSubMesh( theMesh.GetShapeToMesh() )->GetComputeError() = error;
+ throw SALOME_Exception( text );
+ }
+
+ // don't want to sew coincident borders
+ if ( !holes.empty() )
+ {
+ // define tolerance
+ double tol, len, sumLen = 0, minLen = 1e100;
+ int nbSeg = 0;
+ for ( size_t i = 0; i < holes.size(); ++i )
+ {
+ nbSeg += holes[i].size();
+ SMESH_NodeXYZ p1 = holes[i][0];
+ for ( size_t iP = 1; iP < holes[i].size(); ++iP )
+ {
+ SMESH_NodeXYZ p2 = holes[i][iP];
+ len = ( p1 - p2 ).Modulus();
+ sumLen += len;
+ minLen = Min( minLen, len );
+ p1 = p2;
+ }
+ }
+ double avgLen = sumLen / nbSeg;
+ if ( minLen > 1e-5 * avgLen )
+ tol = 0.1 * minLen; // minLen is not degenerate
+ else
+ tol = 0.1 * avgLen;
+
+ SMESH_MeshAlgos::CoincidentFreeBorders freeBords;
+ SMESH_MeshAlgos::FindCoincidentFreeBorders( *myMeshDS, tol, freeBords );
+ if ( !freeBords._coincidentGroups.empty() )
+ {
+ const char* text = "Can't re-meshed a mesh with coincident free edges";
+ SMESH_ComputeErrorPtr error = SMESH_ComputeError::New( COMPERR_BAD_INPUT_MESH, text );
+ for ( size_t i = 0; i < freeBords._borders.size(); ++i )
+ error->myBadElements.insert( error->myBadElements.end(),
+ freeBords._borders[i].begin(),
+ freeBords._borders[i].end() );
+ theMesh.GetSubMesh( theMesh.GetShapeToMesh() )->GetComputeError() = error;
+ throw SALOME_Exception( text );
+ }
+ }
+
+ // fill holes
+ myHole.resize( holes.size() );
+ myInHolePos.resize( holes.size() );
+ std::vector<const SMDS_MeshElement*> newFaces;
+ for ( size_t i = 0; i < holes.size(); ++i )
+ {
+ newFaces.clear();
+ SMESH_MeshAlgos::FillHole( holes[i], *myMeshDS, newFaces );
+
+ // keep data to be able to remove hole filling faces after remeshing
+ if ( !newFaces.empty() )
+ {
+ myHole[i].resize( holes[i].size() );
+ for ( size_t iP = 0; iP < holes[i].size(); ++iP )
+ myHole[i][iP] = SMESH_NodeXYZ( holes[i][iP] );
+
+ myInHolePos[i] = ( SMESH_NodeXYZ( newFaces[0]->GetNode(0)) +
+ SMESH_NodeXYZ( newFaces[0]->GetNode(1)) +
+ SMESH_NodeXYZ( newFaces[0]->GetNode(2)) ) / 3.;
+ myCapElems.insert( myCapElems.end(), newFaces.begin(), newFaces.end() );
+ // unmark to be able to remove them if meshing is canceled
+ // for ( size_t iF = 0; iF < newFaces.size(); ++iF )
+ // newFaces[iF]->setIsMarked( false );
+ }
+ }
+ // fix orientation
+ if ( !isGoodOri )
+ {
+ SMDS_ElemIteratorPtr fIt = myMeshDS->elementsIterator( SMDSAbs_Face );
+ while ( fIt->more() )
+ {
+ const SMDS_MeshElement* f = fIt->next();
+ gp_XYZ normal;
+ if ( SMESH_MeshAlgos::FaceNormal( f, normal ))
+ {
+ TIDSortedElemSet allFaces;
+ editor.Reorient2D( allFaces, normal, f );
+ break;
+ }
+ }
+ }
+ }
+ //================================================================================
+ /*!
+ * \brief Add hole borders to be kept in a new mesh
+ */
+ //================================================================================
+
+ void HoleFiller::AddHoleBorders( Ng_STL_Geometry * ngStlGeo )
+ {
+ for ( size_t i = 0; i < myHole.size(); ++i )
+ for ( size_t iP = 1; iP < myHole[i].size(); ++iP )
+ {
+ Ng_STL_AddEdge( ngStlGeo,
+ myHole[i][iP-1].ChangeData(),
+ myHole[i][iP-0].ChangeData() );
+ }
+ }
+ //================================================================================
+ /*!
+ * \brief Remove triangles filling the holes
+ */
+ //================================================================================
+
+ HoleFiller::~HoleFiller()
+ {
+ if ( myMeshDS->NbNodes() < 3 )
+ return;
+
+ if ( !myCapElems.empty() ) // old mesh not removed; simply remove myCapElems
+ {
+ for ( size_t i = 0; i < myCapElems.size(); ++i )
+ myMeshDS->RemoveFreeElement( myCapElems[i], /*sm=*/0 );
+ return;
+ }
+
+ bool hasOrphanNodes = true;
+
+ const double tol = Max( 1e-3 * netgen::mparam.minh, Precision::Confusion() );
+
+ for ( size_t i = 0; i < myHole.size(); ++i )
+ {
+ std::vector< gp_XYZ >& borderPnt = myHole[i];
+ const gp_XYZ& inHolePos = myInHolePos[i];
+ if ( borderPnt.empty() ) continue;
+ borderPnt.pop_back(); // first point repeated at end
+
+ // mark all nodes located on the hole border
+
+ // new nodeSearcher for each hole, otherwise it contains removed nodes for i > 0
+ SMESHUtils::Deleter< SMESH_NodeSearcher > nodeSearcher;
+ if ( hasOrphanNodes )
+ {
+ std::vector< const SMDS_MeshNode* > sharedNodes;
+ sharedNodes.reserve( myMeshDS->NbNodes() );
+ SMDS_NodeIteratorPtr nIt = myMeshDS->nodesIterator();
+ while ( nIt->more() )
+ {
+ const SMDS_MeshNode* n = nIt->next();
+ if ( n->NbInverseElements() )
+ sharedNodes.push_back( n );
+ }
+ hasOrphanNodes = ((int) sharedNodes.size() < myMeshDS->NbNodes() );
+ SMDS_ElemIteratorPtr elemIt( new SMDS_NodeVectorElemIterator( sharedNodes.begin(),
+ sharedNodes.end() ));
+ nodeSearcher._obj = SMESH_MeshAlgos::GetNodeSearcher( elemIt );
+ }
+ else
+ {
+ nodeSearcher._obj = SMESH_MeshAlgos::GetNodeSearcher( *myMeshDS );
+ }
+
+ std::vector< const SMDS_MeshElement* > edgesToRemove;
+ edgesToRemove.reserve( borderPnt.size() );
+
+ // look for a border point coincident with a node
+ size_t iP = 0;
+ SMESH_NodeXYZ bordNode1;
+ for ( ; iP < borderPnt.size(); ++iP )
+ {
+ bordNode1 = nodeSearcher->FindClosestTo( borderPnt[iP] );
+ if (( bordNode1 - borderPnt[iP] ).SquareModulus() < tol * tol )
+ break;
+ }
+ ++iP;
+ bordNode1._node->setIsMarked( true );
+
+ // find the rest nodes located on the hole border
+ boost::container::flat_set< const SMDS_MeshNode* > checkedNodes;
+ gp_XYZ p1 = bordNode1;
+ for ( size_t j = 0; j < borderPnt.size()+1; ++j, iP = ( iP+1 ) % borderPnt.size() )
+ {
+ // among nodes surrounding bordNode1 find one most close to vec12
+ gp_XYZ vec12 = borderPnt[iP] - p1;
+ bool pntReached = false; // last found node is at iP
+ while ( !pntReached )
+ {
+ const SMDS_MeshNode* bordNode = bordNode1._node;
+ SMDS_ElemIteratorPtr fIt = bordNode->GetInverseElementIterator( SMDSAbs_Face );
+ double minArea = 1e100;
+ checkedNodes.clear();
+ checkedNodes.insert( bordNode );
+ while ( fIt->more() )
+ {
+ const SMDS_MeshElement* f = fIt->next();
+ for ( int iN = 0, nbN = f->NbNodes(); iN < nbN; ++iN )
+ {
+ const SMDS_MeshNode* n = f->GetNode( iN );
+ if ( !checkedNodes.insert( n ).second )
+ continue;
+ SMESH_NodeXYZ pn = n;
+ gp_XYZ vecPN = pn - bordNode1;
+ if ( vecPN * vec12 <= 0 )
+ continue;
+ gp_XYZ vec1N = pn - p1;
+ double a = vec12.CrossSquareMagnitude( vec1N );
+ if ( a < minArea )
+ {
+ bordNode = n;
+ minArea = a;
+ }
+ }
+ if ( minArea < std::numeric_limits<double>::min() )
+ break;
+ }
+ if ( bordNode == bordNode1._node )
+ return; // bug in the loop above
+
+ SMESH_NodeXYZ bordNode2 = bordNode;
+ gp_XYZ vec1N = bordNode2 - p1;
+ double u = ( vec12 * vec1N ) / vec12.SquareModulus(); // param [0,1] of bordNode on vec12
+ if ( u < 1 + tol )
+ {
+ bordNode->setIsMarked( true );
+ //cout << bordNode->GetID() << " ";
+
+ if ( const SMDS_MeshElement* edge = myMeshDS->FindEdge( bordNode1._node, bordNode ))
+ edgesToRemove.push_back( edge );
+ else
+ edgesToRemove.push_back( myMeshDS->AddEdge( bordNode1._node, bordNode ));
+ edgesToRemove.back()->setIsMarked( true );
+
+ if ( minArea > std::numeric_limits<double>::min() &&
+ minArea / vec12.SquareModulus() > tol * tol )
+ {
+ // node is far from the border, move it
+ gp_XYZ p = p1 + u * vec12;
+ myMeshDS->MoveNode( bordNode, p.X(), p.Y(), p.Z() );
+ }
+ bordNode1 = bordNode2;
+ }
+ //else -- there must be another border point between bordNode1 and bordNode
+ pntReached = ( u > 1 - tol );
+ }
+ p1 = borderPnt[iP];
+
+ }
+ //cout << endl << endl;
+
+ // remove all faces starting from inHolePos
+
+ // get a starting face
+ std::vector< const SMDS_MeshNode* > nodesToRemove;
+ std::vector< const SMDS_MeshElement* > facesToRemove;
+ const SMDS_MeshNode* inHoleNode = nodeSearcher->FindClosestTo( inHolePos );
+ if ( inHoleNode && ! inHoleNode->isMarked() )
+ {
+ SMDS_ElemIteratorPtr fIt = inHoleNode->GetInverseElementIterator( SMDSAbs_Face );
+ while ( fIt->more() )
+ facesToRemove.push_back( fIt->next() );
+ }
+ else
+ {
+ SMESHUtils::Deleter< SMESH_ElementSearcher > faceSearcher
+ ( SMESH_MeshAlgos::GetElementSearcher( *myMeshDS ));
+ if ( const SMDS_MeshElement* f = faceSearcher->FindClosestTo( inHolePos, SMDSAbs_Face ))
+ facesToRemove.push_back( f );
+ else
+ continue;
+ }
+ for ( size_t iF = 0; iF < facesToRemove.size(); ++iF )
+ facesToRemove[iF]->setIsMarked( true );
+
+ // remove faces and nodes
+ TIDSortedElemSet elemSet, avoidSet;
+ const SMDS_MeshElement* e;
+ while ( !facesToRemove.empty() )
+ {
+ const SMDS_MeshElement* inHoleFace = facesToRemove.back();
+ facesToRemove.pop_back();
+
+ // add adjacent faces into facesToRemove
+ for ( int iN = 0, nbN = inHoleFace->NbNodes(); iN < nbN; ++iN )
+ {
+ const SMDS_MeshNode* n1 = inHoleFace->GetNode( iN );
+ if ( !n1->isMarked() )
+ {
+ SMDS_ElemIteratorPtr eIt = n1->GetInverseElementIterator();
+ while ( eIt->more() )
+ {
+ e = eIt->next();
+ if ( e->GetType() == SMDSAbs_Face )
+ {
+ if ( !e->isMarked() )
+ facesToRemove.push_back( e );
+ e->setIsMarked( true );
+ }
+ else if ( e->GetType() == SMDSAbs_Edge )
+ {
+ myMeshDS->RemoveFreeElement( e, 0, /*fromGroups=*/false );
+ }
+ }
+ if ( n1->NbInverseElements() == 1 )
+ nodesToRemove.push_back( n1 );
+ }
+ else
+ {
+ const SMDS_MeshNode* n2 = inHoleFace->GetNodeWrap( iN+1 );
+ if (( n2->isMarked() ) &&
+ ( !(e = myMeshDS->FindEdge( n1, n2 )) || !e->isMarked() )) // n1-n2 not hole border
+ {
+ if ( e ) // remove edge
+ myMeshDS->RemoveFreeElement( e, 0, /*fromGroups=*/false );
+ avoidSet.clear();
+ avoidSet.insert( inHoleFace );
+ if (( e = SMESH_MeshAlgos::FindFaceInSet( n1, n2, elemSet, avoidSet )))
+ {
+ if ( !e->isMarked() )
+ facesToRemove.push_back( e );
+ e->setIsMarked( true );
+ }
+ }
+ }
+ }
+ myMeshDS->RemoveFreeElement( inHoleFace, 0, /*fromGroups=*/false );
+
+ for ( size_t iN = 0; iN < nodesToRemove.size(); ++iN )
+ myMeshDS->RemoveFreeNode( nodesToRemove[iN], 0, /*fromGroups=*/false );
+ nodesToRemove.clear();
+ }
+
+ // remove edges from the hole border
+ // for ( size_t iE = 0; iE < edgesToRemove.size(); ++iE )
+ // myMeshDS->RemoveFreeElement( edgesToRemove[iE], 0, /*fromGroups=*/false );
+
+ } // loop on holes
+
+ return;
+ } // ~HoleFiller()
+
+} // namespace
+
+//=============================================================================
+/*!
+ * Constructor
+ */
+//=============================================================================
+
+NETGENPlugin_Remesher_2D::NETGENPlugin_Remesher_2D(int hypId, SMESH_Gen* gen)
+ : SMESH_2D_Algo(hypId, gen)
+{
+ _name = "NETGEN_Remesher_2D";
+ _shapeType = (1 << TopAbs_FACE); // 1 bit /shape type
+ _compatibleHypothesis.push_back("NETGEN_RemesherParameters_2D");
+ _requireShape = false;
+
+ _hypothesis = 0;
+}
+
+//=============================================================================
+/*!
+ * Check assigned hypotheses
+ */
+//=============================================================================
+
+bool NETGENPlugin_Remesher_2D::CheckHypothesis (SMESH_Mesh& theMesh,
+ const TopoDS_Shape& theShape,
+ Hypothesis_Status& theStatus)
+{
+ _hypothesis = 0;
+
+ // can work with no hypothesis
+ theStatus = SMESH_Hypothesis::HYP_OK;
+
+ const list<const SMESHDS_Hypothesis*>& hyps =
+ GetUsedHypothesis( theMesh, theShape, /*skipAux=*/true );
+
+ switch ( hyps.size() ) {
+ case 0:
+ break;
+ case 1:
+ _hypothesis = hyps.front();
+ break;
+ default:
+ theStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
+ }
+
+ return theStatus == SMESH_Hypothesis::HYP_OK;
+}
+
+//=============================================================================
+/*!
+ * Compute mesh on an input mesh
+ */
+//=============================================================================
+
+bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
+ SMESH_MesherHelper* theHelper)
+{
+ if ( theMesh.NbFaces() == 0 )
+ return !error( COMPERR_WARNING, "No faces in input mesh");
+
+ NETGENPlugin_Mesher mesher( &theMesh, theMesh.GetShapeToMesh(), /*isVol=*/false);
+ NETGENPlugin_NetgenLibWrapper ngLib;
+ netgen::Mesh * ngMesh = (netgen::Mesh*) ngLib._ngMesh;
+ Ng_STL_Geometry * ngStlGeo = Ng_STL_NewGeometry();
+ netgen::STLTopology* stlTopo = (netgen::STLTopology*) ngStlGeo;
+ netgen::multithread.terminate = 0;
+
+ const NETGENPlugin_RemesherHypothesis_2D* hyp =
+ dynamic_cast<const NETGENPlugin_RemesherHypothesis_2D*>( _hypothesis );
+ mesher.SetParameters( hyp );// for holeFiller
+
+ SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
+ HoleFiller holeFiller( theMesh );
+ //theHelper->SetIsQuadratic( theMesh.NbFaces( ORDER_QUADRATIC ));
+
+ // fill ngStlGeo with triangles
+ SMDS_ElemIteratorPtr fIt = meshDS->elementsIterator( SMDSAbs_Face );
+ while ( fIt->more() )
+ {
+ const SMDS_MeshElement* f = fIt->next();
+ SMESH_NodeXYZ n1 = f->GetNode( 0 );
+ SMESH_NodeXYZ n2 = f->GetNode( 1 );
+ SMESH_NodeXYZ n3 = f->GetNode( 2 );
+ Ng_STL_AddTriangle( ngStlGeo,
+ n1.ChangeData(),
+ n2.ChangeData(),
+ n3.ChangeData() );
+ if ( f->NbNodes() > 3 )
+ {
+ n2.Set( f->GetNode( 3 ));
+ Ng_STL_AddTriangle( ngStlGeo,
+ n1.ChangeData(),
+ n3.ChangeData(),
+ n2.ChangeData());
+ }
+ }
+ // add edges
+ holeFiller.AddHoleBorders( ngStlGeo );
+
+ // init stl DS
+ Ng_Result ng_res = Ng_STL_InitSTLGeometry( ngStlGeo );
+ if ( ng_res != NG_OK )
+ {
+#ifdef _DEBUG_
+ holeFiller.KeepHole();
+#endif
+ std::string txt = "Error Initialising the STL Geometry";
+ if ( !stlTopo->GetStatusText().empty() )
+ txt += ". " + stlTopo->GetStatusText();
+ return error( COMPERR_BAD_INPUT_MESH, txt );
+ }
+
+ Ng_Meshing_Parameters ngParams;
+ ng_res = Ng_STL_MakeEdges( ngStlGeo, ngLib._ngMesh, &ngParams );
+ if ( ng_res != NG_OK )
+ return error( "Error in Edge Meshing" );
+
+ // set parameters
+ if ( hyp )
+ {
+ ngParams.maxh = hyp->GetMaxSize();
+ ngParams.minh = hyp->GetMinSize();
+ ngParams.meshsize_filename = (char*) hyp->GetMeshSizeFile().c_str();
+ ngParams.quad_dominated = hyp->GetQuadAllowed();
+ netgen::stlparam.yangle = hyp->GetRidgeAngle();
+ mesher.SetParameters( hyp );
+ }
+ else
+ {
+ double diagSize = Dist( stlTopo->GetBoundingBox().PMin(), stlTopo->GetBoundingBox().PMax());
+ netgen::mparam.maxh = diagSize / GetGen()->GetBoundaryBoxSegmentation();
+ netgen::mparam.minh = netgen::mparam.maxh;
+ }
+
+ double h = netgen::mparam.maxh;
+ ngMesh->SetGlobalH( h );
+ ngMesh->SetMinimalH( netgen::mparam.minh );
+ ngMesh->SetLocalH( stlTopo->GetBoundingBox().PMin() - netgen::Vec3d(h, h, h),
+ stlTopo->GetBoundingBox().PMax() + netgen::Vec3d(h, h, h),
+ netgen::mparam.grading );
+ ngMesh->LoadLocalMeshSize( ngParams.meshsize_filename );
+
+ netgen::OCCGeometry occgeo;
+ mesher.SetLocalSize( occgeo, *ngMesh );
+
+ // meshing
+ try
+ {
+ ng_res = Ng_STL_GenerateSurfaceMesh( ngStlGeo, ngLib._ngMesh, &ngParams );
+ }
+ catch (netgen::NgException & ex)
+ {
+ if ( netgen::multithread.terminate )
+ return false;
+ }
+ if ( ng_res != NG_OK )
+ return error( "Error in Surface Meshing" );
+
+ int nbN = ngMesh->GetNP();
+ int nbE = ngMesh->GetNSeg();
+ int nbF = ngMesh->GetNSE();
+ if ( nbF == 0 )
+ return error( "Error in Surface Meshing" );
+
+ // remove existing mesh
+ holeFiller.ClearCapElements();
+ SMDS_ElemIteratorPtr eIt = meshDS->elementsIterator();
+ while ( eIt->more() )
+ meshDS->RemoveFreeElement( eIt->next(), /*sm=*/0 );
+ SMDS_NodeIteratorPtr nIt = meshDS->nodesIterator();
+ while ( nIt->more() )
+ meshDS->RemoveFreeNode( nIt->next(), /*sm=*/0 );
+
+ // retrieve new mesh
+
+ // add nodes
+ std::vector< const SMDS_MeshNode* > newNodes( nbN+1 );
+ for ( int i = 1; i <= nbN; ++i )
+ {
+ const netgen::MeshPoint& p = ngMesh->Point(i);
+ newNodes[i] = meshDS->AddNode( p(0),p(1),p(2) );
+ }
+
+ // add edges
+ std::vector<const SMDS_MeshNode*> nodes(4);
+ for ( int i = 1; i <= nbE; ++i )
+ {
+ const netgen::Segment& seg = ngMesh->LineSegment(i);
+ nodes.clear();
+ for ( int j = 0; j < 2; ++j )
+ {
+ size_t pind = seg.pnums[j];
+ if ( pind > 0 && pind < newNodes.size() )
+ nodes.push_back( newNodes[ pind ]);
+ else
+ break;
+ }
+ if ( nodes.size() == 2 && !meshDS->FindEdge( nodes[0], nodes[1] ))
+ meshDS->AddEdge( nodes[0], nodes[1] );
+ }
+
+ // add faces
+ for ( int i = 1; i <= nbF; ++i )
+ {
+ const netgen::Element2d& elem = ngMesh->SurfaceElement(i);
+ nodes.clear();
+ for ( int j = 1; j <= elem.GetNP(); ++j )
+ {
+ size_t pind = elem.PNum(j);
+ if ( pind > 0 && pind < newNodes.size() )
+ nodes.push_back( newNodes[ pind ]);
+ else
+ break;
+ }
+ switch( nodes.size() )
+ {
+ case 3: meshDS->AddFace( nodes[0], nodes[1], nodes[2] ); break;
+ case 4: meshDS->AddFace( nodes[0], nodes[1], nodes[2], nodes[3] ); break;
+ }
+ }
+
+ // as we don't assign the new triangles to a shape (the pseudo-shape),
+ // to avoid their removal at hypothesis modification,
+ // we mark the shape as always computed to avoid the error messages
+ // that no elements assigned to the shape
+ theMesh.GetSubMesh( theHelper->GetSubShape() )->SetIsAlwaysComputed( true );
+
+ return true;
+}
+
+//=============================================================================
+/*!
+ * Do not compute mesh on geometry
+ */
+//=============================================================================
+
+bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
+ const TopoDS_Shape& theShape)
+{
+ return false;
+}
+
+//=============================================================================
+/*!
+ * Terminate Compute()
+ */
+//=============================================================================
+
+void NETGENPlugin_Remesher_2D::CancelCompute()
+{
+ SMESH_Algo::CancelCompute();
+ netgen::multithread.terminate = 1;
+}
+
+//================================================================================
+/*!
+ * \brief Return progress of Compute() [0.,1]
+ */
+//================================================================================
+
+double NETGENPlugin_Remesher_2D::GetProgress() const
+{
+ return netgen::multithread.percent / 100.;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool NETGENPlugin_Remesher_2D::Evaluate(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ MapShapeNbElems& aResMap)
+{
+ return false;
+}
--- /dev/null
+// Copyright (C) 2007-2016 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, or (at your option) any later version.
+//
+// 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
+//
+// File : NETGENPlugin_Remesher_2D.hxx
+// Created : Thu Sep 21 16:48:46 2017
+// Author : Edward AGAPOV (eap)
+
+
+#ifndef __NETGENPlugin_Remesher_2D_HXX__
+#define __NETGENPlugin_Remesher_2D_HXX__
+
+#include "NETGENPlugin_Defs.hxx"
+
+#include "SMESH_Algo.hxx"
+#include "SMESH_Mesh.hxx"
+
+class NETGENPLUGIN_EXPORT NETGENPlugin_Remesher_2D: public SMESH_2D_Algo
+{
+ public:
+ NETGENPlugin_Remesher_2D(int hypId, SMESH_Gen* gen);
+
+ virtual bool CheckHypothesis(SMESH_Mesh& theMesh,
+ const TopoDS_Shape& theShape,
+ SMESH_Hypothesis::Hypothesis_Status& theStatus);
+
+ virtual bool Compute(SMESH_Mesh & theMesh, SMESH_MesherHelper* theHelper);
+
+ virtual bool Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape);
+
+ virtual void CancelCompute();
+
+ virtual double GetProgress() const;
+
+
+ virtual bool Evaluate(SMESH_Mesh& theMesh,
+ const TopoDS_Shape& theShape,
+ MapShapeNbElems& theResMap);
+
+ protected:
+
+ const SMESHDS_Hypothesis* _hypothesis;
+};
+
+#endif
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_2D_ONLY_i>;
else if (strcmp(aHypName, "NETGEN_2D3D") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_2D3D_i>;
+ else if (strcmp(aHypName, "NETGEN_Remesher_2D") == 0)
+ aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_Remesher_2D_i>;
// Hypotheses
else if (strcmp(aHypName, "NETGEN_Parameters") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_Hypothesis_i>;
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_SimpleHypothesis_2D_i>;
else if (strcmp(aHypName, "NETGEN_SimpleParameters_3D") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_SimpleHypothesis_3D_i>;
+ else if (strcmp(aHypName, "NETGEN_RemesherParameters_2D") == 0)
+ aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_RemesherHypothesis_2D_i>;
else ;
return aCreator;