Join modifications from branch OCC_development_for_3_2_0a2

This commit is contained in:
jfa 2006-03-13 15:29:49 +00:00
parent 50eb85fb3d
commit 4ff5bd6154
192 changed files with 14202 additions and 4014 deletions

View File

@ -14,7 +14,7 @@ VPATH=.:@srcdir@:@top_srcdir@/bin:@top_srcdir@/resources:./bin:@top_srcdir@/idl
@COMMENCE@ @COMMENCE@
SUBDIRS = idl src doc SUBDIRS = idl src doc adm_local
RESOURCES_FILES = \ RESOURCES_FILES = \
delete.png \ delete.png \
@ -131,7 +131,14 @@ mesh_pattern.png \
pattern_sample_2d.png \ pattern_sample_2d.png \
pattern_sample_3D.png \ pattern_sample_3D.png \
mesh_add.png \ mesh_add.png \
mesh_remove.png mesh_remove.png \
mesh_quad_edge.png \
mesh_quad_triangle.png \
mesh_quad_quadrangle.png \
mesh_quad_tetrahedron.png \
mesh_quad_pyramid.png \
mesh_quad_pentahedron.png \
mesh_quad_hexahedron.png
BIN_SCRIPT= \ BIN_SCRIPT= \
VERSION VERSION

41
adm_local/Makefile.in Normal file
View File

@ -0,0 +1,41 @@
# source path
top_srcdir=@top_srcdir@
top_builddir=..
srcdir=@srcdir@
VPATH=.:$(srcdir)/adm_local
all: resources
install:
cp -rf @top_srcdir@/adm_local @prefix@
bin:
resources :
cp -rf @top_srcdir@/adm_local $(top_builddir)
inc:
lib:
depend:
depend_idl:
install-end:
install-include:
install-bin:
uninstall:
uninstall-idl:
distclean:
clean:
distclean-other:

View File

@ -1,45 +0,0 @@
# Check availability of Geom binary distribution
#
# Author : Nicolas REJNERI (OPEN CASCADE, 2003)
#
AC_DEFUN([CHECK_GEOM],[
AC_CHECKING(for Geom)
Geom_ok=no
AC_ARG_WITH(geom,
[ --with-geom=DIR root directory path of GEOM installation ],
GEOM_DIR="$withval",GEOM_DIR="")
if test "x$GEOM_DIR" == "x" ; then
# no --with-geom-dir option used
if test "x$GEOM_ROOT_DIR" != "x" ; then
# GEOM_ROOT_DIR environment variable defined
GEOM_DIR=$GEOM_ROOT_DIR
fi
#
fi
if test -f ${GEOM_DIR}/lib/salome/libGEOMClient.so ; then
Geom_ok=yes
AC_MSG_RESULT(Using Geom module distribution in ${GEOM_DIR})
if test "x$GEOM_ROOT_DIR" == "x" ; then
GEOM_ROOT_DIR=${GEOM_DIR}
fi
AC_SUBST(GEOM_ROOT_DIR)
else
AC_MSG_WARN("Cannot find compiled Geom module distribution")
fi
AC_MSG_RESULT(for Geom: $Geom_ok)
])dnl

View File

@ -1,45 +0,0 @@
# Check availability of Med binary distribution
#
# Author : Nicolas REJNERI (OPEN CASCADE, 2003)
#
AC_DEFUN([CHECK_MED],[
AC_CHECKING(for Med)
Med_ok=no
AC_ARG_WITH(med,
[ --with-med=DIR root directory path of MED installation ],
MED_DIR="$withval",MED_DIR="")
if test "x$MED_DIR" == "x" ; then
# no --with-med-dir option used
if test "x$MED_ROOT_DIR" != "x" ; then
# MED_ROOT_DIR environment variable defined
MED_DIR=$MED_ROOT_DIR
fi
#
fi
if test -f ${MED_DIR}/idl/salome/MED.idl ; then
Med_ok=yes
AC_MSG_RESULT(Using Med module distribution in ${MED_DIR})
if test "x$MED_ROOT_DIR" == "x" ; then
MED_ROOT_DIR=${MED_DIR}
fi
AC_SUBST(MED_ROOT_DIR)
else
AC_MSG_WARN("Cannot find Med module sources")
fi
AC_MSG_RESULT(for Med: $Med_ok)
])dnl

View File

@ -0,0 +1,54 @@
# Check availability of SMesh binary distribution
#
# Author : Nicolas REJNERI (OPEN CASCADE, 2003)
#
AC_DEFUN([CHECK_SMESH],[
AC_CHECKING(for SMesh)
SMesh_ok=no
AC_ARG_WITH(smesh,
[ --with-smesh=DIR root directory path of SMESH installation ],
SMESH_DIR="$withval",SMESH_DIR="")
if test "x$SMESH_DIR" == "x" ; then
# no --with-smesh option used
if test "x$SMESH_ROOT_DIR" != "x" ; then
# SMESH_ROOT_DIR environment variable defined
SMESH_DIR=$SMESH_ROOT_DIR
else
# search SMESH binaries in PATH variable
AC_PATH_PROG(TEMP, libSMESH_Swig.py)
if test "x$TEMP" != "x" ; then
SMESH_BIN_DIR=`dirname $TEMP`
SMESH_DIR=`dirname $SMESH_BIN_DIR`
fi
fi
#
fi
if test -f ${SMESH_DIR}/bin/salome/libSMESH_Swig.py ; then
SMesh_ok=yes
AC_MSG_RESULT(Using SMesh module distribution in ${SMESH_DIR})
if test "x$SMESH_ROOT_DIR" == "x" ; then
SMESH_ROOT_DIR=${SMESH_DIR}
fi
AC_SUBST(SMESH_ROOT_DIR)
else
AC_MSG_WARN("Cannot find compiled SMesh module distribution")
fi
AC_MSG_RESULT(for SMesh: $SMesh_ok)
])dnl

View File

@ -0,0 +1,29 @@
dnl Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
dnl
dnl
dnl
AC_DEFUN([CHECK_F77],[
AC_PROG_F77
AC_F77_LIBRARY_LDFLAGS
AC_F77_WRAPPERS
])dnl

View File

@ -240,14 +240,27 @@ $(top_srcdir)/configure.in: $(top_srcdir)/configure.in.base
ACLOCAL_SRC = \ ACLOCAL_SRC = \
ac_cxx_bool.m4 check_corba.m4 check_vtk.m4 \ ac_cxx_bool.m4 check_corba.m4 \
ac_cxx_depend_flag.m4 check_hdf5.m4 enable_pthreads.m4 \ ac_cxx_depend_flag.m4 check_hdf5.m4 enable_pthreads.m4 \
ac_cxx_mutable.m4 check_mico.m4 libtool.m4 \ ac_cxx_mutable.m4 check_mico.m4 libtool.m4 \
ac_cxx_namespaces.m4 check_omniorb.m4 pyembed.m4 \ ac_cxx_namespaces.m4 check_omniorb.m4 pyembed.m4 \
ac_cxx_partial_specialization.m4 check_opengl.m4 python.m4 \ ac_cxx_partial_specialization.m4 python.m4 \
ac_cxx_typename.m4 check_pthreads.m4 check_cas.m4 \ ac_cxx_typename.m4 check_pthreads.m4 check_cas.m4 \
ac_cc_warnings.m4 check_qt.m4 check_boost.m4 \ ac_cc_warnings.m4 check_boost.m4 check_swig.m4
check_swig.m4
ACLOCAL_GUI = \
check_vtk.m4 check_opengl.m4 check_qt.m4 \
check_GUI.m4 check_corba_in_GUI.m4
ACLOCAL_MED = check_Med.m4
ACLOCAL_GEOM = check_GEOM.m4
$(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%) \
$(ACLOCAL_GUI:%=@GUI_ROOT_DIR@/adm_local/unix/config_files/%) \
$(ACLOCAL_MED:%=@MED_ROOT_DIR@/adm_local/unix/config_files/%) \
$(ACLOCAL_GEOM:%=@GEOM_ROOT_DIR@/adm_local/unix/config_files/%)
cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files \
-I @GUI_ROOT_DIR@/adm_local/unix/config_files \
-I @MED_ROOT_DIR@/adm_local/unix/config_files \
-I @GEOM_ROOT_DIR@/adm_local/unix/config_files
$(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%)
cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files

View File

@ -26,6 +26,31 @@ fi
# echo "failed : KERNEL_SRC variable is not correct !" # echo "failed : KERNEL_SRC variable is not correct !"
# exit # exit
#fi #fi
########################################################################
# Test if the GUI_ROOT_DIR is set correctly
if test ! -d "${GUI_ROOT_DIR}"; then
echo "failed : GUI_ROOT_DIR variable is not correct !"
exit
fi
########################################################################
# Test if the MED_ROOT_DIR is set correctly
if test ! -d "${MED_ROOT_DIR}"; then
echo "failed : MED_ROOT_DIR variable is not correct !"
exit
fi
########################################################################
# Test if the GEOM_ROOT_DIR is set correctly
if test ! -d "${GEOM_ROOT_DIR}"; then
echo "failed : GEOM_ROOT_DIR variable is not correct !"
exit
fi
######################################################################## ########################################################################
# find_in - utility function # find_in - utility function
# #
@ -203,7 +228,10 @@ else
echo -n "Creating 'configure' script ... " echo -n "Creating 'configure' script ... "
fi fi
aclocal --acdir=adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
-I ${GUI_ROOT_DIR}/adm_local/unix/config_files \
-I ${MED_ROOT_DIR}/adm_local/unix/config_files \
-I ${GEOM_ROOT_DIR}/adm_local/unix/config_files
if autoconf if autoconf
then then
echo "done" echo "done"

View File

@ -265,6 +265,26 @@ echo
CHECK_HTML_GENERATORS CHECK_HTML_GENERATORS
echo
echo ---------------------------------------------
echo Testing GUI
echo ---------------------------------------------
echo
CHECK_SALOME_GUI
echo
echo ---------------------------------------------
echo Testing full GUI
echo ---------------------------------------------
echo
CHECK_CORBA_IN_GUI
if test "x${CORBA_IN_GUI}" != "xyes"; then
echo "failed : For configure SMESH module necessary full GUI !"
exit
fi
echo echo
echo --------------------------------------------- echo ---------------------------------------------
echo Testing Kernel echo Testing Kernel

View File

@ -284,58 +284,54 @@ else
<p class="whs3"># create vertices</p> <p class="whs3"># create vertices</p>
<p class="whs2">px &nbsp;&nbsp;= <p class="whs2">px &nbsp;&nbsp;=geompy.MakeVertex(100., 0. &nbsp;,0. &nbsp;)</p>
geompy.MakeVertex(100., 0. &nbsp;,
0. &nbsp;)</p>
<p class="whs2">py &nbsp;&nbsp;= <p class="whs2">py &nbsp;&nbsp;=geompy.MakeVertex(0. &nbsp;,100., 0. &nbsp;)</p>
geompy.MakeVertex(0. &nbsp;,
100., 0. &nbsp;)</p>
<p class="whs2">pz &nbsp;&nbsp;= <p class="whs2">pz &nbsp;&nbsp;=geompy.MakeVertex(0. &nbsp;,0. &nbsp;, 100.)</p>
geompy.MakeVertex(0. &nbsp;,
0. &nbsp;, 100.)</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>
<p class="whs3"># create a vector from <p class="whs3"># create a vector from
two points</p> two points</p>
<p class="whs2">vxy = geompy.MakeVector(px, <p class="whs2">vxy = geompy.MakeVector(px,py)</p>
py)</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>
<p class="whs3"># create an arc from <p class="whs3"># create an arc from
three points</p> three points</p>
<p class="whs2">arc = geompy.MakeArc(py, <p class="whs2">arc = geompy.MakeArc(py, pz, px)</p>
pz, px)</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>
<p class="whs3"># create a wire</p> <p class="whs3"># create a wire</p>
<p class="whs2">wire = geompy.MakeWire([vxy, <p class="whs2">wire = geompy.MakeWire([vxy,arc])</p>
arc])</p>
<p class="whs2">isPlanarFace = 1</p> <p class="whs2">isPlanarFace = 1</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>
<p class="whs3"># create a face from <p class="whs3"># create a face from the wire</p>
the wire</p>
<p class="whs2">face1 = geompy.MakeFace(wire, <p class="whs2">face1 = geompy.MakeFace(wire,isPlanarFace)</p>
isPlanarFace)</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>
<p class="whs3"># add objects in the <p class="whs3"># get edges from the face</p>
study</p>
<p class="whs2">vxy, arc = geompy.SubShapeAll(face1, geompy.ShapeType["EDGE"])</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># add objects in the study</p>
<p class="whs2">id_face1 = geompy.addToStudy(face1,&quot;Face1&quot;)</p> <p class="whs2">id_face1 = geompy.addToStudy(face1,&quot;Face1&quot;)</p>
<p class="whs2">id_arc = geompy.addToStudyInFather(face1,arc,&quot;Arc Edge&quot;)</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>
<p class="whs3"># display faces</p> <p class="whs3"># display faces</p>
@ -350,44 +346,34 @@ else
<p class="whs3"># create hexahedral mesh</p> <p class="whs3"># create hexahedral mesh</p>
<p class="whs2">hexa = smesh.Mesh(face1, <p class="whs2">hexa = smesh.Mesh(face1,&quot;Face compound : hexahedrical mesh&quot;)</p>
&quot;Face compound : hexahedrical mesh&quot;)</p>
<p class="whs2">algo = hexa.Triangle()</p> <p class="whs2">algo = hexa.Triangle()</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>
<p class="whs3"># define &quot;MaxElementArea&quot; <p class="whs3"># define &quot;MaxElementArea&quot;hypothesis</p>
hypothesis to be applied &nbsp;to
each triangle</p>
<p class="whs2">algo.MaxElementArea(30)</p> <p class="whs2">algo.MaxElementArea(30)</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>
<p class="whs3"># create a quadrangle <p class="whs3"># create a local hypothesis on the wire</p>
2D algorithm for faces</p>
<p class="whs2">hexa.Quadrangle()</p>
<p class="whs2">&nbsp;</p>
<p class="whs3"># create a local hypothesis</p>
<p class="whs2">algo = hexa.Segment(wire)</p> <p class="whs2">algo = hexa.Segment(wire)</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>
<p class="whs3"># define &quot;NumberOfSegments&quot; <p class="whs3"># define &quot;NumberOfSegments&quot;hypothesis to cut
hypothesis to cut an edge in a fixed number of segments</p> a straight edge in a fixed number of segments</p>
<p class="whs2">algo.NumberOfSegments(6)</p> <p class="whs2">algo.NumberOfSegments(6)</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>
<p class="whs3"># define &quot;Deflection1D&quot; <p class="whs3"># define a local &quot;Deflection1D&quot;hypothesis on the arc</p>
hypothesis</p>
<p class="whs2">algo = hexa.Segment(arc)</p>
<p class="whs2">algo.Deflection1D(1)</p> <p class="whs2">algo.Deflection1D(1)</p>
<p class="whs2">&nbsp;</p> <p class="whs2">&nbsp;</p>

View File

@ -286,6 +286,20 @@ module StdMeshers
{ {
}; };
/*!
* StdMeshers_QuadraticMesh: interface of "QuadraticMesh" hypothesis.
* This is an auxiliary 1D hypothesis whose presence forces construction
* of quadratic edges.
* If the 2D mesher sees that all boundary edges are quadratic ones,
* it generates quadratic faces, else it generates linear faces using
* medium nodes as if they were vertex ones.
* The 3D mesher generates quadratic volumes only if all boundary faces
* are quadratic ones, else it fails.
*/
interface StdMeshers_QuadraticMesh : SMESH::SMESH_Hypothesis
{
};
/*! /*!
* StdMeshers_Regular_1D: interface of "Wire discretisation" algorithm * StdMeshers_Regular_1D: interface of "Wire discretisation" algorithm

View File

@ -59,6 +59,16 @@ module SMESH
SMESH_Pattern GetPattern(); SMESH_Pattern GetPattern();
/*!
Set the current mode
*/
void SetEmbeddedMode( in boolean theMode );
/*!
Get the current mode
*/
boolean IsEmbeddedMode();
/*! /*!
Set the current study Set the current study
*/ */

View File

@ -84,6 +84,16 @@ module SMESH
* Returns the mesh object this group belongs to * Returns the mesh object this group belongs to
*/ */
SMESH_Mesh GetMesh(); SMESH_Mesh GetMesh();
/*!
* Sets group color number
*/
void SetColorNumber( in long color );
/*!
* Returns group color number
*/
long GetColorNumber();
}; };
/*! /*!

View File

@ -69,7 +69,14 @@ module SMESH
MOVE_NODE, MOVE_NODE,
CHANGE_ELEMENT_NODES, CHANGE_ELEMENT_NODES,
CHANGE_POLYHEDRON_NODES, CHANGE_POLYHEDRON_NODES,
RENUMBER RENUMBER,
ADD_QUADEDGE,
ADD_QUADTRIANGLE,
ADD_QUADQUADRANGLE,
ADD_QUADTETRAHEDRON,
ADD_QUADPYRAMID,
ADD_QUADPENTAHEDRON,
ADD_QUADHEXAHEDRON
}; };
struct log_block struct log_block
@ -119,7 +126,8 @@ module SMESH
HYP_INCOMPATIBLE, // hypothesis does not fit algo HYP_INCOMPATIBLE, // hypothesis does not fit algo
HYP_NOTCONFORM, // not conform mesh is produced appling a hypothesis HYP_NOTCONFORM, // not conform mesh is produced appling a hypothesis
HYP_ALREADY_EXIST,// such hypothesis already exist HYP_ALREADY_EXIST,// such hypothesis already exist
HYP_BAD_DIM // bad dimension HYP_BAD_DIM, // bad dimension
HYP_BAD_SUBSHAPE // shape is neither the main one, nor its subshape, nor a group
}; };
/*! /*!
@ -335,6 +343,11 @@ module SMESH
SMESH_MeshEditor GetMeshEditor() SMESH_MeshEditor GetMeshEditor()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! Check group names for duplications.
* Consider maximum group name length stored in MED file.
*/
boolean HasDuplicatedGroupNamesMED();
/*! /*!
* Export Mesh to different MED Formats * Export Mesh to different MED Formats
* @params * @params
@ -434,6 +447,12 @@ module SMESH
* Get mesh description * Get mesh description
*/ */
string Dump(); string Dump();
/*!
* Get mesh pointer
*/
long GetMeshPtr();
}; };
interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource
@ -514,6 +533,8 @@ module SMESH
boolean AddFace(in long_array IDsOfNodes); boolean AddFace(in long_array IDsOfNodes);
boolean AddPolygonalFace(in long_array IdsOfNodes);
boolean AddVolume(in long_array IDsOfNodes); boolean AddVolume(in long_array IDsOfNodes);
/*! /*!

View File

@ -57,6 +57,12 @@
icon-id="mesh_algo_quad.png" icon-id="mesh_algo_quad.png"
dim="2"/> dim="2"/>
<hypothesis type="QuadraticMesh"
label-id="Quadratic Mesh"
icon-id="mesh_algo_quad.png"
dim="1"
auxiliary="true"/>
<hypothesis type="MaxElementArea" <hypothesis type="MaxElementArea"
label-id="Max. Element Area" label-id="Max. Element Area"
icon-id="mesh_hypo_area.png" icon-id="mesh_hypo_area.png"

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

View File

@ -46,6 +46,8 @@
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_VolumeTool.hxx" #include "SMDS_VolumeTool.hxx"
#include "SMDS_QuadraticFaceOfNodes.hxx"
#include "SMDS_QuadraticEdge.hxx"
/* /*
@ -87,32 +89,69 @@ namespace{
return 0; return 0;
const SMDS_MeshElement* anEdge = theMesh->FindElement( theId ); const SMDS_MeshElement* anEdge = theMesh->FindElement( theId );
if ( anEdge == 0 || anEdge->GetType() != SMDSAbs_Edge || anEdge->NbNodes() != 2 ) if ( anEdge == 0 || anEdge->GetType() != SMDSAbs_Edge/* || anEdge->NbNodes() != 2 */)
return 0; return 0;
TColStd_MapOfInteger aMap; // for each pair of nodes in anEdge (there are 2 pairs in a quadratic edge)
// count elements containing both nodes of the pair.
// Note that there may be such cases for a quadratic edge (a horizontal line):
//
// Case 1 Case 2
// | | | | |
// | | | | |
// +-----+------+ +-----+------+
// | | | |
// | | | |
// result sould be 2 in both cases
//
int aResult0 = 0, aResult1 = 0;
// last node, it is a medium one in a quadratic edge
const SMDS_MeshNode* aLastNode = anEdge->GetNode( anEdge->NbNodes() - 1 );
const SMDS_MeshNode* aNode0 = anEdge->GetNode( 0 );
const SMDS_MeshNode* aNode1 = anEdge->GetNode( 1 );
if ( aNode1 == aLastNode ) aNode1 = 0;
int aResult = 0; SMDS_ElemIteratorPtr anElemIter = aLastNode->GetInverseElementIterator();
SMDS_ElemIteratorPtr anIter = anEdge->nodesIterator(); while( anElemIter->more() ) {
if ( anIter != 0 ) { const SMDS_MeshElement* anElem = anElemIter->next();
while( anIter->more() ) { if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge ) {
const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
if ( aNode == 0 ) while ( anIter->more() ) {
return 0; if ( const SMDS_MeshElement* anElemNode = anIter->next() ) {
SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator(); if ( anElemNode == aNode0 ) {
while( anElemIter->more() ) { aResult0++;
const SMDS_MeshElement* anElem = anElemIter->next(); if ( !aNode1 ) break; // not a quadratic edge
if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge ) { }
int anId = anElem->GetID(); else if ( anElemNode == aNode1 )
aResult1++;
if ( anIter->more() ) // i.e. first node }
aMap.Add( anId ); }
else if ( aMap.Contains( anId ) )
aResult++;
}
}
} }
} }
int aResult = max ( aResult0, aResult1 );
// TColStd_MapOfInteger aMap;
// SMDS_ElemIteratorPtr anIter = anEdge->nodesIterator();
// if ( anIter != 0 ) {
// while( anIter->more() ) {
// const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
// if ( aNode == 0 )
// return 0;
// SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator();
// while( anElemIter->more() ) {
// const SMDS_MeshElement* anElem = anElemIter->next();
// if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge ) {
// int anId = anElem->GetID();
// if ( anIter->more() ) // i.e. first node
// aMap.Add( anId );
// else if ( aMap.Contains( anId ) )
// aResult++;
// }
// }
// }
// }
return aResult; return aResult;
} }
@ -154,23 +193,41 @@ bool NumericalFunctor::GetPoints(const int theId,
} }
bool NumericalFunctor::GetPoints(const SMDS_MeshElement* anElem, bool NumericalFunctor::GetPoints(const SMDS_MeshElement* anElem,
TSequenceOfXYZ& theRes ) TSequenceOfXYZ& theRes )
{ {
theRes.clear(); theRes.clear();
if ( anElem == 0) if ( anElem == 0)
return false; return false;
theRes.reserve( anElem->NbNodes() );
// Get nodes of the element // Get nodes of the element
SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr anIter;
if ( anIter != 0 )
{ if ( anElem->IsQuadratic() ) {
while( anIter->more() ) switch ( anElem->GetType() ) {
{ case SMDSAbs_Edge:
const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); anIter = static_cast<const SMDS_QuadraticEdge*>
if ( aNode != 0 ){ (anElem)->interlacedNodesElemIterator();
break;
case SMDSAbs_Face:
anIter = static_cast<const SMDS_QuadraticFaceOfNodes*>
(anElem)->interlacedNodesElemIterator();
break;
default:
anIter = anElem->nodesIterator();
//return false;
}
}
else {
anIter = anElem->nodesIterator();
}
if ( anIter ) {
while( anIter->more() ) {
if ( const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>( anIter->next() ))
theRes.push_back( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) ); theRes.push_back( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) );
}
} }
} }
@ -285,6 +342,7 @@ double AspectRatio::GetValue( const TSequenceOfXYZ& P )
// According to "Mesh quality control" by Nadir Bouhamau referring to // According to "Mesh quality control" by Nadir Bouhamau referring to
// Pascal Jean Frey and Paul-Louis George. Maillages, applications aux elements finis. // Pascal Jean Frey and Paul-Louis George. Maillages, applications aux elements finis.
// Hermes Science publications, Paris 1999 ISBN 2-7462-0024-4 // Hermes Science publications, Paris 1999 ISBN 2-7462-0024-4
// PAL10872
int nbNodes = P.size(); int nbNodes = P.size();
@ -840,22 +898,21 @@ SMDSAbs_ElementType Skew::GetType() const
*/ */
double Area::GetValue( const TSequenceOfXYZ& P ) double Area::GetValue( const TSequenceOfXYZ& P )
{ {
double aArea = 0; gp_Vec aVec1( P(2) - P(1) );
if ( P.size() == 3 ) gp_Vec aVec2( P(3) - P(1) );
return getArea( P( 1 ), P( 2 ), P( 3 ) ); gp_Vec SumVec = aVec1 ^ aVec2;
else if (P.size() > 3) for (int i=4; i<=P.size(); i++) {
aArea = getArea( P( 1 ), P( 2 ), P( 3 ) ); gp_Vec aVec1( P(i-1) - P(1) );
else gp_Vec aVec2( P(i) - P(1) );
return 0; gp_Vec tmp = aVec1 ^ aVec2;
SumVec.Add(tmp);
for (int i=4; i<=P.size(); i++) }
aArea += getArea(P(1),P(i-1),P(i)); return SumVec.Magnitude() * 0.5;
return aArea;
} }
double Area::GetBadRate( double Value, int /*nbNodes*/ ) const double Area::GetBadRate( double Value, int /*nbNodes*/ ) const
{ {
// meaningless as it is not quality control functor // meaningless as it is not a quality control functor
return Value; return Value;
} }
@ -871,7 +928,11 @@ SMDSAbs_ElementType Area::GetType() const
*/ */
double Length::GetValue( const TSequenceOfXYZ& P ) double Length::GetValue( const TSequenceOfXYZ& P )
{ {
return ( P.size() == 2 ? getDistance( P( 1 ), P( 2 ) ) : 0 ); switch ( P.size() ) {
case 2: return getDistance( P( 1 ), P( 2 ) );
case 3: return getDistance( P( 1 ), P( 2 ) ) + getDistance( P( 2 ), P( 3 ) );
default: return 0.;
}
} }
double Length::GetBadRate( double Value, int /*nbNodes*/ ) const double Length::GetBadRate( double Value, int /*nbNodes*/ ) const
@ -894,7 +955,10 @@ double Length2D::GetValue( long theElementId)
{ {
TSequenceOfXYZ P; TSequenceOfXYZ P;
//cout<<"Length2D::GetValue"<<endl;
if (GetPoints(theElementId,P)){ if (GetPoints(theElementId,P)){
//for(int jj=1; jj<=P.size(); jj++)
// cout<<"jj="<<jj<<" P("<<P(jj).X()<<","<<P(jj).Y()<<","<<P(jj).Z()<<")"<<endl;
double aVal;// = GetValue( P ); double aVal;// = GetValue( P );
const SMDS_MeshElement* aElem = myMesh->FindElement( theElementId ); const SMDS_MeshElement* aElem = myMesh->FindElement( theElementId );
@ -908,7 +972,11 @@ double Length2D::GetValue( long theElementId)
case SMDSAbs_Edge: case SMDSAbs_Edge:
if (len == 2){ if (len == 2){
aVal = getDistance( P( 1 ), P( 2 ) ); aVal = getDistance( P( 1 ), P( 2 ) );
break; break;
}
else if (len == 3){ // quadratic edge
aVal = getDistance(P( 1 ),P( 3 )) + getDistance(P( 3 ),P( 2 ));
break;
} }
case SMDSAbs_Face: case SMDSAbs_Face:
if (len == 3){ // triangles if (len == 3){ // triangles
@ -926,6 +994,22 @@ double Length2D::GetValue( long theElementId)
aVal = Max(Max(L1,L2),Max(L3,L4)); aVal = Max(Max(L1,L2),Max(L3,L4));
break; break;
} }
if (len == 6){ // quadratic triangles
double L1 = getDistance(P( 1 ),P( 2 )) + getDistance(P( 2 ),P( 3 ));
double L2 = getDistance(P( 3 ),P( 4 )) + getDistance(P( 4 ),P( 5 ));
double L3 = getDistance(P( 5 ),P( 6 )) + getDistance(P( 6 ),P( 1 ));
aVal = Max(L1,Max(L2,L3));
//cout<<"L1="<<L1<<" L2="<<L2<<"L3="<<L3<<" aVal="<<aVal<<endl;
break;
}
else if (len == 8){ // quadratic quadrangles
double L1 = getDistance(P( 1 ),P( 2 )) + getDistance(P( 2 ),P( 3 ));
double L2 = getDistance(P( 3 ),P( 4 )) + getDistance(P( 4 ),P( 5 ));
double L3 = getDistance(P( 5 ),P( 6 )) + getDistance(P( 6 ),P( 7 ));
double L4 = getDistance(P( 7 ),P( 8 )) + getDistance(P( 8 ),P( 1 ));
aVal = Max(Max(L1,L2),Max(L3,L4));
break;
}
case SMDSAbs_Volume: case SMDSAbs_Volume:
if (len == 4){ // tetraidrs if (len == 4){ // tetraidrs
double L1 = getDistance(P( 1 ),P( 2 )); double L1 = getDistance(P( 1 ),P( 2 ));
@ -987,6 +1071,63 @@ double Length2D::GetValue( long theElementId)
} }
if (len == 10){ // quadratic tetraidrs
double L1 = getDistance(P( 1 ),P( 5 )) + getDistance(P( 5 ),P( 2 ));
double L2 = getDistance(P( 2 ),P( 6 )) + getDistance(P( 6 ),P( 3 ));
double L3 = getDistance(P( 3 ),P( 7 )) + getDistance(P( 7 ),P( 1 ));
double L4 = getDistance(P( 1 ),P( 8 )) + getDistance(P( 8 ),P( 4 ));
double L5 = getDistance(P( 2 ),P( 9 )) + getDistance(P( 9 ),P( 4 ));
double L6 = getDistance(P( 3 ),P( 10 )) + getDistance(P( 10 ),P( 4 ));
aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
break;
}
else if (len == 13){ // quadratic piramids
double L1 = getDistance(P( 1 ),P( 6 )) + getDistance(P( 6 ),P( 2 ));
double L2 = getDistance(P( 2 ),P( 7 )) + getDistance(P( 7 ),P( 3 ));
double L3 = getDistance(P( 3 ),P( 8 )) + getDistance(P( 8 ),P( 1 ));
double L4 = getDistance(P( 4 ),P( 9 )) + getDistance(P( 9 ),P( 1 ));
double L5 = getDistance(P( 1 ),P( 10 )) + getDistance(P( 10 ),P( 5 ));
double L6 = getDistance(P( 2 ),P( 11 )) + getDistance(P( 11 ),P( 5 ));
double L7 = getDistance(P( 3 ),P( 12 )) + getDistance(P( 12 ),P( 5 ));
double L8 = getDistance(P( 4 ),P( 13 )) + getDistance(P( 13 ),P( 5 ));
aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
aVal = Max(aVal,Max(L7,L8));
break;
}
else if (len == 15){ // quadratic pentaidres
double L1 = getDistance(P( 1 ),P( 7 )) + getDistance(P( 7 ),P( 2 ));
double L2 = getDistance(P( 2 ),P( 8 )) + getDistance(P( 8 ),P( 3 ));
double L3 = getDistance(P( 3 ),P( 9 )) + getDistance(P( 9 ),P( 1 ));
double L4 = getDistance(P( 4 ),P( 10 )) + getDistance(P( 10 ),P( 5 ));
double L5 = getDistance(P( 5 ),P( 11 )) + getDistance(P( 11 ),P( 6 ));
double L6 = getDistance(P( 6 ),P( 12 )) + getDistance(P( 12 ),P( 4 ));
double L7 = getDistance(P( 1 ),P( 13 )) + getDistance(P( 13 ),P( 4 ));
double L8 = getDistance(P( 2 ),P( 14 )) + getDistance(P( 14 ),P( 5 ));
double L9 = getDistance(P( 3 ),P( 15 )) + getDistance(P( 15 ),P( 6 ));
aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
aVal = Max(aVal,Max(Max(L7,L8),L9));
break;
}
else if (len == 20){ // quadratic hexaider
double L1 = getDistance(P( 1 ),P( 9 )) + getDistance(P( 9 ),P( 2 ));
double L2 = getDistance(P( 2 ),P( 10 )) + getDistance(P( 10 ),P( 3 ));
double L3 = getDistance(P( 3 ),P( 11 )) + getDistance(P( 11 ),P( 4 ));
double L4 = getDistance(P( 4 ),P( 12 )) + getDistance(P( 12 ),P( 1 ));
double L5 = getDistance(P( 5 ),P( 13 )) + getDistance(P( 13 ),P( 6 ));
double L6 = getDistance(P( 6 ),P( 14 )) + getDistance(P( 14 ),P( 7 ));
double L7 = getDistance(P( 7 ),P( 15 )) + getDistance(P( 15 ),P( 8 ));
double L8 = getDistance(P( 8 ),P( 16 )) + getDistance(P( 16 ),P( 5 ));
double L9 = getDistance(P( 1 ),P( 17 )) + getDistance(P( 17 ),P( 5 ));
double L10= getDistance(P( 2 ),P( 18 )) + getDistance(P( 18 ),P( 6 ));
double L11= getDistance(P( 3 ),P( 19 )) + getDistance(P( 19 ),P( 7 ));
double L12= getDistance(P( 4 ),P( 20 )) + getDistance(P( 20 ),P( 8 ));
aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
aVal = Max(aVal,Max(Max(L7,L8),Max(L9,L10)));
aVal = Max(aVal,Max(L11,L12));
break;
}
default: aVal=-1; default: aVal=-1;
} }
@ -1038,38 +1179,81 @@ void Length2D::GetValues(TValues& theValues){
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
for(; anIter->more(); ){ for(; anIter->more(); ){
const SMDS_MeshFace* anElem = anIter->next(); const SMDS_MeshFace* anElem = anIter->next();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
long aNodeId[2];
gp_Pnt P[3];
double aLength; if(anElem->IsQuadratic()) {
const SMDS_MeshElement* aNode; const SMDS_QuadraticFaceOfNodes* F =
if(aNodesIter->more()){ static_cast<const SMDS_QuadraticFaceOfNodes*>(anElem);
aNode = aNodesIter->next(); // use special nodes iterator
const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode; SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator();
P[0] = P[1] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z()); long aNodeId[4];
aNodeId[0] = aNodeId[1] = aNode->GetID(); gp_Pnt P[4];
aLength = 0;
double aLength;
const SMDS_MeshElement* aNode;
if(anIter->more()){
aNode = anIter->next();
const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
P[0] = P[1] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
aNodeId[0] = aNodeId[1] = aNode->GetID();
aLength = 0;
}
for(; anIter->more(); ){
const SMDS_MeshNode* N1 = static_cast<const SMDS_MeshNode*> (anIter->next());
P[2] = gp_Pnt(N1->X(),N1->Y(),N1->Z());
aNodeId[2] = N1->GetID();
aLength = P[1].Distance(P[2]);
if(!anIter->more()) break;
const SMDS_MeshNode* N2 = static_cast<const SMDS_MeshNode*> (anIter->next());
P[3] = gp_Pnt(N2->X(),N2->Y(),N2->Z());
aNodeId[3] = N2->GetID();
aLength += P[2].Distance(P[3]);
Value aValue1(aLength,aNodeId[1],aNodeId[2]);
Value aValue2(aLength,aNodeId[2],aNodeId[3]);
P[1] = P[3];
aNodeId[1] = aNodeId[3];
theValues.insert(aValue1);
theValues.insert(aValue2);
}
aLength += P[2].Distance(P[0]);
Value aValue1(aLength,aNodeId[1],aNodeId[2]);
Value aValue2(aLength,aNodeId[2],aNodeId[0]);
theValues.insert(aValue1);
theValues.insert(aValue2);
} }
for(; aNodesIter->more(); ){ else {
aNode = aNodesIter->next(); SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode; long aNodeId[2];
long anId = aNode->GetID(); gp_Pnt P[3];
P[2] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z()); double aLength;
const SMDS_MeshElement* aNode;
if(aNodesIter->more()){
aNode = aNodesIter->next();
const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
P[0] = P[1] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
aNodeId[0] = aNodeId[1] = aNode->GetID();
aLength = 0;
}
for(; aNodesIter->more(); ){
aNode = aNodesIter->next();
const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
long anId = aNode->GetID();
aLength = P[1].Distance(P[2]); P[2] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
Value aValue(aLength,aNodeId[1],anId); aLength = P[1].Distance(P[2]);
aNodeId[1] = anId;
P[1] = P[2]; Value aValue(aLength,aNodeId[1],anId);
aNodeId[1] = anId;
P[1] = P[2];
theValues.insert(aValue);
}
aLength = P[0].Distance(P[1]);
Value aValue(aLength,aNodeId[0],aNodeId[1]);
theValues.insert(aValue); theValues.insert(aValue);
} }
aLength = P[0].Distance(P[1]);
Value aValue(aLength,aNodeId[0],aNodeId[1]);
theValues.insert(aValue);
} }
} }
@ -1194,7 +1378,12 @@ void MultiConnection2D::GetValues(MValues& theValues){
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
for(; anIter->more(); ){ for(; anIter->more(); ){
const SMDS_MeshFace* anElem = anIter->next(); const SMDS_MeshFace* anElem = anIter->next();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr aNodesIter;
if ( anElem->IsQuadratic() )
aNodesIter = static_cast<const SMDS_QuadraticFaceOfNodes*>
(anElem)->interlacedNodesElemIterator();
else
aNodesIter = anElem->nodesIterator();
long aNodeId[3]; long aNodeId[3];
//int aNbConnects=0; //int aNbConnects=0;
@ -1207,7 +1396,7 @@ void MultiConnection2D::GetValues(MValues& theValues){
const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode1; const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode1;
aNodeId[0] = aNodeId[1] = aNodes->GetID(); aNodeId[0] = aNodeId[1] = aNodes->GetID();
} }
for(; aNodesIter->more(); ){ for(; aNodesIter->more(); ) {
aNode2 = (SMDS_MeshNode*) aNodesIter->next(); aNode2 = (SMDS_MeshNode*) aNodesIter->next();
long anId = aNode2->GetID(); long anId = aNode2->GetID();
aNodeId[2] = anId; aNodeId[2] = anId;
@ -1217,7 +1406,8 @@ void MultiConnection2D::GetValues(MValues& theValues){
if (aItr != theValues.end()){ if (aItr != theValues.end()){
aItr->second += 1; aItr->second += 1;
//aNbConnects = nb; //aNbConnects = nb;
} else { }
else {
theValues[aValue] = 1; theValues[aValue] = 1;
//aNbConnects = 1; //aNbConnects = 1;
} }
@ -1227,10 +1417,11 @@ void MultiConnection2D::GetValues(MValues& theValues){
} }
Value aValue(aNodeId[0],aNodeId[2]); Value aValue(aNodeId[0],aNodeId[2]);
MValues::iterator aItr = theValues.find(aValue); MValues::iterator aItr = theValues.find(aValue);
if (aItr != theValues.end()){ if (aItr != theValues.end()) {
aItr->second += 1; aItr->second += 1;
//aNbConnects = nb; //aNbConnects = nb;
} else { }
else {
theValues[aValue] = 1; theValues[aValue] = 1;
//aNbConnects = 1; //aNbConnects = 1;
} }
@ -1346,41 +1537,33 @@ bool FreeEdges::IsSatisfy( long theId )
if ( aFace == 0 || aFace->GetType() != SMDSAbs_Face || aFace->NbNodes() < 3 ) if ( aFace == 0 || aFace->GetType() != SMDSAbs_Face || aFace->NbNodes() < 3 )
return false; return false;
int nbNodes = aFace->NbNodes(); SMDS_ElemIteratorPtr anIter;
//const SMDS_MeshNode* aNodes[ nbNodes ]; if ( aFace->IsQuadratic() ) {
#ifndef WNT anIter = static_cast<const SMDS_QuadraticFaceOfNodes*>
const SMDS_MeshNode* aNodes [nbNodes]; (aFace)->interlacedNodesElemIterator();
#else
const SMDS_MeshNode** aNodes = (const SMDS_MeshNode **)new SMDS_MeshNode*[nbNodes];
#endif
int i = 0;
SMDS_ElemIteratorPtr anIter = aFace->nodesIterator();
if ( anIter != 0 )
{
while( anIter->more() )
{
const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
if ( aNode == 0 )
return false;
aNodes[ i++ ] = aNode;
}
} }
else {
anIter = aFace->nodesIterator();
}
if ( anIter != 0 )
return false;
for ( int i = 0; i < nbNodes - 1; i++ ) int i = 0, nbNodes = aFace->NbNodes();
if ( IsFreeEdge( &aNodes[ i ], theId ) ) { vector <const SMDS_MeshNode*> aNodes( nbNodes+1 );
#ifdef WNT while( anIter->more() )
delete [] aNodes; {
#endif const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
if ( aNode == 0 )
return false;
aNodes[ i++ ] = aNode;
}
aNodes[ nbNodes ] = aNodes[ 0 ];
for ( i = 0; i < nbNodes; i++ )
if ( IsFreeEdge( &aNodes[ i ], theId ) )
return true; return true;
}
aNodes[ 1 ] = aNodes[ nbNodes - 1 ]; return false;
const Standard_Boolean isFree = IsFreeEdge( &aNodes[ 0 ], theId );
#ifdef WNT
delete [] aNodes;
#endif
// return
return isFree;
} }
SMDSAbs_ElementType FreeEdges::GetType() const SMDSAbs_ElementType FreeEdges::GetType() const
@ -1423,7 +1606,12 @@ void FreeEdges::GetBoreders(TBorders& theBorders)
for(; anIter->more(); ){ for(; anIter->more(); ){
const SMDS_MeshFace* anElem = anIter->next(); const SMDS_MeshFace* anElem = anIter->next();
long anElemId = anElem->GetID(); long anElemId = anElem->GetID();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr aNodesIter;
if ( anElem->IsQuadratic() )
aNodesIter = static_cast<const SMDS_QuadraticFaceOfNodes*>(anElem)->
interlacedNodesElemIterator();
else
aNodesIter = anElem->nodesIterator();
long aNodeId[2]; long aNodeId[2];
const SMDS_MeshElement* aNode; const SMDS_MeshElement* aNode;
if(aNodesIter->more()){ if(aNodesIter->more()){
@ -2088,8 +2276,7 @@ static gp_XYZ getNormale( const SMDS_MeshFace* theFace )
TColgp_Array1OfXYZ anArrOfXYZ(1,4); TColgp_Array1OfXYZ anArrOfXYZ(1,4);
SMDS_ElemIteratorPtr aNodeItr = theFace->nodesIterator(); SMDS_ElemIteratorPtr aNodeItr = theFace->nodesIterator();
int i = 1; int i = 1;
for ( ; aNodeItr->more() && i <= 4; i++ ) for ( ; aNodeItr->more() && i <= 4; i++ ) {
{
SMDS_MeshNode* aNode = (SMDS_MeshNode*)aNodeItr->next(); SMDS_MeshNode* aNode = (SMDS_MeshNode*)aNodeItr->next();
anArrOfXYZ.SetValue(i, gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) ); anArrOfXYZ.SetValue(i, gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) );
} }
@ -2097,8 +2284,7 @@ static gp_XYZ getNormale( const SMDS_MeshFace* theFace )
gp_XYZ q1 = anArrOfXYZ.Value(2) - anArrOfXYZ.Value(1); gp_XYZ q1 = anArrOfXYZ.Value(2) - anArrOfXYZ.Value(1);
gp_XYZ q2 = anArrOfXYZ.Value(3) - anArrOfXYZ.Value(1); gp_XYZ q2 = anArrOfXYZ.Value(3) - anArrOfXYZ.Value(1);
n = q1 ^ q2; n = q1 ^ q2;
if ( aNbNode > 3 ) if ( aNbNode > 3 ) {
{
gp_XYZ q3 = anArrOfXYZ.Value(4) - anArrOfXYZ.Value(1); gp_XYZ q3 = anArrOfXYZ.Value(4) - anArrOfXYZ.Value(1);
n += q2 ^ q3; n += q2 ^ q3;
} }

View File

@ -32,7 +32,7 @@ Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform()
Status aResult = DRS_OK; Status aResult = DRS_OK;
int nbNodes, nbCells; int nbNodes, nbCells;
int i; //int i;
char *file2Read = (char *)myFile.c_str(); char *file2Read = (char *)myFile.c_str();
FILE* aFileId = fopen(file2Read, "w+"); FILE* aFileId = fopen(file2Read, "w+");
@ -52,7 +52,7 @@ Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform()
nbNodes = myMesh->NbNodes(); nbNodes = myMesh->NbNodes();
/* Combien de mailles, faces ou aretes ? */ /* Combien de mailles, faces ou aretes ? */
int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes; int /*nb_of_nodes,*/ nb_of_edges, nb_of_faces, nb_of_volumes;
nb_of_edges = myMesh->NbEdges(); nb_of_edges = myMesh->NbEdges();
nb_of_faces = myMesh->NbFaces(); nb_of_faces = myMesh->NbFaces();
nb_of_volumes = myMesh->NbVolumes(); nb_of_volumes = myMesh->NbVolumes();

View File

@ -32,6 +32,103 @@
using namespace std; using namespace std;
//=============================================================================
/*!
* Default constructor
*/
//=============================================================================
DriverMED_Family
::DriverMED_Family():
myGroupAttributVal(0)
{}
//=============================================================================
const ElementsSet&
DriverMED_Family
::GetElements () const
{
return myElements;
}
int
DriverMED_Family
::GetId () const
{
return myId;
}
void
DriverMED_Family
::SetId (const int theId)
{
myId = theId;
}
void
DriverMED_Family
::AddElement(const SMDS_MeshElement* theElement)
{
myElements.insert(theElement);
}
void
DriverMED_Family
::AddGroupName(std::string theGroupName)
{
myGroupNames.insert(theGroupName);
}
void
DriverMED_Family
::SetType(const SMDSAbs_ElementType theType)
{
myType = theType;
}
SMDSAbs_ElementType
DriverMED_Family
::GetType()
{
return myType;
}
bool
DriverMED_Family
::MemberOf(std::string theGroupName) const
{
return myGroupNames.find(theGroupName) != myGroupNames.end();
}
const MED::TStringSet&
DriverMED_Family
::GetGroupNames () const
{
return myGroupNames;
}
int
DriverMED_Family
::GetGroupAttributVal() const
{
return myGroupAttributVal;
}
void
DriverMED_Family
::SetGroupAttributVal( int theValue)
{
myGroupAttributVal = theValue;
}
bool
DriverMED_Family
::IsEmpty () const
{
return myElements.empty();
}
//============================================================================= //=============================================================================
/*! /*!
* Split each group from list <aGroups> on some parts (families) * Split each group from list <aGroups> on some parts (families)
@ -39,15 +136,16 @@ using namespace std;
* Resulting families have no common elements. * Resulting families have no common elements.
*/ */
//============================================================================= //=============================================================================
list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies DriverMED_FamilyPtrList
(const map <int, SMESHDS_SubMesh*>& theSubMeshes, DriverMED_Family
const list<SMESHDS_GroupBase*>& theGroups, ::MakeFamilies(const SMESHDS_SubMeshPtrMap& theSubMeshes,
const bool doGroupOfNodes, const SMESHDS_GroupBasePtrList& theGroups,
const bool doGroupOfEdges, const bool doGroupOfNodes,
const bool doGroupOfFaces, const bool doGroupOfEdges,
const bool doGroupOfVolumes) const bool doGroupOfFaces,
const bool doGroupOfVolumes)
{ {
list<DriverMED_FamilyPtr> aFamilies; DriverMED_FamilyPtrList aFamilies;
string anAllNodesGroupName = "Group_Of_All_Nodes"; string anAllNodesGroupName = "Group_Of_All_Nodes";
string anAllEdgesGroupName = "Group_Of_All_Edges"; string anAllEdgesGroupName = "Group_Of_All_Edges";
@ -61,22 +159,23 @@ list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies
int aElemFamId = FIRST_ELEM_FAMILY; int aElemFamId = FIRST_ELEM_FAMILY;
// Process sub-meshes // Process sub-meshes
map<int, SMESHDS_SubMesh*>::const_iterator aSMIter = theSubMeshes.begin(); SMESHDS_SubMeshPtrMap::const_iterator aSMIter = theSubMeshes.begin();
for (; aSMIter != theSubMeshes.end(); aSMIter++) for (; aSMIter != theSubMeshes.end(); aSMIter++)
{ {
if ( aSMIter->second->IsComplexSubmesh() ) const int anId = aSMIter->first;
SMESHDS_SubMesh* aSubMesh = aSMIter->second;
if ( aSubMesh->IsComplexSubmesh() )
continue; // submesh containing other submeshs continue; // submesh containing other submeshs
list<DriverMED_FamilyPtr> aSMFams = SplitByType((*aSMIter).second, (*aSMIter).first); DriverMED_FamilyPtrList aSMFams = SplitByType(aSubMesh,anId);
list<DriverMED_FamilyPtr>::iterator aSMFamsIter = aSMFams.begin(); DriverMED_FamilyPtrList::iterator aSMFamsIter = aSMFams.begin();
for (; aSMFamsIter != aSMFams.end(); aSMFamsIter++) for (; aSMFamsIter != aSMFams.end(); aSMFamsIter++)
{ {
DriverMED_FamilyPtr aFam2 = (*aSMFamsIter); DriverMED_FamilyPtr aFam2 = (*aSMFamsIter);
DriverMED_FamilyPtrList::iterator aFamsIter = aFamilies.begin();
list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
while (aFamsIter != aFamilies.end()) while (aFamsIter != aFamilies.end())
{ {
DriverMED_FamilyPtr aFam1 = *aFamsIter; DriverMED_FamilyPtr aFam1 = *aFamsIter;
list<DriverMED_FamilyPtr>::iterator aCurrIter = aFamsIter++; DriverMED_FamilyPtrList::iterator aCurrIter = aFamsIter++;
if (aFam1->myType == aFam2->myType) if (aFam1->myType == aFam2->myType)
{ {
DriverMED_FamilyPtr aCommon (new DriverMED_Family); DriverMED_FamilyPtr aCommon (new DriverMED_Family);
@ -89,7 +188,8 @@ list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies
{ {
aFamilies.erase(aCurrIter); aFamilies.erase(aCurrIter);
} }
if (aFam2->IsEmpty()) break; if (aFam2->IsEmpty())
break;
} }
} }
// The rest elements of family // The rest elements of family
@ -101,30 +201,32 @@ list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies
} }
// Process groups // Process groups
list<SMESHDS_GroupBase*>::const_iterator aGroupsIter = theGroups.begin(); SMESHDS_GroupBasePtrList::const_iterator aGroupsIter = theGroups.begin();
for (; aGroupsIter != theGroups.end(); aGroupsIter++) for (; aGroupsIter != theGroups.end(); aGroupsIter++)
{ {
DriverMED_FamilyPtr aFam2 (new DriverMED_Family); DriverMED_FamilyPtr aFam2 (new DriverMED_Family);
aFam2->Init(*aGroupsIter); aFam2->Init(*aGroupsIter);
list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin(); DriverMED_FamilyPtrList::iterator aFamsIter = aFamilies.begin();
while (aFamsIter != aFamilies.end()) while (aFamsIter != aFamilies.end())
{ {
DriverMED_FamilyPtr aFam1 = *aFamsIter; DriverMED_FamilyPtr aFam1 = *aFamsIter;
list<DriverMED_FamilyPtr>::iterator aCurrIter = aFamsIter++; DriverMED_FamilyPtrList::iterator aCurrIter = aFamsIter++;
if (aFam1->myType == aFam2->myType) if (aFam1->myType == aFam2->myType)
{ {
DriverMED_FamilyPtr aCommon (new DriverMED_Family); DriverMED_FamilyPtr aCommon (new DriverMED_Family);
aFam1->Split(aFam2, aCommon); aFam1->Split(aFam2, aCommon);
if (!aCommon->IsEmpty()) if (!aCommon->IsEmpty())
{ {
aCommon->SetGroupAttributVal(0);
aFamilies.push_back(aCommon); aFamilies.push_back(aCommon);
} }
if (aFam1->IsEmpty()) if (aFam1->IsEmpty())
{ {
aFamilies.erase(aCurrIter); aFamilies.erase(aCurrIter);
} }
if (aFam2->IsEmpty()) break; if (aFam2->IsEmpty())
break;
} }
} }
// The rest elements of group // The rest elements of group
@ -134,7 +236,7 @@ list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies
} }
} }
list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin(); DriverMED_FamilyPtrList::iterator aFamsIter = aFamilies.begin();
for (; aFamsIter != aFamilies.end(); aFamsIter++) for (; aFamsIter != aFamilies.end(); aFamsIter++)
{ {
DriverMED_FamilyPtr aFam = *aFamsIter; DriverMED_FamilyPtr aFam = *aFamsIter;
@ -210,33 +312,33 @@ MED::PFamilyInfo
DriverMED_Family::GetFamilyInfo(const MED::PWrapper& theWrapper, DriverMED_Family::GetFamilyInfo(const MED::PWrapper& theWrapper,
const MED::PMeshInfo& theMeshInfo) const const MED::PMeshInfo& theMeshInfo) const
{ {
string aValue;
ostringstream aStr; ostringstream aStr;
aStr << "FAM_" << myId; aStr << "FAM_" << myId;
set<string>::const_iterator aGrIter = myGroupNames.begin(); set<string>::const_iterator aGrIter = myGroupNames.begin();
for (; aGrIter != myGroupNames.end(); aGrIter++) for(; aGrIter != myGroupNames.end(); aGrIter++){
{
aStr << "_" << *aGrIter; aStr << "_" << *aGrIter;
} }
aValue = aStr.str(); MED::PFamilyInfo anInfo;
/* string aValue = aStr.str();
MED::TStringVector anAttrDescs (1, ""); // 1 attribute with empty description, if(myId == 0){
MED::TIntVector anAttrIds (1, myId); // Id=0, anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
MED::TIntVector anAttrVals (1, myId); // Value=0 aValue,
*/ myId,
myGroupNames);
MED::PFamilyInfo anInfo = theWrapper->CrFamilyInfo(theMeshInfo, }else{
aValue, MED::TStringVector anAttrDescs (1, ""); // 1 attribute with empty description,
myId, MED::TIntVector anAttrIds (1, myId); // Id=0,
myGroupNames); MED::TIntVector anAttrVals (1);
/* anAttrVals[0] = myGroupAttributVal != 0? myGroupAttributVal: myId;
anAttrDescs, anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
anAttrIds, aValue,
anAttrVals); myId,
*/ myGroupNames,
anAttrDescs,
anAttrIds,
anAttrVals);
}
// cout << endl; // cout << endl;
// cout << "Groups: "; // cout << "Groups: ";
@ -279,6 +381,14 @@ void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup)
// Groups list // Groups list
myGroupNames.clear(); myGroupNames.clear();
myGroupNames.insert(string(theGroup->GetStoreName())); myGroupNames.insert(string(theGroup->GetStoreName()));
myGroupAttributVal = 0;
if (theGroup->GetColorGroup()!=0)
{
myGroupAttributVal = theGroup->GetColorGroup();
}
} }
//============================================================================= //=============================================================================
@ -287,10 +397,12 @@ void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup)
* on the basis of the elements type. * on the basis of the elements type.
*/ */
//============================================================================= //=============================================================================
list<DriverMED_FamilyPtr> DriverMED_Family::SplitByType (SMESHDS_SubMesh* theSubMesh, DriverMED_FamilyPtrList
const int theId) DriverMED_Family
::SplitByType (SMESHDS_SubMesh* theSubMesh,
const int theId)
{ {
list<DriverMED_FamilyPtr> aFamilies; DriverMED_FamilyPtrList aFamilies;
DriverMED_FamilyPtr aNodesFamily (new DriverMED_Family); DriverMED_FamilyPtr aNodesFamily (new DriverMED_Family);
DriverMED_FamilyPtr anEdgesFamily (new DriverMED_Family); DriverMED_FamilyPtr anEdgesFamily (new DriverMED_Family);
DriverMED_FamilyPtr aFacesFamily (new DriverMED_Family); DriverMED_FamilyPtr aFacesFamily (new DriverMED_Family);
@ -361,7 +473,7 @@ void DriverMED_Family::Split (DriverMED_FamilyPtr by,
DriverMED_FamilyPtr common) DriverMED_FamilyPtr common)
{ {
// Elements // Elements
set<const SMDS_MeshElement *>::iterator anIter = by->myElements.begin(); ElementsSet::iterator anIter = by->myElements.begin();
while ( anIter != by->myElements.end()) while ( anIter != by->myElements.end())
{ {
if (myElements.find(*anIter) != myElements.end()) if (myElements.find(*anIter) != myElements.end())
@ -378,7 +490,7 @@ void DriverMED_Family::Split (DriverMED_FamilyPtr by,
{ {
// Groups list // Groups list
common->myGroupNames = myGroupNames; common->myGroupNames = myGroupNames;
set<string>::iterator aGrNamesIter = by->myGroupNames.begin(); MED::TStringSet::iterator aGrNamesIter = by->myGroupNames.begin();
for (; aGrNamesIter != by->myGroupNames.end(); aGrNamesIter++) for (; aGrNamesIter != by->myGroupNames.end(); aGrNamesIter++)
{ {
common->myGroupNames.insert(*aGrNamesIter); common->myGroupNames.insert(*aGrNamesIter);

View File

@ -45,76 +45,92 @@
class DriverMED_Family; class DriverMED_Family;
typedef boost::shared_ptr<DriverMED_Family> DriverMED_FamilyPtr; typedef boost::shared_ptr<DriverMED_Family> DriverMED_FamilyPtr;
typedef std::list<DriverMED_FamilyPtr> DriverMED_FamilyPtrList;
typedef std::map<int,SMESHDS_SubMesh*> SMESHDS_SubMeshPtrMap;
typedef std::list<SMESHDS_GroupBase*> SMESHDS_GroupBasePtrList;
typedef std::set<const SMDS_MeshElement*> ElementsSet;
class DriverMED_Family class DriverMED_Family
{ {
public: public:
// Methods for groups storing to MED DriverMED_Family();
static std::list<DriverMED_FamilyPtr> MakeFamilies (const std::map <int, SMESHDS_SubMesh*>& theSubMeshes, //! Methods for groups storing to MED
const std::list<SMESHDS_GroupBase*>& theGroups, /*!
const bool doGroupOfNodes, Split each group from list <theGroups> and each sub-mesh from list <theSubMeshes>
const bool doGroupOfEdges, on some parts (families) on the basis of the elements membership in other groups
const bool doGroupOfFaces, from <theGroups> and other sub-meshes from <theSubMeshes>.
const bool doGroupOfVolumes); Resulting families have no common elements.
// Split each group from list <theGroups> and each sub-mesh from list <theSubMeshes> */
// on some parts (families) on the basis of the elements membership in other groups static
// from <theGroups> and other sub-meshes from <theSubMeshes>. DriverMED_FamilyPtrList
// Resulting families have no common elements. MakeFamilies (const SMESHDS_SubMeshPtrMap& theSubMeshes,
const SMESHDS_GroupBasePtrList& theGroups,
const bool doGroupOfNodes,
const bool doGroupOfEdges,
const bool doGroupOfFaces,
const bool doGroupOfVolumes);
MED::PFamilyInfo GetFamilyInfo (const MED::PWrapper& theWrapper, //! Create TFamilyInfo for this family
const MED::PMeshInfo& theMeshInfo) const; MED::PFamilyInfo
// Create TFamilyInfo for this family GetFamilyInfo (const MED::PWrapper& theWrapper,
const MED::PMeshInfo& theMeshInfo) const;
const std::set<const SMDS_MeshElement *>& GetElements () const { return myElements; } //! Returns elements of this family
// Returns elements of this family const ElementsSet& GetElements () const;
int GetId () const { return myId; } //! Returns a family ID
// Returns a family ID int GetId () const;
//! Sets a family ID
void SetId (const int theId);
public: public:
// Methods for groups reading from MED // Methods for groups reading from MED
void AddElement (const SMDS_MeshElement* theElement) { myElements.insert(theElement); } void AddElement(const SMDS_MeshElement* theElement);
void AddGroupName (std::string theGroupName) { myGroupNames.insert(theGroupName); } const MED::TStringSet& GetGroupNames() const;
void AddGroupName(std::string theGroupName);
void SetType (const SMDSAbs_ElementType theType) { myType = theType; } void SetType(const SMDSAbs_ElementType theType);
SMDSAbs_ElementType GetType () { return myType; } SMDSAbs_ElementType GetType();
bool MemberOf (std::string theGroupName) const bool MemberOf(std::string theGroupName) const;
{ return (myGroupNames.find(theGroupName) != myGroupNames.end()); }
const MED::TStringSet& GetGroupNames () const { return myGroupNames; } int GetGroupAttributVal() const;
void SetGroupAttributVal( int theValue);
void SetId (const int theId) { myId = theId; }
// Sets a family ID
private: private:
//! Initialize the tool by SMESHDS_GroupBase
void Init (SMESHDS_GroupBase* group); void Init (SMESHDS_GroupBase* group);
// Initialize the tool by SMESHDS_GroupBase
static std::list<DriverMED_FamilyPtr> SplitByType (SMESHDS_SubMesh* theSubMesh, //! Split <theSubMesh> on some parts (families) on the basis of the elements type.
const int theId); static
// Split <theSubMesh> on some parts (families) DriverMED_FamilyPtrList
// on the basis of the elements type. SplitByType(SMESHDS_SubMesh* theSubMesh,
const int theId);
/*! Remove from <Elements> elements, common with <by>,
Remove from <by> elements, common with <Elements>,
Create family <common> from common elements, with combined groups list.
*/
void Split (DriverMED_FamilyPtr by, void Split (DriverMED_FamilyPtr by,
DriverMED_FamilyPtr common); DriverMED_FamilyPtr common);
// Remove from <Elements> elements, common with <by>,
// Remove from <by> elements, common with <Elements>,
// Create family <common> from common elements, with combined groups list.
bool IsEmpty () const { return myElements.empty(); } //! Check, if this family has empty list of elements
// Check, if this family has empty list of elements bool IsEmpty () const;
private: private:
int myId; int myId;
SMDSAbs_ElementType myType; SMDSAbs_ElementType myType;
std::set<const SMDS_MeshElement *> myElements; ElementsSet myElements;
MED::TStringSet myGroupNames; MED::TStringSet myGroupNames;
int myGroupAttributVal;
}; };
#endif #endif

View File

@ -41,6 +41,7 @@
#ifdef _DEBUG_ #ifdef _DEBUG_
static int MYDEBUG = 0; static int MYDEBUG = 0;
//#define _DEXCEPT_
#else #else
static int MYDEBUG = 0; static int MYDEBUG = 0;
#endif #endif
@ -69,10 +70,12 @@ DriverMED_R_SMESHDS_Mesh
::Perform() ::Perform()
{ {
Status aResult = DRS_FAIL; Status aResult = DRS_FAIL;
#ifndef _DEXCEPT_
try{ try{
#endif
myFamilies.clear(); myFamilies.clear();
if(MYDEBUG) MESSAGE("Perform - myFile : "<<myFile); if(MYDEBUG) MESSAGE("Perform - myFile : "<<myFile);
PWrapper aMed = CrWrapper(myFile); PWrapper aMed = CrWrapper(myFile,true);
aResult = DRS_EMPTY; aResult = DRS_EMPTY;
if(TInt aNbMeshes = aMed->GetNbMeshes()){ if(TInt aNbMeshes = aMed->GetNbMeshes()){
@ -195,7 +198,9 @@ DriverMED_R_SMESHDS_Mesh
SMDS_MeshElement* anElement = NULL; SMDS_MeshElement* anElement = NULL;
TInt aFamNum = aPolygoneInfo->GetFamNum(iElem); TInt aFamNum = aPolygoneInfo->GetFamNum(iElem);
#ifndef _DEXCEPT_
try{ try{
#endif
if(anIsElemNum){ if(anIsElemNum){
TInt anElemId = aPolygoneInfo->GetElemNum(iElem); TInt anElemId = aPolygoneInfo->GetElemNum(iElem);
anElement = myMesh->AddPolygonalFaceWithID(aNodeIds,anElemId); anElement = myMesh->AddPolygonalFaceWithID(aNodeIds,anElemId);
@ -207,12 +212,13 @@ DriverMED_R_SMESHDS_Mesh
anElement = myMesh->AddPolygonalFace(aNodes); anElement = myMesh->AddPolygonalFace(aNodes);
isRenum = anIsElemNum; isRenum = anIsElemNum;
} }
#ifndef _DEXCEPT_
}catch(const std::exception& exc){ }catch(const std::exception& exc){
aResult = DRS_FAIL; aResult = DRS_FAIL;
}catch (...){ }catch (...){
aResult = DRS_FAIL; aResult = DRS_FAIL;
} }
#endif
if(!anElement){ if(!anElement){
aResult = DRS_WARN_SKIP_ELEM; aResult = DRS_WARN_SKIP_ELEM;
}else{ }else{
@ -265,7 +271,9 @@ DriverMED_R_SMESHDS_Mesh
SMDS_MeshElement* anElement = NULL; SMDS_MeshElement* anElement = NULL;
TInt aFamNum = aPolyedreInfo->GetFamNum(iElem); TInt aFamNum = aPolyedreInfo->GetFamNum(iElem);
#ifndef _DEXCEPT_
try{ try{
#endif
if(anIsElemNum){ if(anIsElemNum){
TInt anElemId = aPolyedreInfo->GetElemNum(iElem); TInt anElemId = aPolyedreInfo->GetElemNum(iElem);
anElement = myMesh->AddPolyhedralVolumeWithID(aNodeIds,aQuantities,anElemId); anElement = myMesh->AddPolyhedralVolumeWithID(aNodeIds,aQuantities,anElemId);
@ -277,12 +285,13 @@ DriverMED_R_SMESHDS_Mesh
anElement = myMesh->AddPolyhedralVolume(aNodes,aQuantities); anElement = myMesh->AddPolyhedralVolume(aNodes,aQuantities);
isRenum = anIsElemNum; isRenum = anIsElemNum;
} }
#ifndef _DEXCEPT_
}catch(const std::exception& exc){ }catch(const std::exception& exc){
aResult = DRS_FAIL; aResult = DRS_FAIL;
}catch(...){ }catch(...){
aResult = DRS_FAIL; aResult = DRS_FAIL;
} }
#endif
if(!anElement){ if(!anElement){
aResult = DRS_WARN_SKIP_ELEM; aResult = DRS_WARN_SKIP_ELEM;
}else{ }else{
@ -302,238 +311,388 @@ DriverMED_R_SMESHDS_Mesh
break; break;
} }
default: { default: {
PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom); PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX; EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
TInt aNbElems = aCellInfo->GetNbElem(); TInt aNbElems = aCellInfo->GetNbElem();
if(MYDEBUG) MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum); if(MYDEBUG) MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
if(MYDEBUG) MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems); if(MYDEBUG) MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
for(int iElem = 0; iElem < aNbElems; iElem++){ for(int iElem = 0; iElem < aNbElems; iElem++){
TInt aNbNodes = -1; TInt aNbNodes = -1;
switch(aGeom){ switch(aGeom){
case eSEG2: case eSEG2: aNbNodes = 2; break;
case eSEG3: case eSEG3: aNbNodes = 3; break;
aNbNodes = 2; case eTRIA3: aNbNodes = 3; break;
break; case eTRIA6: aNbNodes = 6; break;
case eTRIA3: case eQUAD4: aNbNodes = 4; break;
case eTRIA6: case eQUAD8: aNbNodes = 8; break;
aNbNodes = 3; case eTETRA4: aNbNodes = 4; break;
break; case eTETRA10: aNbNodes = 10; break;
break; case ePYRA5: aNbNodes = 5; break;
case eQUAD4: case ePYRA13: aNbNodes = 13; break;
case eQUAD8: case ePENTA6: aNbNodes = 6; break;
aNbNodes = 4; case ePENTA15: aNbNodes = 15; break;
break; case eHEXA8: aNbNodes = 8; break;
case eTETRA4: case eHEXA20: aNbNodes = 20; break;
case eTETRA10: default:;
aNbNodes = 4; }
break; vector<TInt> aNodeIds(aNbNodes);
case ePYRA5: bool anIsValidConnect = false;
case ePYRA13: TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
aNbNodes = 5; #ifndef _DEXCEPT_
break; try{
case ePENTA6:
case ePENTA15:
aNbNodes = 6;
break;
case eHEXA8:
case eHEXA20:
aNbNodes = 8;
break;
}
TNodeIds aNodeIds(aNbNodes);
bool anIsValidConnect = false;
TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
try{
#ifdef _EDF_NODE_IDS_
if(anIsNodeNum)
for(int iNode = 0; iNode < aNbNodes; iNode++)
aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iNode] - 1);
else
for(int iNode = 0; iNode < aNbNodes; iNode++)
aNodeIds[iNode] = aConnSlice[iNode];
#else
for(int iNode = 0; iNode < aNbNodes; iNode++)
aNodeIds[iNode] = aConnSlice[iNode];
#endif #endif
anIsValidConnect = true; #ifdef _EDF_NODE_IDS_
}catch(const std::exception& exc){ if(anIsNodeNum)
//INFOS("Follow exception was cought:\n\t"<<exc.what()); for(int iNode = 0; iNode < aNbNodes; iNode++)
aResult = DRS_FAIL; aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iNode] - 1);
}catch(...){ else
//INFOS("Unknown exception was cought !!!"); for(int iNode = 0; iNode < aNbNodes; iNode++)
aResult = DRS_FAIL; aNodeIds[iNode] = aConnSlice[iNode];
} #else
for(int iNode = 0; iNode < aNbNodes; iNode++)
aNodeIds[iNode] = aConnSlice[iNode];
#endif
anIsValidConnect = true;
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
//INFOS("Follow exception was cought:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
//INFOS("Unknown exception was cought !!!");
aResult = DRS_FAIL;
}
#endif
if(!anIsValidConnect)
continue;
if(!anIsValidConnect) bool isRenum = false;
continue; SMDS_MeshElement* anElement = NULL;
TInt aFamNum = aCellInfo->GetFamNum(iElem);
bool isRenum = false; #ifndef _DEXCEPT_
SMDS_MeshElement* anElement = NULL; try{
TInt aFamNum = aCellInfo->GetFamNum(iElem); #endif
try{ //MESSAGE("Try to create element # " << iElem << " with id = "
//MESSAGE("Try to create element # " << iElem << " with id = " // << aCellInfo->GetElemNum(iElem));
// << aCellInfo->GetElemNum(iElem)); switch(aGeom){
switch(aGeom){ case eSEG2:
case eSEG2: if(anIsElemNum)
case eSEG3: anElement = myMesh->AddEdgeWithID(aNodeIds[0],
if(anIsElemNum) aNodeIds[1],
anElement = myMesh->AddEdgeWithID(aNodeIds[0], aCellInfo->GetElemNum(iElem));
aNodeIds[1], if (!anElement) {
aCellInfo->GetElemNum(iElem)); anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
if (!anElement) { FindNode(myMesh,aNodeIds[1]));
anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]), isRenum = anIsElemNum;
FindNode(myMesh,aNodeIds[1])); }
isRenum = anIsElemNum; break;
} case eSEG3:
break; if(anIsElemNum)
case eTRIA3: anElement = myMesh->AddEdgeWithID(aNodeIds[0],
case eTRIA6: aNodeIds[1],
aNbNodes = 3; aNodeIds[2],
if(anIsElemNum) aCellInfo->GetElemNum(iElem));
anElement = myMesh->AddFaceWithID(aNodeIds[0], if (!anElement) {
aNodeIds[1], anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
aNodeIds[2], FindNode(myMesh,aNodeIds[1]),
aCellInfo->GetElemNum(iElem)); FindNode(myMesh,aNodeIds[2]));
if (!anElement) { isRenum = anIsElemNum;
anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]), }
FindNode(myMesh,aNodeIds[1]), break;
FindNode(myMesh,aNodeIds[2])); case eTRIA3:
isRenum = anIsElemNum; aNbNodes = 3;
} if(anIsElemNum)
break; anElement = myMesh->AddFaceWithID(aNodeIds[0],
case eQUAD4: aNodeIds[1],
case eQUAD8: aNodeIds[2],
aNbNodes = 4; aCellInfo->GetElemNum(iElem));
// There is some differnce between SMDS and MED if (!anElement) {
if(anIsElemNum) anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
anElement = myMesh->AddFaceWithID(aNodeIds[0], FindNode(myMesh,aNodeIds[1]),
aNodeIds[1], FindNode(myMesh,aNodeIds[2]));
aNodeIds[2], isRenum = anIsElemNum;
aNodeIds[3], }
aCellInfo->GetElemNum(iElem)); break;
if (!anElement) { case eTRIA6:
anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]), aNbNodes = 6;
FindNode(myMesh,aNodeIds[1]), if(anIsElemNum)
FindNode(myMesh,aNodeIds[2]), anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
FindNode(myMesh,aNodeIds[3])); aNodeIds[2], aNodeIds[3],
isRenum = anIsElemNum; aNodeIds[4], aNodeIds[5],
} aCellInfo->GetElemNum(iElem));
break; if (!anElement) {
case eTETRA4: anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
case eTETRA10: FindNode(myMesh,aNodeIds[1]),
aNbNodes = 4; FindNode(myMesh,aNodeIds[2]),
if(anIsElemNum) FindNode(myMesh,aNodeIds[3]),
anElement = myMesh->AddVolumeWithID(aNodeIds[0], FindNode(myMesh,aNodeIds[4]),
aNodeIds[1], FindNode(myMesh,aNodeIds[5]));
aNodeIds[2], isRenum = anIsElemNum;
aNodeIds[3], }
aCellInfo->GetElemNum(iElem)); break;
if (!anElement) { case eQUAD4:
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]), aNbNodes = 4;
FindNode(myMesh,aNodeIds[1]), if(anIsElemNum)
FindNode(myMesh,aNodeIds[2]), anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
FindNode(myMesh,aNodeIds[3])); aNodeIds[2], aNodeIds[3],
isRenum = anIsElemNum; aCellInfo->GetElemNum(iElem));
} if (!anElement) {
break; anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
case ePYRA5: FindNode(myMesh,aNodeIds[1]),
case ePYRA13: FindNode(myMesh,aNodeIds[2]),
aNbNodes = 5; FindNode(myMesh,aNodeIds[3]));
// There is some differnce between SMDS and MED isRenum = anIsElemNum;
if(anIsElemNum) }
anElement = myMesh->AddVolumeWithID(aNodeIds[0], break;
aNodeIds[1], case eQUAD8:
aNodeIds[2], aNbNodes = 8;
aNodeIds[3], if(anIsElemNum)
aNodeIds[4], anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
aCellInfo->GetElemNum(iElem)); aNodeIds[2], aNodeIds[3],
if (!anElement) { aNodeIds[4], aNodeIds[5],
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]), aNodeIds[6], aNodeIds[7],
FindNode(myMesh,aNodeIds[1]), aCellInfo->GetElemNum(iElem));
FindNode(myMesh,aNodeIds[2]), if (!anElement) {
FindNode(myMesh,aNodeIds[3]), anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[4])); FindNode(myMesh,aNodeIds[1]),
isRenum = anIsElemNum; FindNode(myMesh,aNodeIds[2]),
} FindNode(myMesh,aNodeIds[3]),
break; FindNode(myMesh,aNodeIds[4]),
case ePENTA6: FindNode(myMesh,aNodeIds[5]),
case ePENTA15: FindNode(myMesh,aNodeIds[6]),
aNbNodes = 6; FindNode(myMesh,aNodeIds[7]));
if(anIsElemNum) isRenum = anIsElemNum;
anElement = myMesh->AddVolumeWithID(aNodeIds[0], }
aNodeIds[1], break;
aNodeIds[2], case eTETRA4:
aNodeIds[3], aNbNodes = 4;
aNodeIds[4], if(anIsElemNum)
aNodeIds[5], anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aCellInfo->GetElemNum(iElem)); aNodeIds[2], aNodeIds[3],
if (!anElement) { aCellInfo->GetElemNum(iElem));
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]), if (!anElement) {
FindNode(myMesh,aNodeIds[1]), anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[2]), FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[3]), FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[4]), FindNode(myMesh,aNodeIds[3]));
FindNode(myMesh,aNodeIds[5])); isRenum = anIsElemNum;
isRenum = anIsElemNum; }
} break;
break; case eTETRA10:
case eHEXA8: aNbNodes = 10;
case eHEXA20: if(anIsElemNum)
aNbNodes = 8; anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
if(anIsElemNum) aNodeIds[2], aNodeIds[3],
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[4], aNodeIds[5],
aNodeIds[1], aNodeIds[6], aNodeIds[7],
aNodeIds[2], aNodeIds[8], aNodeIds[9],
aNodeIds[3], aCellInfo->GetElemNum(iElem));
aNodeIds[4], if (!anElement) {
aNodeIds[5], anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
aNodeIds[6], FindNode(myMesh,aNodeIds[1]),
aNodeIds[7], FindNode(myMesh,aNodeIds[2]),
aCellInfo->GetElemNum(iElem)); FindNode(myMesh,aNodeIds[3]),
if (!anElement) { FindNode(myMesh,aNodeIds[4]),
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]), FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[1]), FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[2]), FindNode(myMesh,aNodeIds[7]),
FindNode(myMesh,aNodeIds[3]), FindNode(myMesh,aNodeIds[8]),
FindNode(myMesh,aNodeIds[4]), FindNode(myMesh,aNodeIds[9]));
FindNode(myMesh,aNodeIds[5]), isRenum = anIsElemNum;
FindNode(myMesh,aNodeIds[6]), }
FindNode(myMesh,aNodeIds[7])); break;
isRenum = anIsElemNum; case ePYRA5:
} aNbNodes = 5;
break; // There is some differnce between SMDS and MED
} if(anIsElemNum)
}catch(const std::exception& exc){ anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
//INFOS("Follow exception was cought:\n\t"<<exc.what()); aNodeIds[2], aNodeIds[3],
aResult = DRS_FAIL; aNodeIds[4],
}catch(...){ aCellInfo->GetElemNum(iElem));
//INFOS("Unknown exception was cought !!!"); if (!anElement) {
aResult = DRS_FAIL; anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
} FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
if (!anElement) { FindNode(myMesh,aNodeIds[3]),
aResult = DRS_WARN_SKIP_ELEM; FindNode(myMesh,aNodeIds[4]));
} isRenum = anIsElemNum;
else { }
if (isRenum) { break;
anIsElemNum = eFAUX; case ePYRA13:
takeNumbers = false; aNbNodes = 13;
if (aResult < DRS_WARN_RENUMBER) // There is some differnce between SMDS and MED
aResult = DRS_WARN_RENUMBER; if(anIsElemNum)
} anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
if ( checkFamilyID ( aFamily, aFamNum )) { aNodeIds[2], aNodeIds[3],
// Save reference to this element from its family aNodeIds[4], aNodeIds[5],
myFamilies[aFamNum]->AddElement(anElement); aNodeIds[6], aNodeIds[7],
myFamilies[aFamNum]->SetType(anElement->GetType()); aNodeIds[8], aNodeIds[9],
} aNodeIds[10], aNodeIds[11],
} aNodeIds[12],
} aCellInfo->GetElemNum(iElem));
}} if (!anElement) {
} anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
} FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[7]),
FindNode(myMesh,aNodeIds[8]),
FindNode(myMesh,aNodeIds[9]),
FindNode(myMesh,aNodeIds[10]),
FindNode(myMesh,aNodeIds[11]),
FindNode(myMesh,aNodeIds[12]));
isRenum = anIsElemNum;
}
break;
case ePENTA6:
aNbNodes = 6;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0],
aNodeIds[1],
aNodeIds[2],
aNodeIds[3],
aNodeIds[4],
aNodeIds[5],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]));
isRenum = anIsElemNum;
}
break;
case ePENTA15:
aNbNodes = 15;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aNodeIds[4], aNodeIds[5],
aNodeIds[6], aNodeIds[7],
aNodeIds[8], aNodeIds[9],
aNodeIds[10], aNodeIds[11],
aNodeIds[12], aNodeIds[13],
aNodeIds[14],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[7]),
FindNode(myMesh,aNodeIds[8]),
FindNode(myMesh,aNodeIds[9]),
FindNode(myMesh,aNodeIds[10]),
FindNode(myMesh,aNodeIds[11]),
FindNode(myMesh,aNodeIds[12]),
FindNode(myMesh,aNodeIds[13]),
FindNode(myMesh,aNodeIds[14]));
isRenum = anIsElemNum;
}
break;
case eHEXA8:
aNbNodes = 8;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0],
aNodeIds[1],
aNodeIds[2],
aNodeIds[3],
aNodeIds[4],
aNodeIds[5],
aNodeIds[6],
aNodeIds[7],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[7]));
isRenum = anIsElemNum;
}
break;
case eHEXA20:
aNbNodes = 20;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
aNodeIds[4], aNodeIds[5],
aNodeIds[6], aNodeIds[7],
aNodeIds[8], aNodeIds[9],
aNodeIds[10], aNodeIds[11],
aNodeIds[12], aNodeIds[13],
aNodeIds[14], aNodeIds[15],
aNodeIds[16], aNodeIds[17],
aNodeIds[18], aNodeIds[19],
aCellInfo->GetElemNum(iElem));
if (!anElement) {
anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
FindNode(myMesh,aNodeIds[1]),
FindNode(myMesh,aNodeIds[2]),
FindNode(myMesh,aNodeIds[3]),
FindNode(myMesh,aNodeIds[4]),
FindNode(myMesh,aNodeIds[5]),
FindNode(myMesh,aNodeIds[6]),
FindNode(myMesh,aNodeIds[7]),
FindNode(myMesh,aNodeIds[8]),
FindNode(myMesh,aNodeIds[9]),
FindNode(myMesh,aNodeIds[10]),
FindNode(myMesh,aNodeIds[11]),
FindNode(myMesh,aNodeIds[12]),
FindNode(myMesh,aNodeIds[13]),
FindNode(myMesh,aNodeIds[14]),
FindNode(myMesh,aNodeIds[15]),
FindNode(myMesh,aNodeIds[16]),
FindNode(myMesh,aNodeIds[17]),
FindNode(myMesh,aNodeIds[18]),
FindNode(myMesh,aNodeIds[19]));
isRenum = anIsElemNum;
}
break;
}
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
//INFOS("Follow exception was cought:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
//INFOS("Unknown exception was cought !!!");
aResult = DRS_FAIL;
}
#endif
if (!anElement) {
aResult = DRS_WARN_SKIP_ELEM;
}
else {
if (isRenum) {
anIsElemNum = eFAUX;
takeNumbers = false;
if (aResult < DRS_WARN_RENUMBER)
aResult = DRS_WARN_RENUMBER;
}
if ( checkFamilyID ( aFamily, aFamNum )) {
// Save reference to this element from its family
myFamilies[aFamNum]->AddElement(anElement);
myFamilies[aFamNum]->SetType(anElement->GetType());
}
}
}
}}
}
}
} }
} }
#ifndef _DEXCEPT_
}catch(const std::exception& exc){ }catch(const std::exception& exc){
INFOS("Follow exception was cought:\n\t"<<exc.what()); INFOS("Follow exception was cought:\n\t"<<exc.what());
aResult = DRS_FAIL; aResult = DRS_FAIL;
@ -541,6 +700,7 @@ DriverMED_R_SMESHDS_Mesh
INFOS("Unknown exception was cought !!!"); INFOS("Unknown exception was cought !!!");
aResult = DRS_FAIL; aResult = DRS_FAIL;
} }
#endif
if(MYDEBUG) MESSAGE("Perform - aResult status = "<<aResult); if(MYDEBUG) MESSAGE("Perform - aResult status = "<<aResult);
return aResult; return aResult;
} }

View File

@ -393,39 +393,90 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
#ifdef _ELEMENTS_BY_DIM_ #ifdef _ELEMENTS_BY_DIM_
SMDS_MED_ENTITY = eARETE; SMDS_MED_ENTITY = eARETE;
#endif #endif
// count edges of diff types
int aNbSeg3 = 0, aNbSeg2 = 0;
SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
TInt aNbConnectivity = MED::GetNbNodes(eSEG2); while ( anIter->more() )
MED::TIntVector anElemNums(aNbElems); if ( anIter->next()->NbNodes() == 3 )
MED::TIntVector aFamilyNums(aNbElems); ++aNbSeg3;
MED::TIntVector aConnectivity(aNbElems*aNbConnectivity); aNbSeg2 = aNbElems - aNbSeg3;
for(TInt iElem = 0, iConn = 0; anIter->more(); iElem++, iConn+=aNbConnectivity){ TInt aNbSeg2Conn = MED::GetNbNodes(eSEG2);
MED::TIntVector aSeg2ElemNums, aSeg2FamilyNums, aSeg2Conn;
aSeg2ElemNums .reserve( aNbSeg2 );
aSeg2FamilyNums.reserve( aNbSeg2 );
aSeg2Conn .reserve( aNbSeg2*aNbSeg2Conn );
TInt aNbSeg3Conn = MED::GetNbNodes(eSEG3);
MED::TIntVector aSeg3ElemNums, aSeg3FamilyNums, aSeg3Conn;
aSeg3ElemNums .reserve( aNbSeg3 );
aSeg3FamilyNums.reserve( aNbSeg3 );
aSeg3Conn .reserve( aNbSeg3*aNbSeg3Conn );
anIter = myMesh->edgesIterator();
while ( anIter->more() ) {
const SMDS_MeshEdge* anElem = anIter->next(); const SMDS_MeshEdge* anElem = anIter->next();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); TInt aNbNodes = anElem->NbNodes();
for(TInt iNode = 0; iNode < aNbConnectivity && aNodesIter->more(); iNode++){
const SMDS_MeshElement* aNode = aNodesIter->next();
#ifdef _EDF_NODE_IDS_
aConnectivity[iConn+iNode] = aNodeIdMap[aNode->GetID()];
#else
aConnectivity[iConn+iNode] = aNode->GetID();
#endif
}
anElemNums[iElem] = anElem->GetID();
if (anElemFamMap.find(anElem) != anElemFamMap.end()) TInt aNbConnectivity;
aFamilyNums[iElem] = anElemFamMap[anElem]; MED::TIntVector* anElemNums;
MED::TIntVector* aFamilyNums;
MED::TIntVector* aConnectivity;
switch(aNbNodes){
case 2:
aNbConnectivity = aNbSeg2Conn;
anElemNums = &aSeg2ElemNums;
aFamilyNums = &aSeg2FamilyNums;
aConnectivity = &aSeg2Conn;
break;
case 3:
aNbConnectivity = aNbSeg3Conn;
anElemNums = &aSeg3ElemNums;
aFamilyNums = &aSeg3FamilyNums;
aConnectivity = &aSeg3Conn;
break;
default:
break;
}
for(TInt iNode = 0; iNode < aNbNodes; iNode++) {
const SMDS_MeshElement* aNode = anElem->GetNode( iNode );
#ifdef _EDF_NODE_IDS_
aConnectivity->push_back( aNodeIdMap[aNode->GetID()] );
#else
aConnectivity->push_back( aNode->GetID() );
#endif
}
anElemNums->push_back(anElem->GetID());
map<const SMDS_MeshElement*,int>::iterator edge_fam = anElemFamMap.find( anElem );
if ( edge_fam != anElemFamMap.end() )
aFamilyNums->push_back( edge_fam->second );
else else
aFamilyNums[iElem] = myEdgesDefaultFamilyId; aFamilyNums->push_back( myFacesDefaultFamilyId );
} }
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo, if ( aNbSeg2 ) {
SMDS_MED_ENTITY, PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
eSEG2, SMDS_MED_ENTITY,
aConnectivity, eSEG2,
SMDS_MED_CONNECTIVITY, aSeg2Conn,
aFamilyNums, SMDS_MED_CONNECTIVITY,
anElemNums); aSeg2FamilyNums,
myMed->SetCellInfo(aCellInfo); aSeg2ElemNums);
myMed->SetCellInfo(aCellInfo);
}
if ( aNbSeg3 ) {
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
eSEG3,
aSeg3Conn,
SMDS_MED_CONNECTIVITY,
aSeg3FamilyNums,
aSeg3ElemNums);
myMed->SetCellInfo(aCellInfo);
}
} }
// Storing SMDS Faces // Storing SMDS Faces
@ -442,6 +493,14 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
MED::TIntVector aTriaConn; MED::TIntVector aTriaConn;
aTriaConn.reserve(aNbElems*aNbTriaConn); aTriaConn.reserve(aNbElems*aNbTriaConn);
TInt aNbTria6Conn = MED::GetNbNodes(eTRIA6);
MED::TIntVector anTria6ElemNums;
anTria6ElemNums.reserve(aNbElems);
MED::TIntVector aTria6FamilyNums;
aTria6FamilyNums.reserve(aNbElems);
MED::TIntVector aTria6Conn;
aTria6Conn.reserve(aNbElems*aNbTria6Conn);
TInt aNbQuadConn = MED::GetNbNodes(eQUAD4); TInt aNbQuadConn = MED::GetNbNodes(eQUAD4);
MED::TIntVector aQuadElemNums; MED::TIntVector aQuadElemNums;
aQuadElemNums.reserve(aNbElems); aQuadElemNums.reserve(aNbElems);
@ -450,6 +509,14 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
MED::TIntVector aQuadConn; MED::TIntVector aQuadConn;
aQuadConn.reserve(aNbElems*aNbQuadConn); aQuadConn.reserve(aNbElems*aNbQuadConn);
TInt aNbQuad8Conn = MED::GetNbNodes(eQUAD8);
MED::TIntVector aQuad8ElemNums;
aQuad8ElemNums.reserve(aNbElems);
MED::TIntVector aQuad8FamilyNums;
aQuad8FamilyNums.reserve(aNbElems);
MED::TIntVector aQuad8Conn;
aQuad8Conn.reserve(aNbElems*aNbQuad8Conn);
MED::TIntVector aPolygoneElemNums; MED::TIntVector aPolygoneElemNums;
aPolygoneElemNums.reserve(aNbElems); aPolygoneElemNums.reserve(aNbElems);
MED::TIntVector aPolygoneInds; MED::TIntVector aPolygoneInds;
@ -473,7 +540,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
anElemNums = &aPolygoneElemNums; anElemNums = &aPolygoneElemNums;
aFamilyNums = &aPolygoneFamilyNums; aFamilyNums = &aPolygoneFamilyNums;
aConnectivity = &aPolygoneConn; aConnectivity = &aPolygoneConn;
} else { }
else {
switch(aNbNodes){ switch(aNbNodes){
case 3: case 3:
aNbConnectivity = aNbTriaConn; aNbConnectivity = aNbTriaConn;
@ -487,6 +555,18 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
aFamilyNums = &aQuadFamilyNums; aFamilyNums = &aQuadFamilyNums;
aConnectivity = &aQuadConn; aConnectivity = &aQuadConn;
break; break;
case 6:
aNbConnectivity = aNbTria6Conn;
anElemNums = &anTria6ElemNums;
aFamilyNums = &aTria6FamilyNums;
aConnectivity = &aTria6Conn;
break;
case 8:
aNbConnectivity = aNbQuad8Conn;
anElemNums = &aQuad8ElemNums;
aFamilyNums = &aQuad8FamilyNums;
aConnectivity = &aQuad8Conn;
break;
default: default:
break; break;
} }
@ -550,6 +630,28 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD4<<"; aNbElems = "<<aNbElems); MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD4<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo); myMed->SetCellInfo(aCellInfo);
} }
if(TInt aNbElems = anTria6ElemNums.size()){
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
eTRIA6,
aTria6Conn,
SMDS_MED_CONNECTIVITY,
aTria6FamilyNums,
anTria6ElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTRIA6<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo);
}
if(TInt aNbElems = aQuad8ElemNums.size()){
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
eQUAD8,
aQuad8Conn,
SMDS_MED_CONNECTIVITY,
aQuad8FamilyNums,
aQuad8ElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD8<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo);
}
if(TInt aNbElems = aPolygoneElemNums.size()){ if(TInt aNbElems = aPolygoneElemNums.size()){
// add one element in connectivities, // add one element in connectivities,
// referenced by the last element in indices // referenced by the last element in indices
@ -606,6 +708,38 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
MED::TIntVector aHexaConn; MED::TIntVector aHexaConn;
aHexaConn.reserve(aNbElems*aNbHexaConn); aHexaConn.reserve(aNbElems*aNbHexaConn);
TInt aNbTetra10Conn = MED::GetNbNodes(eTETRA10);
MED::TIntVector anTetra10ElemNums;
anTetra10ElemNums.reserve(aNbElems);
MED::TIntVector aTetra10FamilyNums;
aTetra10FamilyNums.reserve(aNbElems);
MED::TIntVector aTetra10Conn;
aTetra10Conn.reserve(aNbElems*aNbTetra10Conn);
TInt aNbPyra13Conn = MED::GetNbNodes(ePYRA13);
MED::TIntVector anPyra13ElemNums;
anPyra13ElemNums.reserve(aNbElems);
MED::TIntVector aPyra13FamilyNums;
aPyra13FamilyNums.reserve(aNbElems);
MED::TIntVector aPyra13Conn;
aPyra13Conn.reserve(aNbElems*aNbPyra13Conn);
TInt aNbPenta15Conn = MED::GetNbNodes(ePENTA15);
MED::TIntVector anPenta15ElemNums;
anPenta15ElemNums.reserve(aNbElems);
MED::TIntVector aPenta15FamilyNums;
aPenta15FamilyNums.reserve(aNbElems);
MED::TIntVector aPenta15Conn;
aPenta15Conn.reserve(aNbElems*aNbPenta15Conn);
TInt aNbHexa20Conn = MED::GetNbNodes(eHEXA20);
MED::TIntVector aHexa20ElemNums;
aHexa20ElemNums.reserve(aNbElems);
MED::TIntVector aHexa20FamilyNums;
aHexa20FamilyNums.reserve(aNbElems);
MED::TIntVector aHexa20Conn;
aHexa20Conn.reserve(aNbElems*aNbHexa20Conn);
MED::TIntVector aPolyedreElemNums; MED::TIntVector aPolyedreElemNums;
aPolyedreElemNums.reserve(aNbElems); aPolyedreElemNums.reserve(aNbElems);
MED::TIntVector aPolyedreInds; MED::TIntVector aPolyedreInds;
@ -653,7 +787,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
TInt aPrevPos = aPolyedreInds.back(); TInt aPrevPos = aPolyedreInds.back();
aPolyedreInds.push_back(aPrevPos + aNbFaces); aPolyedreInds.push_back(aPrevPos + aNbFaces);
} else { }
else {
TInt aNbNodes = anElem->NbNodes(); TInt aNbNodes = anElem->NbNodes();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
TInt aNbConnectivity; TInt aNbConnectivity;
@ -682,6 +817,30 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
anElemNums = &aHexaElemNums; anElemNums = &aHexaElemNums;
aFamilyNums = &aHexaFamilyNums; aFamilyNums = &aHexaFamilyNums;
aConnectivity = &aHexaConn; aConnectivity = &aHexaConn;
break;
case 10:
aNbConnectivity = aNbTetra10Conn;
anElemNums = &anTetra10ElemNums;
aFamilyNums = &aTetra10FamilyNums;
aConnectivity = &aTetra10Conn;
break;
case 13:
aNbConnectivity = aNbPyra13Conn;
anElemNums = &anPyra13ElemNums;
aFamilyNums = &aPyra13FamilyNums;
aConnectivity = &aPyra13Conn;
break;
case 15:
aNbConnectivity = aNbPenta15Conn;
anElemNums = &anPenta15ElemNums;
aFamilyNums = &aPenta15FamilyNums;
aConnectivity = &aPenta15Conn;
break;
case 20:
aNbConnectivity = aNbHexa20Conn;
anElemNums = &aHexa20ElemNums;
aFamilyNums = &aHexa20FamilyNums;
aConnectivity = &aHexa20Conn;
} }
TInt aSize = aConnectivity->size(); TInt aSize = aConnectivity->size();
@ -762,6 +921,51 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA8<<"; aNbElems = "<<aNbElems); MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA8<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo); myMed->SetCellInfo(aCellInfo);
} }
if(TInt aNbElems = anTetra10ElemNums.size()){
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
eTETRA10,
aTetra10Conn,
SMDS_MED_CONNECTIVITY,
aTetra10FamilyNums,
anTetra10ElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTETRA10<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo);
}
if(TInt aNbElems = anPyra13ElemNums.size()){
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
ePYRA13,
aPyra13Conn,
SMDS_MED_CONNECTIVITY,
aPyra13FamilyNums,
anPyra13ElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePYRA13<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo);
}
if(TInt aNbElems = anPenta15ElemNums.size()){
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
ePENTA15,
aPenta15Conn,
SMDS_MED_CONNECTIVITY,
aPenta15FamilyNums,
anPenta15ElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePENTA15<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo);
}
if(TInt aNbElems = aHexa20ElemNums.size()){
PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
SMDS_MED_ENTITY,
eHEXA20,
aHexa20Conn,
SMDS_MED_CONNECTIVITY,
aHexa20FamilyNums,
aHexa20ElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA20<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo);
}
if(TInt aNbElems = aPolyedreElemNums.size()){ if(TInt aNbElems = aPolyedreElemNums.size()){
// add one element in connectivities, // add one element in connectivities,
// referenced by the last element in faces // referenced by the last element in faces
@ -780,9 +984,11 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
myMed->SetPolyedreInfo(aCellInfo); myMed->SetPolyedreInfo(aCellInfo);
} }
} }
}catch(const std::exception& exc){ }
catch(const std::exception& exc) {
INFOS("Follow exception was cought:\n\t"<<exc.what()); INFOS("Follow exception was cought:\n\t"<<exc.what());
}catch(...){ }
catch(...) {
INFOS("Unknown exception was cought !!!"); INFOS("Unknown exception was cought !!!");
} }

View File

@ -228,7 +228,7 @@ Driver_Mesh::Status DriverSTL_W_SMDS_Mesh::writeBinary() const
} }
// write number of triangles // write number of triangles
unsigned int NBT = nbTri; //unsigned int NBT = nbTri;
aFile.Write((Standard_Address)sval,LABEL_SIZE); aFile.Write((Standard_Address)sval,LABEL_SIZE);
writeInteger(nbTri,aFile); writeInteger(nbTri,aFile);

View File

@ -64,11 +64,22 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
SMDS_MeshElement* anElement = NULL; SMDS_MeshElement* anElement = NULL;
const TElementLab& aLabel = anIter->first; const TElementLab& aLabel = anIter->first;
const TRecord& aRec = anIter->second; const TRecord& aRec = anIter->second;
if(IsBeam(aRec.fe_descriptor_id)){ if(IsBeam(aRec.fe_descriptor_id)) {
anElement = myMesh->AddEdgeWithID(aRec.node_labels[0], if(aRec.fe_descriptor_id == 11) {
aRec.node_labels[1], // edge with two nodes
aLabel); anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
}else if(IsFace(aRec.fe_descriptor_id)){ aRec.node_labels[1],
aLabel);
}
else {
// quadratic edge (with 3 nodes)
anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
aRec.node_labels[1],
aRec.node_labels[2],
aLabel);
}
}
else if(IsFace(aRec.fe_descriptor_id)) {
switch(aRec.fe_descriptor_id){ switch(aRec.fe_descriptor_id){
case 71: // TRI3 case 71: // TRI3
case 72: case 72:
@ -76,18 +87,31 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
case 41: // Plane Stress Linear Triangle - TRI3 case 41: // Plane Stress Linear Triangle - TRI3
case 91: // Thin Shell Linear Triangle - TRI3 case 91: // Thin Shell Linear Triangle - TRI3
case 42: // Plane Stress Quadratic Triangle - TRI6
case 92: // Thin Shell Quadratic Triangle - TRI6
anElement = myMesh->AddFaceWithID(aRec.node_labels[0], anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
aRec.node_labels[1], aRec.node_labels[1],
aRec.node_labels[2], aRec.node_labels[2],
aLabel); aLabel);
break; break;
case 42: // Plane Stress Quadratic Triangle - TRI6
case 92: // Thin Shell Quadratic Triangle - TRI6
anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
aRec.node_labels[1],
aRec.node_labels[2],
aRec.node_labels[3],
aRec.node_labels[4],
aRec.node_labels[5],
aLabel);
break;
case 44: // Plane Stress Linear Quadrilateral - QUAD4 case 44: // Plane Stress Linear Quadrilateral - QUAD4
case 94: // Thin Shell Linear Quadrilateral - QUAD4 case 94: // Thin Shell Linear Quadrilateral - QUAD4
anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
aRec.node_labels[1],
aRec.node_labels[2],
aRec.node_labels[3],
aLabel);
break;
case 45: // Plane Stress Quadratic Quadrilateral - QUAD8 case 45: // Plane Stress Quadratic Quadrilateral - QUAD8
case 95: // Thin Shell Quadratic Quadrilateral - QUAD8 case 95: // Thin Shell Quadratic Quadrilateral - QUAD8
@ -95,15 +119,18 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
aRec.node_labels[1], aRec.node_labels[1],
aRec.node_labels[2], aRec.node_labels[2],
aRec.node_labels[3], aRec.node_labels[3],
aRec.node_labels[4],
aRec.node_labels[5],
aRec.node_labels[6],
aRec.node_labels[7],
aLabel); aLabel);
break; break;
} }
}else if(IsVolume(aRec.fe_descriptor_id)){ }
else if(IsVolume(aRec.fe_descriptor_id)){
switch(aRec.fe_descriptor_id){ switch(aRec.fe_descriptor_id){
case 111: // Solid Linear Tetrahedron - TET4 case 111: // Solid Linear Tetrahedron - TET4
case 118: // Solid Quadratic Tetrahedron - TET10
anElement = myMesh->AddVolumeWithID(aRec.node_labels[0], anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
aRec.node_labels[2], aRec.node_labels[2],
aRec.node_labels[1], aRec.node_labels[1],
@ -111,8 +138,21 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
aLabel); aLabel);
break; break;
case 112: // Solid Linear Prism - PRISM6 case 118: // Solid Quadratic Tetrahedron - TET10
anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
aRec.node_labels[2],
aRec.node_labels[1],
aRec.node_labels[3],
aRec.node_labels[6],
aRec.node_labels[5],
aRec.node_labels[4],
aRec.node_labels[7],
aRec.node_labels[9],
aRec.node_labels[8],
aLabel);
break;
case 112: // Solid Linear Prism - PRISM6
anElement = myMesh->AddVolumeWithID(aRec.node_labels[0], anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
aRec.node_labels[2], aRec.node_labels[2],
aRec.node_labels[1], aRec.node_labels[1],
@ -123,13 +163,21 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
break; break;
case 113: // Solid Quadratic Prism - PRISM15 case 113: // Solid Quadratic Prism - PRISM15
anElement = myMesh->AddVolumeWithID(aRec.node_labels[0], anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
aRec.node_labels[4],
aRec.node_labels[2], aRec.node_labels[2],
aRec.node_labels[9], aRec.node_labels[1],
aRec.node_labels[13], aRec.node_labels[3],
aRec.node_labels[5],
aRec.node_labels[4],
aRec.node_labels[8],
aRec.node_labels[7],
aRec.node_labels[6],
aRec.node_labels[11], aRec.node_labels[11],
aRec.node_labels[10],
aRec.node_labels[9],
aRec.node_labels[12],
aRec.node_labels[14],
aRec.node_labels[13],
aLabel); aLabel);
break; break;
@ -146,26 +194,57 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
break; break;
case 116: // Solid Quadratic Brick - HEX20 case 116: // Solid Quadratic Brick - HEX20
anElement = myMesh->AddVolumeWithID(aRec.node_labels[0], anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
aRec.node_labels[6], aRec.node_labels[3],
aRec.node_labels[4],
aRec.node_labels[2], aRec.node_labels[2],
aRec.node_labels[12], aRec.node_labels[1],
aRec.node_labels[18], aRec.node_labels[4],
aRec.node_labels[16], aRec.node_labels[7],
aRec.node_labels[6],
aRec.node_labels[5],
aRec.node_labels[11],
aRec.node_labels[10],
aRec.node_labels[9],
aRec.node_labels[8],
aRec.node_labels[15],
aRec.node_labels[14], aRec.node_labels[14],
aRec.node_labels[13],
aRec.node_labels[12],
aRec.node_labels[16],
aRec.node_labels[19],
aRec.node_labels[18],
aRec.node_labels[17],
aLabel); aLabel);
break; break;
case 114: // pyramid of 13 nodes (quadratic) - PIRA13
anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
aRec.node_labels[3],
aRec.node_labels[2],
aRec.node_labels[1],
aRec.node_labels[4],
aRec.node_labels[8],
aRec.node_labels[7],
aRec.node_labels[6],
aRec.node_labels[5],
aRec.node_labels[9],
aRec.node_labels[12],
aRec.node_labels[11],
aRec.node_labels[10],
aLabel);
break;
} }
} }
if(!anElement) if(!anElement)
MESSAGE("DriverUNV_R_SMDS_Mesh::Perform - can not add element with ID = "<<aLabel<<" and type = "<<aRec.fe_descriptor_id); MESSAGE("DriverUNV_R_SMDS_Mesh::Perform - can not add element with ID = "<<aLabel<<" and type = "<<aRec.fe_descriptor_id);
} }
} }
}catch(const std::exception& exc){ }
catch(const std::exception& exc){
INFOS("Follow exception was cought:\n\t"<<exc.what()); INFOS("Follow exception was cought:\n\t"<<exc.what());
}catch(...){ }
catch(...){
INFOS("Unknown exception was cought !!!"); INFOS("Unknown exception was cought !!!");
} }
return aResult; return aResult;

View File

@ -91,7 +91,10 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform()
const SMDS_MeshElement* aNode = aNodesIter->next(); const SMDS_MeshElement* aNode = aNodesIter->next();
aRec.node_labels.push_back(aNode->GetID()); aRec.node_labels.push_back(aNode->GetID());
} }
aRec.fe_descriptor_id = 11; if(aNbNodes==2)
aRec.fe_descriptor_id = 11;
else
aRec.fe_descriptor_id = 21;
aDataSet2412.insert(TDataSet::value_type(aLabel,aRec)); aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
} }
MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size()); MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
@ -118,6 +121,12 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform()
case 4: case 4:
aRec.fe_descriptor_id = 44; aRec.fe_descriptor_id = 44;
break; break;
case 6:
aRec.fe_descriptor_id = 42;
break;
case 8:
aRec.fe_descriptor_id = 45;
break;
default: default:
continue; continue;
} }
@ -160,6 +169,30 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform()
anId = 115; anId = 115;
break; break;
} }
case 10: {
static int anIds[] = {0,2,1,3,6,5,4,7,9,8};
aConn = anIds;
anId = 118;
break;
}
case 13: {
static int anIds[] = {0,3,2,1,4,8,7,6,5,9,12,11,10};
aConn = anIds;
anId = 114;
break;
}
case 15: {
static int anIds[] = {0,2,1,3,5,4,8,7,6,11,10,9,12,14,13};
aConn = anIds;
anId = 113;
break;
}
case 20: {
static int anIds[] = {0,3,2,1,4,7,6,5,11,10,9,8,15,14,13,12,16,19,18,17};
aConn = anIds;
anId = 116;
break;
}
default: default:
continue; continue;
} }
@ -177,9 +210,11 @@ Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform()
} }
UNV2412::Write(out_stream,aDataSet2412); UNV2412::Write(out_stream,aDataSet2412);
} }
}catch(const std::exception& exc){ }
catch(const std::exception& exc){
INFOS("Follow exception was cought:\n\t"<<exc.what()); INFOS("Follow exception was cought:\n\t"<<exc.what());
}catch(...){ }
catch(...){
INFOS("Unknown exception was cought !!!"); INFOS("Unknown exception was cought !!!");
} }
return aResult; return aResult;

View File

@ -142,8 +142,8 @@ void UNV2412::Write(std::ofstream& out_stream, const TDataSet& theDataSet)
bool UNV2412::IsBeam(int theFeDescriptorId){ bool UNV2412::IsBeam(int theFeDescriptorId){
switch (theFeDescriptorId){ switch (theFeDescriptorId){
case 11: case 11: // edge with 2 nodes
case 21: case 21: // edge with 3 nodes (quadratic)
case 22: case 22:
case 24: case 24:
case 25: case 25:
@ -197,6 +197,8 @@ bool UNV2412::IsVolume(int theFeDescriptorId){
case 116: // Solid Quadratic Brick - HEX20 case 116: // Solid Quadratic Brick - HEX20
case 117: // Solid Cubic Brick case 117: // Solid Cubic Brick
case 114: // pyramid of 13 nodes (quadratic)
return true; return true;
} }
return false; return false;

View File

@ -33,7 +33,7 @@ VPATH=.:@srcdir@
SUBDIRS = \ SUBDIRS = \
SMDS SMESHDS Controls Driver DriverMED DriverDAT DriverUNV DriverSTL \ SMDS SMESHDS Controls Driver DriverMED DriverDAT DriverUNV DriverSTL \
SMESH SMESH_I OBJECT SMESHFiltersSelection SMESHGUI SMESH_SWIG \ SMESH SMESH_I SMESHClient OBJECT SMESHFiltersSelection SMESHGUI SMESH_SWIG \
MEFISTO2 StdMeshers StdMeshers_I StdMeshersGUI MEFISTO2 StdMeshers StdMeshers_I StdMeshersGUI
@MODULE@ @MODULE@

View File

@ -31,28 +31,105 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl
@COMMENCE@ @COMMENCE@
EXPORT_HEADERS = SMESH_Actor.h SMESH_Object.h SMESH_ObjectDef.h SMESH_ActorUtils.h EXPORT_HEADERS = \
SMESH_Actor.h \
SMESH_Object.h \
SMESH_ObjectDef.h \
SMESH_ActorUtils.h
# Libraries targets # Libraries targets
LIB = libSMESHObject.la LIB = libSMESHObject.la
LIB_SRC = SMESH_Object.cxx SMESH_DeviceActor.cxx SMESH_Actor.cxx \ LIB_SRC = \
SMESH_ExtractGeometry.cxx SMESH_ActorUtils.cxx SMESH_Object.cxx \
SMESH_DeviceActor.cxx \
SMESH_Actor.cxx \
SMESH_ExtractGeometry.cxx \
SMESH_ActorUtils.cxx
LIB_CLIENT_IDL = SALOME_Exception.idl \ LIB_CLIENT_IDL = SALOME_Exception.idl \
SALOME_GenericObj.idl \ SALOME_GenericObj.idl \
SMESH_Mesh.idl \ SMESH_Mesh.idl \
SMESH_Group.idl SMESH_Group.idl \
SALOMEDS.idl \
SMESH_Gen.idl \
GEOM_Gen.idl \
SMESH_Hypothesis.idl
# Executables targets # Executables targets
BIN = BIN =
BIN_SRC = BIN_SRC =
CPPFLAGS+=$(OCC_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \ CPPFLAGS+= \
$(BOOST_CPPFLAGS) $(QT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
LDFLAGS+=$(OCC_KERNEL_LIBS) $(VTK_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome -lSMDS \ -I${GUI_ROOT_DIR}/include/salome \
-lSalomeApp -lSalomeObject -lSMESHControls $(OCC_INCLUDES) \
$(VTK_INCLUDES) \
$(BOOST_CPPFLAGS) \
$(QT_INCLUDES)
LDFLAGS+= \
-L${KERNEL_ROOT_DIR}/lib/salome \
-L${GUI_ROOT_DIR}/lib/salome \
$(OCC_KERNEL_LIBS) \
$(VTK_LIBS) \
-lSMDS \
-lSMESHClient \
-lSalomeApp \
-lSalomeObject \
-lSMESHControls
LDFLAGSFORBIN += \
-L${GEOM_ROOT_DIR}/lib/salome \
-L${MED_ROOT_DIR}/lib/salome \
$(LDFLAGS) \
-lqtx \
-lsuit \
-lstd \
-lCAM \
-lLightApp \
-lObjBrowser \
-lSalomePrs \
-lSalomeDS \
-lTOOLSDS \
-lSalomeDSImpl \
-lSalomeDSClient \
-lSalomeHDFPersist \
-lSalomeResourcesManager \
-lSalomeLifeCycleCORBA \
-lSalomeNotification \
-lSalomeContainer \
-lSalomeCatalog \
-lSalomeSession \
-lRegistry \
-lNMTTools \
-lNMTDS \
-lmed_V2_1 \
-lMEDWrapper \
-lMEDWrapperBase \
-lMEDWrapper_V2_1 \
-lMEDWrapper_V2_2 \
-lPlot2d \
-lGLViewer \
-lOCCViewer \
-lVTKViewer \
-lSVTK \
-lSOCC \
-lSPlot2d \
-lSUPERVGraph \
-lPyInterp \
-lPythonConsole \
-lLogWindow \
-lLightApp \
-lSalomeContainer \
-lToolsGUI \
-lSalomeNS \
-lEvent \
-lSalomeGenericObj \
-lSALOMELocalTrace \
-lwith_loggerTraceCollector \
-lSALOMEBasics \
-lOpUtil
@CONCLUDE@ @CONCLUDE@

View File

@ -150,6 +150,8 @@ SMESH_ActorDef::SMESH_ActorDef()
aFilter->RegisterCellsWithType(VTK_TRIANGLE); aFilter->RegisterCellsWithType(VTK_TRIANGLE);
aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_POLYGON);
aFilter->RegisterCellsWithType(VTK_QUAD); aFilter->RegisterCellsWithType(VTK_QUAD);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
my3DActor = SMESH_DeviceActor::New(); my3DActor = SMESH_DeviceActor::New();
my3DActor->SetUserMatrix(aMatrix); my3DActor->SetUserMatrix(aMatrix);
@ -164,6 +166,8 @@ SMESH_ActorDef::SMESH_ActorDef()
aFilter->RegisterCellsWithType(VTK_HEXAHEDRON); aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
aFilter->RegisterCellsWithType(VTK_WEDGE); aFilter->RegisterCellsWithType(VTK_WEDGE);
aFilter->RegisterCellsWithType(VTK_PYRAMID); aFilter->RegisterCellsWithType(VTK_PYRAMID);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
//Definition 1D divice of the actor //Definition 1D divice of the actor
@ -185,6 +189,7 @@ SMESH_ActorDef::SMESH_ActorDef()
aFilter = my1DActor->GetExtractUnstructuredGrid(); aFilter = my1DActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_LINE); aFilter->RegisterCellsWithType(VTK_LINE);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
my1DProp = vtkProperty::New(); my1DProp = vtkProperty::New();
my1DProp->DeepCopy(myEdgeProp); my1DProp->DeepCopy(myEdgeProp);
@ -210,6 +215,7 @@ SMESH_ActorDef::SMESH_ActorDef()
aFilter = my1DExtActor->GetExtractUnstructuredGrid(); aFilter = my1DExtActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_LINE); aFilter->RegisterCellsWithType(VTK_LINE);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
//Definition 0D divice of the actor //Definition 0D divice of the actor
@ -263,8 +269,6 @@ SMESH_ActorDef::SMESH_ActorDef()
myHighlitableActor->PickableOff(); myHighlitableActor->PickableOff();
myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe); myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 0.75 ) );
myName = ""; myName = "";
myIO = NULL; myIO = NULL;
@ -748,13 +752,15 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
my2DActor->GetPolygonOffsetParameters(aFactor,aUnits); my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75); my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
//SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
SetIsShrunkable(true);
SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
if( !mgr ) if( !mgr )
return false; return false;
//SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
SetIsShrunkable(true);
SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 0.75 ) );
int aMode = mgr->integerValue( "SMESH", "display_mode" ); int aMode = mgr->integerValue( "SMESH", "display_mode" );
SetRepresentation(-1); SetRepresentation(-1);
@ -835,6 +841,8 @@ bool SMESH_ActorDef::IsInfinitive(){
void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){ void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
if ( myIsShrinkable == theShrunkable )
return;
myIsShrinkable = theShrunkable; myIsShrinkable = theShrunkable;
Modified(); Modified();
} }
@ -1015,6 +1023,7 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
if(myEntityMode & eEdges){ if(myEntityMode & eEdges){
if (MYDEBUG) MESSAGE("EDGES"); if (MYDEBUG) MESSAGE("EDGES");
aFilter->RegisterCellsWithType(VTK_LINE); aFilter->RegisterCellsWithType(VTK_LINE);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
} }
if(myEntityMode & eFaces){ if(myEntityMode & eFaces){
@ -1022,6 +1031,8 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
aFilter->RegisterCellsWithType(VTK_TRIANGLE); aFilter->RegisterCellsWithType(VTK_TRIANGLE);
aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_POLYGON);
aFilter->RegisterCellsWithType(VTK_QUAD); aFilter->RegisterCellsWithType(VTK_QUAD);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
} }
if(myEntityMode & eVolumes){ if(myEntityMode & eVolumes){
@ -1031,6 +1042,8 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
aFilter->RegisterCellsWithType(VTK_HEXAHEDRON); aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
aFilter->RegisterCellsWithType(VTK_WEDGE); aFilter->RegisterCellsWithType(VTK_WEDGE);
aFilter->RegisterCellsWithType(VTK_PYRAMID); aFilter->RegisterCellsWithType(VTK_PYRAMID);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
} }
aFilter->Update(); aFilter->Update();
@ -1135,6 +1148,8 @@ void SMESH_ActorDef::SetRepresentation(int theMode){
void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){ void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
if ( myIsPointsVisible == theIsPointsVisible )
return;
myIsPointsVisible = theIsPointsVisible; myIsPointsVisible = theIsPointsVisible;
SetRepresentation(GetRepresentation()); SetRepresentation(GetRepresentation());
} }
@ -1175,12 +1190,16 @@ void SMESH_ActorDef::UpdateHighlight(){
void SMESH_ActorDef::highlight(bool theHighlight){ void SMESH_ActorDef::highlight(bool theHighlight){
if ( myIsHighlighted == theHighlight )
return;
myIsHighlighted = theHighlight; myIsHighlighted = theHighlight;
UpdateHighlight(); UpdateHighlight();
} }
void SMESH_ActorDef::SetPreSelected(bool thePreselect){ void SMESH_ActorDef::SetPreSelected(bool thePreselect){
if ( myIsPreselected == thePreselect )
return;
myIsPreselected = thePreselect; myIsPreselected = thePreselect;
UpdateHighlight(); UpdateHighlight();
} }

View File

@ -547,14 +547,22 @@ void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){
switch(theMode){ switch(theMode){
case ePoint: case ePoint:
myGeomFilter->SetInside(true); myGeomFilter->SetInside(true);
myGeomFilter->SetWireframeMode(false);
GetProperty()->SetRepresentation(0); GetProperty()->SetRepresentation(0);
break; break;
case eWireframe:
myGeomFilter->SetInside(false);
myGeomFilter->SetWireframeMode(true);
GetProperty()->SetRepresentation(theMode);
break;
case eInsideframe: case eInsideframe:
myGeomFilter->SetInside(true); myGeomFilter->SetInside(true);
myGeomFilter->SetWireframeMode(true);
GetProperty()->SetRepresentation(1); GetProperty()->SetRepresentation(1);
break; break;
default : case eSurface:
myGeomFilter->SetInside(false); myGeomFilter->SetInside(false);
myGeomFilter->SetWireframeMode(false);
GetProperty()->SetRepresentation(theMode); GetProperty()->SetRepresentation(theMode);
} }
myRepresentation = theMode; myRepresentation = theMode;
@ -646,6 +654,8 @@ void SMESH_DeviceActor::SetShrinkFactor(float theValue){
void SMESH_DeviceActor::SetHighlited(bool theIsHighlited){ void SMESH_DeviceActor::SetHighlited(bool theIsHighlited){
if ( myIsHighlited == theIsHighlited )
return;
myIsHighlited = theIsHighlited; myIsHighlited = theIsHighlited;
Modified(); Modified();
} }

View File

@ -31,8 +31,10 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "SMESH_ControlsDef.hxx" #include "SMESH_ControlsDef.hxx"
#include <VTKViewer_ExtractUnstructuredGrid.h> #include "SalomeApp_Application.h"
#include "VTKViewer_ExtractUnstructuredGrid.h"
#include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SALOME_Exception) #include CORBA_SERVER_HEADER(SALOME_Exception)
#include <vtkCell.h> #include <vtkCell.h>
@ -69,271 +71,6 @@ static int MYDEBUGWITHFILES = 0;
#endif #endif
namespace{
inline const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, int theId){
if(const SMDS_MeshNode* anElem = theMesh->FindNode(theId)) return anElem;
EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
}
inline const SMDS_MeshElement* FindElement(const SMDS_Mesh* theMesh, int theId){
if(const SMDS_MeshElement* anElem = theMesh->FindElement(theId)) return anElem;
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot find a SMDS_MeshElement for ID = "<<theId);
}
inline void AddNodesWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::double_array& aCoords = theSeq[theId].coords;
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(3*aNbElems != aCoords.length())
EXCEPTION(runtime_error,"AddNodesWithID - 3*aNbElems != aCoords.length()");
for(CORBA::Long aCoordId = 0; anElemId < aNbElems; anElemId++, aCoordId+=3){
SMDS_MeshElement* anElem = theMesh->AddNodeWithID(aCoords[aCoordId],
aCoords[aCoordId+1],
aCoords[aCoordId+2],
anIndexes[anElemId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddNodeWithID for ID = "<<anElemId);
}
}
inline void AddEdgesWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(3*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 3*aNbElems != aCoords.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=3){
SMDS_MeshElement* anElem = theMesh->AddEdgeWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddEdgeWithID for ID = "<<anElemId);
}
}
inline void AddTriasWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(4*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 4*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=4){
SMDS_MeshElement* anElem = theMesh->AddFaceWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
}
}
inline void AddQuadsWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(5*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 4*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=5){
SMDS_MeshElement* anElem = theMesh->AddFaceWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId+4],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
}
}
inline void AddPolygonsWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
int aFaceId = anIndexes[anIndexId++];
int aNbNodes = anIndexes[anIndexId++];
std::vector<int> nodes_ids (aNbNodes);
for (int i = 0; i < aNbNodes; i++) {
nodes_ids[i] = anIndexes[anIndexId++];
}
SMDS_MeshElement* anElem = theMesh->AddPolygonalFaceWithID(nodes_ids, aFaceId);
if (!anElem)
EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolygonalFaceWithID for ID = "
<< anElemId);
}
}
inline void AddTetrasWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(5*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 5*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=5){
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId+4],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
inline void AddPiramidsWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(6*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 6*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=6){
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId+4],
anIndexes[anIndexId+5],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
inline void AddPrismsWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(7*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 7*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=7){
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId+4],
anIndexes[anIndexId+5],
anIndexes[anIndexId+6],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
inline void AddHexasWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(9*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 9*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=9){
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId+4],
anIndexes[anIndexId+5],
anIndexes[anIndexId+6],
anIndexes[anIndexId+7],
anIndexes[anIndexId+8],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
inline void AddPolyhedronsWithID (SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
int aFaceId = anIndexes[anIndexId++];
int aNbNodes = anIndexes[anIndexId++];
std::vector<int> nodes_ids (aNbNodes);
for (int i = 0; i < aNbNodes; i++) {
nodes_ids[i] = anIndexes[anIndexId++];
}
int aNbFaces = anIndexes[anIndexId++];
std::vector<int> quantities (aNbFaces);
for (int i = 0; i < aNbFaces; i++) {
quantities[i] = anIndexes[anIndexId++];
}
SMDS_MeshElement* anElem =
theMesh->AddPolyhedralVolumeWithID(nodes_ids, quantities, aFaceId);
if (!anElem)
EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolyhedralVolumeWithID for ID = "
<< anElemId);
}
}
inline void ChangePolyhedronNodes (SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long iind = 0, aNbElems = theSeq[theId].number;
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++)
{
// find element
const SMDS_MeshElement* elem = FindElement(theMesh, anIndexes[iind++]);
// nb nodes
int nbNodes = anIndexes[iind++];
// nodes
std::vector<const SMDS_MeshNode*> aNodes (nbNodes);
for (int iNode = 0; iNode < nbNodes; iNode++) {
aNodes[iNode] = FindNode(theMesh, anIndexes[iind++]);
}
// nb faces
int nbFaces = anIndexes[iind++];
// quantities
std::vector<int> quantities (nbFaces);
for (int iFace = 0; iFace < nbFaces; iFace++) {
quantities[iFace] = anIndexes[iind++];
}
// change
theMesh->ChangePolyhedronNodes(elem, aNodes, quantities);
}
}
}
/* /*
Class : SMESH_VisualObjDef Class : SMESH_VisualObjDef
Description : Base class for all mesh objects to be visuilised Description : Base class for all mesh objects to be visuilised
@ -350,12 +87,16 @@ static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
switch( theType ) switch( theType )
{ {
case SMDSAbs_Edge: case SMDSAbs_Edge:
return theNbNodes == 2 ? VTK_LINE : VTK_EMPTY_CELL; if( theNbNodes == 2 ) return VTK_LINE;
else if ( theNbNodes == 3 ) return VTK_QUADRATIC_EDGE;
else return VTK_EMPTY_CELL;
case SMDSAbs_Face : case SMDSAbs_Face :
if (thePoly && theNbNodes>2 ) return VTK_POLYGON; if (thePoly && theNbNodes>2 ) return VTK_POLYGON;
else if ( theNbNodes == 3 ) return VTK_TRIANGLE; else if ( theNbNodes == 3 ) return VTK_TRIANGLE;
else if ( theNbNodes == 4 ) return VTK_QUAD; else if ( theNbNodes == 4 ) return VTK_QUAD;
else if ( theNbNodes == 6 ) return VTK_QUADRATIC_TRIANGLE;
else if ( theNbNodes == 8 ) return VTK_QUADRATIC_QUAD;
else return VTK_EMPTY_CELL; else return VTK_EMPTY_CELL;
case SMDSAbs_Volume: case SMDSAbs_Volume:
@ -364,6 +105,15 @@ static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
else if ( theNbNodes == 5 ) return VTK_PYRAMID; else if ( theNbNodes == 5 ) return VTK_PYRAMID;
else if ( theNbNodes == 6 ) return VTK_WEDGE; else if ( theNbNodes == 6 ) return VTK_WEDGE;
else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON; else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON;
else if ( theNbNodes == 10 ) {
return VTK_QUADRATIC_TETRA;
}
else if ( theNbNodes == 20 ) {
return VTK_QUADRATIC_HEXAHEDRON;
}
else if ( theNbNodes==13 || theNbNodes==15 ) {
return VTK_CONVEX_POINT_SET;
}
else return VTK_EMPTY_CELL; else return VTK_EMPTY_CELL;
default: return VTK_EMPTY_CELL; default: return VTK_EMPTY_CELL;
@ -485,42 +235,6 @@ void SMESH_VisualObjDef::buildNodePrs()
aPoints->Delete(); aPoints->Delete();
myGrid->SetCells( 0, 0, 0 ); myGrid->SetCells( 0, 0, 0 );
// Create cells
/*
int nbPoints = aPoints->GetNumberOfPoints();
vtkIdList *anIdList = vtkIdList::New();
anIdList->SetNumberOfIds( 1 );
vtkCellArray *aCells = vtkCellArray::New();
aCells->Allocate( 2 * nbPoints, 0 );
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
aCellTypesArray->SetNumberOfComponents( 1 );
aCellTypesArray->Allocate( nbPoints );
for( vtkIdType aCellId = 0; aCellId < nbPoints; aCellId++ )
{
anIdList->SetId( 0, aCellId );
aCells->InsertNextCell( anIdList );
aCellTypesArray->InsertNextValue( VTK_VERTEX );
}
vtkIntArray* aCellLocationsArray = vtkIntArray::New();
aCellLocationsArray->SetNumberOfComponents( 1 );
aCellLocationsArray->SetNumberOfTuples( nbPoints );
aCells->InitTraversal();
for( vtkIdType i = 0, *pts, npts; aCells->GetNextCell( npts, pts ); i++ )
aCellLocationsArray->SetValue( i, aCells->GetTraversalLocation( npts ) );
myGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells );
aCellLocationsArray->Delete();
aCellTypesArray->Delete();
aCells->Delete();
anIdList->Delete();
*/
} }
//================================================================================= //=================================================================================
@ -651,11 +365,34 @@ void SMESH_VisualObjDef::buildElemPrs()
static int anIds[] = {0,1,2,3,4,5}; static int anIds[] = {0,1,2,3,4,5};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else if (aNbNodes == 8) { }
else if (aNbNodes == 8) {
static int anIds[] = {0,3,2,1,4,7,6,5}; static int anIds[] = {0,3,2,1,4,7,6,5};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]); for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else { }
else if (aNbNodes == 10) {
static int anIds[] = {0,2,1,3,6,5,4,7,9,8};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
else if (aNbNodes == 13) {
static int anIds[] = {0,3,2,1,4,8,7,6,5,9,12,11,10};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
else if (aNbNodes == 15) {
static int anIds[] = {0,2,1,3,5,4,8,7,6,11,10,9,12,14,13};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
//for (int k = 0; k < aNbNodes; k++) {
// int nn = aConnectivities[k];
// const SMDS_MeshNode* N = static_cast<const SMDS_MeshNode*> (aConnect[nn]);
// cout<<"k="<<k<<" N("<<N->X()<<","<<N->Y()<<","<<N->Z()<<")"<<endl;
//}
}
else if (aNbNodes == 20) {
static int anIds[] = {0,3,2,1,4,7,6,5,11,10,9,8,15,14,13,12,16,19,18,17};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
}
else {
} }
if (aConnectivities.size() > 0) { if (aConnectivities.size() > 0) {
@ -748,14 +485,11 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
// function : SMESH_MeshObj // function : SMESH_MeshObj
// purpose : Constructor // purpose : Constructor
//================================================================================= //=================================================================================
SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh) SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh):
myClient(SalomeApp_Application::orb(),theMesh)
{ {
if ( MYDEBUG ) if ( MYDEBUG )
MESSAGE("SMESH_MeshObj - theMesh->_is_nil() = "<<theMesh->_is_nil()); MESSAGE("SMESH_MeshObj - this = "<<this<<"; theMesh->_is_nil() = "<<theMesh->_is_nil());
myMeshServer = SMESH::SMESH_Mesh::_duplicate( theMesh );
myMeshServer->Register();
myMesh = new SMDS_Mesh();
} }
//================================================================================= //=================================================================================
@ -764,8 +498,8 @@ SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh)
//================================================================================= //=================================================================================
SMESH_MeshObj::~SMESH_MeshObj() SMESH_MeshObj::~SMESH_MeshObj()
{ {
myMeshServer->Destroy(); if ( MYDEBUG )
delete myMesh; MESSAGE("SMESH_MeshObj - this = "<<this<<"\n");
} }
//================================================================================= //=================================================================================
@ -775,110 +509,8 @@ SMESH_MeshObj::~SMESH_MeshObj()
void SMESH_MeshObj::Update( int theIsClear ) void SMESH_MeshObj::Update( int theIsClear )
{ {
// Update SMDS_Mesh on client part // Update SMDS_Mesh on client part
if ( myClient.Update(theIsClear) )
try buildPrs(); // Fill unstructured grid
{
SMESH::log_array_var aSeq = myMeshServer->GetLog( theIsClear );
CORBA::Long aLength = aSeq->length();
if( MYDEBUG ) MESSAGE( "Update: length of the script is "<<aLength );
if( !aLength )
return;
for ( CORBA::Long anId = 0; anId < aLength; anId++)
{
const SMESH::double_array& aCoords = aSeq[anId].coords;
const SMESH::long_array& anIndexes = aSeq[anId].indexes;
CORBA::Long anElemId = 0, aNbElems = aSeq[anId].number;
CORBA::Long aCommand = aSeq[anId].commandType;
switch(aCommand)
{
case SMESH::ADD_NODE : AddNodesWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_EDGE : AddEdgesWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_TRIANGLE : AddTriasWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_POLYGON : AddPolygonsWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_PYRAMID : AddPiramidsWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_POLYHEDRON : AddPolyhedronsWithID( myMesh, aSeq, anId ); break;
case SMESH::REMOVE_NODE:
for( ; anElemId < aNbElems; anElemId++ )
myMesh->RemoveNode( FindNode( myMesh, anIndexes[anElemId] ) );
break;
case SMESH::REMOVE_ELEMENT:
for( ; anElemId < aNbElems; anElemId++ )
myMesh->RemoveElement( FindElement( myMesh, anIndexes[anElemId] ) );
break;
case SMESH::MOVE_NODE:
for(CORBA::Long aCoordId=0; anElemId < aNbElems; anElemId++, aCoordId+=3)
{
SMDS_MeshNode* node =
const_cast<SMDS_MeshNode*>( FindNode( myMesh, anIndexes[anElemId] ));
node->setXYZ( aCoords[aCoordId], aCoords[aCoordId+1], aCoords[aCoordId+2] );
}
break;
case SMESH::CHANGE_ELEMENT_NODES:
for ( CORBA::Long i = 0; anElemId < aNbElems; anElemId++ )
{
// find element
const SMDS_MeshElement* elem = FindElement( myMesh, anIndexes[i++] );
// nb nodes
int nbNodes = anIndexes[i++];
// nodes
//ASSERT( nbNodes < 9 );
const SMDS_MeshNode* aNodes[ nbNodes ];
for ( int iNode = 0; iNode < nbNodes; iNode++ )
aNodes[ iNode ] = FindNode( myMesh, anIndexes[i++] );
// change
myMesh->ChangeElementNodes( elem, aNodes, nbNodes );
}
break;
case SMESH::CHANGE_POLYHEDRON_NODES:
ChangePolyhedronNodes(myMesh, aSeq, anId);
break;
case SMESH::RENUMBER:
for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3)
{
myMesh->Renumber( anIndexes[i], anIndexes[i+1], anIndexes[i+2] );
}
break;
default:;
}
}
}
catch ( SALOME::SALOME_Exception& exc )
{
INFOS("Following exception was cought:\n\t"<<exc.details.text);
}
catch( const std::exception& exc)
{
INFOS("Following exception was cought:\n\t"<<exc.what());
}
catch(...)
{
INFOS("Unknown exception was cought !!!");
}
if ( MYDEBUG )
{
MESSAGE("Update - myMesh->NbNodes() = "<<myMesh->NbNodes());
MESSAGE("Update - myMesh->NbEdges() = "<<myMesh->NbEdges());
MESSAGE("Update - myMesh->NbFaces() = "<<myMesh->NbFaces());
MESSAGE("Update - myMesh->NbVolumes() = "<<myMesh->NbVolumes());
}
// Fill unstructured grid
buildPrs();
} }
//================================================================================= //=================================================================================
@ -887,7 +519,7 @@ void SMESH_MeshObj::Update( int theIsClear )
//================================================================================= //=================================================================================
int SMESH_MeshObj::GetElemDimension( const int theObjId ) int SMESH_MeshObj::GetElemDimension( const int theObjId )
{ {
const SMDS_MeshElement* anElem = myMesh->FindElement( theObjId ); const SMDS_MeshElement* anElem = myClient->FindElement( theObjId );
if ( anElem == 0 ) if ( anElem == 0 )
return 0; return 0;
@ -911,22 +543,22 @@ int SMESH_MeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
{ {
case SMDSAbs_Node: case SMDSAbs_Node:
{ {
return myMesh->NbNodes(); return myClient->NbNodes();
} }
break; break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
{ {
return myMesh->NbEdges(); return myClient->NbEdges();
} }
break; break;
case SMDSAbs_Face: case SMDSAbs_Face:
{ {
return myMesh->NbFaces(); return myClient->NbFaces();
} }
break; break;
case SMDSAbs_Volume: case SMDSAbs_Volume:
{ {
return myMesh->NbVolumes(); return myClient->NbVolumes();
} }
break; break;
default: default:
@ -943,25 +575,25 @@ int SMESH_MeshObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList&
{ {
case SMDSAbs_Node: case SMDSAbs_Node:
{ {
SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator(); SMDS_NodeIteratorPtr anIter = myClient->nodesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
{ {
SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); SMDS_EdgeIteratorPtr anIter = myClient->edgesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
case SMDSAbs_Face: case SMDSAbs_Face:
{ {
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); SMDS_FaceIteratorPtr anIter = myClient->facesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
case SMDSAbs_Volume: case SMDSAbs_Volume:
{ {
SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator(); SMDS_VolumeIteratorPtr anIter = myClient->volumesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() ); while ( anIter->more() ) theObjs.push_back( anIter->next() );
} }
break; break;
@ -987,7 +619,7 @@ void SMESH_MeshObj::UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor
//================================================================================= //=================================================================================
bool SMESH_MeshObj::IsNodePrs() const bool SMESH_MeshObj::IsNodePrs() const
{ {
return myMesh->NbEdges() == 0 &&myMesh->NbFaces() == 0 &&myMesh->NbVolumes() == 0 ; return myClient->NbEdges() == 0 &&myClient->NbFaces() == 0 && myClient->NbVolumes() == 0 ;
} }
@ -1256,15 +888,3 @@ bool SMESH_subMeshObj::IsNodePrs() const
{ {
return mySubMeshServer->GetNumberOfElements() == 0; return mySubMeshServer->GetNumberOfElements() == 0;
} }

View File

@ -29,6 +29,10 @@
#ifndef SMESH_OBJECTDEF_H #ifndef SMESH_OBJECTDEF_H
#define SMESH_OBJECTDEF_H #define SMESH_OBJECTDEF_H
#include "SMESH_Controls.hxx"
#include "SMESH_Object.h"
#include "SMESH_Client.hxx"
// IDL Headers // IDL Headers
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
@ -37,9 +41,6 @@
#include <map> #include <map>
#include <list> #include <list>
#include "SMESH_Controls.hxx"
#include "SMESH_Object.h"
class vtkPoints; class vtkPoints;
class SALOME_ExtractUnstructuredGrid; class SALOME_ExtractUnstructuredGrid;
@ -121,13 +122,11 @@ public:
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ); virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); } SMESH::SMESH_Mesh_ptr GetMeshServer() { return myClient.GetMeshServer(); }
SMDS_Mesh* GetMesh() const { return myMesh; } SMDS_Mesh* GetMesh() const { return myClient.GetMesh(); }
protected: protected:
SMESH_Client myClient;
SMESH::SMESH_Mesh_var myMeshServer;
SMDS_Mesh* myMesh;
}; };

View File

@ -59,21 +59,10 @@ LIB_SRC = \
SMDS_FaceOfEdges.cxx \ SMDS_FaceOfEdges.cxx \
SMDS_FaceOfNodes.cxx \ SMDS_FaceOfNodes.cxx \
SMDS_PolygonalFaceOfNodes.cxx \ SMDS_PolygonalFaceOfNodes.cxx \
SMDS_VolumeTool.cxx SMDS_VolumeTool.cxx \
# SMDS_Tria3OfNodes.cxx \ SMDS_QuadraticEdge.cxx \
# SMDS_HexahedronOfNodes.cxx SMDS_QuadraticFaceOfNodes.cxx \
SMDS_QuadraticVolumeOfNodes.cxx
#SMDSControl_BoundaryEdges.cxx \
#SMDSControl_BoundaryFaces.cxx \
#SMDSControl.cxx \
#SMDSControl_MeshBoundary.cxx \
#SMDSEdit_Transform.cxx \
#SMDS_MeshNodeIDFactory.cxx \
#SMDS_MeshPrism.cxx \
#SMDS_MeshPyramid.cxx \
#SMDS_MeshQuadrangle.cxx \
#SMDS_MeshTetrahedron.cxx \
#SMDS_MeshTriangle.cxx \
LIB_CLIENT_IDL = LIB_CLIENT_IDL =
@ -113,21 +102,11 @@ EXPORT_HEADERS= \
SMDS_FaceOfEdges.hxx \ SMDS_FaceOfEdges.hxx \
SMDS_FaceOfNodes.hxx \ SMDS_FaceOfNodes.hxx \
SMDS_PolygonalFaceOfNodes.hxx \ SMDS_PolygonalFaceOfNodes.hxx \
SMDS_VolumeTool.hxx SMDS_VolumeTool.hxx \
# SMDS_Tria3OfNodes.hxx \ SMDS_QuadraticEdge.hxx \
# SMDS_HexahedronOfNodes.hxx SMDS_QuadraticFaceOfNodes.hxx \
SMDS_QuadraticVolumeOfNodes.hxx \
#SMDSControl_BoundaryEdges.hxx \ SMDS_SetIterator.hxx
#SMDSControl_BoundaryFaces.hxx \
#SMDSControl.hxx \
#SMDSControl_MeshBoundary.hxx \
#SMDSEdit_Transform.hxx \
#SMDS_MeshPrism.hxx \
#SMDS_MeshPyramid.hxx \
#SMDS_MeshQuadrangle.hxx \
#SMDS_MeshTetrahedron.hxx \
#SMDS_MeshTriangle.hxx \
#SMDS_MeshNodeIDFactory.hxx
# additionnal information to compil and link file # additionnal information to compil and link file
CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(OCC_INCLUDES) $(BOOST_CPPFLAGS) CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(OCC_INCLUDES) $(BOOST_CPPFLAGS)

View File

@ -33,8 +33,24 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
class SMDS_MeshElement; class SMDS_MeshElement;
class SMDS_MeshNode;
class SMDS_MeshEdge;
class SMDS_MeshFace;
class SMDS_MeshVolume;
typedef SMDS_Iterator<const SMDS_MeshElement *> SMDS_ElemIterator; typedef SMDS_Iterator<const SMDS_MeshElement *> SMDS_ElemIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshElement *> > SMDS_ElemIteratorPtr; typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshElement *> > SMDS_ElemIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshNode *> SMDS_NodeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshNode *> > SMDS_NodeIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshEdge *> SMDS_EdgeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshEdge *> > SMDS_EdgeIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshFace *> SMDS_FaceIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshFace *> > SMDS_FaceIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshVolume *> SMDS_VolumeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshVolume *> > SMDS_VolumeIteratorPtr;
#endif #endif

View File

@ -155,3 +155,29 @@ SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
}*/ }*/
int SMDS_FaceOfEdges::NbNodes() const
{
return myEdges[0]->NbNodes() + myEdges[1]->NbNodes() + myEdges[2]->NbNodes() +
( myNbEdges == 4 ? myEdges[3]->NbNodes() : 0 ) - myNbEdges;
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
const SMDS_MeshNode* SMDS_FaceOfEdges::GetNode(const int ind) const
{
int index = WrappedIndex( ind );
for ( int i = 0; i < myNbEdges; ++i ) {
if ( index >= myEdges[ i ]->NbNodes() )
index -= myEdges[ i ]->NbNodes();
else
return myEdges[ i ]->GetNode( index );
}
return 0;
}

View File

@ -42,10 +42,21 @@ class SMDS_FaceOfEdges:public SMDS_MeshFace
const SMDS_MeshEdge* edge4); const SMDS_MeshEdge* edge4);
SMDSAbs_ElementType GetType() const; SMDSAbs_ElementType GetType() const;
int NbNodes() const;
int NbEdges() const; int NbEdges() const;
int NbFaces() const; int NbFaces() const;
// friend bool operator<(const SMDS_FaceOfEdges& e1, const SMDS_FaceOfEdges& e2); // friend bool operator<(const SMDS_FaceOfEdges& e1, const SMDS_FaceOfEdges& e2);
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected: protected:
SMDS_ElemIteratorPtr SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const; elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -23,6 +23,7 @@
#pragma warning(disable:4786) #pragma warning(disable:4786)
#endif #endif
#include "SMDS_SetIterator.hxx"
#include "SMDS_FaceOfNodes.hxx" #include "SMDS_FaceOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx" #include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
@ -68,25 +69,11 @@ void SMDS_FaceOfNodes::Print(ostream & OS) const
//purpose : //purpose :
//======================================================================= //=======================================================================
class SMDS_FaceOfNodes_MyIterator:public SMDS_ElemIterator class SMDS_FaceOfNodes_MyIterator:public SMDS_NodeArrayElemIterator
{ {
const SMDS_MeshNode* const *mySet;
int myLength;
int index;
public: public:
SMDS_FaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l): SMDS_FaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l):
mySet(s),myLength(l),index(0) {} SMDS_NodeArrayElemIterator( s, & s[ l ] ) {}
bool more()
{
return index<myLength;
}
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
}
}; };
SMDS_ElemIteratorPtr SMDS_FaceOfNodes::elementsIterator SMDS_ElemIteratorPtr SMDS_FaceOfNodes::elementsIterator
@ -147,6 +134,18 @@ bool SMDS_FaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
return true; return true;
} }
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
const SMDS_MeshNode* SMDS_FaceOfNodes::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}
/*bool operator<(const SMDS_FaceOfNodes& f1, const SMDS_FaceOfNodes& f2) /*bool operator<(const SMDS_FaceOfNodes& f1, const SMDS_FaceOfNodes& f2)
{ {
set<SMDS_MeshNode> set1,set2; set<SMDS_MeshNode> set1,set2;

View File

@ -44,6 +44,16 @@ class SMDS_FaceOfNodes:public SMDS_MeshFace
int NbEdges() const; int NbEdges() const;
int NbFaces() const; int NbFaces() const;
int NbNodes() const; int NbNodes() const;
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected: protected:
SMDS_ElemIteratorPtr SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const; elementsIterator(SMDSAbs_ElementType type) const;

File diff suppressed because it is too large Load Diff

View File

@ -50,15 +50,6 @@
#include <set> #include <set>
#include <list> #include <list>
typedef SMDS_Iterator<const SMDS_MeshNode *> SMDS_NodeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshNode *> > SMDS_NodeIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshEdge *> SMDS_EdgeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshEdge *> > SMDS_EdgeIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshFace *> SMDS_FaceIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshFace *> > SMDS_FaceIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshVolume *> SMDS_VolumeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshVolume *> > SMDS_VolumeIteratorPtr;
class SMDS_WNT_EXPORT SMDS_Mesh:public SMDS_MeshObject{ class SMDS_WNT_EXPORT SMDS_Mesh:public SMDS_MeshObject{
public: public:
@ -84,6 +75,16 @@ public:
virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1, virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2); const SMDS_MeshNode * n2);
// 2d order edge with 3 nodes: n12 - node between n1 and n2
virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int n12, int ID);
virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n12,
int ID);
virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n12);
virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID); virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1, virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2, const SMDS_MeshNode * n2,
@ -120,6 +121,44 @@ public:
const SMDS_MeshEdge * e3, const SMDS_MeshEdge * e3,
const SMDS_MeshEdge * e4); const SMDS_MeshEdge * e4);
// 2d order triangle of 6 nodes
virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
int n12,int n23,int n31, int ID);
virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
int ID);
virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31);
// 2d order quadrangle
virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
int n12,int n23,int n34,int n41, int ID);
virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
int ID);
virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41);
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID); virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID);
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1, virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2, const SMDS_MeshNode * n2,
@ -214,6 +253,153 @@ public:
const SMDS_MeshFace * f5, const SMDS_MeshFace * f5,
const SMDS_MeshFace * f6); const SMDS_MeshFace * f6);
// 2d order tetrahedron of 10 nodes
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
int n12,int n23,int n31,
int n14,int n24,int n34, int ID);
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34,
int ID);
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34);
// 2d order pyramid of 13 nodes
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
int n12,int n23,int n34,int n41,
int n15,int n25,int n35,int n45,
int ID);
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45,
int ID);
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45);
// 2d order Pentahedron with 15 nodes
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3,
int n4, int n5, int n6,
int n12,int n23,int n31,
int n45,int n56,int n64,
int n14,int n25,int n36,
int ID);
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n45,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n64,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36,
int ID);
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n45,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n64,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36);
// 2d oreder Hexahedrons with 20 nodes
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
int n5, int n6, int n7, int n8,
int n12,int n23,int n34,int n41,
int n56,int n67,int n78,int n85,
int n15,int n26,int n37,int n48,
int ID);
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n67,
const SMDS_MeshNode * n78,
const SMDS_MeshNode * n85,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n26,
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48,
int ID);
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n67,
const SMDS_MeshNode * n78,
const SMDS_MeshNode * n85,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n26,
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48);
virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids, virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids,
const int ID); const int ID);
@ -246,6 +432,12 @@ public:
virtual void RemoveFace(const SMDS_MeshFace * face); virtual void RemoveFace(const SMDS_MeshFace * face);
virtual void RemoveVolume(const SMDS_MeshVolume * volume); virtual void RemoveVolume(const SMDS_MeshVolume * volume);
/*! Remove only the given element and only if it is free.
* Method does not work for meshes with descendants.
* Implemented for fast cleaning of meshes.
*/
virtual void RemoveFreeElement(const SMDS_MeshElement * elem);
virtual bool RemoveFromParent(); virtual bool RemoveFromParent();
virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh); virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh);
@ -261,11 +453,19 @@ public:
const SMDS_MeshNode *FindNode(int idnode) const; const SMDS_MeshNode *FindNode(int idnode) const;
const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const; const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const;
const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2, int idnode3) const;
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const; const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const;
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4) const; const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4) const;
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6) const;
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4,
int idnode5, int idnode6, int idnode7, int idnode8) const;
const SMDS_MeshElement *FindElement(int IDelem) const; const SMDS_MeshElement *FindElement(int IDelem) const;
static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1, static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2); const SMDS_MeshNode * n2);
static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3);
static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1, static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
const SMDS_MeshNode *n2, const SMDS_MeshNode *n2,
const SMDS_MeshNode *n3); const SMDS_MeshNode *n3);
@ -273,6 +473,20 @@ public:
const SMDS_MeshNode *n2, const SMDS_MeshNode *n2,
const SMDS_MeshNode *n3, const SMDS_MeshNode *n3,
const SMDS_MeshNode *n4); const SMDS_MeshNode *n4);
static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
const SMDS_MeshNode *n2,
const SMDS_MeshNode *n3,
const SMDS_MeshNode *n4,
const SMDS_MeshNode *n5,
const SMDS_MeshNode *n6);
static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
const SMDS_MeshNode *n2,
const SMDS_MeshNode *n3,
const SMDS_MeshNode *n4,
const SMDS_MeshNode *n5,
const SMDS_MeshNode *n6,
const SMDS_MeshNode *n7,
const SMDS_MeshNode *n8);
const SMDS_MeshFace *FindFace(std::vector<int> nodes_ids) const; const SMDS_MeshFace *FindFace(std::vector<int> nodes_ids) const;
static const SMDS_MeshFace* FindFace(std::vector<const SMDS_MeshNode *> nodes); static const SMDS_MeshFace* FindFace(std::vector<const SMDS_MeshNode *> nodes);

View File

@ -135,6 +135,18 @@ bool operator<(const SMDS_MeshEdge & e1, const SMDS_MeshEdge & e2)
else return false; else return false;
} }
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
const SMDS_MeshNode* SMDS_MeshEdge::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}
//======================================================================= //=======================================================================
//function : ChangeNodes //function : ChangeNodes
//purpose : //purpose :

View File

@ -44,12 +44,22 @@ class SMDS_MeshEdge:public SMDS_MeshElement
int NbNodes() const; int NbNodes() const;
int NbEdges() const; int NbEdges() const;
friend bool operator<(const SMDS_MeshEdge& e1, const SMDS_MeshEdge& e2); 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
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected: protected:
SMDS_ElemIteratorPtr SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const; elementsIterator(SMDSAbs_ElementType type) const;
private: protected:
const SMDS_MeshNode* myNodes[2]; const SMDS_MeshNode* myNodes[3];
}; };
#endif #endif

View File

@ -192,3 +192,29 @@ bool operator<(const SMDS_MeshElement& e1, const SMDS_MeshElement& e2)
} }
return false; return false;
} }
bool SMDS_MeshElement::IsValidIndex(const int ind) const
{
return ( ind>-1 && ind<NbNodes() );
}
const SMDS_MeshNode* SMDS_MeshElement::GetNode(const int ind) const
{
SMDS_ElemIteratorPtr it = nodesIterator();
int i = 0, index = WrappedIndex( ind );
while ( index != i++ )
it->next();
if ( it->more() )
return static_cast<const SMDS_MeshNode*> (it->next());
return 0;
}
bool SMDS_MeshElement::IsQuadratic() const
{
return false;
}
bool SMDS_MeshElement::IsMediumNode(const SMDS_MeshNode* node) const
{
return false;
}

View File

@ -56,32 +56,64 @@ class SMDS_MeshFace;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class SMDS_WNT_EXPORT SMDS_MeshElement:public SMDS_MeshObject class SMDS_WNT_EXPORT SMDS_MeshElement:public SMDS_MeshObject
{ {
public:
public: SMDS_ElemIteratorPtr nodesIterator() const;
SMDS_ElemIteratorPtr nodesIterator() const; SMDS_ElemIteratorPtr edgesIterator() const;
SMDS_ElemIteratorPtr edgesIterator() const; SMDS_ElemIteratorPtr facesIterator() const;
SMDS_ElemIteratorPtr facesIterator() const; virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
virtual SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
virtual int NbNodes() const; virtual int NbNodes() const;
virtual int NbEdges() const; virtual int NbEdges() const;
virtual int NbFaces() const; virtual int NbFaces() const;
int GetID() const; int GetID() const;
///Return the type of the current element ///Return the type of the current element
virtual SMDSAbs_ElementType GetType() const = 0; virtual SMDSAbs_ElementType GetType() const = 0;
virtual bool IsPoly() const { return false; }; virtual bool IsPoly() const { return false; };
virtual bool IsQuadratic() const;
friend std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *); virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
friend bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem);
protected: friend std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
SMDS_MeshElement(int ID=-1); friend bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem);
virtual void Print(std::ostream & OS) const;
private: // ===========================
int myID; // Access to nodes by index
// ===========================
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
/*!
* \brief Return true if index of node is valid (0 <= ind < NbNodes())
* \param ind - node index
* \retval bool - index check result
*/
virtual bool IsValidIndex(const int ind) const;
/*!
* \brief Return a valid node index, fixing the given one if necessary
* \param ind - node index
* \retval int - valid node index
*/
int WrappedIndex(const int ind) const {
if ( ind < 0 ) return -( ind % NbNodes());
if ( ind >= NbNodes() ) return ind % NbNodes();
return ind;
}
protected:
SMDS_MeshElement(int ID=-1);
virtual void Print(std::ostream & OS) const;
private:
int myID;
}; };
#endif #endif

View File

@ -64,6 +64,15 @@ class SMDS_WNT_EXPORT SMDS_MeshNode:public SMDS_MeshElement
void setXYZ(double x, double y, double z); void setXYZ(double x, double y, double z);
friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2); friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2);
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int) const { return this; }
protected: protected:
SMDS_ElemIteratorPtr SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const; elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -26,7 +26,7 @@
#include "SMDS_PolygonalFaceOfNodes.hxx" #include "SMDS_PolygonalFaceOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx" #include "SMDS_IteratorOfElements.hxx"
//#include "SMDS_MeshNode.hxx" #include "SMDS_SetIterator.hxx"
#include "utilities.h" #include "utilities.h"
using namespace std; using namespace std;
@ -128,28 +128,11 @@ void SMDS_PolygonalFaceOfNodes::Print(ostream & OS) const
//function : elementsIterator //function : elementsIterator
//purpose : //purpose :
//======================================================================= //=======================================================================
class SMDS_PolygonalFaceOfNodes_MyIterator:public SMDS_ElemIterator class SMDS_PolygonalFaceOfNodes_MyIterator:public SMDS_NodeVectorElemIterator
{ {
//const SMDS_MeshNode* const *mySet;
const std::vector<const SMDS_MeshNode *> mySet;
//int myLength;
int index;
public: public:
//SMDS_PolygonalFaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l): SMDS_PolygonalFaceOfNodes_MyIterator(const vector<const SMDS_MeshNode *>& s):
// mySet(s),myLength(l),index(0) {} SMDS_NodeVectorElemIterator( s.begin(), s.end() ) {}
SMDS_PolygonalFaceOfNodes_MyIterator(const std::vector<const SMDS_MeshNode *> s):
mySet(s),index(0) {}
bool more()
{
return index < mySet.size();
}
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
}
}; };
SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::elementsIterator SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::elementsIterator
@ -172,3 +155,16 @@ SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::elementsIterator
} }
return SMDS_ElemIteratorPtr(); return SMDS_ElemIteratorPtr();
} }
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
const SMDS_MeshNode* SMDS_PolygonalFaceOfNodes::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}

View File

@ -50,6 +50,15 @@ class SMDS_PolygonalFaceOfNodes:public SMDS_MeshFace
virtual void Print (std::ostream & OS) const; virtual void Print (std::ostream & OS) const;
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected: protected:
virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const; virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;

View File

@ -0,0 +1,187 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File: SMDS_QuadraticEdge.cxx
// Created: 16.01.06 16:25:42
// Author: Sergey KUUL
#include "SMDS_QuadraticEdge.hxx"
#include "SMDS_SetIterator.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
using namespace std;
//=======================================================================
//function : SMDS_QuadraticEdge
//purpose :
//=======================================================================
SMDS_QuadraticEdge::SMDS_QuadraticEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12)
:SMDS_MeshEdge(node1,node2)
{
myNodes[2]=node12;
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_QuadraticEdge::Print(ostream & OS) const
{
OS << "quadratic edge <" << GetID() << "> : ( first-" << myNodes[0]
<< " , last-" << myNodes[1] << " , medium-" << myNodes[2] << ") " << endl;
}
//=======================================================================
//function : NbNodes
//purpose :
//=======================================================================
int SMDS_QuadraticEdge::NbNodes() const
{
return 3;
}
//=======================================================================
//function : ChangeNodes
//purpose :
//=======================================================================
bool SMDS_QuadraticEdge::ChangeNodes(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12)
{
myNodes[0]=node1;
myNodes[1]=node2;
myNodes[2]=node12;
return true;
}
//=======================================================================
//function : IsMediumNode
//purpose :
//=======================================================================
bool SMDS_QuadraticEdge::IsMediumNode(const SMDS_MeshNode * node) const
{
return (myNodes[2]==node);
}
namespace
{
//=======================================================================
//class : _MyInterlacedNodeIterator
//purpose :
//=======================================================================
class _MyInterlacedNodeIterator: public SMDS_NodeArrayIterator
{
const SMDS_MeshNode * myNodes[3];
public:
_MyInterlacedNodeIterator(const SMDS_MeshNode * const * nodes):
SMDS_NodeArrayIterator( myNodes, & myNodes[3] )
{
myNodes[0] = nodes[0];
myNodes[1] = nodes[2];
myNodes[2] = nodes[1];
}
};
//=======================================================================
//class : _MyInterlacedNodeElemIterator
//purpose :
//=======================================================================
class _MyInterlacedNodeElemIterator : public SMDS_ElemIterator
{
SMDS_NodeIteratorPtr myItr;
public:
_MyInterlacedNodeElemIterator(SMDS_NodeIteratorPtr interlacedNodeItr):
myItr( interlacedNodeItr ) {}
bool more() { return myItr->more(); }
const SMDS_MeshElement* next() { return myItr->next(); }
};
//=======================================================================
//class : _MyNodeIterator
//purpose :
//=======================================================================
class _MyNodeIterator:public SMDS_NodeArrayElemIterator
{
public:
_MyNodeIterator(const SMDS_MeshNode * const * nodes):
SMDS_NodeArrayElemIterator( nodes, & nodes[3] ) {}
};
}
//=======================================================================
//function : interlacedNodesIterator
//purpose :
//=======================================================================
SMDS_NodeIteratorPtr SMDS_QuadraticEdge::interlacedNodesIterator() const
{
return SMDS_NodeIteratorPtr (new _MyInterlacedNodeIterator (myNodes));
}
//=======================================================================
//function : interlacedNodesElemIterator
//purpose :
//=======================================================================
SMDS_ElemIteratorPtr SMDS_QuadraticEdge::interlacedNodesElemIterator() const
{
return SMDS_ElemIteratorPtr
(new _MyInterlacedNodeElemIterator ( interlacedNodesIterator() ));
}
//=======================================================================
//function : elementsIterator
//purpose :
//=======================================================================
SMDS_ElemIteratorPtr SMDS_QuadraticEdge::elementsIterator(SMDSAbs_ElementType type) const
{
switch(type)
{
case SMDSAbs_Edge:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Edge);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes));
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type, SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes))));
}
}

View File

@ -0,0 +1,62 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMDS_QuadraticEdge.hxx
// Module : SMESH
#ifndef _SMDS_QuadraticEdge_HeaderFile
#define _SMDS_QuadraticEdge_HeaderFile
#include "SMDS_MeshEdge.hxx"
#include <iostream>
class SMDS_WNT_EXPORT SMDS_QuadraticEdge: public SMDS_MeshEdge
{
public:
SMDS_QuadraticEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12);
bool ChangeNodes(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12);
void Print(std::ostream & OS) const;
int NbNodes() const;
virtual bool IsQuadratic() const { return true; }
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
SMDS_NodeIteratorPtr interlacedNodesIterator() const;
SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
};
#endif

View File

@ -0,0 +1,281 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File: SMDS_QuadraticFaceOfNodes.cxx
// Created: 16.01.06 17:12:58
// Author: Sergey KUUL
#include "SMDS_QuadraticFaceOfNodes.hxx"
#include "SMDS_SetIterator.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
#include "utilities.h"
using namespace std;
//=======================================================================
//function : SMDS_QuadraticFaceOfNodes()
//purpose : Constructor
//=======================================================================
SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31)
{
myNodes.resize( 6 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n12;
myNodes[ 4 ] = n23;
myNodes[ 5 ] = n31;
}
//=======================================================================
//function : SMDS_QuadraticFaceOfNodes()
//purpose : Constructor
//=======================================================================
SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41)
{
myNodes.resize( 8 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n4;
myNodes[ 4 ] = n12;
myNodes[ 5 ] = n23;
myNodes[ 6 ] = n34;
myNodes[ 7 ] = n41;
}
//=======================================================================
//function : IsMediumNode
//purpose :
//=======================================================================
bool SMDS_QuadraticFaceOfNodes::IsMediumNode(const SMDS_MeshNode * node) const
{
int i=NbNodes()/2;
for(; i<NbNodes(); i++) {
if(myNodes[i]==node) return true;
}
return false;
}
//=======================================================================
//function : ChangeNodes
//purpose :
//=======================================================================
bool SMDS_QuadraticFaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes)
{
if( nbNodes==6 || nbNodes==8 ) {
myNodes.resize(nbNodes);
int i=0;
for(; i<nbNodes; i++) {
myNodes[i] = nodes[i];
}
return true;
}
return false;
}
//=======================================================================
//function : NbNodes
//purpose :
//=======================================================================
int SMDS_QuadraticFaceOfNodes::NbNodes() const
{
return myNodes.size();
}
//=======================================================================
//function : NbEdges
//purpose :
//=======================================================================
int SMDS_QuadraticFaceOfNodes::NbEdges() const
{
return NbNodes()/2;
}
//=======================================================================
//function : NbFaces
//purpose :
//=======================================================================
int SMDS_QuadraticFaceOfNodes::NbFaces() const
{
return 1;
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_QuadraticFaceOfNodes::Print(ostream & OS) const
{
OS << "quadratic face <" << GetID() << " > : ";
int i, nbNodes = myNodes.size();
for (i = 0; i < nbNodes - 1; i++)
OS << myNodes[i] << ",";
OS << myNodes[i] << ") " << endl;
}
namespace {
//=======================================================================
//class : _MyInterlacedNodeIterator
//purpose :
//=======================================================================
class _MyInterlacedNodeIterator:public SMDS_NodeIterator
{
const vector<const SMDS_MeshNode *>& mySet;
int myIndex;
const int * myInterlace;
public:
_MyInterlacedNodeIterator(const vector<const SMDS_MeshNode *>& s,
const int * interlace):
mySet(s),myIndex(0),myInterlace(interlace) {}
bool more()
{
return myIndex < mySet.size();
}
const SMDS_MeshNode* next()
{
return mySet[ myInterlace[ myIndex++ ]];
}
};
//=======================================================================
//class : _MyInterlacedNodeElemIterator
//purpose :
//=======================================================================
class _MyInterlacedNodeElemIterator : public SMDS_ElemIterator
{
SMDS_NodeIteratorPtr myItr;
public:
_MyInterlacedNodeElemIterator(SMDS_NodeIteratorPtr interlacedNodeItr):
myItr( interlacedNodeItr ) {}
bool more() { return myItr->more(); }
const SMDS_MeshElement* next() { return myItr->next(); }
};
//=======================================================================
//class : _MyNodeIterator
//purpose :
//=======================================================================
class _MyNodeIterator : public SMDS_NodeVectorElemIterator
{
public:
_MyNodeIterator(const vector<const SMDS_MeshNode *>& s):
SMDS_NodeVectorElemIterator( s.begin(), s.end() ) {}
};
}
//=======================================================================
//function : interlacedNodesIterator
//purpose :
//=======================================================================
SMDS_NodeIteratorPtr SMDS_QuadraticFaceOfNodes::interlacedNodesIterator() const
{
static int triaInterlace [] = { 0, 3, 1, 4, 2, 5 };
static int quadInterlace [] = { 0, 4, 1, 5, 2, 6, 3, 7 };
return SMDS_NodeIteratorPtr
(new _MyInterlacedNodeIterator (myNodes, myNodes.size()==6 ? triaInterlace : quadInterlace));
}
//=======================================================================
//function : interlacedNodesElemIterator
//purpose :
//=======================================================================
SMDS_ElemIteratorPtr SMDS_QuadraticFaceOfNodes::interlacedNodesElemIterator() const
{
return SMDS_ElemIteratorPtr
(new _MyInterlacedNodeElemIterator ( interlacedNodesIterator() ));
}
//=======================================================================
//function : elementsIterator
//purpose :
//=======================================================================
SMDS_ElemIteratorPtr SMDS_QuadraticFaceOfNodes::elementsIterator
(SMDSAbs_ElementType type) const
{
switch(type)
{
case SMDSAbs_Face:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes));
case SMDSAbs_Edge:
MESSAGE("Error : edge iterator for SMDS_QuadraticFaceOfNodes not implemented");
break;
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type,SMDS_ElemIteratorPtr (new _MyNodeIterator(myNodes))));
}
return SMDS_ElemIteratorPtr();
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
const SMDS_MeshNode* SMDS_QuadraticFaceOfNodes::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}

View File

@ -0,0 +1,84 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMDS_QuadraticVolumeOfNodes.hxx
// Module : SMESH
#ifndef _SMDS_QuadraticFaceOfNodes_HeaderFile
#define _SMDS_QuadraticFaceOfNodes_HeaderFile
#include "SMDS_MeshFace.hxx"
class SMDS_WNT_EXPORT SMDS_QuadraticFaceOfNodes:public SMDS_MeshFace
{
public:
SMDS_QuadraticFaceOfNodes (const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31);
SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41);
virtual bool IsQuadratic() const { return true; }
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
bool ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes);
virtual int NbNodes() const;
virtual int NbEdges() const;
virtual int NbFaces() const;
virtual void Print (std::ostream & OS) const;
SMDS_NodeIteratorPtr interlacedNodesIterator() const;
SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected:
virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
private:
std::vector<const SMDS_MeshNode *> myNodes;
};
#endif

View File

@ -0,0 +1,347 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File: SMDS_QuadraticVolumeOfNodes.cxx
// Created: 17.01.06 09:46:11
// Author: Sergey KUUL
#include "SMDS_QuadraticVolumeOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
#include "utilities.h"
using namespace std;
//=======================================================================
//function : SMDS_QuadraticVolumeOfNodes()
//purpose : Constructor tetrahedron of 10 nodes
//=======================================================================
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34)
{
myNodes.resize( 10 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n4;
myNodes[ 4 ] = n12;
myNodes[ 5 ] = n23;
myNodes[ 6 ] = n31;
myNodes[ 7 ] = n14;
myNodes[ 8 ] = n24;
myNodes[ 9 ] = n34;
}
//=======================================================================
//function : SMDS_QuadraticVolumeOfNodes()
//purpose : Constructor pyramid of 13 nodes
//=======================================================================
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45)
{
myNodes.resize( 13 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n4;
myNodes[ 4 ] = n5;
myNodes[ 5 ] = n12;
myNodes[ 6 ] = n23;
myNodes[ 7 ] = n34;
myNodes[ 8 ] = n41;
myNodes[ 9 ] = n15;
myNodes[ 10 ] = n25;
myNodes[ 11 ] = n35;
myNodes[ 12 ] = n45;
}
//=======================================================================
//function : SMDS_QuadraticVolumeOfNodes()
//purpose : Constructor Pentahedron with 15 nodes
//=======================================================================
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n45,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n64,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36)
{
myNodes.resize( 15 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n4;
myNodes[ 4 ] = n5;
myNodes[ 5 ] = n6;
myNodes[ 6 ] = n12;
myNodes[ 7 ] = n23;
myNodes[ 8 ] = n31;
myNodes[ 9 ] = n45;
myNodes[ 10 ] = n56;
myNodes[ 11 ] = n64;
myNodes[ 12 ] = n14;
myNodes[ 13 ] = n25;
myNodes[ 14 ] = n36;
}
//=======================================================================
//function : SMDS_QuadraticVolumeOfNodes()
//purpose : Constructor Hexahedrons with 20 nodes
//=======================================================================
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n67,
const SMDS_MeshNode * n78,
const SMDS_MeshNode * n85,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n26,
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48)
{
myNodes.resize( 20 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n4;
myNodes[ 4 ] = n5;
myNodes[ 5 ] = n6;
myNodes[ 6 ] = n7;
myNodes[ 7 ] = n8;
myNodes[ 8 ] = n12;
myNodes[ 9 ] = n23;
myNodes[ 10 ] = n34;
myNodes[ 11 ] = n41;
myNodes[ 12 ] = n56;
myNodes[ 13 ] = n67;
myNodes[ 14 ] = n78;
myNodes[ 15 ] = n85;
myNodes[ 16 ] = n15;
myNodes[ 17 ] = n26;
myNodes[ 18 ] = n37;
myNodes[ 19 ] = n48;
}
//=======================================================================
//function : IsMediumNode
//purpose :
//=======================================================================
bool SMDS_QuadraticVolumeOfNodes::IsMediumNode(const SMDS_MeshNode* node) const
{
int nbCorners = 0;
switch (myNodes.size()) {
case 10: nbCorners = 4; break;
case 13: nbCorners = 5; break;
case 15: nbCorners = 6; break;
default: nbCorners = 8;
}
for ( int i = nbCorners; i<myNodes.size(); i++) {
if(myNodes[i]==node) return true;
}
return false;
}
//=======================================================================
//function : ChangeNodes
//purpose :
//=======================================================================
bool SMDS_QuadraticVolumeOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes)
{
if( nbNodes==10 || nbNodes==13 || nbNodes==15 || nbNodes==20 ) {
myNodes.resize(nbNodes);
int i=0;
for(; i<nbNodes; i++) {
myNodes[i] = nodes[i];
}
return true;
}
return false;
}
//=======================================================================
//function : NbNodes
//purpose :
//=======================================================================
int SMDS_QuadraticVolumeOfNodes::NbNodes() const
{
return myNodes.size();
}
//=======================================================================
//function : NbEdges
//purpose :
//=======================================================================
int SMDS_QuadraticVolumeOfNodes::NbEdges() const
{
if(myNodes.size()==10)
return 6;
else if(myNodes.size()==13)
return 8;
else if(myNodes.size()==15)
return 9;
else
return 12;
}
//=======================================================================
//function : NbFaces
//purpose :
//=======================================================================
int SMDS_QuadraticVolumeOfNodes::NbFaces() const
{
if(myNodes.size()==10)
return 4;
else if(myNodes.size()==20)
return 6;
else
return 5;
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_QuadraticVolumeOfNodes::Print(ostream & OS) const
{
OS << "quadratic volume <" << GetID() << " > : ";
int i, nbNodes = myNodes.size();
for (i = 0; i < nbNodes - 1; i++)
OS << myNodes[i] << ",";
OS << myNodes[i] << ") " << endl;
}
//=======================================================================
//private class : SMDS_QuadraticVolumeOfNodes_MyIterator
//purpose :
//=======================================================================
class SMDS_QuadraticVolumeOfNodes_MyIterator : public SMDS_NodeVectorElemIterator
{
public:
SMDS_QuadraticVolumeOfNodes_MyIterator(const vector<const SMDS_MeshNode *>& s):
SMDS_NodeVectorElemIterator( s.begin(), s.end() ) {}
};
//=======================================================================
//function : elementsIterator
//purpose :
//=======================================================================
SMDS_ElemIteratorPtr SMDS_QuadraticVolumeOfNodes::elementsIterator
(SMDSAbs_ElementType type) const
{
switch(type)
{
case SMDSAbs_Volume:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new SMDS_QuadraticVolumeOfNodes_MyIterator(myNodes));
case SMDSAbs_Edge:
MESSAGE("Error : edge iterator for SMDS_QuadraticVolumeOfNodes not implemented");
break;
case SMDSAbs_Face:
MESSAGE("Error : face iterator for SMDS_QuadraticVolumeOfNodes not implemented");
break;
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type,SMDS_ElemIteratorPtr
(new SMDS_QuadraticVolumeOfNodes_MyIterator(myNodes))));
}
return SMDS_ElemIteratorPtr();
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
const SMDS_MeshNode* SMDS_QuadraticVolumeOfNodes::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}

View File

@ -0,0 +1,130 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMDS_QuadraticVolumeOfNodes.hxx
// Module : SMESH
#ifndef _SMDS_QuadraticVolumeOfNodes_HeaderFile
#define _SMDS_QuadraticVolumeOfNodes_HeaderFile
#include "SMDS_MeshVolume.hxx"
class SMDS_WNT_EXPORT SMDS_QuadraticVolumeOfNodes: public SMDS_MeshVolume
{
public:
// tetrahedron of 10 nodes
SMDS_QuadraticVolumeOfNodes (const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34);
// pyramid of 13 nodes
SMDS_QuadraticVolumeOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45);
// Pentahedron with 15 nodes
SMDS_QuadraticVolumeOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n45,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n64,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36);
// Hexahedrons with 20 nodes
SMDS_QuadraticVolumeOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n67,
const SMDS_MeshNode * n78,
const SMDS_MeshNode * n85,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n26,
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48);
virtual bool IsQuadratic() const { return true; }
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
bool ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes);
virtual int NbNodes() const;
virtual int NbEdges() const;
virtual int NbFaces() const;
virtual void Print (std::ostream & OS) const;
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected:
virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
private:
std::vector<const SMDS_MeshNode *> myNodes;
};
#endif

View File

@ -0,0 +1,101 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMDS_SetIterator.hxx
// Created : Mon Feb 27 16:57:43 2006
// Author : Edward AGAPOV (eap)
#ifndef SMDS_SetIterator_HeaderFile
#define SMDS_SetIterator_HeaderFile
#include "SMDS_Iterator.hxx"
///////////////////////////////////////////////////////////////////////////////
/// specific SMDS_Iterator iterating over abstract set of values like STL containers
///
/// BE CAREFUL: iterator pointed value is static_cast'ed to VALUE
///
///////////////////////////////////////////////////////////////////////////////
template<typename VALUE, typename VALUE_SET_ITERATOR>
class SMDS_SetIterator : public SMDS_Iterator<VALUE>
{
protected:
VALUE_SET_ITERATOR _beg, _end;
public:
SMDS_SetIterator(const VALUE_SET_ITERATOR & begin,
const VALUE_SET_ITERATOR & end)
{ init ( begin, end ); }
/// Initialization
virtual void init(const VALUE_SET_ITERATOR & begin,
const VALUE_SET_ITERATOR & end)
{ _beg = begin; _end = end; }
/// Return true if and only if there are other object in this iterator
virtual bool more() { return _beg != _end; }
/// Return the current object and step to the next one
virtual VALUE next() { return static_cast<VALUE>( *_beg++ ); }
};
// useful specifications
#include <vector>
class SMDS_MeshElement;
class SMDS_MeshNode;
typedef const SMDS_MeshElement* SMDS_pElement;
typedef const SMDS_MeshNode* SMDS_pNode;
// element iterators
typedef SMDS_SetIterator< SMDS_pElement, std::vector< SMDS_pElement >::const_iterator>
SMDS_ElementVectorIterator;
typedef SMDS_SetIterator< SMDS_pElement, SMDS_pElement const *>
SMDS_ElementArrayIterator;
typedef SMDS_SetIterator< SMDS_pElement, std::vector< SMDS_pNode >::const_iterator>
SMDS_NodeVectorElemIterator;
typedef SMDS_SetIterator< SMDS_pElement, SMDS_pNode const * >
SMDS_NodeArrayElemIterator;
// node iterators
typedef SMDS_SetIterator< SMDS_pNode, std::vector< SMDS_pNode >::const_iterator >
SMDS_NodeVectorIterator;
typedef SMDS_SetIterator< SMDS_pNode, SMDS_pNode const * >
SMDS_NodeArrayIterator;
#endif

View File

@ -25,6 +25,7 @@
#include "SMDS_VolumeOfNodes.hxx" #include "SMDS_VolumeOfNodes.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
#include "utilities.h" #include "utilities.h"
using namespace std; using namespace std;
@ -170,29 +171,14 @@ int SMDS_VolumeOfNodes::NbEdges() const
return 0; return 0;
} }
class SMDS_VolumeOfNodes_MyIterator:public SMDS_ElemIterator class SMDS_VolumeOfNodes_MyIterator:public SMDS_NodeArrayElemIterator
{ {
const SMDS_MeshNode* const* mySet;
int myLength;
int index;
public: public:
SMDS_VolumeOfNodes_MyIterator(const SMDS_MeshNode* const* s, int l): SMDS_VolumeOfNodes_MyIterator(const SMDS_MeshNode* const* s, int l):
mySet(s),myLength(l),index(0) {} SMDS_NodeArrayElemIterator( s, & s[ l ]) {}
bool more()
{
return index<myLength;
}
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
}
}; };
SMDS_ElemIteratorPtr SMDS_VolumeOfNodes:: SMDS_ElemIteratorPtr SMDS_VolumeOfNodes::elementsIterator(SMDSAbs_ElementType type) const
elementsIterator(SMDSAbs_ElementType type) const
{ {
switch(type) switch(type)
{ {
@ -210,3 +196,15 @@ SMDSAbs_ElementType SMDS_VolumeOfNodes::GetType() const
{ {
return SMDSAbs_Volume; return SMDSAbs_Volume;
} }
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
const SMDS_MeshNode* SMDS_VolumeOfNodes::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}

View File

@ -70,6 +70,16 @@ class SMDS_VolumeOfNodes:public SMDS_MeshVolume
int NbNodes() const; int NbNodes() const;
int NbEdges() const; int NbEdges() const;
SMDSAbs_ElementType GetType() const; SMDSAbs_ElementType GetType() const;
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected: protected:
SMDS_ElemIteratorPtr SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const; elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -185,6 +185,184 @@ static int Hexa_RE [6][5] = { // REVERSED -> EXTERNAL
{ 1, 2, 6, 5, 1 }}; { 1, 2, 6, 5, 1 }};
static int Hexa_nbN [] = { 4, 4, 4, 4, 4, 4 }; static int Hexa_nbN [] = { 4, 4, 4, 4, 4, 4 };
/*
// N3
// +
// /|\
// 7/ | \8
// / |4 \ QUADRATIC
// N0 +---|---+ N1 TETRAHEDRON
// \ +9 /
// \ | /
// 6\ | /5
// \|/
// +
// N2
*/
static int QuadTetra_F [4][7] = { // FORWARD == EXTERNAL
{ 0, 4, 1, 5, 2, 6, 0 }, // All faces have external normals
{ 0, 7, 3, 8, 1, 4, 0 },
{ 1, 8, 3, 9, 2, 5, 1 },
{ 0, 6, 2, 9, 3, 7, 0 }};
static int QuadTetra_R [4][7] = { // REVERSED
{ 0, 4, 1, 5, 2, 6, 0 }, // All faces but a bottom have external normals
{ 0, 4, 1, 8, 3, 7, 0 },
{ 1, 5, 2, 9, 3, 8, 1 },
{ 0, 7, 3, 9, 2, 6, 0 }};
static int QuadTetra_RE [4][7] = { // REVERSED -> FORWARD (EXTERNAL)
{ 0, 6, 2, 5, 1, 4, 0 }, // All faces have external normals
{ 0, 4, 1, 8, 3, 7, 0 },
{ 1, 5, 2, 9, 3, 8, 1 },
{ 0, 7, 3, 9, 2, 6, 0 }};
static int QuadTetra_nbN [] = { 6, 6, 6, 6 };
//
// QUADRATIC
// PYRAMID
//
// +4
//
//
// 10+-----+11
// | | 9 - middle point for (0,4) etc.
// | |
// 9+-----+12
//
// 6
// 1+----+----+2
// | |
// | |
// 5+ +7
// | |
// | |
// 0+----+----+3
// 8
static int QuadPyram_F [5][9] = { // FORWARD == EXTERNAL
{ 0, 5, 1, 6, 2, 7, 3, 8, 0 }, // All faces have external normals
{ 0, 9, 4, 10,1, 5, 0, 4, 4 },
{ 1, 10,4, 11,2, 6, 1, 4, 4 },
{ 2, 11,4, 12,3, 7, 2, 4, 4 },
{ 3, 12,4, 9, 0, 8, 3, 4, 4 }};
static int QuadPyram_R [5][9] = { // REVERSED
{ 0, 5, 1, 6, 2, 7, 3, 8, 0 }, // All faces but a bottom have external normals
{ 0, 5, 1, 10,4, 9, 0, 4, 4 },
{ 1, 6, 2, 11,4, 10,1, 4, 4 },
{ 2, 7, 3, 12,4, 11,2, 4, 4 },
{ 3, 8, 0, 9, 4, 12,3, 4, 4 }};
static int QuadPyram_RE [5][9] = { // REVERSED -> FORWARD (EXTERNAL)
{ 0, 8, 3, 7, 2, 6, 1, 5, 0 }, // All faces but a bottom have external normals
{ 0, 5, 1, 10,4, 9, 0, 4, 4 },
{ 1, 6, 2, 11,4, 10,1, 4, 4 },
{ 2, 7, 3, 12,4, 11,2, 4, 4 },
{ 3, 8, 0, 9, 4, 12,3, 4, 4 }};
static int QuadPyram_nbN [] = { 8, 6, 6, 6, 6 };
/*
// + N4
// /|\
// 9/ | \10
// / | \
// / | \
// N3 +----+----+ N5
// | |11 |
// | | |
// | +13 | QUADRATIC
// | | | PENTAHEDRON
// | | |
// | | |
// | | |
// 12+ | +14
// | | |
// | | |
// | + N1 |
// | / \ |
// | 6/ \7 |
// | / \ |
// |/ \|
// N0 +---------+ N2
// 8
*/
static int QuadPenta_F [5][9] = { // FORWARD
{ 0, 6, 1, 7, 2, 8, 0, 0, 0 }, // Top face has an internal normal, other - external
{ 3, 9, 4, 10,5, 11,3, 3, 3 }, // 0 is bottom, 1 is top face
{ 0, 8, 2, 14,5, 11,3, 12,0 },
{ 1, 13,4, 10,5, 14,2, 7, 1 },
{ 0, 12,3, 9, 4, 13,1, 6, 0 }};
static int QuadPenta_R [5][9] = { // REVERSED
{ 0, 6, 1, 7, 2, 8, 0, 0, 0 }, // Bottom face has an internal normal, other - external
{ 3, 9, 4, 10,5, 11,3, 3, 3 }, // 0 is bottom, 1 is top face
{ 0, 12,3, 11,5, 14,2, 8, 0 },
{ 1, 7, 2, 14,5, 10,4, 13,1 },
{ 0, 6, 1, 13,4, 9, 3, 12,0 }};
static int QuadPenta_FE [5][9] = { // FORWARD -> EXTERNAL
{ 0, 6, 1, 7, 2, 8, 0, 0, 0 },
{ 3,11, 5, 10,4, 9, 3, 3, 3 },
{ 0, 8, 2, 14,5, 11,3, 12,0 },
{ 1, 13,4, 10,5, 14,2, 7, 1 },
{ 0, 12,3, 9, 4, 13,1, 6, 0 }};
static int QuadPenta_RE [5][9] = { // REVERSED -> EXTERNAL
{ 0, 8, 2, 7, 1, 6, 0, 0, 0 },
{ 3, 9, 4, 10,5, 11,3, 3, 3 },
{ 0, 12,3, 11,5, 14,2, 8, 0 },
{ 1, 7, 2, 14,5, 10,4, 13,1 },
{ 0, 6, 1, 13,4, 9, 3, 12,0 }};
static int QuadPenta_nbN [] = { 6, 6, 8, 8, 8 };
/*
// 13
// N5+-----+-----+N6
// /| /|
// 12+ | 14+ |
// / | / |
// N4+-----+-----+N7 | QUADRATIC
// | | 15 | | HEXAHEDRON
// | | | |
// | 17+ | +18
// | | | |
// | | | |
// | | | |
// 16+ | +19 |
// | | | |
// | | 9 | |
// | N1+-----+-|---+N2
// | / | /
// | +8 | +10
// |/ |/
// N0+-----+-----+N3
// 11
*/
static int QuadHexa_F [6][9] = { // FORWARD
{ 0, 8, 1, 9, 2, 10,3, 11,0 }, // opposite faces are neighbouring,
{ 4, 12,5, 13,6, 14,7, 15,4 }, // odd face(1,3,5) normal is internal, even(0,2,4) - external
{ 1, 8, 0, 16,4, 12,5, 17,1 }, // same index nodes of opposite faces are linked
{ 2, 10,3, 19,7, 14,6, 18,2 },
{ 0, 11,3, 19,7, 15,4, 16,0 },
{ 1, 9, 2, 18,6, 13,5, 17,1 }};
// static int Hexa_R [6][5] = { // REVERSED
// { 0, 3, 2, 1, 0 }, // opposite faces are neighbouring,
// { 4, 7, 6, 5, 4 }, // odd face(1,3,5) normal is external, even(0,2,4) - internal
// { 1, 5, 4, 0, 1 }, // same index nodes of opposite faces are linked
// { 2, 6, 7, 3, 2 },
// { 0, 4, 7, 3, 0 },
// { 1, 5, 6, 2, 1 }};
static int QuadHexa_FE [6][9] = { // FORWARD -> EXTERNAL
{ 0, 8, 1, 9, 2, 10,3, 11,0 }, // opposite faces are neighbouring,
{ 4, 15,7, 14,6, 13,5, 12,4 }, // all face normals are external,
{ 0, 16,4, 12,5, 17,1, 8, 0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1
{ 3, 10,2, 18,6, 14,7, 19,3 },
{ 0, 11,3, 19,7, 15,4, 16,0 },
{ 1, 17,5, 13,6, 18,2, 9, 1 }};
static int QuadHexa_RE [6][9] = { // REVERSED -> EXTERNAL
{ 0, 11,3, 10,2, 9, 1, 8, 0 }, // opposite faces are neighbouring,
{ 4, 12,5, 13,6, 14,7, 15,4 }, // all face normals are external,
{ 0, 8, 1, 17,5, 12,4, 16,0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1
{ 3, 19,7, 14,6, 18,2, 10,3 },
{ 0, 16,4, 15,7, 19,3, 11,0 },
{ 1, 9, 2, 18,6, 13,5, 17,1 }};
static int QuadHexa_nbN [] = { 8, 8, 8, 8, 8, 8 };
// ======================================================== // ========================================================
// to perform some calculations without linkage to CASCADE // to perform some calculations without linkage to CASCADE
// ======================================================== // ========================================================
@ -323,12 +501,17 @@ bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume)
MESSAGE("Warning: bad volumic element"); MESSAGE("Warning: bad volumic element");
return false; return false;
} }
} else { }
else {
switch ( myVolumeNbNodes ) { switch ( myVolumeNbNodes ) {
case 4: case 4:
case 5: case 5:
case 6: case 6:
case 8: { case 8:
case 10:
case 13:
case 15:
case 20: {
// define volume orientation // define volume orientation
XYZ botNormal; XYZ botNormal;
GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z ); GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z );
@ -387,6 +570,34 @@ void SMDS_VolumeTool::Inverse ()
SWAP_NODES( myVolumeNodes, 1, 3 ); SWAP_NODES( myVolumeNodes, 1, 3 );
SWAP_NODES( myVolumeNodes, 5, 7 ); SWAP_NODES( myVolumeNodes, 5, 7 );
break; break;
case 10:
SWAP_NODES( myVolumeNodes, 1, 2 );
SWAP_NODES( myVolumeNodes, 4, 6 );
SWAP_NODES( myVolumeNodes, 8, 9 );
break;
case 13:
SWAP_NODES( myVolumeNodes, 1, 3 );
SWAP_NODES( myVolumeNodes, 5, 8 );
SWAP_NODES( myVolumeNodes, 6, 7 );
SWAP_NODES( myVolumeNodes, 10, 12 );
break;
case 15:
SWAP_NODES( myVolumeNodes, 1, 2 );
SWAP_NODES( myVolumeNodes, 4, 5 );
SWAP_NODES( myVolumeNodes, 6, 8 );
SWAP_NODES( myVolumeNodes, 9, 11 );
SWAP_NODES( myVolumeNodes, 13, 14 );
break;
case 20:
SWAP_NODES( myVolumeNodes, 1, 3 );
SWAP_NODES( myVolumeNodes, 5, 7 );
SWAP_NODES( myVolumeNodes, 8, 11 );
SWAP_NODES( myVolumeNodes, 9, 10 );
SWAP_NODES( myVolumeNodes, 12, 15 );
SWAP_NODES( myVolumeNodes, 13, 14 );
SWAP_NODES( myVolumeNodes, 17, 19 );
break;
default:; default:;
} }
} }
@ -402,14 +613,25 @@ SMDS_VolumeTool::VolumeType SMDS_VolumeTool::GetVolumeType() const
return POLYHEDA; return POLYHEDA;
if ( myVolume ) { if ( myVolume ) {
static const VolumeType types[] = { // static const VolumeType types[] = {
TETRA, // myVolumeNbNodes = 4 // TETRA, // myVolumeNbNodes = 4
PYRAM, // myVolumeNbNodes = 5 // PYRAM, // myVolumeNbNodes = 5
PENTA, // myVolumeNbNodes = 6 // PENTA, // myVolumeNbNodes = 6
UNKNOWN, // myVolumeNbNodes = 7 // UNKNOWN, // myVolumeNbNodes = 7
HEXA // myVolumeNbNodes = 8 // HEXA // myVolumeNbNodes = 8
}; // };
return types[ myVolumeNbNodes - 4 ]; // return types[ myVolumeNbNodes - 4 ];
switch(myVolumeNbNodes) {
case 4: return TETRA; break;
case 5: return PYRAM; break;
case 6: return PENTA; break;
case 8: return HEXA; break;
case 10: return QUAD_TETRA; break;
case 13: return QUAD_PYRAM; break;
case 15: return QUAD_PENTA; break;
case 20: return QUAD_HEXA; break;
default: break;
}
} }
return UNKNOWN; return UNKNOWN;
@ -491,7 +713,7 @@ double SMDS_VolumeTool::GetSize() const
else else
{ {
const static int ind[] = { const static int ind[] = {
0, 1, 3, 6, 11 }; 0, 1, 3, 6, 11, 19, 32, 46, 66};
const static int vtab[][4] = { const static int vtab[][4] = {
// tetrahedron // tetrahedron
{ 0, 1, 2, 3 }, { 0, 1, 2, 3 },
@ -507,15 +729,80 @@ double SMDS_VolumeTool::GetSize() const
{ 4, 1, 6, 5 }, { 4, 1, 6, 5 },
{ 1, 3, 6, 2 }, { 1, 3, 6, 2 },
{ 4, 6, 3, 7 }, { 4, 6, 3, 7 },
{ 1, 4, 6, 3 } { 1, 4, 6, 3 },
// quadratic tetrahedron
{ 0, 4, 6, 7 },
{ 1, 5, 4, 8 },
{ 2, 6, 5, 9 },
{ 7, 8, 9, 3 },
{ 4, 6, 7, 9 },
{ 4, 5, 6, 9 },
{ 4, 7, 8, 9 },
{ 4, 5, 9, 8 },
// quadratic pyramid
{ 0, 5, 8, 9 },
{ 1, 5,10, 6 },
{ 2, 6,11, 7 },
{ 3, 7,12, 8 },
{ 4, 9,11,10 },
{ 4, 9,12,11 },
{ 10, 5, 9, 8 },
{ 10, 8, 9,12 },
{ 10, 8,12, 7 },
{ 10, 7,12,11 },
{ 10, 7,11, 6 },
{ 10, 5, 8, 6 },
{ 10, 6, 8, 7 },
// quadratic pentahedron
{ 12, 0, 8, 6 },
{ 12, 8, 7, 6 },
{ 12, 8, 2, 7 },
{ 12, 6, 7, 1 },
{ 12, 1, 7,13 },
{ 12, 7, 2,13 },
{ 12, 2,14,13 },
{ 12, 3, 9,11 },
{ 12,11, 9,10 },
{ 12,11,10, 5 },
{ 12, 9, 4,10 },
{ 12,14, 5,10 },
{ 12,14,10, 4 },
{ 12,14, 4,13 },
// quadratic hexahedron
{ 16, 0,11, 8 },
{ 16,11, 9, 8 },
{ 16, 8, 9, 1 },
{ 16,11, 3,10 },
{ 16,11,10, 9 },
{ 16,10, 2, 9 },
{ 16, 3,19, 2 },
{ 16, 2,19,18 },
{ 16, 2,18,17 },
{ 16, 2,17, 1 },
{ 16, 4,12,15 },
{ 16,12, 5,13 },
{ 16,12,13,15 },
{ 16,13, 6,14 },
{ 16,13,14,15 },
{ 16,14, 7,15 },
{ 16, 6, 5,17 },
{ 16,18, 6,17 },
{ 16,18, 7, 6 },
{ 16,18,19, 7 },
}; };
int type = GetVolumeType(); int type = GetVolumeType();
int n1 = ind[type]; int n1 = ind[type];
int n2 = ind[type+1]; int n2 = ind[type+1];
for (int i = n1; i < n2; i++) for (int i = n1; i < n2; i++) {
{
V -= getTetraVolume( myVolumeNodes[ vtab[i][0] ], V -= getTetraVolume( myVolumeNodes[ vtab[i][0] ],
myVolumeNodes[ vtab[i][1] ], myVolumeNodes[ vtab[i][1] ],
myVolumeNodes[ vtab[i][2] ], myVolumeNodes[ vtab[i][2] ],
@ -647,12 +934,16 @@ bool SMDS_VolumeTool::IsFaceExternal( int faceIndex )
switch ( myVolumeNbNodes ) { switch ( myVolumeNbNodes ) {
case 4: case 4:
case 5: case 5:
case 10:
case 13:
// only the bottom of a reversed tetrahedron can be internal // only the bottom of a reversed tetrahedron can be internal
return ( myVolForward || faceIndex != 0 ); return ( myVolForward || faceIndex != 0 );
case 6: case 6:
case 15:
// in a forward pentahedron, the top is internal, in a reversed one - bottom // in a forward pentahedron, the top is internal, in a reversed one - bottom
return ( myVolForward ? faceIndex != 1 : faceIndex != 0 ); return ( myVolForward ? faceIndex != 1 : faceIndex != 0 );
case 8: { case 8:
case 20: {
// in a forward hexahedron, even face normal is external, odd - internal // in a forward hexahedron, even face normal is external, odd - internal
bool odd = faceIndex % 2; bool odd = faceIndex % 2;
return ( myVolForward ? !odd : odd ); return ( myVolForward ? !odd : odd );
@ -679,7 +970,8 @@ bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, doub
XYZ aVec13( p3 - p1 ); XYZ aVec13( p3 - p1 );
XYZ cross = aVec12.Crossed( aVec13 ); XYZ cross = aVec12.Crossed( aVec13 );
if ( myFaceNbNodes == 4 ) { //if ( myFaceNbNodes == 4 ) {
if ( myFaceNbNodes >3 ) {
XYZ p4 ( myFaceNodes[3] ); XYZ p4 ( myFaceNodes[3] );
XYZ aVec14( p4 - p1 ); XYZ aVec14( p4 - p1 );
XYZ cross2 = aVec13.Crossed( aVec14 ); XYZ cross2 = aVec13.Crossed( aVec14 );
@ -815,7 +1107,7 @@ bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1,
bool SMDS_VolumeTool::IsLinked (const int theNode1Index, bool SMDS_VolumeTool::IsLinked (const int theNode1Index,
const int theNode2Index) const const int theNode2Index) const
{ {
if (myVolume->IsPoly()) { if ( myVolume->IsPoly() ) {
return IsLinked(myVolumeNodes[theNode1Index], myVolumeNodes[theNode2Index]); return IsLinked(myVolumeNodes[theNode1Index], myVolumeNodes[theNode2Index]);
} }
@ -853,6 +1145,57 @@ bool SMDS_VolumeTool::IsLinked (const int theNode1Index,
default:; default:;
} }
break; break;
case 10:
{
switch ( minInd ) {
case 0: if( maxInd==4 || maxInd==6 || maxInd==7 ) return true;
case 1: if( maxInd==4 || maxInd==5 || maxInd==8 ) return true;
case 2: if( maxInd==5 || maxInd==6 || maxInd==9 ) return true;
case 3: if( maxInd==7 || maxInd==8 || maxInd==9 ) return true;
default:;
}
break;
}
case 13:
{
switch ( minInd ) {
case 0: if( maxInd==5 || maxInd==8 || maxInd==9 ) return true;
case 1: if( maxInd==5 || maxInd==6 || maxInd==10 ) return true;
case 2: if( maxInd==6 || maxInd==7 || maxInd==11 ) return true;
case 3: if( maxInd==7 || maxInd==8 || maxInd==12 ) return true;
case 4: if( maxInd==9 || maxInd==10 || maxInd==11 || maxInd==12 ) return true;
default:;
}
break;
}
case 15:
{
switch ( minInd ) {
case 0: if( maxInd==6 || maxInd==8 || maxInd==12 ) return true;
case 1: if( maxInd==6 || maxInd==7 || maxInd==13 ) return true;
case 2: if( maxInd==7 || maxInd==8 || maxInd==14 ) return true;
case 3: if( maxInd==9 || maxInd==11 || maxInd==12 ) return true;
case 4: if( maxInd==9 || maxInd==10 || maxInd==13 ) return true;
case 5: if( maxInd==10 || maxInd==11 || maxInd==14 ) return true;
default:;
}
break;
}
case 20:
{
switch ( minInd ) {
case 0: if( maxInd==8 || maxInd==11 || maxInd==16 ) return true;
case 1: if( maxInd==8 || maxInd==9 || maxInd==17 ) return true;
case 2: if( maxInd==9 || maxInd==10 || maxInd==18 ) return true;
case 3: if( maxInd==10 || maxInd==11 || maxInd==19 ) return true;
case 4: if( maxInd==12 || maxInd==15 || maxInd==16 ) return true;
case 5: if( maxInd==12 || maxInd==13 || maxInd==17 ) return true;
case 6: if( maxInd==13 || maxInd==14 || maxInd==18 ) return true;
case 7: if( maxInd==14 || maxInd==15 || maxInd==19 ) return true;
default:;
}
break;
}
default:; default:;
} }
return false; return false;
@ -894,8 +1237,7 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
typedef map< const SMDS_MeshElement*, int > TElemIntMap; typedef map< const SMDS_MeshElement*, int > TElemIntMap;
TElemIntMap volNbShared; TElemIntMap volNbShared;
TElemIntMap::iterator vNbIt; TElemIntMap::iterator vNbIt;
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
{
const SMDS_MeshNode* n = nodes[ iNode ]; const SMDS_MeshNode* n = nodes[ iNode ];
SMDS_ElemIteratorPtr eIt = n->GetInverseElementIterator(); SMDS_ElemIteratorPtr eIt = n->GetInverseElementIterator();
while ( eIt->more() ) { while ( eIt->more() ) {
@ -903,10 +1245,12 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
if ( elem != myVolume && elem->GetType() == SMDSAbs_Volume ) { if ( elem != myVolume && elem->GetType() == SMDSAbs_Volume ) {
int nbShared = 1; int nbShared = 1;
vNbIt = volNbShared.find( elem ); vNbIt = volNbShared.find( elem );
if ( vNbIt == volNbShared.end() ) if ( vNbIt == volNbShared.end() ) {
volNbShared.insert ( TElemIntMap::value_type( elem, nbShared )); volNbShared.insert ( TElemIntMap::value_type( elem, nbShared ));
else }
else {
nbShared = ++(*vNbIt).second; nbShared = ++(*vNbIt).second;
}
if ( nbShared > maxNbShared ) if ( nbShared > maxNbShared )
maxNbShared = nbShared; maxNbShared = nbShared;
} }
@ -922,8 +1266,7 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
if ( IsFaceExternal( faceIndex )) if ( IsFaceExternal( faceIndex ))
intNormal = XYZ( -intNormal.x, -intNormal.y, -intNormal.z ); intNormal = XYZ( -intNormal.x, -intNormal.y, -intNormal.z );
XYZ p0 ( nodes[0] ), baryCenter; XYZ p0 ( nodes[0] ), baryCenter;
for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) {
{
int nbShared = (*vNbIt).second; int nbShared = (*vNbIt).second;
if ( nbShared >= 3 ) { if ( nbShared >= 3 ) {
SMDS_VolumeTool volume( (*vNbIt).first ); SMDS_VolumeTool volume( (*vNbIt).first );
@ -935,20 +1278,20 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
// remove a volume from volNbShared map // remove a volume from volNbShared map
volNbShared.erase( vNbIt ); volNbShared.erase( vNbIt );
} }
// here volNbShared contains only volumes laying on the // here volNbShared contains only volumes laying on the
// opposite side of the face // opposite side of the face
if ( volNbShared.empty() ) if ( volNbShared.empty() ) {
return free; // is free return free; // is free
}
// check if the whole area of a face is shared // check if the whole area of a face is shared
bool isShared[] = { false, false, false, false }; // 4 triangle parts of a quadrangle bool isShared[] = { false, false, false, false }; // 4 triangle parts of a quadrangle
for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) {
{
SMDS_VolumeTool volume( (*vNbIt).first ); SMDS_VolumeTool volume( (*vNbIt).first );
bool prevLinkShared = false; bool prevLinkShared = false;
int nbSharedLinks = 0; int nbSharedLinks = 0;
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
{
bool linkShared = volume.IsLinked( nodes[ iNode ], nodes[ iNode + 1] ); bool linkShared = volume.IsLinked( nodes[ iNode ], nodes[ iNode + 1] );
if ( linkShared ) if ( linkShared )
nbSharedLinks++; nbSharedLinks++;
@ -1059,7 +1402,8 @@ bool SMDS_VolumeTool::setFace( int faceIndex )
} }
myFaceNodes[ myFaceNbNodes ] = myFaceNodes[ 0 ]; // last = first myFaceNodes[ myFaceNbNodes ] = myFaceNodes[ 0 ]; // last = first
} else { }
else {
// choose face node indices // choose face node indices
switch ( myVolumeNbNodes ) { switch ( myVolumeNbNodes ) {
case 4: case 4:
@ -1090,6 +1434,34 @@ bool SMDS_VolumeTool::setFace( int faceIndex )
else else
myFaceNodeIndices = Hexa_F[ faceIndex ]; myFaceNodeIndices = Hexa_F[ faceIndex ];
break; break;
case 10:
myFaceNbNodes = QuadTetra_nbN[ faceIndex ];
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? QuadTetra_F[ faceIndex ] : QuadTetra_RE[ faceIndex ];
else
myFaceNodeIndices = myVolForward ? QuadTetra_F[ faceIndex ] : QuadTetra_R[ faceIndex ];
break;
case 13:
myFaceNbNodes = QuadPyram_nbN[ faceIndex ];
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? QuadPyram_F[ faceIndex ] : QuadPyram_RE[ faceIndex ];
else
myFaceNodeIndices = myVolForward ? QuadPyram_F[ faceIndex ] : QuadPyram_R[ faceIndex ];
break;
case 15:
myFaceNbNodes = QuadPenta_nbN[ faceIndex ];
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? QuadPenta_FE[ faceIndex ] : QuadPenta_RE[ faceIndex ];
else
myFaceNodeIndices = myVolForward ? QuadPenta_F[ faceIndex ] : QuadPenta_R[ faceIndex ];
break;
case 20:
myFaceNbNodes = QuadHexa_nbN[ faceIndex ];
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? QuadHexa_FE[ faceIndex ] : QuadHexa_RE[ faceIndex ];
else
myFaceNodeIndices = QuadHexa_F[ faceIndex ];
break;
default: default:
return false; return false;
} }
@ -1118,6 +1490,10 @@ SMDS_VolumeTool::VolumeType SMDS_VolumeTool::GetType(int nbNodes)
case 5: return PYRAM; case 5: return PYRAM;
case 6: return PENTA; case 6: return PENTA;
case 8: return HEXA; case 8: return HEXA;
case 10: return QUAD_TETRA;
case 13: return QUAD_PYRAM;
case 15: return QUAD_PENTA;
case 20: return QUAD_HEXA;
default:return UNKNOWN; default:return UNKNOWN;
} }
} }
@ -1130,10 +1506,14 @@ SMDS_VolumeTool::VolumeType SMDS_VolumeTool::GetType(int nbNodes)
int SMDS_VolumeTool::NbFaces( VolumeType type ) int SMDS_VolumeTool::NbFaces( VolumeType type )
{ {
switch ( type ) { switch ( type ) {
case TETRA: return 4; case TETRA :
case PYRAM: return 5; case QUAD_TETRA: return 4;
case PENTA: return 5; case PYRAM :
case HEXA : return 6; case QUAD_PYRAM: return 5;
case PENTA :
case QUAD_PENTA: return 5;
case HEXA :
case QUAD_HEXA : return 6;
default: return 0; default: return 0;
} }
} }
@ -1155,6 +1535,10 @@ const int* SMDS_VolumeTool::GetFaceNodesIndices(VolumeType type,
case PYRAM: return Pyramid_F[ faceIndex ]; case PYRAM: return Pyramid_F[ faceIndex ];
case PENTA: return external ? Penta_FE[ faceIndex ] : Penta_F[ faceIndex ]; case PENTA: return external ? Penta_FE[ faceIndex ] : Penta_F[ faceIndex ];
case HEXA: return external ? Hexa_FE[ faceIndex ] : Hexa_F[ faceIndex ]; case HEXA: return external ? Hexa_FE[ faceIndex ] : Hexa_F[ faceIndex ];
case QUAD_TETRA: return QuadTetra_F[ faceIndex ];
case QUAD_PYRAM: return QuadPyram_F[ faceIndex ];
case QUAD_PENTA: return external ? QuadPenta_FE[ faceIndex ] : QuadPenta_F[ faceIndex ];
case QUAD_HEXA: return external ? QuadHexa_FE[ faceIndex ] : QuadHexa_F[ faceIndex ];
default:; default:;
} }
return 0; return 0;
@ -1173,6 +1557,10 @@ int SMDS_VolumeTool::NbFaceNodes(VolumeType type,
case PYRAM: return Pyramid_nbN[ faceIndex ]; case PYRAM: return Pyramid_nbN[ faceIndex ];
case PENTA: return Penta_nbN[ faceIndex ]; case PENTA: return Penta_nbN[ faceIndex ];
case HEXA: return Hexa_nbN[ faceIndex ]; case HEXA: return Hexa_nbN[ faceIndex ];
case QUAD_TETRA: return QuadTetra_nbN[ faceIndex ];
case QUAD_PYRAM: return QuadPyram_nbN[ faceIndex ];
case QUAD_PENTA: return QuadPenta_nbN[ faceIndex ];
case QUAD_HEXA: return QuadHexa_nbN[ faceIndex ];
default:; default:;
} }
return 0; return 0;

View File

@ -61,7 +61,8 @@ class SMDS_WNT_EXPORT SMDS_VolumeTool
{ {
public: public:
enum VolumeType { UNKNOWN = -1, TETRA = 0, PYRAM, PENTA, HEXA, POLYHEDA }; enum VolumeType { UNKNOWN = -1, TETRA = 0, PYRAM, PENTA, HEXA, QUAD_TETRA,
QUAD_PYRAM, QUAD_PENTA, QUAD_HEXA, POLYHEDA };
SMDS_VolumeTool (); SMDS_VolumeTool ();
~SMDS_VolumeTool (); ~SMDS_VolumeTool ();

View File

@ -39,6 +39,7 @@ EXPORT_HEADERS= \
SMESH_Mesh.hxx \ SMESH_Mesh.hxx \
SMESH_subMesh.hxx \ SMESH_subMesh.hxx \
SMESH_Hypothesis.hxx \ SMESH_Hypothesis.hxx \
SMESH_HypoFilter.hxx \
SMESH_Algo.hxx \ SMESH_Algo.hxx \
SMESH_1D_Algo.hxx \ SMESH_1D_Algo.hxx \
SMESH_2D_Algo.hxx \ SMESH_2D_Algo.hxx \

View File

@ -29,7 +29,7 @@
using namespace std; using namespace std;
#include "SMESH_2D_Algo.hxx" #include "SMESH_2D_Algo.hxx"
#include "SMESH_Gen.hxx" #include "SMESH_Gen.hxx"
#include "SMESH_subMesh.hxx" #include <TopExp.hxx>
#include "utilities.h" #include "utilities.h"
@ -80,13 +80,14 @@ int SMESH_2D_Algo::NumberOfWires(const TopoDS_Shape& S)
int SMESH_2D_Algo::NumberOfPoints(SMESH_Mesh& aMesh, const TopoDS_Wire& W) int SMESH_2D_Algo::NumberOfPoints(SMESH_Mesh& aMesh, const TopoDS_Wire& W)
{ {
int nbPoints = 0; int nbPoints = 0;
for (TopExp_Explorer exp(W,TopAbs_EDGE); exp.More(); exp.Next()) for (TopExp_Explorer exp(W,TopAbs_EDGE); exp.More(); exp.Next()) {
{ const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
const TopoDS_Edge& E = TopoDS::Edge(exp.Current()); int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); if(_quadraticMesh)
//SCRUTE(nb); nb = nb/2;
nbPoints += nb +1; // internal points plus 1 vertex of 2 (last point ?) nbPoints += nb + 1; // internal points plus 1 vertex of 2 (last point ?)
} }
//SCRUTE(nbPoints);
return nbPoints; return nbPoints;
} }

View File

@ -30,7 +30,8 @@
#define _SMESH_2D_ALGO_HXX_ #define _SMESH_2D_ALGO_HXX_
#include "SMESH_Algo.hxx" #include "SMESH_Algo.hxx"
#include <TopoDS_Wire.hxx> #include "SMESH_subMesh.hxx"
#include "TopoDS_Wire.hxx"
class SMESH_2D_Algo: class SMESH_2D_Algo:
public SMESH_Algo public SMESH_Algo
@ -41,6 +42,7 @@ public:
int NumberOfWires(const TopoDS_Shape& S); int NumberOfWires(const TopoDS_Shape& S);
int NumberOfPoints(SMESH_Mesh& aMesh,const TopoDS_Wire& W); int NumberOfPoints(SMESH_Mesh& aMesh,const TopoDS_Wire& W);
}; };
#endif #endif

View File

@ -29,7 +29,6 @@
using namespace std; using namespace std;
#include "SMESH_3D_Algo.hxx" #include "SMESH_3D_Algo.hxx"
#include "SMESH_Gen.hxx" #include "SMESH_Gen.hxx"
#include "SMESH_subMesh.hxx"
#include "utilities.h" #include "utilities.h"
@ -56,3 +55,5 @@ SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen)
SMESH_3D_Algo::~SMESH_3D_Algo() SMESH_3D_Algo::~SMESH_3D_Algo()
{ {
} }

View File

@ -37,6 +37,7 @@ class SMESH_3D_Algo:
public: public:
SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen); SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen);
virtual ~SMESH_3D_Algo(); virtual ~SMESH_3D_Algo();
}; };
#endif #endif

View File

@ -69,6 +69,7 @@ SMESH_Algo::SMESH_Algo(int hypId, int studyId,
gen->_mapAlgo[hypId] = this; gen->_mapAlgo[hypId] = this;
_onlyUnaryInput = _requireDescretBoundary = true; _onlyUnaryInput = _requireDescretBoundary = true;
_quadraticMesh = false;
} }
//============================================================================= //=============================================================================
@ -102,18 +103,17 @@ const vector < string > &SMESH_Algo::GetCompatibleHypothesis()
*/ */
//============================================================================= //=============================================================================
const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis( const list <const SMESHDS_Hypothesis *> &
SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) SMESH_Algo::GetUsedHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool ignoreAuxiliary)
{ {
_usedHypList.clear(); _usedHypList.clear();
if ( !_compatibleHypothesis.empty() ) SMESH_HypoFilter filter;
if ( InitCompatibleHypoFilter( filter, ignoreAuxiliary ))
{ {
SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( _compatibleHypothesis[0] ));
for ( int i = 1; i < _compatibleHypothesis.size(); ++i )
filter.Or( filter.HasName( _compatibleHypothesis[ i ] ));
aMesh.GetHypotheses( aShape, filter, _usedHypList, true ); aMesh.GetHypotheses( aShape, filter, _usedHypList, true );
if ( _usedHypList.size() > 1 ) if ( ignoreAuxiliary && _usedHypList.size() > 1 )
_usedHypList.clear(); //only one compatible hypothesis allowed _usedHypList.clear(); //only one compatible hypothesis allowed
} }
return _usedHypList; return _usedHypList;
@ -127,18 +127,16 @@ const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis(
*/ */
//============================================================================= //=============================================================================
const list<const SMESHDS_Hypothesis *> & SMESH_Algo::GetAppliedHypothesis( const list<const SMESHDS_Hypothesis *> &
SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool ignoreAuxiliary)
{ {
_appliedHypList.clear(); _appliedHypList.clear();
if ( !_compatibleHypothesis.empty() ) SMESH_HypoFilter filter;
{ if ( InitCompatibleHypoFilter( filter, ignoreAuxiliary ))
SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( _compatibleHypothesis[0] ));
for ( int i = 1; i < _compatibleHypothesis.size(); ++i )
filter.Or( filter.HasName( _compatibleHypothesis[ i ] ));
aMesh.GetHypotheses( aShape, filter, _appliedHypList, false ); aMesh.GetHypotheses( aShape, filter, _appliedHypList, false );
}
return _appliedHypList; return _appliedHypList;
} }
@ -344,3 +342,28 @@ bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
return theParams.size() > 1; return theParams.size() > 1;
} }
//================================================================================
/*!
* \brief Make filter recognize only compatible hypotheses
* \param theFilter - the filter to initialize
* \param ignoreAuxiliary - make filter ignore compatible auxiliary hypotheses
*/
//================================================================================
bool SMESH_Algo::InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
const bool ignoreAuxiliary) const
{
if ( !_compatibleHypothesis.empty() )
{
theFilter.Init( theFilter.HasName( _compatibleHypothesis[0] ));
for ( int i = 1; i < _compatibleHypothesis.size(); ++i )
theFilter.Or( theFilter.HasName( _compatibleHypothesis[ i ] ));
if ( ignoreAuxiliary )
theFilter.AndNot( theFilter.IsAuxiliary() );
return true;
}
return false;
}

View File

@ -33,16 +33,20 @@
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <gp_XY.hxx>
#include <string> #include <string>
#include <vector> #include <vector>
#include <list> #include <list>
#include <map>
class SMESH_Gen; class SMESH_Gen;
class SMESH_Mesh; class SMESH_Mesh;
class SMESH_HypoFilter;
class TopoDS_Face; class TopoDS_Face;
class TopoDS_Shape; class TopoDS_Shape;
class SMESHDS_Mesh; class SMESHDS_Mesh;
class SMDS_MeshNode;
class SMESH_Algo:public SMESH_Hypothesis class SMESH_Algo:public SMESH_Hypothesis
{ {
@ -58,13 +62,27 @@ class SMESH_Algo:public SMESH_Hypothesis
virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0; virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0;
virtual const std::list <const SMESHDS_Hypothesis *> & virtual const std::list <const SMESHDS_Hypothesis *> &
GetUsedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); GetUsedHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool ignoreAuxiliary=true);
const list <const SMESHDS_Hypothesis *> & const list <const SMESHDS_Hypothesis *> &
GetAppliedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); GetAppliedHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool ignoreAuxiliary=true);
static double EdgeLength(const TopoDS_Edge & E); static double EdgeLength(const TopoDS_Edge & E);
/*!
* \brief Make filter recognize only compatible hypotheses
* \param theFilter - the filter to initialize
* \param ignoreAuxiliary - make filter ignore compatible auxiliary hypotheses
* \retval bool - true if the algo has compatible hypotheses
*/
bool InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
const bool ignoreAuxiliary) const;
/*! /*!
* \brief Fill vector of node parameters on geometrical edge, including vertex nodes * \brief Fill vector of node parameters on geometrical edge, including vertex nodes
* \param theMesh - The mesh containing nodes * \param theMesh - The mesh containing nodes
@ -121,6 +139,9 @@ class SMESH_Algo:public SMESH_Hypothesis
std::vector<std::string> _compatibleHypothesis; std::vector<std::string> _compatibleHypothesis;
std::list<const SMESHDS_Hypothesis *> _appliedHypList; std::list<const SMESHDS_Hypothesis *> _appliedHypList;
std::list<const SMESHDS_Hypothesis *> _usedHypList; std::list<const SMESHDS_Hypothesis *> _usedHypList;
// quadratic mesh creation required
bool _quadraticMesh;
}; };
#endif #endif

View File

@ -102,33 +102,24 @@ SMESH_Gen::~SMESH_Gen()
*/ */
//============================================================================= //=============================================================================
SMESH_Mesh* SMESH_Gen::CreateMesh(int studyId) SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
throw(SALOME_Exception) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
MESSAGE("SMESH_Gen::CreateMesh"); MESSAGE("SMESH_Gen::CreateMesh");
// if (aShape.ShapeType() == TopAbs_COMPOUND)
// {
// INFOS("Mesh Compound not yet implemented!");
// throw(SALOME_Exception(LOCALIZED("Mesh Compound not yet implemented!")));
// }
// Get studyContext, create it if it does'nt exist, with a SMESHDS_Document // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
StudyContextStruct *aStudyContext = GetStudyContext(theStudyId);
StudyContextStruct *myStudyContext = GetStudyContext(studyId); // create a new SMESH_mesh object
SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
theStudyId,
this,
theIsEmbeddedMode,
aStudyContext->myDocument);
aStudyContext->mapMesh[_localId] = aMesh;
// create a new SMESH_mesh object return aMesh;
SMESH_Mesh *mesh = new SMESH_Mesh(_localId++,
studyId,
this,
myStudyContext->myDocument);
myStudyContext->mapMesh[_localId] = mesh;
// associate a TopoDS_Shape to the mesh
//mesh->ShapeToMesh(aShape);
return mesh;
} }
//============================================================================= //=============================================================================
@ -633,13 +624,14 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
if ( algoList.empty() ) if ( algoList.empty() )
return NULL; return NULL;
if (algoList.size() > 1 ) { // check if there is one algo several times // Now it is checked in SMESH_Mesh::GetHypotheses()
list <const SMESHDS_Hypothesis * >::iterator algo = algoList.begin(); // if (algoList.size() > 1 ) { // check if there is one algo several times
for ( ; algo != algoList.end(); ++algo ) // list <const SMESHDS_Hypothesis * >::iterator algo = algoList.begin();
if ( (*algo) != algoList.front() && // for ( ; algo != algoList.end(); ++algo )
(*algo)->GetName() != algoList.front()->GetName() ) // if ( (*algo) != algoList.front() &&
return NULL; // (*algo)->GetName() != algoList.front()->GetName() )
} // return NULL;
// }
return const_cast<SMESH_Algo*> ( static_cast<const SMESH_Algo* >( algoList.front() )); return const_cast<SMESH_Algo*> ( static_cast<const SMESH_Algo* >( algoList.front() ));
} }
@ -702,37 +694,20 @@ void SMESH_Gen::Close(int studyId)
int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType) int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType)
{ {
int shapeDim = -1; // Shape dimension: 0D, 1D, 2D, 3D static vector<int> dim;
int type = aShapeType;//.ShapeType(); if ( dim.empty() )
switch (type) {
{ dim.resize( TopAbs_SHAPE, -1 );
case TopAbs_COMPOUND: dim[ TopAbs_COMPOUND ] = 3;
case TopAbs_COMPSOLID: dim[ TopAbs_COMPSOLID ] = 3;
case TopAbs_SOLID: dim[ TopAbs_SOLID ] = 3;
case TopAbs_SHELL: dim[ TopAbs_SHELL ] = 3;
{ dim[ TopAbs_FACE ] = 2;
shapeDim = 3; dim[ TopAbs_WIRE ] = 1;
break; dim[ TopAbs_EDGE ] = 1;
} dim[ TopAbs_VERTEX ] = 0;
// case TopAbs_SHELL: }
case TopAbs_FACE: return dim[ aShapeType ];
{
shapeDim = 2;
break;
}
case TopAbs_WIRE:
case TopAbs_EDGE:
{
shapeDim = 1;
break;
}
case TopAbs_VERTEX:
{
shapeDim = 0;
break;
}
}
return shapeDim;
} }
//============================================================================= //=============================================================================

View File

@ -60,7 +60,7 @@ class SMESH_Gen
// SMESH_Hypothesis *CreateHypothesis(const char *anHyp, int studyId) // SMESH_Hypothesis *CreateHypothesis(const char *anHyp, int studyId)
// throw(SALOME_Exception); // throw(SALOME_Exception);
SMESH_Mesh* CreateMesh(int studyId) SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode)
throw(SALOME_Exception); throw(SALOME_Exception);
bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);

View File

@ -53,6 +53,9 @@ class SMESH_Group
SMESHDS_GroupBase * GetGroupDS () { return myGroupDS; } SMESHDS_GroupBase * GetGroupDS () { return myGroupDS; }
void SetColorNumber (int theColorNumber) { myColorNumber = theColorNumber; }
int GetColorNumber() const { return myColorNumber; }
private: private:
SMESH_Group (const SMESH_Group& theOther); SMESH_Group (const SMESH_Group& theOther);
// prohibited copy constructor // prohibited copy constructor
@ -61,7 +64,7 @@ class SMESH_Group
SMESHDS_GroupBase * myGroupDS; SMESHDS_GroupBase * myGroupDS;
std::string myName; std::string myName;
int myColorNumber;
}; };
#endif #endif

View File

@ -75,6 +75,17 @@ bool SMESH_HypoFilter::ApplicablePredicate::IsOk(const SMESH_Hypothesis* aHyp,
return SMESH_subMesh::IsApplicableHypotesis( aHyp, (TopAbs_ShapeEnum)_shapeType ); return SMESH_subMesh::IsApplicableHypotesis( aHyp, (TopAbs_ShapeEnum)_shapeType );
}; };
//=======================================================================
//function : IsAuxiliaryPredicate::IsOk
//purpose :
//=======================================================================
bool SMESH_HypoFilter::IsAuxiliaryPredicate::IsOk(const SMESH_Hypothesis* aHyp,
const TopoDS_Shape& /*aShape*/) const
{
return aHyp->IsAuxiliary();
};
//======================================================================= //=======================================================================
//function : ApplicablePredicate::ApplicablePredicate //function : ApplicablePredicate::ApplicablePredicate
//purpose : //purpose :
@ -190,6 +201,17 @@ SMESH_HypoPredicate* SMESH_HypoFilter::IsAlgo()
return new TypePredicate( MORE, SMESHDS_Hypothesis::PARAM_ALGO ); return new TypePredicate( MORE, SMESHDS_Hypothesis::PARAM_ALGO );
} }
//=======================================================================
//function : IsAuxiliary
//purpose :
//=======================================================================
SMESH_HypoPredicate* SMESH_HypoFilter::IsAuxiliary()
{
return new IsAuxiliaryPredicate();
}
//======================================================================= //=======================================================================
//function : IsGlobal //function : IsGlobal
//purpose : //purpose :
@ -287,6 +309,7 @@ SMESH_HypoFilter & SMESH_HypoFilter::Init ( SMESH_HypoPredicate* aPredicate, bo
list<SMESH_HypoPredicate*>::const_iterator pred = myPredicates.begin(); list<SMESH_HypoPredicate*>::const_iterator pred = myPredicates.begin();
for ( ; pred != myPredicates.end(); ++pred ) for ( ; pred != myPredicates.end(); ++pred )
delete *pred; delete *pred;
myPredicates.clear();
add( notNagate ? AND : AND_NOT, aPredicate ); add( notNagate ? AND : AND_NOT, aPredicate );
return *this; return *this;

View File

@ -67,6 +67,7 @@ class SMESH_HypoFilter: public SMESH_HypoPredicate
// Create predicates // Create predicates
static SMESH_HypoPredicate* IsAlgo(); static SMESH_HypoPredicate* IsAlgo();
static SMESH_HypoPredicate* IsAuxiliary();
static SMESH_HypoPredicate* IsApplicableTo(const TopoDS_Shape& theShape); static SMESH_HypoPredicate* IsApplicableTo(const TopoDS_Shape& theShape);
static SMESH_HypoPredicate* IsAssignedTo(const TopoDS_Shape& theShape); static SMESH_HypoPredicate* IsAssignedTo(const TopoDS_Shape& theShape);
static SMESH_HypoPredicate* Is(const SMESH_Hypothesis* theHypo); static SMESH_HypoPredicate* Is(const SMESH_Hypothesis* theHypo);
@ -158,6 +159,11 @@ class SMESH_HypoFilter: public SMESH_HypoPredicate
const TopoDS_Shape& aShape) const; const TopoDS_Shape& aShape) const;
}; };
struct IsAuxiliaryPredicate : public SMESH_HypoPredicate {
bool IsOk(const SMESH_Hypothesis* aHyp,
const TopoDS_Shape& aShape) const;
};
}; };

View File

@ -72,13 +72,14 @@ SMESH_Hypothesis::~SMESH_Hypothesis()
int SMESH_Hypothesis::GetDim() const int SMESH_Hypothesis::GetDim() const
{ {
int dim = -1; int dim = 0;
switch (_type) switch (_type)
{ {
case ALGO_1D: dim = 1; break; case ALGO_1D: dim = 1; break;
case ALGO_2D: dim = 2; break; case ALGO_2D: dim = 2; break;
case ALGO_3D: dim = 3; break; case ALGO_3D: dim = 3; break;
case PARAM_ALGO: dim = _param_algo_dim; break; case PARAM_ALGO:
dim = ( _param_algo_dim < 0 ) ? -_param_algo_dim : _param_algo_dim; break;
} }
return dim; return dim;
} }
@ -124,14 +125,15 @@ void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
itm++) itm++)
{ {
SMESH_Mesh* mesh = (*itm).second; SMESH_Mesh* mesh = (*itm).second;
const list<SMESH_subMesh*>& subMeshes = mesh->NotifySubMeshesHypothesisModification( this );
mesh->GetSubMeshUsingHypothesis(this); // const list<SMESH_subMesh*>& subMeshes =
// mesh->GetSubMeshUsingHypothesis(this);
//for all subMeshes using hypothesis // //for all subMeshes using hypothesis
list<SMESH_subMesh*>::const_iterator its; // list<SMESH_subMesh*>::const_iterator its;
for (its = subMeshes.begin(); its != subMeshes.end(); its++) // for (its = subMeshes.begin(); its != subMeshes.end(); its++)
(*its)->ComputeStateEngine(SMESH_subMesh::MODIF_HYP); // (*its)->ComputeStateEngine(SMESH_subMesh::MODIF_HYP);
} }
} }

View File

@ -49,18 +49,19 @@ public:
HYP_INCOMPATIBLE, // hypothesis does not fit algo HYP_INCOMPATIBLE, // hypothesis does not fit algo
HYP_NOTCONFORM, // not conform mesh is produced appling a hypothesis HYP_NOTCONFORM, // not conform mesh is produced appling a hypothesis
HYP_ALREADY_EXIST,// such hypothesis already exist HYP_ALREADY_EXIST,// such hypothesis already exist
HYP_BAD_DIM // bad dimension HYP_BAD_DIM, // bad dimension
HYP_BAD_SUBSHAPE // shape is neither the main one, nor its subshape, nor a group
}; };
static bool IsStatusFatal(Hypothesis_Status theStatus) static bool IsStatusFatal(Hypothesis_Status theStatus)
{ return theStatus >= HYP_UNKNOWN_FATAL; } { return theStatus >= HYP_UNKNOWN_FATAL; }
SMESH_Hypothesis(int hypId, int studyId, SMESH_Gen* gen); SMESH_Hypothesis(int hypId, int studyId, SMESH_Gen* gen);
virtual ~SMESH_Hypothesis(); virtual ~SMESH_Hypothesis();
int GetDim() const; virtual int GetDim() const;
int GetStudyId() const; int GetStudyId() const;
void NotifySubMeshesHypothesisModification(); virtual void NotifySubMeshesHypothesisModification();
int GetShapeType() const; virtual int GetShapeType() const;
const char* GetLibName() const; virtual const char* GetLibName() const;
void SetLibName(const char* theLibName); void SetLibName(const char* theLibName);
/*! /*!
@ -71,6 +72,17 @@ public:
*/ */
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape)=0; virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape)=0;
/*!
* \brief Return true if me is an auxiliary hypothesis
* \retval bool - auxiliary or not
*
* An auxiliary hypothesis is optional, i.e. an algorithm
* can work without it and another hypothesis of the same
* dimention can be assigned to the shape
*/
virtual bool IsAuxiliary() const
{ return GetType() == PARAM_ALGO && _param_algo_dim <= 0; }
protected: protected:
SMESH_Gen* _gen; SMESH_Gen* _gen;
int _studyId; int _studyId;

View File

@ -63,6 +63,9 @@
#include "Utils_ExceptHandlers.hxx" #include "Utils_ExceptHandlers.hxx"
// maximum stored group name length in MED file
#define MAX_MED_GROUP_NAME_LENGTH 80
#ifdef _DEBUG_ #ifdef _DEBUG_
static int MYDEBUG = 0; static int MYDEBUG = 0;
#else #else
@ -76,17 +79,21 @@ static int MYDEBUG = 0;
*/ */
//============================================================================= //=============================================================================
SMESH_Mesh::SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESHDS_Document * myDocument) SMESH_Mesh::SMESH_Mesh(int theLocalId,
: _groupId( 0 ) int theStudyId,
SMESH_Gen* theGen,
bool theIsEmbeddedMode,
SMESHDS_Document* theDocument):
_groupId( 0 )
{ {
INFOS("SMESH_Mesh::SMESH_Mesh(int localId)"); INFOS("SMESH_Mesh::SMESH_Mesh(int localId)");
_id = localId; _id = theLocalId;
_studyId = studyId; _studyId = theStudyId;
_gen = gen; _gen = theGen;
_myDocument = myDocument; _myDocument = theDocument;
_idDoc = _myDocument->NewMesh(); _idDoc = theDocument->NewMesh(theIsEmbeddedMode);
_myMeshDS = _myDocument->GetMesh(_idDoc); _myMeshDS = theDocument->GetMesh(_idDoc);
_isShapeToMesh = false; _isShapeToMesh = false;
} }
//============================================================================= //=============================================================================
@ -149,7 +156,7 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape)
// fill _mapAncestors // fill _mapAncestors
_mapAncestors.Clear(); _mapAncestors.Clear();
int desType, ancType; int desType, ancType;
for ( desType = TopAbs_EDGE; desType > TopAbs_COMPOUND; desType-- ) for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- )
for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- ) for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
TopExp::MapShapesAndAncestors ( aShape, TopExp::MapShapesAndAncestors ( aShape,
(TopAbs_ShapeEnum) desType, (TopAbs_ShapeEnum) desType,
@ -267,6 +274,9 @@ SMESH_Hypothesis::Hypothesis_Status
if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis"); if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis");
SMESH_subMesh *subMesh = GetSubMesh(aSubShape); SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
if ( !subMesh || !subMesh->GetId())
return SMESH_Hypothesis::HYP_BAD_SUBSHAPE;
SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS(); SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
if ( subMeshDS && subMeshDS->IsComplexSubmesh() ) // group of sub-shapes and maybe of not sub- if ( subMeshDS && subMeshDS->IsComplexSubmesh() ) // group of sub-shapes and maybe of not sub-
{ {
@ -520,45 +530,62 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS
//purpose : //purpose :
//======================================================================= //=======================================================================
bool SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape, //================================================================================
const SMESH_HypoFilter& aFilter, /*!
list <const SMESHDS_Hypothesis * >& aHypList, * \brief Return hypothesis assigned to the shape
const bool andAncestors) const * \param aSubShape - the shape to check
* \param aFilter - the hypothesis filter
* \param aHypList - the list of the found hypotheses
* \param andAncestors - flag to check hypos assigned to ancestors of the shape
* \retval int - number of unique hypos in aHypList
*/
//================================================================================
int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
const SMESH_HypoFilter& aFilter,
list <const SMESHDS_Hypothesis * >& aHypList,
const bool andAncestors) const
{ {
int nbHyp = 0; set<string> hypTypes; // to exclude same type hypos from the result list
int nbHyps = 0;
// fill in hypTypes
list<const SMESHDS_Hypothesis*>::const_iterator hyp;
for ( hyp = aHypList.begin(); hyp != aHypList.end(); hyp++ )
if ( hypTypes.insert( (*hyp)->GetName() ).second )
nbHyps++;
// get hypos from aSubShape
{ {
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape); const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin(); for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
for ( ; hyp != hypList.end(); hyp++ ) if ( aFilter.IsOk (static_cast<const SMESH_Hypothesis*>( *hyp ), aSubShape) &&
if ( aFilter.IsOk (static_cast<const SMESH_Hypothesis*>( *hyp ), aSubShape)) { hypTypes.insert( (*hyp)->GetName() ).second )
{
aHypList.push_back( *hyp ); aHypList.push_back( *hyp );
nbHyp++; nbHyps++;
} }
} }
// get hypos from shape of one type only: if any hypo is found on edge, do
// not look up on faces // get hypos from ancestors of aSubShape
if ( !nbHyp && andAncestors ) if ( andAncestors )
{ {
TopTools_MapOfShape map; TopTools_MapOfShape map;
TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape )); TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
int shapeType = it.More() ? it.Value().ShapeType() : TopAbs_SHAPE;
for (; it.More(); it.Next() ) for (; it.More(); it.Next() )
{ {
if ( nbHyp && shapeType != it.Value().ShapeType() ) if ( !map.Add( it.Value() ))
break;
shapeType = it.Value().ShapeType();
if ( !map.Add( it.Value() ))
continue; continue;
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value()); const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin(); for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
for ( ; hyp != hypList.end(); hyp++ ) if (aFilter.IsOk( static_cast<const SMESH_Hypothesis*>( *hyp ), it.Value() ) &&
if (aFilter.IsOk( static_cast<const SMESH_Hypothesis*>( *hyp ), it.Value() )) { hypTypes.insert( (*hyp)->GetName() ).second ) {
aHypList.push_back( *hyp ); aHypList.push_back( *hyp );
nbHyp++; nbHyps++;
} }
} }
} }
return nbHyp; return nbHyps;
} }
//============================================================================= //=============================================================================
@ -616,7 +643,7 @@ SMESH_Gen *SMESH_Mesh::GetGen()
//============================================================================= //=============================================================================
SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape) SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
throw(SALOME_Exception) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
SMESH_subMesh *aSubMesh; SMESH_subMesh *aSubMesh;
@ -628,16 +655,19 @@ throw(SALOME_Exception)
if ( it.More() ) if ( it.More() )
index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() ); index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() );
} }
// if ( !index )
// return NULL; // neither sub-shape nor a group
if (_mapSubMesh.find(index) != _mapSubMesh.end()) map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(index);
{ if ( i_sm != _mapSubMesh.end())
aSubMesh = _mapSubMesh[index]; {
} aSubMesh = i_sm->second;
}
else else
{ {
aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape); aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
_mapSubMesh[index] = aSubMesh; _mapSubMesh[index] = aSubMesh;
} }
return aSubMesh; return aSubMesh;
} }
@ -649,20 +679,17 @@ throw(SALOME_Exception)
//============================================================================= //=============================================================================
SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape) SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
throw(SALOME_Exception) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
bool isFound = false;
SMESH_subMesh *aSubMesh = NULL; SMESH_subMesh *aSubMesh = NULL;
int index = _myMeshDS->ShapeToIndex(aSubShape); int index = _myMeshDS->ShapeToIndex(aSubShape);
if (_mapSubMesh.find(index) != _mapSubMesh.end())
{ map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(index);
aSubMesh = _mapSubMesh[index]; if ( i_sm != _mapSubMesh.end())
isFound = true; aSubMesh = i_sm->second;
}
if (!isFound)
aSubMesh = NULL;
return aSubMesh; return aSubMesh;
} }
@ -690,15 +717,17 @@ throw(SALOME_Exception)
//======================================================================= //=======================================================================
bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
const TopoDS_Shape & aSubShape) const SMESH_subMesh* aSubMesh)
{ {
SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp); SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp);
// check if anHyp is applicable to aSubShape
SMESH_subMesh * subMesh = GetSubMeshContaining( aSubShape ); // check if anHyp can be used to mesh aSubMesh
if ( !subMesh || !subMesh->IsApplicableHypotesis( hyp )) if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
return false; return false;
SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape); const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape();
SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );
// algorithm // algorithm
if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO) if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
@ -708,17 +737,19 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
if (algo) if (algo)
{ {
// look trough hypotheses used by algo // look trough hypotheses used by algo
const list <const SMESHDS_Hypothesis * >&usedHyps = SMESH_HypoFilter hypoKind;
algo->GetUsedHypothesis(*this, aSubShape); if ( algo->InitCompatibleHypoFilter( hypoKind, !hyp->IsAuxiliary() )) {
return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() ); list <const SMESHDS_Hypothesis * > usedHyps;
if ( GetHypotheses( aSubShape, hypoKind, usedHyps, true ))
return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() );
}
} }
// look through all assigned hypotheses // look through all assigned hypotheses
SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp )); //SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp ));
return GetHypothesis( aSubShape, filter, true ); return false; //GetHypothesis( aSubShape, filter, true );
} }
//============================================================================= //=============================================================================
/*! /*!
* *
@ -726,28 +757,100 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
//============================================================================= //=============================================================================
const list < SMESH_subMesh * >& const list < SMESH_subMesh * >&
SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
throw(SALOME_Exception) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis"); if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
map < int, SMESH_subMesh * >::iterator itsm; map < int, SMESH_subMesh * >::iterator itsm;
_subMeshesUsingHypothesisList.clear(); _subMeshesUsingHypothesisList.clear();
for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++) for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
{ {
SMESH_subMesh *aSubMesh = (*itsm).second; SMESH_subMesh *aSubMesh = (*itsm).second;
if ( IsUsedHypothesis ( anHyp, aSubMesh->GetSubShape() )) if ( IsUsedHypothesis ( anHyp, aSubMesh ))
_subMeshesUsingHypothesisList.push_back(aSubMesh); _subMeshesUsingHypothesisList.push_back(aSubMesh);
} }
return _subMeshesUsingHypothesisList; return _subMeshesUsingHypothesisList;
}
//=======================================================================
//function : NotifySubMeshesHypothesisModification
//purpose : Say all submeshes using theChangedHyp that it has been modified
//=======================================================================
void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp)
{
Unexpect aCatch(SalomeException);
const SMESH_Hypothesis* hyp = static_cast<const SMESH_Hypothesis*>(theChangedHyp);
const SMESH_Algo *foundAlgo = 0;
SMESH_HypoFilter algoKind( SMESH_HypoFilter::IsAlgo() );
SMESH_HypoFilter compatibleHypoKind;
list <const SMESHDS_Hypothesis * > usedHyps;
map < int, SMESH_subMesh * >::iterator itsm;
for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
{
SMESH_subMesh *aSubMesh = (*itsm).second;
if ( aSubMesh->IsApplicableHypotesis( hyp ))
{
const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
if ( !foundAlgo ) // init filter for algo search
algoKind.And( algoKind.IsApplicableTo( aSubShape ));
const SMESH_Algo *algo = static_cast<const SMESH_Algo*>
( GetHypothesis( aSubShape, algoKind, true ));
if ( algo )
{
bool sameAlgo = ( algo == foundAlgo );
if ( !sameAlgo && foundAlgo )
sameAlgo = ( strcmp( algo->GetName(), foundAlgo->GetName() ) == 0);
if ( !sameAlgo ) { // init filter for used hypos search
if ( !algo->InitCompatibleHypoFilter( compatibleHypoKind, !hyp->IsAuxiliary() ))
continue; // algo does not use any hypothesis
foundAlgo = algo;
}
// check if hyp is used by algo
usedHyps.clear();
if ( GetHypotheses( aSubShape, compatibleHypoKind, usedHyps, true ) &&
find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
{
aSubMesh->ComputeStateEngine(SMESH_subMesh::MODIF_HYP);
if ( algo->GetDim() == 1 && IsPropagationHypothesis( aSubShape ))
CleanMeshOnPropagationChain( aSubShape );
}
}
}
}
} }
//============================================================================= //=============================================================================
/*! /*! Export* methods.
* * To store mesh contents on disk in different formats.
*/ */
//============================================================================= //=============================================================================
bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
{
set<string> aGroupNames;
for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
SMESH_Group* aGroup = it->second;
string aGroupName = aGroup->GetName();
aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
if (!aGroupNames.insert(aGroupName).second)
return true;
}
return false;
}
void SMESH_Mesh::ExportMED(const char *file, void SMESH_Mesh::ExportMED(const char *file,
const char* theMeshName, const char* theMeshName,
bool theAutoGroups, bool theAutoGroups,
@ -755,6 +858,7 @@ void SMESH_Mesh::ExportMED(const char *file,
throw(SALOME_Exception) throw(SALOME_Exception)
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
DriverMED_W_SMESHDS_Mesh myWriter; DriverMED_W_SMESHDS_Mesh myWriter;
myWriter.SetFile ( file, MED::EVersion(theVersion) ); myWriter.SetFile ( file, MED::EVersion(theVersion) );
myWriter.SetMesh ( _myMeshDS ); myWriter.SetMesh ( _myMeshDS );
@ -772,15 +876,28 @@ void SMESH_Mesh::ExportMED(const char *file,
myWriter.AddGroupOfVolumes(); myWriter.AddGroupOfVolumes();
} }
// Pass groups to writer. Provide unique group names.
set<string> aGroupNames;
char aString [256];
int maxNbIter = 10000; // to guarantee cycle finish
for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) { for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
SMESH_Group* aGroup = it->second; SMESH_Group* aGroup = it->second;
SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS(); SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
if ( aGroupDS ) { if ( aGroupDS ) {
aGroupDS->SetStoreName( aGroup->GetName() ); string aGroupName0 = aGroup->GetName();
aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
string aGroupName = aGroupName0;
for (int i = 1; !aGroupNames.insert(aGroupName).second && i < maxNbIter; i++) {
sprintf(&aString[0], "GR_%d_%s", i, aGroupName0.c_str());
aGroupName = aString;
aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
}
aGroupDS->SetStoreName( aGroupName.c_str() );
myWriter.AddGroup( aGroupDS ); myWriter.AddGroup( aGroupDS );
} }
} }
// Perform export
myWriter.Perform(); myWriter.Perform();
} }
@ -861,7 +978,8 @@ int SMESH_Mesh::NbTriangles() throw(SALOME_Exception)
const SMDS_MeshFace * curFace; const SMDS_MeshFace * curFace;
while (itFaces->more()) { while (itFaces->more()) {
curFace = itFaces->next(); curFace = itFaces->next();
if (!curFace->IsPoly() && curFace->NbNodes() == 3) Nb++; if ( !curFace->IsPoly() &&
( curFace->NbNodes()==3 || curFace->NbNodes()==6 ) ) Nb++;
} }
return Nb; return Nb;
} }
@ -879,7 +997,8 @@ int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
const SMDS_MeshFace * curFace; const SMDS_MeshFace * curFace;
while (itFaces->more()) { while (itFaces->more()) {
curFace = itFaces->next(); curFace = itFaces->next();
if (!curFace->IsPoly() && curFace->NbNodes() == 4) Nb++; if ( !curFace->IsPoly() &&
( curFace->NbNodes() == 4 || curFace->NbNodes()==8 ) ) Nb++;
} }
return Nb; return Nb;
} }
@ -917,7 +1036,8 @@ int SMESH_Mesh::NbTetras() throw(SALOME_Exception)
const SMDS_MeshVolume * curVolume; const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) { while (itVolumes->more()) {
curVolume = itVolumes->next(); curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 4) Nb++; if ( !curVolume->IsPoly() &&
( curVolume->NbNodes() == 4 || curVolume->NbNodes()==10 ) ) Nb++;
} }
return Nb; return Nb;
} }
@ -931,7 +1051,8 @@ int SMESH_Mesh::NbHexas() throw(SALOME_Exception)
const SMDS_MeshVolume * curVolume; const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) { while (itVolumes->more()) {
curVolume = itVolumes->next(); curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 8) Nb++; if ( !curVolume->IsPoly() &&
( curVolume->NbNodes() == 8 || curVolume->NbNodes()==20 ) ) Nb++;
} }
return Nb; return Nb;
} }
@ -945,7 +1066,8 @@ int SMESH_Mesh::NbPyramids() throw(SALOME_Exception)
const SMDS_MeshVolume * curVolume; const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) { while (itVolumes->more()) {
curVolume = itVolumes->next(); curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 5) Nb++; if ( !curVolume->IsPoly() &&
( curVolume->NbNodes() == 5 || curVolume->NbNodes()==13 ) ) Nb++;
} }
return Nb; return Nb;
} }
@ -959,7 +1081,8 @@ int SMESH_Mesh::NbPrisms() throw(SALOME_Exception)
const SMDS_MeshVolume * curVolume; const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) { while (itVolumes->more()) {
curVolume = itVolumes->next(); curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 6) Nb++; if ( !curVolume->IsPoly() &&
( curVolume->NbNodes() == 6 || curVolume->NbNodes()==15 ) ) Nb++;
} }
return Nb; return Nb;
} }
@ -1152,7 +1275,7 @@ void SMESH_Mesh::CleanMeshOnPropagationChain (const TopoDS_Shape& theMainEdge)
SMESH_subMesh *subMesh = GetSubMesh(anEdge); SMESH_subMesh *subMesh = GetSubMesh(anEdge);
SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS(); SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
if (subMeshDS && subMeshDS->NbElements() > 0) { if (subMeshDS && subMeshDS->NbElements() > 0) {
subMesh->ComputeStateEngine(SMESH_subMesh::CLEANDEP); subMesh->ComputeStateEngine(SMESH_subMesh::CLEAN);
} }
} }
} }

View File

@ -79,8 +79,11 @@ class SMESH_Mesh
SMESH_Mesh(); SMESH_Mesh();
SMESH_Mesh(const SMESH_Mesh&); SMESH_Mesh(const SMESH_Mesh&);
public: public:
SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESH_Mesh(int theLocalId,
SMESHDS_Document * myDocument); int theStudyId,
SMESH_Gen* theGen,
bool theIsEmbeddedMode,
SMESHDS_Document* theDocument);
virtual ~SMESH_Mesh(); virtual ~SMESH_Mesh();
@ -110,10 +113,10 @@ public:
const SMESH_HypoFilter& aFilter, const SMESH_HypoFilter& aFilter,
const bool andAncestors) const; const bool andAncestors) const;
bool GetHypotheses(const TopoDS_Shape & aSubShape, int GetHypotheses(const TopoDS_Shape & aSubShape,
const SMESH_HypoFilter& aFilter, const SMESH_HypoFilter& aFilter,
list <const SMESHDS_Hypothesis * >& aHypList, list <const SMESHDS_Hypothesis * >& aHypList,
const bool andAncestors) const; const bool andAncestors) const;
const list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception); const list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
@ -134,12 +137,15 @@ public:
SMESH_subMesh *GetSubMeshContaining(const int aShapeID) SMESH_subMesh *GetSubMeshContaining(const int aShapeID)
throw(SALOME_Exception); throw(SALOME_Exception);
void NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp);
// Say all submeshes that theChangedHyp has been modified
const list < SMESH_subMesh * >& const list < SMESH_subMesh * >&
GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
throw(SALOME_Exception); throw(SALOME_Exception);
bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
const TopoDS_Shape & aSubShape); const SMESH_subMesh * aSubMesh);
// Return True if anHyp is used to mesh aSubShape // Return True if anHyp is used to mesh aSubShape
bool IsNotConformAllowed() const; bool IsNotConformAllowed() const;
@ -151,6 +157,11 @@ public:
// return list of ancestors of theSubShape in the order // return list of ancestors of theSubShape in the order
// that lower dimention shapes come first. // that lower dimention shapes come first.
/*! Check group names for duplications.
* Consider maximum group name length stored in MED file.
*/
bool HasDuplicatedGroupNamesMED();
void ExportMED(const char *file, void ExportMED(const char *file,
const char* theMeshName = NULL, const char* theMeshName = NULL,
bool theAutoGroups = true, bool theAutoGroups = true,

File diff suppressed because it is too large Load Diff

View File

@ -364,6 +364,15 @@ class SMESH_MeshEditor {
// - not in avoidSet, // - not in avoidSet,
// - in elemSet provided that !elemSet.empty() // - in elemSet provided that !elemSet.empty()
/*!
* \brief Returns true if given node is medium
* \param n - node to check
* \param typeToCheck - type of elements containing the node to ask about node status
* \retval bool - check result
*/
static bool IsMedium(const SMDS_MeshNode* node,
const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
int FindShape (const SMDS_MeshElement * theElem); int FindShape (const SMDS_MeshElement * theElem);
// Return an index of the shape theElem is on // Return an index of the shape theElem is on
// or zero if a shape not found // or zero if a shape not found

View File

@ -3505,7 +3505,7 @@ void SMESH_Pattern::clearMesh(SMESH_Mesh* theMesh) const
{ {
if ( SMESH_subMesh * aSubMesh = theMesh->GetSubMesh/*Containing*/( myShape )) if ( SMESH_subMesh * aSubMesh = theMesh->GetSubMesh/*Containing*/( myShape ))
{ {
aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEANDEP ); aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEAN );
} }
else { else {
SMESHDS_Mesh* aMeshDS = theMesh->GetMeshDS(); SMESHDS_Mesh* aMeshDS = theMesh->GetMeshDS();

View File

@ -53,6 +53,9 @@ using namespace std;
#include <TopTools_IndexedMapOfShape.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#endif #endif
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
//============================================================================= //=============================================================================
/*! /*!
* default constructor: * default constructor:
@ -76,8 +79,8 @@ SMESH_subMesh::SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
} }
else else
{ {
_algoState = NO_ALGO; _algoState = NO_ALGO;
_computeState = NOT_READY; _computeState = NOT_READY;
} }
} }
@ -89,8 +92,8 @@ SMESH_subMesh::SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
SMESH_subMesh::~SMESH_subMesh() SMESH_subMesh::~SMESH_subMesh()
{ {
MESSAGE("SMESH_subMesh::~SMESH_subMesh"); MESSAGE("SMESH_subMesh::~SMESH_subMesh");
// **** // ****
} }
//============================================================================= //=============================================================================
@ -101,8 +104,8 @@ SMESH_subMesh::~SMESH_subMesh()
int SMESH_subMesh::GetId() const int SMESH_subMesh::GetId() const
{ {
//MESSAGE("SMESH_subMesh::GetId"); //MESSAGE("SMESH_subMesh::GetId");
return _Id; return _Id;
} }
//============================================================================= //=============================================================================
@ -113,19 +116,16 @@ int SMESH_subMesh::GetId() const
SMESHDS_SubMesh * SMESH_subMesh::GetSubMeshDS() SMESHDS_SubMesh * SMESH_subMesh::GetSubMeshDS()
{ {
//MESSAGE("SMESH_subMesh::GetSubMeshDS"); // submesh appears in DS only when a mesher set nodes and elements on it
if (_subMeshDS==NULL) if (_subMeshDS==NULL)
{ {
//MESSAGE("subMesh pointer still null, trying to get it..."); _subMeshDS = _meshDS->MeshElements(_subShape); // may be null ...
_subMeshDS = _meshDS->MeshElements(_subShape); // may be null ... // if (_subMeshDS==NULL)
if (_subMeshDS==NULL) // {
{ // MESSAGE("problem... subMesh still empty");
MESSAGE("problem... subMesh still empty"); // }
//NRI ASSERT(0); }
//NRI throw SALOME_Exception(LOCALIZED(subMesh still empty)); return _subMeshDS;
}
}
return _subMeshDS;
} }
//============================================================================= //=============================================================================
@ -150,7 +150,6 @@ SMESHDS_SubMesh* SMESH_subMesh::CreateSubMeshDS()
SMESH_subMesh *SMESH_subMesh::GetFirstToCompute() SMESH_subMesh *SMESH_subMesh::GetFirstToCompute()
{ {
//MESSAGE("SMESH_subMesh::GetFirstToCompute");
const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
SMESH_subMesh *firstToCompute = 0; SMESH_subMesh *firstToCompute = 0;
@ -158,13 +157,10 @@ SMESH_subMesh *SMESH_subMesh::GetFirstToCompute()
for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
{ {
SMESH_subMesh *sm = (*itsub).second; SMESH_subMesh *sm = (*itsub).second;
// SCRUTE(sm->GetId());
// SCRUTE(sm->GetComputeState());
bool readyToCompute = (sm->GetComputeState() == READY_TO_COMPUTE); bool readyToCompute = (sm->GetComputeState() == READY_TO_COMPUTE);
if (readyToCompute) if (readyToCompute)
{ {
firstToCompute = sm; firstToCompute = sm;
//SCRUTE(sm->GetId());
break; break;
} }
} }
@ -423,20 +419,12 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid
int cle = aSubMesh->GetId(); int cle = aSubMesh->GetId();
cle += 10000000 * ordType; // sort map by ordType then index cle += 10000000 * ordType; // sort map by ordType then index
if (_mapDepend.find(cle) == _mapDepend.end()) if ( _mapDepend.find( cle ) == _mapDepend.end())
{ {
_mapDepend[cle] = aSubMesh; _mapDepend[cle] = aSubMesh;
const map < int, SMESH_subMesh * >&subMap = aSubMesh->DependsOn(); const map < int, SMESH_subMesh * > & subMap = aSubMesh->DependsOn();
map < int, SMESH_subMesh * >::const_iterator im; _mapDepend.insert( subMap.begin(), subMap.end() );
for (im = subMap.begin(); im != subMap.end(); im++)
{
int clesub = (*im).first;
SMESH_subMesh *sm = (*im).second;
if (_mapDepend.find(clesub) == _mapDepend.end())
_mapDepend[clesub] = sm;
}
} }
} }
//============================================================================= //=============================================================================
@ -445,7 +433,7 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
*/ */
//============================================================================= //=============================================================================
const TopoDS_Shape & SMESH_subMesh::GetSubShape() const TopoDS_Shape & SMESH_subMesh::GetSubShape() const
{ {
//MESSAGE("SMESH_subMesh::GetSubShape"); //MESSAGE("SMESH_subMesh::GetSubShape");
return _subShape; return _subShape;
@ -483,20 +471,18 @@ bool SMESH_subMesh::IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis,
return ( theHypothesis->GetShapeType() & (1<< theShapeType)); return ( theHypothesis->GetShapeType() & (1<< theShapeType));
// hypothesis // hypothesis
int aShapeDim = 100;
switch ( theShapeType ) { switch ( theShapeType ) {
case TopAbs_EDGE: aShapeDim = 1; break; case TopAbs_EDGE:
case TopAbs_FACE: aShapeDim = 2; break; case TopAbs_FACE:
case TopAbs_SHELL:aShapeDim = 3; break; case TopAbs_SHELL:
case TopAbs_SOLID:aShapeDim = 3; break; case TopAbs_SOLID:
// case TopAbs_VERTEX: return SMESH_Gen::GetShapeDim( theShapeType ) == theHypothesis->GetDim();
// case TopAbs_WIRE: // case TopAbs_WIRE:
// case TopAbs_COMPSOLID: // case TopAbs_COMPSOLID:
// case TopAbs_COMPOUND: // case TopAbs_COMPOUND:
default: return false; default:;
} }
return false;
return ( theHypothesis->GetDim() == aShapeDim );
} }
//============================================================================= //=============================================================================
@ -554,7 +540,7 @@ SMESH_Hypothesis::Hypothesis_Status
if ( ! CanAddHypothesis( anHyp )) if ( ! CanAddHypothesis( anHyp ))
return SMESH_Hypothesis::HYP_BAD_DIM; return SMESH_Hypothesis::HYP_BAD_DIM;
if ( GetSimilarAttached( _subShape, anHyp ) ) if ( /*!anHyp->IsAuxiliary() &&*/ GetSimilarAttached( _subShape, anHyp ) )
return SMESH_Hypothesis::HYP_ALREADY_EXIST; return SMESH_Hypothesis::HYP_ALREADY_EXIST;
if ( !_meshDS->AddHypothesis(_subShape, anHyp)) if ( !_meshDS->AddHypothesis(_subShape, anHyp))
@ -563,9 +549,9 @@ SMESH_Hypothesis::Hypothesis_Status
// Serve Propagation of 1D hypothesis // Serve Propagation of 1D hypothesis
if (event == ADD_HYP) { if (event == ADD_HYP) {
bool isPropagationOk = true; bool isPropagationOk = true;
string hypName = anHyp->GetName(); bool isPropagationHyp = ( strcmp( "Propagation", anHyp->GetName() ) == 0 );
if (hypName == "Propagation") { if ( isPropagationHyp ) {
TopExp_Explorer exp (_subShape, TopAbs_EDGE); TopExp_Explorer exp (_subShape, TopAbs_EDGE);
TopTools_MapOfShape aMap; TopTools_MapOfShape aMap;
for (; exp.More(); exp.Next()) { for (; exp.More(); exp.Next()) {
@ -593,7 +579,11 @@ SMESH_Hypothesis::Hypothesis_Status
} else { } else {
} }
if (!isPropagationOk && ret < SMESH_Hypothesis::HYP_CONCURENT) { if ( isPropagationOk ) {
if ( isPropagationHyp )
return ret; // nothing more to do for "Propagation" hypothesis
}
else if ( ret < SMESH_Hypothesis::HYP_CONCURENT) {
ret = SMESH_Hypothesis::HYP_CONCURENT; ret = SMESH_Hypothesis::HYP_CONCURENT;
} }
} // Serve Propagation of 1D hypothesis } // Serve Propagation of 1D hypothesis
@ -612,7 +602,9 @@ SMESH_Hypothesis::Hypothesis_Status
{ {
bool isPropagationOk = true; bool isPropagationOk = true;
SMESH_HypoFilter propagFilter( SMESH_HypoFilter::HasName( "Propagation" )); SMESH_HypoFilter propagFilter( SMESH_HypoFilter::HasName( "Propagation" ));
if ( propagFilter.IsOk( anHyp, _subShape )) bool isPropagationHyp = propagFilter.IsOk( anHyp, _subShape );
if ( isPropagationHyp )
{ {
TopExp_Explorer exp (_subShape, TopAbs_EDGE); TopExp_Explorer exp (_subShape, TopAbs_EDGE);
TopTools_MapOfShape aMap; TopTools_MapOfShape aMap;
@ -634,7 +626,11 @@ SMESH_Hypothesis::Hypothesis_Status
isPropagationOk = _father->RebuildPropagationChains(); isPropagationOk = _father->RebuildPropagationChains();
} }
if (!isPropagationOk && ret < SMESH_Hypothesis::HYP_CONCURENT) { if ( isPropagationOk ) {
if ( isPropagationHyp )
return ret; // nothing more to do for "Propagation" hypothesis
}
else if ( ret < SMESH_Hypothesis::HYP_CONCURENT) {
ret = SMESH_Hypothesis::HYP_CONCURENT; ret = SMESH_Hypothesis::HYP_CONCURENT;
} }
} // Serve Propagation of 1D hypothesis } // Serve Propagation of 1D hypothesis
@ -712,7 +708,7 @@ SMESH_Hypothesis::Hypothesis_Status
SetAlgoState(HYP_OK); SetAlgoState(HYP_OK);
if (SMESH_Hypothesis::IsStatusFatal( ret )) if (SMESH_Hypothesis::IsStatusFatal( ret ))
_meshDS->RemoveHypothesis(_subShape, anHyp); _meshDS->RemoveHypothesis(_subShape, anHyp);
else if (!_father->IsUsedHypothesis( anHyp, _subShape )) else if (!_father->IsUsedHypothesis( anHyp, this ))
{ {
_meshDS->RemoveHypothesis(_subShape, anHyp); _meshDS->RemoveHypothesis(_subShape, anHyp);
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
@ -802,7 +798,7 @@ SMESH_Hypothesis::Hypothesis_Status
// ret should be fatal: anHyp was not added // ret should be fatal: anHyp was not added
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
} }
else if (!_father->IsUsedHypothesis( anHyp, _subShape )) else if (!_father->IsUsedHypothesis( anHyp, this ))
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
if (SMESH_Hypothesis::IsStatusFatal( ret )) if (SMESH_Hypothesis::IsStatusFatal( ret ))
@ -866,7 +862,7 @@ SMESH_Hypothesis::Hypothesis_Status
ASSERT(algo); ASSERT(algo);
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
{ {
if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp if (_father->IsUsedHypothesis( anHyp, this )) // new Hyp
modifiedHyp = true; modifiedHyp = true;
} }
else else
@ -1000,9 +996,7 @@ bool SMESH_subMesh::IsConform(const SMESH_Algo* theAlgo)
void SMESH_subMesh::SetAlgoState(int state) void SMESH_subMesh::SetAlgoState(int state)
{ {
// if (state != _oldAlgoState) _algoState = state;
// int retc = ComputeStateEngine(MODIF_ALGO_STATE);
_algoState = state;
} }
//============================================================================= //=============================================================================
@ -1018,7 +1012,7 @@ SMESH_Hypothesis::Hypothesis_Status
SMESH_Hypothesis::Hypothesis_Status ret = SMESH_Hypothesis::HYP_OK; SMESH_Hypothesis::Hypothesis_Status ret = SMESH_Hypothesis::HYP_OK;
//EAP: a wire (dim==1) should notify edges (dim==1) //EAP: a wire (dim==1) should notify edges (dim==1)
//EAP: int dim = SMESH_Gen::GetShapeDim(_subShape); //EAP: int dim = SMESH_Gen::GetShapeDim(_subShape);
if (/*EAP:dim > 1*/ _subShape.ShapeType() < TopAbs_EDGE ) if (_subShape.ShapeType() < TopAbs_EDGE ) // wire,face etc
{ {
const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
@ -1043,18 +1037,18 @@ SMESH_Hypothesis::Hypothesis_Status
void SMESH_subMesh::CleanDependsOn() void SMESH_subMesh::CleanDependsOn()
{ {
MESSAGE("SMESH_subMesh::CleanDependsOn"); //MESSAGE("SMESH_subMesh::CleanDependsOn");
// **** parcourir les ancetres dans l'ordre de dépendance // **** parcourir les ancetres dans l'ordre de dépendance
ComputeStateEngine(CLEAN); ComputeStateEngine(CLEAN);
const map < int, SMESH_subMesh * >&dependson = DependsOn(); const map < int, SMESH_subMesh * >&dependson = DependsOn();
map < int, SMESH_subMesh * >::const_iterator its; map < int, SMESH_subMesh * >::const_iterator its;
for (its = dependson.begin(); its != dependson.end(); its++) for (its = dependson.begin(); its != dependson.end(); its++)
{ {
SMESH_subMesh *sm = (*its).second; SMESH_subMesh *sm = (*its).second;
sm->ComputeStateEngine(CLEAN); sm->ComputeStateEngine(CLEAN);
} }
} }
//============================================================================= //=============================================================================
@ -1109,31 +1103,33 @@ void SMESH_subMesh::DumpAlgoState(bool isMain)
} }
} }
//============================================================================= //================================================================================
/*! /*!
* * \brief Remove nodes and elements bound to submesh
* \param subMesh - submesh containing nodes and elements
*/ */
//============================================================================= //================================================================================
static void removeSubMesh( SMESHDS_Mesh * meshDS, const TopoDS_Shape& subShape) static void cleanSubMesh( SMESH_subMesh * subMesh )
{ {
SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(subShape); if (subMesh) {
if (subMeshDS!=NULL) if (SMESHDS_SubMesh * subMeshDS = subMesh->GetSubMeshDS()) {
{ SMESHDS_Mesh * meshDS = subMesh->GetFather()->GetMeshDS();
SMDS_ElemIteratorPtr ite=subMeshDS->GetElements(); SMDS_ElemIteratorPtr ite = subMeshDS->GetElements();
while(ite->more()) while (ite->more()) {
{ const SMDS_MeshElement * elt = ite->next();
const SMDS_MeshElement * elt = ite->next(); //MESSAGE( " RM elt: "<<elt->GetID()<<" ( "<<elt->NbNodes()<<" )" );
//MESSAGE( " RM elt: "<<elt->GetID()<<" ( "<<elt->NbNodes()<<" )" ); //meshDS->RemoveElement(elt);
meshDS->RemoveElement(elt); meshDS->RemoveFreeElement(elt, subMeshDS);
} }
SMDS_NodeIteratorPtr itn=subMeshDS->GetNodes(); SMDS_NodeIteratorPtr itn = subMeshDS->GetNodes();
while(itn->more()) while (itn->more()) {
{ const SMDS_MeshNode * node = itn->next();
const SMDS_MeshNode * node = itn->next(); //MESSAGE( " RM node: "<<node->GetID());
//MESSAGE( " RM node: "<<node->GetID()); //meshDS->RemoveNode(node);
meshDS->RemoveNode(node); meshDS->RemoveFreeNode(node, subMeshDS);
}
} }
} }
} }
@ -1181,13 +1177,11 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
_computeState = READY_TO_COMPUTE; _computeState = READY_TO_COMPUTE;
} }
break; break;
case COMPUTE: // nothing to do case COMPUTE: // nothing to do
break; break;
case CLEAN: case CLEAN:
RemoveSubMeshElementsAndNodes();
break;
case CLEANDEP:
CleanDependants(); CleanDependants();
RemoveSubMeshElementsAndNodes();
break; break;
case SUBMESH_COMPUTED: // nothing to do case SUBMESH_COMPUTED: // nothing to do
break; break;
@ -1245,13 +1239,17 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
} }
// compute // compute
CleanDependants(); CleanDependants();
//RemoveSubMeshElementsAndNodes(); RemoveSubMeshElementsAndNodes();
//removeSubMesh( _meshDS, _subShape ); try {
if (!algo->NeedDescretBoundary() && !algo->OnlyUnaryInput()) if (!algo->NeedDescretBoundary() && !algo->OnlyUnaryInput())
ret = ApplyToCollection( algo, GetCollection( gen, algo ) ); ret = ApplyToCollection( algo, GetCollection( gen, algo ) );
else else
ret = algo->Compute((*_father), _subShape); ret = algo->Compute((*_father), _subShape);
}
catch (Standard_Failure) {
MESSAGE( "Exception in algo->Compute() ");
ret = false;
}
if (!ret) if (!ret)
{ {
MESSAGE("problem in algo execution: failed to compute"); MESSAGE("problem in algo execution: failed to compute");
@ -1280,6 +1278,7 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
} }
break; break;
case CLEAN: case CLEAN:
CleanDependants();
RemoveSubMeshElementsAndNodes(); RemoveSubMeshElementsAndNodes();
_computeState = NOT_READY; _computeState = NOT_READY;
algo = gen->GetAlgo((*_father), _subShape); algo = gen->GetAlgo((*_father), _subShape);
@ -1290,9 +1289,6 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
_computeState = READY_TO_COMPUTE; _computeState = READY_TO_COMPUTE;
} }
break; break;
case CLEANDEP:
CleanDependants();
break;
case SUBMESH_COMPUTED: // nothing to do case SUBMESH_COMPUTED: // nothing to do
break; break;
case SUBMESH_RESTORED: case SUBMESH_RESTORED:
@ -1319,20 +1315,16 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
switch (event) switch (event)
{ {
case MODIF_HYP: case MODIF_HYP:
CleanDependants(); // recursive recall with event CLEANDEP
algo = gen->GetAlgo((*_father), _subShape);
if (algo && !algo->NeedDescretBoundary())
CleanDependsOn(); // remove sub-mesh with event CLEANDEP
break;
case MODIF_ALGO_STATE: case MODIF_ALGO_STATE:
CleanDependants(); // recursive recall with event CLEANDEP ComputeStateEngine( CLEAN );
algo = gen->GetAlgo((*_father), _subShape); algo = gen->GetAlgo((*_father), _subShape);
if (algo && !algo->NeedDescretBoundary()) if (algo && !algo->NeedDescretBoundary())
CleanDependsOn(); // remove sub-mesh with event CLEANDEP CleanDependsOn(); // clean sub-meshes with event CLEAN
break; break;
case COMPUTE: // nothing to do case COMPUTE: // nothing to do
break; break;
case CLEAN: case CLEAN:
CleanDependants(); // clean sub-meshes, dependant on this one, with event CLEAN
RemoveSubMeshElementsAndNodes(); RemoveSubMeshElementsAndNodes();
_computeState = NOT_READY; _computeState = NOT_READY;
algo = gen->GetAlgo((*_father), _subShape); algo = gen->GetAlgo((*_father), _subShape);
@ -1343,9 +1335,6 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
_computeState = READY_TO_COMPUTE; _computeState = READY_TO_COMPUTE;
} }
break; break;
case CLEANDEP:
CleanDependants(); // recursive recall with event CLEANDEP
break;
case SUBMESH_COMPUTED: // nothing to do case SUBMESH_COMPUTED: // nothing to do
break; break;
case SUBMESH_RESTORED: case SUBMESH_RESTORED:
@ -1390,15 +1379,13 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
case COMPUTE: // nothing to do case COMPUTE: // nothing to do
break; break;
case CLEAN: case CLEAN:
CleanDependants(); // submeshes dependent on me should be cleaned as well
RemoveSubMeshElementsAndNodes(); RemoveSubMeshElementsAndNodes();
if (_algoState == HYP_OK) if (_algoState == HYP_OK)
_computeState = READY_TO_COMPUTE; _computeState = READY_TO_COMPUTE;
else else
_computeState = NOT_READY; _computeState = NOT_READY;
break; break;
case CLEANDEP:
CleanDependants();
break;
case SUBMESH_COMPUTED: // allow retry compute case SUBMESH_COMPUTED: // allow retry compute
if (_algoState == HYP_OK) if (_algoState == HYP_OK)
_computeState = READY_TO_COMPUTE; _computeState = READY_TO_COMPUTE;
@ -1534,19 +1521,22 @@ void SMESH_subMesh::UpdateDependantsState(const compute_event theEvent)
void SMESH_subMesh::CleanDependants() void SMESH_subMesh::CleanDependants()
{ {
int dimToClean = SMESH_Gen::GetShapeDim( _subShape ) + 1;
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
for (; it.More(); it.Next()) for (; it.More(); it.Next())
{ {
const TopoDS_Shape& ancestor = it.Value(); const TopoDS_Shape& ancestor = it.Value();
// PAL8021. do not go upper than SOLID, else ComputeStateEngine(CLEANDEP) if ( SMESH_Gen::GetShapeDim( ancestor ) == dimToClean ) {
// will erase mesh on other shapes in a compound // PAL8021. do not go upper than SOLID, else ComputeStateEngine(CLEAN)
if ( ancestor.ShapeType() >= TopAbs_SOLID ) { // will erase mesh on other shapes in a compound
SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor); if ( ancestor.ShapeType() >= TopAbs_SOLID ) {
if (aSubMesh) SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor);
aSubMesh->ComputeStateEngine(CLEANDEP); if (aSubMesh)
aSubMesh->ComputeStateEngine(CLEAN);
}
} }
} }
ComputeStateEngine(CLEAN);
} }
//============================================================================= //=============================================================================
@ -1559,22 +1549,23 @@ void SMESH_subMesh::RemoveSubMeshElementsAndNodes()
{ {
//SCRUTE(_subShape.ShapeType()); //SCRUTE(_subShape.ShapeType());
removeSubMesh( _meshDS, _subShape ); cleanSubMesh( this );
// algo may bind a submesh not to _subShape, eg 3D algo // algo may bind a submesh not to _subShape, eg 3D algo
// sets nodes on SHELL while _subShape may be SOLID // sets nodes on SHELL while _subShape may be SOLID
int dim = SMESH_Gen::GetShapeDim( _subShape ); int dim = SMESH_Gen::GetShapeDim( _subShape );
int type = _subShape.ShapeType() + 1; int type = _subShape.ShapeType() + 1;
for ( ; type <= TopAbs_EDGE; type++) for ( ; type <= TopAbs_EDGE; type++) {
if ( dim == SMESH_Gen::GetShapeDim( (TopAbs_ShapeEnum) type )) if ( dim == SMESH_Gen::GetShapeDim( (TopAbs_ShapeEnum) type ))
{ {
TopExp_Explorer exp( _subShape, (TopAbs_ShapeEnum) type ); TopExp_Explorer exp( _subShape, (TopAbs_ShapeEnum) type );
for ( ; exp.More(); exp.Next() ) for ( ; exp.More(); exp.Next() )
removeSubMesh( _meshDS, exp.Current() ); cleanSubMesh( _father->GetSubMeshContaining( exp.Current() ));
} }
else else
break; break;
}
} }
//======================================================================= //=======================================================================
@ -1626,8 +1617,9 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg
if ( mainShape.IsSame( _subShape )) if ( mainShape.IsSame( _subShape ))
return _subShape; return _subShape;
const bool ignoreAuxiliaryHyps = false;
list<const SMESHDS_Hypothesis*> aUsedHyp = list<const SMESHDS_Hypothesis*> aUsedHyp =
theAlgo->GetUsedHypothesis( *_father, _subShape ); // copy theAlgo->GetUsedHypothesis( *_father, _subShape, ignoreAuxiliaryHyps ); // copy
// put in a compound all shapes with the same hypothesis assigned // put in a compound all shapes with the same hypothesis assigned
// and a good ComputState // and a good ComputState
@ -1645,7 +1637,7 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg
if (subMesh->GetComputeState() == READY_TO_COMPUTE && if (subMesh->GetComputeState() == READY_TO_COMPUTE &&
anAlgo == theAlgo && anAlgo == theAlgo &&
anAlgo->GetUsedHypothesis( *_father, S ) == aUsedHyp) anAlgo->GetUsedHypothesis( *_father, S, ignoreAuxiliaryHyps ) == aUsedHyp)
{ {
aBuilder.Add( aCompound, S ); aBuilder.Add( aCompound, S );
} }
@ -1656,26 +1648,31 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg
//======================================================================= //=======================================================================
//function : GetSimilarAttached //function : GetSimilarAttached
//purpose : return nb of hypotheses attached to theShape. //purpose : return a hypothesis attached to theShape.
// If theHyp is provided, similar but not same hypotheses // If theHyp is provided, similar but not same hypotheses
// are countered; else only applicable ones having theHypType // is returned; else only applicable ones having theHypType
// are countered // is returned
//======================================================================= //=======================================================================
const SMESH_Hypothesis* SMESH_subMesh::GetSimilarAttached(const TopoDS_Shape& theShape, const SMESH_Hypothesis* SMESH_subMesh::GetSimilarAttached(const TopoDS_Shape& theShape,
const SMESH_Hypothesis * theHyp, const SMESH_Hypothesis * theHyp,
const int theHypType) const int theHypType)
{ {
SMESH_HypoFilter filter; SMESH_HypoFilter hypoKind;
filter.Init( SMESH_HypoFilter::HasType( theHyp ? theHyp->GetType() : theHypType )); hypoKind.Init( hypoKind.HasType( theHyp ? theHyp->GetType() : theHypType ));
if ( theHyp ) { if ( theHyp ) {
filter.And( SMESH_HypoFilter::HasDim( theHyp->GetDim() )); hypoKind.And ( hypoKind.HasDim( theHyp->GetDim() ));
filter.AndNot( SMESH_HypoFilter::Is( theHyp )); hypoKind.AndNot( hypoKind.Is( theHyp ));
if ( theHyp->IsAuxiliary() )
hypoKind.And( hypoKind.HasName( theHyp->GetName() ));
else
hypoKind.AndNot( hypoKind.IsAuxiliary());
}
else {
hypoKind.And( hypoKind.IsApplicableTo( theShape ));
} }
else
filter.And( SMESH_HypoFilter::IsApplicableTo( theShape ));
return _father->GetHypothesis( theShape, filter, false ); return _father->GetHypothesis( theShape, hypoKind, false );
} }
//======================================================================= //=======================================================================

View File

@ -70,7 +70,7 @@ class SMESH_subMesh
const map < int, SMESH_subMesh * >&DependsOn(); const map < int, SMESH_subMesh * >&DependsOn();
//const map < int, SMESH_subMesh * >&Dependants(); //const map < int, SMESH_subMesh * >&Dependants();
const TopoDS_Shape & GetSubShape(); const TopoDS_Shape & GetSubShape() const;
// bool _vertexSet; // only for vertex subMesh, set to false for dim > 0 // bool _vertexSet; // only for vertex subMesh, set to false for dim > 0
@ -93,7 +93,7 @@ class SMESH_subMesh
enum compute_event enum compute_event
{ {
MODIF_HYP, MODIF_ALGO_STATE, COMPUTE, MODIF_HYP, MODIF_ALGO_STATE, COMPUTE,
CLEAN, CLEANDEP, SUBMESH_COMPUTED, SUBMESH_RESTORED, CLEAN, SUBMESH_COMPUTED, SUBMESH_RESTORED,
MESH_ENTITY_REMOVED, CHECK_COMPUTE_STATE MESH_ENTITY_REMOVED, CHECK_COMPUTE_STATE
}; };
@ -103,17 +103,13 @@ class SMESH_subMesh
SMESH_Hypothesis::Hypothesis_Status SMESH_Hypothesis::Hypothesis_Status
SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp); SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
int GetAlgoState() { return _algoState; } int GetAlgoState() const { return _algoState; }
int GetComputeState() const { return _computeState; };
void DumpAlgoState(bool isMain); void DumpAlgoState(bool isMain);
bool ComputeStateEngine(int event); bool ComputeStateEngine(int event);
int GetComputeState()
{
return _computeState;
};
bool IsConform(const SMESH_Algo* theAlgo); bool IsConform(const SMESH_Algo* theAlgo);
// check if a conform mesh will be produced by the Algo // check if a conform mesh will be produced by the Algo

View File

@ -0,0 +1,97 @@
# GEOM GEOMClient : tool to transfer BREP files from GEOM server to GEOM client
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Author : Pavel TELKOV (OCC)
# Module : SHESM
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl
@COMMENCE@
# header files
EXPORT_HEADERS = \
SMESH_Client.hxx
# Libraries targets
LIB = libSMESHClient.la
LIB_SRC = SMESH_Client.cxx
LIB_CLIENT_IDL = SALOME_Comm.idl \
SALOME_Component.idl \
SALOMEDS.idl \
SALOMEDS_Attributes.idl \
SALOME_Exception.idl \
SALOME_GenericObj.idl \
SMESH_Mesh.idl \
SMESH_Gen.idl \
SMESH_Group.idl \
SMESH_Hypothesis.idl \
SMESH_Pattern.idl \
SMESH_Filter.idl \
GEOM_Gen.idl \
MED.idl
# Executables targets
BIN = SMESHClientBin
BIN_SRC =
BIN_CLIENT_IDL =
BIN_SERVER_IDL =
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS += $(OCC_KERNEL_LIBS) \
-L${KERNEL_ROOT_DIR}/lib/salome \
-L${GEOM_ROOT_DIR}/lib/salome \
-L${MED_ROOT_DIR}/lib/salome \
-lSMDS \
-lSMESHimpl \
-lSMESHDS \
-lSMESHControls \
-lNMTTools \
-lNMTDS \
-lmed_V2_1 \
-lMEDWrapper \
-lMEDWrapperBase \
-lMEDWrapper_V2_1 \
-lMEDWrapper_V2_2 \
-lSalomeResourcesManager \
-lSalomeLifeCycleCORBA \
-lSalomeNotification \
-lSalomeContainer \
-lRegistry \
-lSalomeNS \
-lSALOMELocalTrace \
-lSALOMEBasics \
-lOpUtil
LDFLAGSFORBIN += $(LDFLAGS)
@CONCLUDE@

View File

@ -0,0 +1,30 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
// File :
// Author :
// Module :
// $Header:
#include "SMESH_Client.hxx"
int main( int, char** )
{
return 0;
}

View File

@ -0,0 +1,542 @@
// SMESH SMESHClient : tool to update client mesh structure by mesh from server
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_Client.cxx
// Author : Pavel TELKOV
// Module : SMESH
#include "SMESH_Client.hxx"
#include "SMESH_Mesh.hxx"
#include "SALOME_NamingService.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_Component)
#include CORBA_SERVER_HEADER(SALOME_Exception)
#include "OpUtil.hxx"
#include "utilities.h"
#ifdef WNT
#include <process.h>
#else
#include <unistd.h>
#endif
#include <stdexcept>
#ifndef EXCEPTION
#define EXCEPTION(TYPE, MSG) {\
std::ostringstream aStream;\
aStream<<__FILE__<<"["<<__LINE__<<"]::"<<MSG;\
throw TYPE(aStream.str());\
}
#endif
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
namespace
{
inline const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, int theId){
if(const SMDS_MeshNode* anElem = theMesh->FindNode(theId)) return anElem;
EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
}
inline const SMDS_MeshElement* FindElement(const SMDS_Mesh* theMesh, int theId){
if(const SMDS_MeshElement* anElem = theMesh->FindElement(theId)) return anElem;
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot find a SMDS_MeshElement for ID = "<<theId);
}
inline void AddNodesWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::double_array& aCoords = theSeq[theId].coords;
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(3*aNbElems != aCoords.length())
EXCEPTION(runtime_error,"AddNodesWithID - 3*aNbElems != aCoords.length()");
for(CORBA::Long aCoordId = 0; anElemId < aNbElems; anElemId++, aCoordId+=3){
SMDS_MeshElement* anElem = theMesh->AddNodeWithID(aCoords[aCoordId],
aCoords[aCoordId+1],
aCoords[aCoordId+2],
anIndexes[anElemId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddNodeWithID for ID = "<<anElemId);
}
}
inline void AddEdgesWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(3*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 3*aNbElems != aCoords.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=3){
SMDS_MeshElement* anElem = theMesh->AddEdgeWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddEdgeWithID for ID = "<<anElemId);
}
}
inline void AddTriasWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(4*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 4*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=4){
SMDS_MeshElement* anElem = theMesh->AddFaceWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
}
}
inline void AddQuadsWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(5*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 4*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=5){
SMDS_MeshElement* anElem = theMesh->AddFaceWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId+4],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
}
}
inline void AddPolygonsWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
int aFaceId = anIndexes[anIndexId++];
int aNbNodes = anIndexes[anIndexId++];
std::vector<int> nodes_ids (aNbNodes);
for (int i = 0; i < aNbNodes; i++) {
nodes_ids[i] = anIndexes[anIndexId++];
}
SMDS_MeshElement* anElem = theMesh->AddPolygonalFaceWithID(nodes_ids, aFaceId);
if (!anElem)
EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolygonalFaceWithID for ID = "
<< anElemId);
}
}
inline void AddTetrasWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(5*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 5*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=5){
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId+4],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
inline void AddPiramidsWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(6*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 6*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=6){
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId+4],
anIndexes[anIndexId+5],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
inline void AddPrismsWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(7*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 7*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=7){
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId+4],
anIndexes[anIndexId+5],
anIndexes[anIndexId+6],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
inline void AddHexasWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(9*aNbElems != anIndexes.length())
EXCEPTION(runtime_error,"AddEdgeWithID - 9*aNbElems != anIndexes.length()");
for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=9){
SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
anIndexes[anIndexId+2],
anIndexes[anIndexId+3],
anIndexes[anIndexId+4],
anIndexes[anIndexId+5],
anIndexes[anIndexId+6],
anIndexes[anIndexId+7],
anIndexes[anIndexId+8],
anIndexes[anIndexId]);
if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
inline void AddPolyhedronsWithID (SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
int aFaceId = anIndexes[anIndexId++];
int aNbNodes = anIndexes[anIndexId++];
std::vector<int> nodes_ids (aNbNodes);
for (int i = 0; i < aNbNodes; i++) {
nodes_ids[i] = anIndexes[anIndexId++];
}
int aNbFaces = anIndexes[anIndexId++];
std::vector<int> quantities (aNbFaces);
for (int i = 0; i < aNbFaces; i++) {
quantities[i] = anIndexes[anIndexId++];
}
SMDS_MeshElement* anElem =
theMesh->AddPolyhedralVolumeWithID(nodes_ids, quantities, aFaceId);
if (!anElem)
EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolyhedralVolumeWithID for ID = "
<< anElemId);
}
}
inline void ChangePolyhedronNodes (SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long iind = 0, aNbElems = theSeq[theId].number;
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++)
{
// find element
const SMDS_MeshElement* elem = FindElement(theMesh, anIndexes[iind++]);
// nb nodes
int nbNodes = anIndexes[iind++];
// nodes
std::vector<const SMDS_MeshNode*> aNodes (nbNodes);
for (int iNode = 0; iNode < nbNodes; iNode++) {
aNodes[iNode] = FindNode(theMesh, anIndexes[iind++]);
}
// nb faces
int nbFaces = anIndexes[iind++];
// quantities
std::vector<int> quantities (nbFaces);
for (int iFace = 0; iFace < nbFaces; iFace++) {
quantities[iFace] = anIndexes[iind++];
}
// change
theMesh->ChangePolyhedronNodes(elem, aNodes, quantities);
}
}
}
//=======================================================================
SMESH::SMESH_Gen_var
SMESH_Client::GetSMESHGen(CORBA::ORB_ptr theORB,
CORBA::Boolean& theIsEmbeddedMode)
{
static SMESH::SMESH_Gen_var aMeshGen;
if(CORBA::is_nil(aMeshGen.in())){
#ifdef WNT
long aClientPID = (long)_getpid();
#else
long aClientPID = (long)getpid();
#endif
SALOME_NamingService aNamingService(theORB);
SALOME_LifeCycleCORBA aLifeCycleCORBA(&aNamingService);
Engines::Component_var aComponent = aLifeCycleCORBA.FindOrLoad_Component("FactoryServer","SMESH");
aMeshGen = SMESH::SMESH_Gen::_narrow(aComponent);
std::string aClientHostName = GetHostname();
Engines::Container_var aServerContainer = aMeshGen->GetContainerRef();
CORBA::String_var aServerHostName = aServerContainer->getHostName();
CORBA::Long aServerPID = aServerContainer->getPID();
aMeshGen->SetEmbeddedMode((aClientPID == aServerPID) && (aClientHostName == aServerHostName.in()));
}
theIsEmbeddedMode = aMeshGen->IsEmbeddedMode();
return aMeshGen;
}
//=======================================================================
// function : Create()
// purpose :
//=======================================================================
SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB,
SMESH::SMESH_Mesh_ptr theMesh):
myMeshServer(SMESH::SMESH_Mesh::_duplicate(theMesh)),
mySMESHDSMesh(NULL),
mySMDSMesh(NULL)
{
myMeshServer->Register();
CORBA::Boolean anIsEmbeddedMode;
GetSMESHGen(theORB,anIsEmbeddedMode);
if(anIsEmbeddedMode){
if ( MYDEBUG )
MESSAGE("Info: The same process, update mesh by pointer ");
// just set client mesh pointer to server mesh pointer
SMESH_Mesh* aMesh = reinterpret_cast<SMESH_Mesh*>(theMesh->GetMeshPtr());
if(aMesh->GetMeshDS()->IsEmbeddedMode()){
mySMESHDSMesh = aMesh->GetMeshDS();
mySMDSMesh = mySMESHDSMesh;
}
}
if(!mySMDSMesh)
mySMDSMesh = new SMDS_Mesh();
}
//=================================================================================
// function : ~SMESH_Client
// purpose : Destructor
//=================================================================================
SMESH_Client::~SMESH_Client()
{
myMeshServer->Destroy();
if(!mySMESHDSMesh)
delete mySMDSMesh;
}
//=================================================================================
SMDS_Mesh*
SMESH_Client::GetMesh() const
{
return mySMDSMesh;
}
//=================================================================================
SMDS_Mesh*
SMESH_Client::operator->() const
{
return GetMesh();
}
//=================================================================================
SMESH::SMESH_Mesh_ptr
SMESH_Client::GetMeshServer()
{
return myMeshServer.in();
}
//=================================================================================
// function : SMESH_Client
// purpose : Update mesh
//=================================================================================
bool
SMESH_Client::Update(bool theIsClear)
{
bool anIsModified = true;
if(mySMESHDSMesh){
SMESHDS_Script* aScript = mySMESHDSMesh->GetScript();
anIsModified = aScript->IsModified();
aScript->SetModified(false);
}else{
SMESH::log_array_var aSeq = myMeshServer->GetLog( theIsClear );
CORBA::Long aLength = aSeq->length();
anIsModified = aLength > 0;
if( MYDEBUG )
MESSAGE( "Update: length of the script is "<<aLength );
if(!anIsModified)
return false;
// update client mesh structure by logged changes commands
try
{
for ( CORBA::Long anId = 0; anId < aLength; anId++)
{
const SMESH::double_array& aCoords = aSeq[anId].coords;
const SMESH::long_array& anIndexes = aSeq[anId].indexes;
CORBA::Long anElemId = 0, aNbElems = aSeq[anId].number;
CORBA::Long aCommand = aSeq[anId].commandType;
switch(aCommand)
{
case SMESH::ADD_NODE : AddNodesWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_EDGE : AddEdgesWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_TRIANGLE : AddTriasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_POLYGON : AddPolygonsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_PYRAMID : AddPiramidsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_PRISM : AddPrismsWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( mySMDSMesh, aSeq, anId ); break;
case SMESH::ADD_POLYHEDRON : AddPolyhedronsWithID( mySMDSMesh, aSeq, anId ); break;
case SMESH::REMOVE_NODE:
for( ; anElemId < aNbElems; anElemId++ )
mySMDSMesh->RemoveNode( FindNode( mySMDSMesh, anIndexes[anElemId] ) );
break;
case SMESH::REMOVE_ELEMENT:
for( ; anElemId < aNbElems; anElemId++ )
mySMDSMesh->RemoveElement( FindElement( mySMDSMesh, anIndexes[anElemId] ) );
break;
case SMESH::MOVE_NODE:
for(CORBA::Long aCoordId=0; anElemId < aNbElems; anElemId++, aCoordId+=3)
{
SMDS_MeshNode* node =
const_cast<SMDS_MeshNode*>( FindNode( mySMDSMesh, anIndexes[anElemId] ));
node->setXYZ( aCoords[aCoordId], aCoords[aCoordId+1], aCoords[aCoordId+2] );
}
break;
case SMESH::CHANGE_ELEMENT_NODES:
for ( CORBA::Long i = 0; anElemId < aNbElems; anElemId++ )
{
// find element
const SMDS_MeshElement* elem = FindElement( mySMDSMesh, anIndexes[i++] );
// nb nodes
int nbNodes = anIndexes[i++];
// nodes
//ASSERT( nbNodes < 9 );
const SMDS_MeshNode* aNodes[ nbNodes ];
for ( int iNode = 0; iNode < nbNodes; iNode++ )
aNodes[ iNode ] = FindNode( mySMDSMesh, anIndexes[i++] );
// change
mySMDSMesh->ChangeElementNodes( elem, aNodes, nbNodes );
}
break;
case SMESH::CHANGE_POLYHEDRON_NODES:
ChangePolyhedronNodes(mySMDSMesh, aSeq, anId);
break;
case SMESH::RENUMBER:
for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3)
{
mySMDSMesh->Renumber( anIndexes[i], anIndexes[i+1], anIndexes[i+2] );
}
break;
default:;
}
}
}
catch ( SALOME::SALOME_Exception& exc )
{
INFOS("Following exception was cought:\n\t"<<exc.details.text);
}
catch( const std::exception& exc)
{
INFOS("Following exception was cought:\n\t"<<exc.what());
}
catch(...)
{
INFOS("Unknown exception was cought !!!");
}
if ( MYDEBUG && mySMDSMesh )
{
MESSAGE("Update - mySMDSMesh->NbNodes() = "<<mySMDSMesh->NbNodes());
MESSAGE("Update - mySMDSMesh->NbEdges() = "<<mySMDSMesh->NbEdges());
MESSAGE("Update - mySMDSMesh->NbFaces() = "<<mySMDSMesh->NbFaces());
MESSAGE("Update - mySMDSMesh->NbVolumes() = "<<mySMDSMesh->NbVolumes());
}
} // end of update mesh by log script
return anIsModified;
}

View File

@ -0,0 +1,79 @@
// SMESH SMESHClient : tool to update client mesh structure by mesh from server
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_Client.hxx
// Author : Pavel TELKOV
// Module : SMESH
#ifndef _SMESH_Client_HeaderFile
#define _SMESH_Client_HeaderFile
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS
#define SMESHCLIENT_WNT_EXPORT __declspec( dllexport )
#else
#define SMESHCLIENT_WNT_EXPORT
#endif
class SMESHDS_Mesh;
class SMDS_Mesh;
//=====================================================================
// SMESH_Client : class definition
//=====================================================================
class SMESHCLIENT_WNT_EXPORT SMESH_Client
{
public:
static
SMESH::SMESH_Gen_var
GetSMESHGen(CORBA::ORB_ptr theORB,
CORBA::Boolean& theIsEmbeddedMode);
SMESH_Client(CORBA::ORB_ptr theORB,
SMESH::SMESH_Mesh_ptr theMesh);
~SMESH_Client();
bool
Update(bool theIsClear);
SMDS_Mesh*
GetMesh() const;
SMDS_Mesh*
operator->() const;
SMESH::SMESH_Mesh_ptr
GetMeshServer();
protected:
SMESH::SMESH_Mesh_var myMeshServer;
SMESHDS_Mesh* mySMESHDSMesh;
SMDS_Mesh* mySMDSMesh;
};
#endif

View File

@ -33,7 +33,7 @@
using namespace std; using namespace std;
//======================================================================= //=======================================================================
//function : //function : Constructor
//purpose : //purpose :
//======================================================================= //=======================================================================
SMESHDS_Command::SMESHDS_Command(const SMESHDS_CommandType aType):myType(aType), SMESHDS_Command::SMESHDS_Command(const SMESHDS_CommandType aType):myType(aType),
@ -41,6 +41,14 @@ myNumber(0)
{ {
} }
//=======================================================================
//function : Destructor
//purpose :
//=======================================================================
SMESHDS_Command::~SMESHDS_Command()
{
}
//======================================================================= //=======================================================================
//function : //function :
//purpose : //purpose :
@ -408,3 +416,199 @@ const list < double >&SMESHDS_Command::GetCoords()
{ {
return myReals; return myReals;
} }
//********************************************************************
//***** Methods for quadratic elements ******
//********************************************************************
//=======================================================================
//function : AddEdge
//purpose :
//=======================================================================
void SMESHDS_Command::AddEdge(int NewEdgeID, int n1, int n2, int n12)
{
if (!myType == SMESHDS_AddQuadEdge) {
MESSAGE("SMESHDS_Command::AddEdge : Bad Type");
return;
}
myIntegers.push_back(NewEdgeID);
myIntegers.push_back(n1);
myIntegers.push_back(n2);
myIntegers.push_back(n12);
myNumber++;
}
//=======================================================================
//function : AddFace
//purpose :
//=======================================================================
void SMESHDS_Command::AddFace(int NewFaceID,
int n1, int n2, int n3,
int n12, int n23, int n31)
{
if (!myType == SMESHDS_AddQuadTriangle) {
MESSAGE("SMESHDS_Command::AddFace : Bad Type");
return;
}
myIntegers.push_back(NewFaceID);
myIntegers.push_back(n1);
myIntegers.push_back(n2);
myIntegers.push_back(n3);
myIntegers.push_back(n12);
myIntegers.push_back(n23);
myIntegers.push_back(n31);
myNumber++;
}
//=======================================================================
//function : AddFace
//purpose :
//=======================================================================
void SMESHDS_Command::AddFace(int NewFaceID,
int n1, int n2, int n3, int n4,
int n12, int n23, int n34, int n41)
{
if (!myType == SMESHDS_AddQuadQuadrangle) {
MESSAGE("SMESHDS_Command::AddFace : Bad Type");
return;
}
myIntegers.push_back(NewFaceID);
myIntegers.push_back(n1);
myIntegers.push_back(n2);
myIntegers.push_back(n3);
myIntegers.push_back(n4);
myIntegers.push_back(n12);
myIntegers.push_back(n23);
myIntegers.push_back(n34);
myIntegers.push_back(n41);
myNumber++;
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
void SMESHDS_Command::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n12, int n23, int n31,
int n14, int n24, int n34)
{
if (!myType == SMESHDS_AddQuadTetrahedron) {
MESSAGE("SMESHDS_Command::AddVolume : Bad Type");
return;
}
myIntegers.push_back(NewVolID);
myIntegers.push_back(n1);
myIntegers.push_back(n2);
myIntegers.push_back(n3);
myIntegers.push_back(n4);
myIntegers.push_back(n12);
myIntegers.push_back(n23);
myIntegers.push_back(n31);
myIntegers.push_back(n14);
myIntegers.push_back(n24);
myIntegers.push_back(n34);
myNumber++;
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
void SMESHDS_Command::AddVolume(int NewVolID, int n1, int n2,
int n3, int n4, int n5,
int n12, int n23, int n34, int n41,
int n15, int n25, int n35, int n45)
{
if (!myType == SMESHDS_AddQuadPyramid) {
MESSAGE("SMESHDS_Command::AddVolume : Bad Type");
return;
}
myIntegers.push_back(NewVolID);
myIntegers.push_back(n1);
myIntegers.push_back(n2);
myIntegers.push_back(n3);
myIntegers.push_back(n4);
myIntegers.push_back(n5);
myIntegers.push_back(n12);
myIntegers.push_back(n23);
myIntegers.push_back(n34);
myIntegers.push_back(n41);
myIntegers.push_back(n15);
myIntegers.push_back(n25);
myIntegers.push_back(n35);
myIntegers.push_back(n45);
myNumber++;
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
void SMESHDS_Command::AddVolume(int NewVolID, int n1, int n2,
int n3, int n4, int n5,int n6,
int n12, int n23, int n31,
int n45, int n56, int n64,
int n14, int n25, int n36)
{
if (!myType == SMESHDS_AddQuadPentahedron) {
MESSAGE("SMESHDS_Command::AddVolume : Bad Type");
return;
}
myIntegers.push_back(NewVolID);
myIntegers.push_back(n1);
myIntegers.push_back(n2);
myIntegers.push_back(n3);
myIntegers.push_back(n4);
myIntegers.push_back(n5);
myIntegers.push_back(n6);
myIntegers.push_back(n12);
myIntegers.push_back(n23);
myIntegers.push_back(n31);
myIntegers.push_back(n45);
myIntegers.push_back(n56);
myIntegers.push_back(n64);
myIntegers.push_back(n14);
myIntegers.push_back(n25);
myIntegers.push_back(n36);
myNumber++;
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
void SMESHDS_Command::AddVolume(int NewVolID, int n1, int n2, int n3,
int n4, int n5, int n6, int n7, int n8,
int n12, int n23, int n34, int n41,
int n56, int n67, int n78, int n85,
int n15, int n26, int n37, int n48)
{
if (!myType == SMESHDS_AddQuadHexahedron) {
MESSAGE("SMESHDS_Command::AddVolume : Bad Type");
return;
}
myIntegers.push_back(NewVolID);
myIntegers.push_back(n1);
myIntegers.push_back(n2);
myIntegers.push_back(n3);
myIntegers.push_back(n4);
myIntegers.push_back(n5);
myIntegers.push_back(n6);
myIntegers.push_back(n7);
myIntegers.push_back(n8);
myIntegers.push_back(n12);
myIntegers.push_back(n23);
myIntegers.push_back(n34);
myIntegers.push_back(n41);
myIntegers.push_back(n56);
myIntegers.push_back(n67);
myIntegers.push_back(n78);
myIntegers.push_back(n85);
myIntegers.push_back(n15);
myIntegers.push_back(n26);
myIntegers.push_back(n37);
myIntegers.push_back(n48);
myNumber++;
}

View File

@ -54,6 +54,28 @@ class SMESHDS_Command
void AddPolyhedralVolume (const int ElementID, void AddPolyhedralVolume (const int ElementID,
std::vector<int> nodes_ids, std::vector<int> nodes_ids,
std::vector<int> quantities); std::vector<int> quantities);
// special methods for quadratic elements
void AddEdge(int NewEdgeID, int n1, int n2, int n12);
void AddFace(int NewFaceID, int n1, int n2, int n3,
int n12, int n23, int n31);
void AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
int n12, int n23, int n34, int n41);
void AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n12, int n23, int n31, int n14, int n24, int n34);
void AddVolume(int NewVolID, int n1, int n2, int n3, int n4, int n5,
int n12, int n23, int n34, int n41,
int n15, int n25, int n35, int n45);
void AddVolume(int NewVolID, int n1, int n2, int n3,
int n4, int n5, int n6,
int n12, int n23, int n31,
int n45, int n56, int n64,
int n14, int n25, int n36);
void AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n5, int n6, int n7, int n8,
int n12, int n23, int n34, int n41,
int n56, int n67, int n78, int n85,
int n15, int n26, int n37, int n48);
void MoveNode(int NewNodeID, double x, double y, double z); void MoveNode(int NewNodeID, double x, double y, double z);
void RemoveNode(int NodeID); void RemoveNode(int NodeID);
void RemoveElement(int ElementID); void RemoveElement(int ElementID);

View File

@ -30,22 +30,30 @@
//#include <Standard_PrimitiveTypes.hxx> //#include <Standard_PrimitiveTypes.hxx>
enum SMESHDS_CommandType { enum SMESHDS_CommandType {
SMESHDS_AddNode, SMESHDS_AddNode,
SMESHDS_AddEdge, SMESHDS_AddEdge,
SMESHDS_AddTriangle, SMESHDS_AddTriangle,
SMESHDS_AddQuadrangle, SMESHDS_AddQuadrangle,
SMESHDS_AddPolygon, SMESHDS_AddPolygon,
SMESHDS_AddTetrahedron, SMESHDS_AddTetrahedron,
SMESHDS_AddPyramid, SMESHDS_AddPyramid,
SMESHDS_AddPrism, SMESHDS_AddPrism,
SMESHDS_AddHexahedron, SMESHDS_AddHexahedron,
SMESHDS_AddPolyhedron, SMESHDS_AddPolyhedron,
SMESHDS_RemoveNode, SMESHDS_RemoveNode,
SMESHDS_RemoveElement, SMESHDS_RemoveElement,
SMESHDS_MoveNode, SMESHDS_MoveNode,
SMESHDS_ChangeElementNodes, SMESHDS_ChangeElementNodes,
SMESHDS_ChangePolyhedronNodes, SMESHDS_ChangePolyhedronNodes,
SMESHDS_Renumber SMESHDS_Renumber,
// special types for quadratic elements
SMESHDS_AddQuadEdge,
SMESHDS_AddQuadTriangle,
SMESHDS_AddQuadQuadrangle,
SMESHDS_AddQuadTetrahedron,
SMESHDS_AddQuadPyramid,
SMESHDS_AddQuadPentahedron,
SMESHDS_AddQuadHexahedron
}; };

View File

@ -43,13 +43,13 @@ SMESHDS_Document::SMESHDS_Document(int UserID):myUserID(UserID)
//function : NewMesh //function : NewMesh
//purpose : //purpose :
//======================================================================= //=======================================================================
int SMESHDS_Document::NewMesh() int SMESHDS_Document::NewMesh(bool theIsEmbeddedMode)
{ {
static int NewMeshID = 0; static int aNewMeshID = 0;
NewMeshID++; aNewMeshID++;
SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(NewMeshID); SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(aNewMeshID,theIsEmbeddedMode);
myMeshes[NewMeshID] = aNewMesh; myMeshes[aNewMeshID] = aNewMesh;
return NewMeshID; return aNewMeshID;
} }
//======================================================================= //=======================================================================

View File

@ -36,7 +36,7 @@ class SMESHDS_Document
{ {
public: public:
SMESHDS_Document(int UserID); SMESHDS_Document(int UserID);
int NewMesh(); int NewMesh(bool theIsEmbeddedMode);
void RemoveMesh(int MeshID); void RemoveMesh(int MeshID);
SMESHDS_Mesh * GetMesh(int MeshID); SMESHDS_Mesh * GetMesh(int MeshID);
void AddHypothesis(SMESHDS_Hypothesis * H); void AddHypothesis(SMESHDS_Hypothesis * H);

View File

@ -66,6 +66,12 @@ class SMESHDS_GroupBase
virtual ~SMESHDS_GroupBase() {} virtual ~SMESHDS_GroupBase() {}
void SetColorGroup (int theColorGroup)
{ myColorGroup = theColorGroup;}
int GetColorGroup() const
{ return myColorGroup;}
protected: protected:
const SMDS_MeshElement* findInMesh (const int theID) const; const SMDS_MeshElement* findInMesh (const int theID) const;
void resetIterator(); void resetIterator();
@ -84,7 +90,7 @@ class SMESHDS_GroupBase
int myCurIndex; int myCurIndex;
int myCurID; int myCurID;
SMDS_ElemIteratorPtr myIterator; SMDS_ElemIteratorPtr myIterator;
int myColorGroup;
}; };
#endif #endif

View File

@ -45,9 +45,17 @@ using namespace std;
//function : Create //function : Create
//purpose : //purpose :
//======================================================================= //=======================================================================
SMESHDS_Mesh::SMESHDS_Mesh(int MeshID):myMeshID(MeshID) SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
myIsEmbeddedMode(theIsEmbeddedMode),
myMeshID(theMeshID)
{ {
myScript = new SMESHDS_Script(); myScript = new SMESHDS_Script(theIsEmbeddedMode);
}
//=======================================================================
bool SMESHDS_Mesh::IsEmbeddedMode()
{
return myIsEmbeddedMode;
} }
//======================================================================= //=======================================================================
@ -607,10 +615,10 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
//purpose : //purpose :
//======================================================================= //=======================================================================
static void removeFromContainers (map<int,SMESHDS_SubMesh*> & theSubMeshes, static void removeFromContainers (map<int,SMESHDS_SubMesh*>& theSubMeshes,
set<SMESHDS_GroupBase*>& theGroups, set<SMESHDS_GroupBase*>& theGroups,
list<const SMDS_MeshElement *> & theElems, list<const SMDS_MeshElement*>& theElems,
const bool isNode) const bool isNode)
{ {
if ( theElems.empty() ) if ( theElems.empty() )
return; return;
@ -682,6 +690,32 @@ void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true ); removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true );
} }
//=======================================================================
//function : RemoveFreeNode
//purpose :
//=======================================================================
void SMESHDS_Mesh::RemoveFreeNode(const SMDS_MeshNode * n, SMESHDS_SubMesh * subMesh)
{
myScript->RemoveNode(n->GetID());
// Rm from group
// Node can belong to several groups
if (!myGroups.empty()) {
set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
for (; GrIt != myGroups.end(); GrIt++) {
SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
if (!group || group->IsEmpty()) continue;
group->SMDSGroup().Remove(n);
}
}
// Rm from sub-mesh
// Node should belong to only one sub-mesh
subMesh->RemoveNode(n);
SMDS_Mesh::RemoveFreeElement(n);
}
//======================================================================= //=======================================================================
//function : RemoveElement //function : RemoveElement
//purpose : //purpose :
@ -704,6 +738,107 @@ void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false ); removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false );
} }
//=======================================================================
//function : RemoveFreeElement
//purpose :
//========================================================================
void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt, SMESHDS_SubMesh * subMesh)
{
if (elt->GetType() == SMDSAbs_Node) {
RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
return;
}
if (hasConstructionEdges() || hasConstructionFaces())
// this methods is only for meshes without descendants
return;
myScript->RemoveElement(elt->GetID());
// Rm from group
// Node can belong to several groups
if (!myGroups.empty()) {
set<SMESHDS_GroupBase*>::iterator GrIt = myGroups.begin();
for (; GrIt != myGroups.end(); GrIt++) {
SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>(*GrIt);
if (!group || group->IsEmpty()) continue;
group->SMDSGroup().Remove(elt);
}
}
// Rm from sub-mesh
// Element should belong to only one sub-mesh
subMesh->RemoveElement(elt);
SMDS_Mesh::RemoveFreeElement(elt);
}
//================================================================================
/*!
* \brief return submesh by shape
* \param shape - the subshape
* \retval SMESHDS_SubMesh* - the found submesh
*
* search of submeshes is optimized
*/
//================================================================================
SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const TopoDS_Shape & shape )
{
if ( shape.IsNull() )
return 0;
if ( !myCurSubShape.IsNull() && shape.IsSame( myCurSubShape ))
return myCurSubMesh;
getSubmesh( ShapeToIndex( shape ));
myCurSubShape = shape;
return myCurSubMesh;
}
//================================================================================
/*!
* \brief return submesh by subshape index
* \param Index - the subshape index
* \retval SMESHDS_SubMesh* - the found submesh
* search of submeshes is optimized
*/
//================================================================================
SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
{
//Update or build submesh
if ( Index != myCurSubID ) {
map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
if ( it == myShapeIndexToSubMesh.end() )
it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
myCurSubMesh = it->second;
myCurSubID = Index;
myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
}
return myCurSubMesh;
}
//================================================================================
/*!
* \brief Add element or node to submesh
* \param elem - element to add
* \param subMesh - submesh to be filled in
*/
//================================================================================
bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
{
if ( elem && subMesh ) {
if ( elem->GetType() == SMDSAbs_Node )
subMesh->AddNode( static_cast<const SMDS_MeshNode* >( elem ));
else
subMesh->AddElement( elem );
return true;
}
return false;
}
//======================================================================= //=======================================================================
//function : SetNodeOnVolume //function : SetNodeOnVolume
//purpose : //purpose :
@ -711,7 +846,7 @@ void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode, void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
const TopoDS_Shell & S) const TopoDS_Shell & S)
{ {
SetNodeInVolume( aNode, myIndexToShape.FindIndex(S) ); add( aNode, getSubmesh(S) );
} }
//======================================================================= //=======================================================================
//function : SetNodeOnVolume //function : SetNodeOnVolume
@ -720,7 +855,7 @@ void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode, void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
const TopoDS_Solid & S) const TopoDS_Solid & S)
{ {
SetNodeInVolume( aNode, myIndexToShape.FindIndex(S) ); add( aNode, getSubmesh(S) );
} }
//======================================================================= //=======================================================================
@ -732,7 +867,8 @@ void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
double u, double u,
double v) double v)
{ {
SetNodeOnFace( aNode, myIndexToShape.FindIndex(S), u, v ); if ( add( aNode, getSubmesh(S) ))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
} }
//======================================================================= //=======================================================================
@ -743,7 +879,8 @@ void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
const TopoDS_Edge & S, const TopoDS_Edge & S,
double u) double u)
{ {
SetNodeOnEdge( aNode, myIndexToShape.FindIndex(S), u ); if ( add( aNode, getSubmesh(S) ))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
} }
//======================================================================= //=======================================================================
@ -753,7 +890,8 @@ void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode, void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
const TopoDS_Vertex & S) const TopoDS_Vertex & S)
{ {
SetNodeOnVertex( aNode, myIndexToShape.FindIndex(S)); if ( add( aNode, getSubmesh(S) ))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
} }
//======================================================================= //=======================================================================
@ -762,7 +900,12 @@ void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
//======================================================================= //=======================================================================
void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode) void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
{ {
MESSAGE("not implemented"); if ( aNode && aNode->GetPosition() ) {
map<int,SMESHDS_SubMesh*>::iterator it =
myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
if ( it != myShapeIndexToSubMesh.end() )
it->second->RemoveNode( aNode );
}
} }
//======================================================================= //=======================================================================
@ -770,32 +913,26 @@ void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
//purpose : //purpose :
//======================================================================= //=======================================================================
void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement, void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
const TopoDS_Shape & S) const TopoDS_Shape & S)
{ {
if (myShape.IsNull()) MESSAGE("myShape is NULL"); add( anElement, getSubmesh(S) );
int Index = myIndexToShape.FindIndex(S);
if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddElement(anElement);
} }
//======================================================================= //=======================================================================
//function : UnSetMeshElementOnShape //function : UnSetMeshElementOnShape
//purpose : //purpose :
//======================================================================= //=======================================================================
void SMESHDS_Mesh:: void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem,
UnSetMeshElementOnShape(const SMDS_MeshElement * anElement, const TopoDS_Shape & S)
const TopoDS_Shape & S)
{ {
if (myShape.IsNull()) MESSAGE("myShape is NULL"); int Index = myIndexToShape.FindIndex(S);
int Index = myIndexToShape.FindIndex(S); map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
if ( it != myShapeIndexToSubMesh.end() )
if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end()) if ( elem->GetType() == SMDSAbs_Node )
myShapeIndexToSubMesh[Index]->RemoveElement(anElement); it->second->RemoveNode( static_cast<const SMDS_MeshNode* >( elem ));
else
it->second->RemoveElement( elem );
} }
//======================================================================= //=======================================================================
@ -833,8 +970,6 @@ bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
{ {
if (myShape.IsNull()) MESSAGE("myShape is NULL");
int Index = ShapeToIndex(S); int Index = ShapeToIndex(S);
TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index); TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
if (anIter != myShapeIndexToSubMesh.end()) if (anIter != myShapeIndexToSubMesh.end())
@ -848,10 +983,9 @@ SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index) SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
{ {
if (myShape.IsNull()) MESSAGE("myShape is NULL"); TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
if (anIter != myShapeIndexToSubMesh.end())
if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end()) return anIter->second;
return myShapeIndexToSubMesh[Index];
else else
return NULL; return NULL;
} }
@ -981,7 +1115,7 @@ int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S,
//function : IndexToShape //function : IndexToShape
//purpose : //purpose :
//======================================================================= //=======================================================================
TopoDS_Shape SMESHDS_Mesh::IndexToShape(int ShapeIndex) const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
{ {
return myIndexToShape.FindKey(ShapeIndex); return myIndexToShape.FindKey(ShapeIndex);
} }
@ -1006,7 +1140,7 @@ int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
//======================================================================= //=======================================================================
void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index) void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
{ {
addNodeToSubmesh( aNode, Index ); add( aNode, getSubmesh( Index ));
} }
//======================================================================= //=======================================================================
@ -1016,9 +1150,8 @@ void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v) void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, double v)
{ {
//Set Position on Node //Set Position on Node
aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v))); if ( add( aNode, getSubmesh( Index )))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
addNodeToSubmesh( aNode, Index );
} }
//======================================================================= //=======================================================================
@ -1030,9 +1163,8 @@ void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
double u) double u)
{ {
//Set Position on Node //Set Position on Node
aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u))); if ( add( aNode, getSubmesh( Index )))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
addNodeToSubmesh( aNode, Index );
} }
//======================================================================= //=======================================================================
@ -1042,9 +1174,8 @@ void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index) void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
{ {
//Set Position on Node //Set Position on Node
aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index))); if ( add( aNode, getSubmesh( Index )))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
addNodeToSubmesh( aNode, Index );
} }
//======================================================================= //=======================================================================
@ -1052,14 +1183,469 @@ void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
//purpose : //purpose :
//======================================================================= //=======================================================================
void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement, void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
int Index) int Index)
{ {
if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end()) add( anElement, getSubmesh( Index ));
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddElement(anElement);
} }
SMESHDS_Mesh::~SMESHDS_Mesh() SMESHDS_Mesh::~SMESHDS_Mesh()
{ {
delete myScript;
} }
//********************************************************************
//********************************************************************
//******** *********
//***** Methods for addition of quadratic elements ******
//******** *********
//********************************************************************
//********************************************************************
//=======================================================================
//function : AddEdgeWithID
//purpose :
//=======================================================================
SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID)
{
SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdgeWithID(n1,n2,n12,ID);
if(anElem) myScript->AddEdge(ID,n1,n2,n12);
return anElem;
}
//=======================================================================
//function : AddEdge
//purpose :
//=======================================================================
SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n12)
{
SMDS_MeshEdge* anElem = SMDS_Mesh::AddEdge(n1,n2,n12);
if(anElem) myScript->AddEdge(anElem->GetID(),
n1->GetID(),
n2->GetID(),
n12->GetID());
return anElem;
}
//=======================================================================
//function : AddEdgeWithID
//purpose :
//=======================================================================
SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n12,
int ID)
{
return AddEdgeWithID(n1->GetID(),
n2->GetID(),
n12->GetID(),
ID);
}
//=======================================================================
//function : AddFace
//purpose :
//=======================================================================
SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31)
{
SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n12,n23,n31);
if(anElem) myScript->AddFace(anElem->GetID(),
n1->GetID(), n2->GetID(), n3->GetID(),
n12->GetID(), n23->GetID(), n31->GetID());
return anElem;
}
//=======================================================================
//function : AddFaceWithID
//purpose :
//=======================================================================
SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3,
int n12,int n23,int n31, int ID)
{
SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31,ID);
if(anElem) myScript->AddFace(ID,n1,n2,n3,n12,n23,n31);
return anElem;
}
//=======================================================================
//function : AddFaceWithID
//purpose :
//=======================================================================
SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
int ID)
{
return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(),
n12->GetID(), n23->GetID(), n31->GetID(),
ID);
}
//=======================================================================
//function : AddFace
//purpose :
//=======================================================================
SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41)
{
SMDS_MeshFace *anElem = SMDS_Mesh::AddFace(n1,n2,n3,n4,n12,n23,n34,n41);
if(anElem) myScript->AddFace(anElem->GetID(),
n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID());
return anElem;
}
//=======================================================================
//function : AddFaceWithID
//purpose :
//=======================================================================
SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4,
int n12,int n23,int n34,int n41, int ID)
{
SMDS_MeshFace *anElem = SMDS_Mesh::AddFaceWithID(n1,n2,n3,n4,n12,n23,n34,n41,ID);
if(anElem) myScript->AddFace(ID,n1,n2,n3,n4,n12,n23,n34,n41);
return anElem;
}
//=======================================================================
//function : AddFaceWithID
//purpose :
//=======================================================================
SMDS_MeshFace* SMESHDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
int ID)
{
return AddFaceWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
ID);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
if(anElem) myScript->AddVolume(anElem->GetID(),
n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
n12->GetID(), n23->GetID(), n31->GetID(),
n14->GetID(), n24->GetID(), n34->GetID());
return anElem;
}
//=======================================================================
//function : AddVolumeWithID
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
int n12,int n23,int n31,
int n14,int n24,int n34, int ID)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n12,n23,
n31,n14,n24,n34,ID);
if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
return anElem;
}
//=======================================================================
//function : AddVolumeWithID
//purpose : 2d order tetrahedron of 10 nodes
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34,
int ID)
{
return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
n12->GetID(), n23->GetID(), n31->GetID(),
n14->GetID(), n24->GetID(), n34->GetID(), ID);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n12,n23,n34,n41,
n15,n25,n35,n45);
if(anElem)
myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
n3->GetID(), n4->GetID(), n5->GetID(),
n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID());
return anElem;
}
//=======================================================================
//function : AddVolumeWithID
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
int n12,int n23,int n34,int n41,
int n15,int n25,int n35,int n45, int ID)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,
n12,n23,n34,n41,
n15,n25,n35,n45,ID);
if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n12,n23,n34,n41,
n15,n25,n35,n45);
return anElem;
}
//=======================================================================
//function : AddVolumeWithID
//purpose : 2d order pyramid of 13 nodes
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45,
int ID)
{
return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
n4->GetID(), n5->GetID(),
n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
n15->GetID(), n25->GetID(), n35->GetID(), n45->GetID(),
ID);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n45,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n64,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n12,n23,n31,
n45,n56,n64,n14,n25,n36);
if(anElem)
myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
n3->GetID(), n4->GetID(), n5->GetID(), n6->GetID(),
n12->GetID(), n23->GetID(), n31->GetID(),
n45->GetID(), n56->GetID(), n64->GetID(),
n14->GetID(), n25->GetID(), n36->GetID());
return anElem;
}
//=======================================================================
//function : AddVolumeWithID
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3,
int n4, int n5, int n6,
int n12,int n23,int n31,
int n45,int n56,int n64,
int n14,int n25,int n36, int ID)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,
n12,n23,n31,
n45,n56,n64,
n14,n25,n36,ID);
if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n12,n23,n31,
n45,n56,n64,n14,n25,n36);
return anElem;
}
//=======================================================================
//function : AddVolumeWithID
//purpose : 2d order Pentahedron with 15 nodes
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n45,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n64,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36,
int ID)
{
return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(),
n4->GetID(), n5->GetID(), n6->GetID(),
n12->GetID(), n23->GetID(), n31->GetID(),
n45->GetID(), n56->GetID(), n64->GetID(),
n14->GetID(), n25->GetID(), n36->GetID(),
ID);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n67,
const SMDS_MeshNode * n78,
const SMDS_MeshNode * n85,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n26,
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1,n2,n3,n4,n5,n6,n7,n8,
n12,n23,n34,n41,
n56,n67,n78,n85,
n15,n26,n37,n48);
if(anElem)
myScript->AddVolume(anElem->GetID(), n1->GetID(), n2->GetID(),
n3->GetID(), n4->GetID(), n5->GetID(),
n6->GetID(), n7->GetID(), n8->GetID(),
n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID());
return anElem;
}
//=======================================================================
//function : AddVolumeWithID
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4,
int n5, int n6, int n7, int n8,
int n12,int n23,int n34,int n41,
int n56,int n67,int n78,int n85,
int n15,int n26,int n37,int n48, int ID)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolumeWithID(n1,n2,n3,n4,n5,n6,n7,n8,
n12,n23,n34,n41,
n56,n67,n78,n85,
n15,n26,n37,n48,ID);
if(anElem) myScript->AddVolume(ID,n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
n56,n67,n78,n85,n15,n26,n37,n48);
return anElem;
}
//=======================================================================
//function : AddVolumeWithID
//purpose : 2d order Hexahedrons with 20 nodes
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n67,
const SMDS_MeshNode * n78,
const SMDS_MeshNode * n85,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n26,
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48,
int ID)
{
return AddVolumeWithID(n1->GetID(), n2->GetID(), n3->GetID(), n4->GetID(),
n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID(),
n12->GetID(), n23->GetID(), n34->GetID(), n41->GetID(),
n56->GetID(), n67->GetID(), n78->GetID(), n85->GetID(),
n15->GetID(), n26->GetID(), n37->GetID(), n48->GetID(),
ID);
}

View File

@ -78,7 +78,9 @@ class SMESHDS_GroupBase;
class SMESHDS_WNT_EXPORT SMESHDS_Mesh:public SMDS_Mesh{ class SMESHDS_WNT_EXPORT SMESHDS_Mesh:public SMDS_Mesh{
public: public:
SMESHDS_Mesh(int MeshID); SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode);
bool IsEmbeddedMode();
void ShapeToMesh(const TopoDS_Shape & S); void ShapeToMesh(const TopoDS_Shape & S);
bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H); bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H);
bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H); bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H);
@ -93,6 +95,16 @@ public:
virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1, virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2); const SMDS_MeshNode * n2);
// 2d order edge with 3 nodes: n12 - node between n1 and n2
virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int n12, int ID);
virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n12,
int ID);
virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n12);
virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID); virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1, virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2, const SMDS_MeshNode * n2,
@ -113,6 +125,44 @@ public:
const SMDS_MeshNode * n3, const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4); const SMDS_MeshNode * n4);
// 2d order triangle of 6 nodes
virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
int n12,int n23,int n31, int ID);
virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
int ID);
virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31);
// 2d order quadrangle
virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
int n12,int n23,int n34,int n41, int ID);
virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
int ID);
virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41);
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID); virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID);
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1, virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2, const SMDS_MeshNode * n2,
@ -171,6 +221,153 @@ public:
const SMDS_MeshNode * n7, const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8); const SMDS_MeshNode * n8);
// 2d order tetrahedron of 10 nodes
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
int n12,int n23,int n31,
int n14,int n24,int n34, int ID);
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34,
int ID);
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34);
// 2d order pyramid of 13 nodes
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5,
int n12,int n23,int n34,int n41,
int n15,int n25,int n35,int n45,
int ID);
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45,
int ID);
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45);
// 2d order Pentahedron with 15 nodes
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3,
int n4, int n5, int n6,
int n12,int n23,int n31,
int n45,int n56,int n64,
int n14,int n25,int n36,
int ID);
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n45,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n64,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36,
int ID);
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n45,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n64,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36);
// 2d order Hexahedrons with 20 nodes
virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4,
int n5, int n6, int n7, int n8,
int n12,int n23,int n34,int n41,
int n56,int n67,int n78,int n85,
int n15,int n26,int n37,int n48,
int ID);
virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n67,
const SMDS_MeshNode * n78,
const SMDS_MeshNode * n85,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n26,
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48,
int ID);
virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n67,
const SMDS_MeshNode * n78,
const SMDS_MeshNode * n85,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n26,
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48);
virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids, virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids,
const int ID); const int ID);
@ -196,6 +393,14 @@ public:
void MoveNode(const SMDS_MeshNode *, double x, double y, double z); void MoveNode(const SMDS_MeshNode *, double x, double y, double z);
virtual void RemoveNode(const SMDS_MeshNode *); virtual void RemoveNode(const SMDS_MeshNode *);
void RemoveElement(const SMDS_MeshElement *); void RemoveElement(const SMDS_MeshElement *);
/*! Remove only the given element/node and only if it is free.
* Methods do not work for meshes with descendants.
* Implemented for fast cleaning of meshes.
*/
void RemoveFreeNode(const SMDS_MeshNode *, SMESHDS_SubMesh *);
void RemoveFreeElement(const SMDS_MeshElement *, SMESHDS_SubMesh *);
bool ChangeElementNodes(const SMDS_MeshElement * elem, bool ChangeElementNodes(const SMDS_MeshElement * elem,
const SMDS_MeshNode * nodes[], const SMDS_MeshNode * nodes[],
const int nbnodes); const int nbnodes);
@ -229,7 +434,7 @@ public:
SMESHDS_Script * GetScript(); SMESHDS_Script * GetScript();
void ClearScript(); void ClearScript();
int ShapeToIndex(const TopoDS_Shape & aShape) const; int ShapeToIndex(const TopoDS_Shape & aShape) const;
TopoDS_Shape IndexToShape(int ShapeIndex); const TopoDS_Shape& IndexToShape(int ShapeIndex) const;
SMESHDS_SubMesh * NewSubMesh(int Index); SMESHDS_SubMesh * NewSubMesh(int Index);
int AddCompoundSubmesh(const TopoDS_Shape& S, TopAbs_ShapeEnum type = TopAbs_SHAPE); int AddCompoundSubmesh(const TopoDS_Shape& S, TopAbs_ShapeEnum type = TopAbs_SHAPE);
@ -274,15 +479,6 @@ private:
#endif #endif
void addNodeToSubmesh( const SMDS_MeshNode* aNode, int Index )
{
//Update or build submesh
map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
if ( it == myShapeIndexToSubMesh.end() )
it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
it->second->AddNode( aNode ); // add aNode to submesh
}
typedef std::list<const SMESHDS_Hypothesis*> THypList; typedef std::list<const SMESHDS_Hypothesis*> THypList;
#ifndef WNT #ifndef WNT
@ -305,6 +501,16 @@ private:
TGroups myGroups; TGroups myGroups;
SMESHDS_Script* myScript; SMESHDS_Script* myScript;
bool myIsEmbeddedMode;
// optimize addition of nodes/elements to submeshes by, SetNodeInVolume() etc:
// avoid search of submeshes in maps
bool add( const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh );
SMESHDS_SubMesh* getSubmesh( const TopoDS_Shape & shape);
SMESHDS_SubMesh* getSubmesh( const int Index );
int myCurSubID;
TopoDS_Shape myCurSubShape;
SMESHDS_SubMesh* myCurSubMesh;
}; };

View File

@ -30,6 +30,35 @@
using namespace std; using namespace std;
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
SMESHDS_Script::SMESHDS_Script(bool theIsEmbeddedMode):
myIsEmbeddedMode(theIsEmbeddedMode)
{}
//=======================================================================
//function : Destructor
//purpose :
//=======================================================================
SMESHDS_Script::~SMESHDS_Script()
{
Clear();
}
//=======================================================================
void SMESHDS_Script::SetModified(bool theModified)
{
myIsModified = theModified;
}
//=======================================================================
bool SMESHDS_Script::IsModified()
{
return myIsModified;
}
//======================================================================= //=======================================================================
//function : getCommand //function : getCommand
//purpose : //purpose :
@ -69,6 +98,10 @@ void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
//======================================================================= //=======================================================================
void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2) void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2); getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2);
} }
@ -79,6 +112,10 @@ void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
void SMESHDS_Script::AddFace(int NewFaceID, void SMESHDS_Script::AddFace(int NewFaceID,
int idnode1, int idnode2, int idnode3) int idnode1, int idnode2, int idnode3)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID, getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID,
idnode1, idnode2, idnode3); idnode1, idnode2, idnode3);
} }
@ -91,6 +128,10 @@ void SMESHDS_Script::AddFace(int NewFaceID,
int idnode1, int idnode2, int idnode1, int idnode2,
int idnode3, int idnode4) int idnode3, int idnode4)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID, getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
idnode1, idnode2, idnode1, idnode2,
idnode3, idnode4); idnode3, idnode4);
@ -104,6 +145,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2, int idnode1, int idnode2,
int idnode3, int idnode4) int idnode3, int idnode4)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID, getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
idnode1, idnode2, idnode1, idnode2,
idnode3, idnode4); idnode3, idnode4);
@ -117,6 +162,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2, int idnode1, int idnode2,
int idnode3, int idnode4, int idnode5) int idnode3, int idnode4, int idnode5)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPyramid)->AddVolume(NewID, getCommand(SMESHDS_AddPyramid)->AddVolume(NewID,
idnode1, idnode2, idnode1, idnode2,
idnode3, idnode4, idnode5); idnode3, idnode4, idnode5);
@ -130,6 +179,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2, int idnode3, int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6) int idnode4, int idnode5, int idnode6)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPrism)->AddVolume(NewID, getCommand(SMESHDS_AddPrism)->AddVolume(NewID,
idnode1, idnode2, idnode3, idnode1, idnode2, idnode3,
idnode4, idnode5, idnode6); idnode4, idnode5, idnode6);
@ -143,6 +196,10 @@ void SMESHDS_Script::AddVolume(int NewID,
int idnode1, int idnode2, int idnode3, int idnode4, int idnode1, int idnode2, int idnode3, int idnode4,
int idnode5, int idnode6, int idnode7, int idnode8) int idnode5, int idnode6, int idnode7, int idnode8)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID, getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID,
idnode1, idnode2, idnode3, idnode4, idnode1, idnode2, idnode3, idnode4,
idnode5, idnode6, idnode7, idnode8); idnode5, idnode6, idnode7, idnode8);
@ -154,6 +211,10 @@ void SMESHDS_Script::AddVolume(int NewID,
//======================================================================= //=======================================================================
void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids) void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids); getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
} }
@ -165,6 +226,10 @@ void SMESHDS_Script::AddPolyhedralVolume (int NewID,
std::vector<int> nodes_ids, std::vector<int> nodes_ids,
std::vector<int> quantities) std::vector<int> quantities)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
(NewID, nodes_ids, quantities); (NewID, nodes_ids, quantities);
} }
@ -175,6 +240,10 @@ void SMESHDS_Script::AddPolyhedralVolume (int NewID,
//======================================================================= //=======================================================================
void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z) void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z); getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
} }
@ -184,6 +253,10 @@ void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
//======================================================================= //=======================================================================
void SMESHDS_Script::RemoveNode(int ID) void SMESHDS_Script::RemoveNode(int ID)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_RemoveNode)->RemoveNode(ID); getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
} }
@ -193,6 +266,10 @@ void SMESHDS_Script::RemoveNode(int ID)
//======================================================================= //=======================================================================
void SMESHDS_Script::RemoveElement(int ElementID) void SMESHDS_Script::RemoveElement(int ElementID)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID); getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
} }
@ -203,6 +280,10 @@ void SMESHDS_Script::RemoveElement(int ElementID)
void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes) void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes ); getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
} }
@ -214,6 +295,10 @@ void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
std::vector<int> nodes_ids, std::vector<int> nodes_ids,
std::vector<int> quantities) std::vector<int> quantities)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
(ElementID, nodes_ids, quantities); (ElementID, nodes_ids, quantities);
} }
@ -222,9 +307,12 @@ void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
//function : Renumber //function : Renumber
//purpose : //purpose :
//======================================================================= //=======================================================================
void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID) void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
{ {
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID ); getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
} }
@ -234,7 +322,11 @@ void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int
//======================================================================= //=======================================================================
void SMESHDS_Script::Clear() void SMESHDS_Script::Clear()
{ {
myCommands.clear(); list<SMESHDS_Command*>::iterator anIt = myCommands.begin();
for (; anIt != myCommands.end(); anIt++) {
delete (*anIt);
}
myCommands.clear();
} }
//======================================================================= //=======================================================================
@ -243,5 +335,128 @@ void SMESHDS_Script::Clear()
//======================================================================= //=======================================================================
const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands() const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
{ {
return myCommands; return myCommands;
} }
//********************************************************************
//***** Methods for quadratic elements ******
//********************************************************************
//=======================================================================
//function : AddEdge
//purpose :
//=======================================================================
void SMESHDS_Script::AddEdge(int NewEdgeID, int n1, int n2, int n12)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadEdge)->AddEdge(NewEdgeID, n1, n2, n12);
}
//=======================================================================
//function : AddFace
//purpose :
//=======================================================================
void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3,
int n12, int n23, int n31)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadTriangle)->AddFace(NewFaceID, n1, n2, n3,
n12, n23, n31);
}
//=======================================================================
//function : AddFace
//purpose :
//=======================================================================
void SMESHDS_Script::AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
int n12, int n23, int n34, int n41)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadQuadrangle)->AddFace(NewFaceID, n1, n2, n3, n4,
n12, n23, n34, n41);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n12, int n23, int n31,
int n14, int n24, int n34)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadTetrahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
n12, n23, n31,
n14, n24, n34);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n5, int n12, int n23, int n34, int n41,
int n15, int n25, int n35, int n45)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadPyramid)->AddVolume(NewVolID, n1, n2, n3, n4, n5,
n12, n23, n34, n41,
n15, n25, n35, n45);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n5,int n6, int n12, int n23, int n31,
int n45, int n56, int n64,
int n14, int n25, int n36)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadPentahedron)->AddVolume(NewVolID, n1,n2,n3,n4,n5,n6,
n12, n23, n31,
n45, n56, n64,
n14, n25, n36);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
void SMESHDS_Script::AddVolume(int NewVolID, int n1, int n2, int n3,
int n4, int n5, int n6, int n7, int n8,
int n12, int n23, int n34, int n41,
int n56, int n67, int n78, int n85,
int n15, int n26, int n37, int n48)
{
if(myIsEmbeddedMode){
myIsModified = true;
return;
}
getCommand(SMESHDS_AddQuadHexahedron)->AddVolume(NewVolID, n1, n2, n3, n4,
n5, n6, n7, n8,
n12, n23, n34, n41,
n56, n67, n78, n85,
n15, n26, n37, n48);
}

View File

@ -36,6 +36,12 @@
class SMESHDS_Script class SMESHDS_Script
{ {
public: public:
SMESHDS_Script(bool theIsEmbeddedMode);
~SMESHDS_Script();
void SetModified(bool theModified);
bool IsModified();
void AddNode(int NewNodeID, double x, double y, double z); void AddNode(int NewNodeID, double x, double y, double z);
void AddEdge(int NewEdgeID, int idnode1, int idnode2); void AddEdge(int NewEdgeID, int idnode1, int idnode2);
void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3); void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3);
@ -56,6 +62,27 @@ class SMESHDS_Script
std::vector<int> nodes_ids, std::vector<int> nodes_ids,
std::vector<int> quantities); std::vector<int> quantities);
// special methods for quadratic elements
void AddEdge(int NewEdgeID, int n1, int n2, int n12);
void AddFace(int NewFaceID, int n1, int n2, int n3,
int n12, int n23, int n31);
void AddFace(int NewFaceID, int n1, int n2, int n3, int n4,
int n12, int n23, int n34, int n41);
void AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n12, int n23, int n31, int n14, int n24, int n34);
void AddVolume(int NewVolID, int n1, int n2, int n3, int n4, int n5,
int n12, int n23, int n34, int n41,
int n15, int n25, int n35, int n45);
void AddVolume(int NewVolID, int n1, int n2, int n3,
int n4, int n5, int n6,
int n12, int n23, int n31,
int n45, int n56, int n64,
int n14, int n25, int n36);
void AddVolume(int NewVolID, int n1, int n2, int n3, int n4,
int n5, int n6, int n7, int n8,
int n12, int n23, int n34, int n41,
int n56, int n67, int n78, int n85,
int n15, int n26, int n37, int n48);
void MoveNode(int NewNodeID, double x, double y, double z); void MoveNode(int NewNodeID, double x, double y, double z);
void RemoveNode(int NodeID); void RemoveNode(int NodeID);
void RemoveElement(int ElementID); void RemoveElement(int ElementID);
@ -66,12 +93,14 @@ class SMESHDS_Script
void Renumber (const bool isNodes, const int startID, const int deltaID); void Renumber (const bool isNodes, const int startID, const int deltaID);
void Clear(); void Clear();
const std::list<SMESHDS_Command*> & GetCommands(); const std::list<SMESHDS_Command*> & GetCommands();
~SMESHDS_Script();
private: private:
SMESHDS_Command* getCommand(const SMESHDS_CommandType aType); SMESHDS_Command* getCommand(const SMESHDS_CommandType aType);
std::list<SMESHDS_Command*> myCommands; std::list<SMESHDS_Command*> myCommands;
bool myIsEmbeddedMode;
bool myIsModified;
}; };
#endif #endif

View File

@ -67,7 +67,7 @@ CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) \
-I${GEOM_ROOT_DIR}/include/salome ${BOOST_CPPFLAGS} -I${GEOM_ROOT_DIR}/include/salome ${BOOST_CPPFLAGS}
CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \ CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome -I${BOOSTDIR} -I${GEOM_ROOT_DIR}/include/salome -I${BOOSTDIR}
LDFLAGS += $(OCC_KERNEL_LIBS) -L${GUI_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeApp -lsuit LDFLAGS += $(OCC_KERNEL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeDSClient -lSalomeDS -L${GUI_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeApp -lsuit
# additional file to be cleaned # additional file to be cleaned
MOSTLYCLEAN = MOSTLYCLEAN =

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