merge from branch BR_SMDS_MEMIMP 29 nov 2010

This commit is contained in:
prascle 2010-11-29 13:20:53 +00:00
parent dd21629a81
commit 8fa039a796
146 changed files with 10692 additions and 1965 deletions

View File

@ -0,0 +1,29 @@
dnl Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
dnl
dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Lesser General Public
dnl License as published by the Free Software Foundation; either
dnl version 2.1 of the License.
dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
dnl
dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
dnl
AC_DEFUN([CHECK_F77],[
AC_PROG_F77
AC_F77_LIBRARY_LDFLAGS
AC_F77_WRAPPERS
])dnl

View File

@ -0,0 +1,187 @@
dnl Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
dnl
dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Lesser General Public
dnl License as published by the Free Software Foundation; either
dnl version 2.1 of the License.
dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
dnl
dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
dnl
AC_DEFUN([CHECK_QWT],[
AC_REQUIRE([CHECK_QT])dnl
AC_REQUIRE([AC_LINKER_OPTIONS])dnl
AC_CHECKING(for qwt)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
qwt_ok=yes
dnl where is qwt ?
AC_ARG_WITH(qwt,
[ --with-qwt=DIR directory path to QWT installation ],
[QWTHOME="$withval"
AC_MSG_RESULT("select $withval as path to QWT")
])
AC_ARG_WITH(qwt_inc,
[ --with-qwt_inc=DIR directory path to QWT includes ],
[QWT_INCDIR="$withval"
AC_MSG_RESULT("select $withval as path to QWT includes")
])
libqwt_name=qwt
if test -z $QWTHOME; then
AC_MSG_RESULT(QWTHOME not defined)
AC_MSG_NOTICE(Trying native Qwt...)
exist_ok=no
if test "x$exist_ok" = "xno"; then
for d in /usr /usr/local ; do
for extension in qwt-qt4 qwt; do
AC_CHECK_FILE(${d}/lib${LIB_LOCATION_SUFFIX}/lib${extension}.so,exist_ok=yes,exist_ok=no)
if test "x$exist_ok" = "xyes"; then
QWTHOME=$d
AC_MSG_RESULT(lib${extension}.so detected in $d/lib)
libqwt_name=${extension}
dnl break, libqwt-qt4.so is choosen before libqwt.so since it is surely the Qt4 version.
break
fi
done
if test "x$exist_ok" = "xyes"; then
break
fi
done
fi
if test "x$exist_ok" = "xno"; then
for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do
if test -f $d/libqwt.so ; then
AC_MSG_RESULT(libqwt.so detected in $d)
QWTHOME=$d
QWTHOME=`echo ${QWTHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
exist_ok=yes
break
fi
done
fi
if test "x$exist_ok" = "xyes"; then
if test -z $QWT_INCDIR; then
QWT_INCDIR=$QWTHOME"/include/qwt-qt4"
if test ! -f $QWT_INCDIR/qwt.h ; then
QWT_INCDIR=/usr/include/qwt
fi
if test ! -f $QWT_INCDIR/qwt.h ; then
QWT_INCDIR=$QWTHOME"/include"
fi
if test ! -f $QWT_INCDIR/qwt.h ; then
QWT_INCDIR=/usr/lib/qt4/include/qwt
fi
if test ! -f $QWT_INCDIR/qwt.h ; then
QWT_INCDIR=/usr/include/qwt-qt4
fi
fi
else
qwt_ok=no
fi
else
AC_MSG_NOTICE(Trying Qwt from $QWTHOME ...)
if test -z $QWT_INCDIR; then
QWT_INCDIR="$QWTHOME/include"
fi
fi
if test "x$qwt_ok" = xno -o ! -d "$QWTHOME" ; then
AC_MSG_RESULT(no)
AC_MSG_WARN(qwt not found)
qwt_ok=no
else
CPPFLAGS_old=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $QT_INCLUDES -I$QWT_INCDIR"
AC_CHECK_HEADER(qwt.h,qwt_ok=yes,qwt_ok=no)
CPPFLAGS=$CPPFLAGS_old
AC_MSG_CHECKING(include of qwt headers)
if test "x$qwt_ok" = xno ; then
AC_MSG_RESULT(no)
AC_MSG_WARN(qwt not found)
else
AC_MSG_RESULT(yes)
QWT_INCLUDES=-I$QWT_INCDIR
fi
#
# test Qwt libraries
#
if test "x$qwt_ok" = "xyes" ; then
AC_MSG_CHECKING(linking qwt library)
LIBS_old=$LIBS
LIBS="$LIBS $QT_LIBS"
if test "x$QWTHOME" = "x/usr" ; then
LIBS="$LIBS -l${libqwt_name}"
else
LIBS="$LIBS -L$QWTHOME/lib -l${libqwt_name}"
fi
CXXFLAGS_old=$CXXFLAGS
CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QWT_INCLUDES"
AC_CACHE_VAL(salome_cv_lib_qwt,[
AC_TRY_LINK(
#include <QApplication>
#include <qwt_plot.h>
, int n;
char **s;
QApplication a(n, s);
QwtPlot p;
p.resize( 600, 400 );
p.show();
a.exec();,
eval "salome_cv_lib_qwt=yes",eval "salome_cv_lib_qwt=no")
])
qwt_ok="$salome_cv_lib_qwt"
if test "x$qwt_ok" = "xno" ; then
AC_MSG_RESULT(unable to link with qwt library)
AC_MSG_RESULT(QWTHOME environment variable may be wrong)
else
AC_MSG_RESULT(yes)
if test "x$QWTHOME" = "x/usr" ; then
QWT_LIBS=" -l${libqwt_name}"
else
QWT_LIBS="-L$QWTHOME/lib -l${libqwt_name}"
fi
fi
LIBS=$LIBS_old
CXXFLAGS=$CXXFLAGS_old
fi
fi
AC_SUBST(QWT_INCLUDES)
AC_SUBST(QWT_LIBS)
AC_LANG_RESTORE
AC_MSG_RESULT(for qwt: $qwt_ok)
# Save cache
AC_CACHE_SAVE
])dnl
dnl

View File

@ -28,6 +28,9 @@ find bin -name Makefile.in | xargs rm -f
find doc -name Makefile.in | xargs rm -f
find idl -name Makefile.in | xargs rm -f
find resources -name Makefile.in | xargs rm -f
find salome_adm -name Makefile.in | xargs rm -f
find adm_local -name Makefile.in | xargs rm -f
find src -name Makefile.in | xargs rm -f
rm -f Makefile.in
cd adm_local/unix/config_files
rm -f config.* depcomp install-sh l*.m4 ltmain.sh missing py-compile

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -0,0 +1,12 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>$title</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head>
<hr>
<center>
SALOME documentation central
</center>
<hr>

View File

@ -31,7 +31,7 @@ CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = NO
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF =
ALWAYS_DETAILED_SEC = YES
INLINE_INHERITED_MEMB = YES
@ -40,6 +40,7 @@ STRIP_FROM_PATH = @top_srcdir@ @top_builddir@
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
@ -69,7 +70,7 @@ CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
@ -91,7 +92,7 @@ WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
WARN_LOGFILE = log.txt
#---------------------------------------------------------------------------
# configuration options related to the input files
@ -117,19 +118,19 @@ FILTER_SOURCE_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
SOURCE_BROWSER = YES
INLINE_SOURCES = YES
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
USE_HTAGS = NO
#USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 3
COLS_IN_ALPHA_INDEX = 2
IGNORE_PREFIX =
#---------------------------------------------------------------------------
@ -146,11 +147,11 @@ GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = YES
TOC_EXPAND = YES
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
GENERATE_TREEVIEW = YES
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
@ -213,14 +214,14 @@ PERLMOD_MAKEVAR_PREFIX =
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = NO
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
@ -239,23 +240,23 @@ HIDE_UNDOC_RELATIONS = NO
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = NO
GROUP_GRAPHS = NO
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = NO
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = jpg
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1200
MAX_DOT_GRAPH_DEPTH = 0
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,13 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.73 [en] (WinNT; I) [Netscape]">
<title>Main Page</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head>
<body>
&nbsp;
</body>
</html>

View File

@ -929,6 +929,19 @@ module SMESH
*/
boolean Make2DMeshFrom3D();
/*!
* \brief Double nodes on shared faces between groups of volumes and create flat elements on demand.
* The list of groups must describe a partition of the mesh volumes.
* The nodes of the internal faces at the boundaries of the groups are doubled.
* In option, the internal faces are replaced by flat elements.
* Triangles are transformed in prisms, and quadrangles in hexahedrons.
* \param theDomains - list of groups of volumes
* \param createJointElems - if TRUE, create the elements
* \return TRUE if operation has been completed successfully, FALSE otherwise
*/
boolean DoubleNodesOnGroupBoundaries( in ListOfGroups theDomains,
in boolean createJointElems );
/*!
* \brief Creates missing boundary elements
* \param elements - elements whose boundary is to be checked

View File

@ -43,6 +43,7 @@ dist_SMESHControls_SOURCES = \
# additionnal information to compil and link file
libSMESHControls_la_CPPFLAGS = \
$(CAS_CPPFLAGS) \
$(VTK_INCLUDES) \
$(BOOST_CPPFLAGS) \
$(KERNEL_CXXFLAGS) \
-I$(srcdir)/../SMDS \

View File

@ -250,11 +250,11 @@ bool NumericalFunctor::GetPoints(const SMDS_MeshElement* anElem,
if ( anElem->IsQuadratic() ) {
switch ( anElem->GetType() ) {
case SMDSAbs_Edge:
anIter = static_cast<const SMDS_QuadraticEdge*>
anIter = dynamic_cast<const SMDS_VtkEdge*>
(anElem)->interlacedNodesElemIterator();
break;
case SMDSAbs_Face:
anIter = static_cast<const SMDS_QuadraticFaceOfNodes*>
anIter = dynamic_cast<const SMDS_VtkFace*>
(anElem)->interlacedNodesElemIterator();
break;
default:
@ -1622,10 +1622,10 @@ void Length2D::GetValues(TValues& theValues){
const SMDS_MeshFace* anElem = anIter->next();
if(anElem->IsQuadratic()) {
const SMDS_QuadraticFaceOfNodes* F =
static_cast<const SMDS_QuadraticFaceOfNodes*>(anElem);
const SMDS_VtkFace* F =
dynamic_cast<const SMDS_VtkFace*>(anElem);
// use special nodes iterator
SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator();
SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator();
long aNodeId[4];
gp_Pnt P[4];
@ -1819,7 +1819,7 @@ void MultiConnection2D::GetValues(MValues& theValues){
const SMDS_MeshFace* anElem = anIter->next();
SMDS_ElemIteratorPtr aNodesIter;
if ( anElem->IsQuadratic() )
aNodesIter = static_cast<const SMDS_QuadraticFaceOfNodes*>
aNodesIter = dynamic_cast<const SMDS_VtkFace*>
(anElem)->interlacedNodesElemIterator();
else
aNodesIter = anElem->nodesIterator();
@ -1978,7 +1978,7 @@ bool FreeEdges::IsSatisfy( long theId )
SMDS_ElemIteratorPtr anIter;
if ( aFace->IsQuadratic() ) {
anIter = static_cast<const SMDS_QuadraticFaceOfNodes*>
anIter = dynamic_cast<const SMDS_VtkFace*>
(aFace)->interlacedNodesElemIterator();
}
else {
@ -2047,7 +2047,7 @@ void FreeEdges::GetBoreders(TBorders& theBorders)
long anElemId = anElem->GetID();
SMDS_ElemIteratorPtr aNodesIter;
if ( anElem->IsQuadratic() )
aNodesIter = static_cast<const SMDS_QuadraticFaceOfNodes*>(anElem)->
aNodesIter = static_cast<const SMDS_VtkFace*>(anElem)->
interlacedNodesElemIterator();
else
aNodesIter = anElem->nodesIterator();
@ -3225,7 +3225,7 @@ void ManifoldPart::expandBoundary
void ManifoldPart::getFacesByLink( const ManifoldPart::Link& theLink,
ManifoldPart::TVectorOfFacePtr& theFaces ) const
{
SMDS_Mesh::SetOfFaces aSetOfFaces;
std::set<SMDS_MeshCell *> aSetOfFaces;
// take all faces that shared first node
SMDS_ElemIteratorPtr anItr = theLink.myNode1->facesIterator();
for ( ; anItr->more(); )
@ -3233,7 +3233,7 @@ void ManifoldPart::getFacesByLink( const ManifoldPart::Link& theLink,
SMDS_MeshFace* aFace = (SMDS_MeshFace*)anItr->next();
if ( !aFace )
continue;
aSetOfFaces.Add( aFace );
aSetOfFaces.insert( aFace );
}
// take all faces that shared second node
anItr = theLink.myNode2->facesIterator();
@ -3241,7 +3241,7 @@ void ManifoldPart::getFacesByLink( const ManifoldPart::Link& theLink,
for ( ; anItr->more(); )
{
SMDS_MeshFace* aFace = (SMDS_MeshFace*)anItr->next();
if ( aSetOfFaces.Contains( aFace ) )
if ( aSetOfFaces.count( aFace ) )
theFaces.push_back( aFace );
}
}

View File

@ -56,6 +56,7 @@ dist_DAT_Test_SOURCES = \
libMeshDriverDAT_la_CPPFLAGS = \
$(KERNEL_CXXFLAGS) \
$(CAS_CPPFLAGS) \
$(VTK_INCLUDES) \
$(BOOST_CPPFLAGS) \
-I$(srcdir)/../Driver \
-I$(srcdir)/../SMDS \

View File

@ -24,6 +24,7 @@
// File : DriverMED_Family.cxx
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
//
#include "DriverMED_Family.h"
#include "MED_Factory.hxx"

View File

@ -24,6 +24,7 @@
// File : DriverMED_Family.hxx
// Author : Julia DOROVSKIKH
// Module : SMESH
// $Header$
//
#ifndef _INCLUDE_DRIVERMED_FAMILY
#define _INCLUDE_DRIVERMED_FAMILY

View File

@ -40,7 +40,7 @@
#include <stdlib.h>
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUG = 1;
//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
@ -161,9 +161,11 @@ DriverMED_R_SMESHDS_Mesh
if(anIsNodeNum) {
aNode = myMesh->AddNodeWithID
(aCoords[0],aCoords[1],aCoords[2],aNodeInfo->GetElemNum(iElem));
//MESSAGE("AddNodeWithID " << aNodeInfo->GetElemNum(iElem));
} else {
aNode = myMesh->AddNode
(aCoords[0],aCoords[1],aCoords[2]);
aNode = myMesh->AddNodeWithID
(aCoords[0],aCoords[1],aCoords[2], iElem+1);
//MESSAGE("AddNode " << aNode->GetID());
}
//cout<<aNode->GetID()<<": "<<aNode->X()<<", "<<aNode->Y()<<", "<<aNode->Z()<<endl;
@ -225,12 +227,14 @@ DriverMED_R_SMESHDS_Mesh
if(anIsElemNum){
TInt anElemId = aPolygoneInfo->GetElemNum(iElem);
anElement = myMesh->AddPolygonalFaceWithID(aNodeIds,anElemId);
//MESSAGE("AddPolygonalFaceWithID " << anElemId);
}
if(!anElement){
vector<const SMDS_MeshNode*> aNodes(aNbConn);
for(TInt iConn = 0; iConn < aNbConn; iConn++)
aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
anElement = myMesh->AddPolygonalFace(aNodes);
//MESSAGE("AddPolygonalFace " << anElement->GetID());
isRenum = anIsElemNum;
}
#ifndef _DEXCEPT_
@ -270,21 +274,35 @@ DriverMED_R_SMESHDS_Mesh
typedef MED::TVector<int> TQuantities;
TQuantities aQuantities(aNbFaces);
TInt aNbNodes = aPolyedreInfo->GetNbNodes(iElem);
//MESSAGE("--- aNbNodes " << aNbNodes);
TNodeIds aNodeIds(aNbNodes);
for(TInt iFace = 0, iNode = 0; iFace < aNbFaces; iFace++){
//MESSAGE("--- iface " << aNbFaces << " " << iFace);
MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
TInt aNbConn = aConnSlice.size();
aQuantities[iFace] = aNbConn;
#ifdef _EDF_NODE_IDS_
//MESSAGE(anIsNodeNum);
if(anIsNodeNum)
for(TInt iConn = 0; iConn < aNbConn; iConn++)
aNodeIds[iNode++] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
{
//MESSAGE("iConn " << iConn << " aConnSlice[iConn] " << aConnSlice[iConn]);
aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
//MESSAGE("aNodeIds[" << iNode << "]=" << aNodeIds[iNode]);
iNode++;
}
else
for(TInt iConn = 0; iConn < aNbConn; iConn++)
{
//MESSAGE("iConn " << iConn);
aNodeIds[iNode++] = aConnSlice[iConn];
}
#else
for(TInt iConn = 0; iConn < aNbConn; iConn++)
{
//MESSAGE("iConn " << iConn);
aNodeIds[iNode++] = aConnSlice[iConn];
}
#endif
}
@ -298,12 +316,14 @@ DriverMED_R_SMESHDS_Mesh
if(anIsElemNum){
TInt anElemId = aPolyedreInfo->GetElemNum(iElem);
anElement = myMesh->AddPolyhedralVolumeWithID(aNodeIds,aQuantities,anElemId);
//MESSAGE("AddPolyhedralVolumeWithID " << anElemId);
}
if(!anElement){
vector<const SMDS_MeshNode*> aNodes(aNbNodes);
for(TInt iConn = 0; iConn < aNbNodes; iConn++)
aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
anElement = myMesh->AddPolyhedralVolume(aNodes,aQuantities);
//MESSAGE("AddPolyhedralVolume " << anElement->GetID());
isRenum = anIsElemNum;
}
#ifndef _DEXCEPT_
@ -378,10 +398,10 @@ DriverMED_R_SMESHDS_Mesh
anIsValidConnect = true;
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
//INFOS("Follow exception was cought:\n\t"<<exc.what());
INFOS("Following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
//INFOS("Unknown exception was cought !!!");
INFOS("Unknown exception was cought !!!");
aResult = DRS_FAIL;
}
#endif
@ -552,7 +572,7 @@ DriverMED_R_SMESHDS_Mesh
break;
case ePYRA13:
aNbNodes = 13;
// There is some differnce between SMDS and MED
// There is some difference between SMDS and MED
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
@ -693,13 +713,18 @@ DriverMED_R_SMESHDS_Mesh
}
break;
}
// if (anIsElemNum) {
// MESSAGE("add element with id " << aCellInfo->GetElemNum(iElem));
// }
// else {
// MESSAGE("add element "<< anElement->GetID());
// }
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
//INFOS("Follow exception was cought:\n\t"<<exc.what());
INFOS("The following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
//INFOS("Unknown exception was cought !!!");
INFOS("Unknown exception was caught !!!");
aResult = DRS_FAIL;
}
#endif
@ -727,13 +752,15 @@ DriverMED_R_SMESHDS_Mesh
}
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
INFOS("Follow exception was cought:\n\t"<<exc.what());
INFOS("The following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
INFOS("Unknown exception was cought !!!");
INFOS("Unknown exception was caught !!!");
aResult = DRS_FAIL;
}
#endif
if (myMesh)
myMesh->compactMesh();
if(MYDEBUG) MESSAGE("Perform - aResult status = "<<aResult);
return aResult;
}
@ -756,10 +783,10 @@ list<string> DriverMED_R_SMESHDS_Mesh::GetMeshNames(Status& theStatus)
}
}
}catch(const std::exception& exc){
INFOS("Follow exception was cought:\n\t"<<exc.what());
INFOS("Following exception was caught:\n\t"<<exc.what());
theStatus = DRS_FAIL;
}catch(...){
INFOS("Unknown exception was cought !!!");
INFOS("Unknown exception was caught !!!");
theStatus = DRS_FAIL;
}
@ -944,6 +971,9 @@ bool DriverMED_R_SMESHDS_Mesh::buildMeshGrille(const MED::PWrapper& theWrapper,
for(MED::TInt iDim=0;iDim<aMeshDim;iDim++)
aCoords[(int)iDim] = aMEDNodeCoord[(int)iDim];
aNode = myMesh->AddNodeWithID(aCoords[0],aCoords[1],aCoords[2],(int)iNode);
if (!aNode) {
EXCEPTION(runtime_error,"buildMeshGrille Error. Node not created! "<<(int)iNode);
}
if((aGrilleInfo->myFamNumNode).size() > 0){
TInt aFamNum = aGrilleInfo->GetFamNumNode(iNode);
@ -999,7 +1029,9 @@ bool DriverMED_R_SMESHDS_Mesh::buildMeshGrille(const MED::PWrapper& theWrapper,
default:
break;
}
if (!anElement) {
EXCEPTION(runtime_error,"buildMeshGrille Error. Element not created! "<<iCell);
}
if((aGrilleInfo->myFamNum).size() > 0){
TInt aFamNum = aGrilleInfo->GetFamNum(iCell);
if ( checkFamilyID ( aFamily, aFamNum )){

View File

@ -622,6 +622,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
nbElemInfo.NbHexas( ORDER_QUADRATIC ),
SMDSAbs_Volume));
if ( polyTypesSupported ) {
//MESSAGE("polyTypesSupported");
aTElemTypeDatas.push_back( TElemTypeData(anEntity,
ePOLYEDRE,
nbElemInfo.NbPolyhedrons(),
@ -738,18 +739,21 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
// ----------------
else if (aElemTypeData->_geomType == ePOLYEDRE )
{
//MESSAGE("_geomType == ePOLYEDRE");
if ( nbPolyhedronNodes == 0 ) {
// Count nb of nodes
while ( const SMDS_MeshElement* anElem = elemIterator->next() ) {
const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>( anElem );
if ( aPolyedre ) {
const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
if ( aPolyedre && aPolyedre->IsPoly()) {
nbPolyhedronNodes += aPolyedre->NbNodes();
nbPolyhedronFaces += aPolyedre->NbFaces();
if ( ++iElem == aElemTypeData->_nbElems )
break;
}
}
//MESSAGE("nbPolyhedronNodes=" << nbPolyhedronNodes);
//MESSAGE("nbPolyhedronFaces=" << nbPolyhedronFaces);
//MESSAGE("_nbElems="<< aElemTypeData->_nbElems);
}
else {
// Store in med file
@ -771,19 +775,22 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
TInt iFace = 0, iNode = 0;
while ( const SMDS_MeshElement* anElem = elemIterator->next() )
{
const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>( anElem );
const SMDS_VtkVolume *aPolyedre = dynamic_cast<const SMDS_VtkVolume*>(anElem);
if ( !aPolyedre )
continue;
if ( !aPolyedre->IsPoly() )
continue;
//MESSAGE("index[" << iElem << "]=" << index[iElem] << " iElem=" << iElem);
// index
TInt aNbFaces = aPolyedre->NbFaces();
index[ iElem+1 ] = index[ iElem ] + aNbFaces;
//MESSAGE("index[" << iElem+1 << "]=" << index[iElem+1] << " iElem=" << iElem);
// face index
for (TInt f = 1; f <= aNbFaces; ++f, ++iFace ) {
int aNbFaceNodes = aPolyedre->NbFaceNodes( f );
faces[ iFace+1 ] = faces[ iFace ] + aNbFaceNodes;
//MESSAGE("faces[" << iFace+1 << "]=" << faces[iFace+1] << " iFace=" << iFace);
}
// connectivity
SMDS_ElemIteratorPtr nodeIt = anElem->nodesIterator();
@ -791,8 +798,10 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
const SMDS_MeshElement* aNode = nodeIt->next();
#ifdef _EDF_NODE_IDS_
conn[ iNode ] = aNodeIdMap[aNode->GetID()];
//MESSAGE("conn["<< iNode << "]=" << conn[iNode] << " aNode->GetID()=" << aNode->GetID());
#else
conn[ iNode ] = aNode->GetID();
//MESSAGE("conn["<< iNode << "]=" << conn[iNode]);
#endif
++iNode;
}
@ -868,11 +877,11 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
}
catch(const std::exception& exc) {
INFOS("Follow exception was cought:\n\t"<<exc.what());
INFOS("The following exception was caught:\n\t"<<exc.what());
throw;
}
catch(...) {
INFOS("Unknown exception was cought !!!");
INFOS("Unknown exception was caught !!!");
throw;
}

View File

@ -61,6 +61,7 @@ libMeshDriverMED_la_CPPFLAGS = \
@HDF5_INCLUDES@ \
$(KERNEL_CXXFLAGS) \
$(CAS_CPPFLAGS) \
$(VTK_INCLUDES) \
$(BOOST_CPPFLAGS) \
-I$(srcdir)/../Driver \
-I$(srcdir)/../SMDS \

View File

@ -50,6 +50,7 @@ dist_STL_Test_SOURCES = \
libMeshDriverSTL_la_CPPFLAGS = \
$(KERNEL_CXXFLAGS) \
$(CAS_CPPFLAGS) \
$(VTK_INCLUDES) \
$(BOOST_CPPFLAGS) \
-I$(srcdir)/../Driver \
-I$(srcdir)/../SMDS

View File

@ -37,7 +37,7 @@ using namespace std;
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
@ -65,6 +65,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
for(; anIter != aDataSet2411.end(); anIter++){
const TNodeLab& aLabel = anIter->first;
const TRecord& aRec = anIter->second;
//MESSAGE("AddNodeWithID " << aLabel << " " << aRec.coord[0] << " " << aRec.coord[1] << " " << aRec.coord[2]);
myMesh->AddNodeWithID(aRec.coord[0],aRec.coord[1],aRec.coord[2],aLabel);
}
}
@ -82,11 +83,13 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
if(IsBeam(aRec.fe_descriptor_id)) {
switch ( aRec.node_labels.size() ) {
case 2: // edge with two nodes
//MESSAGE("add edge " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1]);
anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
aRec.node_labels[1],
aLabel);
break;
case 3: // quadratic edge (with 3 nodes)
//MESSAGE("add edge " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1] << " " << aRec.node_labels[2]);
anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
aRec.node_labels[2],
aRec.node_labels[1],
@ -94,6 +97,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
}
}
else if(IsFace(aRec.fe_descriptor_id)) {
//MESSAGE("add face " << aLabel);
switch(aRec.fe_descriptor_id){
case 41: // Plane Stress Linear Triangle
case 51: // Plane Strain Linear Triangle
@ -113,6 +117,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
case 72: // Membrane Parabolic Triangle
case 82: // Axisymetric Solid Parabolic Triangle
case 92: // Thin Shell Parabolic Triangle
//MESSAGE("add face " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1] << " " << aRec.node_labels[2] << " " << aRec.node_labels[3] << " " << aRec.node_labels[4] << " " << aRec.node_labels[5]);
anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
aRec.node_labels[2],
aRec.node_labels[4],
@ -154,6 +159,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
}
}
else if(IsVolume(aRec.fe_descriptor_id)){
//MESSAGE("add volume " << aLabel);
switch(aRec.fe_descriptor_id){
case 111: // Solid Linear Tetrahedron - TET4
@ -377,5 +383,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
catch(...){
INFOS("Unknown exception was cought !!!");
}
if (myMesh)
myMesh->compactMesh();
return aResult;
}

View File

@ -99,12 +99,10 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform()
TRecord aRec;
aRec.node_labels.reserve(aNbNodes);
SMDS_ElemIteratorPtr aNodesIter;
aNodesIter = anElem->nodesIteratorToUNV();
if( anElem->IsQuadratic() ) {
aNodesIter = static_cast<const SMDS_QuadraticEdge* >
( anElem )->interlacedNodesElemIterator();
aRec.fe_descriptor_id = 22;
} else {
aNodesIter = anElem->nodesIterator();
aRec.fe_descriptor_id = 11;
}
for(; aNodesIter->more();){
@ -126,11 +124,7 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform()
TRecord aRec;
aRec.node_labels.reserve(aNbNodes);
SMDS_ElemIteratorPtr aNodesIter;
if( anElem->IsQuadratic() )
aNodesIter = static_cast<const SMDS_QuadraticFaceOfNodes* >
( anElem )->interlacedNodesElemIterator();
else
aNodesIter = anElem->nodesIterator();
aNodesIter = anElem->nodesIteratorToUNV();
for(; aNodesIter->more();){
const SMDS_MeshElement* aNode = aNodesIter->next();
aRec.node_labels.push_back(aNode->GetID());
@ -164,72 +158,59 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform()
TElementLab aLabel = anElem->GetID();
int aNbNodes = anElem->NbNodes();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
//MESSAGE("aNbNodes="<<aNbNodes);
SMDS_ElemIteratorPtr aNodesIter;
aNodesIter = anElem->nodesIteratorToUNV();
if ( anElem->IsPoly() ) {
if ( const SMDS_PolyhedralVolumeOfNodes* ph =
dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*> (anElem))
MESSAGE("anElem->IsPoly");
if ( const SMDS_VtkVolume* ph =
dynamic_cast<const SMDS_VtkVolume*> (anElem))
{
aNbNodes = ph->NbUniqueNodes();
aNodesIter = ph->uniqueNodesIterator();
}
}
aConnect.resize(aNbNodes);
GetConnect(aNodesIter,aConnect);
int anId = -1;
int* aConn = NULL;
switch(aNbNodes){
case 4: {
static int anIds[] = {0,2,1,3};
aConn = anIds;
anId = 111;
break;
}
case 6: {
static int anIds[] = {0,2,1,3,5,4};
aConn = anIds;
anId = 112;
break;
}
case 8: {
static int anIds[] = {0,3,2,1,4,7,6,5};
aConn = anIds;
anId = 115;
break;
}
case 10: {
static int anIds[] = {0,4,2,9,5,3, 1,6,8, 7};
aConn = anIds;
anId = 118;
break;
}
case 13: {
static int anIds[] = {0,6,4,2,7,5,3,1,8,11,10,9,12};
aConn = anIds;
anId = 114;
break;
}
case 15: {
static int anIds[] = {0,4,2,9,13,11,5,3,1,14,12,10,6,8,7};
aConn = anIds;
anId = 113;
break;
}
case 20: {
static int anIds[] = {0,6, 4,2, 12,18,16,14,7, 5, 3, 1, 19,17,15,13,8, 11,10,9};
aConn = anIds;
anId = 116;
break;
}
default:
continue;
}
if(aConn){
if(anId>0){
TRecord aRec;
aRec.fe_descriptor_id = anId;
aRec.node_labels.resize(aNbNodes);
for(int aNodeId = 0; aNodeId < aNbNodes; aNodeId++){
aRec.node_labels[aConn[aNodeId]] = aConnect[aNodeId];
aRec.node_labels.reserve(aNbNodes);
for(; aNodesIter->more();){
const SMDS_MeshElement* aNode = aNodesIter->next();
aRec.node_labels.push_back(aNode->GetID());
}
aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
}

View File

@ -69,6 +69,7 @@ libMeshDriverUNV_la_CPPFLAGS = \
$(CAS_CPPFLAGS) \
$(CORBA_CXXFLAGS) \
$(CORBA_INCLUDES) \
$(VTK_INCLUDES) \
$(BOOST_CPPFLAGS) \
-I$(srcdir)/../Driver \
-I$(srcdir)/../SMDS \

View File

@ -37,7 +37,6 @@ salomeinclude_HEADERS = \
SMESH_FaceOrientationFilter.h \
SMESH_ScalarBarActor.h
# Libraries targets
lib_LTLIBRARIES = libSMESHObject.la

View File

@ -30,6 +30,7 @@
#include "SMESH_DeviceActor.h"
#include "SMESH_ObjectDef.h"
#include "SMESH_ControlsDef.hxx"
#include "SMDS_UnstructuredGrid.hxx"
#include "SMESH_ScalarBarActor.h"
#include "VTKViewer_CellCenters.h"
#include "VTKViewer_ExtractUnstructuredGrid.h"
@ -82,7 +83,7 @@
#ifdef _DEBUG_
static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
static int MYDEBUG = 1;
#endif
static int aLineWidthInc = 2;
@ -198,6 +199,10 @@ SMESH_ActorDef::SMESH_ActorDef()
aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
//#ifdef VTK_HAVE_POLYHEDRON
MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
//#endif
//Definition 1D device of the actor
//---------------------------------
@ -1359,6 +1364,9 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
//#ifdef VTK_HAVE_POLYHEDRON
aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
//#endif
aHightFilter->RegisterCellsWithType(VTK_TETRA);
aHightFilter->RegisterCellsWithType(VTK_VOXEL);
@ -1370,6 +1378,9 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
//#ifdef VTK_HAVE_POLYHEDRON
aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
//#endif
}
aFilter->Update();
if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());

View File

@ -29,6 +29,7 @@
#include "utilities.h"
#include <vtkUnstructuredGrid.h>
#include <vtkXMLUnstructuredGridWriter.h>
#include <vtkUnstructuredGridWriter.h>
#ifdef _DEBUG_
@ -73,9 +74,10 @@ namespace SMESH
WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid,
const char* theFileName)
{
vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
vtkXMLUnstructuredGridWriter* aWriter = vtkXMLUnstructuredGridWriter::New();
aWriter->SetFileName(theFileName);
aWriter->SetInput(theGrid);
aWriter->SetDataModeToAscii();
if(theGrid->GetNumberOfCells()){
aWriter->Write();
}

View File

@ -64,8 +64,8 @@ using namespace std;
#endif
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
static int MYDEBUG = 1;
static int MYDEBUGWITHFILES = 1;
#else
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
@ -133,11 +133,14 @@ static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
//=================================================================================
SMESH_VisualObjDef::SMESH_VisualObjDef()
{
MESSAGE("---------------------------------------------SMESH_VisualObjDef::SMESH_VisualObjDef");
myGrid = vtkUnstructuredGrid::New();
myLocalGrid = false;
}
SMESH_VisualObjDef::~SMESH_VisualObjDef()
{
if ( MYDEBUG )
MESSAGE("---------------------------------------------SMESH_VisualObjDef::~SMESH_VisualObjDef");
//if ( MYDEBUG )
MESSAGE( "~SMESH_MeshObj - myGrid->GetReferenceCount() = " << myGrid->GetReferenceCount() );
myGrid->Delete();
}
@ -148,32 +151,53 @@ SMESH_VisualObjDef::~SMESH_VisualObjDef()
//=================================================================================
vtkIdType SMESH_VisualObjDef::GetNodeObjId( int theVTKID )
{
TMapOfIds::const_iterator i = myVTK2SMDSNodes.find(theVTKID);
return i == myVTK2SMDSNodes.end() ? -1 : i->second;
if (myLocalGrid)
{
TMapOfIds::const_iterator i = myVTK2SMDSNodes.find(theVTKID);
return i == myVTK2SMDSNodes.end() ? -1 : i->second;
}
return this->GetMesh()->FindNodeVtk(theVTKID)->GetID();
}
vtkIdType SMESH_VisualObjDef::GetNodeVTKId( int theObjID )
{
TMapOfIds::const_iterator i = mySMDS2VTKNodes.find(theObjID);
return i == mySMDS2VTKNodes.end() ? -1 : i->second;
if (myLocalGrid)
{
TMapOfIds::const_iterator i = mySMDS2VTKNodes.find(theObjID);
return i == mySMDS2VTKNodes.end() ? -1 : i->second;
}
return this->GetMesh()->FindNode(theObjID)->getVtkId();
}
vtkIdType SMESH_VisualObjDef::GetElemObjId( int theVTKID )
{
TMapOfIds::const_iterator i = myVTK2SMDSElems.find(theVTKID);
return i == myVTK2SMDSElems.end() ? -1 : i->second;
if (myLocalGrid)
{
TMapOfIds::const_iterator i = myVTK2SMDSElems.find(theVTKID);
return i == myVTK2SMDSElems.end() ? -1 : i->second;
}
return this->GetMesh()->fromVtkToSmds(theVTKID);
}
vtkIdType SMESH_VisualObjDef::GetElemVTKId( int theObjID )
{
TMapOfIds::const_iterator i = mySMDS2VTKElems.find(theObjID);
return i == mySMDS2VTKElems.end() ? -1 : i->second;
if (myLocalGrid)
{
TMapOfIds::const_iterator i = mySMDS2VTKElems.find(theObjID);
return i == mySMDS2VTKElems.end() ? -1 : i->second;
}
return this->GetMesh()->FindElement(theObjID)->getVtkId();
//return this->GetMesh()->fromSmdsToVtk(theObjID);
}
//=================================================================================
// function : SMESH_VisualObjDef::createPoints
// purpose : Create points from nodes
//=================================================================================
/*! fills a vtkPoints structure for a submesh.
* fills a std::list of SMDS_MeshElements*, then extract the points.
* fills also conversion id maps between SMDS and VTK.
*/
void SMESH_VisualObjDef::createPoints( vtkPoints* thePoints )
{
if ( thePoints == 0 )
@ -182,7 +206,7 @@ void SMESH_VisualObjDef::createPoints( vtkPoints* thePoints )
TEntityList aNodes;
vtkIdType nbNodes = GetEntities( SMDSAbs_Node, aNodes );
thePoints->SetNumberOfPoints( nbNodes );
int nbPoints = 0;
TEntityList::const_iterator anIter;
@ -207,52 +231,70 @@ void SMESH_VisualObjDef::createPoints( vtkPoints* thePoints )
// function : buildPrs
// purpose : create VTK cells( fill unstructured grid )
//=================================================================================
void SMESH_VisualObjDef::buildPrs()
void SMESH_VisualObjDef::buildPrs(bool buildGrid)
{
try
MESSAGE("----------------------------------------------------------SMESH_VisualObjDef::buildPrs " << buildGrid);
if (buildGrid)
{
mySMDS2VTKNodes.clear();
myVTK2SMDSNodes.clear();
mySMDS2VTKElems.clear();
myVTK2SMDSElems.clear();
if ( IsNodePrs() )
buildNodePrs();
else
buildElemPrs();
}
catch(...)
{
mySMDS2VTKNodes.clear();
myVTK2SMDSNodes.clear();
mySMDS2VTKElems.clear();
myVTK2SMDSElems.clear();
myLocalGrid = true;
try
{
mySMDS2VTKNodes.clear();
myVTK2SMDSNodes.clear();
mySMDS2VTKElems.clear();
myVTK2SMDSElems.clear();
myGrid->SetPoints( 0 );
myGrid->SetCells( 0, 0, 0 );
throw;
if ( IsNodePrs() )
buildNodePrs();
else
buildElemPrs();
}
catch(...)
{
mySMDS2VTKNodes.clear();
myVTK2SMDSNodes.clear();
mySMDS2VTKElems.clear();
myVTK2SMDSElems.clear();
myGrid->SetPoints( 0 );
myGrid->SetCells( 0, 0, 0, 0, 0 );
throw;
}
}
else
{
myLocalGrid = false;
if (!GetMesh()->isCompacted())
{
MESSAGE("*** buildPrs ==> compactMesh!");
GetMesh()->compactMesh();
}
vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
myGrid->ShallowCopy(theGrid);
//MESSAGE(myGrid->GetReferenceCount());
//MESSAGE( "Update - myGrid->GetNumberOfCells() = "<<myGrid->GetNumberOfCells() );
//MESSAGE( "Update - myGrid->GetNumberOfPoints() = "<<myGrid->GetNumberOfPoints() );
if( MYDEBUGWITHFILES ) SMESH::WriteUnstructuredGrid( myGrid,"buildPrs.vtu" );
}
if( MYDEBUG ) MESSAGE( "Update - myGrid->GetNumberOfCells() = "<<myGrid->GetNumberOfCells() );
if( MYDEBUGWITHFILES ) SMESH::WriteUnstructuredGrid( myGrid,"/tmp/buildPrs" );
}
//=================================================================================
// function : buildNodePrs
// purpose : create VTK cells for nodes
//=================================================================================
void SMESH_VisualObjDef::buildNodePrs()
{
// PAL16631: without swap, bad_alloc is not thrown but hung up and crash instead,
// so check remaining memory size for safety
SMDS_Mesh::CheckMemory(); // PAL16631
// SMDS_Mesh::CheckMemory(); // PAL16631
vtkPoints* aPoints = vtkPoints::New();
createPoints( aPoints );
SMDS_Mesh::CheckMemory();
// SMDS_Mesh::CheckMemory();
myGrid->SetPoints( aPoints );
aPoints->Delete();
myGrid->SetCells( 0, 0, 0 );
myGrid->SetCells( 0, 0, 0, 0, 0 );
}
//=================================================================================
@ -288,12 +330,12 @@ namespace{
void SMESH_VisualObjDef::buildElemPrs()
{
// Create points
vtkPoints* aPoints = vtkPoints::New();
createPoints( aPoints );
myGrid->SetPoints( aPoints );
aPoints->Delete();
if ( MYDEBUG )
MESSAGE("Update - myGrid->GetNumberOfPoints() = "<<myGrid->GetNumberOfPoints());
@ -311,7 +353,7 @@ void SMESH_VisualObjDef::buildElemPrs()
// PAL16631: without swap, bad_alloc is not thrown but hung up and crash instead,
// so check remaining memory size for safety
SMDS_Mesh::CheckMemory(); // PAL16631
// SMDS_Mesh::CheckMemory(); // PAL16631
vtkIdType aCellsSize = 2 * nbEnts[ SMDSAbs_0DElement ] + 3 * nbEnts[ SMDSAbs_Edge ];
@ -328,7 +370,7 @@ void SMESH_VisualObjDef::buildElemPrs()
vtkIdType aNbCells = nbEnts[ SMDSAbs_0DElement ] + nbEnts[ SMDSAbs_Edge ] +
nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ];
if ( MYDEBUG )
MESSAGE( "Update - aNbCells = "<<aNbCells<<"; aCellsSize = "<<aCellsSize );
@ -337,13 +379,13 @@ void SMESH_VisualObjDef::buildElemPrs()
vtkCellArray* aConnectivity = vtkCellArray::New();
aConnectivity->Allocate( aCellsSize, 0 );
SMDS_Mesh::CheckMemory(); // PAL16631
// SMDS_Mesh::CheckMemory(); // PAL16631
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
aCellTypesArray->SetNumberOfComponents( 1 );
aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
SMDS_Mesh::CheckMemory(); // PAL16631
// SMDS_Mesh::CheckMemory(); // PAL16631
vtkIdList *anIdList = vtkIdList::New();
vtkIdType iElem = 0;
@ -351,7 +393,7 @@ void SMESH_VisualObjDef::buildElemPrs()
TConnect aConnect;
aConnect.reserve(VTK_CELL_SIZE);
SMDS_Mesh::CheckMemory(); // PAL16631
// SMDS_Mesh::CheckMemory(); // PAL16631
for ( int i = 0; i <= 3; i++ ) // iterate through 0d elements, edges, faces and volumes
{
@ -380,8 +422,8 @@ void SMESH_VisualObjDef::buildElemPrs()
// Convertions connectivities from SMDS to VTK
if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE
if ( const SMDS_PolyhedralVolumeOfNodes* ph =
dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*> (anElem))
if ( const SMDS_VtkVolume* ph =
dynamic_cast<const SMDS_VtkVolume*> (anElem))
{
aNbNodes = GetConnect(ph->uniqueNodesIterator(),aConnect);
anIdList->SetNumberOfIds( aNbNodes );
@ -454,29 +496,29 @@ void SMESH_VisualObjDef::buildElemPrs()
iElem++;
}
}
SMDS_Mesh::CheckMemory(); // PAL16631
// SMDS_Mesh::CheckMemory(); // PAL16631
}
// Insert cells in grid
VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
aCellLocationsArray->SetNumberOfComponents( 1 );
aCellLocationsArray->SetNumberOfTuples( aNbCells );
SMDS_Mesh::CheckMemory(); // PAL16631
// SMDS_Mesh::CheckMemory(); // PAL16631
aConnectivity->InitTraversal();
for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
myGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
aCellLocationsArray->Delete();
aCellTypesArray->Delete();
aConnectivity->Delete();
anIdList->Delete();
SMDS_Mesh::CheckMemory(); // PAL16631
// SMDS_Mesh::CheckMemory(); // PAL16631
}
//=================================================================================
@ -521,12 +563,20 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
return true;
}
vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid()
{
//MESSAGE("SMESH_VisualObjDef::GetUnstructuredGrid " << myGrid);
return myGrid;
}
//=================================================================================
// function : IsValid
// purpose : Return true if there are some entities
//=================================================================================
bool SMESH_VisualObjDef::IsValid() const
{
//MESSAGE("SMESH_VisualObjDef::IsValid");
return GetNbEntities(SMDSAbs_Node) > 0 ||
GetNbEntities(SMDSAbs_0DElement) > 0 ||
GetNbEntities(SMDSAbs_Edge) > 0 ||
@ -546,6 +596,7 @@ bool SMESH_VisualObjDef::IsValid() const
SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh):
myClient(SalomeApp_Application::orb(),theMesh)
{
myEmptyGrid = 0;
if ( MYDEBUG )
MESSAGE("SMESH_MeshObj - this = "<<this<<"; theMesh->_is_nil() = "<<theMesh->_is_nil());
}
@ -567,13 +618,31 @@ SMESH_MeshObj::~SMESH_MeshObj()
bool SMESH_MeshObj::Update( int theIsClear )
{
// Update SMDS_Mesh on client part
MESSAGE("SMESH_MeshObj::Update " << this);
if ( myClient.Update(theIsClear) || GetUnstructuredGrid()->GetNumberOfPoints()==0) {
MESSAGE("buildPrs");
buildPrs(); // Fill unstructured grid
return true;
}
return false;
}
bool SMESH_MeshObj::NulData()
{
MESSAGE ("SMESH_MeshObj::NulData() ==================================================================================");
if (!myEmptyGrid)
{
myEmptyGrid = SMDS_UnstructuredGrid::New();
myEmptyGrid->Initialize();
myEmptyGrid->Allocate();
vtkPoints* points = vtkPoints::New();
points->SetNumberOfPoints(0);
myEmptyGrid->SetPoints( points );
points->Delete();
myEmptyGrid->BuildLinks();
}
myGrid->ShallowCopy(myEmptyGrid);
}
//=================================================================================
// function : GetElemDimension
// purpose : Get dimension of element
@ -740,8 +809,9 @@ void SMESH_SubMeshObj::UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunc
//=================================================================================
bool SMESH_SubMeshObj::Update( int theIsClear )
{
MESSAGE("SMESH_SubMeshObj::Update " << this)
bool changed = myMeshObj->Update( theIsClear );
buildPrs();
buildPrs(true);
return changed;
}

View File

@ -56,6 +56,7 @@ class SMESHOBJECT_EXPORT SMESH_VisualObj
{
public:
virtual bool Update( int theIsClear = true ) = 0;
virtual bool NulData() = 0;
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
virtual int GetElemDimension( const int theObjId ) = 0;

View File

@ -62,6 +62,7 @@ public:
virtual ~SMESH_VisualObjDef();
virtual bool Update( int theIsClear = true ) = 0;
virtual bool NulData() {return 0; };
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
virtual int GetElemDimension( const int theObjId ) = 0;
@ -77,7 +78,7 @@ public:
int& theNodeId1,
int& theNodeId2 ) const;
virtual vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; }
virtual vtkUnstructuredGrid* GetUnstructuredGrid();
virtual vtkIdType GetNodeObjId( int theVTKID );
virtual vtkIdType GetNodeVTKId( int theObjID );
@ -87,16 +88,17 @@ public:
protected:
void createPoints( vtkPoints* );
void buildPrs();
void buildPrs(bool buildGrid = false);
void buildNodePrs();
void buildElemPrs();
private:
//private:
TMapOfIds mySMDS2VTKNodes;
TMapOfIds myVTK2SMDSNodes;
TMapOfIds mySMDS2VTKElems;
TMapOfIds myVTK2SMDSElems;
bool myLocalGrid;
vtkUnstructuredGrid* myGrid;
};
@ -115,6 +117,7 @@ public:
virtual ~SMESH_MeshObj();
virtual bool Update( int theIsClear = true );
virtual bool NulData();
virtual int GetNbEntities( const SMDSAbs_ElementType) const;
virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
@ -129,6 +132,7 @@ public:
protected:
SMESH_Client myClient;
vtkUnstructuredGrid* myEmptyGrid;
};

View File

@ -0,0 +1,230 @@
/*=========================================================================
Program: ParaView
Module: $RCSfile$
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "SMESH_vtkPVUpdateSuppressor.h"
#include "vtkAlgorithmOutput.h"
#include "vtkCollection.h"
#include "vtkCommand.h"
#include "vtkCompositeDataPipeline.h"
#include "vtkDataObject.h"
#include "vtkDemandDrivenPipeline.h"
#include "vtkInformation.h"
#include "vtkInformationDoubleVectorKey.h"
#include "vtkInformationExecutivePortKey.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"
//#include "vtkProcessModule.h"
#include "vtkSmartPointer.h"
#include "vtkUnstructuredGrid.h"
//#include "vtkUpdateSuppressorPipeline.h"
#include <vtkstd/map>
#ifdef MYDEBUG
# define vtkMyDebug(x)\
cout << x;
#else
# define vtkMyDebug(x)
#endif
vtkCxxRevisionMacro(vtkPVUpdateSuppressor, "$Revision$")
;
vtkStandardNewMacro(vtkPVUpdateSuppressor)
;
//----------------------------------------------------------------------------
vtkPVUpdateSuppressor::vtkPVUpdateSuppressor()
{
this->UpdatePiece = 0;
this->UpdateNumberOfPieces = 1;
this->UpdateTime = 0.0;
this->UpdateTimeInitialized = false;
this->Enabled = 1;
// vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
//
// if (pm)
// {
// this->UpdateNumberOfPieces = pm->GetNumberOfLocalPartitions();
// this->UpdatePiece = pm->GetPartitionId();
// }
}
//----------------------------------------------------------------------------
vtkPVUpdateSuppressor::~vtkPVUpdateSuppressor()
{
}
//----------------------------------------------------------------------------
void vtkPVUpdateSuppressor::SetUpdateTime(double utime)
{
this->UpdateTimeInitialized = true;
if (this->UpdateTime != utime)
{
this->Modified();
this->UpdateTime = utime;
}
}
//----------------------------------------------------------------------------
void vtkPVUpdateSuppressor::SetEnabled(int enable)
{
if (this->Enabled == enable)
{
return;
}
this->Enabled = enable;
this->Modified();
// vtkUpdateSuppressorPipeline* executive =
// vtkUpdateSuppressorPipeline::SafeDownCast(this->GetExecutive());
// if (executive)
// {
// executive->SetEnabled(enable);
// }
}
//----------------------------------------------------------------------------
void vtkPVUpdateSuppressor::ForceUpdate()
{
// Make sure that output type matches input type
this->UpdateInformation();
vtkDataObject *input = this->GetInput();
if (input == 0)
{
vtkErrorMacro("No valid input.");
return;
}
vtkDataObject *output = this->GetOutput();
// int fixme; // I do not like this hack. How can we get rid of it?
// Assume the input is the collection filter.
// Client needs to modify the collection filter because it is not
// connected to a pipeline.
vtkAlgorithm *source = input->GetProducerPort()->GetProducer();
if (source && (source->IsA("vtkMPIMoveData")
|| source->IsA("vtkCollectPolyData") || source->IsA("vtkM2NDuplicate")
|| source->IsA("vtkM2NCollect")
|| source->IsA("vtkOrderedCompositeDistributor")
|| source->IsA("vtkClientServerMoveData")))
{
source->Modified();
}
vtkInformation* info = input->GetPipelineInformation();
vtkStreamingDemandDrivenPipeline
* sddp =
vtkStreamingDemandDrivenPipeline::SafeDownCast(
vtkExecutive::PRODUCER()->GetExecutive(
info));
if (sddp)
{
sddp->SetUpdateExtent(info, this->UpdatePiece,
this->UpdateNumberOfPieces, 0);
}
else
{
input->SetUpdatePiece(this->UpdatePiece);
input->SetUpdateNumberOfPieces(this->UpdateNumberOfPieces);
input->SetUpdateGhostLevel(0);
} vtkMyDebug("ForceUpdate ");
if (this->UpdateTimeInitialized)
{
info->Set(vtkCompositeDataPipeline::UPDATE_TIME_STEPS(),
&this->UpdateTime, 1);
vtkMyDebug(this->UpdateTime);
} vtkMyDebug(endl);
input->Update();
// Input may have changed, we obtain the pointer again.
input = this->GetInput();
output->ShallowCopy(input);
this->PipelineUpdateTime.Modified();
}
//----------------------------------------------------------------------------
vtkExecutive* vtkPVUpdateSuppressor::CreateDefaultExecutive()
{
vtkUpdateSuppressorPipeline* executive = vtkUpdateSuppressorPipeline::New();
executive->SetEnabled(this->Enabled);
return executive;
}
//----------------------------------------------------------------------------
int vtkPVUpdateSuppressor::RequestDataObject(
vtkInformation* vtkNotUsed(reqInfo),
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
if (!inInfo)
{
return 0;
}
vtkDataObject *input = inInfo->Get(vtkDataObject::DATA_OBJECT());
if (input)
{
// for each output
for (int i = 0; i < this->GetNumberOfOutputPorts(); ++i)
{
vtkInformation* outInfo = outputVector->GetInformationObject(i);
vtkDataObject *output = outInfo->Get(vtkDataObject::DATA_OBJECT());
if (!output || !output->IsA(input->GetClassName()))
{
vtkDataObject* newOutput = input->NewInstance();
newOutput->SetPipelineInformation(outInfo);
newOutput->Delete();
this->GetOutputPortInformation(i)->Set(
vtkDataObject::DATA_EXTENT_TYPE(),
newOutput->GetExtentType());
}
}
return 1;
}
return 0;
}
//----------------------------------------------------------------------------
int vtkPVUpdateSuppressor::RequestData(vtkInformation* vtkNotUsed(reqInfo),
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
// RequestData is only called by its executive when
// (Enabled==off) and thus acting as a passthrough filter
vtkInformation *outInfo = outputVector->GetInformationObject(0);
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
vtkDataObject *input = inInfo->Get(vtkDataObject::DATA_OBJECT());
vtkDataObject *output = outInfo->Get(vtkDataObject::DATA_OBJECT());
output->ShallowCopy(input);
return 1;
}
//----------------------------------------------------------------------------
void vtkPVUpdateSuppressor::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "UpdatePiece: " << this->UpdatePiece << endl;
os << indent << "UpdateNumberOfPieces: " << this->UpdateNumberOfPieces
<< endl;
os << indent << "Enabled: " << this->Enabled << endl;
os << indent << "UpdateTime: " << this->UpdateTime << endl;
}

View File

@ -0,0 +1,98 @@
/*=========================================================================
Program: ParaView
Module: $RCSfile$
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPVUpdateSuppressor - prevents propagation of update
// .SECTION Description
// vtkPVUpdateSuppressor now uses the vtkProcessModule singleton to set up the
// default values for UpdateNumberOfPieces and UpdatePiece, so we no longer have
// to set the default values (in most cases).
// .SECTION See Also
// vtkPVCacheKeeper vtkUpdateSuppressorPipeline
#ifndef __vtkPVUpdateSuppressor_h
#define __vtkPVUpdateSuppressor_h
#include "vtkDataObjectAlgorithm.h"
class VTK_EXPORT vtkPVUpdateSuppressor: public vtkDataObjectAlgorithm
{
public:
vtkTypeRevisionMacro(vtkPVUpdateSuppressor,vtkDataObjectAlgorithm)
;
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Construct with user-specified implicit function.
static vtkPVUpdateSuppressor *New();
// Description:
// Force update on the input.
virtual void ForceUpdate();
// Description:
// Set number of pieces and piece on the data.
// This causes the filter to ingore the request from the output.
// It is here because the user may not have celled update on the output
// before calling force update (it is an easy fix).
vtkSetMacro(UpdatePiece, int)
;
vtkGetMacro(UpdatePiece, int)
;
vtkSetMacro(UpdateNumberOfPieces, int)
;
vtkGetMacro(UpdateNumberOfPieces, int)
;
// Description:
// Get/Set if the update suppressor is enabled. If the update suppressor
// is not enabled, it won't supress any updates. Enabled by default.
void SetEnabled(int);
vtkGetMacro(Enabled, int)
;
// Description:
// Get/Set the update time that is sent up the pipeline.
void SetUpdateTime(double utime);
vtkGetMacro(UpdateTime, double)
;
protected:
vtkPVUpdateSuppressor();
~vtkPVUpdateSuppressor();
int RequestDataObject(vtkInformation* request,
vtkInformationVector **inputVector,
vtkInformationVector *outputVector);
int RequestData(vtkInformation* request, vtkInformationVector **inputVector,
vtkInformationVector *outputVector);
int UpdatePiece;
int UpdateNumberOfPieces;
double UpdateTime;
bool UpdateTimeInitialized;
int Enabled;
vtkTimeStamp PipelineUpdateTime;
// Create a default executive.
virtual vtkExecutive* CreateDefaultExecutive();
private:
vtkPVUpdateSuppressor(const vtkPVUpdateSuppressor&); // Not implemented.
void operator=(const vtkPVUpdateSuppressor&); // Not implemented.
};
#endif

View File

@ -27,6 +27,8 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am
# header files
salomeinclude_HEADERS = \
chrono.hxx \
ObjectPool.hxx \
SMDS_TypeOfPosition.hxx \
SMDSAbs_ElementType.hxx \
SMDS_EdgePosition.hxx \
@ -34,13 +36,17 @@ salomeinclude_HEADERS = \
SMDS_FacePosition.hxx \
SMDS_Mesh.hxx \
SMDS_Mesh0DElement.hxx \
SMDS_LinearEdge.hxx \
SMDS_MeshEdge.hxx \
SMDS_MeshElement.hxx \
SMDS_MeshElement.cxx \
SMDS_MeshElementIDFactory.hxx \
SMDS_MeshCell.hxx \
SMDS_MeshFace.hxx \
SMDS_MeshGroup.hxx \
SMDS_MeshIDFactory.hxx \
SMDS_MeshNode.hxx \
SMDS_MeshNodeIDFactory.hxx \
SMDS_MeshObject.hxx \
SMDS_MeshVolume.hxx \
SMDS_Position.hxx \
@ -50,6 +56,10 @@ salomeinclude_HEADERS = \
SMDS_IteratorOfElements.hxx \
SMDS_VolumeOfFaces.hxx \
SMDS_VolumeOfNodes.hxx \
SMDS_VtkEdge.hxx \
SMDS_VtkFace.hxx \
SMDS_VtkVolume.hxx \
SMDS_VtkCellIterator.hxx \
SMDS_PolyhedralVolumeOfNodes.hxx \
SMDS_FaceOfEdges.hxx \
SMDS_FaceOfNodes.hxx \
@ -61,6 +71,8 @@ salomeinclude_HEADERS = \
SMDS_SetIterator.hxx \
SMESH_SMDS.hxx \
SMDS_MeshInfo.hxx \
SMDS_UnstructuredGrid.hxx \
SMDS_Downward.hxx \
SMDS_StdIterator.hxx
@ -68,8 +80,10 @@ salomeinclude_HEADERS = \
lib_LTLIBRARIES = libSMDS.la
dist_libSMDS_la_SOURCES = \
chrono.cxx \
SMDS_MeshObject.cxx \
SMDS_MeshElement.cxx \
SMDS_MeshCell.cxx \
SMDS_Position.cxx \
SMDS_EdgePosition.cxx \
SMDS_FacePosition.cxx \
@ -77,9 +91,11 @@ dist_libSMDS_la_SOURCES = \
SMDS_VertexPosition.cxx \
SMDS_MeshNode.cxx \
SMDS_Mesh0DElement.cxx \
SMDS_LinearEdge.cxx \
SMDS_MeshEdge.cxx \
SMDS_MeshFace.cxx \
SMDS_MeshVolume.cxx \
SMDS_MeshNodeIDFactory.cxx \
SMDS_MeshElementIDFactory.cxx \
SMDS_MeshGroup.cxx \
SMDS_MeshIDFactory.cxx \
@ -87,6 +103,10 @@ dist_libSMDS_la_SOURCES = \
SMDS_IteratorOfElements.cxx \
SMDS_VolumeOfFaces.cxx \
SMDS_VolumeOfNodes.cxx \
SMDS_VtkEdge.cxx \
SMDS_VtkFace.cxx \
SMDS_VtkVolume.cxx \
SMDS_VtkCellIterator.cxx \
SMDS_PolyhedralVolumeOfNodes.cxx \
SMDS_FaceOfEdges.cxx \
SMDS_FaceOfNodes.cxx \
@ -94,15 +114,19 @@ dist_libSMDS_la_SOURCES = \
SMDS_VolumeTool.cxx \
SMDS_QuadraticEdge.cxx \
SMDS_QuadraticFaceOfNodes.cxx \
SMDS_QuadraticVolumeOfNodes.cxx
SMDS_QuadraticVolumeOfNodes.cxx \
SMDS_UnstructuredGrid.cxx \
SMDS_Downward.cxx
# additionnal information to compil and link file
libSMDS_la_CPPFLAGS = \
$(KERNEL_CXXFLAGS) \
$(CAS_CPPFLAGS) \
$(VTK_INCLUDES) \
$(BOOST_CPPFLAGS)
libSMDS_la_LDFLAGS = \
$(VTK_LIBS) \
$(KERNEL_LDFLAGS) -lSALOMELocalTrace \
$(CAS_KERNEL)

235
src/SMDS/Notes Normal file
View File

@ -0,0 +1,235 @@
--> Branche V6_main
Problemes en cours
==================
- a faire
+ en cours, OK mais perfectible
* OK
+ visualisation de groupe (type d'element): on voit tout le maillage, mais le groupe est OK
creation d'une structure vtkUnstructuredGrid locale : iteration un peu lourde, et pas de partage avec la structure du maillage (pas evident)
- inversion d'un volume (tetra): exception
- script de creation de noeuds et d'elements: OK, mais pas compatible avec version precedente (numerotation noeuds differente)
+ affichage numeros noeuds: numeros en trop sur (O,0,0) pas systematique, trouver la condition (enlever dans vtkUnstructuredGrid ?)
==> purge systematique noeuds et cellules en trop dans compactage grid.
+ gestion du mode embedded mal faite lors d'un script python : journal commandes intempestif
- affichage des noeuds apres changement lineaire <--> quadratique à l'IHM : pas pris en compte, alors que maillage OK,
mais script OK
==> cassé apres mode embedded ou elimination noeuds en trop ?
- extrusion elements 2D along a path : affichage apres calcul pas toujours OK (filaire)
- branche git a ouvrir pour merge avec V5_1_4_BR tag V5_1_4rc1
A tester, non pris en compte
============================
- engine standalone
- polyedres (attendre vtk)
=============================== Hypothese de refonte de l'API de SMDS
n'utiliser que vtkUnstructuredGrid, ne pas avor d'objets SMDS_MeshElement mais seulement des index de vtkUnstructuredGrid.
2987 usages de SMDS_MeshNodes
810 SMDS_MeshElement
...
==> en dernier ressort, lourd
================================================================================
Essai a API SMDS a peu pres constante
=====================================
SMDS_Mesh
static vector<SMDS_Mesh*> _meshList; --> retrouver un SMDS_Mesh
vtkUnstructuredGrid* myGrid;
vector<SMDS_MeshNode *> myNodes; --> meme index que dans le pointSet de myGrid
vector<SMDS_MeshCell *> myCells; --> index = ID client, pas le meme index que dans le cellTypes de myGrid (ID vtk)
SMDS_MeshElement
int myID; --> index dans la structure geree par SMDS_Mesh
int myMeshId; --> pour retrouver SMDS_Mesh* dans _meshList
int myShapeId; --> pour retrouver la subShape
SMDS_MeshNode: SMDS_MeshElement
SMDS_PositionPtr myPosition; --> A REVOIR : objet position dans la shape geom
##vector<int> myInverseElements; --> SUPPRIME : pour retrouver les elements, vtkCellLinks
SMDS_MeshCell: SMDS_MeshElement --> generique pour tous les elements (cells)
int myVtkID --> A SUPPRIMER
SMDS_MeshVolume: SMDS_MeshCell
SMDS_VolumeOfNodes: SMDS_MeshVolume --> Garder temporairement, utilisation dans StdMesher et SMDS_VolumeTool
const SMDS_MeshNode **myNodes; --> Couteux
int myNbNodes; --> ""
SMDS_VolumeVtkNodes: SMDS_MeshVolume --> Utiliser systematiquement dans SMDS,
--> IMPLEMENTER.
SMDS_MeshElementIDFactory: SMDS_MeshNodeIDFactory
vector<int> myIDElements; // index = ID client, value = ID vtk --> A SUPPRIMER, ne sert que dans SMDS_MeshElementIDFactory
vector<int> myVtkIndex; // index = ID vtk, value = ID client --> A REPORTER dans SMDS_Mesh
========= TODO ============
enlever vtkId de SMDS_MeshCell, utiliser SMDS_MeshElementIDFactory.
ajouter ID dans SMDS_Mesh::createTriangle
verifier ID dans SMDS_Mesh::Find*OrCreate
===================================================
occupation memoire cube 100*100*100 sans affichage
NOTES:
- sur Debian Sarge 64 bits, les mesures malloc_stat() semblent coherentes
avec une mesure externe globale(recherche du passage en swap du process).
- sur Ubuntu 9.10 64 bits, les mesures malloc_stat() donnent des resultats bizarres (surestimation ?),
mais la mesure avec l'outil KDE de surveillance systeme est OK avec la recherche du swap.
Reference : V513 Debian Sarge 64 bits: --> 463 - 33 = 430 Mo
-------------------------------------
Total (incl. mmap):
system bytes = 43757568
in use bytes = 32909584 = 33M
max mmap regions = 41
max mmap bytes = 16371712
----
Total (incl. mmap):
system bytes = 464670720
in use bytes = 463105120 = 463M
max mmap regions = 47
max mmap bytes = 28188672
Debian Sarge 64 bits, vtkUnstructuredGrid nodes et hexa, 4 janvier 2010 --> 512 - 41 = 471M
-----------------------------------
Total (incl. mmap):
system bytes = 52133888
in use bytes = 41340320 : 41M
max mmap regions = 72
max mmap bytes = 24625152
----
Total (incl. mmap):
system bytes = 520560640
in use bytes = 518735584 : 512M
max mmap regions = 88
max mmap bytes = 198385664
idem avec pool SMDS_MeshNodes --> 483 -33 = 450M
-----------------------------
Total (incl. mmap):
system bytes = 43696128
in use bytes = 32915184 : 33M
max mmap regions = 41
max mmap bytes = 16371712
----
Total (incl. mmap):
system bytes = 484806656
in use bytes = 482980992 : 483M
max mmap regions = 58
max mmap bytes = 184557568
idem ci-dessus + pool SMDS_VolumeVtkNodes --> 475 -33 = 442M (git: add ObjectPool.hxx)
-----------------------------------------
Total (incl. mmap):
system bytes = 43200512
in use bytes = 32908576 : 33M
max mmap regions = 41
max mmap bytes = 16371712
----
Total (incl. mmap):
system bytes = 478068736
in use bytes = 475144400 : 475M
max mmap regions = 59
max mmap bytes = 184692736
remplacement SMDS_PositionPtr: (boost::shared_ptr<SMDS_Position> --> SMDS_Position*) --> 436 - 35 = 401M (git SMDS_Position)
------------------------------------------------------------------------------------
Total (incl. mmap):
system bytes = 45408256
in use bytes = 35097680 : 35M
max mmap regions = 47
max mmap bytes = 18116608
----
Total (incl. mmap):
system bytes = 438935552
in use bytes = 436116560 : 436M
max mmap regions = 65
max mmap bytes = 186437632
simplification SMDS_SpacePosition (pas de double[3]) --> 418 -33 = 385M (git SMDS_SpacePosition)
----------------------------------------------------
Total (incl. mmap):
system bytes = 42582016
in use bytes = 32883552 : 33M
max mmap regions = 41
max mmap bytes = 16371712
----
Total (incl. mmap):
system bytes = 421728256
in use bytes = 418378000 : 418M
max mmap regions = 58
max mmap bytes = 183640064
sizeof(SMDS_MeshElement) 16
sizeof(SMDS_MeshNode) 24
sizeof(SMDS_MeshCell) 24
sizeof(SMDS_VolumeVtkNodes) 24
sizeof(SMDS_Position) 16
sizeof(SMDS_SpacePosition) 16
impact d'un int en plus dans SMDS_MeshElement --> 426 - 33 = 393M
---------------------------------------------
sizeof(SMDS_MeshElement) 24
sizeof(SMDS_MeshNode) 32 --> on retrouve bien les 8M
sizeof(SMDS_MeshCell) 24
sizeof(SMDS_VolumeVtkNodes) 24
sizeof(SMDS_Position) 16
sizeof(SMDS_SpacePosition) 16
Total (incl. mmap):
system bytes = 43192320
in use bytes = 32681088 : 33M
max mmap regions = 41
max mmap bytes = 16371712
----
Total (incl. mmap):
system bytes = 429334528
in use bytes = 426424576 : 426M
max mmap regions = 59
max mmap bytes = 184692736
remplacement std::set par std::vector dans SMESHDS_SubMesh --> 347 - 35 = 312M
----------------------------------------------------------
sizeof(SMDS_MeshElement) 24
sizeof(SMDS_MeshNode) 32
sizeof(SMDS_MeshCell) 24
sizeof(SMDS_VolumeVtkNodes) 24
sizeof(SMDS_Position) 16
sizeof(SMDS_SpacePosition) 16
Total (incl. mmap):
system bytes = 45404160
in use bytes = 35132160 --> 35M
max mmap regions = 49
max mmap bytes = 17723392
----
Total (incl. mmap):
system bytes = 349831168
in use bytes = 346885424 --> 347M
max mmap regions = 73
max mmap bytes = 204148736
Ce resultat est coherent avec une recherche de swap sur une machine a 8Go de memoire:
Cube a 270**3 mailles (~20M mailles) --> 6.2 Go (idem Debian Sarge et Ubuntu 9.10, 64 bits)
Le meme avec V5.1.3 --> 14 Go (swap)

115
src/SMDS/ObjectPool.hxx Normal file
View File

@ -0,0 +1,115 @@
#ifndef _OBJECTPOOL_HXX_
#define _OBJECTPOOL_HXX_
#include <vector>
#include <stack>
#include <iostream>
template<class X> class ObjectPool
{
private:
std::vector<X*> _chunkList;
std::vector<bool> _freeList;
int _nextFree;
int _maxAvail;
int _chunkSize;
int getNextFree()
{
for (int i = _nextFree; i < _maxAvail; i++)
if (_freeList[i] == true)
{
return i;
break;
}
return _maxAvail;
}
void checkDelete(int chunkId)
{
int i0 = _chunkSize * chunkId;
int i1 = _chunkSize * (chunkId + 1);
for (int i = i0; i < i1; i++)
if (_freeList[i] == false)
return;
std::cerr << "a chunk to delete" << std::endl;
// compactage des vecteurs un peu lourd, pas necessaire
//X* chunk = _chunkList[chunkId];
//delete [] chunk;
}
public:
ObjectPool(int nblk)
{
_chunkSize = nblk;
_nextFree = 0;
_maxAvail = 0;
_chunkList.clear();
_freeList.clear();
}
virtual ~ObjectPool()
{
for (int i = 0; i < _chunkList.size(); i++)
delete[] _chunkList[i];
}
X* getNew()
{
X *obj = 0;
_nextFree = getNextFree();
if (_nextFree == _maxAvail)
{
X* newChunk = new X[_chunkSize];
_chunkList.push_back(newChunk);
_freeList.insert(_freeList.end(), _chunkSize, true);
_maxAvail += _chunkSize;
_freeList[_nextFree] = false;
obj = newChunk; // &newChunk[0];
}
else
{
int chunkId = _nextFree / _chunkSize;
int rank = _nextFree - chunkId * _chunkSize;
_freeList[_nextFree] = false;
obj = _chunkList[chunkId] + rank; // &_chunkList[chunkId][rank];
}
//obj->init();
return obj;
}
void destroy(X* obj)
{
long adrobj = (long) (obj);
for (int i = 0; i < _chunkList.size(); i++)
{
X* chunk = _chunkList[i];
long adrmin = (long) (chunk);
if (adrobj < adrmin)
continue;
long adrmax = (long) (chunk + _chunkSize);
if (adrobj >= adrmax)
continue;
int rank = (adrobj - adrmin) / sizeof(X);
int toFree = i * _chunkSize + rank;
_freeList[toFree] = true;
if (toFree < _nextFree)
_nextFree = toFree;
//obj->clean();
//checkDelete(i); compactage non fait
break;
}
}
// void destroy(int toFree)
// {
// // no control 0<= toFree < _freeList.size()
// _freeList[toFree] = true;
// if (toFree < _nextFree)
// _nextFree = toFree;
// }
};
#endif

1981
src/SMDS/SMDS_Downward.cxx Normal file

File diff suppressed because it is too large Load Diff

363
src/SMDS/SMDS_Downward.hxx Normal file
View File

@ -0,0 +1,363 @@
/*
* SMDS_Downward.hxx
*
* Created on: Jun 3, 2010
* Author: prascle
*/
#ifndef SMDS_DOWNWARD_HXX_
#define SMDS_DOWNWARD_HXX_
#include "SMDS_UnstructuredGrid.hxx"
#include <vector>
#include <set>
typedef struct
{
int nodeIds[8]; //!< max number of nodes in a face or edge: quad quad = 8
int nbNodes;
unsigned char vtkType;
} ElemByNodesType; // TODO resize for polyhedrons
typedef struct
{
ElemByNodesType elems[6]; //!< max number of faces in a volume or edges in a face : hexahedron = 6
int nbElems;
} ListElemByNodesType; // TODO resize for polyhedrons
class DownIdType
{
public:
DownIdType(int a, unsigned char b) :
cellId(a), cellType(b)
{
}
int cellId;
unsigned char cellType;
};
struct DownIdCompare
{
bool operator ()(const DownIdType e1, const DownIdType e2) const
{
if (e1.cellId == e2.cellId)
return (e1.cellType < e2.cellType);
else
return (e1.cellId < e2.cellId);
}
};
class SMDS_Downward
{
friend class SMDS_UnstructuredGrid;
friend class SMDS_Down2D;
friend class SMDS_Down3D;
public:
virtual int getNumberOfDownCells(int cellId);
virtual const int* getDownCells(int cellId);
virtual const unsigned char* getDownTypes(int cellId);
virtual int getNumberOfUpCells(int cellId) = 0;
virtual const int* getUpCells(int cellId) = 0;
virtual const unsigned char* getUpTypes(int cellId) = 0;
virtual void getNodeIds(int cellId, std::set<int>& nodeSet) = 0;
int getVtkCellId(int cellId)
{
return _vtkCellIds[cellId];
}
int getMaxId()
{
return _maxId;
}
static int getCellDimension(unsigned char cellType);
protected:
SMDS_Downward(SMDS_UnstructuredGrid *grid, int nbDownCells);
~SMDS_Downward();
int addCell(int vtkId = -1);
virtual void initCell(int cellId);
virtual void allocate(int nbElems) = 0;
virtual void compactStorage() = 0;
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType); //!< Id's are downward connectivity id's
virtual void addUpCell(int cellId, int upCellId, unsigned char aType); //!< Id's are downward connectivity id's
virtual int getNodeSet(int cellId, int* nodeSet);
SMDS_UnstructuredGrid* _grid;
int _maxId;
int _nbDownCells; //!< the same number for all cells of a derived class
std::vector<int> _cellIds; //!< growing size: all the down cell id's, size = _maxId * _nbDownCells
std::vector<int> _vtkCellIds; //!< growing size: size = _maxId, either vtkId or -1
std::vector<unsigned char> _cellTypes; //!< fixed size: the same vector for all cells of a derived class
static std::vector<int> _cellDimension; //!< conversion table: type --> dimension
};
class SMDS_Down1D: public SMDS_Downward
{
friend class SMDS_UnstructuredGrid;
public:
virtual int getNumberOfUpCells(int cellId);
virtual const int* getUpCells(int cellId);
virtual const unsigned char* getUpTypes(int cellId);
virtual void getNodeIds(int cellId, std::set<int>& nodeSet);
protected:
SMDS_Down1D(SMDS_UnstructuredGrid *grid, int nbDownCells);
~SMDS_Down1D();
virtual void initCell(int cellId);
virtual void allocate(int nbElems);
virtual void compactStorage();
virtual void addUpCell(int cellId, int upCellId, unsigned char aType); //!< Id's are downward connectivity id's
virtual int getNodeSet(int cellId, int* nodeSet);
void setNodes(int cellId, int vtkId);
void setNodes(int cellId, const int* nodeIds);
int computeVtkCells(int cellId, std::vector<int>& vtkIds);
int computeVtkCells(int* pts, std::vector<int>& vtkIds);
int computeFaces(int cellId, int* vtkIds, int nbcells, int* downFaces, unsigned char* downTypes);
int computeFaces(int* pts, int* vtkIds, int nbcells, int* downFaces, unsigned char* downTypes);
std::vector<std::vector<int> > _upCellIdsVector; //!< the number of faces sharing an edge is not known
std::vector<std::vector<unsigned char> > _upCellTypesVector; //!< the number of faces sharing an edge is not known
std::vector<int> _upCellIds; //!< compacted storage after connectivity calculation
std::vector<unsigned char> _upCellTypes; //!< compacted storage after connectivity calculation
std::vector<int> _upCellIndex; //!< compacted storage after connectivity calculation
};
class SMDS_Down2D: public SMDS_Downward
{
friend class SMDS_UnstructuredGrid;
friend class SMDS_Down1D;
public:
virtual int getNumberOfUpCells(int cellId);
virtual const int* getUpCells(int cellId);
virtual const unsigned char* getUpTypes(int cellId);
virtual void getNodeIds(int cellId, std::set<int>& nodeSet);
protected:
SMDS_Down2D(SMDS_UnstructuredGrid *grid, int nbDownCells);
~SMDS_Down2D();
virtual void allocate(int nbElems);
virtual void compactStorage();
virtual void addUpCell(int cellId, int upCellId, unsigned char aType);
virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& facesWithNodes) = 0;
virtual int getNodeSet(int cellId, int* nodeSet);
int computeVolumeIds(int cellId, int* ids);
int computeVolumeIds(ElemByNodesType& faceByNodes, int* ids);
int computeVolumeIdsFromNodesFace(int* nodes, int nbNodes, int* ids);
void setTempNodes(int cellId, int vtkId);
void setTempNodes(int cellId, ElemByNodesType& faceByNodes);
bool isInFace(int cellId, int *pts, int npts);
int FindEdgeByNodes(int cellId, ElemByNodesType& edgeByNodes);
std::vector<int> _upCellIds; //!< 2 volumes max. per face
std::vector<unsigned char> _upCellTypes; //!< 2 volume types per face
std::vector<int> _tempNodes; //!< temporary storage of nodes, until downward connectivity completion
int _nbNodes; //!< number of nodes in a face
};
class SMDS_Down3D: public SMDS_Downward
{
friend class SMDS_UnstructuredGrid;
public:
virtual int getNumberOfUpCells(int cellId);
virtual const int* getUpCells(int cellId);
virtual const unsigned char* getUpTypes(int cellId);
virtual void getNodeIds(int cellId, std::set<int>& nodeSet);
virtual void getOrderedNodesOfFace(int cellId, std::vector<int>& orderedNodes) = 0;
protected:
SMDS_Down3D(SMDS_UnstructuredGrid *grid, int nbDownCells);
~SMDS_Down3D();
virtual void allocate(int nbElems);
virtual void compactStorage();
virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes) = 0;
int FindFaceByNodes(int cellId, ElemByNodesType& faceByNodes);
};
class SMDS_DownEdge: public SMDS_Down1D
{
friend class SMDS_UnstructuredGrid;
public:
protected:
SMDS_DownEdge(SMDS_UnstructuredGrid *grid);
~SMDS_DownEdge();
};
class SMDS_DownQuadEdge: public SMDS_Down1D
{
friend class SMDS_UnstructuredGrid;
public:
protected:
SMDS_DownQuadEdge(SMDS_UnstructuredGrid *grid);
~SMDS_DownQuadEdge();
};
class SMDS_DownTriangle: public SMDS_Down2D
{
friend class SMDS_UnstructuredGrid;
public:
protected:
SMDS_DownTriangle(SMDS_UnstructuredGrid *grid);
~SMDS_DownTriangle();
virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType); //!< Id's are downward connectivity id's
};
class SMDS_DownQuadTriangle: public SMDS_Down2D
{
friend class SMDS_UnstructuredGrid;
public:
protected:
SMDS_DownQuadTriangle(SMDS_UnstructuredGrid *grid);
~SMDS_DownQuadTriangle();
virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType); //!< Id's are downward connectivity id's
};
class SMDS_DownQuadrangle: public SMDS_Down2D
{
friend class SMDS_UnstructuredGrid;
public:
protected:
SMDS_DownQuadrangle(SMDS_UnstructuredGrid *grid);
~SMDS_DownQuadrangle();
virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType); //!< Id's are downward connectivity id's
};
class SMDS_DownQuadQuadrangle: public SMDS_Down2D
{
friend class SMDS_UnstructuredGrid;
public:
protected:
SMDS_DownQuadQuadrangle(SMDS_UnstructuredGrid *grid);
~SMDS_DownQuadQuadrangle();
virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType); //!< Id's are downward connectivity id's
};
//class SMDS_DownPolygon: public SMDS_Down2D
//{
//public:
// SMDS_DownPolygon(SMDS_UnstructuredGrid *grid);
// ~SMDS_DownPolygon();
//protected:
//};
//class SMDS_DownQuadPolygon: public SMDS_Down2D
//{
//public:
// SMDS_DownQuadPolygon(SMDS_UnstructuredGrid *grid);
// ~SMDS_DownQuadPolygon();
//protected:
//};
class SMDS_DownTetra: public SMDS_Down3D
{
friend class SMDS_UnstructuredGrid;
public:
virtual void getOrderedNodesOfFace(int cellId, std::vector<int>& orderedNodes);
protected:
SMDS_DownTetra(SMDS_UnstructuredGrid *grid);
~SMDS_DownTetra();
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
};
class SMDS_DownQuadTetra: public SMDS_Down3D
{
friend class SMDS_UnstructuredGrid;
public:
virtual void getOrderedNodesOfFace(int cellId, std::vector<int>& orderedNodes);
protected:
SMDS_DownQuadTetra(SMDS_UnstructuredGrid *grid);
~SMDS_DownQuadTetra();
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
};
class SMDS_DownPyramid: public SMDS_Down3D
{
friend class SMDS_UnstructuredGrid;
public:
virtual void getOrderedNodesOfFace(int cellId, std::vector<int>& orderedNodes);
protected:
SMDS_DownPyramid(SMDS_UnstructuredGrid *grid);
~SMDS_DownPyramid();
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
};
class SMDS_DownQuadPyramid: public SMDS_Down3D
{
friend class SMDS_UnstructuredGrid;
public:
virtual void getOrderedNodesOfFace(int cellId, std::vector<int>& orderedNodes);
protected:
SMDS_DownQuadPyramid(SMDS_UnstructuredGrid *grid);
~SMDS_DownQuadPyramid();
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
};
class SMDS_DownPenta: public SMDS_Down3D
{
friend class SMDS_UnstructuredGrid;
public:
virtual void getOrderedNodesOfFace(int cellId, std::vector<int>& orderedNodes);
protected:
SMDS_DownPenta(SMDS_UnstructuredGrid *grid);
~SMDS_DownPenta();
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
};
class SMDS_DownQuadPenta: public SMDS_Down3D
{
friend class SMDS_UnstructuredGrid;
public:
virtual void getOrderedNodesOfFace(int cellId, std::vector<int>& orderedNodes);
protected:
SMDS_DownQuadPenta(SMDS_UnstructuredGrid *grid);
~SMDS_DownQuadPenta();
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
};
class SMDS_DownHexa: public SMDS_Down3D
{
friend class SMDS_UnstructuredGrid;
public:
virtual void getOrderedNodesOfFace(int cellId, std::vector<int>& orderedNodes);
protected:
SMDS_DownHexa(SMDS_UnstructuredGrid *grid);
~SMDS_DownHexa();
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
};
class SMDS_DownQuadHexa: public SMDS_Down3D
{
friend class SMDS_UnstructuredGrid;
public:
virtual void getOrderedNodesOfFace(int cellId, std::vector<int>& orderedNodes);
protected:
SMDS_DownQuadHexa(SMDS_UnstructuredGrid *grid);
~SMDS_DownQuadHexa();
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
};
//class SMDS_DownPolyhedra: public SMDS_Down3D
//{
//public:
// SMDS_DownPolyhedra(SMDS_UnstructuredGrid *grid);
// ~SMDS_DownPolyhedra();
//protected:
//};
//class SMDS_DownQuadPolyhedra: public SMDS_Down3D
//{
//public:
// SMDS_DownQuadPolyhedra(SMDS_UnstructuredGrid *grid);
// ~SMDS_DownQuadPolyhedra();
//protected:
//};
#endif /* SMDS_DOWNWARD_HXX_ */

View File

@ -36,32 +36,22 @@ using namespace std;
//purpose :
//=======================================================================
SMDS_EdgePosition::SMDS_EdgePosition(const int aEdgeId,
const double aUParam):SMDS_Position(aEdgeId), myUParameter(aUParam)
SMDS_EdgePosition::SMDS_EdgePosition(const double aUParam): myUParameter(aUParam)
{
}
//=======================================================================
//function : Coords
//purpose :
//=======================================================================
const double *SMDS_EdgePosition::Coords() const
{
static double origin[]={0,0,0};
MESSAGE("SMDS_EdgePosition::Coords not implemented");
return origin;
//MESSAGE("********************************* SMDS_EdgePosition " << myUParameter);
}
/**
*/
SMDS_TypeOfPosition SMDS_EdgePosition::GetTypeOfPosition() const
{
//MESSAGE("###################################### SMDS_EdgePosition::GetTypeOfPosition");
return SMDS_TOP_EDGE;
}
void SMDS_EdgePosition::SetUParameter(double aUparam)
{
//MESSAGE("############################### SMDS_EdgePosition::SetUParameter " << aUparam);
myUParameter = aUparam;
}
@ -72,5 +62,6 @@ void SMDS_EdgePosition::SetUParameter(double aUparam)
double SMDS_EdgePosition::GetUParameter() const
{
//MESSAGE("########################## SMDS_EdgePosition::GetUParameter " << myUParameter);
return myUParameter;
}

View File

@ -35,8 +35,7 @@ class SMDS_EXPORT SMDS_EdgePosition:public SMDS_Position
{
public:
SMDS_EdgePosition(const int aEdgeId=0, const double aUParam=0);
const virtual double * Coords() const;
SMDS_EdgePosition(const double aUParam=0);
SMDS_TypeOfPosition GetTypeOfPosition() const;
void SetUParameter(double aUparam);
double GetUParameter() const;

View File

@ -29,6 +29,7 @@
#include "SMDS_FaceOfEdges.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
#include "utilities.h"
using namespace std;
@ -111,6 +112,7 @@ SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
const SMDS_MeshEdge* edge2,
const SMDS_MeshEdge* edge3)
{
//MESSAGE("****************************************************** SMDS_FaceOfEdges");
myNbEdges = 3;
myEdges[0]=edge1;
myEdges[1]=edge2;
@ -123,6 +125,7 @@ SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
const SMDS_MeshEdge* edge3,
const SMDS_MeshEdge* edge4)
{
//MESSAGE("****************************************************** SMDS_FaceOfEdges");
myNbEdges = 4;
myEdges[0]=edge1;
myEdges[1]=edge2;

View File

@ -20,7 +20,7 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMDS : implementaion of Salome mesh data structure
// SMESH SMDS : implementation of Salome mesh data structure
//
#ifndef _SMDS_FaceOfEdges_HeaderFile
#define _SMDS_FaceOfEdges_HeaderFile
@ -48,6 +48,7 @@ class SMDS_EXPORT SMDS_FaceOfEdges:public SMDS_MeshFace
SMDSAbs_ElementType GetType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) {return false;};
int NbNodes() const;
int NbEdges() const;
int NbFaces() const;

View File

@ -133,6 +133,7 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
const SMDS_MeshNode* node2,
const SMDS_MeshNode* node3)
{
//MESSAGE("******************************************************* SMDS_FaceOfNodes");
myNbNodes = 3;
myNodes[0]=node1;
myNodes[1]=node2;
@ -145,6 +146,7 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
const SMDS_MeshNode* node3,
const SMDS_MeshNode* node4)
{
//MESSAGE("******************************************************* SMDS_FaceOfNodes");
myNbNodes = 4;
myNodes[0]=node1;
myNodes[1]=node2;

View File

@ -36,23 +36,11 @@ using namespace std;
//purpose :
//=======================================================================
SMDS_FacePosition::SMDS_FacePosition(const int aEdgeId,
const double aUParam,
SMDS_FacePosition::SMDS_FacePosition(const double aUParam,
const double aVParam)
:SMDS_Position(aEdgeId),
myUParameter(aUParam),myVParameter(aVParam)
: myUParameter(aUParam),myVParameter(aVParam)
{
}
//=======================================================================
//function : Coords
//purpose :
//=======================================================================
const double *SMDS_FacePosition::Coords() const
{
static double origin[]={0,0,0};
MESSAGE("SMDS_EdgePosition::Coords not implemented");
return origin;
//MESSAGE("******************************************************** SMDS_FacePosition");
}
/**

View File

@ -35,9 +35,7 @@ class SMDS_EXPORT SMDS_FacePosition:public SMDS_Position
{
public:
SMDS_FacePosition(int aFaceId=0, double aUParam=0,
double aVParam=0);
const virtual double * Coords() const;
SMDS_FacePosition(double aUParam=0, double aVParam=0);
SMDS_TypeOfPosition GetTypeOfPosition() const;
void SetUParameter(double aUparam);
void SetVParameter(double aVparam);

View File

@ -0,0 +1,163 @@
// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMDS : implementaion of Salome mesh data structure
// File : SMDS_LinearEdge.cxx
// Author : Jean-Michel BOULCOURT
// Module : SMESH
//
#ifdef _MSC_VER
#pragma warning(disable:4786)
#endif
#include "SMDS_LinearEdge.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
#include "utilities.h"
using namespace std;
//=======================================================================
//function : SMDS_LinearEdge
//purpose :
//=======================================================================
SMDS_LinearEdge::SMDS_LinearEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2)
{
//MESSAGE("SMDS_LinearEdge " << GetID());
myNodes[0] = node1;
myNodes[1] = node2;
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_LinearEdge::Print(ostream & OS) const
{
OS << "edge <" << GetID() << "> : (" << myNodes[0] << " , " << myNodes[1]
<< ") " << endl;
}
int SMDS_LinearEdge::NbNodes() const
{
return 2;
}
int SMDS_LinearEdge::NbEdges() const
{
return 1;
}
class SMDS_LinearEdge_MyNodeIterator: public SMDS_ElemIterator
{
const SMDS_MeshNode * const * myNodes;
int myIndex;
public:
SMDS_LinearEdge_MyNodeIterator(const SMDS_MeshNode * const * nodes) :
myNodes(nodes), myIndex(0)
{
}
bool more()
{
return myIndex < 2;
}
const SMDS_MeshElement* next()
{
myIndex++;
return myNodes[myIndex - 1];
}
};
SMDS_ElemIteratorPtr SMDS_LinearEdge::elementsIterator(SMDSAbs_ElementType type) const
{
switch (type)
{
case SMDSAbs_Edge:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Edge);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new SMDS_LinearEdge_MyNodeIterator(myNodes));
default:
return SMDS_ElemIteratorPtr(
new SMDS_IteratorOfElements(
this,
type,
SMDS_ElemIteratorPtr(
new SMDS_LinearEdge_MyNodeIterator(
myNodes))));
}
}
bool operator<(const SMDS_LinearEdge & e1, const SMDS_LinearEdge & e2)
{
int id11 = e1.myNodes[0]->getVtkId();
int id21 = e2.myNodes[0]->getVtkId();
int id12 = e1.myNodes[1]->getVtkId();
int id22 = e2.myNodes[1]->getVtkId();
int tmp;
if (id11 >= id12)
{
tmp = id11;
id11 = id12;
id12 = tmp;
}
if (id21 >= id22)
{
tmp = id21;
id21 = id22;
id22 = tmp;
}
if (id11 < id21)
return true;
else if (id11 == id21)
return (id21 < id22);
else
return false;
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
const SMDS_MeshNode* SMDS_LinearEdge::GetNode(const int ind) const
{
return myNodes[ind];
}
//=======================================================================
//function : ChangeNodes
//purpose :
//=======================================================================
bool SMDS_LinearEdge::ChangeNodes(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2)
{
myNodes[0] = node1;
myNodes[1] = node2;
return true;
}

View File

@ -0,0 +1,69 @@
// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMDS : implementaion of Salome mesh data structure
// File : SMDS_LinearEdge.hxx
// Module : SMESH
//
#ifndef _SMDS_LinearEdge_HeaderFile
#define _SMDS_LinearEdge_HeaderFile
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshEdge.hxx"
#include <iostream>
class SMDS_EXPORT SMDS_LinearEdge: public SMDS_MeshEdge
{
public:
SMDS_LinearEdge(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2);
bool ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2);
void Print(std::ostream & OS) const;
virtual SMDSAbs_EntityType GetEntityType() const
{
return SMDSEntity_Edge;
}
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
return false;
}
int NbNodes() const;
int NbEdges() const;
friend bool operator<(const SMDS_LinearEdge& e1, const SMDS_LinearEdge& e2);
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
protected:
const SMDS_MeshNode* myNodes[3];
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -30,23 +30,47 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_MeshCell.hxx"
#include "SMDS_Mesh0DElement.hxx"
#include "SMDS_MeshEdge.hxx"
#include "SMDS_MeshFace.hxx"
#include "SMDS_MeshVolume.hxx"
#include "SMDS_MeshNodeIDFactory.hxx"
#include "SMDS_MeshElementIDFactory.hxx"
#include "SMDS_MeshInfo.hxx"
#include "SMDS_ElemIterator.hxx"
#include <NCollection_Map.hxx>
#include "SMDS_VolumeOfNodes.hxx"
#include "SMDS_VtkEdge.hxx"
#include "SMDS_VtkFace.hxx"
#include "SMDS_VtkVolume.hxx"
#include "ObjectPool.hxx"
#include "SMDS_UnstructuredGrid.hxx"
#include <boost/shared_ptr.hpp>
#include <set>
#include <list>
#include <vector>
#include <vtkSystemIncludes.h>
#include "Utils_SALOME_Exception.hxx"
#define MYASSERT(val) if (!(val)) throw SALOME_Exception(LOCALIZED("assertion not verified"));
class SMDS_EXPORT SMDS_Mesh:public SMDS_MeshObject{
public:
friend class SMDS_MeshIDFactory;
friend class SMDS_MeshNodeIDFactory;
friend class SMDS_MeshElementIDFactory;
friend class SMDS_MeshVolumeVtkNodes;
friend class SMDS_MeshNode;
SMDS_Mesh();
//! to retreive this SMDS_Mesh instance from its elements (index stored in SMDS_Elements)
static std::vector<SMDS_Mesh*> _meshList;
//! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
inline SMDS_UnstructuredGrid* getGrid() {return myGrid; };
inline int getMeshId() {return myMeshId; };
SMDS_NodeIteratorPtr nodesIterator (bool idInceasingOrder=false) const;
SMDS_0DElementIteratorPtr elements0dIterator(bool idInceasingOrder=false) const;
@ -420,6 +444,11 @@ public:
(std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities);
virtual SMDS_MeshVolume* AddVolumeFromVtkIds(const std::vector<int>& vtkNodeIds);
virtual SMDS_MeshVolume* AddVolumeFromVtkIdsWithID(const std::vector<int>& vtkNodeIds,
const int ID);
virtual void RemoveElement(const SMDS_MeshElement * elem,
std::list<const SMDS_MeshElement *>& removedElems,
std::list<const SMDS_MeshElement *>& removedNodes,
@ -451,8 +480,10 @@ public:
virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
// Renumber all nodes or elements.
virtual void compactMesh();
const SMDS_MeshNode *FindNode(int idnode) const;
const SMDS_MeshNode *FindNodeVtk(int idnode) const;
const SMDS_Mesh0DElement* Find0DElement(int idnode) const;
const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const;
const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2, int idnode3) const;
@ -541,23 +572,40 @@ public:
*/
bool Contains (const SMDS_MeshElement* elem) const;
typedef NCollection_Map<SMDS_MeshNode *> SetOfNodes;
typedef NCollection_Map<SMDS_Mesh0DElement *> SetOf0DElements;
typedef NCollection_Map<SMDS_MeshEdge *> SetOfEdges;
typedef NCollection_Map<SMDS_MeshFace *> SetOfFaces;
typedef NCollection_Map<SMDS_MeshVolume *> SetOfVolumes;
typedef std::vector<SMDS_MeshNode *> SetOfNodes;
typedef std::vector<SMDS_MeshCell *> SetOfCells;
private:
void updateNodeMinMax();
void updateBoundingBox();
double getMaxDim();
int fromVtkToSmds(int vtkid);
void incrementNodesCapacity(int nbNodes);
void incrementCellsCapacity(int nbCells);
void adjustStructure();
void dumpGrid(string ficdump="dumpGrid");
static int chunkSize;
//! low level modification: add, change or remove node or element
inline void setMyModified() { this->myModified = true; };
void Modified();
unsigned long GetMTime();
bool isCompacted();
protected:
SMDS_Mesh(SMDS_Mesh * parent);
SMDS_MeshFace * createTriangle(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node3);
const SMDS_MeshNode * node3,
int ID);
SMDS_MeshFace * createQuadrangle(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node3,
const SMDS_MeshNode * node4);
SMDS_Mesh0DElement* Find0DElementOrCreate(const SMDS_MeshNode * n);
const SMDS_MeshNode * node4,
int ID);
// SMDS_Mesh0DElement* Find0DElementOrCreate(const SMDS_MeshNode * n);
SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2);
SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1,
@ -574,22 +622,77 @@ private:
const SMDS_MeshElement * element,
std::set<const SMDS_MeshElement*>& nodes);
inline void adjustmyCellsCapacity(int ID)
{
assert(ID >= 0);
myElementIDFactory->adjustMaxId(ID);
if (ID >= myCells.size())
myCells.resize(ID+SMDS_Mesh::chunkSize,0);
};
inline void adjustBoundingBox(double x, double y, double z)
{
if (x > xmax) xmax = x;
else if (x < xmin) xmin = x;
if (y > ymax) ymax = y;
else if (y < ymin) ymin = y;
if (z > zmax) zmax = z;
else if (z < zmin) zmin = z;
};
// Fields PRIVATE
//! index of this SMDS_mesh in the static vector<SMDS_Mesh*> _meshList
int myMeshId;
//! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
SMDS_UnstructuredGrid* myGrid;
//! Small objects like SMDS_MeshNode are allocated by chunks to limit memory costs of new
ObjectPool<SMDS_MeshNode>* myNodePool;
//! Small objects like SMDS_VtkVolume are allocated by chunks to limit memory costs of new
ObjectPool<SMDS_VtkVolume>* myVolumePool;
ObjectPool<SMDS_VtkFace>* myFacePool;
ObjectPool<SMDS_VtkEdge>* myEdgePool;
//! SMDS_MeshNodes refer to vtk nodes (vtk id = index in myNodes),store reference to this mesh, and subshape
SetOfNodes myNodes;
SetOf0DElements my0DElements;
SetOfEdges myEdges;
SetOfFaces myFaces;
SetOfVolumes myVolumes;
//! SMDS_MeshCells refer to vtk cells (vtk id != index in myCells),store reference to this mesh, and subshape
SetOfCells myCells;
//! for cells only: index = ID for SMDS users, value = ID in vtkUnstructuredGrid
//std::vector<int> myCellIdSmdsToVtk;
//! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users
std::vector<int> myCellIdVtkToSmds;
SMDS_Mesh * myParent;
std::list<SMDS_Mesh *> myChildren;
SMDS_MeshElementIDFactory *myNodeIDFactory;
SMDS_MeshNodeIDFactory *myNodeIDFactory;
SMDS_MeshElementIDFactory *myElementIDFactory;
SMDS_MeshInfo myInfo;
//! use a counter to keep track of modifications
unsigned long myModifTime, myCompactTime;
int myNodeMin;
int myNodeMax;
bool myHasConstructionEdges;
bool myHasConstructionFaces;
bool myHasInverseElements;
//! any add, remove or change of node or cell
bool myModified;
double xmin;
double xmax;
double ymin;
double ymax;
double zmin;
double zmax;
};

View File

@ -29,6 +29,7 @@
#include "SMDS_Mesh0DElement.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
#include "utilities.h"
using namespace std;
@ -37,7 +38,8 @@ using namespace std;
//purpose :
//=======================================================================
SMDS_Mesh0DElement::SMDS_Mesh0DElement (const SMDS_MeshNode * node)
{
{
MESSAGE("SMDS_Mesh0DElement " << GetID());
myNode = node;
}
@ -77,6 +79,11 @@ SMDSAbs_ElementType SMDS_Mesh0DElement::GetType() const
return SMDSAbs_0DElement;
}
vtkIdType SMDS_Mesh0DElement::GetVtkType() const
{
return VTK_VERTEX;
}
//=======================================================================
//function : elementsIterator
//purpose :
@ -124,8 +131,8 @@ SMDS_ElemIteratorPtr SMDS_Mesh0DElement::elementsIterator (SMDSAbs_ElementType t
//=======================================================================
bool operator< (const SMDS_Mesh0DElement & e1, const SMDS_Mesh0DElement & e2)
{
int id1 = e1.myNode->GetID();
int id2 = e2.myNode->GetID();
int id1 = e1.myNode->getVtkId();
int id2 = e2.myNode->getVtkId();
return (id1 < id2);
}

View File

@ -26,18 +26,20 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshCell.hxx"
#include <iostream>
class SMDS_EXPORT SMDS_Mesh0DElement: public SMDS_MeshElement
class SMDS_EXPORT SMDS_Mesh0DElement: public SMDS_MeshCell
{
public:
SMDS_Mesh0DElement (const SMDS_MeshNode * node);
bool ChangeNode (const SMDS_MeshNode * node);
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) {return false;};
void Print (std::ostream & OS) const;
SMDSAbs_ElementType GetType() const;
virtual vtkIdType GetVtkType() const;
SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_0D;}
int NbNodes() const;
int NbEdges() const;

View File

@ -0,0 +1,18 @@
#include "SMDS_MeshCell.hxx"
#include "utilities.h"
using namespace std;
int SMDS_MeshCell::nbCells = 0;
SMDS_MeshCell::SMDS_MeshCell() :
SMDS_MeshElement(-1)
{
nbCells++;
myVtkID = -1;
}
SMDS_MeshCell::~SMDS_MeshCell()
{
nbCells--;
}

View File

@ -0,0 +1,30 @@
#ifndef _SMDS_MESHCELL_HXX_
#define _SMDS_MESHCELL_HXX_
#include "SMDS_MeshElement.hxx"
/*!
* \brief Base class for all cells
*/
class SMDS_EXPORT SMDS_MeshCell: public SMDS_MeshElement
{
public:
SMDS_MeshCell();
virtual ~SMDS_MeshCell();
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)= 0;
virtual bool vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes) {return true; };
static int nbCells;
protected:
inline void exchange(const SMDS_MeshNode* nodes[],int a, int b)
{
const SMDS_MeshNode* noda = nodes[a];
nodes[a] = nodes[b];
nodes[b] = noda;
}
};
#endif

View File

@ -1,159 +1,11 @@
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMDS : implementaion of Salome mesh data structure
// File : SMDS_MeshEdge.cxx
// Author : Jean-Michel BOULCOURT
// Module : SMESH
//
#ifdef _MSC_VER
#pragma warning(disable:4786)
#endif
#include "SMDS_MeshEdge.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
using namespace std;
//=======================================================================
//function : SMDS_MeshEdge
//purpose :
//=======================================================================
SMDS_MeshEdge::SMDS_MeshEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2)
{
myNodes[0]=node1;
myNodes[1]=node2;
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_MeshEdge::Print(ostream & OS) const
{
OS << "edge <" << GetID() << "> : (" << myNodes[0] << " , " << myNodes[1] <<
") " << endl;
}
int SMDS_MeshEdge::NbNodes() const
{
return 2;
}
int SMDS_MeshEdge::NbEdges() const
{
return 1;
}
SMDSAbs_ElementType SMDS_MeshEdge::GetType() const
{
return SMDSAbs_Edge;
return SMDSAbs_Edge;
}
class SMDS_MeshEdge_MyNodeIterator:public SMDS_ElemIterator
vtkIdType SMDS_MeshEdge::GetVtkType() const
{
const SMDS_MeshNode *const* myNodes;
int myIndex;
public:
SMDS_MeshEdge_MyNodeIterator(const SMDS_MeshNode * const* nodes):
myNodes(nodes),myIndex(0) {}
bool more()
{
return myIndex<2;
}
const SMDS_MeshElement* next()
{
myIndex++;
return myNodes[myIndex-1];
}
};
SMDS_ElemIteratorPtr SMDS_MeshEdge::
elementsIterator(SMDSAbs_ElementType type) const
{
switch(type)
{
case SMDSAbs_Edge:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Edge);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new SMDS_MeshEdge_MyNodeIterator(myNodes));
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type, SMDS_ElemIteratorPtr(new SMDS_MeshEdge_MyNodeIterator(myNodes))));
}
}
bool operator<(const SMDS_MeshEdge & e1, const SMDS_MeshEdge & e2)
{
int id11=e1.myNodes[0]->GetID();
int id21=e2.myNodes[0]->GetID();
int id12=e1.myNodes[1]->GetID();
int id22=e2.myNodes[1]->GetID();
int tmp;
if(id11>=id12)
{
tmp=id11;
id11=id12;
id12=tmp;
}
if(id21>=id22)
{
tmp=id21;
id21=id22;
id22=tmp;
}
if(id11<id21) return true;
else if(id11==id21) return (id21<id22);
else return false;
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
const SMDS_MeshNode* SMDS_MeshEdge::GetNode(const int ind) const
{
return myNodes[ ind ];
}
//=======================================================================
//function : ChangeNodes
//purpose :
//=======================================================================
bool SMDS_MeshEdge::ChangeNodes(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2)
{
myNodes[0]=node1;
myNodes[1]=node2;
return true;
return VTK_POLY_VERTEX; // --- must be reimplemented in derived classes
}

View File

@ -29,38 +29,13 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshElement.hxx"
#include <iostream>
#include "SMDS_MeshCell.hxx"
class SMDS_EXPORT SMDS_MeshEdge:public SMDS_MeshElement
class SMDS_EXPORT SMDS_MeshEdge:public SMDS_MeshCell
{
public:
SMDS_MeshEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2);
bool ChangeNodes(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2);
void Print(std::ostream & OS) const;
virtual SMDSAbs_ElementType GetType() const;
virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Edge; }
int NbNodes() const;
int NbEdges() const;
friend bool operator<(const SMDS_MeshEdge& e1, const SMDS_MeshEdge& e2);
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
protected:
const SMDS_MeshNode* myNodes[3];
SMDSAbs_ElementType GetType() const;
virtual vtkIdType GetVtkType() const;
};
#endif

View File

@ -35,7 +35,12 @@
using namespace std;
SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID)
SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID), myMeshId(-1), myShapeId(0), myIdInShape(-1)
{
}
SMDS_MeshElement::SMDS_MeshElement(int id, ShortType meshId, ShortType shapeId):
myID(id), myMeshId(meshId), myShapeId(shapeId), myIdInShape(-1)
{
}
@ -146,6 +151,7 @@ class SMDS_MeshElement_MyIterator:public SMDS_ElemIterator
return myElement;
}
};
SMDS_ElemIteratorPtr SMDS_MeshElement::
elementsIterator(SMDSAbs_ElementType type) const
{
@ -162,12 +168,18 @@ SMDS_ElemIteratorPtr SMDS_MeshElement::
}
}
///////////////////////////////////////////////////////////////////////////////
///Return the ID of the element
///////////////////////////////////////////////////////////////////////////////
int SMDS_MeshElement::GetID() const
//! virtual, redefined in vtkEdge, vtkFace and vtkVolume classes
SMDS_ElemIteratorPtr SMDS_MeshElement::nodesIteratorToUNV() const
{
return myID;
MESSAGE("Iterator not implemented");
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
}
//! virtual, redefined in vtkEdge, vtkFace and vtkVolume classes
SMDS_ElemIteratorPtr SMDS_MeshElement::interlacedNodesElemIterator() const
{
MESSAGE("Iterator not implemented");
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
}
bool operator<(const SMDS_MeshElement& e1, const SMDS_MeshElement& e2)

View File

@ -38,9 +38,16 @@
#include <vector>
#include <iostream>
#include <vtkType.h>
#include <vtkCellType.h>
//typedef unsigned short UShortType;
typedef short ShortType;
class SMDS_MeshNode;
class SMDS_MeshEdge;
class SMDS_MeshFace;
class SMDS_MeshFace;
class SMDS_Mesh;
// ============================================================
/*!
@ -48,6 +55,7 @@ class SMDS_MeshFace;
*/
// ============================================================
class SMDS_EXPORT SMDS_MeshElement:public SMDS_MeshObject
{
public:
@ -56,6 +64,8 @@ public:
SMDS_ElemIteratorPtr edgesIterator() const;
SMDS_ElemIteratorPtr facesIterator() const;
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
// std-like iteration on nodes
typedef SMDS_StdIterator< const SMDS_MeshNode*, SMDS_ElemIteratorPtr > iterator;
@ -65,11 +75,12 @@ public:
virtual int NbNodes() const;
virtual int NbEdges() const;
virtual int NbFaces() const;
int GetID() const;
inline int GetID() const { return myID; };
///Return the type of the current element
virtual SMDSAbs_ElementType GetType() const = 0;
virtual bool IsPoly() const { return false; }
virtual vtkIdType GetVtkType() const = 0;
virtual bool IsPoly() const { return false; };
virtual bool IsQuadratic() const;
//! Return type of entity
virtual SMDSAbs_EntityType GetEntityType() const = 0;
@ -78,7 +89,11 @@ public:
virtual int NbCornerNodes() const;
friend SMDS_EXPORT std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem);
friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement* elem);
friend class SMDS_Mesh;
friend class SMESHDS_Mesh;
friend class SMESHDS_SubMesh;
friend class SMDS_MeshElementIDFactory;
// ===========================
// Access to nodes by index
@ -124,14 +139,33 @@ public:
*/
int GetNodeIndex( const SMDS_MeshNode* node ) const;
inline ShortType getMeshId() const {return myMeshId; };
inline ShortType getshapeId() const {return myShapeId; };
inline int getIdInShape() const { return myIdInShape; };
inline int getVtkId() const { return myVtkID; };
protected:
inline void setId(int id) {myID = id; };
inline void setShapeId(ShortType shapeId) {myShapeId = shapeId; };
inline void setIdInShape(int id) { myIdInShape = id; };
inline void setVtkId(int vtkId) { myVtkID = vtkId; };
SMDS_MeshElement(int ID=-1);
SMDS_MeshElement(int id, ShortType meshId, ShortType shapeId = 0);
virtual void Print(std::ostream & OS) const;
private:
//! Element index in vector SMDS_Mesh::myNodes or SMDS_Mesh::myCells
int myID;
//! index in vtkUnstructuredGrid
int myVtkID;
//! SMDS_Mesh identification in SMESH
ShortType myMeshId;
//! SubShape and SubMesh identification in SMESHDS
ShortType myShapeId;
//! Element index in SMESHDS_SubMesh vector
int myIdInShape;
};
// ============================================================
/*!
* \brief Comparator of elements by ID for usage in std containers

View File

@ -31,6 +31,12 @@
#include "SMDS_MeshElementIDFactory.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_Mesh.hxx"
#include "utilities.h"
#include <SMDS_UnstructuredGrid.hxx>
#include <vtkCellType.h>
using namespace std;
@ -39,86 +45,110 @@ using namespace std;
//purpose :
//=======================================================================
SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
SMDS_MeshIDFactory(),
myMin(0), myMax(0)
SMDS_MeshNodeIDFactory()
{
// myIDElements.clear();
// myVtkIndex.clear();
myVtkCellTypes.clear();
myVtkCellTypes.reserve(SMDSEntity_Last);
myVtkCellTypes[SMDSEntity_Node] = VTK_VERTEX;
myVtkCellTypes[SMDSEntity_0D] = VTK_VERTEX;
myVtkCellTypes[SMDSEntity_Edge] = VTK_LINE;
myVtkCellTypes[SMDSEntity_Quad_Edge] = VTK_QUADRATIC_EDGE;
myVtkCellTypes[SMDSEntity_Triangle] = VTK_TRIANGLE;
myVtkCellTypes[SMDSEntity_Quad_Triangle] = VTK_QUADRATIC_TRIANGLE;
myVtkCellTypes[SMDSEntity_Quadrangle] = VTK_QUAD;
myVtkCellTypes[SMDSEntity_Quad_Quadrangle] = VTK_QUADRATIC_TRIANGLE;
myVtkCellTypes[SMDSEntity_Polygon] = VTK_POLYGON;
myVtkCellTypes[SMDSEntity_Quad_Polygon] = VTK_POLYGON; // -PR- verifer
myVtkCellTypes[SMDSEntity_Tetra] = VTK_TETRA;
myVtkCellTypes[SMDSEntity_Quad_Tetra] = VTK_QUADRATIC_TETRA;
myVtkCellTypes[SMDSEntity_Pyramid] = VTK_PYRAMID;
myVtkCellTypes[SMDSEntity_Quad_Pyramid] = VTK_CONVEX_POINT_SET;
myVtkCellTypes[SMDSEntity_Hexa] = VTK_HEXAHEDRON;
myVtkCellTypes[SMDSEntity_Quad_Hexa] = VTK_QUADRATIC_HEXAHEDRON;
myVtkCellTypes[SMDSEntity_Penta] = VTK_WEDGE;
myVtkCellTypes[SMDSEntity_Quad_Penta] = VTK_QUADRATIC_WEDGE;
//#ifdef VTK_HAVE_POLYHEDRON
myVtkCellTypes[SMDSEntity_Polyhedra] = VTK_POLYHEDRON;
//#else
// myVtkCellTypes[SMDSEntity_Polyhedra] = VTK_CONVEX_POINT_SET;
//#endif
myVtkCellTypes[SMDSEntity_Quad_Polyhedra] = VTK_CONVEX_POINT_SET;
}
int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem)
{
// --- retrieve nodes ID
SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(elem);
assert(cell);
vector<vtkIdType> nodeIds;
SMDS_ElemIteratorPtr it = elem->nodesIterator();
while(it->more())
{
int nodeId = (static_cast<const SMDS_MeshNode*>(it->next()))->getVtkId();
MESSAGE(" node in cell " << cell->getVtkId() << " : " << nodeId)
nodeIds.push_back(nodeId);
}
// --- insert cell in vtkUnstructuredGrid
vtkUnstructuredGrid * grid = myMesh->getGrid();
int typ = GetVtkCellType(elem->GetType());
int cellId = grid->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]);
cell->setVtkId(cellId);
//MESSAGE("SMDS_MeshElementIDFactory::SetInVtkGrid " << cellId);
return cellId;
}
//=======================================================================
//function : BindID
//purpose :
//=======================================================================
bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
{
if (myIDElements.IsBound(ID))
return false;
myIDElements.Bind(ID,elem);
elem->myID=ID;
updateMinMax (ID);
return true;
MESSAGE("SMDS_MeshElementIDFactory::BindID " << ID);
SetInVtkGrid(elem);
return myMesh->registerElement(ID, elem);
}
//=======================================================================
//function : MeshElement
//purpose :
//=======================================================================
SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID) const
SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
{
if (!myIDElements.IsBound(ID))
if ((ID<1) || (ID>=myMesh->myCells.size()))
return NULL;
return myIDElements.Find(ID);
}
//=======================================================================
//function : GetFreeID
//purpose :
//=======================================================================
int SMDS_MeshElementIDFactory::GetFreeID()
{
int ID;
do {
ID = SMDS_MeshIDFactory::GetFreeID();
} while (myIDElements.IsBound(ID));
return ID;
const SMDS_MeshElement* elem = GetMesh()->FindElement(ID);
return (SMDS_MeshElement*)(elem);
}
//=======================================================================
//function : ReleaseID
//purpose :
//=======================================================================
void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
void SMDS_MeshElementIDFactory::ReleaseID(int ID, int vtkId)
{
myIDElements.UnBind(ID);
if (ID < 1) // TODO check case ID == O
{
MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID);
return;
}
//MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID smdsId vtkId " << ID << " " << vtkId);
if (vtkId >= 0)
{
assert(vtkId < myMesh->myCellIdVtkToSmds.size());
myMesh->myCellIdVtkToSmds[vtkId] = -1;
myMesh->setMyModified();
}
SMDS_MeshIDFactory::ReleaseID(ID);
if (ID == myMax)
myMax = 0;
if (ID == myMin)
myMin = 0;
}
//=======================================================================
//function : GetMaxID
//purpose :
//=======================================================================
int SMDS_MeshElementIDFactory::GetMaxID() const
{
if (myMax == 0)
updateMinMax();
return myMax;
}
//=======================================================================
//function : GetMinID
//purpose :
//=======================================================================
int SMDS_MeshElementIDFactory::GetMinID() const
{
if (myMin == 0)
updateMinMax();
return myMin;
myMax = 0;
}
//=======================================================================
@ -130,9 +160,17 @@ void SMDS_MeshElementIDFactory::updateMinMax() const
{
myMin = IntegerLast();
myMax = 0;
SMDS_IdElementMap::Iterator it(myIDElements);
for (; it.More(); it.Next())
updateMinMax (it.Key());
for (int i = 0; i < myMesh->myCells.size(); i++)
{
if (myMesh->myCells[i])
{
int id = myMesh->myCells[i]->GetID();
if (id > myMax)
myMax = id;
if (id < myMin)
myMin = id;
}
}
if (myMin == IntegerLast())
myMin = 0;
}
@ -142,35 +180,21 @@ void SMDS_MeshElementIDFactory::updateMinMax() const
//purpose : Return an iterator on elements of the factory
//=======================================================================
class SMDS_Fact_MyElemIterator:public SMDS_ElemIterator
{
SMDS_IdElementMap::Iterator myIterator;
public:
SMDS_Fact_MyElemIterator(const SMDS_IdElementMap& s):myIterator(s)
{}
bool more()
{
return myIterator.More() != Standard_False;
}
const SMDS_MeshElement* next()
{
const SMDS_MeshElement* current = myIterator.Value();
myIterator.Next();
return current;
}
};
SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const
{
return SMDS_ElemIteratorPtr
(new SMDS_Fact_MyElemIterator(myIDElements));
return myMesh->elementsIterator(SMDSAbs_All);
}
void SMDS_MeshElementIDFactory::Clear()
{
myIDElements.Clear();
//myMesh->myCellIdSmdsToVtk.clear();
myMesh->myCellIdVtkToSmds.clear();
myMin = myMax = 0;
SMDS_MeshIDFactory::Clear();
}
int SMDS_MeshElementIDFactory::GetVtkCellType(int SMDSType)
{
assert((SMDSType >=0) && (SMDSType< SMDSEntity_Last));
return myVtkCellTypes[SMDSType];
}

View File

@ -29,28 +29,28 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshIDFactory.hxx"
#include "SMDS_ElemIterator.hxx"
#include "SMDS_MeshNodeIDFactory.hxx"
#include <NCollection_DataMap.hxx>
#include <vector>
class SMDS_MeshElement;
class SMDS_Mesh;
typedef NCollection_DataMap<int, SMDS_MeshElement *> SMDS_IdElementMap;
class SMDS_EXPORT SMDS_MeshElementIDFactory:public SMDS_MeshIDFactory
class SMDS_EXPORT SMDS_MeshElementIDFactory:public SMDS_MeshNodeIDFactory
{
public:
friend class SMDS_Mesh;
SMDS_MeshElementIDFactory();
bool BindID(int ID, SMDS_MeshElement * elem);
SMDS_MeshElement * MeshElement(int ID) const;
virtual int GetFreeID();
virtual void ReleaseID(int ID);
int GetMaxID() const;
int GetMinID() const;
int SetInVtkGrid(SMDS_MeshElement * elem);
SMDS_MeshElement * MeshElement(int ID);
virtual void ReleaseID(int ID, int vtkId = -1);
SMDS_ElemIteratorPtr elementsIterator() const;
virtual void Clear();
private:
int GetVtkCellType(int SMDSType);
protected:
void updateMinMax() const;
void updateMinMax(int id) const
{
@ -58,8 +58,7 @@ private:
if (id < myMin) myMin = id;
}
SMDS_IdElementMap myIDElements;
mutable int myMin, myMax;
std::vector<int> myVtkCellTypes;
};

View File

@ -28,3 +28,8 @@ SMDSAbs_ElementType SMDS_MeshFace::GetType() const
{
return SMDSAbs_Face;
}
vtkIdType SMDS_MeshFace::GetVtkType() const
{
return VTK_POLY_LINE; // --- must be reimplemented in derived classes
}

View File

@ -29,12 +29,13 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshCell.hxx"
class SMDS_EXPORT SMDS_MeshFace:public SMDS_MeshElement
class SMDS_EXPORT SMDS_MeshFace:public SMDS_MeshCell
{
public:
SMDSAbs_ElementType GetType() const;
virtual vtkIdType GetVtkType() const;
};
#endif

View File

@ -26,6 +26,8 @@
// Module : SMESH
//
#include "SMDS_MeshIDFactory.hxx"
#include "SMDS_Mesh.hxx"
#include "utilities.h"
using namespace std;
@ -34,27 +36,33 @@ using namespace std;
//purpose :
//=======================================================================
SMDS_MeshIDFactory::SMDS_MeshIDFactory():myMaxID(0)
SMDS_MeshIDFactory::SMDS_MeshIDFactory():myMaxID(0), myMesh(0)
{
}
int SMDS_MeshIDFactory::GetFreeID()
{
if (myPoolOfID.empty()) return ++myMaxID;
int newid;
if (myPoolOfID.empty())
{
newid = ++myMaxID;
//MESSAGE("GetFreeID new " << newid);
}
else
{
set<int>::iterator i = myPoolOfID.begin();
int ID = *i;//myPoolOfID.top();
newid = *i;//myPoolOfID.top();
myPoolOfID.erase( i );//myPoolOfID.pop();
return ID;
//MESSAGE("GetFreeID pool " << newid);
}
return newid;
}
//=======================================================================
//function : ReleaseID
//purpose :
//=======================================================================
void SMDS_MeshIDFactory::ReleaseID(const int ID)
void SMDS_MeshIDFactory::ReleaseID(int ID, int vtkId)
{
if ( ID > 0 )
{
@ -83,6 +91,24 @@ void SMDS_MeshIDFactory::ReleaseID(const int ID)
void SMDS_MeshIDFactory::Clear()
{
myMaxID = 0;
myPoolOfID.clear();
myMaxID = 0;
myPoolOfID.clear();
}
void SMDS_MeshIDFactory::SetMesh(SMDS_Mesh *mesh)
{
myMesh = mesh;
}
SMDS_Mesh* SMDS_MeshIDFactory::GetMesh()
{
return myMesh;
}
void SMDS_MeshIDFactory::emptyPool(int maxId)
{
MESSAGE("SMDS_MeshIDFactory::emptyPool " << myMaxID << " --> " << maxId);
myMaxID = maxId;
myPoolOfID.clear();
}

View File

@ -32,18 +32,25 @@
#include "SMDS_MeshObject.hxx"
#include <set>
class SMDS_Mesh;
class SMDS_EXPORT SMDS_MeshIDFactory:public SMDS_MeshObject
{
public:
virtual int GetFreeID();
virtual void ReleaseID(int ID);
int GetFreeID();
virtual void ReleaseID(int ID, int vtkId = -1);
virtual void Clear();
protected:
SMDS_MeshIDFactory();
int myMaxID;
std::set<int> myPoolOfID;
void SetMesh(SMDS_Mesh *mesh);
SMDS_Mesh* GetMesh();
inline bool isPoolIdEmpty() { return myPoolOfID.empty(); };
virtual void emptyPool(int maxId);
inline void adjustMaxId(int ID) { if (ID > myMaxID) myMaxID = ID;};
protected:
SMDS_MeshIDFactory();
int myMaxID;
std::set<int> myPoolOfID;
SMDS_Mesh *myMesh;
};
#endif

View File

@ -29,18 +29,61 @@
#include "SMDS_MeshNode.hxx"
#include "SMDS_SpacePosition.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_Mesh.hxx"
#include <vtkUnstructuredGrid.h>
#define protected public
#include <vtkCellLinks.h>
#define protected protected
#include "utilities.h"
#include "Utils_SALOME_Exception.hxx"
#include <cassert>
using namespace std;
int SMDS_MeshNode::nbNodes =0;
//=======================================================================
//function : SMDS_MeshNode
//purpose :
//=======================================================================
SMDS_MeshNode::SMDS_MeshNode(double x, double y, double z):
myX(x), myY(y), myZ(z),
myPosition(SMDS_SpacePosition::originSpacePosition())
SMDS_MeshNode::SMDS_MeshNode() :
SMDS_MeshElement(-1, -1, 0),
myPosition(SMDS_SpacePosition::originSpacePosition())
{
nbNodes++;
}
SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y, double z):
SMDS_MeshElement(id, meshId, shapeId),
myPosition(SMDS_SpacePosition::originSpacePosition())
{
nbNodes++;
init(id, meshId, shapeId, x, y ,z);
}
void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, double z)
{
myVtkID = id -1;
assert(myVtkID >= 0);
myID = id;
myMeshId = meshId;
myShapeId = shapeId;
myIdInShape = -1;
//MESSAGE("Node " << myID << " " << myVtkID << " (" << x << ", " << y << ", " << z << ")");
SMDS_Mesh* mesh = SMDS_Mesh::_meshList[myMeshId];
vtkUnstructuredGrid * grid = mesh->getGrid();
vtkPoints *points = grid->GetPoints();
points->InsertPoint(myVtkID, x, y, z);
vtkCellLinks *cellLinks = grid->GetCellLinks();
if (myVtkID >=cellLinks->Size)
cellLinks->Resize(myVtkID+SMDS_Mesh::chunkSize);
}
SMDS_MeshNode::~SMDS_MeshNode()
{
nbNodes--;
}
//=======================================================================
@ -50,14 +93,10 @@ SMDS_MeshNode::SMDS_MeshNode(double x, double y, double z):
void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * parent)
{
NCollection_List<const SMDS_MeshElement*>::Iterator it(myInverseElements);
while (it.More()) {
const SMDS_MeshElement* elem = it.Value();
if (elem == parent)
myInverseElements.Remove(it);
else
it.Next();
}
//MESSAGE("RemoveInverseElement " << myID << " " << parent->GetID());
const SMDS_MeshCell* cell = dynamic_cast<const SMDS_MeshCell*>(parent);
MYASSERT(cell);
SMDS_Mesh::_meshList[myMeshId]->getGrid()->RemoveReferenceToCell(myVtkID, cell->getVtkId());
}
//=======================================================================
@ -67,8 +106,8 @@ void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * parent)
void SMDS_MeshNode::Print(ostream & OS) const
{
OS << "Node <" << GetID() << "> : X = " << myX << " Y = "
<< myY << " Z = " << myZ << endl;
OS << "Node <" << myID << "> : X = " << X() << " Y = "
<< Y() << " Z = " << Z() << endl;
}
//=======================================================================
@ -97,77 +136,116 @@ const SMDS_PositionPtr& SMDS_MeshNode::GetPosition() const
*/
//=======================================================================
class SMDS_MeshNode_MyInvIterator:public SMDS_ElemIterator
class SMDS_MeshNode_MyInvIterator: public SMDS_ElemIterator
{
NCollection_List<const SMDS_MeshElement*>::Iterator myIterator;
SMDSAbs_ElementType myType;
public:
SMDS_MeshNode_MyInvIterator(const NCollection_List<const SMDS_MeshElement*>& s,
SMDSAbs_ElementType type):
myIterator(s), myType(type)
{}
private:
SMDS_Mesh* myMesh;
vtkIdType* myCells;
int myNcells;
SMDSAbs_ElementType myType;
int iter;
vector<vtkIdType> cellList;
public:
SMDS_MeshNode_MyInvIterator(SMDS_Mesh *mesh, vtkIdType* cells, int ncells, SMDSAbs_ElementType type) :
myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0)
{
//MESSAGE("SMDS_MeshNode_MyInvIterator : ncells " << myNcells);
cellList.clear();
if (type == SMDSAbs_All)
for (int i = 0; i < ncells; i++)
cellList.push_back(cells[i]);
else for (int i = 0; i < ncells; i++)
{
int vtkId = cells[i];
int smdsId = myMesh->fromVtkToSmds(vtkId);
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
if (elem->GetType() == type)
{
//MESSAGE("Add element vtkId " << vtkId << " " << elem->GetType())
cellList.push_back(vtkId);
}
}
myCells = &cellList[0];
myNcells = cellList.size();
//MESSAGE("myNcells="<<myNcells);
}
bool more()
{
if ( myType != SMDSAbs_All ) {
while ( myIterator.More() && myIterator.Value()->GetType() != myType)
myIterator.Next();
}
return myIterator.More() != Standard_False;
//MESSAGE("iter " << iter << " ncells " << myNcells);
return (iter < myNcells);
}
const SMDS_MeshElement* next()
{
if ( !more() ) return 0;
const SMDS_MeshElement* current=myIterator.Value();
myIterator.Next();
return current;
}
int vtkId = myCells[iter];
int smdsId = myMesh->fromVtkToSmds(vtkId);
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
if (!elem)
{
MESSAGE("SMDS_MeshNode_MyInvIterator problem Null element");
throw SALOME_Exception("SMDS_MeshNode_MyInvIterator problem Null element");
}
//MESSAGE("vtkId " << vtkId << " smdsId " << smdsId << " " << elem->GetType());
iter++;
return elem;
}
};
SMDS_ElemIteratorPtr SMDS_MeshNode::
GetInverseElementIterator(SMDSAbs_ElementType type) const
{
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(myInverseElements,type));
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
//MESSAGE("myID " << myID << " ncells " << l.ncells);
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
}
// Same as GetInverseElementIterator but the create iterator only return
// wanted type elements.
class SMDS_MeshNode_MyIterator:public SMDS_ElemIterator
{
NCollection_List<const SMDS_MeshElement*> mySet;
NCollection_List<const SMDS_MeshElement*>::Iterator myIterator;
private:
SMDS_Mesh* myMesh;
vtkIdType* myCells;
int myNcells;
SMDSAbs_ElementType myType;
int iter;
vector<SMDS_MeshElement*> myFiltCells;
public:
SMDS_MeshNode_MyIterator(SMDSAbs_ElementType type,
const NCollection_List<const SMDS_MeshElement*>& s)
SMDS_MeshNode_MyIterator(SMDS_Mesh *mesh,
vtkIdType* cells,
int ncells,
SMDSAbs_ElementType type):
myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0)
{
const SMDS_MeshElement * e;
bool toInsert;
NCollection_List<const SMDS_MeshElement*>::Iterator it(s);
for(; it.More(); it.Next())
{
e=it.Value();
switch(type)
{
case SMDSAbs_Edge: toInsert=true; break;
case SMDSAbs_Face: toInsert=(e->GetType()!=SMDSAbs_Edge); break;
case SMDSAbs_Volume: toInsert=(e->GetType()==SMDSAbs_Volume); break;
}
if(toInsert) mySet.Append(e);
}
myIterator.Init(mySet);
//MESSAGE("myNcells " << myNcells);
for (; iter<ncells; iter++)
{
int vtkId = myCells[iter];
int smdsId = myMesh->fromVtkToSmds(vtkId);
//MESSAGE("vtkId " << vtkId << " smdsId " << smdsId);
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
if (elem->GetType() == type)
myFiltCells.push_back((SMDS_MeshElement*)elem);
}
myNcells = myFiltCells.size();
//MESSAGE("myNcells " << myNcells);
iter = 0;
//MESSAGE("SMDS_MeshNode_MyIterator (filter) " << ncells << " " << myNcells);
}
bool more()
{
return myIterator.More() != Standard_False;
return (iter< myNcells);
}
const SMDS_MeshElement* next()
{
const SMDS_MeshElement* current=myIterator.Value();
myIterator.Next();
return current;
const SMDS_MeshElement* elem = myFiltCells[iter];
iter++;
return elem;
}
};
@ -177,10 +255,10 @@ SMDS_ElemIteratorPtr SMDS_MeshNode::
if(type==SMDSAbs_Node)
return SMDS_MeshElement::elementsIterator(SMDSAbs_Node);
else
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type,
SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(type, myInverseElements))));
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
}
}
int SMDS_MeshNode::NbNodes() const
@ -188,26 +266,37 @@ int SMDS_MeshNode::NbNodes() const
return 1;
}
double* SMDS_MeshNode::getCoord() const
{
return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoint(myVtkID);
}
double SMDS_MeshNode::X() const
{
return myX;
double *coord = getCoord();
return coord[0];
}
double SMDS_MeshNode::Y() const
{
return myY;
double *coord = getCoord();
return coord[1];
}
double SMDS_MeshNode::Z() const
{
return myZ;
double *coord = getCoord();
return coord[2];
}
//* resize the vtkPoints structure every SMDS_Mesh::chunkSize points
void SMDS_MeshNode::setXYZ(double x, double y, double z)
{
myX=x;
myY=y;
myZ=z;
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
vtkPoints *points = mesh->getGrid()->GetPoints();
points->InsertPoint(myVtkID, x, y, z);
mesh->adjustBoundingBox(x, y, z);
mesh->setMyModified();
}
SMDSAbs_ElementType SMDS_MeshNode::GetType() const
@ -215,19 +304,20 @@ SMDSAbs_ElementType SMDS_MeshNode::GetType() const
return SMDSAbs_Node;
}
vtkIdType SMDS_MeshNode::GetVtkType() const
{
return VTK_VERTEX;
}
//=======================================================================
//function : AddInverseElement
//purpose :
//=======================================================================
void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
{
NCollection_List<const SMDS_MeshElement*>::Iterator it(myInverseElements);
for (; it.More(); it.Next()) {
const SMDS_MeshElement* elem = it.Value();
if (elem == ME)
return;
}
myInverseElements.Append(ME);
const SMDS_MeshCell *cell = dynamic_cast<const SMDS_MeshCell*>(ME);
assert(cell);
SMDS_Mesh::_meshList[myMeshId]->getGrid()->AddReferenceToCell(myVtkID, cell->getVtkId());
}
//=======================================================================
@ -236,7 +326,13 @@ void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
//=======================================================================
void SMDS_MeshNode::ClearInverseElements()
{
myInverseElements.Clear();
SMDS_Mesh::_meshList[myMeshId]->getGrid()->ResizeCellList(myVtkID, 0);
}
bool SMDS_MeshNode::emptyInverseElements()
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
return (l.ncells == 0);
}
//================================================================================
@ -247,13 +343,19 @@ void SMDS_MeshNode::ClearInverseElements()
int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
if ( type == SMDSAbs_All )
return myInverseElements.Extent();
return l.ncells;
int nb = 0;
NCollection_List<const SMDS_MeshElement*>::Iterator it( myInverseElements );
for ( ; it.More(); it.Next() )
if ( it.Value()->GetType() == type )
nb++;
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
for (int i=0; i<l.ncells; i++)
{
const SMDS_MeshElement* elem = mesh->FindElement(mesh->fromVtkToSmds(l.cells[i]));
if (elem->GetType() == type)
nb++;
}
return nb;
}
@ -262,7 +364,7 @@ int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const
///////////////////////////////////////////////////////////////////////////////
bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2)
{
return e1.GetID()<e2.GetID();
return e1.getVtkId()<e2.getVtkId();
/*if(e1.myX<e2.myX) return true;
else if(e1.myX==e2.myX)
{

View File

@ -31,50 +31,52 @@
#include "SMDS_MeshElement.hxx"
#include "SMDS_Position.hxx"
#include "ObjectPool.hxx"
#include <NCollection_List.hxx>
class SMDS_EXPORT SMDS_MeshNode:public SMDS_MeshElement
{
public:
SMDS_MeshNode(double x, double y, double z);
friend class SMESHDS_Mesh;
friend class SMDS_Mesh;
friend class ObjectPool<SMDS_MeshNode>;
void Print(std::ostream & OS) const;
double X() const;
double Y() const;
double Z() const;
SMDS_ElemIteratorPtr GetInverseElementIterator(SMDSAbs_ElementType type=SMDSAbs_All) const;
int NbInverseElements(SMDSAbs_ElementType type=SMDSAbs_All) const;
const SMDS_PositionPtr& GetPosition() const;
SMDSAbs_ElementType GetType() const;
virtual vtkIdType GetVtkType() const;
SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_Node;}
int NbNodes() const;
friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2);
void SetPosition(const SMDS_PositionPtr& aPos);
void setXYZ(double x, double y, double z);
static int nbNodes;
protected:
SMDS_MeshNode();
SMDS_MeshNode(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0);
virtual ~SMDS_MeshNode();
void init(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0);
inline void setVtkId(int vtkId) { myVtkID = vtkId; };
double* getCoord() const;
void AddInverseElement(const SMDS_MeshElement * ME);
void RemoveInverseElement(const SMDS_MeshElement * parent);
void ClearInverseElements();
SMDS_ElemIteratorPtr GetInverseElementIterator(SMDSAbs_ElementType type=SMDSAbs_All) const;
int NbInverseElements(SMDSAbs_ElementType type=SMDSAbs_All) const;
bool emptyInverseElements();
void SetPosition(const SMDS_PositionPtr& aPos);
const SMDS_PositionPtr& GetPosition() const;
SMDSAbs_ElementType GetType() const;
SMDSAbs_EntityType GetEntityType() const {return SMDSEntity_Node;}
friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2);
void Print(std::ostream & OS) const;
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
virtual const SMDS_MeshNode* GetNode(const int) const { return this; }
virtual int NbNodes() const;
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
private:
double myX, myY, myZ;
SMDS_PositionPtr myPosition;
NCollection_List<const SMDS_MeshElement*> myInverseElements;
};
#endif

View File

@ -0,0 +1,136 @@
// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMDS : implementaion of Salome mesh data structure
// File : SMDS_MeshNodeIDFactory.cxx
// Author : Jean-Michel BOULCOURT
// Module : SMESH
//
#ifdef _MSC_VER
#pragma warning(disable:4786)
#endif
#include "SMDS_MeshNodeIDFactory.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_Mesh.hxx"
#include <vtkUnstructuredGrid.h>
#include <vtkCellType.h>
using namespace std;
//=======================================================================
//function : SMDS_MeshNodeIDFactory
//purpose :
//=======================================================================
SMDS_MeshNodeIDFactory::SMDS_MeshNodeIDFactory() :
SMDS_MeshIDFactory(), myMin(0), myMax(0)
{
}
//=======================================================================
//function : BindID
//purpose :
//=======================================================================
bool SMDS_MeshNodeIDFactory::BindID(int ID, SMDS_MeshElement * elem)
{
updateMinMax(ID);
return true;
}
//=======================================================================
//function : MeshElement
//purpose :
//=======================================================================
SMDS_MeshElement* SMDS_MeshNodeIDFactory::MeshElement(int ID)
{
if ((ID < 1) || (ID > myMax))
return NULL;
const SMDS_MeshElement* elem = GetMesh()->FindNode(ID);
return (SMDS_MeshElement*) (elem);
}
//=======================================================================
//function : ReleaseID
//purpose :
//=======================================================================
void SMDS_MeshNodeIDFactory::ReleaseID(const int ID, int vtkId)
{
SMDS_MeshIDFactory::ReleaseID(ID);
myMesh->setMyModified();
if (ID == myMax)
myMax = 0; // --- force updateMinMax
if (ID == myMin)
myMax = 0; // --- force updateMinMax
}
//=======================================================================
//function : GetMaxID
//purpose :
//=======================================================================
int SMDS_MeshNodeIDFactory::GetMaxID() const
{
if (myMax == 0)
updateMinMax();
return myMax;
}
//=======================================================================
//function : GetMinID
//purpose :
//=======================================================================
int SMDS_MeshNodeIDFactory::GetMinID() const
{
if (myMax == 0)
updateMinMax();
return myMin;
}
//=======================================================================
//function : updateMinMax
//purpose :
//=======================================================================
void SMDS_MeshNodeIDFactory::updateMinMax() const
{
myMesh->updateNodeMinMax();
myMin = myMesh->MinNodeID();
myMax = myMesh->MaxNodeID();
}
SMDS_ElemIteratorPtr SMDS_MeshNodeIDFactory::elementsIterator() const
{
return myMesh->elementsIterator(SMDSAbs_Node);
}
void SMDS_MeshNodeIDFactory::Clear()
{
myMin = myMax = 0;
SMDS_MeshIDFactory::Clear();
}
void SMDS_MeshNodeIDFactory::emptyPool(int maxId)
{
SMDS_MeshIDFactory::emptyPool(maxId);
myMax = maxId;
}

View File

@ -0,0 +1,65 @@
// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMDS : implementaion of Salome mesh data structure
// File : SMDS_MeshElementIDFactory.hxx
// Module : SMESH
//
#ifndef _SMDS_MeshNodeIDFactory_HeaderFile
#define _SMDS_MeshNodeIDFactory_HeaderFile
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshIDFactory.hxx"
#include "SMDS_ElemIterator.hxx"
#include <vector>
class SMDS_MeshElement;
class SMDS_EXPORT SMDS_MeshNodeIDFactory: public SMDS_MeshIDFactory
{
public:
SMDS_MeshNodeIDFactory();
bool BindID(int ID, SMDS_MeshElement * elem);
SMDS_MeshElement * MeshElement(int ID);
virtual void ReleaseID(int ID, int vtkId = -1);
int GetMaxID() const;
int GetMinID() const;
SMDS_ElemIteratorPtr elementsIterator() const;
virtual void Clear();
virtual void emptyPool(int maxId);
protected:
void updateMinMax() const;
void updateMinMax(int id) const
{
if (id > myMax)
myMax = id;
if (id < myMin)
myMin = id;
}
mutable int myMin, myMax;
};
#endif

View File

@ -36,3 +36,7 @@ SMDSAbs_ElementType SMDS_MeshVolume::GetType() const
return SMDSAbs_Volume;
}
vtkIdType SMDS_MeshVolume::GetVtkType() const
{
return VTK_CONVEX_POINT_SET; // --- must be reimplemented in derived classes
}

View File

@ -29,12 +29,13 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshCell.hxx"
class SMDS_EXPORT SMDS_MeshVolume:public SMDS_MeshElement
class SMDS_EXPORT SMDS_MeshVolume:public SMDS_MeshCell
{
public:
SMDSAbs_ElementType GetType() const;
virtual vtkIdType GetVtkType() const;
};
#endif

View File

@ -43,6 +43,7 @@ using namespace std;
SMDS_PolygonalFaceOfNodes::SMDS_PolygonalFaceOfNodes
(std::vector<const SMDS_MeshNode *> nodes)
{
//MESSAGE("******************************************** SMDS_PolygonalFaceOfNodes");
myNodes = nodes;
}

View File

@ -45,6 +45,7 @@ SMDS_PolyhedralVolumeOfNodes::SMDS_PolyhedralVolumeOfNodes
vector<int> quantities)
: SMDS_VolumeOfNodes(NULL, NULL, NULL, NULL)
{
//MESSAGE("****************************************** SMDS_PolyhedralVolumeOfNodes");
ChangeNodes(nodes, quantities);
}

View File

@ -26,34 +26,16 @@
// Module : SMESH
//
#include "SMDS_Position.hxx"
#include "utilities.h"
//=======================================================================
//function : SMDS_Position
//purpose :
//=======================================================================
SMDS_Position::SMDS_Position(int aShapeId) :myShapeId(aShapeId)
SMDS_Position::SMDS_Position()
{
}
//=======================================================================
//function : SetShapeId
//purpose :
//=======================================================================
void SMDS_Position::SetShapeId(int aShapeId)
{
myShapeId = aShapeId;
}
//=======================================================================
//function : GetShapeId
//purpose :
//=======================================================================
int SMDS_Position::GetShapeId() const
{
return myShapeId;
//MESSAGE("########################## SMDS_Position ");
}
//=======================================================================

View File

@ -33,24 +33,19 @@
#include <boost/shared_ptr.hpp>
class SMDS_Position;
typedef boost::shared_ptr<SMDS_Position> SMDS_PositionPtr;
//typedef boost::shared_ptr<SMDS_Position> SMDS_PositionPtr;
typedef SMDS_Position* SMDS_PositionPtr;
class SMDS_EXPORT SMDS_Position
{
public:
const virtual double * Coords() const = 0;
virtual SMDS_TypeOfPosition GetTypeOfPosition() const = 0;
virtual int GetDim() const;
void SetShapeId(int aShapeId);
int GetShapeId() const;
virtual ~SMDS_Position() {}
protected:
SMDS_Position(int aShapeId);
private:
int myShapeId;
SMDS_Position();
};

View File

@ -30,6 +30,7 @@
#include "SMDS_SetIterator.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
#include "utilities.h"
using namespace std;
@ -41,8 +42,9 @@ using namespace std;
SMDS_QuadraticEdge::SMDS_QuadraticEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12)
:SMDS_MeshEdge(node1,node2)
{
:SMDS_LinearEdge(node1,node2)
{
//MESSAGE("******************************************************* SMDS_QuadraticEdge");
myNodes[2]=node12;
}

View File

@ -29,10 +29,10 @@
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshEdge.hxx"
#include "SMDS_LinearEdge.hxx"
#include <iostream>
class SMDS_EXPORT SMDS_QuadraticEdge: public SMDS_MeshEdge
class SMDS_EXPORT SMDS_QuadraticEdge: public SMDS_LinearEdge
{
public:

View File

@ -49,6 +49,7 @@ SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31)
{
//MESSAGE("********************************************** SMDS_QuadraticFaceOfNodes 1");
myNodes.resize( 6 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
@ -73,6 +74,7 @@ SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41)
{
//MESSAGE("********************************************* SMDS_QuadraticFaceOfNodes 2");
myNodes.resize( 8 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;

View File

@ -54,6 +54,7 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34)
{
//MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes");
myNodes.resize( 10 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
@ -88,6 +89,7 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45)
{
//MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes");
myNodes.resize( 13 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
@ -127,6 +129,7 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36)
{
//MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes");
myNodes.resize( 15 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
@ -173,6 +176,7 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48)
{
//MESSAGE("*********************************************** SMDS_QuadraticVolumeOfNodes");
myNodes.resize( 20 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;

View File

@ -25,35 +25,21 @@
// Author : Jean-Michel BOULCOURT
// Module : SMESH
//
#include "SMDS_SpacePosition.hxx"
//=======================================================================
//function : SMDS_SpacePosition
//purpose :
//=======================================================================
SMDS_SpacePosition* SMDS_SpacePosition::_originPosition = new SMDS_SpacePosition();
SMDS_SpacePosition::SMDS_SpacePosition(double x, double y, double z):
SMDS_Position(0)
SMDS_SpacePosition::SMDS_SpacePosition(double x, double y, double z)
{
myCoords[0]=x;
myCoords[1]=y;
myCoords[2]=z;
}
/**
*/
SMDS_TypeOfPosition SMDS_SpacePosition::GetTypeOfPosition() const
{
return SMDS_TOP_3DSPACE;
}
const double * SMDS_SpacePosition::Coords() const
{
return myCoords;
return SMDS_TOP_3DSPACE;
}
SMDS_PositionPtr SMDS_SpacePosition::originSpacePosition()
{
static SMDS_PositionPtr staticpos (new SMDS_SpacePosition());
return staticpos;
return _originPosition;
}

View File

@ -34,14 +34,12 @@
class SMDS_EXPORT SMDS_SpacePosition:public SMDS_Position
{
public:
SMDS_SpacePosition(double x=0, double y=0, double z=0);
const virtual double * Coords() const;
virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const;
inline void SetCoords(const double x, const double y, const double z);
static SMDS_PositionPtr originSpacePosition();
private:
double myCoords[3];
public:
SMDS_SpacePosition(double x=0, double y=0, double z=0);
virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const;
static SMDS_PositionPtr originSpacePosition();
private:
static SMDS_SpacePosition* _originPosition;
};
#endif

View File

@ -0,0 +1,841 @@
#define CHRONODEF
#include "SMDS_UnstructuredGrid.hxx"
#include "SMDS_Mesh.hxx"
#include "SMDS_MeshInfo.hxx"
#include "SMDS_Downward.hxx"
#include "utilities.h"
#include <vtkCellArray.h>
#include <vtkCellLinks.h>
#include <vtkIdTypeArray.h>
#include <vtkUnsignedCharArray.h>
#include <list>
using namespace std;
SMDS_UnstructuredGrid* SMDS_UnstructuredGrid::New()
{
MESSAGE("SMDS_UnstructuredGrid::New");
return new SMDS_UnstructuredGrid();
}
SMDS_UnstructuredGrid::SMDS_UnstructuredGrid() :
vtkUnstructuredGrid()
{
_cellIdToDownId.clear();
_downTypes.clear();
_downArray.clear();
_mesh = 0;
}
SMDS_UnstructuredGrid::~SMDS_UnstructuredGrid()
{
}
unsigned long SMDS_UnstructuredGrid::GetMTime()
{
unsigned long mtime = vtkUnstructuredGrid::GetMTime();
MESSAGE("vtkUnstructuredGrid::GetMTime: " << mtime);
return mtime;
}
void SMDS_UnstructuredGrid::Update()
{
MESSAGE("SMDS_UnstructuredGrid::Update");
return vtkUnstructuredGrid::Update();
}
void SMDS_UnstructuredGrid::UpdateInformation()
{
MESSAGE("SMDS_UnstructuredGrid::UpdateInformation");
return vtkUnstructuredGrid::UpdateInformation();
}
vtkPoints* SMDS_UnstructuredGrid::GetPoints()
{
// TODO erreur incomprehensible de la macro vtk GetPoints apparue avec la version paraview de fin aout 2010
//MESSAGE("*********************** SMDS_UnstructuredGrid::GetPoints " << this->Points << " " << vtkUnstructuredGrid::GetPoints());
return this->Points;
}
//#ifdef VTK_HAVE_POLYHEDRON
int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *pts)
{
if (type != VTK_POLYHEDRON)
return vtkUnstructuredGrid::InsertNextLinkedCell(type, npts, pts);
// --- type = VTK_POLYHEDRON
MESSAGE("InsertNextLinkedCell VTK_POLYHEDRON");
int cellid = this->InsertNextCell(type, npts, pts);
set<vtkIdType> setOfNodes;
setOfNodes.clear();
int nbfaces = npts;
int i = 0;
for (int nf = 0; nf < nbfaces; nf++)
{
int nbnodes = pts[i];
i++;
for (int k = 0; k < nbnodes; k++)
{
MESSAGE(" cell " << cellid << " face " << nf << " node " << pts[i]);
setOfNodes.insert(pts[i]);
i++;
}
}
set<vtkIdType>::iterator it = setOfNodes.begin();
for (; it != setOfNodes.end(); ++it)
{
MESSAGE("reverse link for node " << *it << " cell " << cellid);
this->Links->ResizeCellList(*it, 1);
this->Links->AddCellReference(cellid, *it);
}
return cellid;
}
//#endif
void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh)
{
_mesh = mesh;
}
void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int newNodeSize,
std::vector<int>& idCellsOldToNew, int newCellSize)
{
// TODO utiliser mieux vtk pour faire plus simple (plus couteux ?)
MESSAGE("------------------------- SMDS_UnstructuredGrid::compactGrid " << newNodeSize << " " << newCellSize);CHRONO(1);
int startHole = 0;
int endHole = 0;
int startBloc = 0;
int endBloc = 0;
int alreadyCopied = 0;
int holes = 0;
typedef enum
{
lookHoleStart, lookHoleEnd, lookBlocEnd
} enumState;
enumState compactState = lookHoleStart;
// if (this->Links)
// {
// this->Links->UnRegister(this);
// this->Links = 0;
// }
// --- if newNodeSize, create a new compacted vtkPoints
vtkPoints *newPoints = 0;
if (newNodeSize)
{
MESSAGE("-------------- compactGrid, newNodeSize " << newNodeSize);
newPoints = vtkPoints::New();
newPoints->Initialize();
newPoints->Allocate(newNodeSize);
newPoints->SetNumberOfPoints(newNodeSize);
int oldNodeSize = idNodesOldToNew.size();
for (int i = 0; i < oldNodeSize; i++)
{
//MESSAGE(" " << i << " " << idNodesOldToNew[i]);
switch (compactState)
{
case lookHoleStart:
if (idNodesOldToNew[i] < 0)
{
MESSAGE("-------------- newNodeSize, startHole " << i << " " << oldNodeSize);
startHole = i;
if (!alreadyCopied) // copy the first bloc
{
MESSAGE("--------- copy first nodes before hole " << i << " " << oldNodeSize);
copyNodes(newPoints, idNodesOldToNew, alreadyCopied, 0, startHole);
}
compactState = lookHoleEnd;
}
break;
case lookHoleEnd:
if (idNodesOldToNew[i] >= 0)
{
MESSAGE("-------------- newNodeSize, endHole " << i << " " << oldNodeSize);
endHole = i;
startBloc = i;
compactState = lookBlocEnd;
}
break;
case lookBlocEnd:
if (idNodesOldToNew[i] < 0)
endBloc = i; // see nbPoints below
else if (i == (oldNodeSize - 1))
endBloc = i + 1;
if (endBloc)
{
MESSAGE("-------------- newNodeSize, endbloc " << endBloc << " " << oldNodeSize);
copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc);
compactState = lookHoleEnd;
startHole = i;
endHole = 0;
startBloc = 0;
endBloc = 0;
}
break;
}
}
if (!alreadyCopied) // no hole, but shorter, no need to modify idNodesOldToNew
{
MESSAGE("------------- newNodeSize, shorter " << oldNodeSize);
copyNodes(newPoints, idNodesOldToNew, alreadyCopied, 0, newNodeSize);
}
newPoints->Squeeze();
}
// --- create new compacted Connectivity, Locations and Types
int oldCellSize = this->Types->GetNumberOfTuples();
vtkCellArray *newConnectivity = vtkCellArray::New();
newConnectivity->Initialize();
int oldCellDataSize = this->Connectivity->GetData()->GetSize();
newConnectivity->Allocate(oldCellDataSize);
MESSAGE("oldCellSize="<< oldCellSize << " oldCellDataSize=" << oldCellDataSize);
vtkUnsignedCharArray *newTypes = vtkUnsignedCharArray::New();
newTypes->Initialize();
newTypes->SetNumberOfValues(newCellSize);
vtkIdTypeArray *newLocations = vtkIdTypeArray::New();
newLocations->Initialize();
newLocations->SetNumberOfValues(newCellSize);
startHole = 0;
endHole = 0;
startBloc = 0;
endBloc = 0;
alreadyCopied = 0;
holes = 0;
compactState = lookHoleStart;
// TODO some polyhedron may be huge (only in some tests)
vtkIdType tmpid[NBMAXNODESINCELL];
vtkIdType *pointsCell = &tmpid[0]; // --- points id to fill a new cell
for (int i = 0; i < oldCellSize; i++)
{
switch (compactState)
{
case lookHoleStart:
if (this->Types->GetValue(i) == VTK_EMPTY_CELL)
{
MESSAGE(" -------- newCellSize, startHole " << i << " " << oldCellSize);
startHole = i;
compactState = lookHoleEnd;
if (!alreadyCopied) // copy the first bloc
{
MESSAGE("--------- copy first bloc before hole " << i << " " << oldCellSize);
copyBloc(newTypes, idCellsOldToNew, idNodesOldToNew, newConnectivity, newLocations, pointsCell,
alreadyCopied, 0, startHole);
}
}
break;
case lookHoleEnd:
if (this->Types->GetValue(i) != VTK_EMPTY_CELL)
{
MESSAGE(" -------- newCellSize, EndHole " << i << " " << oldCellSize);
endHole = i;
startBloc = i;
compactState = lookBlocEnd;
holes += endHole - startHole;
}
break;
case lookBlocEnd:
endBloc = 0;
if (this->Types->GetValue(i) == VTK_EMPTY_CELL)
endBloc = i;
else if (i == (oldCellSize - 1))
endBloc = i + 1;
if (endBloc)
{
MESSAGE(" -------- newCellSize, endBloc " << endBloc << " " << oldCellSize);
copyBloc(newTypes, idCellsOldToNew, idNodesOldToNew, newConnectivity, newLocations, pointsCell,
alreadyCopied, startBloc, endBloc);
compactState = lookHoleEnd;
}
break;
}
}
if (!alreadyCopied) // no hole, but shorter
{
MESSAGE(" -------- newCellSize, shorter " << oldCellSize);
copyBloc(newTypes, idCellsOldToNew, idNodesOldToNew, newConnectivity, newLocations, pointsCell, alreadyCopied, 0,
oldCellSize);
}
newConnectivity->Squeeze();
//newTypes->Squeeze();
//newLocations->Squeeze();
if (newNodeSize)
{
MESSAGE("------- newNodeSize, setPoints");
this->SetPoints(newPoints);
MESSAGE("NumberOfPoints: " << this->GetNumberOfPoints());
}
//#ifdef VTK_HAVE_POLYHEDRON
// TODO compact faces for Polyhedrons
// refaire completement faces et faceLocation
// pour chaque cell, recup oldCellId, oldFacesId, recopie dans newFaces de la faceStream
// en changeant les numeros de noeuds
// vtkIdTypeArray *newFaceLocations = vtkIdTypeArray::New();
// newFaceLocations->Initialize();
// vtkIdTypeArray *newFaces = vtkIdTypeArray::New();
// newFaces->Initialize();
// newFaceLocations->DeepCopy(this->FaceLocations);
// newFaces->DeepCopy(this->Faces);
// this->SetCells(newTypes, newLocations, newConnectivity, newFaceLocations, newFaces);
// newFaceLocations->Delete();
// newFaces->Delete();
if (this->FaceLocations) this->FaceLocations->Register(this);
if (this->Faces) this->Faces->Register(this);
this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces);
//#else
// this->SetCells(newTypes, newLocations, newConnectivity);
//#endif
newTypes->Delete();
newLocations->Delete();
newConnectivity->Delete();
this->BuildLinks();
}
void SMDS_UnstructuredGrid::copyNodes(vtkPoints *newPoints, std::vector<int>& idNodesOldToNew, int& alreadyCopied,
int start, int end)
{
MESSAGE("copyNodes " << alreadyCopied << " " << start << " " << end << " size: " << end - start << " total: " << alreadyCopied + end - start);
void *target = newPoints->GetVoidPointer(3 * alreadyCopied);
void *source = this->Points->GetVoidPointer(3 * start);
int nbPoints = end - start;
if (nbPoints > 0)
{
memcpy(target, source, 3 * sizeof(float) * nbPoints);
for (int j = start; j < end; j++)
idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId
//idNodesOldToNew[alreadyCopied++] = idNodesOldToNew[j]; // new vtkId --> old SMDS id
}
}
void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, std::vector<int>& idCellsOldToNew,
std::vector<int>& idNodesOldToNew, vtkCellArray* newConnectivity,
vtkIdTypeArray* newLocations, vtkIdType* pointsCell, int& alreadyCopied,
int start, int end)
{
MESSAGE("copyBloc " << alreadyCopied << " " << start << " " << end << " size: " << end - start << " total: " << alreadyCopied + end - start);
for (int j = start; j < end; j++)
{
newTypes->SetValue(alreadyCopied, this->Types->GetValue(j));
idCellsOldToNew[j] = alreadyCopied; // old vtkId --> new vtkId
vtkIdType oldLoc = this->Locations->GetValue(j);
vtkIdType nbpts;
vtkIdType *oldPtsCell = 0;
this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell);
assert(nbpts < NBMAXNODESINCELL);
//MESSAGE(j << " " << alreadyCopied << " " << (int)this->Types->GetValue(j) << " " << oldLoc << " " << nbpts );
for (int l = 0; l < nbpts; l++)
{
int oldval = oldPtsCell[l];
pointsCell[l] = idNodesOldToNew[oldval];
//MESSAGE(" " << oldval << " " << pointsCell[l]);
}
int newcnt = newConnectivity->InsertNextCell(nbpts, pointsCell);
int newLoc = newConnectivity->GetInsertLocation(nbpts);
//MESSAGE(newcnt << " " << newLoc);
newLocations->SetValue(alreadyCopied, newLoc);
alreadyCopied++;
}
}
int SMDS_UnstructuredGrid::CellIdToDownId(int vtkCellId)
{
// ASSERT((vtkCellId >= 0) && (vtkCellId < _cellIdToDownId.size()));
return _cellIdToDownId[vtkCellId];
}
void SMDS_UnstructuredGrid::setCellIdToDownId(int vtkCellId, int downId)
{
// ASSERT((vtkCellId >= 0) && (vtkCellId < _cellIdToDownId.size()));
_cellIdToDownId[vtkCellId] = downId;
}
/*! Build downward connectivity: to do only when needed because heavy memory load.
* Downward connectivity is no more valid if vtkUnstructuredGrid is modified.
*
*/
void SMDS_UnstructuredGrid::BuildDownwardConnectivity(bool withEdges)
{
MESSAGE("SMDS_UnstructuredGrid::BuildDownwardConnectivity");CHRONO(2);
// TODO calcul partiel sans edges
// --- erase previous data if any
for (int i = 0; i < _downArray.size(); i++)
{
if (_downArray[i])
delete _downArray[i];
_downArray[i] = 0;
}
_cellIdToDownId.clear();
// --- create SMDS_Downward structures (in _downArray vector[vtkCellType])
_downArray.resize(VTK_MAXTYPE + 1, 0); // --- max. type value = VTK_QUADRATIC_PYRAMID
_downArray[VTK_LINE] = new SMDS_DownEdge(this);
_downArray[VTK_QUADRATIC_EDGE] = new SMDS_DownQuadEdge(this);
_downArray[VTK_TRIANGLE] = new SMDS_DownTriangle(this);
_downArray[VTK_QUADRATIC_TRIANGLE] = new SMDS_DownQuadTriangle(this);
_downArray[VTK_QUAD] = new SMDS_DownQuadrangle(this);
_downArray[VTK_QUADRATIC_QUAD] = new SMDS_DownQuadQuadrangle(this);
_downArray[VTK_TETRA] = new SMDS_DownTetra(this);
_downArray[VTK_QUADRATIC_TETRA] = new SMDS_DownQuadTetra(this);
_downArray[VTK_PYRAMID] = new SMDS_DownPyramid(this);
_downArray[VTK_QUADRATIC_PYRAMID] = new SMDS_DownQuadPyramid(this);
_downArray[VTK_WEDGE] = new SMDS_DownPenta(this);
_downArray[VTK_QUADRATIC_WEDGE] = new SMDS_DownQuadPenta(this);
_downArray[VTK_HEXAHEDRON] = new SMDS_DownHexa(this);
_downArray[VTK_QUADRATIC_HEXAHEDRON] = new SMDS_DownQuadHexa(this);
// --- get detailed info of number of cells of each type, allocate SMDS_downward structures
const SMDS_MeshInfo &meshInfo = _mesh->GetMeshInfo();
int nbLinTetra = meshInfo.NbTetras(ORDER_LINEAR);
int nbQuadTetra = meshInfo.NbTetras(ORDER_QUADRATIC);
int nbLinPyra = meshInfo.NbPyramids(ORDER_LINEAR);
int nbQuadPyra = meshInfo.NbPyramids(ORDER_QUADRATIC);
int nbLinPrism = meshInfo.NbPrisms(ORDER_LINEAR);
int nbQuadPrism = meshInfo.NbPrisms(ORDER_QUADRATIC);
int nbLinHexa = meshInfo.NbHexas(ORDER_LINEAR);
int nbQuadHexa = meshInfo.NbHexas(ORDER_QUADRATIC);
int nbLineGuess = int((4.0 / 3.0) * nbLinTetra + 2 * nbLinPrism + 2.5 * nbLinPyra + 3 * nbLinHexa);
int nbQuadEdgeGuess = int((4.0 / 3.0) * nbQuadTetra + 2 * nbQuadPrism + 2.5 * nbQuadPyra + 3 * nbQuadHexa);
int nbLinTriaGuess = 2 * nbLinTetra + nbLinPrism + 2 * nbLinPyra;
int nbQuadTriaGuess = 2 * nbQuadTetra + nbQuadPrism + 2 * nbQuadPyra;
int nbLinQuadGuess = int((2.0 / 3.0) * nbLinPrism + (1.0 / 2.0) * nbLinPyra + 3 * nbLinHexa);
int nbQuadQuadGuess = int((2.0 / 3.0) * nbQuadPrism + (1.0 / 2.0) * nbQuadPyra + 3 * nbQuadHexa);
int GuessSize[VTK_QUADRATIC_TETRA];
GuessSize[VTK_LINE] = nbLineGuess;
GuessSize[VTK_QUADRATIC_EDGE] = nbQuadEdgeGuess;
GuessSize[VTK_TRIANGLE] = nbLinTriaGuess;
GuessSize[VTK_QUADRATIC_TRIANGLE] = nbQuadTriaGuess;
GuessSize[VTK_QUAD] = nbLinQuadGuess;
GuessSize[VTK_QUADRATIC_QUAD] = nbQuadQuadGuess;
GuessSize[VTK_TETRA] = nbLinTetra;
GuessSize[VTK_QUADRATIC_TETRA] = nbQuadTetra;
GuessSize[VTK_PYRAMID] = nbLinPyra;
GuessSize[VTK_QUADRATIC_PYRAMID] = nbQuadPyra;
GuessSize[VTK_WEDGE] = nbLinPrism;
GuessSize[VTK_QUADRATIC_WEDGE] = nbQuadPrism;
GuessSize[VTK_HEXAHEDRON] = nbLinHexa;
GuessSize[VTK_QUADRATIC_HEXAHEDRON] = nbQuadHexa;
_downArray[VTK_LINE]->allocate(nbLineGuess);
_downArray[VTK_QUADRATIC_EDGE]->allocate(nbQuadEdgeGuess);
_downArray[VTK_TRIANGLE]->allocate(nbLinTriaGuess);
_downArray[VTK_QUADRATIC_TRIANGLE]->allocate(nbQuadTriaGuess);
_downArray[VTK_QUAD]->allocate(nbLinQuadGuess);
_downArray[VTK_QUADRATIC_QUAD]->allocate(nbQuadQuadGuess);
_downArray[VTK_TETRA]->allocate(nbLinTetra);
_downArray[VTK_QUADRATIC_TETRA]->allocate(nbQuadTetra);
_downArray[VTK_PYRAMID]->allocate(nbLinPyra);
_downArray[VTK_QUADRATIC_PYRAMID]->allocate(nbQuadPyra);
_downArray[VTK_WEDGE]->allocate(nbLinPrism);
_downArray[VTK_QUADRATIC_WEDGE]->allocate(nbQuadPrism);
_downArray[VTK_HEXAHEDRON]->allocate(nbLinHexa);
_downArray[VTK_QUADRATIC_HEXAHEDRON]->allocate(nbQuadHexa);
// --- iteration on vtkUnstructuredGrid cells, only faces
// for each vtk face:
// create a downward face entry with its downward id.
// compute vtk volumes, create downward volumes entry.
// mark face in downward volumes
// mark volumes in downward face
MESSAGE("--- iteration on vtkUnstructuredGrid cells, only faces");CHRONO(20);
int cellSize = this->Types->GetNumberOfTuples();
_cellIdToDownId.resize(cellSize, -1);
for (int i = 0; i < cellSize; i++)
{
int vtkFaceType = this->GetCellType(i);
if (SMDS_Downward::getCellDimension(vtkFaceType) == 2)
{
int vtkFaceId = i;
//ASSERT(_downArray[vtkFaceType]);
int connFaceId = _downArray[vtkFaceType]->addCell(vtkFaceId);
SMDS_Down2D* downFace = static_cast<SMDS_Down2D*> (_downArray[vtkFaceType]);
downFace->setTempNodes(connFaceId, vtkFaceId);
int vols[2] = { -1, -1 };
int nbVolumes = downFace->computeVolumeIds(vtkFaceId, vols);
//MESSAGE("nbVolumes="<< nbVolumes);
for (int ivol = 0; ivol < nbVolumes; ivol++)
{
int vtkVolId = vols[ivol];
int vtkVolType = this->GetCellType(vtkVolId);
//ASSERT(_downArray[vtkVolType]);
int connVolId = _downArray[vtkVolType]->addCell(vtkVolId);
_downArray[vtkVolType]->addDownCell(connVolId, connFaceId, vtkFaceType);
_downArray[vtkFaceType]->addUpCell(connFaceId, connVolId, vtkVolType);
// MESSAGE("Face " << vtkFaceId << " belongs to volume " << vtkVolId);
}
}
}
// --- iteration on vtkUnstructuredGrid cells, only volumes
// for each vtk volume:
// create downward volumes entry if not already done
// build a temporary list of faces described with their nodes
// for each face
// compute the vtk volumes containing this face
// check if the face is already listed in the volumes (comparison of ordered list of nodes)
// if not, create a downward face entry (resizing of structure required)
// (the downward faces store a temporary list of nodes to ease the comparison)
// create downward volumes entry if not already done
// mark volumes in downward face
// mark face in downward volumes
CHRONOSTOP(20);
MESSAGE("--- iteration on vtkUnstructuredGrid cells, only volumes");CHRONO(21);
for (int i = 0; i < cellSize; i++)
{
int vtkType = this->GetCellType(i);
if (SMDS_Downward::getCellDimension(vtkType) == 3)
{
//CHRONO(31);
int vtkVolId = i;
// MESSAGE("vtk volume " << vtkVolId);
//ASSERT(_downArray[vtkType]);
int connVolId = _downArray[vtkType]->addCell(vtkVolId);
// --- find all the faces of the volume, describe the faces by their nodes
SMDS_Down3D* downVol = static_cast<SMDS_Down3D*> (_downArray[vtkType]);
ListElemByNodesType facesWithNodes;
downVol->computeFacesWithNodes(vtkVolId, facesWithNodes);
// MESSAGE("vtk volume " << vtkVolId << " contains " << facesWithNodes.nbElems << " faces");
//CHRONOSTOP(31);
for (int iface = 0; iface < facesWithNodes.nbElems; iface++)
{
// --- find the volumes containing the face
//CHRONO(32);
int vtkFaceType = facesWithNodes.elems[iface].vtkType;
SMDS_Down2D* downFace = static_cast<SMDS_Down2D*> (_downArray[vtkFaceType]);
int vols[2] = { -1, -1 };
int *nodes = &facesWithNodes.elems[iface].nodeIds[0];
int lg = facesWithNodes.elems[iface].nbNodes;
int nbVolumes = downFace->computeVolumeIdsFromNodesFace(nodes, lg, vols);
// MESSAGE("vtk volume " << vtkVolId << " face " << iface << " belongs to " << nbVolumes << " volumes");
// --- check if face is registered in the volumes
//CHRONOSTOP(32);
//CHRONO(33);
int connFaceId = -1;
for (int ivol = 0; ivol < nbVolumes; ivol++)
{
int vtkVolId2 = vols[ivol];
int vtkVolType = this->GetCellType(vtkVolId2);
//ASSERT(_downArray[vtkVolType]);
int connVolId2 = _downArray[vtkVolType]->addCell(vtkVolId2);
SMDS_Down3D* downVol2 = static_cast<SMDS_Down3D*> (_downArray[vtkVolType]);
connFaceId = downVol2->FindFaceByNodes(connVolId2, facesWithNodes.elems[iface]);
if (connFaceId >= 0)
break; // --- face already created
}//CHRONOSTOP(33);
// --- if face is not registered in the volumes, create face
//CHRONO(34);
if (connFaceId < 0)
{
connFaceId = _downArray[vtkFaceType]->addCell();
downFace->setTempNodes(connFaceId, facesWithNodes.elems[iface]);
}//CHRONOSTOP(34);
// --- mark volumes in downward face and mark face in downward volumes
//CHRONO(35);
for (int ivol = 0; ivol < nbVolumes; ivol++)
{
int vtkVolId2 = vols[ivol];
int vtkVolType = this->GetCellType(vtkVolId2);
//ASSERT(_downArray[vtkVolType]);
int connVolId2 = _downArray[vtkVolType]->addCell(vtkVolId2);
_downArray[vtkVolType]->addDownCell(connVolId2, connFaceId, vtkFaceType);
_downArray[vtkFaceType]->addUpCell(connFaceId, connVolId2, vtkVolType);
// MESSAGE(" From volume " << vtkVolId << " face " << connFaceId << " belongs to volume " << vtkVolId2);
}//CHRONOSTOP(35);
}
}
}
// --- iteration on vtkUnstructuredGrid cells, only edges
// for each vtk edge:
// create downward edge entry
// store the nodes id's in downward edge (redundant with vtkUnstructuredGrid)
// find downward faces
// (from vtk faces or volumes, get downward faces, they have a temporary list of nodes)
// mark edge in downward faces
// mark faces in downward edge
CHRONOSTOP(21);
MESSAGE("--- iteration on vtkUnstructuredGrid cells, only edges");CHRONO(22);
for (int i = 0; i < cellSize; i++)
{
int vtkEdgeType = this->GetCellType(i);
if (SMDS_Downward::getCellDimension(vtkEdgeType) == 1)
{
int vtkEdgeId = i;
//ASSERT(_downArray[vtkEdgeType]);
int connEdgeId = _downArray[vtkEdgeType]->addCell(vtkEdgeId);
SMDS_Down1D* downEdge = static_cast<SMDS_Down1D*> (_downArray[vtkEdgeType]);
downEdge->setNodes(connEdgeId, vtkEdgeId);
vector<int> vtkIds;
int nbVtkCells = downEdge->computeVtkCells(connEdgeId, vtkIds);
int downFaces[1000];
unsigned char downTypes[1000];
int nbDownFaces = downEdge->computeFaces(connEdgeId, &vtkIds[0], nbVtkCells, downFaces, downTypes);
for (int n = 0; n < nbDownFaces; n++)
{
_downArray[downTypes[n]]->addDownCell(downFaces[n], connEdgeId, vtkEdgeType);
_downArray[vtkEdgeType]->addUpCell(connEdgeId, downFaces[n], downTypes[n]);
}
}
}
// --- iteration on downward faces (they are all listed now)
// for each downward face:
// build a temporary list of edges with their ordered list of nodes
// for each edge:
// find all the vtk cells containing this edge
// then identify all the downward faces containing the edge, from the vtk cells
// check if the edge is already listed in the faces (comparison of ordered list of nodes)
// if not, create a downward edge entry with the node id's
// mark edge in downward faces
// mark downward faces in edge (size of list unknown, to be allocated)
CHRONOSTOP(22);CHRONO(23);
for (int vtkFaceType = 0; vtkFaceType < VTK_QUADRATIC_PYRAMID; vtkFaceType++)
{
if (SMDS_Downward::getCellDimension(vtkFaceType) != 2)
continue;
// --- find all the edges of the face, describe the edges by their nodes
SMDS_Down2D* downFace = static_cast<SMDS_Down2D*> (_downArray[vtkFaceType]);
int maxId = downFace->getMaxId();
for (int faceId = 0; faceId < maxId; faceId++)
{
//CHRONO(40);
ListElemByNodesType edgesWithNodes;
downFace->computeEdgesWithNodes(faceId, edgesWithNodes);
// MESSAGE("downward face type " << vtkFaceType << " num " << faceId << " contains " << edgesWithNodes.nbElems << " edges");
//CHRONOSTOP(40);
for (int iedge = 0; iedge < edgesWithNodes.nbElems; iedge++)
{
// --- check if the edge is already registered by exploration of the faces
//CHRONO(41);
vector<int> vtkIds;
unsigned char vtkEdgeType = edgesWithNodes.elems[iedge].vtkType;
int *pts = &edgesWithNodes.elems[iedge].nodeIds[0];
SMDS_Down1D* downEdge = static_cast<SMDS_Down1D*> (_downArray[vtkEdgeType]);
int nbVtkCells = downEdge->computeVtkCells(pts, vtkIds);
//CHRONOSTOP(41);CHRONO(42);
int downFaces[1000];
unsigned char downTypes[1000];
int nbDownFaces = downEdge->computeFaces(pts, &vtkIds[0], nbVtkCells, downFaces, downTypes);
//CHRONOSTOP(42);
//CHRONO(43);
int connEdgeId = -1;
for (int idf = 0; idf < nbDownFaces; idf++)
{
int faceId2 = downFaces[idf];
int faceType = downTypes[idf];
//ASSERT(_downArray[faceType]);
SMDS_Down2D* downFace2 = static_cast<SMDS_Down2D*> (_downArray[faceType]);
connEdgeId = downFace2->FindEdgeByNodes(faceId2, edgesWithNodes.elems[iedge]);
if (connEdgeId >= 0)
break; // --- edge already created
}//CHRONOSTOP(43);
// --- if edge is not registered in the faces, create edge
if (connEdgeId < 0)
{
//CHRONO(44);
connEdgeId = _downArray[vtkEdgeType]->addCell();
downEdge->setNodes(connEdgeId, edgesWithNodes.elems[iedge].nodeIds);
//CHRONOSTOP(44);
}
// --- mark faces in downward edge and mark edge in downward faces
//CHRONO(45);
for (int idf = 0; idf < nbDownFaces; idf++)
{
int faceId2 = downFaces[idf];
int faceType = downTypes[idf];
//ASSERT(_downArray[faceType]);
SMDS_Down2D* downFace2 = static_cast<SMDS_Down2D*> (_downArray[faceType]);
_downArray[vtkEdgeType]->addUpCell(connEdgeId, faceId2, faceType);
_downArray[faceType]->addDownCell(faceId2, connEdgeId, vtkEdgeType);
// MESSAGE(" From face t:" << vtkFaceType << " " << faceId <<
// " edge " << connEdgeId << " belongs to face t:" << faceType << " " << faceId2);
}//CHRONOSTOP(45);
}
}
}
CHRONOSTOP(23);CHRONO(24);
// compact downward connectivity structure: adjust downward arrays size, replace vector<vector int>> by a single vector<int>
// 3D first then 2D and last 1D to release memory before edge upCells reorganization, (temporary memory use)
for (int vtkType = VTK_QUADRATIC_PYRAMID; vtkType >= 0; vtkType--)
{
if (SMDS_Downward *down = _downArray[vtkType])
{
down->compactStorage();
}
}
// --- Statistics
for (int vtkType = 0; vtkType <= VTK_QUADRATIC_PYRAMID; vtkType++)
{
if (SMDS_Downward *down = _downArray[vtkType])
{
if (down->getMaxId())
{
MESSAGE("Cells of Type " << vtkType << " : number of entities, est: "
<< GuessSize[vtkType] << " real: " << down->getMaxId());
}
}
}CHRONOSTOP(24);CHRONOSTOP(2);
counters::stats();
}
/*! Get the neighbors of a cell.
* Only the neighbors having the dimension of the cell are taken into account
* (neighbors of a volume are the volumes sharing a face with this volume,
* neighbors of a face are the faces sharing an edge with this face...).
* @param neighborsVtkIds vector of neighbors vtk id's to fill (reserve enough space).
* @param downIds downward id's of cells of dimension n-1, to fill (reserve enough space).
* @param downTypes vtk types of cells of dimension n-1, to fill (reserve enough space).
* @param vtkId the vtk id of the cell
* @return number of neighbors
*/
int SMDS_UnstructuredGrid::GetNeighbors(int* neighborsVtkIds, int* downIds, unsigned char* downTypes, int vtkId)
{
int vtkType = this->GetCellType(vtkId);
int cellDim = SMDS_Downward::getCellDimension(vtkType);
if (cellDim != 3)
return 0; // TODO voisins des faces ou edges
int cellId = this->_cellIdToDownId[vtkId];
int nbCells = _downArray[vtkType]->getNumberOfDownCells(cellId);
const int *downCells = _downArray[vtkType]->getDownCells(cellId);
const unsigned char* downTyp = _downArray[vtkType]->getDownTypes(cellId);
// --- iteration on faces of the 3D cell.
int nb = 0;
for (int i = 0; i < nbCells; i++)
{
int downId = downCells[i];
int cellType = downTyp[i];
int nbUp = _downArray[cellType]->getNumberOfUpCells(downId);
const int *upCells = _downArray[cellType]->getUpCells(downId);
const unsigned char* upTypes = _downArray[cellType]->getUpTypes(downId);
// --- max 2 upCells, one is this cell, the other is a neighbor
for (int j = 0; j < nbUp; j++)
{
if ((upCells[j] == cellId) && (upTypes[j] == vtkType))
continue;
int vtkNeighbor = _downArray[upTypes[j]]->getVtkCellId(upCells[j]);
neighborsVtkIds[nb] = vtkNeighbor;
downIds[nb] = downId;
downTypes[nb] = cellType;
nb++;
}
if (nb >= NBMAXNEIGHBORS)
assert(0);
}
return nb;
}
/*! get the node id's of a cell.
* The cell is defined by it's downward connectivity id and type.
* @param nodeSet set of of vtk node id's to fill.
* @param downId downward connectivity id of the cell.
* @param downType type of cell.
*/
void SMDS_UnstructuredGrid::GetNodeIds(std::set<int>& nodeSet, int downId, unsigned char downType)
{
_downArray[downType]->getNodeIds(downId, nodeSet);
}
/*! change some nodes in cell without modifying type or internal connectivity.
* Nodes inverse connectivity is maintained up to date.
* @param vtkVolId vtk id of the cell
* @param localClonedNodeIds map old node id to new node id.
*/
void SMDS_UnstructuredGrid::ModifyCellNodes(int vtkVolId, std::map<int, int> localClonedNodeIds)
{
vtkIdType npts = 0;
vtkIdType *pts; // will refer to the point id's of the face
this->GetCellPoints(vtkVolId, npts, pts);
for (int i = 0; i < npts; i++)
{
if (localClonedNodeIds.count(pts[i]))
{
vtkIdType oldpt = pts[i];
pts[i] = localClonedNodeIds[oldpt];
//MESSAGE(oldpt << " --> " << pts[i]);
//this->RemoveReferenceToCell(oldpt, vtkVolId);
//this->AddReferenceToCell(pts[i], vtkVolId);
}
}
}
/*! Create a volume (prism or hexahedron) by duplication of a face.
* the nodes of the new face are already created.
* @param vtkVolId vtk id of a volume containing the face, to get an orientation for the face.
* @param localClonedNodeIds map old node id to new node id.
* @return vtk id of the new volume.
*/
int SMDS_UnstructuredGrid::getOrderedNodesOfFace(int vtkVolId, std::vector<int>& orderedNodes)
{
int vtkType = this->GetCellType(vtkVolId);
int cellDim = SMDS_Downward::getCellDimension(vtkType);
if (cellDim != 3)
return 0;
SMDS_Down3D *downvol = static_cast<SMDS_Down3D*> (_downArray[vtkType]);
int downVolId = this->_cellIdToDownId[vtkVolId];
downvol->getOrderedNodesOfFace(downVolId, orderedNodes);
return orderedNodes.size();
}

View File

@ -0,0 +1,80 @@
/*
* File: SMDS_UnstructuredGrid.hxx
* Author: prascle
*
* Created on September 16, 2009, 10:28 PM
*/
#ifndef _SMDS_UNSTRUCTUREDGRID_HXX
#define _SMDS_UNSTRUCTUREDGRID_HXX
#include <vtkUnstructuredGrid.h>
#include "chrono.hxx"
#include <vector>
#include <set>
#include <map>
//#define VTK_HAVE_POLYHEDRON
//#ifdef VTK_HAVE_POLYHEDRON
#define VTK_MAXTYPE VTK_POLYHEDRON
//#else
// #define VTK_MAXTYPE VTK_QUADRATIC_PYRAMID
//#endif
#define NBMAXNEIGHBORS 100
// allow very huge polyhedrons in tests
#define NBMAXNODESINCELL 5000
class SMDS_Downward;
class SMDS_Mesh;
class SMDS_UnstructuredGrid: public vtkUnstructuredGrid
{
public:
void setSMDS_mesh(SMDS_Mesh *mesh);
void compactGrid(std::vector<int>& idNodesOldToNew, int newNodeSize, std::vector<int>& idCellsOldToNew,
int newCellSize);
virtual unsigned long GetMTime();
virtual void Update();
virtual void UpdateInformation();
virtual vtkPoints *GetPoints();
//#ifdef VTK_HAVE_POLYHEDRON
int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
//#endif
int CellIdToDownId(int vtkCellId);
void setCellIdToDownId(int vtkCellId, int downId);
void BuildDownwardConnectivity(bool withEdges);
int GetNeighbors(int* neighborsVtkIds, int* downIds, unsigned char* downTypes, int vtkId);
void GetNodeIds(std::set<int>& nodeSet, int downId, unsigned char downType);
void ModifyCellNodes(int vtkVolId, std::map<int, int> localClonedNodeIds);
int getOrderedNodesOfFace(int vtkVolId, std::vector<int>& orderedNodes);
vtkCellLinks* GetLinks()
{
return Links;
}
SMDS_Downward* getDownArray(unsigned char vtkType)
{
return _downArray[vtkType];
}
static SMDS_UnstructuredGrid* New();
SMDS_Mesh *_mesh;
protected:
SMDS_UnstructuredGrid();
~SMDS_UnstructuredGrid();
void copyNodes(vtkPoints *newPoints, std::vector<int>& idNodesOldToNew, int& alreadyCopied, int start, int end);
void copyBloc(vtkUnsignedCharArray *newTypes, std::vector<int>& idCellsOldToNew, std::vector<int>& idNodesOldToNew,
vtkCellArray* newConnectivity, vtkIdTypeArray* newLocations, vtkIdType* pointsCell, int& alreadyCopied,
int start, int end);
std::vector<int> _cellIdToDownId; //!< convert vtk Id to downward[vtkType] id, initialized with -1
std::vector<unsigned char> _downTypes;
std::vector<SMDS_Downward*> _downArray;
};
#endif /* _SMDS_UNSTRUCTUREDGRID_HXX */

View File

@ -36,25 +36,13 @@ using namespace std;
//purpose :
//=======================================================================
SMDS_VertexPosition:: SMDS_VertexPosition(const int aVertexId)
:SMDS_Position(aVertexId)
SMDS_VertexPosition:: SMDS_VertexPosition()
{
//MESSAGE("*********************************************** SMDS_VertexPosition " << aVertexId);
}
//=======================================================================
//function : Coords
//purpose :
//=======================================================================
const double *SMDS_VertexPosition::Coords() const
{
const static double origin[]={0,0,0};
MESSAGE("SMDS_VertexPosition::Coords not implemented");
return origin;
}
SMDS_TypeOfPosition SMDS_VertexPosition::GetTypeOfPosition() const
{
//MESSAGE("################################################# GetTypeOfPosition");
return SMDS_TOP_VERTEX;
}

View File

@ -36,8 +36,7 @@ class SMDS_EXPORT SMDS_VertexPosition:public SMDS_Position
public:
SMDS_TypeOfPosition GetTypeOfPosition() const;
SMDS_VertexPosition(int aVertexId=0);
const double *Coords() const;
SMDS_VertexPosition();
};
#endif

View File

@ -31,6 +31,7 @@
#include "SMDS_VolumeOfFaces.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "utilities.h"
using namespace std;
@ -96,6 +97,7 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
const SMDS_MeshFace * face3,
const SMDS_MeshFace * face4)
{
//MESSAGE("****************************************************** SMDS_VolumeOfFaces");
myNbFaces = 4;
myFaces[0]=face1;
myFaces[1]=face2;
@ -111,6 +113,7 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
const SMDS_MeshFace * face4,
const SMDS_MeshFace * face5)
{
//MESSAGE("****************************************************** SMDS_VolumeOfFaces");
myNbFaces = 5;
myFaces[0]=face1;
myFaces[1]=face2;
@ -127,6 +130,7 @@ SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
const SMDS_MeshFace * face5,
const SMDS_MeshFace * face6)
{
//MESSAGE("****************************************************** SMDS_VolumeOfFaces");
myNbFaces = 6;
myFaces[0]=face1;
myFaces[1]=face2;

View File

@ -56,8 +56,9 @@ class SMDS_EXPORT SMDS_VolumeOfFaces:public SMDS_MeshVolume
const SMDS_MeshFace * face6);
virtual SMDSAbs_EntityType GetEntityType() const;
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) {return false;};
void Print(std::ostream & OS) const;
int NbFaces() const;
protected:

View File

@ -30,10 +30,9 @@
#include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
#include "SMDS_VolumeTool.hxx"
#include "SMDS_Mesh.hxx"
#include "utilities.h"
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////////////////////////
@ -50,6 +49,7 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
const SMDS_MeshNode * node7,
const SMDS_MeshNode * node8)
{
//MESSAGE("***************************************************** SMDS_VolumeOfNodes");
myNbNodes = 8;
myNodes = new const SMDS_MeshNode* [myNbNodes];
myNodes[0]=node1;
@ -68,6 +68,7 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
const SMDS_MeshNode * node3,
const SMDS_MeshNode * node4)
{
//MESSAGE("***************************************************** SMDS_VolumeOfNodes");
myNbNodes = 4;
myNodes = new const SMDS_MeshNode* [myNbNodes];
myNodes[0]=node1;
@ -83,6 +84,7 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
const SMDS_MeshNode * node4,
const SMDS_MeshNode * node5)
{
//MESSAGE("***************************************************** SMDS_VolumeOfNodes");
myNbNodes = 5;
myNodes = new const SMDS_MeshNode* [myNbNodes];
myNodes[0]=node1;
@ -100,6 +102,7 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(
const SMDS_MeshNode * node5,
const SMDS_MeshNode * node6)
{
//MESSAGE("***************************************************** SMDS_VolumeOfNodes");
myNbNodes = 6;
myNodes = new const SMDS_MeshNode* [myNbNodes];
myNodes[0]=node1;
@ -133,11 +136,6 @@ SMDS_VolumeOfNodes::~SMDS_VolumeOfNodes()
}
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_VolumeOfNodes::Print(ostream & OS) const
{
OS << "volume <" << GetID() << "> : ";
@ -177,12 +175,9 @@ int SMDS_VolumeOfNodes::NbEdges() const
return 0;
}
/// ===================================================================
/*!
* \brief Iterator on node of volume
*/
/// ===================================================================
class SMDS_VolumeOfNodes_MyIterator:public SMDS_NodeArrayElemIterator
{
public:
@ -190,12 +185,9 @@ class SMDS_VolumeOfNodes_MyIterator:public SMDS_NodeArrayElemIterator
SMDS_NodeArrayElemIterator( s, & s[ l ]) {}
};
/// ===================================================================
/*!
* \brief Iterator on faces or edges of volume
*/
/// ===================================================================
class _MySubIterator : public SMDS_ElemIterator
{
vector< const SMDS_MeshElement* > myElems;
@ -261,3 +253,5 @@ SMDSAbs_EntityType SMDS_VolumeOfNodes::GetEntityType() const
}
return aType;
}

View File

@ -85,5 +85,7 @@ class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume
elementsIterator(SMDSAbs_ElementType type) const;
const SMDS_MeshNode** myNodes;
int myNbNodes;
};
#endif

View File

@ -32,7 +32,7 @@
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
#include "SMDS_VtkVolume.hxx"
#include "SMDS_Mesh.hxx"
#include "utilities.h"
@ -418,6 +418,7 @@ SMDS_VolumeTool::SMDS_VolumeTool ()
myFaceNodeIndices( NULL ),
myFaceNodes( NULL )
{
//MESSAGE("******************************************************** SMDS_VolumeToo");
}
//=======================================================================
@ -438,6 +439,7 @@ SMDS_VolumeTool::SMDS_VolumeTool (const SMDS_MeshElement* theVolume)
myFaceNodeIndices( NULL ),
myFaceNodes( NULL )
{
//MESSAGE("******************************************************** SMDS_VolumeToo");
Set( theVolume );
}
@ -499,7 +501,7 @@ bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume)
}
if (myVolume->IsPoly()) {
myPolyedre = static_cast<const SMDS_PolyhedralVolumeOfNodes*>( myVolume );
myPolyedre = dynamic_cast<const SMDS_VtkVolume*>( myVolume );
if (!myPolyedre) {
MESSAGE("Warning: bad volumic element");
return false;
@ -694,12 +696,13 @@ double SMDS_VolumeTool::GetSize() const
if ( !myPolyedre )
return 0.;
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myPolyedre->getMeshId()];
// split a polyhedron into tetrahedrons
SMDS_VolumeTool* me = const_cast< SMDS_VolumeTool* > ( this );
XYZ baryCenter;
me->GetBaryCenter(baryCenter.x, baryCenter.y, baryCenter.z);
SMDS_MeshNode bcNode ( baryCenter.x, baryCenter.y, baryCenter.z );
SMDS_MeshNode *bcNode = mesh->AddNode( baryCenter.x, baryCenter.y, baryCenter.z );
for ( int f = 0; f < NbFaces(); ++f )
{
@ -709,11 +712,12 @@ double SMDS_VolumeTool::GetSize() const
double Vn = getTetraVolume( myFaceNodes[ 0 ],
myFaceNodes[ n-1 ],
myFaceNodes[ n ],
& bcNode );
bcNode );
/// cout <<"++++ " << Vn << " nodes " <<myFaceNodes[ 0 ]->GetID() << " " <<myFaceNodes[ n-1 ]->GetID() << " " <<myFaceNodes[ n ]->GetID() << " < " << V << endl;
V += externalFace ? -Vn : Vn;
}
}
mesh->RemoveNode(bcNode);
}
else
{

View File

@ -33,7 +33,7 @@
class SMDS_MeshElement;
class SMDS_MeshNode;
class SMDS_PolyhedralVolumeOfNodes;
class SMDS_VtkVolume;
class SMDS_MeshVolume;
#include <vector>
@ -212,7 +212,7 @@ private:
bool setFace( int faceIndex );
const SMDS_MeshElement* myVolume;
const SMDS_PolyhedralVolumeOfNodes* myPolyedre;
const SMDS_VtkVolume* myPolyedre;
bool myVolForward;
int myNbFaces;

View File

@ -0,0 +1,234 @@
#include "SMDS_VtkCellIterator.hxx"
#include "utilities.h"
SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
_mesh(mesh), _cellId(vtkCellId), _index(0), _type(aType)
{
//MESSAGE("SMDS_VtkCellIterator " << _type);
_vtkIdList = vtkIdList::New();
vtkUnstructuredGrid* grid = _mesh->getGrid();
grid->GetCellPoints(_cellId, _vtkIdList);
_nbNodes = _vtkIdList->GetNumberOfIds();
switch (_type)
{
case SMDSEntity_Tetra:
{
this->exchange(1, 2);
break;
}
case SMDSEntity_Pyramid:
{
this->exchange(1, 3);
break;
}
case SMDSEntity_Penta:
{
//this->exchange(1, 2);
//this->exchange(4, 5);
break;
}
case SMDSEntity_Hexa:
{
this->exchange(1, 3);
this->exchange(5, 7);
break;
}
case SMDSEntity_Quad_Tetra:
{
this->exchange(1, 2);
this->exchange(4, 6);
this->exchange(8, 9);
break;
}
case SMDSEntity_Quad_Pyramid:
{
this->exchange(1, 3);
this->exchange(5, 8);
this->exchange(6, 7);
this->exchange(10, 12);
break;
}
case SMDSEntity_Quad_Penta:
{
//this->exchange(1, 2);
//this->exchange(4, 5);
//this->exchange(6, 8);
//this->exchange(9, 11);
//this->exchange(13, 14);
break;
}
case SMDSEntity_Quad_Hexa:
{
MESSAGE("SMDS_VtkCellIterator Quad_Hexa");
this->exchange(1, 3);
this->exchange(5, 7);
this->exchange(8, 11);
this->exchange(9, 10);
this->exchange(12, 15);
this->exchange(13, 14);
this->exchange(17, 19);
break;
}
case SMDSEntity_Polyhedra:
MESSAGE("SMDS_VtkCellIterator Polyhedra (iterate on actual nodes)");
break;
default:
break;
}
}
SMDS_VtkCellIterator::~SMDS_VtkCellIterator()
{
_vtkIdList->Delete();
}
bool SMDS_VtkCellIterator::more()
{
return (_index < _nbNodes);
}
const SMDS_MeshElement* SMDS_VtkCellIterator::next()
{
vtkIdType id = _vtkIdList->GetId(_index++);
return _mesh->FindNodeVtk(id);
}
SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
SMDS_VtkCellIterator()
{
_mesh = mesh;
_cellId = vtkCellId;
_index = 0;
_type = aType;
//MESSAGE("SMDS_VtkCellInterlacedIterator (UNV)" << _type);
_vtkIdList = vtkIdList::New();
vtkIdType* pts;
vtkUnstructuredGrid* grid = _mesh->getGrid();
grid->GetCellPoints(_cellId, _nbNodes, pts);
_vtkIdList->SetNumberOfIds(_nbNodes);
int *ids = 0;
switch (_type)
{
case SMDSEntity_Quad_Edge:
{
static int id[] = { 0, 2, 1 };
ids = id;
break;
}
case SMDSEntity_Quad_Triangle:
{
static int id[] = { 0, 3, 1, 4, 2, 5 };
ids = id;
break;
}
case SMDSEntity_Quad_Quadrangle:
{
static int id[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
ids = id;
break;
}
case SMDSEntity_Quad_Tetra:
{
static int id[] = { 0, 4, 1, 5, 2, 6, 7, 8, 9, 3 };
ids = id;
break;
}
case SMDSEntity_Quad_Pyramid:
{
static int id[] = { 0, 5, 1, 6, 2, 7, 3, 8, 9, 10, 11, 12, 4 };
ids = id;
break;
}
case SMDSEntity_Penta:
{
static int id[] = { 0, 2, 1, 3, 5, 4 };
ids = id;
break;
}
case SMDSEntity_Quad_Penta:
{
static int id[] = { 0, 8, 2, 7, 1, 6, 12, 14, 13, 3, 11, 5, 10, 4, 9 };
ids = id;
break;
}
case SMDSEntity_Quad_Hexa:
{
static int id[] = { 0, 8, 1, 9, 2, 10, 3, 11, 16, 17, 18, 19, 4, 12, 5, 13, 6, 14, 7, 15 };
ids = id;
break;
}
case SMDSEntity_Polygon:
case SMDSEntity_Quad_Polygon:
case SMDSEntity_Polyhedra:
case SMDSEntity_Quad_Polyhedra:
default:
{
static int id[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29 };
ids = id;
break;
}
}
//MESSAGE("_nbNodes " << _nbNodes);
for (int i = 0; i < _nbNodes; i++)
_vtkIdList->SetId(i, pts[ids[i]]);
}
SMDS_VtkCellIteratorToUNV::~SMDS_VtkCellIteratorToUNV()
{
}
SMDS_VtkCellIteratorPolyH::SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
SMDS_VtkCellIterator()
{
_mesh = mesh;
_cellId = vtkCellId;
_index = 0;
_type = aType;
//MESSAGE("SMDS_VtkCellIteratorPolyH " << _type);
_vtkIdList = vtkIdList::New();
vtkUnstructuredGrid* grid = _mesh->getGrid();
grid->GetCellPoints(_cellId, _vtkIdList);
_nbNodes = _vtkIdList->GetNumberOfIds();
switch (_type)
{
case SMDSEntity_Polyhedra:
{
//MESSAGE("SMDS_VtkCellIterator Polyhedra");
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(_cellId, nFaces, ptIds);
int id = 0;
_nbNodesInFaces = 0;
for (int i = 0; i < nFaces; i++)
{
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
_nbNodesInFaces += nodesInFace;
id += (nodesInFace + 1);
}
_vtkIdList->SetNumberOfIds(_nbNodesInFaces);
id = 0;
int n = 0;
for (int i = 0; i < nFaces; i++)
{
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
for (int k = 1; k <= nodesInFace; k++)
_vtkIdList->SetId(n++, ptIds[id + k]);
id += (nodesInFace + 1);
}
break;
}
default:
assert(0);
}
}
SMDS_VtkCellIteratorPolyH::~SMDS_VtkCellIteratorPolyH()
{
}
bool SMDS_VtkCellIteratorPolyH::more()
{
return (_index < _nbNodesInFaces);
}

View File

@ -0,0 +1,53 @@
#ifndef _SMDS_VTKCELLITERATOR_HXX_
#define _SMDS_VTKCELLITERATOR_HXX_
#include "SMDS_ElemIterator.hxx"
#include "SMDS_Mesh.hxx"
#include "SMDSAbs_ElementType.hxx"
#include <vtkCell.h>
#include <vtkIdList.h>
class SMDS_VtkCellIterator: public SMDS_ElemIterator
{
public:
SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType);
virtual ~SMDS_VtkCellIterator();
virtual bool more();
virtual const SMDS_MeshElement* next();
inline void exchange(vtkIdType a, vtkIdType b)
{
vtkIdType t = _vtkIdList->GetId(a);
_vtkIdList->SetId(a, _vtkIdList->GetId(b));
_vtkIdList->SetId(b, t);
}
protected:
SMDS_VtkCellIterator() {};
SMDS_Mesh* _mesh;
int _cellId;
int _index;
int _nbNodes;
SMDSAbs_EntityType _type;
vtkIdList* _vtkIdList;
};
class SMDS_VtkCellIteratorToUNV: public SMDS_VtkCellIterator
{
public:
SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType);
virtual ~SMDS_VtkCellIteratorToUNV();
};
class SMDS_VtkCellIteratorPolyH: public SMDS_VtkCellIterator
{
public:
SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType);
virtual ~SMDS_VtkCellIteratorPolyH();
virtual bool more();
protected:
int _nbNodesInFaces;
};
#endif

151
src/SMDS/SMDS_VtkEdge.cxx Normal file
View File

@ -0,0 +1,151 @@
#include "SMDS_VtkEdge.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_Mesh.hxx"
#include "SMDS_VtkCellIterator.hxx"
#include "utilities.h"
#include <vector>
#include <cassert>
using namespace std;
SMDS_VtkEdge::SMDS_VtkEdge()
{
}
SMDS_VtkEdge::SMDS_VtkEdge(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
init(nodeIds, mesh);
}
SMDS_VtkEdge::~SMDS_VtkEdge()
{
}
void SMDS_VtkEdge::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
vtkUnstructuredGrid* grid = mesh->getGrid();
myIdInShape = -1;
myMeshId = mesh->getMeshId();
vtkIdType aType = VTK_LINE;
if (nodeIds.size() == 3)
aType = VTK_QUADRATIC_EDGE;
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
mesh->setMyModified();
//MESSAGE("SMDS_VtkEdge::init myVtkID " << myVtkID);
}
bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2)
{
const SMDS_MeshNode* nodes[] = { node1, node2 };
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return ChangeNodes(nodes, 2);
}
bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts)
{
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false;
}
for (int i = 0; i < nbNodes; i++)
{
pts[i] = nodes[i]->getVtkId();
}
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
}
bool SMDS_VtkEdge::IsMediumNode(const SMDS_MeshNode* node) const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
//MESSAGE("IsMediumNode " << npts << " " << (node->getVtkId() == pts[npts-1]));
return ((npts == 3) && (node->getVtkId() == pts[2]));
}
void SMDS_VtkEdge::Print(std::ostream & OS) const
{
OS << "edge <" << GetID() << "> : ";
}
int SMDS_VtkEdge::NbNodes() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
assert(nbPoints >= 2);
return nbPoints;
}
int SMDS_VtkEdge::NbEdges() const
{
return 1;
}
SMDSAbs_EntityType SMDS_VtkEdge::GetEntityType() const
{
if (NbNodes() == 2)
return SMDSEntity_Edge;
else
return SMDSEntity_Quad_Edge;
}
vtkIdType SMDS_VtkEdge::GetVtkType() const
{
if (NbNodes() == 2)
return VTK_LINE;
else
return VTK_QUADRATIC_EDGE;
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
const SMDS_MeshNode*
SMDS_VtkEdge::GetNode(const int ind) const
{
// TODO optimize !!
return SMDS_MeshElement::GetNode(ind);
}
bool SMDS_VtkEdge::IsQuadratic() const
{
if (this->NbNodes() > 2)
return true;
else
return false;
}
SMDS_ElemIteratorPtr SMDS_VtkEdge::elementsIterator(SMDSAbs_ElementType type) const
{
switch (type)
{
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
default:
MESSAGE("ERROR : Iterator not implemented")
;
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
}
}
SMDS_ElemIteratorPtr SMDS_VtkEdge::nodesIteratorToUNV() const
{
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}
SMDS_ElemIteratorPtr SMDS_VtkEdge::interlacedNodesElemIterator() const
{
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}

36
src/SMDS/SMDS_VtkEdge.hxx Normal file
View File

@ -0,0 +1,36 @@
#ifndef _SMDS_VTKEDGE_HXX_
#define _SMDS_VTKEDGE_HXX_
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshEdge.hxx"
#include <vtkUnstructuredGrid.h>
#include <vector>
class SMDS_EXPORT SMDS_VtkEdge: public SMDS_MeshEdge
{
public:
SMDS_VtkEdge();
SMDS_VtkEdge(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
~SMDS_VtkEdge();
void init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
bool ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2);
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
void Print(std::ostream & OS) const;
int NbNodes() const;
int NbEdges() const;
virtual vtkIdType GetVtkType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual bool IsQuadratic() const;
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
protected:
};
#endif

262
src/SMDS/SMDS_VtkFace.cxx Normal file
View File

@ -0,0 +1,262 @@
#include "SMDS_VtkFace.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_Mesh.hxx"
#include "SMDS_VtkCellIterator.hxx"
#include "utilities.h"
#include <vector>
using namespace std;
SMDS_VtkFace::SMDS_VtkFace()
{
}
SMDS_VtkFace::SMDS_VtkFace(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
init(nodeIds, mesh);
}
SMDS_VtkFace::~SMDS_VtkFace()
{
}
void SMDS_VtkFace::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
vtkUnstructuredGrid* grid = mesh->getGrid();
myIdInShape = -1;
myMeshId = mesh->getMeshId();
vtkIdType aType = VTK_TRIANGLE;
switch (nodeIds.size())
{
case 3:
aType = VTK_TRIANGLE;
break;
case 4:
aType = VTK_QUAD;
break;
case 6:
aType = VTK_QUADRATIC_TRIANGLE;
break;
case 8:
aType = VTK_QUADRATIC_QUAD;
break;
default:
aType = VTK_POLYGON;
break;
}
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
mesh->setMyModified();
//MESSAGE("SMDS_VtkFace::init myVtkID " << myVtkID);
}
void SMDS_VtkFace::initPoly(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
vtkUnstructuredGrid* grid = mesh->getGrid();
myIdInShape = -1;
myMeshId = mesh->getMeshId();
myVtkID = grid->InsertNextLinkedCell(VTK_POLYGON, nodeIds.size(), &nodeIds[0]);
mesh->setMyModified();
}
bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts)
{
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false;
}
for (int i = 0; i < nbNodes; i++)
{
pts[i] = nodes[i]->getVtkId();
}
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
}
void SMDS_VtkFace::Print(std::ostream & OS) const
{
OS << "face <" << GetID() << "> : ";
}
int SMDS_VtkFace::NbEdges() const
{
// TODO quadratic polygons ?
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int nbEdges = 3;
switch (aVtkType)
{
case VTK_TRIANGLE:
case VTK_QUADRATIC_TRIANGLE:
nbEdges = 3;
break;
case VTK_QUAD:
case VTK_QUADRATIC_QUAD:
nbEdges = 4;
break;
case VTK_POLYGON:
default:
nbEdges = grid->GetCell(myVtkID)->GetNumberOfPoints();
break;
}
return nbEdges;
}
int SMDS_VtkFace::NbFaces() const
{
return 1;
}
int SMDS_VtkFace::NbNodes() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
return nbPoints;
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
const SMDS_MeshNode*
SMDS_VtkFace::GetNode(const int ind) const
{
return SMDS_MeshElement::GetNode(ind); // --- a optimiser !
}
bool SMDS_VtkFace::IsQuadratic() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
// TODO quadratic polygons ?
switch (aVtkType)
{
case VTK_QUADRATIC_TRIANGLE:
case VTK_QUADRATIC_QUAD:
return true;
break;
default:
return false;
}
}
bool SMDS_VtkFace::IsPoly() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
return (aVtkType == VTK_POLYGON);
}
bool SMDS_VtkFace::IsMediumNode(const SMDS_MeshNode* node) const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int rankFirstMedium = 0;
switch (aVtkType)
{
case VTK_QUADRATIC_TRIANGLE:
rankFirstMedium = 3; // medium nodes are of rank 3,4,5
break;
case VTK_QUADRATIC_QUAD:
rankFirstMedium = 4; // medium nodes are of rank 4,5,6,7
break;
default:
//MESSAGE("wrong element type " << aVtkType);
return false;
}
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
vtkIdType nodeId = node->getVtkId();
for (int rank = 0; rank < npts; rank++)
{
if (pts[rank] == nodeId)
{
//MESSAGE("rank " << rank << " is medium node " << (rank < rankFirstMedium));
if (rank < rankFirstMedium)
return false;
else
return true;
}
}
//throw SALOME_Exception(LOCALIZED("node does not belong to this element"));
MESSAGE("======================================================");
MESSAGE("= IsMediumNode: node does not belong to this element =");
MESSAGE("======================================================");
return false;
}
SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
SMDSAbs_EntityType aType = SMDSEntity_Polygon;
switch (aVtkType)
{
case VTK_TRIANGLE:
aType = SMDSEntity_Triangle;
break;
case VTK_QUAD:
aType = SMDSEntity_Quadrangle;
break;
case VTK_QUADRATIC_TRIANGLE:
aType = SMDSEntity_Quad_Triangle;
break;
case VTK_QUADRATIC_QUAD:
aType = SMDSEntity_Quad_Quadrangle;
break;
default:
aType = SMDSEntity_Polygon;
}
return aType;
}
vtkIdType SMDS_VtkFace::GetVtkType() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
return aVtkType;
}
SMDS_ElemIteratorPtr SMDS_VtkFace::elementsIterator(SMDSAbs_ElementType type) const
{
switch (type)
{
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
default:
MESSAGE("ERROR : Iterator not implemented")
;
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
}
}
SMDS_ElemIteratorPtr SMDS_VtkFace::nodesIteratorToUNV() const
{
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}
SMDS_ElemIteratorPtr SMDS_VtkFace::interlacedNodesElemIterator() const
{
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}
//! change only the first node, used for temporary triangles in quadrangle to triangle adaptor
void SMDS_VtkFace::ChangeApex(const SMDS_MeshNode* node)
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
grid->RemoveReferenceToCell(pts[0], myVtkID);
pts[0] = node->getVtkId();
grid->AddReferenceToCell(pts[0], myVtkID);
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
}

38
src/SMDS/SMDS_VtkFace.hxx Normal file
View File

@ -0,0 +1,38 @@
#ifndef _SMDS_VTKFACE_HXX_
#define _SMDS_VTKFACE_HXX_
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshFace.hxx"
#include <vtkUnstructuredGrid.h>
#include <vector>
class SMDS_EXPORT SMDS_VtkFace: public SMDS_MeshFace
{
public:
SMDS_VtkFace();
SMDS_VtkFace(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
~SMDS_VtkFace();
void init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
void initPoly(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
void ChangeApex(const SMDS_MeshNode* node); // to use only for tmp triangles
void Print(std::ostream & OS) const;
int NbEdges() const;
int NbFaces() const;
int NbNodes() const;
virtual vtkIdType GetVtkType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual bool IsQuadratic() const;
virtual bool IsPoly() const;
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
protected:
};
#endif

594
src/SMDS/SMDS_VtkVolume.cxx Normal file
View File

@ -0,0 +1,594 @@
#include "SMDS_VtkVolume.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_Mesh.hxx"
#include "SMDS_VtkCellIterator.hxx"
#include "utilities.h"
#include <vector>
SMDS_VtkVolume::SMDS_VtkVolume()
{
}
SMDS_VtkVolume::SMDS_VtkVolume(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
init(nodeIds, mesh);
}
/*!
* typed used are vtk types (@see vtkCellType.h)
* see GetEntityType() for conversion in SMDS type (@see SMDSAbs_ElementType.hxx)
*/
void SMDS_VtkVolume::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
vtkUnstructuredGrid* grid = mesh->getGrid();
myIdInShape = -1;
myMeshId = mesh->getMeshId();
vtkIdType aType = VTK_TETRA;
switch (nodeIds.size())
{
case 4:
aType = VTK_TETRA;
break;
case 5:
aType = VTK_PYRAMID;
break;
case 6:
aType = VTK_WEDGE;
break;
case 8:
aType = VTK_HEXAHEDRON;
break;
case 10:
aType = VTK_QUADRATIC_TETRA;
break;
case 13:
aType = VTK_QUADRATIC_PYRAMID;
break;
case 15:
aType = VTK_QUADRATIC_WEDGE;
break;
case 20:
aType = VTK_QUADRATIC_HEXAHEDRON;
break;
default:
aType = VTK_HEXAHEDRON;
break;
}
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
mesh->setMyModified();
//MESSAGE("SMDS_VtkVolume::init myVtkID " << myVtkID);
}
//#ifdef VTK_HAVE_POLYHEDRON
void SMDS_VtkVolume::initPoly(std::vector<vtkIdType> nodeIds, std::vector<int> nbNodesPerFace, SMDS_Mesh* mesh)
{
MESSAGE("SMDS_VtkVolume::initPoly");
SMDS_UnstructuredGrid* grid = mesh->getGrid();
// TODO is it useful to orient faces ?
double center[3];
this->gravityCenter(grid, &nodeIds[0], nodeIds.size(), &center[0]);
vector<vtkIdType> ptIds;
ptIds.clear();
vtkIdType nbFaces = nbNodesPerFace.size();
int k = 0;
for (int i = 0; i < nbFaces; i++)
{
int nf = nbNodesPerFace[i];
ptIds.push_back(nf);
// double a[3];
// double b[3];
// double c[3];
// grid->GetPoints()->GetPoint(nodeIds[k], a);
// grid->GetPoints()->GetPoint(nodeIds[k + 1], b);
// grid->GetPoints()->GetPoint(nodeIds[k + 2], c);
// bool isFaceForward = this->isForward(a, b, c, center);
bool isFaceForward = true;
//MESSAGE("isFaceForward " << i << " " << isFaceForward);
vtkIdType *facePts = &nodeIds[k];
if (isFaceForward)
for (int n = 0; n < nf; n++)
ptIds.push_back(facePts[n]);
else
for (int n = nf - 1; n >= 0; n--)
ptIds.push_back(facePts[n]);
k += nf;
}
myVtkID = grid->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]);
mesh->setMyModified();
}
//#endif
bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts)
{
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false;
}
for (int i = 0; i < nbNodes; i++)
{
pts[i] = nodes[i]->getVtkId();
}
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
}
/*!
* Reorder in VTK order a list of nodes given in SMDS order.
* To be used before ChangeNodes: lists are given or computed in SMDS order.
*/
bool SMDS_VtkVolume::vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes)
{
if (nbNodes != this->NbNodes())
{
MESSAGE("vtkOrder, wrong number of nodes " << nbNodes << " instead of "<< this->NbNodes());
return false;
}
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
switch (aVtkType)
{
case VTK_TETRA:
this->exchange(nodes, 1, 2);
break;
case VTK_QUADRATIC_TETRA:
this->exchange(nodes, 1, 2);
this->exchange(nodes, 4, 6);
this->exchange(nodes, 8, 9);
break;
case VTK_PYRAMID:
this->exchange(nodes, 1, 3);
break;
case VTK_WEDGE:
break;
case VTK_QUADRATIC_PYRAMID:
this->exchange(nodes, 1, 3);
this->exchange(nodes, 5, 8);
this->exchange(nodes, 6, 7);
this->exchange(nodes, 10, 12);
break;
case VTK_QUADRATIC_WEDGE:
break;
case VTK_HEXAHEDRON:
this->exchange(nodes, 1, 3);
this->exchange(nodes, 5, 7);
break;
case VTK_QUADRATIC_HEXAHEDRON:
this->exchange(nodes, 1, 3);
this->exchange(nodes, 5, 7);
this->exchange(nodes, 8, 11);
this->exchange(nodes, 9, 10);
this->exchange(nodes, 12, 15);
this->exchange(nodes, 13, 14);
this->exchange(nodes, 17, 19);
break;
case VTK_POLYHEDRON:
default:
break;
}
}
SMDS_VtkVolume::~SMDS_VtkVolume()
{
}
void SMDS_VtkVolume::Print(ostream & OS) const
{
OS << "volume <" << GetID() << "> : ";
}
int SMDS_VtkVolume::NbFaces() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int nbFaces = 4;
switch (aVtkType)
{
case VTK_TETRA:
case VTK_QUADRATIC_TETRA:
nbFaces = 4;
break;
case VTK_PYRAMID:
case VTK_WEDGE:
case VTK_QUADRATIC_PYRAMID:
case VTK_QUADRATIC_WEDGE:
nbFaces = 5;
break;
case VTK_HEXAHEDRON:
case VTK_QUADRATIC_HEXAHEDRON:
nbFaces = 6;
break;
case VTK_POLYHEDRON:
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
nbFaces = nFaces;
break;
}
default:
MESSAGE("invalid volume type")
;
nbFaces = 0;
break;
}
return nbFaces;
}
int SMDS_VtkVolume::NbNodes() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int nbPoints = 0;
if (aVtkType != VTK_POLYHEDRON)
{
nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
}
else
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
int id = 0;
for (int i = 0; i < nFaces; i++)
{
int nodesInFace = ptIds[id];
nbPoints += nodesInFace;
id += (nodesInFace + 1);
}
}
return nbPoints;
}
int SMDS_VtkVolume::NbEdges() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int nbEdges = 6;
switch (aVtkType)
{
case VTK_TETRA:
case VTK_QUADRATIC_TETRA:
nbEdges = 6;
break;
case VTK_PYRAMID:
case VTK_QUADRATIC_PYRAMID:
nbEdges = 8;
break;
case VTK_WEDGE:
case VTK_QUADRATIC_WEDGE:
nbEdges = 9;
break;
case VTK_HEXAHEDRON:
case VTK_QUADRATIC_HEXAHEDRON:
nbEdges = 12;
break;
case VTK_POLYHEDRON:
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
nbEdges = 0;
int id = 0;
for (int i = 0; i < nFaces; i++)
{
int edgesInFace = ptIds[id];
id += (edgesInFace + 1);
nbEdges += edgesInFace;
}
nbEdges = nbEdges / 2;
break;
}
default:
MESSAGE("invalid volume type")
;
nbEdges = 0;
break;
}
return nbEdges;
}
/*! polyhedron only,
* 1 <= face_ind <= NbFaces()
*/
int SMDS_VtkVolume::NbFaceNodes(const int face_ind) const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int nbNodes = 0;
if (aVtkType == VTK_POLYHEDRON)
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
int id = 0;
for (int i = 0; i < nFaces; i++)
{
int nodesInFace = ptIds[id];
id += (nodesInFace + 1);
if (i == face_ind - 1)
{
nbNodes = nodesInFace;
break;
}
}
}
return nbNodes;
}
/*! polyhedron only,
* 1 <= face_ind <= NbFaces()
* 1 <= node_ind <= NbFaceNodes()
*/
const SMDS_MeshNode* SMDS_VtkVolume::GetFaceNode(const int face_ind, const int node_ind) const
{
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
vtkUnstructuredGrid* grid = mesh->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
const SMDS_MeshNode* node = 0;
if (aVtkType == VTK_POLYHEDRON)
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
int id = 0;
for (int i = 0; i < nFaces; i++)
{
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
if (i == face_ind - 1) // first face is number 1
{
if ((node_ind > 0) && (node_ind <= nodesInFace))
node = mesh->FindNodeVtk(ptIds[id + node_ind]); // ptIds[id+1] : first node
break;
}
id += (nodesInFace + 1);
}
}
return node;
}
/*! polyhedron only,
* return number of nodes for each face
*/
const std::vector<int> & SMDS_VtkVolume::GetQuantities() const
{
vector<int> quantities;
quantities.clear();
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
vtkUnstructuredGrid* grid = mesh->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
if (aVtkType == VTK_POLYHEDRON)
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
int id = 0;
for (int i = 0; i < nFaces; i++)
{
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
quantities.push_back(nodesInFace);
id += (nodesInFace + 1);
}
}
return quantities;
}
SMDS_ElemIteratorPtr SMDS_VtkVolume::elementsIterator(SMDSAbs_ElementType type) const
{
switch (type)
{
case SMDSAbs_Node:
{
SMDSAbs_EntityType aType = this->GetEntityType();
if (aType == SMDSEntity_Polyhedra)
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorPolyH(SMDS_Mesh::_meshList[myMeshId], myVtkID, aType));
else
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, aType));
}
default:
MESSAGE("ERROR : Iterator not implemented");
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
}
}
SMDS_ElemIteratorPtr SMDS_VtkVolume::nodesIteratorToUNV() const
{
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}
SMDS_ElemIteratorPtr SMDS_VtkVolume::interlacedNodesElemIterator() const
{
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}
SMDSAbs_ElementType SMDS_VtkVolume::GetType() const
{
return SMDSAbs_Volume;
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
const SMDS_MeshNode* SMDS_VtkVolume::GetNode(const int ind) const
{
// TODO optimize if possible (vtkCellIterator)
return SMDS_MeshElement::GetNode(ind);
}
bool SMDS_VtkVolume::IsQuadratic() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
// TODO quadratic polyhedrons ?
switch (aVtkType)
{
case VTK_QUADRATIC_TETRA:
case VTK_QUADRATIC_PYRAMID:
case VTK_QUADRATIC_WEDGE:
case VTK_QUADRATIC_HEXAHEDRON:
return true;
break;
default:
return false;
}
}
bool SMDS_VtkVolume::IsPoly() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
return (aVtkType == VTK_POLYHEDRON);
}
bool SMDS_VtkVolume::IsMediumNode(const SMDS_MeshNode* node) const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int rankFirstMedium = 0;
switch (aVtkType)
{
case VTK_QUADRATIC_TETRA:
rankFirstMedium = 4; // medium nodes are of rank 4 to 9
break;
case VTK_QUADRATIC_PYRAMID:
rankFirstMedium = 5; // medium nodes are of rank 5 to 12
break;
case VTK_QUADRATIC_WEDGE:
rankFirstMedium = 6; // medium nodes are of rank 6 to 14
break;
case VTK_QUADRATIC_HEXAHEDRON:
rankFirstMedium = 8; // medium nodes are of rank 8 to 19
break;
default:
return false;
}
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
vtkIdType nodeId = node->getVtkId();
for (int rank = 0; rank < npts; rank++)
{
if (pts[rank] == nodeId)
{
if (rank < rankFirstMedium)
return false;
else
return true;
}
}
//throw SALOME_Exception(LOCALIZED("node does not belong to this element"));
MESSAGE("======================================================");
MESSAGE("= IsMediumNode: node does not belong to this element =");
MESSAGE("======================================================");
return false;
}
SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
SMDSAbs_EntityType aType = SMDSEntity_Tetra;
switch (aVtkType)
{
case VTK_TETRA:
aType = SMDSEntity_Tetra;
break;
case VTK_PYRAMID:
aType = SMDSEntity_Pyramid;
break;
case VTK_WEDGE:
aType = SMDSEntity_Penta;
break;
case VTK_HEXAHEDRON:
aType = SMDSEntity_Hexa;
break;
case VTK_QUADRATIC_TETRA:
aType = SMDSEntity_Quad_Tetra;
break;
case VTK_QUADRATIC_PYRAMID:
aType = SMDSEntity_Quad_Pyramid;
break;
case VTK_QUADRATIC_WEDGE:
aType = SMDSEntity_Quad_Penta;
break;
case VTK_QUADRATIC_HEXAHEDRON:
aType = SMDSEntity_Quad_Hexa;
break;
//#ifdef VTK_HAVE_POLYHEDRON
case VTK_POLYHEDRON:
aType = SMDSEntity_Polyhedra;
break;
//#endif
default:
aType = SMDSEntity_Polyhedra;
break;
}
return aType;
}
vtkIdType SMDS_VtkVolume::GetVtkType() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aType = grid->GetCellType(myVtkID);
return aType;
}
void SMDS_VtkVolume::gravityCenter(SMDS_UnstructuredGrid* grid, vtkIdType *nodeIds, int nbNodes, double* result)
{
for (int j = 0; j < 3; j++)
result[j] = 0;
if (nbNodes <= 0)
return;
for (int i = 0; i < nbNodes; i++)
{
double *coords = grid->GetPoint(nodeIds[i]);
for (int j = 0; j < 3; j++)
result[j] += coords[j];
}
for (int j = 0; j < 3; j++)
result[j] = result[j] / nbNodes;
//MESSAGE("center " << result[0] << " " << result[1] << " " << result[2]);
return;
}
bool SMDS_VtkVolume::isForward(double* a, double* b, double* c, double* d)
{
double u[3], v[3], w[3];
for (int j = 0; j < 3; j++)
{
//MESSAGE("a,b,c,d " << a[j] << " " << b[j] << " " << c[j] << " " << d[j]);
u[j] = b[j] - a[j];
v[j] = c[j] - a[j];
w[j] = d[j] - a[j];
//MESSAGE("u,v,w " << u[j] << " " << v[j] << " " << w[j]);
}
double prodmixte = (u[2] * v[3] - u[3] * v[2]) * w[1] + (u[3] * v[1] - u[1] * v[3]) * w[2] + (u[1] * v[2] - u[2]
* v[1]) * w[3];
return (prodmixte >= 0);
}
/*! For polyhedron only
* @return actual number of nodes (not the sum of nodes of all faces)
*/
int SMDS_VtkVolume::NbUniqueNodes() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
return grid->GetCell(myVtkID)->GetNumberOfPoints();
}
/*! For polyhedron use only
* @return iterator on actual nodes (not through the faces)
*/
SMDS_ElemIteratorPtr SMDS_VtkVolume::uniqueNodesIterator() const
{
MESSAGE("uniqueNodesIterator");
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}

View File

@ -0,0 +1,57 @@
#ifndef _SMDS_VTKVOLUME_HXX_
#define _SMDS_VTKVOLUME_HXX_
#include "SMESH_SMDS.hxx"
#include "SMDS_MeshVolume.hxx"
#include "SMDS_UnstructuredGrid.hxx"
#include <vector>
class SMDS_EXPORT SMDS_VtkVolume: public SMDS_MeshVolume
{
public:
SMDS_VtkVolume();
SMDS_VtkVolume(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
~SMDS_VtkVolume();
void init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
//#ifdef VTK_HAVE_POLYHEDRON
void initPoly(std::vector<vtkIdType> nodeIds, std::vector<int> nbNodesPerFace, SMDS_Mesh* mesh);
//#endif
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
virtual bool vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes);
void Print(std::ostream & OS) const;
int NbFaces() const;
int NbNodes() const;
int NbEdges() const;
// 1 <= face_ind <= NbFaces()
int NbFaceNodes (const int face_ind) const;
// 1 <= face_ind <= NbFaces()
// 1 <= node_ind <= NbFaceNodes()
const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const;
virtual SMDSAbs_ElementType GetType() const;
virtual vtkIdType GetVtkType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual bool IsQuadratic() const;
virtual bool IsPoly() const;
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
static void gravityCenter(SMDS_UnstructuredGrid* grid,
vtkIdType *nodeIds,
int nbNodes,
double* result);
static bool isForward(double* a,double* b,double* c,double* d);
int NbUniqueNodes() const;
SMDS_ElemIteratorPtr uniqueNodesIterator() const;
const std::vector<int> & GetQuantities() const;
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
virtual SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
protected:
};
#endif

86
src/SMDS/chrono.cxx Normal file
View File

@ -0,0 +1,86 @@
// Copyright (C) 2006-2010 CEA/DEN, EDF R&D
//
// 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
//
#include "chrono.hxx"
#include "utilities.h"
using namespace std;
cntStruct* counters::_ctrs = 0;
int counters::_nbChrono = 0;
counters::counters(int nb)
{
MESSAGE("counters::counters(int nb)");
_nbChrono = nb;
_ctrs = new cntStruct[_nbChrono];
for (int i = 0; i < _nbChrono; i++)
{
_ctrs[i]._ctrNames = 0;
_ctrs[i]._ctrLines = 0;
_ctrs[i]._ctrOccur = 0;
_ctrs[i]._ctrCumul = 0;
}
MESSAGE("counters::counters()");
}
counters::~counters()
{
stats();
}
void counters::stats()
{
MESSAGE("counters::stats()");
for (int i = 0; i < _nbChrono; i++)
if (_ctrs[i]._ctrOccur)
{
MESSAGE("Compteur[" << i << "]: "<< _ctrs[i]._ctrNames << "[" << _ctrs[i]._ctrLines << "]");
MESSAGE(" " << _ctrs[i]._ctrOccur);
MESSAGE(" " << _ctrs[i]._ctrCumul);
}
}
chrono::chrono(int i) :
_ctr(i), _run(true)
{
//MESSAGE("chrono::chrono " << _ctr << " " << _run);
_start = clock();
}
chrono::~chrono()
{
if (_run)
stop();
}
void chrono::stop()
{
//MESSAGE("chrono::stop " << _ctr << " " << _run);
if (_run)
{
_run = false;
_end = clock();
double elapse = double(_end - _start) / double(CLOCKS_PER_SEC);
counters::_ctrs[_ctr]._ctrOccur++;
counters::_ctrs[_ctr]._ctrCumul += elapse;
}
}

73
src/SMDS/chrono.hxx Normal file
View File

@ -0,0 +1,73 @@
// Copyright (C) 2006-2010 CEA/DEN, EDF R&D
//
// 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
//
#ifndef _CHRONO_HXX_
#define _CHRONO_HXX_
#include <vector>
#include <string>
#include <iostream>
#include <ctime>
typedef struct acnt
{
char* _ctrNames;
int _ctrLines;
int _ctrOccur;
double _ctrCumul;
} cntStruct;
class counters
{
public:
static cntStruct *_ctrs;
counters(int nb);
~counters();
static void stats();
protected:
static int _nbChrono;
};
class chrono
{
public:
chrono(int i);
~chrono();
void stop();
protected:
bool _run;
int _ctr;
clock_t _start, _end;
};
#ifdef CHRONODEF
#define CHRONO(i) counters::_ctrs[i]._ctrNames = (char *)__FILE__; \
counters::_ctrs[i]._ctrLines = __LINE__; \
chrono aChrono##i(i);
#define CHRONOSTOP(i) aChrono##i.stop();
#else // CHRONODEF
#define CHRONO(i)
#define CHRONOSTOP(i)
#endif // CHRONODEF
#endif // _CHRONO_HXX_

View File

@ -85,6 +85,7 @@ libSMESHimpl_la_CPPFLAGS = \
$(CAS_CPPFLAGS) \
$(MED_CXXFLAGS) \
$(GEOM_CXX_FLAGS) \
$(VTK_INCLUDES) \
$(BOOST_CPPFLAGS) \
@HDF5_INCLUDES@ \
-I$(srcdir)/../Controls \

View File

@ -255,10 +255,10 @@ bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face& theFace,
const SMDS_PositionPtr& pos = node->GetPosition();
if ( !pos ) continue;
if ( pos->GetTypeOfPosition() == SMDS_TOP_FACE ) {
fPos = dynamic_cast< const SMDS_FacePosition* >( pos.get() );
fPos = dynamic_cast< const SMDS_FacePosition* >( pos );
}
else if ( pos->GetTypeOfPosition() == SMDS_TOP_VERTEX ) {
vID = pos->GetShapeId();
vID = node->getshapeId();
}
}
if ( fPos || ( !normalOK && vID )) {
@ -366,7 +366,7 @@ bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
return false;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
static_cast<const SMDS_EdgePosition*>(node->GetPosition());
if ( !paramSet.insert( epos->GetUParameter() ).second )
return false; // equal parameters
}
@ -433,8 +433,9 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theM
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
return false;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
static_cast<const SMDS_EdgePosition*>(node->GetPosition());
theNodes.insert( make_pair( epos->GetUParameter(), node ));
//MESSAGE("U " << epos->GetUParameter() << " ID " << node->GetID());
++nbNodes;
}
}
@ -443,6 +444,7 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theM
TopExp::Vertices(theEdge, v1, v2);
const SMDS_MeshNode* n1 = VertexNode( v1, (SMESHDS_Mesh*) theMesh );
const SMDS_MeshNode* n2 = VertexNode( v2, (SMESHDS_Mesh*) theMesh );
//MESSAGE("Vertices ID " << n1->GetID() << " " << n2->GetID());
Standard_Real f, l;
BRep_Tool::Range(theEdge, f, l);
if ( v1.Orientation() != TopAbs_FORWARD )

View File

@ -25,12 +25,14 @@
// Author : Paul RASCLE, EDF
// Module : SMESH
//
#define CHRONODEF
#include "SMESH_Gen.hxx"
#include "SMESH_subMesh.hxx"
#include "SMESH_HypoFilter.hxx"
#include "SMESHDS_Document.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_Mesh.hxx"
#include "utilities.h"
#include "OpUtil.hxx"
@ -41,6 +43,8 @@
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include "memoire.h"
using namespace std;
//=============================================================================
@ -51,10 +55,13 @@ using namespace std;
SMESH_Gen::SMESH_Gen()
{
MESSAGE("SMESH_Gen::SMESH_Gen");
_localId = 0;
_hypId = 0;
_segmentation = _nbSegments = 10;
MESSAGE("SMESH_Gen::SMESH_Gen");
_localId = 0;
_hypId = 0;
_segmentation = 10;
SMDS_Mesh::_meshList.clear();
MESSAGE(SMDS_Mesh::_meshList.size());
_counters = new counters(100);
}
//=============================================================================
@ -108,6 +115,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
TSetOfInt* aShapesId)
{
MESSAGE("SMESH_Gen::Compute");
MEMOSTAT;
bool ret = true;
@ -151,6 +159,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
else if ( aShapesId )
aShapesId->insert( smToCompute->GetId() );
}
//aMesh.GetMeshDS()->Modified();
return ret;
}
else
@ -265,6 +274,26 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
}
MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret);
MEMOSTAT;
SMESHDS_Mesh *myMesh = aMesh.GetMeshDS();
myMesh->adjustStructure();
MESSAGE("*** compactMesh after compute");
myMesh->compactMesh();
//myMesh->adjustStructure();
list<int> listind = myMesh->SubMeshIndices();
list<int>::iterator it = listind.begin();
int total = 0;
for(; it != listind.end(); ++it)
{
::SMESHDS_SubMesh *subMesh = myMesh->MeshElements(*it);
total += subMesh->getSize();
}
MESSAGE("total elements and nodes in submesh sets:" << total);
MESSAGE("Number of node objects " << SMDS_MeshNode::nbNodes);
MESSAGE("Number of cell objects " << SMDS_MeshCell::nbCells);
//myMesh->dumpGrid();
//aMesh.GetMeshDS()->Modified();
return ret;
}

View File

@ -41,6 +41,8 @@
#include "SMESH_3D_Algo.hxx"
#include "SMESH_Mesh.hxx"
#include "chrono.hxx"
#include <TopoDS_Shape.hxx>
#include <map>
@ -159,6 +161,7 @@ private:
int _segmentation;
// default of segments
int _nbSegments;
counters *_counters;
};
#endif

Some files were not shown because too many files have changed in this diff Show More