Join modifications from V3_2_0_maintainance (V3_2_6pre4 - T32x_16Aug2007_16h00m)

This commit is contained in:
jfa 2007-08-21 08:31:46 +00:00
parent 01732a44e5
commit 577a14ea2a
16 changed files with 1886 additions and 1132 deletions

View File

@ -13,6 +13,7 @@
ORIG_DIR=`pwd`
CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
NETGENPLUGIN_WITH_GUI="yes"
########################################################################
# Test if the KERNEL_ROOT_DIR is set correctly
@ -28,12 +29,26 @@ fi
# echo "failed : KERNEL_SRC variable is not correct !"
# exit
#fi
for option
do
case $option in
-with-ihm | --with-ihm)
NETGENPLUGIN_WITH_GUI="yes"
break;;
-without-ihm | --without-ihm | -with-ihm=no | --with-ihm=no)
NETGENPLUGIN_WITH_GUI="no"
break;;
esac
done
########################################################################
# Test if the GUI_ROOT_DIR is set correctly
if test ! -d "${GUI_ROOT_DIR}"; then
echo "failed : GUI_ROOT_DIR variable is not correct !"
exit
if test ${NETGENPLUGIN_WITH_GUI} = yes; then
if test ! -d "${GUI_ROOT_DIR}"; then
echo "failed : GUI_ROOT_DIR variable is not correct !"
exit
fi
fi
########################################################################
@ -63,6 +78,11 @@ fi
cd ${CONF_DIR}
ABS_CONF_DIR=`pwd`
#######################################################################
# Update configure.ac script: to set NETGENPLUGIN_WITH_GUI variable
sed -e s/NETGENPLUGIN_WITH_GUI=[a-z]*/NETGENPLUGIN_WITH_GUI=${NETGENPLUGIN_WITH_GUI}/g configure.ac > configure.tmp
mv -f configure.tmp configure.ac
mkdir -p salome_adm/unix/config_files
#cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files/* salome_adm/unix/config_files
#cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/pythonbe.py salome_adm/unix
@ -92,12 +112,20 @@ cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/SALOMEconfig.h.in salome_adm/unix
# autom4te.cache (directory)
echo "====================================================== aclocal"
aclocal -I adm_local/unix/config_files \
-I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
-I ${GUI_ROOT_DIR}/adm_local/unix/config_files \
-I ${MED_ROOT_DIR}/adm_local/unix/config_files \
-I ${GEOM_ROOT_DIR}/adm_local/unix/config_files \
-I ${SMESH_ROOT_DIR}/adm_local/unix/config_files || exit 1
if test ${NETGENPLUGIN_WITH_GUI} = yes; then
aclocal -I adm_local/unix/config_files \
-I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
-I ${GUI_ROOT_DIR}/adm_local/unix/config_files \
-I ${MED_ROOT_DIR}/adm_local/unix/config_files \
-I ${GEOM_ROOT_DIR}/adm_local/unix/config_files \
-I ${SMESH_ROOT_DIR}/adm_local/unix/config_files || exit 1
else
aclocal -I adm_local/unix/config_files \
-I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
-I ${MED_ROOT_DIR}/adm_local/unix/config_files \
-I ${GEOM_ROOT_DIR}/adm_local/unix/config_files \
-I ${SMESH_ROOT_DIR}/adm_local/unix/config_files || exit 1
fi
# ____________________________________________________________________
# libtoolize creates some configuration files (ltmain.sh,

View File

@ -223,22 +223,6 @@ AC_SUBST_FILE(CORBA)
corba=make_$ORB
CORBA=adm_local/unix/$corba
echo
echo ---------------------------------------------
echo testing openGL
echo ---------------------------------------------
echo
CHECK_OPENGL
echo
echo ---------------------------------------------
echo testing QT
echo ---------------------------------------------
echo
CHECK_QT
echo
echo ---------------------------------------------
echo testing MSG2QM
@ -247,13 +231,55 @@ echo
CHECK_MSG2QM
echo
echo ---------------------------------------------
echo testing VTK
echo ---------------------------------------------
echo
NETGENPLUGIN_WITH_GUI=yes
CHECK_VTK
AM_CONDITIONAL(NETGENPLUGIN_ENABLE_GUI, [test "${NETGENPLUGIN_WITH_GUI}" = "yes"])
if test "${NETGENPLUGIN_WITH_GUI}" = "yes"; then
echo
echo ---------------------------------------------
echo testing openGL
echo ---------------------------------------------
echo
CHECK_OPENGL
echo
echo ---------------------------------------------
echo testing QT
echo ---------------------------------------------
echo
CHECK_QT
echo
echo ---------------------------------------------
echo testing VTK
echo ---------------------------------------------
echo
CHECK_VTK
echo
echo ---------------------------------------------
echo Testing GUI
echo ---------------------------------------------
echo
CHECK_SALOME_GUI
echo
echo ---------------------------------------------
echo Testing full GUI
echo ---------------------------------------------
echo
CHECK_CORBA_IN_GUI
if test "x${CORBA_IN_GUI}" != "xyes"; then
echo "failed : For configure NETGENPLUGIN module necessary full GUI !"
exit
fi
fi
echo
echo ---------------------------------------------
@ -279,26 +305,6 @@ echo
CHECK_HTML_GENERATORS
echo
echo ---------------------------------------------
echo Testing GUI
echo ---------------------------------------------
echo
CHECK_SALOME_GUI
echo
echo ---------------------------------------------
echo Testing full GUI
echo ---------------------------------------------
echo
CHECK_CORBA_IN_GUI
if test "x${CORBA_IN_GUI}" != "xyes"; then
echo "failed : For configure NETGENPLUGIN module necessary full GUI !"
exit
fi
echo
echo ---------------------------------------------
echo Testing Kernel

View File

@ -41,19 +41,28 @@ module NETGENPlugin
};
/*!
* NETGENPlugin_NETGEN_2D: interface of "1D-2D (Netgen)" algorithm
* NETGENPlugin_NETGEN_2D: interface of "Netgen 1D-2D" algorithm
*/
interface NETGENPlugin_NETGEN_2D : SMESH::SMESH_2D_Algo
{
};
/*!
* NETGENPlugin_NETGEN_2D3D: interface of "1D-2D-3D (Netgen)" algorithm
* NETGENPlugin_NETGEN_2D3D: interface of "Netgen 1D-2D-3D" algorithm
*/
interface NETGENPlugin_NETGEN_2D3D : SMESH::SMESH_3D_Algo
{
};
/*!
* NETGENPlugin_NETGEN_2D_ONLY: interface of "Netgen 2D" algorithm,
* generating 2D elements on a geometrical face taking
* into account pre-existing nodes on face boundaries
*/
interface NETGENPlugin_NETGEN_2D_ONLY : SMESH::SMESH_2D_Algo
{
};
/*!
* NETGENPlugin_Hypothesis: interface of "NETGEN parameters" hypothesis
*/

View File

@ -37,6 +37,14 @@
icon-id="mesh_algo_netgen_2d3d.png"
hypos="NETGEN_Parameters"
dim="3"/>
<algorithm type="NETGEN_2D_ONLY"
label-id="Netgen 2D"
icon-id="mesh_algo_netgen_2d.png"
hypos="LengthFromEdges,MaxElementArea"
opt-hypos="QuadranglePreference"
input="EDGE"
output="TRIA,QUAD"
dim="2"/>
</algorithms>
</meshers-group>

View File

@ -27,4 +27,10 @@
include $(top_srcdir)/adm_local/unix/make_common_starter.am
SUBDIRS = NETGEN NETGENPlugin GUI
#SUBDIRS = NETGEN NETGENPlugin GUI
SUBDIRS = NETGEN NETGENPlugin
if NETGENPLUGIN_ENABLE_GUI
SUBDIRS += GUI
endif

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,8 @@ dist_libNETGENEngine_la_SOURCES = \
NETGENPlugin_NETGEN_2D_i.cxx \
NETGENPlugin_NETGEN_2D3D.cxx \
NETGENPlugin_NETGEN_2D3D_i.cxx \
NETGENPlugin_NETGEN_2D_ONLY.cxx \
NETGENPlugin_NETGEN_2D_ONLY_i.cxx \
NETGENPlugin_Hypothesis.cxx \
NETGENPlugin_Hypothesis_i.cxx \
NETGENPlugin_Hypothesis_2D.cxx \

View File

@ -34,4 +34,4 @@
#define NETGENPLUGIN_EXPORT
#endif
#endif
#endif

View File

@ -25,11 +25,13 @@
// Project : SALOME
// $Header$
//=============================================================================
#include "NETGENPlugin_Mesher.hxx"
#include "NETGENPlugin_Hypothesis_2D.hxx"
#include <SMESH_Mesh.hxx>
#include <SMESH_Comment.hxx>
#include <SMESH_ComputeError.hxx>
#include <SMESH_subMesh.hxx>
#include <SMESHDS_Mesh.hxx>
#include <SMDS_MeshElement.hxx>
@ -43,6 +45,9 @@
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <NCollection_Map.hxx>
#include <OSD_Path.hxx>
#include <OSD_File.hxx>
#include <TCollection_AsciiString.hxx>
// Netgen include files
namespace nglib {
@ -153,6 +158,32 @@ Standard_Boolean IsEqual(const Link& aLink1, const Link& aLink2)
aLink1.n1 == aLink2.n2 && aLink1.n2 == aLink2.n1);
}
//================================================================================
/*!
* \brief Initialize netgen::OCCGeometry with OCCT shape
*/
//================================================================================
void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo,
const TopoDS_Shape& shape)
{
occgeo.shape = shape;
occgeo.changed = 1;
occgeo.BuildFMap();
BRepTools::Clean (shape);
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, 0.01, true);
Bnd_Box bb;
BRepBndLib::Add (shape, bb);
double x1,y1,z1,x2,y2,z2;
bb.Get (x1,y1,z1,x2,y2,z2);
MESSAGE("shape bounding box:\n" <<
"(" << x1 << " " << y1 << " " << z1 << ") " <<
"(" << x2 << " " << y2 << " " << z2 << ")");
netgen::Point<3> p1 = netgen::Point<3> (x1,y1,z1);
netgen::Point<3> p2 = netgen::Point<3> (x2,y2,z2);
occgeo.boundingbox = netgen::Box<3> (p1,p2);
}
//=============================================================================
/*!
* Here we are going to use the NETGEN mesher
@ -182,21 +213,7 @@ bool NETGENPlugin_Mesher::Compute()
// -------------------------
netgen::OCCGeometry occgeo;
occgeo.shape = _shape;
occgeo.changed = 1;
occgeo.BuildFMap();
BRepTools::Clean (_shape);
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (_shape, 0.01, true);
Bnd_Box bb;
BRepBndLib::Add (_shape, bb);
double x1,y1,z1,x2,y2,z2;
bb.Get (x1,y1,z1,x2,y2,z2);
MESSAGE("shape bounding box:\n" <<
"(" << x1 << " " << y1 << " " << z1 << ") " <<
"(" << x2 << " " << y2 << " " << z2 << ")");
netgen::Point<3> p1 = netgen::Point<3> (x1,y1,z1);
netgen::Point<3> p2 = netgen::Point<3> (x2,y2,z2);
occgeo.boundingbox = netgen::Box<3> (p1,p2);
PrepareOCCgeometry( occgeo, _shape );
// -------------------------
// Generate the mesh
@ -488,5 +505,25 @@ bool NETGENPlugin_Mesher::Compute()
nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh);
nglib::Ng_Exit();
RemoveTmpFiles();
return error->IsOK();
}
//================================================================================
/*!
* \brief Remove "test.out" and "problemfaces" files in current directory
*/
//================================================================================
void NETGENPlugin_Mesher::RemoveTmpFiles()
{
TCollection_AsciiString str("test.out");
OSD_Path path1( str );
OSD_File file1( path1 );
file1.Remove();
str = "problemfaces";
OSD_Path path2( str );
OSD_File file2( path2 );
file2.Remove();
}

View File

@ -31,12 +31,13 @@
#include "NETGENPlugin_Defs.hxx"
#include "SMESH_ComputeError.hxx"
class SMESH_Mesh;
class SMESHDS_Mesh;
class TopoDS_Shape;
class NETGENPlugin_Hypothesis;
namespace netgen {
class OCCGeometry;
}
/*!
* \brief This class calls the NETGEN mesher of OCC geometry
@ -54,6 +55,11 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
bool Compute();
static void PrepareOCCgeometry(netgen::OCCGeometry& occgeom,
const TopoDS_Shape& shape);
static void RemoveTmpFiles();
private:
SMESH_Mesh* _mesh;
const TopoDS_Shape& _shape;

View File

@ -0,0 +1,436 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS, L3S, LJLL, MENSI
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : NETGENPlugin_NETGEN_2D_ONLY.cxx
// Author : Edward AGAPOV (OCC)
// Project : SALOME
#include "NETGENPlugin_NETGEN_2D_ONLY.hxx"
#include "NETGENPlugin_Mesher.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMESHDS_Mesh.hxx"
#include "SMESH_Comment.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
#include "SMESH_MesherHelper.hxx"
#include "StdMeshers_FaceSide.hxx"
#include "StdMeshers_MaxElementArea.hxx"
#include "StdMeshers_LengthFromEdges.hxx"
#include "StdMeshers_QuadranglePreference.hxx"
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include "utilities.h"
#include <list>
#include <vector>
/*
Netgen include files
*/
namespace nglib {
#include <nglib.h>
}
#define OCCGEOMETRY
#include <occgeom.hpp>
#include <meshing.hpp>
namespace netgen {
extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
extern MeshingParameters mparam;
}
using namespace std;
using namespace netgen;
using namespace nglib;
//=============================================================================
/*!
*
*/
//=============================================================================
NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY(int hypId, int studyId,
SMESH_Gen* gen)
: SMESH_2D_Algo(hypId, studyId, gen)
{
MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY");
_name = "NETGEN_2D_ONLY";
_shapeType = (1 << TopAbs_FACE);// 1 bit /shape type
_compatibleHypothesis.push_back("MaxElementArea");
_compatibleHypothesis.push_back("LengthFromEdges");
_compatibleHypothesis.push_back("QuadranglePreference");
_hypMaxElementArea = 0;
_hypLengthFromEdges = 0;
_hypQuadranglePreference = 0;
}
//=============================================================================
/*!
*
*/
//=============================================================================
NETGENPlugin_NETGEN_2D_ONLY::~NETGENPlugin_NETGEN_2D_ONLY()
{
MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::~NETGENPlugin_NETGEN_2D_ONLY");
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
Hypothesis_Status& aStatus)
{
_hypMaxElementArea = 0;
_hypLengthFromEdges = 0;
_hypQuadranglePreference = 0;
aStatus = HYP_MISSING;
const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape, false);
if (hyps.empty()) return false; // can't work with no hypothesis
list<const SMESHDS_Hypothesis*>::const_iterator ith;
for (ith = hyps.begin(); ith != hyps.end(); ++ith )
{
const SMESHDS_Hypothesis* hyp = (*ith);
string hypName = hyp->GetName();
if ( hypName == "MaxElementArea")
_hypMaxElementArea = static_cast<const StdMeshers_MaxElementArea*> (hyp);
else if ( hypName == "LengthFromEdges" )
_hypLengthFromEdges = static_cast<const StdMeshers_LengthFromEdges*> (hyp);
else if ( hypName == "QuadranglePreference" )
_hypQuadranglePreference = static_cast<const StdMeshers_QuadranglePreference*>(hyp);
else {
aStatus = HYP_INCOMPATIBLE;
return false;
}
}
if ( _hypMaxElementArea && _hypLengthFromEdges ) {
aStatus = HYP_CONCURENT;
return false;
}
if ( _hypMaxElementArea || _hypLengthFromEdges )
aStatus = HYP_OK;
return aStatus == HYP_OK;
}
//================================================================================
/*!
* \brief Fill netgen mesh with segments
* \retval SMESH_ComputeErrorPtr - error description
*/
//================================================================================
static TError AddSegmentsToMesh(netgen::Mesh& ngMesh,
OCCGeometry& geom,
const TSideVector& wires,
SMESH_MesherHelper& helper,
vector< const SMDS_MeshNode* > & nodeVec)
{
// ----------------------------
// Check wires and count nodes
// ----------------------------
int nbNodes = 0;
for ( int iW = 0; iW < wires.size(); ++iW )
{
StdMeshers_FaceSidePtr wire = wires[ iW ];
if ( wire->MissVertexNode() )
return TError
(new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH, "Missing nodes on vertices"));
const vector<UVPtStruct>& uvPtVec = wire->GetUVPtStruct();
if ( uvPtVec.size() != wire->NbPoints() )
return TError
(new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH,
SMESH_Comment("Unexpected nb of points on wire ") << iW
<< ": " << uvPtVec.size()<<" != "<<wire->NbPoints()));
nbNodes += wire->NbSegments();
}
nodeVec.reserve( nbNodes );
// -----------------
// Fill netgen mesh
// -----------------
// netgen::Box<3> bb = geom.GetBoundingBox();
// bb.Increase (bb.Diam()/10);
// ngMesh.SetLocalH (bb.PMin(), bb.PMax(), 0.5); // set grading
const int faceID = 1, solidID = 0;
ngMesh.AddFaceDescriptor (FaceDescriptor(faceID, solidID, solidID, 0));
for ( int iW = 0; iW < wires.size(); ++iW )
{
StdMeshers_FaceSidePtr wire = wires[ iW ];
const vector<UVPtStruct>& uvPtVec = wire->GetUVPtStruct();
int firstPointID = ngMesh.GetNP() + 1;
int edgeID = 1, posID = -2;
for ( int i = 0; i < wire->NbSegments(); ++i ) // loop on segments
{
// Add the first point of a segment
const SMDS_MeshNode * n = uvPtVec[ i ].node;
const int posShapeID = n->GetPosition()->GetShapeId();
// skip nodes on degenerated edges
if ( helper.IsDegenShape( posShapeID ) &&
helper.IsDegenShape( uvPtVec[ i+1 ].node->GetPosition()->GetShapeId() ))
continue;
nodeVec.push_back( n );
MeshPoint mp( Point<3> (n->X(), n->Y(), n->Z()) );
ngMesh.AddPoint ( mp, 1, EDGEPOINT );
// Add the segment
Segment seg;
seg.p1 = ngMesh.GetNP(); // ng node id
seg.p2 = seg.p1 + 1; // ng node id
seg.edgenr = ngMesh.GetNSeg() + 1;// segment id
seg.si = faceID; // = geom.fmap.FindIndex (face);
for ( int iEnd = 0; iEnd < 2; ++iEnd)
{
const UVPtStruct& pnt = uvPtVec[ i + iEnd ];
seg.epgeominfo[ iEnd ].dist = pnt.param; // param on curve
seg.epgeominfo[ iEnd ].u = pnt.u;
seg.epgeominfo[ iEnd ].v = pnt.v;
// find out edge id and node parameter on edge
bool onVertex = ( pnt.node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_VERTEX );
if ( onVertex || posShapeID != posID )
{
// get edge id
double normParam = pnt.normParam;
if ( onVertex )
normParam = 0.5 * ( uvPtVec[ i ].normParam + uvPtVec[ i+1 ].normParam );
const TopoDS_Edge& edge = wire->Edge( wire->EdgeIndex( normParam ));
edgeID = geom.emap.FindIndex( edge );
posID = posShapeID;
if ( onVertex ) // param on curve is different on each of two edges
seg.epgeominfo[ iEnd ].dist = helper.GetNodeU( edge, pnt.node );
}
seg.epgeominfo[ iEnd ].edgenr = edgeID; // = geom.emap.FindIndex(edge);
}
ngMesh.AddSegment (seg);
// cout << "Segment: " << seg.edgenr << endl
// << "\tp1: " << seg.p1 << endl
// << "\tp2: " << seg.p2 << endl
// << "\tp0 param: " << seg.epgeominfo[ 0 ].dist << endl
// << "\tp0 uv: " << seg.epgeominfo[ 0 ].u <<", "<< seg.epgeominfo[ 0 ].v << endl
// << "\tp0 edge: " << seg.epgeominfo[ 0 ].edgenr << endl
// << "\tp1 param: " << seg.epgeominfo[ 1 ].dist << endl
// << "\tp1 uv: " << seg.epgeominfo[ 1 ].u <<", "<< seg.epgeominfo[ 1 ].v << endl
// << "\tp1 edge: " << seg.epgeominfo[ 1 ].edgenr << endl;
}
Segment& seg = ngMesh.LineSegment( ngMesh.GetNSeg() );
seg.p2 = firstPointID;
}
ngMesh.CalcSurfacesOfNode();
return TError();
}
//=============================================================================
/*!
*Here we are going to use the NETGEN mesher
*/
//=============================================================================
bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::Compute()");
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
int faceID = meshDS->ShapeToIndex( aShape );
SMESH_MesherHelper helper(aMesh);
_quadraticMesh = helper.IsQuadraticSubMesh(aShape);
helper.SetElementsOnShape( true );
const bool ignoreMediumNodes = _quadraticMesh;
// ------------------------
// get all edges of a face
// ------------------------
const TopoDS_Face F = TopoDS::Face( aShape.Oriented( TopAbs_FORWARD ));
TError problem;
TSideVector wires = StdMeshers_FaceSide::GetFaceWires( F, aMesh, ignoreMediumNodes, problem );
if ( problem && !problem->IsOK() )
return error( problem );
int nbWires = wires.size();
if ( nbWires == 0 )
return error( "Problem in StdMeshers_FaceSide::GetFaceWires()");
if ( wires[0]->NbSegments() < 3 ) // ex: a circle with 2 segments
return error(COMPERR_BAD_INPUT_MESH,
SMESH_Comment("Too few segments: ")<<wires[0]->NbSegments());
// -------------------------
// Make input netgen mesh
// -------------------------
Ng_Init();
netgen::Mesh * ngMesh = new netgen::Mesh ();
netgen::OCCGeometry occgeo;
NETGENPlugin_Mesher::PrepareOCCgeometry( occgeo, F );
vector< const SMDS_MeshNode* > nodeVec;
problem = AddSegmentsToMesh( *ngMesh, occgeo, wires, helper, nodeVec );
if ( problem && !problem->IsOK() ) {
delete ngMesh; Ng_Exit();
return error( problem );
}
// --------------------
// compute edge length
// --------------------
double edgeLength = 0;
if (_hypLengthFromEdges)
{
int nbSegments = 0;
for ( int iW = 0; iW < nbWires; ++iW )
{
edgeLength += wires[ iW ]->Length();
nbSegments += wires[ iW ]->NbSegments();
}
if ( nbSegments )
edgeLength /= nbSegments;
}
if ( _hypMaxElementArea )
{
double maxArea = _hypMaxElementArea->GetMaxArea();
edgeLength = sqrt(2. * maxArea/sqrt(3.0));
}
if ( edgeLength < DBL_MIN )
edgeLength = occgeo.GetBoundingBox().Diam();
//cout << " edgeLength = " << edgeLength << endl;
netgen::mparam.maxh = edgeLength;
netgen::mparam.quad = _hypQuadranglePreference ? 1 : 0;
//ngMesh->SetGlobalH ( edgeLength );
// -------------------------
// Generate surface mesh
// -------------------------
char *optstr;
int startWith = MESHCONST_MESHSURFACE;
int endWith = MESHCONST_OPTSURFACE;
int err = 1;
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
}
catch (Standard_Failure& ex) {
string comment = ex.DynamicType()->Name();
if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) {
comment += ": ";
comment += ex.GetMessageString();
}
error(COMPERR_OCC_EXCEPTION, comment);
}
catch (NgException exc) {
error( SMESH_Comment("NgException: ") << exc.What() );
}
catch (...) {
error(COMPERR_EXCEPTION,"Exception in netgen::OCCGenerateMesh()");
}
// ----------------------------------------------------
// Fill the SMESHDS with the generated nodes and faces
// ----------------------------------------------------
int nbNodes = ngMesh->GetNP();
int nbFaces = ngMesh->GetNSE();
int nbInputNodes = nodeVec.size();
nodeVec.resize( nbNodes, 0 );
// add nodes
for ( int i = nbInputNodes + 1; i <= nbNodes; ++i )
{
const MeshPoint& ngPoint = ngMesh->Point(i);
SMDS_MeshNode * node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z());
nodeVec[ i-1 ] = node;
}
// create faces
bool reverse = ( aShape.Orientation() == TopAbs_REVERSED );
for ( int i = 1; i <= nbFaces ; ++i )
{
const Element2d& elem = ngMesh->SurfaceElement(i);
vector<const SMDS_MeshNode*> nodes( elem.GetNP() );
for (int j=1; j <= elem.GetNP(); ++j)
{
int pind = elem.PNum(j);
const SMDS_MeshNode* node = nodeVec.at(pind-1);
if ( reverse )
nodes[ nodes.size()-j ] = node;
else
nodes[ j-1 ] = node;
if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE )
{
const PointGeomInfo& pgi = elem.GeomInfoPi(j);
meshDS->SetNodeOnFace((SMDS_MeshNode*)node, faceID, pgi.u, pgi.v);
}
}
SMDS_MeshFace* face = 0;
if ( elem.GetType() == TRIG )
face = helper.AddFace(nodes[0],nodes[1],nodes[2]);
else
face = helper.AddFace(nodes[0],nodes[1],nodes[2],nodes[3]);
}
Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh);
Ng_Exit();
NETGENPlugin_Mesher::RemoveTmpFiles();
return !err;
}

View File

@ -0,0 +1,63 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS, L3S, LJLL, MENSI
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : NETGENPlugin_NETGEN_2D_ONLY.hxx
// Project : SALOME
// Author : Edward AGAPOV (OCC)
#ifndef _NETGENPlugin_NETGEN_2D_ONLY_HXX_
#define _NETGENPlugin_NETGEN_2D_ONLY_HXX_
#include "SMESH_2D_Algo.hxx"
#include "SMESH_Mesh.hxx"
class StdMeshers_MaxElementArea;
class StdMeshers_LengthFromEdges;
class StdMeshers_QuadranglePreference;
//class NETGENPlugin_Hypothesis;
/*!
* \brief Mesher generating 2D elements on a geometrical face taking
* into account pre-existing nodes on face boundaries
*
* Historically, NETGENPlugin_NETGEN_2D is actually 1D-2D, that is why
* the class is named NETGENPlugin_NETGEN_2D_ONLY. Renaming is useless as
* algorithm field "_name" can't be changed
*/
class NETGENPlugin_NETGEN_2D_ONLY: public SMESH_2D_Algo
{
public:
NETGENPlugin_NETGEN_2D_ONLY(int hypId, int studyId, SMESH_Gen* gen);
virtual ~NETGENPlugin_NETGEN_2D_ONLY();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
Hypothesis_Status& aStatus);
virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape);
protected:
const StdMeshers_MaxElementArea* _hypMaxElementArea;
const StdMeshers_LengthFromEdges* _hypLengthFromEdges;
const StdMeshers_QuadranglePreference* _hypQuadranglePreference;
// const NETGENPlugin_Hypothesis* _hypothesis;
};
#endif

View File

@ -0,0 +1,81 @@
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
//
// File : NETGENPlugin_NETGEN_2D_ONLY_i.cxx
// Author : Edward AGAPOV (OCC)
// Module : SMESH
#include "NETGENPlugin_NETGEN_2D_ONLY_i.hxx"
#include "SMESH_Gen.hxx"
#include "utilities.h"
//=============================================================================
/*!
* NETGENPlugin_NETGEN_2D_ONLY_i::NETGENPlugin_NETGEN_2D_ONLY_i
*
* Constructor
*/
//=============================================================================
NETGENPlugin_NETGEN_2D_ONLY_i::NETGENPlugin_NETGEN_2D_ONLY_i( PortableServer::POA_ptr thePOA,
int theStudyId,
::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ),
SMESH_Algo_i( thePOA ),
SMESH_2D_Algo_i( thePOA )
{
MESSAGE( "NETGENPlugin_NETGEN_2D_ONLY_i::NETGENPlugin_NETGEN_2D_ONLY_i" );
myBaseImpl = new ::NETGENPlugin_NETGEN_2D_ONLY( theGenImpl->GetANewId(),
theStudyId,
theGenImpl );
}
//=============================================================================
/*!
* NETGENPlugin_NETGEN_2D_ONLY_i::~NETGENPlugin_NETGEN_2D_ONLY_i
*
* Destructor
*/
//=============================================================================
NETGENPlugin_NETGEN_2D_ONLY_i::~NETGENPlugin_NETGEN_2D_ONLY_i()
{
MESSAGE( "NETGENPlugin_NETGEN_2D_ONLY_i::~NETGENPlugin_NETGEN_2D_ONLY_i" );
}
//=============================================================================
/*!
* NETGENPlugin_NETGEN_2D_ONLY_i::GetImpl
*
* Get implementation
*/
//=============================================================================
::NETGENPlugin_NETGEN_2D_ONLY* NETGENPlugin_NETGEN_2D_ONLY_i::GetImpl()
{
MESSAGE( "NETGENPlugin_NETGEN_2D_ONLY_i::GetImpl" );
return ( ::NETGENPlugin_NETGEN_2D_ONLY* )myBaseImpl;
}

View File

@ -0,0 +1,56 @@
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
//
// File : NETGENPlugin_NETGEN_2D_ONLY_i.cxx
// Author : Edward AGAPOV (OCC)
// Module : SMESH
#ifndef _NETGENPlugin_NETGEN_2D_ONLY_I_HXX_
#define _NETGENPlugin_NETGEN_2D_ONLY_I_HXX_
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm)
#include "SMESH_2D_Algo_i.hxx"
#include "NETGENPlugin_NETGEN_2D_ONLY.hxx"
// ======================================================
// NETGEN 2D algorithm
// ======================================================
class NETGENPlugin_NETGEN_2D_ONLY_i:
public virtual POA_NETGENPlugin::NETGENPlugin_NETGEN_2D_ONLY,
public virtual SMESH_2D_Algo_i
{
public:
// Constructor
NETGENPlugin_NETGEN_2D_ONLY_i( PortableServer::POA_ptr thePOA,
int theStudyId,
::SMESH_Gen* theGenImpl );
// Destructor
virtual ~NETGENPlugin_NETGEN_2D_ONLY_i();
// Get implementation
::NETGENPlugin_NETGEN_2D_ONLY* GetImpl();
};
#endif

View File

@ -28,6 +28,8 @@
//=============================================================================
#include "NETGENPlugin_NETGEN_3D.hxx"
#include "NETGENPlugin_Mesher.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMESHDS_Mesh.hxx"
@ -42,6 +44,9 @@
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
#include "utilities.h"
#include <list>
@ -312,11 +317,17 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
Ng_Result status;
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
status = Ng_GenerateVolumeMesh(Netgen_mesh, &Netgen_param);
}
catch (Standard_Failure& exc) {
error(COMPERR_OCC_EXCEPTION, exc.GetMessageString());
status = NG_VOLUME_FAILURE;
}
catch (...) {
MESSAGE("An exception has been caught during the Volume Mesh Generation ...");
error(dfltErr(), "Exception in Ng_GenerateVolumeMesh()");
error("Exception in Ng_GenerateVolumeMesh()");
status = NG_VOLUME_FAILURE;
}
if ( GetComputeError()->IsOK() ) {
@ -378,5 +389,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
Ng_DeleteMesh(Netgen_mesh);
Ng_Exit();
NETGENPlugin_Mesher::RemoveTmpFiles();
return (status == NG_OK);
}

View File

@ -30,6 +30,7 @@
#include "NETGENPlugin_NETGEN_3D_i.hxx"
#include "NETGENPlugin_NETGEN_2D_i.hxx"
#include "NETGENPlugin_NETGEN_2D_ONLY_i.hxx"
#include "NETGENPlugin_NETGEN_2D3D_i.hxx"
#include "NETGENPlugin_Hypothesis_i.hxx"
#include "NETGENPlugin_Hypothesis_2D_i.hxx"
@ -62,6 +63,8 @@ extern "C"
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_3D_i>;
else if (strcmp(aHypName, "NETGEN_2D") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_2D_i>;
else if (strcmp(aHypName, "NETGEN_2D_ONLY") == 0)
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>;
// Hypotheses