--- /dev/null
+# -* Makefile *-
+#
+# Author : Patrick GOLDBRONN (CEA)
+# Date : 28/06/2001
+# $Header$
+#
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=.
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/bin:@top_srcdir@/resources:./bin:@top_srcdir@/idl
+
+
+@COMMENCE@
+
+SUBDIRS = idl src
+
+RESOURCES_FILES = \
+delete.png \
+mesh_add_sub.png \
+mesh_algo_hexa.png \
+mesh_algo_mefisto.png \
+mesh_algo_quad.png \
+mesh_algo_regular.png \
+mesh_angle.png \
+mesh_area.png \
+mesh_aspect.png \
+mesh_compute.png \
+mesh_connectivity.png \
+mesh_diagonal.png \
+mesh_edit.png \
+mesh_hexa_n.png \
+mesh_hexa.png \
+mesh_hypo_area.png \
+mesh_hypo_length.png \
+mesh_hypo_segment.png \
+mesh_hypo_volume.png \
+mesh_info.png \
+mesh_init.png \
+mesh_length.png \
+mesh_line_n.png \
+mesh_line.png \
+mesh_move_node.png \
+mesh_orientation.png \
+mesh.png \
+mesh_pyramid_n.png \
+mesh_pyramid.png \
+mesh_quad_n.png \
+mesh_quad.png \
+mesh_rem_element.png \
+mesh_rem_node.png \
+mesh_set_algo.png \
+mesh_set_hypo.png \
+mesh_shading.png \
+mesh_shrink.png \
+mesh_skew.png \
+mesh_taper.png \
+mesh_tetra_n.png \
+mesh_tetra.png \
+mesh_tree_algo_hexa.png \
+mesh_tree_algo_mefisto.png \
+mesh_tree_algo.png \
+mesh_tree_algo_quad.png \
+mesh_tree_algo_regular.png \
+mesh_tree_hypo_area.png \
+mesh_tree_hypo_length.png \
+mesh_tree_hypo.png \
+mesh_tree_hypo_segment.png \
+mesh_tree_hypo_volume.png \
+mesh_tree_mesh.png \
+mesh_tree_mesh_warn.png \
+mesh_triangle_n.png \
+mesh_triangle.png \
+mesh_update.png \
+mesh_vertex_n.png \
+mesh_vertex.png \
+mesh_wireframe.png \
+mesh_wrap.png \
+ModuleMesh.png \
+select1.png \
+SMESH_en.xml
+
+# copy header files in common directory
+ifeq ($(HAVE_SSTREAM),yes)
+ include_list=include/salome/SALOMEconfig.h
+else
+ include_list=include/salome/SALOMEconfig.h include/salome/sstream
+endif
+
+inc: idl $(include_list)
+
+include/salome/SALOMEconfig.h: salome_adm/unix/SALOMEconfig.h
+ -$(RM) $@
+ $(LN_S) ../../$< $@
+
+include/salome/sstream: salome_adm/unix/sstream
+ -$(RM) $@
+ $(LN_S) ../../$< $@
+
+depend: depend_idl
+
+depend_idl:
+ (cd idl ; $(MAKE) $@) || exit 1
+
+# doc is already build : if you want to had documents, go manually to doc and run 'make doc'
+#doc:
+# (cd doc && $(MAKE) $@) || exit 1
+
+install-end:
+# finish libtool install
+# @$(LT) --mode=finish $(libdir)
+
+install-include: $(include_list)
+ $(INSTALL) -d $(includedir)
+ @for f in X $(include_list); do \
+ if test $$f != X; then \
+ ($(INSTALL_DATA) $$f $(includedir)/. || exit 1); \
+ fi; \
+ done
+
+# install script in $(bindir) :
+install-bin: $(BIN_SCRIPT)
+ $(INSTALL) -d $(bindir)
+ if test $(BIN_SCRIPT)X != X; then \
+ $(INSTALL_PROGRAM) $^ $(bindir); \
+ fi
+
+uninstall: uninstall-idl
+
+uninstall-idl:
+ $(RM) $(idldir)/*.idl
+
+distclean: distclean-other
+
+distclean-other:
+ -$(RM) salome_adm/unix/*~ salome_adm/unix/*% salome_adm/unix/*.bak salome_adm/unix/*.new salome_adm/unix/*.old
+ -$(RM) salome_adm/unix/make_*
+ -$(RM) salome_adm/unix/depend salome_adm/unix/SALOMEconfig.h
+ -$(RM) config.cache config.log config.status
+
+@MODULE@
+
+install: install-bin install-include install-end
+
--- /dev/null
+#!/bin/bash
+
+#
+# Tool for updating list of .in file for the SALOME project
+# and regenerating configure script
+#
+# Author : Marc Tajchman - CEA
+# Date : 10/10/2002
+# $Header$
+#
+
+ORIG_DIR=`pwd`
+CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
+
+########################################################################
+# Test if the KERNEL_ROOT_DIR is set correctly
+
+if test ! -d "${KERNEL_ROOT_DIR}"; then
+ echo "failed : KERNEL_ROOT_DIR variable is not correct !"
+ exit
+fi
+
+# Test if the KERNEL_SRC is set correctly
+
+#if test ! -d "${KERNEL_SRC}"; then
+# echo "failed : KERNEL_SRC variable is not correct !"
+# exit
+#fi
+########################################################################
+# find_in - utility function
+#
+# usage :
+# find_in directory filename
+#
+# Finds files following the *.in pattern, recursively in the
+# directory (first argument).
+# Results are appended into the file (second argument)
+#
+# Difference from the standard unix find is that files are tested
+# before directories
+#
+
+find_in()
+{
+ local i
+ local f=$2
+
+# if the first argument is not a directory, returns
+
+ if [ ! -d "$1" ] ; then
+ return
+ fi
+
+# dont look in the CVS directories
+
+ case $1 in
+ */CVS) return ;;
+ *) ;;
+ esac
+
+# for each regular file contained in the directory
+# test if it's a .in file
+
+ for i in "$1"/*
+ do
+ if [ -f "$i" ] ; then
+ case $i in
+ *.in) echo " "$i" \\" >> $f;;
+ *) ;;
+ esac
+ fi
+ done
+
+# for each subdirectory of the first argument, proceeds recursively
+
+ for i in "$1"/*
+ do
+ if [ -d "$i" ] ; then
+ find_in "$i" "$f"
+ fi
+ done
+}
+
+
+#######################################################################
+# Generate list of .in files (Makefile.in, config.h.in, etc)
+# appending it in file configure.in
+
+cd ${CONF_DIR}
+ABS_CONF_DIR=`pwd`
+
+#
+# Common part of the configure.in file
+#
+chmod u+w configure.in.base
+if ! \cp -f configure.in.base configure.in_tmp1
+then
+ echo
+ echo "error : can't create files in" ${CONF_DIR}
+ echo "aborting ..."
+ chmod u-w configure.in.base
+ exit
+fi
+chmod u-w configure.in.base
+
+# make a link allowing AC_OUTPUT to find the salome_adm/.../*.in files
+echo "" >> configure.in_tmp1
+echo 'ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}/salome_adm' >> configure.in_tmp1
+
+echo "" >> configure.in_tmp1
+echo "AC_OUTPUT([ \\" >> configure.in_tmp1
+
+#
+# List of .in files in the adm/unix directory
+# These files MUST be on top of AC_OUTPUT list so we
+# put them "manually"
+#
+
+echo " ./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
+echo " ./salome_adm/unix/F77config.h \\" >> configure.in_tmp1
+echo " ./salome_adm/unix/sstream \\" >> configure.in_tmp1
+echo " ./salome_adm/unix/depend \\" >> configure.in_tmp1
+echo " ./salome_adm/unix/make_omniorb \\" >> configure.in_tmp1
+echo " ./salome_adm/unix/envScript \\" >> configure.in_tmp1
+echo " ./salome_adm/unix/make_commence \\" >> configure.in_tmp1
+echo " ./salome_adm/unix/make_conclude \\" >> configure.in_tmp1
+echo " ./salome_adm/unix/make_module \\" >> configure.in_tmp1
+
+\rm -f configure.in_tmp2 configure.in_tmp3
+touch configure.in_tmp2
+find_in . configure.in_tmp2
+sed '/^.*salome_adm/d' configure.in_tmp2 > configure.in_tmp3
+sed '/configure.in/d' configure.in_tmp3 > configure.in_tmp2
+sed 's/.in / /' configure.in_tmp2 >> configure.in_tmp1
+
+echo "])" >> configure.in_tmp1
+
+# delete the link created for AC_OUTPUT
+#echo "" >> configure.in_tmp1
+#echo 'rm -f ${ROOT_SRCDIR}/salome_adm' >> configure.in_tmp1
+\mv configure.in_tmp1 configure.in_new
+\rm -f configure.in_tmp2 configure.in_tmp3
+
+
+########################################################################
+# Create new (or replace old) configure.in file
+# Print a message if the file is write protected
+#
+
+echo
+if test ! -f configure.in
+then
+ echo -n "Creating new file 'configure.in' ... "
+ if \mv configure.in_new configure.in >& /dev/null
+ then
+ echo "done"
+ else
+ echo "error, check your file permissions"
+ fi
+else
+ echo -n "Updating 'configure.in' file ... "
+ if ! \cp configure.in configure.in_old >& /dev/null
+ then
+ echo
+ echo
+ echo "Can't backup previous configure.in"
+ echo -n "Continue (you will not be able to revert) - (Y/N) ? "
+ read R
+ case "x$R" in
+ xn*) exit;;
+ xN*) exit;;
+ esac
+ echo
+ echo -n " "
+ fi
+ if \cp configure.in_new configure.in >& /dev/null
+ then
+ echo "done"
+ else
+ echo
+ echo "error, can't update previous configure.in"
+ fi
+fi
+
+########################################################################
+# Use autoconf to rebuild the configure script
+#
+
+if test -f configure
+then
+ echo -n "Updating 'configure' script ... "
+else
+ echo -n "Creating 'configure' script ... "
+fi
+
+aclocal --acdir=${KERNEL_ROOT_DIR}/salome_adm/unix/config_files
+if autoconf
+then
+ echo "done"
+else
+ echo "failed (check file permissions and/or user quotas ...)"
+fi
+
+cd ${ORIG_DIR}
+
+echo
--- /dev/null
+#
+# PLEASE DO NOT MODIFY configure.in FILE
+#
+# ALL CHANGES WILL BE DISCARDED BY THE NEXT
+# build_configure COMMAND
+#
+# CHANGES MUST BE MADE IN configure.in.base FILE
+#
+#
+# Author : Marc Tajchman (CEA)
+# Date : 28/06/2001
+# Modified by : Patrick GOLDBRONN (CEA)
+# Modified by : Marc Tajchman (CEA)
+#
+# Created from configure.in.base
+#
+
+AC_INIT(src)
+AC_CONFIG_AUX_DIR(${KERNEL_ROOT_DIR}/salome_adm/unix/config_files)
+AC_CANONICAL_HOST
+
+PACKAGE=salome
+AC_SUBST(PACKAGE)
+
+VERSION=0.0.1
+AC_SUBST(VERSION)
+
+dnl
+dnl Initialize source and build root directories
+dnl
+
+ROOT_BUILDDIR=`pwd`
+ROOT_SRCDIR=`echo $0 | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
+cd $ROOT_SRCDIR
+ROOT_SRCDIR=`pwd`
+cd $ROOT_BUILDDIR
+
+AC_SUBST(ROOT_SRCDIR)
+AC_SUBST(ROOT_BUILDDIR)
+
+echo
+echo Source root directory : $ROOT_SRCDIR
+echo Build root directory : $ROOT_BUILDDIR
+echo
+echo
+
+if test -z "$AR"; then
+ AC_CHECK_PROGS(AR,ar xar,:,$PATH)
+fi
+AC_SUBST(AR)
+
+dnl Export the AR macro so that it will be placed in the libtool file
+dnl correctly.
+export AR
+
+echo
+echo ---------------------------------------------
+echo testing make
+echo ---------------------------------------------
+echo
+
+AC_PROG_MAKE_SET
+AC_PROG_INSTALL
+dnl
+dnl libtool macro check for CC, LD, NM, LN_S, RANLIB, STRIP + pour les librairies dynamiques !
+
+AC_ENABLE_DEBUG(yes)
+AC_DISABLE_PRODUCTION
+
+echo ---------------------------------------------
+echo testing libtool
+echo ---------------------------------------------
+
+dnl first, we set static to no!
+dnl if we want it, use --enable-static
+AC_ENABLE_STATIC(no)
+
+AC_LIBTOOL_DLOPEN
+AC_PROG_LIBTOOL
+
+dnl Fix up the INSTALL macro if it s a relative path. We want the
+dnl full-path to the binary instead.
+case "$INSTALL" in
+ *install-sh*)
+ INSTALL='\${KERNEL_ROOT_DIR}'/salome_adm/unix/config_files/install-sh
+ ;;
+esac
+
+echo
+echo ---------------------------------------------
+echo testing C/C++
+echo ---------------------------------------------
+echo
+
+cc_ok=no
+dnl inutil car libtool
+dnl AC_PROG_CC
+AC_PROG_CXX
+AC_DEPEND_FLAG
+# AC_CC_WARNINGS([ansi])
+cc_ok=yes
+
+dnl Library libdl :
+AC_CHECK_LIB(dl,dlopen)
+
+dnl add library libm :
+AC_CHECK_LIB(m,ceil)
+
+dnl
+dnl Well we use sstream which is not in gcc pre-2.95.3
+dnl We must test if it exists. If not, add it in include !
+dnl
+
+AC_CXX_HAVE_SSTREAM
+
+dnl
+dnl ---------------------------------------------
+dnl testing MPICH
+dnl ---------------------------------------------
+dnl
+
+CHECK_MPICH
+
+echo
+echo ---------------------------------------------
+echo testing LEX \& YACC
+echo ---------------------------------------------
+echo
+
+lex_yacc_ok=no
+AC_PROG_YACC
+AC_PROG_LEX
+lex_yacc_ok=yes
+
+echo
+echo ---------------------------------------------
+echo testing python
+echo ---------------------------------------------
+echo
+
+CHECK_PYTHON
+
+echo
+echo ---------------------------------------------
+echo testing java
+echo ---------------------------------------------
+echo
+
+CHECK_JAVA
+
+echo
+echo ---------------------------------------------
+echo testing swig
+echo ---------------------------------------------
+echo
+
+CHECK_SWIG
+
+echo
+echo ---------------------------------------------
+echo testing threads
+echo ---------------------------------------------
+echo
+
+ENABLE_PTHREADS
+
+echo
+echo ---------------------------------------------
+echo testing omniORB
+echo ---------------------------------------------
+echo
+
+CHECK_OMNIORB
+
+echo
+echo ---------------------------------------------
+echo testing mico
+echo ---------------------------------------------
+echo
+
+CHECK_MICO
+
+echo
+echo ---------------------------------------------
+echo default ORB : omniORB
+echo ---------------------------------------------
+echo
+
+DEFAULT_ORB=omniORB
+CHECK_CORBA
+
+AC_SUBST_FILE(CORBA)
+corba=make_$ORB
+CORBA=salome_adm/unix/$corba
+
+echo
+echo ---------------------------------------------
+echo testing openGL
+echo ---------------------------------------------
+echo
+
+CHECK_OPENGL
+
+echo
+echo ---------------------------------------------
+echo testing QT
+echo ---------------------------------------------
+echo
+
+CHECK_QT
+
+echo
+echo ---------------------------------------------
+echo testing VTK
+echo ---------------------------------------------
+echo
+
+CHECK_VTK
+
+echo
+echo ---------------------------------------------
+echo testing HDF5
+echo ---------------------------------------------
+echo
+
+CHECK_HDF5
+
+echo
+echo ---------------------------------------------
+echo testing MED2
+echo ---------------------------------------------
+echo
+
+CHECK_MED2
+
+echo
+echo ---------------------------------------------
+echo Testing OpenCascade
+echo ---------------------------------------------
+echo
+
+CHECK_CAS
+
+echo
+echo ---------------------------------------------
+echo Testing Kernel
+echo ---------------------------------------------
+echo
+
+CHECK_KERNEL
+
+echo
+echo ---------------------------------------------
+echo Testing Geom
+echo ---------------------------------------------
+echo
+
+CHECK_GEOM
+
+echo
+echo ---------------------------------------------
+echo Summary
+echo ---------------------------------------------
+echo
+
+echo Configure
+variables="cc_ok lex_yacc_ok python_ok java_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok mico_ok occ_ok Kernel_ok Geom_Ok"
+
+for var in $variables
+do
+ printf " %10s : " `echo \$var | sed -e "s,_ok,,"`
+ eval echo \$$var
+done
+
+echo
+echo "Default ORB : $DEFAULT_ORB"
+echo
+
+dnl generals files which could be included in every makefile
+
+AC_SUBST_FILE(COMMENCE) COMMENCE=salome_adm/unix/make_commence
+AC_SUBST_FILE(CONCLUDE) CONCLUDE=salome_adm/unix/make_conclude
+AC_SUBST_FILE(MODULE) MODULE=salome_adm/unix/make_module
+
+dnl les dependences
+AC_SUBST_FILE(DEPEND) DEPEND=salome_adm/unix/depend
+
+dnl We don t need to say when we re entering directories if we re using
+dnl GNU make becuase make does it for us.
+if test "X$GMAKE" = "Xyes"; then
+ AC_SUBST(SETX) SETX=":"
+else
+ AC_SUBST(SETX) SETX="set -x"
+fi
+
+# make other build directories
+for rep in salome_adm adm_local doc bin/salome include/salome lib/salome share/salome/resources share/salome/doc idl
+do
+# if test ! -d $rep ; then
+# eval mkdir $rep
+# fi
+ $INSTALL -d $rep
+done
+
+echo
+echo ---------------------------------------------
+echo copying resource files, shell scripts, and
+echo xml files
+echo ---------------------------------------------
+echo
+
+
+dnl copy resources directories
+
+#for i in `find $ROOT_SRCDIR -name 'resources' -print`
+#do
+# local_res=`echo $i | sed -e "s,$ROOT_SRCDIR,.,"`
+# local_res_dir=`echo $local_res | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
+# mkdir -p $local_res_dir
+# cd $local_res_dir
+# ln -fs $i
+# echo $local_res
+# cd $ROOT_BUILDDIR
+#done
+
+dnl copy shells and utilities contained in the bin directory
+dnl excluding .in files (treated in AC-OUTPUT below) and CVS
+dnl directory
+
+cd bin
+for i in $ROOT_SRCDIR/bin/*
+do
+ local_bin=`echo $i | sed -e "s,$ROOT_SRCDIR,.,"`
+ case "$local_bin" in
+ *.in | *~) ;;
+ ./bin/CVS) ;;
+ *) ln -fs $i; echo $local_bin ;;
+ esac
+done
+cd $ROOT_BUILDDIR
+
+AC_SUBST_FILE(ENVSCRIPT) ENVSCRIPT=salome_adm/unix/envScript
+
+dnl copy xml files to the build tree (lib directory)
+dnl pourquoi ????
+
+#cd lib
+#for i in `find $ROOT_SRCDIR -name "*.xml" -print`
+#do
+# ln -fs $i
+# echo `echo $i | sed -e "s,$ROOT_SRCDIR,.,"`
+#done
+#cd $ROOT_BUILDDIR
+
+
+echo
+echo ---------------------------------------------
+echo generating Makefiles and configure files
+echo ---------------------------------------------
+echo
+
+AC_OUTPUT_COMMANDS([ \
+ chmod +x ./bin/* \
+])
+
+## do not delete this line
--- /dev/null
+#
+# generate dependencies for idl file :
+#
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=..
+srcdir=@srcdir@
+VPATH=.:$(srcdir):${KERNEL_ROOT_DIR}/idl/salome:${GEOM_ROOT_DIR}/idl/salome
+
+@COMMENCE@
+
+IDL_FILES = \
+ SALOME_Component.idl \
+ SALOMEDS.idl \
+ SALOMEDS_Attributes.idl \
+ SALOME_Exception.idl \
+ Logger.idl \
+ SALOME_ModuleCatalog.idl \
+ GEOM_Shape.idl \
+ GEOM_Gen.idl \
+ SMESH_Gen.idl \
+ SMESH_Mesh.idl \
+ SMESH_Hypothesis.idl \
+ SMESH_BasicHypothesis.idl
+
+PY_CLIENT_IDL = $(IDL_FILES)
+
+# we copy all idl file in $(top_builddir)/idl
+inc: $(IDL_FILES:%=$(top_builddir)/idl/%)
+
+$(IDL_FILES:%=$(top_builddir)/idl/%):$(top_builddir)/idl/%:%
+# $(CP) $< $@
+ cp -f $< $@
+
+
+lib: pyidl
+
+PYTHON_BUILD_SITE=$(top_builddir)/lib/python$(PYTHON_VERSION)/site-packages/@PACKAGE@
+
+pyidl: $(PYTHON_BUILD_SITE) $(IDL_FILES:%.idl=$(PYTHON_BUILD_SITE)/%_idl.py)
+
+$(PYTHON_BUILD_SITE):
+ $(INSTALL) -d $@
+
+$(PYTHON_BUILD_SITE)/%_idl.py: %.idl
+ $(OMNIORB_IDL) $(OMNIORB_IDLPYFLAGS) -C$(PYTHON_BUILD_SITE) $<
+
+
+# install python client (generated from idl file
+install: install-pyidl install-idl
+
+# create directory $(idldir) and copy idl files into it
+install-idl: $(IDL_FILES)
+ $(INSTALL) -d $(idldir)
+ $(INSTALL_DATA) $^ $(idldir)
+
+
+install-pyidl: $(IDL_FILES)
+ $(INSTALL) -d $(PYTHON_SITE_INSTALL)
+ @for file in $^ dummy; do \
+ if [ $$file != "dummy" ]; then \
+ $(OMNIORB_IDL) $(OMNIORB_IDLPYFLAGS) -C$(PYTHON_SITE_INSTALL) $$file ; \
+ fi ; \
+ done ;
+
+#@ CONCLUDE @
+
+cleandep:
+ -$(RM) .dep*
+
+distclean:
+ -$(RM) *.py
+ -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/%)
+ -$(RM) Makefile
+
--- /dev/null
+//=============================================================================
+// File : SMESH_BasicHypothesis.idl
+// Created : mer mai 15 13:37:18 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_BASICHYPOTHESIS_IDL_
+#define _SMESH_BASICHYPOTHESIS_IDL_
+
+#include "SALOME_Exception.idl"
+#include "SMESH_Hypothesis.idl"
+
+
+module SMESH
+{
+ interface SMESH_LocalLength : SMESH_Hypothesis
+ {
+ void SetLength(in double length)
+ raises (SALOME::SALOME_Exception);
+ double GetLength();
+ };
+
+ interface SMESH_NumberOfSegments : SMESH_Hypothesis
+ {
+ void SetNumberOfSegments(in long segmentsNumber)
+ raises (SALOME::SALOME_Exception);
+ long GetNumberOfSegments();
+ };
+
+ interface SMESH_MaxElementArea : SMESH_Hypothesis
+ {
+ void SetMaxElementArea(in double area)
+ raises (SALOME::SALOME_Exception);
+ double GetMaxElementArea();
+ };
+
+ interface SMESH_MaxElementVolume : SMESH_Hypothesis
+ {
+ void SetMaxElementVolume(in double volume)
+ raises (SALOME::SALOME_Exception);
+ double GetMaxElementVolume();
+ };
+
+ interface SMESH_Regular_1D : SMESH_1D_Algo
+ {
+ };
+
+ interface SMESH_MEFISTO_2D : SMESH_2D_Algo
+ {
+ };
+
+ interface SMESH_Quadrangle_2D : SMESH_2D_Algo
+ {
+ };
+
+ interface SMESH_Hexa_3D : SMESH_3D_Algo
+ {
+ };
+};
+
+#endif
--- /dev/null
+//=============================================================================
+// File : SMESH_Gen.idl
+// Created : jeu avr 11 15:26:35 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_GEN_IDL_
+#define _SMESH_GEN_IDL_
+
+#include "SALOME_Exception.idl"
+#include "SALOME_Component.idl"
+#include "SALOMEDS.idl"
+
+#include "GEOM_Gen.idl"
+#include "GEOM_Shape.idl"
+
+#include "SMESH_Mesh.idl"
+#include "SMESH_Hypothesis.idl"
+
+module SMESH
+{
+ typedef sequence<GEOM::GEOM_Shape> shape_array;
+
+ interface SMESH_Gen : Engines::Component, SALOMEDS::Driver
+ {
+ /*!
+ * Create an hypothesis that can be shared by differents parts of the mesh.
+ * An hypothesis is either:
+ * - a method used to generate or modify a part of the mesh (algorithm).
+ * - a parameter or a law used by an algorithm.
+ * Algorithms are 1D, 2D or 3D.
+ */
+ SMESH_Hypothesis CreateHypothesis( in string anHyp,
+ in long studyId)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Create a Mesh object, given a geometry shape.
+ * Mesh is created empty (no points, no elements).
+ * Shape is explored via GEOM_Client to create local copies.
+ * of TopoDS_Shapes and bind CORBA references of shape & subshapes
+ * with TopoDS_Shapes
+ */
+ SMESH_Mesh Init(in GEOM::GEOM_Gen geomEngine,
+ in long studyId,
+ in GEOM::GEOM_Shape aShape)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Create a Mesh object, without a geometry shape reference
+ */
+// SMESH_Mesh NewEmpty(in GEOM::GEOM_Gen geomEngine,
+// in long studyId)
+// raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Mesh a subShape.
+ * First, verify list of hypothesis associated with the subShape,
+ * return NOK if hypothesis are not sufficient
+ */
+ boolean Compute(in SMESH_Mesh aMesh, in GEOM::GEOM_Shape aSubShape)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ *
+ */
+
+ boolean IsReadyToCompute(in SMESH_Mesh aMesh, in GEOM::GEOM_Shape aSubShape)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ *
+ */
+ long_array GetSubShapesId(in GEOM::GEOM_Gen geomEngine,
+ in long studyId,
+ in GEOM::GEOM_Shape mainShape,
+ in shape_array listOfSubShape)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ *
+ */
+ // long_array GetSubMeshesState(in GEOM::GEOM_Gen geomEngine,
+ // in long studyId,
+ // in shape_array listOfSubShape)
+ // raises (SALOME::SALOME_Exception);
+
+
+ };
+
+};
+
+#endif
--- /dev/null
+//=============================================================================
+// File : SMESH_Hypothesis.idl
+// Created : jeu avr 11 19:26:16 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_HYPOTHESIS_IDL_
+#define _SMESH_HYPOTHESIS_IDL_
+
+#include "SALOME_Exception.idl"
+
+module SMESH
+{
+ interface SMESH_Hypothesis;
+
+ typedef sequence<SMESH_Hypothesis> ListOfHypothesis;
+ typedef sequence<string> ListOfHypothesisName;
+
+ interface SMESH_Hypothesis
+ {
+ /*!
+ * Get the Hypothesis typeName
+ */
+ string GetName();
+
+ /*!
+ * Get the internal Id
+ */
+ long GetId();
+ };
+
+ interface SMESH_Algo : SMESH_Hypothesis
+ {
+ /*!
+ * Get list of hypothesis that can be used with this algorithm
+ */
+ ListOfHypothesisName GetCompatibleHypothesis();
+
+ };
+
+ interface SMESH_1D_Algo : SMESH_Algo
+ {
+ /*!
+ *
+ */
+ };
+
+ interface SMESH_2D_Algo : SMESH_Algo
+ {
+ /*!
+ *
+ */
+ };
+
+ interface SMESH_3D_Algo : SMESH_Algo
+ {
+ /*!
+ *
+ */
+ };
+};
+
+ // -----------------------------------------------------------------
+ // Specific Algorithms in separate idl file
+ // -----------------------------------------------------------------
+
+
+#endif
--- /dev/null
+//=============================================================================
+// File : SMESH_Mesh.idl
+// Created : jeu avr 11 15:31:39 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+
+#ifndef _SMESH_MESH_IDL_
+#define _SMESH_MESH_IDL_
+
+#include "SALOME_Exception.idl"
+#include "SMESH_Hypothesis.idl"
+
+#include "GEOM_Shape.idl"
+#include "MED.idl"
+
+module SMESH
+{
+ typedef sequence<double> double_array ;
+ typedef sequence<long> long_array ;
+ typedef sequence<string> string_array ;
+
+ enum log_command
+ {
+ ADD_NODE,
+ ADD_EDGE,
+ ADD_TRIANGLE,
+ ADD_QUADRANGLE,
+ ADD_TETRAHEDRON,
+ ADD_PYRAMID,
+ ADD_PRISM,
+ ADD_HEXAHEDRON,
+ REMOVE_NODE,
+ REMOVE_ELEMENT
+ };
+
+ struct log_block
+ {
+ long commandType;
+ long number;
+ double_array coords;
+ long_array indexes;
+ };
+
+ typedef sequence<log_block> log_array;
+
+ interface SMESH_subMesh;
+ interface SMESH_MeshEditor;
+ interface SMESH_Mesh
+ {
+ /*!
+ * Associate a Shape to a Mesh created with NewEmpty
+ */
+
+// boolean SetMesh(in GEOM::GEOM_Shape aShape)
+// raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Get the subMesh object associated to a subShape. The subMesh object
+ * gives access to nodes and elements IDs.
+ * SubMesh will be used instead of SubShape in a next idl version to
+ * adress a specific subMesh...
+ */
+ SMESH_subMesh GetElementsOnShape(in GEOM::GEOM_Shape aSubShape)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Create a subMesh without reference to a subShape
+ */
+// SMESH_subMesh NewEmpty()
+// raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Add hypothesis to the mesh, under a particular subShape
+ * (or the main shape itself)
+ * The Add method is only used to prepare the build of the mesh and store
+ * the algorithms and associated parameters.
+ * Actual job of mesh the shape is done by MESH_Gen.
+ * @params
+ * - aSubShape : subShape obtained by a shape explode in GEOM
+ * (or main shape)
+ * - anHyp : hypothesis object
+ * @return
+ * - OK if the hypothesis is compatible with the subShape
+ * (and all previous hypothesis on the subShape)
+ * - NOK if the hypothesis is not compatible with the subShape
+ * (or one previous hypothesis on the subShape)
+ * raises exception if hypothesis has not been created
+ */
+ boolean AddHypothesis(in GEOM::GEOM_Shape aSubShape, in SMESH_Hypothesis anHyp)
+ raises (SALOME::SALOME_Exception);
+// boolean AddHypothesis(in SMESH_subMesh aSubMesh, in SMESH_Hypothesis anHyp)
+// raises (SALOME::SALOME_Exception);
+
+
+ /*!
+ * Remove an hypothesis previouly added with AddHypothesis.
+ */
+ boolean RemoveHypothesis(in GEOM::GEOM_Shape aSubShape,
+ in SMESH_Hypothesis anHyp)
+ raises (SALOME::SALOME_Exception);
+// boolean RemoveHypothesis(in SMESH_subMesh aSubMesh,
+// in SMESH_Hypothesis anHyp)
+// raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Get the list of hypothesis added on a subShape
+ */
+ ListOfHypothesis GetHypothesisList(in GEOM::GEOM_Shape aSubShape)
+ raises (SALOME::SALOME_Exception);
+// ListOfHypothesis GetHypothesisList(in SMESH_subMesh aSubMesh)
+// raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Get the log of nodes and elements added or removed since previous
+ * clear of the log.
+ * @params
+ * - clearAfterGet : log is emptied after Get (safe if concurrents access)
+ */
+ // string_array GetLog(in boolean clearAfterGet)
+ // raises (SALOME::SALOME_Exception);
+ log_array GetLog(in boolean clearAfterGet)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Clear the log of nodes and elements added or removed since previous
+ * clear. Must be used immediately after GetLog if clearAfterGet is false.
+ */
+ void ClearLog()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Get the internal Id
+ */
+ long GetId();
+
+ /*!
+ * Get the study Id
+ */
+ long GetStudyId();
+
+ SMESH_MeshEditor GetMeshEditor()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Export Mesh with DAT and MED Formats
+ */
+ void ExportDAT( in string file )
+ raises (SALOME::SALOME_Exception);
+ void ExportMED( in string file )
+ raises (SALOME::SALOME_Exception);
+ void ExportUNV( in string file )
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Get MED Mesh
+ */
+ SALOME_MED::MESH GetMEDMesh()
+ raises (SALOME::SALOME_Exception);
+
+ long NbNodes()
+ raises (SALOME::SALOME_Exception);
+
+ long NbEdges()
+ raises (SALOME::SALOME_Exception);
+
+ long NbFaces()
+ raises (SALOME::SALOME_Exception);
+
+ long NbTriangles()
+ raises (SALOME::SALOME_Exception);
+
+ long NbQuadrangles()
+ raises (SALOME::SALOME_Exception);
+
+ long NbVolumes()
+ raises (SALOME::SALOME_Exception);
+
+ long NbTetras()
+ raises (SALOME::SALOME_Exception);
+
+ long NbHexas()
+ raises (SALOME::SALOME_Exception);
+
+ long NbSubMesh()
+ raises (SALOME::SALOME_Exception);
+ };
+
+ interface SMESH_subMesh
+ {
+ /*!
+ *
+ */
+ long GetNumberOfElements()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ *
+ */
+ long GetNumberOfNodes()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ *
+ */
+ long_array GetElementsId()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ *
+ */
+ long_array GetNodesId()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Get SMESH_Mesh which stores nodes coordinates & elements definition
+ */
+ SMESH_Mesh GetFather()
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Get the internal Id
+ */
+ long GetId();
+
+ /*!
+ * Get MED subMesh
+ */
+ SALOME_MED::FAMILY GetFamily()
+ raises (SALOME::SALOME_Exception);
+ };
+
+ /*
+ * This interface makes modifications on the Mesh - removing elements and nodes
+ */
+ interface SMESH_MeshEditor {
+
+
+ boolean RemoveElements(in long_array IDsOfElements)
+ raises (SALOME::SALOME_Exception);
+
+ boolean RemoveNodes(in long_array IDsOfNodes)
+ raises (SALOME::SALOME_Exception);
+
+ boolean AddNode(in double x, in double y, in double z)
+ raises (SALOME::SALOME_Exception);
+
+ boolean AddEdge(in long_array IDsOfNodes)
+ raises (SALOME::SALOME_Exception);
+
+ boolean AddFace(in long_array IDsOfNodes)
+ raises (SALOME::SALOME_Exception);
+
+ boolean AddVolume(in long_array IDsOfNodes)
+ raises (SALOME::SALOME_Exception);
+ };
+};
+
+#endif
--- /dev/null
+<?xml version='1.0' encoding='us-ascii' ?>
+
+<!-- XML component catalog -->
+<begin-catalog>
+
+<!-- Path prefix information -->
+
+<path-prefix-list>
+</path-prefix-list>
+
+<!-- Component list -->
+<component-list>
+ <component>
+ <!-- Component identification -->
+ <component-name>SMESH</component-name>
+ <component-type>Mesh</component-type>
+ <component-author>NRI</component-author>
+ <component-version> 1.0</component-version>
+ <component-comment>New Mesh component</component-comment>
+ <component-multistudy>1</component-multistudy>
+ <component-icone>ModuleMesh.png</component-icone>
+
+ <component-interface-list>
+ <component-interface-name>SMESH</component-interface-name>
+ <component-interface-comment></component-interface-comment>
+ <component-service-list>
+ <component-service>
+ <service-name>CreateHypothesis</service-name>
+ <service-author></service-author>
+ <service-version></service-version>
+ <service-comment></service-comment>
+ <service-by-default>1</service-by-default>
+ <inParameter-list>
+ <inParameter>
+ <inParameter-type>string</inParameter-type>
+ <inParameter-name>anHyp</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ <inParameter>
+ <inParameter-type>long</inParameter-type>
+ <inParameter-name>studyId</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ </inParameter-list>
+ <outParameter-list>
+ <outParameter>
+ <outParameter-type>SMESH_Hypothesis</outParameter-type>
+ <outParameter-name>aHyp</outParameter-name>
+ <outParameter-comment></outParameter-comment>
+ </outParameter>
+ </outParameter-list>
+ </component-service>
+ <component-service>
+ <service-name>Init</service-name>
+ <service-author></service-author>
+ <service-version></service-version>
+ <service-comment></service-comment>
+ <service-by-default>1</service-by-default>
+ <inParameter-list>
+ <inParameter>
+ <inParameter-type>GEOM_Gen</inParameter-type>
+ <inParameter-name>geomEngine</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ <inParameter>
+ <inParameter-type>long</inParameter-type>
+ <inParameter-name>studyId</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ <inParameter>
+ <inParameter-type>GEOM_Shape</inParameter-type>
+ <inParameter-name>aShape</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ </inParameter-list>
+ <outParameter-list>
+ <outParameter>
+ <outParameter-type>SMESH_Mesh</outParameter-type>
+ <outParameter-name>aMesh</outParameter-name>
+ <outParameter-comment></outParameter-comment>
+ </outParameter>
+ </outParameter-list>
+ </component-service>
+ <component-service>
+ <service-name>Compute</service-name>
+ <service-author></service-author>
+ <service-version></service-version>
+ <service-comment></service-comment>
+ <service-by-default>1</service-by-default>
+ <inParameter-list>
+ <inParameter>
+ <inParameter-type>SMESH_Mesh</inParameter-type>
+ <inParameter-name>aMesh</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ <inParameter>
+ <inParameter-type>GEOM_Shape</inParameter-type>
+ <inParameter-name>aSubShape</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ </inParameter-list>
+ <outParameter-list>
+ <outParameter>
+ <outParameter-type>boolean</outParameter-type>
+ <outParameter-name>res</outParameter-name>
+ <outParameter-comment>Result</outParameter-comment>
+ </outParameter>
+ </outParameter-list>
+ </component-service>
+ <component-service>
+ <service-name>IsReadyToCompute</service-name>
+ <service-author></service-author>
+ <service-version></service-version>
+ <service-comment></service-comment>
+ <service-by-default>1</service-by-default>
+ <inParameter-list>
+ <inParameter>
+ <inParameter-type>SMESH_Mesh</inParameter-type>
+ <inParameter-name>aMesh</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ <inParameter>
+ <inParameter-type>GEOM_Shape</inParameter-type>
+ <inParameter-name>aSubShape</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ </inParameter-list>
+ <outParameter-list>
+ <outParameter-type>boolean</outParameter-type>
+ <outParameter-name>res</outParameter-name>
+ <outParameter-comment>Result</outParameter-comment>
+ </outParameter-list>
+ </component-service>
+ </component-service-list>
+ <component-interface-name>SMESH_Mesh</component-interface-name>
+ <component-interface-comment></component-interface-comment>
+ <component-service-list>
+ <component-service>
+ <service-name>AddHypothesis</service-name>
+ <service-author></service-author>
+ <service-version></service-version>
+ <service-comment></service-comment>
+ <service-by-default>1</service-by-default>
+ <inParameter-list>
+ <inParameter>
+ <inParameter-type>GEOM_Shape</inParameter-type>
+ <inParameter-name>aSubShape</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ <inParameter>
+ <inParameter-type>SMESH_Hypothesis</inParameter-type>
+ <inParameter-name>aHyp</inParameter-name>
+ <inParameter-comment></inParameter-comment>
+ </inParameter>
+ </inParameter-list>
+ <outParameter-list>
+ <outParameter>
+ <outParameter-type>boolean</outParameter-type>
+ <outParameter-name>res</outParameter-name>
+ <outParameter-comment>Result</outParameter-comment>
+ </outParameter>
+ </outParameter-list>
+ </component-service>
+ </component-service-list>
+ </component-interface-list>
+ <constraint>hostname = localhost</constraint>
+ </component>
+</component-list>
+</begin-catalog>
--- /dev/null
+<?xml version='1.0' encoding='us-ascii'?>
+<!DOCTYPE application PUBLIC "" "desktop.dtd">
+
+<!-- GUI customization for MESH component -->
+
+<application
+ title="Mesh component"
+ date="13/05/2002"
+ author="Nicolas REJNERI"
+ appId="Mesh for Salome" >
+
+<desktop>
+<menubar>
+
+<!-- ************************** File (menubar) ************************************ -->
+<menu-item label-id="File" item-id="1" pos-id="">
+ <submenu label-id="Import" item-id="11" pos-id="8">
+ <popup-item item-id="111" pos-id="" label-id="DAT file" icon-id="" tooltip-id="" accel-id="Ctrl+B" toggle-id="" execute-action=""/>
+ <popup-item item-id="112" pos-id="" label-id="UNV File" icon-id="" tooltip-id="" accel-id="Ctrl+I" toggle-id="" execute-action=""/>
+ <popup-item item-id="113" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <submenu label-id="Export" item-id="12" pos-id="9">
+ <popup-item item-id="121" pos-id="" label-id="DAT File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="122" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="123" pos-id="" label-id="UNV File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <separator pos-id="10"/>
+</menu-item>
+
+<!-- ************************* Edit (menubar) ************************************** -->
+<menu-item label-id="Edit" item-id="3" pos-id="2">
+ <separator pos-id=""/>
+ <popup-item item-id="33" pos-id="" label-id="Delete" icon-id="delete.png" tooltip-id="" accel-id="" toggle-id="" execute-action="" />
+</menu-item>
+
+<!-- ************************** Hypothesis (menubar) ************************************ -->
+<menu-item label-id="Hypotheses" item-id="50" pos-id="3">
+ <popup-item item-id="5030" pos-id="" label-id="Average length" icon-id="mesh_hypo_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5031" pos-id="" label-id="Nb. Segments" icon-id="mesh_hypo_segment.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5032" pos-id="" label-id="Max. Triangle Area" icon-id="mesh_hypo_area.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5033" pos-id="" label-id="Max. Hexahedron Volume" icon-id="mesh_hypo_volume.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="5000" pos-id="" label-id="Wire discretisation" icon-id="mesh_algo_regular.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5010" pos-id="" label-id="Triangle (Mefisto)" icon-id="mesh_algo_mefisto.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5011" pos-id="" label-id="Quadrangle (Mapping)" icon-id="mesh_algo_quad.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5020" pos-id="" label-id="Hexaedron (i,j,k)" icon-id="mesh_algo_hexa.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</menu-item>
+
+<!-- ************************** Mesh (menubar) ************************************ -->
+<menu-item label-id="Mesh" item-id="70" pos-id="4">
+ <popup-item item-id="703" pos-id="" label-id="Global Hyp." icon-id="mesh_init.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="702" pos-id="" label-id="Local Hyp." icon-id="mesh_add_sub.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="704" pos-id="" label-id="Edit Hyp." icon-id="mesh_edit.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="701" pos-id="" label-id="Compute" icon-id="mesh_compute.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="900" pos-id="" label-id="Mesh Infos" icon-id="mesh_info.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</menu-item>
+
+<!-- ************************** Control (menubar) ************************************ -->
+<menu-item label-id="Controls" item-id="60" pos-id="5">
+ <popup-item item-id="6001" pos-id="" label-id="Length" icon-id="mesh_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6002" pos-id="" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6011" pos-id="" label-id="Area" icon-id="mesh_area.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6012" pos-id="" label-id="Taper" icon-id="mesh_taper.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6013" pos-id="" label-id="Aspect Ratio" icon-id="mesh_aspect.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6014" pos-id="" label-id="Minimum angle" icon-id="mesh_angle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6015" pos-id="" label-id="Warp" icon-id="mesh_wrap.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6016" pos-id="" label-id="Skew" icon-id="mesh_skew.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</menu-item>
+
+<!-- ************************** Entity (menubar) ************************************ -->
+<menu-item label-id="Modification" item-id="40" pos-id="6">
+ <submenu label-id="Add" item-id="402" pos-id="">
+ <popup-item item-id="400" pos-id="" label-id="Node" icon-id="mesh_vertex.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="401" pos-id="" label-id="Beam" icon-id="mesh_line.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="4021" pos-id="" label-id="Triangle" icon-id="mesh_triangle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="4022" pos-id="" label-id="Quadrangle" icon-id="mesh_quad.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="4031" pos-id="" label-id="Tetrahedron" icon-id="mesh_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="4032" pos-id="" label-id="Hexahedron" icon-id="mesh_hexa.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <submenu label-id="Remove" item-id="403" pos-id="">
+ <popup-item item-id="4041" pos-id="" label-id="Nodes" icon-id="mesh_rem_node.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="4042" pos-id="" label-id="Elements" icon-id="mesh_rem_element.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <popup-item item-id="405" pos-id="" label-id="Move Node" icon-id="mesh_move_node.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="806" pos-id="" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="807" pos-id="" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</menu-item>
+
+<!-- ************************** Numbering (menubar) ************************************ -->
+<menu-item label-id="Numbering" item-id="80" pos-id="7">
+ <popup-item item-id="9010" pos-id="" label-id="Display Nodes #" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+ <popup-item item-id="9011" pos-id="" label-id="Display Elements #" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+</menu-item>
+
+<!-- ********************************* Settings (menubar) ********************************* -->
+<menu-item label-id="Preferences" item-id="4" pos-id="">
+ <submenu label-id="Mesh" item-id="100" pos-id="-1">
+ <submenu label-id="Display Mode" item-id="1000" pos-id="">
+ <popup-item item-id="10001" pos-id="" label-id="Wireframe" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+ <popup-item item-id="10002" pos-id="" label-id="Shading" icon-id="" tooltip-id=""accel-id="" toggle-id="true" execute-action=""/>
+ <popup-item item-id="10003" pos-id="" label-id="Shrink" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <popup-item item-id="1001" pos-id="" label-id="Automatic Update" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="1003" pos-id="" label-id="Colors - Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="1005" pos-id="" label-id="Scalars Bar" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <separator pos-id="-1"/>
+</menu-item>
+
+<!-- ********************************* View (menubar) ********************************* -->
+<menu-item label-id="View" item-id="2" pos-id="">
+ <submenu label-id="Display Mode" item-id="21" pos-id="">
+ <popup-item item-id="211" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="212" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id=""accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <separator pos-id=""/>
+ <popup-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</menu-item>
+
+<!-- ################################# POPUP MENU ################################# -->
+
+<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Mesh">
+ <popup-item item-id="705" pos-id="" label-id="Edit Global Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="701" pos-id="" label-id="Compute" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="214" pos-id="" label-id="Update" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</popupmenu>
+
+<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="SubMesh">
+ <popup-item item-id="706" pos-id="" label-id="Edit Local Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</popupmenu>
+
+<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Hypothesis">
+ <popup-item item-id="1100" pos-id="" label-id="Edit" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="1102" pos-id="" label-id="Unassign Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</popupmenu>
+<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Algorithm">
+ <popup-item item-id="1102" pos-id="" label-id="Unassign Algo." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</popupmenu>
+
+
+
+<popupmenu label-id="Popup for Viewer" context-id="" parent-id="Viewer" object-id="Mesh">
+ <popup-item item-id="214" pos-id="" label-id="Update" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <submenu label-id="Properties" item-id="113" pos-id="">
+ <submenu label-id="Display Mode" item-id="1131" pos-id="">
+ <popup-item item-id="211" pos-id="" label-id="Wireframe" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="212" pos-id="" label-id="Shading" icon-id="" tooltip-id=""accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <separator pos-id=""/>
+ <popup-item item-id="1132" pos-id="" label-id="Colors - Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="1133" pos-id="" label-id="Transparency" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+</popupmenu>
+
+<popupmenu label-id="ScalarBar" context-id="" parent-id="Viewer" object-id="ScalarBar">
+ <popup-item item-id="200" pos-id="" label-id="Erase" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="201" pos-id="" label-id="Edit" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="202" pos-id="" label-id="Update View" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</popupmenu>
+
+</menubar>
+
+<!-- ///////////////////////////////////// TOOLBARS ////////////////////////////////////// -->
+<toolbar label-id="Mesh Toolbar">
+ <toolbutton-item item-id="703" pos-id="" label-id="Init" icon-id="mesh_init.png" tooltip-id="Global Hyp." accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="702" pos-id="" label-id="Add SubMesh" icon-id="mesh_add_sub.png" tooltip-id="Local Hyp." accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="704" pos-id="" label-id="Edit" icon-id="mesh_edit.png" tooltip-id="Edit Hyp." accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="701" pos-id="" label-id="Compute" icon-id="mesh_compute.png" tooltip-id="Compute" accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="900" pos-id="" label-id="Mesh Infos" icon-id="mesh_info.png" tooltip-id="Mesh Infos" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+<toolbar label-id="Hypotheses Toolbar">
+ <toolbutton-item item-id="5030" label-id="Average length" icon-id="mesh_hypo_length.png" tooltip-id="Avreage length Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5031" label-id="Segments" icon-id="mesh_hypo_segment.png" tooltip-id="Nb. Segments Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5032" label-id="Max. Triangle Area" icon-id="mesh_hypo_area.png" tooltip-id="Max. Triangle Area Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5033" label-id="Max. Hexaedron Volume" icon-id="mesh_hypo_volume.png" tooltip-id="Max. Hexaedron Volume Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="5000" label-id="Wire Discretisation" icon-id="mesh_algo_regular.png" tooltip-id="Wire Discratisation Algorithm" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5010" label-id="Triangle (Mefisto)" icon-id="mesh_algo_mefisto.png" tooltip-id="Triangle (Mefisto) Algorithm" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5011" label-id="Quadrangle (Mapping)" icon-id="mesh_algo_quad.png" tooltip-id="Quadrangle (Mapping) Algorithm" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5020" label-id="Hexaedron (i,j,k)" icon-id="mesh_algo_hexa.png" tooltip-id="Hexaedron (i,j,k) Algorithm" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+<toolbar label-id="Controls toolbar">
+ <toolbutton-item item-id="6001" label-id="Length" icon-id="mesh_length.png" tooltip-id="Length" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6002" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="Connectivity" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6011" label-id="Area" icon-id="mesh_area.png" tooltip-id="Area" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6012" label-id="Taper" icon-id="mesh_taper.png" tooltip-id="Taper" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6013" label-id="Aspect Ratio" icon-id="mesh_aspect.png" tooltip-id="Aspect Ratio" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6014" label-id="Minimum angle" icon-id="mesh_angle.png" tooltip-id="Minimum angle" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6015" label-id="Warp" icon-id="mesh_wrap.png" tooltip-id="Warp" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6016" label-id="Skew" icon-id="mesh_skew.png" tooltip-id="Skew" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+<toolbar label-id="Add/Remove toolbar">
+ <toolbutton-item item-id="400" label-id="Node" icon-id="mesh_vertex.png" tooltip-id="Add Node" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="401" label-id="Beam" icon-id="mesh_line.png" tooltip-id="Add Beam" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4021" label-id="Triangle" icon-id="mesh_triangle.png" tooltip-id="Add Triangle" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4022" label-id="Quadrangle" icon-id="mesh_quad.png" tooltip-id="Add Quadrangle" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4031" label-id="Tetrahedron" icon-id="mesh_tetra.png" tooltip-id="Add Tetrahedron" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4032" label-id="Hexahedron" icon-id="mesh_hexa.png" tooltip-id="Add Hexahedron" accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="4041" label-id="Nodes" icon-id="mesh_rem_node.png" tooltip-id="Remove Nodes" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4042" label-id="Elements" icon-id="mesh_rem_element.png" tooltip-id="Remove Elements" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+<toolbar label-id="Modification toolbar">
+ <toolbutton-item item-id="405" label-id="Move Node" icon-id="mesh_move_node.png" tooltip-id="Move Node" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="806" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="Orientation" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="807" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="Diagonal Inversion" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+<toolbar label-id="Display Mode Toolbar">
+ <toolbutton-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="Update View" accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="211" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="Wireframe" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="212" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id="shading" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="shrink" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+</desktop>
+
+</application>
--- /dev/null
+<?xml version='1.0' encoding='us-ascii'?>
+<!DOCTYPE application PUBLIC "" "desktop.dtd">
+
+<!-- GUI customization for MESH component -->
+
+<application
+ title="Mesh component"
+ date="13/05/2002"
+ author="Nicolas REJNERI"
+ appId="Mesh for Salome" >
+
+<desktop>
+<menubar>
+
+<!-- ************************** File (menubar) ************************************ -->
+<menu-item label-id="File" item-id="1" pos-id="">
+ <submenu label-id="Import" item-id="11" pos-id="8">
+ <popup-item item-id="111" pos-id="" label-id="DAT file" icon-id="" tooltip-id="" accel-id="Ctrl+B" toggle-id="" execute-action=""/>
+ <popup-item item-id="112" pos-id="" label-id="UNV File" icon-id="" tooltip-id="" accel-id="Ctrl+I" toggle-id="" execute-action=""/>
+ <popup-item item-id="113" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <submenu label-id="Export" item-id="12" pos-id="9">
+ <popup-item item-id="121" pos-id="" label-id="DAT File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="122" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="123" pos-id="" label-id="UNV File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <separator pos-id="10"/>
+</menu-item>
+
+<!-- ************************* Edit (menubar) ************************************** -->
+<menu-item label-id="Edit" item-id="3" pos-id="2">
+ <separator pos-id=""/>
+ <popup-item item-id="33" pos-id="" label-id="Delete" icon-id="delete.png" tooltip-id="" accel-id="" toggle-id="" execute-action="" />
+</menu-item>
+
+<!-- ************************** Hypothesis (menubar) ************************************ -->
+<menu-item label-id="Hypotheses" item-id="50" pos-id="3">
+ <popup-item item-id="5030" pos-id="" label-id="Average length" icon-id="mesh_hypo_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5031" pos-id="" label-id="Nb. Segments" icon-id="mesh_hypo_segment.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5032" pos-id="" label-id="Max. Triangle Area" icon-id="mesh_hypo_area.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5033" pos-id="" label-id="Max. Hexahedron Volume" icon-id="mesh_hypo_volume.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="5000" pos-id="" label-id="Wire discretisation" icon-id="mesh_algo_regular.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5010" pos-id="" label-id="Triangle (Mefisto)" icon-id="mesh_algo_mefisto.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5011" pos-id="" label-id="Quadrangle (Mapping)" icon-id="mesh_algo_quad.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="5020" pos-id="" label-id="Hexaedron (i,j,k)" icon-id="mesh_algo_hexa.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</menu-item>
+
+<!-- ************************** Mesh (menubar) ************************************ -->
+<menu-item label-id="Mesh" item-id="70" pos-id="4">
+ <popup-item item-id="703" pos-id="" label-id="Global Hyp." icon-id="mesh_init.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="702" pos-id="" label-id="Local Hyp." icon-id="mesh_add_sub.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="704" pos-id="" label-id="Edit Hyp." icon-id="mesh_edit.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="701" pos-id="" label-id="Compute" icon-id="mesh_compute.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="900" pos-id="" label-id="Mesh Infos" icon-id="mesh_info.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</menu-item>
+
+<!-- ************************** Control (menubar) ************************************ -->
+<menu-item label-id="Controls" item-id="60" pos-id="5">
+ <popup-item item-id="6001" pos-id="" label-id="Length" icon-id="mesh_length.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6002" pos-id="" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6011" pos-id="" label-id="Area" icon-id="mesh_area.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6012" pos-id="" label-id="Taper" icon-id="mesh_taper.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6013" pos-id="" label-id="Aspect Ratio" icon-id="mesh_aspect.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6014" pos-id="" label-id="Minimum angle" icon-id="mesh_angle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6015" pos-id="" label-id="Warp" icon-id="mesh_wrap.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6016" pos-id="" label-id="Skew" icon-id="mesh_skew.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</menu-item>
+
+<!-- ************************** Entity (menubar) ************************************ -->
+<menu-item label-id="Modification" item-id="40" pos-id="6">
+ <submenu label-id="Add" item-id="402" pos-id="">
+ <popup-item item-id="400" pos-id="" label-id="Node" icon-id="mesh_vertex.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="401" pos-id="" label-id="Beam" icon-id="mesh_line.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="4021" pos-id="" label-id="Triangle" icon-id="mesh_triangle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="4022" pos-id="" label-id="Quadrangle" icon-id="mesh_quad.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="4031" pos-id="" label-id="Tetrahedron" icon-id="mesh_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="4032" pos-id="" label-id="Hexahedron" icon-id="mesh_hexa.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <submenu label-id="Remove" item-id="403" pos-id="">
+ <popup-item item-id="4041" pos-id="" label-id="Nodes" icon-id="mesh_rem_node.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="4042" pos-id="" label-id="Elements" icon-id="mesh_rem_element.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <popup-item item-id="405" pos-id="" label-id="Move Node" icon-id="mesh_move_node.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="806" pos-id="" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="807" pos-id="" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</menu-item>
+
+<!-- ************************** Numbering (menubar) ************************************ -->
+<menu-item label-id="Numbering" item-id="80" pos-id="7">
+ <popup-item item-id="9010" pos-id="" label-id="Display Nodes #" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+ <popup-item item-id="9011" pos-id="" label-id="Display Elements #" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+</menu-item>
+
+<!-- ********************************* Settings (menubar) ********************************* -->
+<menu-item label-id="Preferences" item-id="4" pos-id="">
+ <submenu label-id="Mesh" item-id="100" pos-id="-1">
+ <submenu label-id="Display Mode" item-id="1000" pos-id="">
+ <popup-item item-id="10001" pos-id="" label-id="Wireframe" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+ <popup-item item-id="10002" pos-id="" label-id="Shading" icon-id="" tooltip-id=""accel-id="" toggle-id="true" execute-action=""/>
+ <popup-item item-id="10003" pos-id="" label-id="Shrink" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <popup-item item-id="1001" pos-id="" label-id="Automatic Update" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="1003" pos-id="" label-id="Colors - Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="1005" pos-id="" label-id="Scalars Bar" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <separator pos-id="-1"/>
+</menu-item>
+
+<!-- ********************************* View (menubar) ********************************* -->
+<menu-item label-id="View" item-id="2" pos-id="">
+ <submenu label-id="Display Mode" item-id="21" pos-id="">
+ <popup-item item-id="211" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="212" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id=""accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <separator pos-id=""/>
+ <popup-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</menu-item>
+
+<!-- ################################# POPUP MENU ################################# -->
+
+<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Mesh">
+ <popup-item item-id="705" pos-id="" label-id="Edit Global Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="701" pos-id="" label-id="Compute" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="214" pos-id="" label-id="Update" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</popupmenu>
+
+<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="SubMesh">
+ <popup-item item-id="706" pos-id="" label-id="Edit Local Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</popupmenu>
+
+<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Hypothesis">
+ <popup-item item-id="1100" pos-id="" label-id="Edit" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="1102" pos-id="" label-id="Unassign Hyp." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</popupmenu>
+<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="Algorithm">
+ <popup-item item-id="1102" pos-id="" label-id="Unassign Algo." icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="1101" pos-id="" label-id="Rename" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</popupmenu>
+
+
+
+<popupmenu label-id="Popup for Viewer" context-id="" parent-id="Viewer" object-id="Mesh">
+ <popup-item item-id="214" pos-id="" label-id="Update" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <submenu label-id="Properties" item-id="113" pos-id="">
+ <submenu label-id="Display Mode" item-id="1131" pos-id="">
+ <popup-item item-id="211" pos-id="" label-id="Wireframe" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="212" pos-id="" label-id="Shading" icon-id="" tooltip-id=""accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="213" pos-id="" label-id="Shrink" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+ <separator pos-id=""/>
+ <popup-item item-id="1132" pos-id="" label-id="Colors - Size" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="1133" pos-id="" label-id="Transparency" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
+</popupmenu>
+
+<popupmenu label-id="ScalarBar" context-id="" parent-id="Viewer" object-id="ScalarBar">
+ <popup-item item-id="200" pos-id="" label-id="Erase" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="201" pos-id="" label-id="Edit" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="202" pos-id="" label-id="Update View" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+</popupmenu>
+
+</menubar>
+
+<!-- ///////////////////////////////////// TOOLBARS ////////////////////////////////////// -->
+<toolbar label-id="Mesh Toolbar">
+ <toolbutton-item item-id="703" pos-id="" label-id="Init" icon-id="mesh_init.png" tooltip-id="Global Hyp." accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="702" pos-id="" label-id="Add SubMesh" icon-id="mesh_add_sub.png" tooltip-id="Local Hyp." accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="704" pos-id="" label-id="Edit" icon-id="mesh_edit.png" tooltip-id="Edit Hyp." accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="701" pos-id="" label-id="Compute" icon-id="mesh_compute.png" tooltip-id="Compute" accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="900" pos-id="" label-id="Mesh Infos" icon-id="mesh_info.png" tooltip-id="Mesh Infos" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+<toolbar label-id="Hypotheses Toolbar">
+ <toolbutton-item item-id="5030" label-id="Average length" icon-id="mesh_hypo_length.png" tooltip-id="Avreage length Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5031" label-id="Segments" icon-id="mesh_hypo_segment.png" tooltip-id="Nb. Segments Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5032" label-id="Max. Triangle Area" icon-id="mesh_hypo_area.png" tooltip-id="Max. Triangle Area Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5033" label-id="Max. Hexaedron Volume" icon-id="mesh_hypo_volume.png" tooltip-id="Max. Hexaedron Volume Hypothesis" accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="5000" label-id="Wire Discretisation" icon-id="mesh_algo_regular.png" tooltip-id="Wire Discratisation Algorithm" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5010" label-id="Triangle (Mefisto)" icon-id="mesh_algo_mefisto.png" tooltip-id="Triangle (Mefisto) Algorithm" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5011" label-id="Quadrangle (Mapping)" icon-id="mesh_algo_quad.png" tooltip-id="Quadrangle (Mapping) Algorithm" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="5020" label-id="Hexaedron (i,j,k)" icon-id="mesh_algo_hexa.png" tooltip-id="Hexaedron (i,j,k) Algorithm" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+<toolbar label-id="Controls toolbar">
+ <toolbutton-item item-id="6001" label-id="Length" icon-id="mesh_length.png" tooltip-id="Length" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6002" label-id="Connectivity" icon-id="mesh_connectivity.png" tooltip-id="Connectivity" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6011" label-id="Area" icon-id="mesh_area.png" tooltip-id="Area" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6012" label-id="Taper" icon-id="mesh_taper.png" tooltip-id="Taper" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6013" label-id="Aspect Ratio" icon-id="mesh_aspect.png" tooltip-id="Aspect Ratio" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6014" label-id="Minimum angle" icon-id="mesh_angle.png" tooltip-id="Minimum angle" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6015" label-id="Warp" icon-id="mesh_wrap.png" tooltip-id="Warp" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6016" label-id="Skew" icon-id="mesh_skew.png" tooltip-id="Skew" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+<toolbar label-id="Add/Remove toolbar">
+ <toolbutton-item item-id="400" label-id="Node" icon-id="mesh_vertex.png" tooltip-id="Add Node" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="401" label-id="Beam" icon-id="mesh_line.png" tooltip-id="Add Beam" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4021" label-id="Triangle" icon-id="mesh_triangle.png" tooltip-id="Add Triangle" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4022" label-id="Quadrangle" icon-id="mesh_quad.png" tooltip-id="Add Quadrangle" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4031" label-id="Tetrahedron" icon-id="mesh_tetra.png" tooltip-id="Add Tetrahedron" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4032" label-id="Hexahedron" icon-id="mesh_hexa.png" tooltip-id="Add Hexahedron" accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="4041" label-id="Nodes" icon-id="mesh_rem_node.png" tooltip-id="Remove Nodes" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="4042" label-id="Elements" icon-id="mesh_rem_element.png" tooltip-id="Remove Elements" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+<toolbar label-id="Modification toolbar">
+ <toolbutton-item item-id="405" label-id="Move Node" icon-id="mesh_move_node.png" tooltip-id="Move Node" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="806" label-id="Orientation" icon-id="mesh_orientation.png" tooltip-id="Orientation" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="807" label-id="Diagonal Inversion" icon-id="mesh_diagonal.png" tooltip-id="Diagonal Inversion" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+<toolbar label-id="Display Mode Toolbar">
+ <toolbutton-item item-id="214" pos-id="" label-id="Update" icon-id="mesh_update.png" tooltip-id="Update View" accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="211" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="Wireframe" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="212" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id="shading" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="213" pos-id="" label-id="Shrink" icon-id="mesh_shrink.png" tooltip-id="shrink" accel-id="" toggle-id="" execute-action=""/>
+</toolbar>
+
+</desktop>
+
+</application>
--- /dev/null
+using namespace std;
+#include "DriverDAT_R_SMDS_Mesh.h"
+
+#include "utilities.h"
+
+DriverDAT_R_SMDS_Mesh::DriverDAT_R_SMDS_Mesh() {
+;
+}
+
+DriverDAT_R_SMDS_Mesh::~DriverDAT_R_SMDS_Mesh() {
+;
+}
+
+void DriverDAT_R_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+ myMesh = aMesh;
+}
+
+void DriverDAT_R_SMDS_Mesh::SetFile(string aFile) {
+ myFile = aFile;
+}
+
+void DriverDAT_R_SMDS_Mesh::SetFileId(FILE* aFileId) {
+ myFileId = aFileId;
+}
+
+void DriverDAT_R_SMDS_Mesh::SetMeshId(int aMeshId) {
+ myMeshId = aMeshId;
+}
+
+void DriverDAT_R_SMDS_Mesh::Add() {
+ ;
+}
+
+void DriverDAT_R_SMDS_Mesh::Read() {
+
+ int i,j;
+ int nbNodes,nbCells;
+ int intNumPoint;
+ float coordX, coordY, coordZ;
+ int nbNoeuds;
+
+ int intNumMaille,Degre;
+ int ValElement;
+ int ValDegre;
+ int NoeudsMaille[20];
+ int NoeudMaille;
+
+ bool ok;
+
+ MESSAGE("in DriverDAT_R_SMDS_Mesh::Read()");
+ /****************************************************************************
+ * OUVERTURE DU FICHIER EN LECTURE *
+ ****************************************************************************/
+ char* file2Read = (char*)myFile.c_str();
+ myFileId = fopen(file2Read,"r");
+ if (myFileId < 0)
+ {
+ fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+ exit(EXIT_FAILURE);
+ }
+
+ fscanf(myFileId,"%d %d\n",&nbNodes,&nbCells);
+
+ /****************************************************************************
+ * LECTURE DES NOEUDS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(************************)\n");
+ fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
+ fprintf(stdout,"(************************)\n");
+
+ for (i=0;i<nbNodes;i++) {
+ fscanf(myFileId,"%d %e %e %e\n",&intNumPoint,&coordX,&coordY,&coordZ);
+ ok = myMesh->AddNodeWithID(coordX,coordY,coordZ,intNumPoint);
+ }
+
+ fprintf(stdout,"%d noeuds\n",myMesh->NbNodes());
+ /****************************************************************************
+ * LECTURE DES ELEMENTS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(**************************)\n");
+ fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
+ fprintf(stdout,"(**************************)");
+
+ fprintf(stdout,"%d elements\n",nbCells);
+
+ for (i=0; i<nbCells; i++) {
+ fscanf(myFileId,"%d %d",&intNumMaille,&ValElement);
+ Degre=abs(ValElement/100);
+ nbNoeuds=ValElement-(Degre*100);
+
+ // Recuperation des noeuds de la maille
+ for (j=0; j<nbNoeuds; j++) {
+ fscanf(myFileId,"%d",&NoeudMaille);
+ NoeudsMaille[j]=NoeudMaille;
+ }
+
+ // Analyse des cas de cellules
+ switch (ValElement) {
+ case 102 : ;
+ case 103 : ;
+ {
+ ValDegre=3;
+ nbNoeuds=2;
+ ok = myMesh->AddEdgeWithID(NoeudsMaille[0],NoeudsMaille[1],intNumMaille);
+ break;
+ }
+ case 204 : ;
+ case 208 : ;
+ {
+ ValDegre=9;
+ nbNoeuds=4;
+ ok = myMesh->AddFaceWithID(NoeudsMaille[0],NoeudsMaille[1],NoeudsMaille[2],NoeudsMaille[3],intNumMaille);
+ break;
+ }
+ case 203 : ;
+ case 206 : ;
+ {
+ ValDegre=5;
+ nbNoeuds=3;
+ ok = myMesh->AddFaceWithID(NoeudsMaille[0],NoeudsMaille[1],NoeudsMaille[2],intNumMaille);
+ break;
+ }
+ case 308 : ;
+ case 320 : ;
+ {
+ ValDegre=12;
+ nbNoeuds=8;
+ if (ValElement==320) {
+ //A voir, correspondance VTK
+ NoeudsMaille[4]=NoeudsMaille[8];
+ NoeudsMaille[5]=NoeudsMaille[9];
+ NoeudsMaille[6]=NoeudsMaille[10];
+ NoeudsMaille[7]=NoeudsMaille[11];
+ }
+ ok = myMesh->AddVolumeWithID(NoeudsMaille[0],NoeudsMaille[1],NoeudsMaille[2],NoeudsMaille[3],NoeudsMaille[4],NoeudsMaille[5],NoeudsMaille[6],NoeudsMaille[7],intNumMaille);
+ break;
+ }
+ case 304 : ;
+ case 310 : ;
+ {
+ ValDegre=10;
+ nbNoeuds=4;
+ if (ValElement==310)
+ NoeudsMaille[3]=NoeudsMaille[6];
+ ok = myMesh->AddVolumeWithID(NoeudsMaille[0],NoeudsMaille[1],NoeudsMaille[2],NoeudsMaille[3],intNumMaille);
+ break;
+ }
+ case 306 : ;
+ case 315 : ;
+ {
+ ValDegre=12;
+ nbNoeuds=8;
+ if (ValElement==315) {
+ NoeudsMaille[3]=NoeudsMaille[6];
+ NoeudsMaille[4]=NoeudsMaille[7];
+ NoeudsMaille[5]=NoeudsMaille[8];
+ }
+ NoeudsMaille[7]=NoeudsMaille[5];
+ NoeudsMaille[6]=NoeudsMaille[5];
+ NoeudsMaille[5]=NoeudsMaille[4];
+ NoeudsMaille[4]=NoeudsMaille[3];
+ NoeudsMaille[3]=NoeudsMaille[2];
+ ok = myMesh->AddVolumeWithID(NoeudsMaille[0],NoeudsMaille[1],NoeudsMaille[2],NoeudsMaille[3],NoeudsMaille[4],NoeudsMaille[5],intNumMaille);
+ break;
+ }
+
+ }
+ }
+
+ /****************************************************************************
+ * FERMETURE DU FICHIER *
+ ****************************************************************************/
+ fclose(myFileId);
+
+}
--- /dev/null
+#ifndef _INCLUDE_DRIVERDAT_R_SMDS_MESH
+#define _INCLUDE_DRIVERDAT_R_SMDS_MESH
+
+#include <stdio.h>
+
+#include "SMDS_Mesh.hxx"
+#include "Mesh_Reader.h"
+
+class DriverDAT_R_SMDS_Mesh : public Mesh_Reader {
+
+ public :
+ DriverDAT_R_SMDS_Mesh();
+ ~DriverDAT_R_SMDS_Mesh();
+
+ void Add();
+ void Read();
+ void SetMesh(Handle(SMDS_Mesh)& aMesh);
+ void SetFile(string);
+
+ void SetFileId(FILE*);
+ void SetMeshId(int);
+
+ private :
+ Handle_SMDS_Mesh myMesh;
+ string myFile;
+ FILE* myFileId;
+ int myMeshId;
+
+};
+#endif
--- /dev/null
+using namespace std;
+#include "DriverDAT_R_SMESHDS_Document.h"
+#include "DriverDAT_R_SMESHDS_Mesh.h"
+
+#include "utilities.h"
+
+int getOne() {
+ printf("in getOne");
+ return (1);
+}
+
+extern "C" {
+ // Document_Reader* maker() {
+ DriverDAT_R_SMESHDS_Document* maker() {
+ fprintf(stdout,"here in maker\n");
+ return new DriverDAT_R_SMESHDS_Document;
+ }
+}
+
+DriverDAT_R_SMESHDS_Document::DriverDAT_R_SMESHDS_Document() {
+ myFile = string("");
+}
+
+DriverDAT_R_SMESHDS_Document::~DriverDAT_R_SMESHDS_Document() {
+;
+}
+
+//void DriverDAT_R_SMESHDS_Document::SetFile(string aFile) {
+//myFile = aFile;
+//}
+
+//void DriverDAT_R_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDoc) {
+//myDocument = aDoc;
+//}
+
+void DriverDAT_R_SMESHDS_Document::Read() {
+
+ int myMeshId;
+ MESSAGE("in read");
+ SCRUTE(myFile);
+ //Handle(SMESHDS_Document) myDocument = new SMESHDS_Document(1);
+
+ /****************************************************************************
+ * OUVERTURE DU FICHIER EN LECTURE *
+ ****************************************************************************/
+ char* file2Read = (char*)myFile.c_str();
+ FILE* fid = fopen(file2Read,"r");
+ if (fid < 0)
+ {
+ fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+ exit(EXIT_FAILURE);
+ }
+
+ /****************************************************************************
+ * COMBIEN DE MAILLAGES ? *
+ ****************************************************************************/
+ int nmaa = 1;
+
+ /****************************************************************************
+ * FERMETURE DU FICHIER *
+ ****************************************************************************/
+ fclose(fid);
+
+ printf("Nombre de maillages = %d\n",nmaa);
+
+ string myClass = string("SMESHDS_Mesh");
+ string myExtension = string("DAT");
+
+ for (int meshIt=1;meshIt<=nmaa;meshIt++) {
+ myMeshId = myDocument->NewMesh();
+
+ Handle(SMDS_Mesh) myMesh = myDocument->GetMesh(myMeshId);
+
+ DriverDAT_R_SMESHDS_Mesh* myReader = new DriverDAT_R_SMESHDS_Mesh;
+
+
+ myReader->SetMesh(myMesh);
+ myReader->SetFile(myFile);
+ //myReader->SetFileId(fid);
+
+ myReader->Read();
+
+ }
+
+
+}
--- /dev/null
+#ifndef _INCLUDE_DRIVERDAT_R_SMESHDS_DOCUMENT
+#define _INCLUDE_DRIVERDAT_R_SMESHDS_DOCUMENT
+
+#include <stdio.h>
+
+#include "SMESHDS_Document.hxx"
+#include "Document_Reader.h"
+
+class DriverDAT_R_SMESHDS_Document : public Document_Reader {
+
+public :
+ DriverDAT_R_SMESHDS_Document();
+ ~DriverDAT_R_SMESHDS_Document();
+
+ void Read();
+ //void SetFile(string);
+ //void SetDocument(Handle_SMESHDS_Document&);
+
+private :
+ //Handle_SMESHDS_Document myDocument;
+ //string myFile;
+
+};
+#endif
--- /dev/null
+using namespace std;
+#include "DriverDAT_R_SMESHDS_Mesh.h"
+#include "DriverDAT_R_SMDS_Mesh.h"
+
+#include "utilities.h"
+
+DriverDAT_R_SMESHDS_Mesh::DriverDAT_R_SMESHDS_Mesh() {
+;
+}
+
+DriverDAT_R_SMESHDS_Mesh::~DriverDAT_R_SMESHDS_Mesh() {
+;
+}
+
+void DriverDAT_R_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+ //myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh);
+ myMesh = aMesh;
+}
+
+void DriverDAT_R_SMESHDS_Mesh::SetFile(string aFile) {
+ myFile = aFile;
+}
+
+void DriverDAT_R_SMESHDS_Mesh::SetFileId(FILE* aFileId) {
+ myFileId = aFileId;
+}
+
+void DriverDAT_R_SMESHDS_Mesh::SetMeshId(int aMeshId) {
+ myMeshId = aMeshId;
+}
+
+void DriverDAT_R_SMESHDS_Mesh::Add() {
+ ;
+}
+
+void DriverDAT_R_SMESHDS_Mesh::Read() {
+ string myClass = string("SMDS_Mesh");
+ string myExtension = string("DAT");
+
+ MESSAGE("in DriverDAT_R_SMESHDS_Mesh::Read() 1");
+ DriverDAT_R_SMDS_Mesh* myReader = new DriverDAT_R_SMDS_Mesh;
+
+ MESSAGE("in DriverDAT_R_SMESHDS_Mesh::Read() 2");
+ myReader->SetMesh(myMesh);
+ MESSAGE("in DriverDAT_R_SMESHDS_Mesh::Read() 3");
+ myReader->SetFile(myFile);
+ //myReader->SetFileId(myFileId);
+
+ MESSAGE("in DriverDAT_R_SMESHDS_Mesh::Read() 4");
+ myReader->Read();
+
+}
--- /dev/null
+#ifndef _INCLUDE_DRIVERDAT_R_SMESHDS_MESH
+#define _INCLUDE_DRIVERDAT_R_SMESHDS_MESH
+
+#include <stdio.h>
+
+#include "SMESHDS_Mesh.hxx"
+#include "Mesh_Reader.h"
+
+class DriverDAT_R_SMESHDS_Mesh : public Mesh_Reader {
+
+ public :
+ DriverDAT_R_SMESHDS_Mesh();
+ ~DriverDAT_R_SMESHDS_Mesh();
+
+ void Add();
+ void Read();
+ void SetMesh(Handle(SMDS_Mesh)& aMesh);
+ void SetFile(string);
+
+ void SetFileId(FILE*);
+ void SetMeshId(int);
+
+private :
+ Handle_SMDS_Mesh myMesh;
+ string myFile;
+ FILE* myFileId;
+ int myMeshId;
+
+};
+#endif
--- /dev/null
+using namespace std;
+#include "DriverDAT_W_SMDS_Mesh.h"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_MeshEdgesIterator.hxx"
+#include "SMDS_MeshFacesIterator.hxx"
+#include "SMDS_MeshNodesIterator.hxx"
+#include "SMDS_MeshVolumesIterator.hxx"
+
+#include "utilities.h"
+
+DriverDAT_W_SMDS_Mesh::DriverDAT_W_SMDS_Mesh() {
+;
+}
+
+DriverDAT_W_SMDS_Mesh::~DriverDAT_W_SMDS_Mesh() {
+;
+}
+
+void DriverDAT_W_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+ myMesh = aMesh;
+}
+
+void DriverDAT_W_SMDS_Mesh::SetFile(string aFile) {
+ myFile = aFile;
+}
+
+void DriverDAT_W_SMDS_Mesh::SetFileId(FILE* aFileId) {
+ myFileId = aFileId;
+}
+
+void DriverDAT_W_SMDS_Mesh::SetMeshId(int aMeshId) {
+ myMeshId = aMeshId;
+}
+
+void DriverDAT_W_SMDS_Mesh::Add() {
+ ;
+}
+
+void DriverDAT_W_SMDS_Mesh::Write() {
+
+ int nbNodes,nbCells;
+ int i;
+
+ char* file2Read = (char*)myFile.c_str();
+ myFileId = fopen(file2Read,"w+");
+ if (myFileId < 0)
+ {
+ fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+ exit(EXIT_FAILURE);
+ }
+ SCRUTE(myMesh);
+ /****************************************************************************
+ * NOMBRES D'OBJETS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(****************************)\n");
+ fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n");
+ fprintf(stdout,"(****************************)\n");
+
+ /* Combien de noeuds ? */
+ nbNodes = myMesh->NbNodes();
+
+ /* Combien de mailles, faces ou aretes ? */
+ Standard_Integer nb_of_nodes, nb_of_edges,nb_of_faces, nb_of_volumes;
+ nb_of_edges = myMesh->NbEdges();
+ nb_of_faces = myMesh->NbFaces();
+ nb_of_volumes = myMesh->NbVolumes();
+ nbCells = nb_of_edges + nb_of_faces + nb_of_volumes;
+ SCRUTE(nb_of_edges);
+ SCRUTE(nb_of_faces);
+ SCRUTE(nb_of_volumes);
+
+ fprintf(stdout,"%d %d\n",nbNodes,nbCells);
+ fprintf(myFileId,"%d %d\n",nbNodes,nbCells);
+
+ /****************************************************************************
+ * ECRITURE DES NOEUDS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(************************)\n");
+ fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
+ fprintf(stdout,"(************************)\n");
+
+ SMDS_MeshNodesIterator itNodes(myMesh);
+ for (;itNodes.More();itNodes.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itNodes.Value();
+ const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem);
+
+ fprintf(myFileId,"%d %e %e %e\n",node->GetID(),node->X(),node->Y(),node->Z());
+ }
+
+ /****************************************************************************
+ * ECRITURE DES ELEMENTS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(**************************)\n");
+ fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
+ fprintf(stdout,"(**************************)");
+ /* Ecriture des connectivites, noms, numeros des mailles */
+
+ SMDS_MeshEdgesIterator itEdges(myMesh);
+ for (;itEdges.More();itEdges.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itEdges.Value();
+
+ switch (elem->NbNodes()) {
+ case 2 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),102);
+ break;
+ }
+ case 3 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),103);
+ break;
+ }
+ }
+
+ for (i=0;i<elem->NbNodes();i++)
+ fprintf(myFileId,"%d ",elem->GetConnection(i+1));
+
+ fprintf(myFileId,"\n");
+ }
+
+ SMDS_MeshFacesIterator itFaces(myMesh);
+ for (;itFaces.More();itFaces.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itFaces.Value();
+
+ switch (elem->NbNodes()) {
+ case 3 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),203);
+ break;
+ }
+ case 4 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),204);
+ break;
+ }
+ case 6 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),206);
+ break;
+ }
+ }
+
+ for (i=0;i<elem->NbNodes();i++)
+ fprintf(myFileId,"%d ",elem->GetConnection(i+1));
+
+ fprintf(myFileId,"\n");
+ }
+
+ SMDS_MeshVolumesIterator itVolumes(myMesh);
+ for (;itVolumes.More();itVolumes.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
+
+ switch (elem->NbNodes()) {
+ case 8 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),308);
+ break;
+ }
+ }
+
+ for (i=0;i<elem->NbNodes();i++)
+ fprintf(myFileId,"%d ",elem->GetConnection(i+1));
+
+ fprintf(myFileId,"\n");
+ }
+
+ fclose (myFileId);
+}
--- /dev/null
+#ifndef _INCLUDE_DRIVERDAT_W_SMDS_MESH
+#define _INCLUDE_DRIVERDAT_W_SMDS_MESH
+
+#include <stdio.h>
+#include <string>
+
+#include "SMDS_Mesh.hxx"
+#include "Mesh_Writer.h"
+
+class DriverDAT_W_SMDS_Mesh : public Mesh_Writer {
+
+ public :
+ DriverDAT_W_SMDS_Mesh();
+ ~DriverDAT_W_SMDS_Mesh();
+
+ void Add();
+ void Write();
+ void SetMesh(Handle(SMDS_Mesh)& aMesh);
+ void SetFile(string);
+
+ void SetFileId(FILE*);
+ void SetMeshId(int);
+
+private :
+ Handle_SMDS_Mesh myMesh;
+ string myFile;
+ FILE* myFileId;
+ int myMeshId;
+
+};
+#endif
--- /dev/null
+using namespace std;
+#include "DriverDAT_W_SMESHDS_Document.h"
+#include "DriverDAT_W_SMESHDS_Mesh.h"
+
+#include "utilities.h"
+
+extern "C"
+{
+ Document_Writer* Wmaker() {
+ return new DriverDAT_W_SMESHDS_Document;
+ }
+}
+
+DriverDAT_W_SMESHDS_Document::DriverDAT_W_SMESHDS_Document() {
+;
+}
+
+DriverDAT_W_SMESHDS_Document::~DriverDAT_W_SMESHDS_Document() {
+;
+}
+
+//void DriverDAT_W_SMESHDS_Document::SetFile(string aFile) {
+//myFile = aFile;
+//}
+
+//void DriverDAT_W_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDocument) {
+//myDocument = aDocument;
+//}
+
+void DriverDAT_W_SMESHDS_Document::Write() {
+
+ Handle(SMESHDS_Mesh) myMesh;
+
+ /****************************************************************************
+ * OUVERTURE DU FICHIER EN ECRITURE *
+ ****************************************************************************/
+ char* file2Write = (char*)myFile.c_str();
+ FILE* fid = fopen(file2Write,"w+");
+ if (fid < 0)
+ {
+ fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Write);
+ exit(EXIT_FAILURE);
+ }
+
+ /****************************************************************************
+ * FERMETURE DU FICHIER *
+ ****************************************************************************/
+
+ fclose(fid);
+
+ /******** Nombre de maillages ********/
+ int nb_of_meshes = myDocument->NbMeshes(); //voir avec Yves
+ //nb_of_meshes = 1;
+ int numero = 0;
+
+ string myClass = string("SMESHDS_Mesh");
+ string myExtension = string("DAT");
+
+ //while (numero<nb_of_meshes) {
+ //numero++;
+ //myMesh = myDocument->GetMesh(numero);
+ myDocument->InitMeshesIterator();
+ for (;myDocument->MoreMesh();myDocument->NextMesh()) {
+ numero++;
+ myMesh = myDocument->CurrentMesh();
+
+ DriverDAT_W_SMESHDS_Mesh* myWriter = new DriverDAT_W_SMESHDS_Mesh;
+ //Mesh_Writer* myWriter = Driver::GetMeshWriter(myExtension, myClass);
+
+ myWriter->SetMesh(myMesh);
+ myWriter->SetFile(myFile);
+ SCRUTE(myMesh);
+ //myWriter->SetFileId(fid);
+ myWriter->SetMeshId(numero);
+ myWriter->Write();
+ }
+
+}
--- /dev/null
+#ifndef _INCLUDE_DRIVERDAT_W_SMESHDS_DOCUMENT
+#define _INCLUDE_DRIVERDAT_W_SMESHDS_DOCUMENT
+
+#include <stdio.h>
+#include <string>
+
+#include "SMESHDS_Document.hxx"
+#include "Document_Writer.h"
+
+class DriverDAT_W_SMESHDS_Document : public Document_Writer {
+
+public :
+ DriverDAT_W_SMESHDS_Document();
+ ~DriverDAT_W_SMESHDS_Document();
+
+ void Write();
+ //void SetFile(string);
+ //void SetDocument(Handle(SMESHDS_Document)&);
+
+private :
+ //Handle_SMESHDS_Document myDocument;
+ //string myFile;
+
+};
+#endif
--- /dev/null
+using namespace std;
+#include "DriverDAT_W_SMESHDS_Mesh.h"
+#include "DriverDAT_W_SMDS_Mesh.h"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_MeshEdgesIterator.hxx"
+#include "SMDS_MeshFacesIterator.hxx"
+#include "SMDS_MeshNodesIterator.hxx"
+#include "SMDS_MeshVolumesIterator.hxx"
+
+#include "utilities.h"
+
+DriverDAT_W_SMESHDS_Mesh::DriverDAT_W_SMESHDS_Mesh() {
+;
+}
+
+DriverDAT_W_SMESHDS_Mesh::~DriverDAT_W_SMESHDS_Mesh() {
+;
+}
+
+void DriverDAT_W_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+ //myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh);
+ myMesh = aMesh;
+}
+
+void DriverDAT_W_SMESHDS_Mesh::SetFile(string aFile) {
+ myFile = aFile;
+}
+
+void DriverDAT_W_SMESHDS_Mesh::SetFileId(FILE* aFileId) {
+ myFileId = aFileId;
+}
+
+void DriverDAT_W_SMESHDS_Mesh::SetMeshId(int aMeshId) {
+ myMeshId = aMeshId;
+}
+
+void DriverDAT_W_SMESHDS_Mesh::Write() {
+
+ string myClass = string("SMDS_Mesh");
+ string myExtension = string("DAT");
+
+ DriverDAT_W_SMDS_Mesh* myWriter = new DriverDAT_W_SMDS_Mesh;
+
+ myWriter->SetMesh(myMesh);
+ myWriter->SetFile(myFile);
+ myWriter->SetMeshId(myMeshId);
+ //myWriter->SetFileId(myFileId);
+
+ myWriter->Write();
+
+
+}
+void DriverDAT_W_SMESHDS_Mesh::Add() {
+ int nbNodes,nbCells;
+ int i;
+
+ char* file2Read = (char*)myFile.c_str();
+ myFileId = fopen(file2Read,"w+");
+ if (myFileId < 0)
+ {
+ fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+ exit(EXIT_FAILURE);
+ }
+
+ /****************************************************************************
+ * NOMBRES D'OBJETS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(****************************)\n");
+ fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n");
+ fprintf(stdout,"(****************************)\n");
+
+ /* Combien de noeuds ? */
+ nbNodes = myMesh->NbNodes();
+
+ /* Combien de mailles, faces ou aretes ? */
+ Standard_Integer nb_of_nodes, nb_of_edges,nb_of_faces, nb_of_volumes;
+ nb_of_edges = myMesh->NbEdges();
+ nb_of_faces = myMesh->NbFaces();
+ nb_of_volumes = myMesh->NbVolumes();
+ nbCells = nb_of_edges + nb_of_faces + nb_of_volumes;
+
+ fprintf(stdout,"%d %d\n",nbNodes,nbCells);
+ fprintf(myFileId,"%d %d\n",nbNodes,nbCells);
+
+ /****************************************************************************
+ * ECRITURE DES NOEUDS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(************************)\n");
+ fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
+ fprintf(stdout,"(************************)\n");
+
+ SMDS_MeshNodesIterator itNodes(myMesh);
+ for (;itNodes.More();itNodes.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itNodes.Value();
+ const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem);
+
+ fprintf(myFileId,"%d %e %e %e\n",node->GetID(),node->X(),node->Y(),node->Z());
+ }
+
+ /****************************************************************************
+ * ECRITURE DES ELEMENTS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(**************************)\n");
+ fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
+ fprintf(stdout,"(**************************)");
+ /* Ecriture des connectivites, noms, numeros des mailles */
+
+ SMDS_MeshEdgesIterator itEdges(myMesh);
+ for (;itEdges.More();itEdges.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itEdges.Value();
+
+ switch (elem->NbNodes()) {
+ case 2 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),102);
+ break;
+ }
+ case 3 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),103);
+ break;
+ }
+ }
+
+ for (i=0;i<elem->NbNodes();i++)
+ fprintf(myFileId,"%d ",elem->GetConnection(i+1));
+
+ fprintf(myFileId,"\n");
+ }
+
+ SMDS_MeshFacesIterator itFaces(myMesh);
+ for (;itFaces.More();itFaces.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itFaces.Value();
+
+ switch (elem->NbNodes()) {
+ case 3 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),203);
+ break;
+ }
+ case 4 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),204);
+ break;
+ }
+ case 6 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),206);
+ break;
+ }
+ }
+
+ for (i=0;i<elem->NbNodes();i++)
+ fprintf(myFileId,"%d ",elem->GetConnection(i+1));
+
+ fprintf(myFileId,"\n");
+ }
+
+ SMDS_MeshVolumesIterator itVolumes(myMesh);
+ for (;itVolumes.More();itVolumes.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
+
+ switch (elem->NbNodes()) {
+ case 8 : {
+ fprintf(myFileId,"%d %d ",elem->GetID(),308);
+ break;
+ }
+ }
+
+ for (i=0;i<elem->NbNodes();i++)
+ fprintf(myFileId,"%d ",elem->GetConnection(i+1));
+
+ fprintf(myFileId,"\n");
+ }
+
+ fclose (myFileId);
+}
+
--- /dev/null
+#ifndef _INCLUDE_DRIVERDAT_W_SMESHDS_MESH
+#define _INCLUDE_DRIVERDAT_W_SMESHDS_MESH
+
+#include <stdio.h>
+#include <string>
+
+#include "SMESHDS_Mesh.hxx"
+#include "Mesh_Writer.h"
+
+class DriverDAT_W_SMESHDS_Mesh : public Mesh_Writer {
+
+ public :
+ DriverDAT_W_SMESHDS_Mesh();
+ ~DriverDAT_W_SMESHDS_Mesh();
+
+ void Add();
+ void Write();
+ void SetMesh(Handle(SMDS_Mesh)& aMesh);
+ void SetFile(string);
+
+ void SetFileId(FILE*);
+ void SetMeshId(int);
+
+private :
+ Handle_SMDS_Mesh myMesh;
+ string myFile;
+ FILE* myFileId;
+ int myMeshId;
+
+};
+#endif
--- /dev/null
+# -* Makefile *-
+#
+# Author : Marc Tajchman (CEA)
+# Date : 5/07/2001
+# $Header$
+#
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@
+
+
+@COMMENCE@
+
+# header files
+EXPORT_HEADERS= DriverDAT_R_SMDS_Mesh.h DriverDAT_R_SMESHDS_Mesh.h DriverDAT_R_SMESHDS_Document.h DriverDAT_W_SMDS_Mesh.h DriverDAT_W_SMESHDS_Mesh.h DriverDAT_W_SMESHDS_Document.h
+
+# Libraries targets
+LIB = libMeshDriverDAT.la
+LIB_SRC = DriverDAT_R_SMDS_Mesh.cxx DriverDAT_R_SMESHDS_Mesh.cxx DriverDAT_R_SMESHDS_Document.cxx DriverDAT_W_SMDS_Mesh.cxx DriverDAT_W_SMESHDS_Mesh.cxx DriverDAT_W_SMESHDS_Document.cxx
+
+LIB_CLIENT_IDL =
+
+LIB_SERVER_IDL =
+
+# additionnal information to compil and link file
+CPPFLAGS += $(OCC_INCLUDES)
+CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES)
+LDFLAGS += $(OCC_LIBS) $(MED2_LIBS) -lMeshDriver
+
+%_moc.cxx: %.h
+ $(MOC) $< -o $@
+
+@CONCLUDE@
+
+
+
+using namespace std;
#include "DriverMED_R_SMDS_Mesh.h"
#include "utilities.h"
+using namespace std;
#include "DriverMED_R_SMESHDS_Document.h"
#include "DriverMED_R_SMESHDS_Mesh.h"
#include "utilities.h"
+using namespace std;
#include "DriverMED_R_SMESHDS_Mesh.h"
#include "DriverMED_R_SMDS_Mesh.h"
#include "utilities.h"
+using namespace std;
#include "DriverMED_W_SMDS_Mesh.h"
#include "SMDS_MeshElement.hxx"
+using namespace std;
#include "DriverMED_W_SMESHDS_Document.h"
#include "DriverMED_W_SMESHDS_Mesh.h"
#include "utilities.h"
+using namespace std;
#include "DriverMED_W_SMESHDS_Mesh.h"
#include "DriverMED_W_SMDS_Mesh.h"
/* calcul de la dimension */
mdim=2;
double epsilon=0.00001;
+ double nodeRefX;
+ double nodeRefY;
+ double nodeRefZ;
+
+ bool dimX = true;
+ bool dimY = true;
+ bool dimZ = true;
+
SMDS_MeshNodesIterator myItNodes(myMesh);
+ int inode = 0;
for (;myItNodes.More();myItNodes.Next()) {
const Handle(SMDS_MeshElement)& elem = myItNodes.Value();
const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem);
- if ( fabs(node->Z()) > epsilon ) {
- mdim=3;
+ if ( inode == 0 ) {
+ nodeRefX = fabs(node->X());
+ nodeRefY = fabs(node->Y());
+ nodeRefZ = fabs(node->Z());
+ }
+ SCRUTE( inode );
+ SCRUTE( nodeRefX );
+ SCRUTE( nodeRefY );
+ SCRUTE( nodeRefZ );
+
+ if ( inode !=0 ) {
+ if ( (fabs(fabs(node->X()) - nodeRefX) > epsilon ) && dimX )
+ dimX = false;
+ if ( (fabs(fabs(node->Y()) - nodeRefY) > epsilon ) && dimY )
+ dimY = false;
+ if ( (fabs(fabs(node->Z()) - nodeRefZ) > epsilon ) && dimZ )
+ dimZ = false;
+ }
+ if ( !dimX && !dimY && !dimZ ) {
+ mdim = 3;
break;
}
+ inode++;
}
+
+ if ( mdim != 3 ) {
+ if ( dimX && dimY && dimZ )
+ mdim = 0;
+ else if ( !dimX ) {
+ if ( dimY && dimZ )
+ mdim = 1;
+ else if (( dimY && !dimZ ) || ( !dimY && dimZ ) )
+ mdim = 2;
+ } else if ( !dimY ) {
+ if ( dimX && dimZ )
+ mdim = 1;
+ else if (( dimX && !dimZ ) || ( !dimX && dimZ ) )
+ mdim = 2;
+ } else if ( !dimZ ) {
+ if ( dimY && dimX )
+ mdim = 1;
+ else if (( dimY && !dimX ) || ( !dimY && dimX ) )
+ mdim = 2;
+ }
+ }
+
MESSAGE ( " mdim " << mdim );
/* creation du maillage */
coo[i*3+1]=node->Y();
coo[i*3+2]=node->Z();
} else {
- coo[i*2]=node->X();
- coo[i*2+1]=node->Y();
+ if ( dimX ) {
+ coo[i*2]=node->Y();
+ coo[i*2+1]=node->Z();
+ }
+ if ( dimY ) {
+ coo[i*2]=node->X();
+ coo[i*2+1]=node->Z();
+ }
+ if ( dimZ ) {
+ coo[i*2]=node->X();
+ coo[i*2+1]=node->Y();
+ }
}
mapNoeud[node->GetID()] = i+1;
# source path
top_srcdir=@top_srcdir@
-top_builddir=../../..
+top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@
--- /dev/null
+using namespace std;
+#include "DriverUNV_R_SMDS_Mesh.h"
+
+#include "utilities.h"
+
+DriverUNV_R_SMDS_Mesh::DriverUNV_R_SMDS_Mesh() {
+;
+}
+
+DriverUNV_R_SMDS_Mesh::~DriverUNV_R_SMDS_Mesh() {
+;
+}
+
+void DriverUNV_R_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+ myMesh = aMesh;
+}
+
+void DriverUNV_R_SMDS_Mesh::SetFile(string aFile) {
+ myFile = aFile;
+}
+
+void DriverUNV_R_SMDS_Mesh::SetFileId(FILE* aFileId) {
+ myFileId = aFileId;
+}
+
+void DriverUNV_R_SMDS_Mesh::SetMeshId(int aMeshId) {
+ myMeshId = aMeshId;
+}
+
+void DriverUNV_R_SMDS_Mesh::Add() {
+ ;
+}
+
+void DriverUNV_R_SMDS_Mesh::Read() {
+
+ int cell=0,node=0,n1,n2,n3,n4,n_nodes,nodes[6],blockId,i;
+ char *s1,*s2,*s3;
+ string str1,str2,str3;
+ int i1=0;
+ bool ok, found_block2411, found_block2412;
+
+ /****************************************************************************
+ * OUVERTURE DU FICHIER EN LECTURE *
+ ****************************************************************************/
+ char* file2Read = (char*)myFile.c_str();
+ myFileId = fopen(file2Read,"r");
+ if (myFileId < 0)
+ {
+ fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+ exit(EXIT_FAILURE);
+ }
+
+ s1 = (char*) malloc(sizeof(char)*100);
+ s2 = (char*) malloc(sizeof(char)*100);
+ s3 = (char*) malloc(sizeof(char)*100);
+
+ found_block2411 = false;
+ found_block2412 = false;
+
+ do {
+
+ while (i1==-1) {
+ fscanf(myFileId,"%d\n",&blockId);
+ switch (blockId) {
+ case 2411 : {
+ MESSAGE("BlockId "<<blockId);
+ fscanf(myFileId,"%d",&node);
+ //MESSAGE("Node "<<node);
+ while (node!=-1) {
+ fscanf(myFileId,"%d %d %d\n",&n1,&n2,&n3);
+ fscanf(myFileId,"%s %s %s\n",s1,s2,s3);
+ str1=string(s1);
+ str2=string(s2);
+ str3=string(s3);
+ if (str1.find("D")!=string::npos) str1.replace(str1.find("D"),1,"E");
+ if (str2.find("D")!=string::npos) str2.replace(str2.find("D"),1,"E");
+ if (str3.find("D")!=string::npos) str3.replace(str3.find("D"),1,"E");
+ ok = myMesh->AddNodeWithID(atof(str1.c_str()),atof(str2.c_str()),atof(str3.c_str()),node);
+ fscanf(myFileId,"%d",&node);
+ }
+ i1=0;
+ found_block2411 = true;
+ break;
+ }
+ case 2412 : {
+ MESSAGE("BlockId "<<blockId);
+ fscanf(myFileId,"%d",&cell);
+ //MESSAGE("Cell "<<cell);
+ while (cell!=-1) {
+ fscanf(myFileId,"%d %d %d %d %d\n",&n1,&n2,&n3,&n4,&n_nodes);
+
+ if ((n1==71)||(n1==72)||(n1==74)||(n1==91)||(n1==92)) {//203
+ if (n_nodes==3) {
+ for (i=1;i<=n_nodes;i++)
+ fscanf(myFileId,"%d",&nodes[i-1]);
+ ok = myMesh->AddFaceWithID(nodes[0],nodes[1],nodes[2],cell);
+ }
+ else if (n_nodes==6) {//206
+ for (i=1;i<=n_nodes;i++)
+ fscanf(myFileId,"%d",&nodes[i-1]);
+ ok = myMesh->AddFaceWithID(nodes[0],nodes[2],nodes[4],cell);
+ }
+ }
+
+ else if ((n1==11)||(n1==21)||(n1==24)||(n1==25)) {//103
+ fgets(s2,100,myFileId);
+ if (n_nodes==3) {
+ for (i=1;i<=n_nodes;i++)
+ fscanf(myFileId,"%d",&nodes[i-1]);
+ ok = myMesh->AddEdgeWithID(nodes[0],nodes[1],cell);
+ //MESSAGE("in 103 "<<cell);
+ }
+ else if (n_nodes==2) {//102
+ for (i=1;i<=n_nodes;i++)
+ fscanf(myFileId,"%d",&nodes[i-1]);
+ ok = myMesh->AddEdgeWithID(nodes[0],nodes[1],cell);
+ //MESSAGE("in 102 "<<cell);
+ }
+ }
+
+ fscanf(myFileId,"\n");
+ fscanf(myFileId,"%d",&cell);
+ }
+
+ i1=0;
+ found_block2412 = true;
+ break;
+ }
+ case -1 : {
+ break;
+ }
+ default:
+ MESSAGE("BlockId "<<blockId);
+ i1=0;
+ break;
+ }
+ }
+
+ fscanf(myFileId,"%s\n",s1);
+ i1 = atoi(s1);
+
+ }
+ while ((!feof(myFileId))&&((!found_block2411)||(!found_block2412)));
+
+ /****************************************************************************
+ * FERMETURE DU FICHIER *
+ ****************************************************************************/
+ free(s1);
+ free(s2);
+ free(s3);
+ fclose(myFileId);
+
+}
--- /dev/null
+#ifndef _INCLUDE_DRIVERUNV_R_SMDS_MESH
+#define _INCLUDE_DRIVERUNV_R_SMDS_MESH
+
+#include <stdio.h>
+
+#include "SMDS_Mesh.hxx"
+#include "Mesh_Reader.h"
+
+class DriverUNV_R_SMDS_Mesh : public Mesh_Reader {
+
+ public :
+ DriverUNV_R_SMDS_Mesh();
+ ~DriverUNV_R_SMDS_Mesh();
+
+ void Add();
+ void Read();
+ void SetMesh(Handle(SMDS_Mesh)& aMesh);
+ void SetFile(string);
+
+ void SetFileId(FILE*);
+ void SetMeshId(int);
+
+ private :
+ Handle_SMDS_Mesh myMesh;
+ string myFile;
+ FILE* myFileId;
+ int myMeshId;
+
+};
+#endif
--- /dev/null
+using namespace std;
+#include "DriverUNV_R_SMESHDS_Document.h"
+#include "DriverUNV_R_SMESHDS_Mesh.h"
+
+#include "utilities.h"
+
+int getOne() {
+ printf("in getOne");
+ return (1);
+}
+
+extern "C" {
+ // Document_Reader* maker() {
+ DriverUNV_R_SMESHDS_Document* maker() {
+ fprintf(stdout,"here in maker\n");
+ return new DriverUNV_R_SMESHDS_Document;
+ }
+}
+
+DriverUNV_R_SMESHDS_Document::DriverUNV_R_SMESHDS_Document() {
+ myFile = string("");
+}
+
+DriverUNV_R_SMESHDS_Document::~DriverUNV_R_SMESHDS_Document() {
+;
+}
+
+//void DriverUNV_R_SMESHDS_Document::SetFile(string aFile) {
+//myFile = aFile;
+//}
+
+//void DriverUNV_R_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDoc) {
+//myDocument = aDoc;
+//}
+
+void DriverUNV_R_SMESHDS_Document::Read() {
+
+ int myMeshId;
+ SCRUTE(myFile);
+ //Handle(SMESHDS_Document) myDocument = new SMESHDS_Document(1);
+
+ /****************************************************************************
+ * OUVERTURE DU FICHIER EN LECTURE *
+ ****************************************************************************/
+ char* file2Read = (char*)myFile.c_str();
+ FILE* fid = fopen(file2Read,"r");
+ if (fid < 0)
+ {
+ fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+ exit(EXIT_FAILURE);
+ }
+
+ /****************************************************************************
+ * COMBIEN DE MAILLAGES ? *
+ ****************************************************************************/
+ int nmaa = 1;
+
+ /****************************************************************************
+ * FERMETURE DU FICHIER *
+ ****************************************************************************/
+ fclose(fid);
+
+ printf("Nombre de maillages = %d\n",nmaa);
+
+ string myClass = string("SMESHDS_Mesh");
+ string myExtension = string("UNV");
+
+ for (int meshIt=1;meshIt<=nmaa;meshIt++) {
+ myMeshId = myDocument->NewMesh();
+
+ Handle(SMDS_Mesh) myMesh = myDocument->GetMesh(myMeshId);
+
+ DriverUNV_R_SMESHDS_Mesh* myReader = new DriverUNV_R_SMESHDS_Mesh;
+
+
+ myReader->SetMesh(myMesh);
+ myReader->SetFile(myFile);
+ //myReader->SetFileId(fid);
+
+ myReader->Read();
+
+ }
+
+
+}
--- /dev/null
+#ifndef _INCLUDE_DRIVERUNV_R_SMESHDS_DOCUMENT
+#define _INCLUDE_DRIVERUNV_R_SMESHDS_DOCUMENT
+
+#include <stdio.h>
+
+#include "SMESHDS_Document.hxx"
+#include "Document_Reader.h"
+
+class DriverUNV_R_SMESHDS_Document : public Document_Reader {
+
+public :
+ DriverUNV_R_SMESHDS_Document();
+ ~DriverUNV_R_SMESHDS_Document();
+
+ void Read();
+ //void SetFile(string);
+ //void SetDocument(Handle_SMESHDS_Document&);
+
+private :
+ //Handle_SMESHDS_Document myDocument;
+ //string myFile;
+
+};
+#endif
--- /dev/null
+using namespace std;
+#include "DriverUNV_R_SMESHDS_Mesh.h"
+#include "DriverUNV_R_SMDS_Mesh.h"
+
+#include "utilities.h"
+
+DriverUNV_R_SMESHDS_Mesh::DriverUNV_R_SMESHDS_Mesh() {
+;
+}
+
+DriverUNV_R_SMESHDS_Mesh::~DriverUNV_R_SMESHDS_Mesh() {
+;
+}
+
+void DriverUNV_R_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+ //myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh);
+ myMesh = aMesh;
+}
+
+void DriverUNV_R_SMESHDS_Mesh::SetFile(string aFile) {
+ myFile = aFile;
+}
+
+void DriverUNV_R_SMESHDS_Mesh::SetFileId(FILE* aFileId) {
+ myFileId = aFileId;
+}
+
+void DriverUNV_R_SMESHDS_Mesh::SetMeshId(int aMeshId) {
+ myMeshId = aMeshId;
+}
+
+void DriverUNV_R_SMESHDS_Mesh::Add() {
+ ;
+}
+
+void DriverUNV_R_SMESHDS_Mesh::Read() {
+ string myClass = string("SMDS_Mesh");
+ string myExtension = string("UNV");
+
+ DriverUNV_R_SMDS_Mesh* myReader = new DriverUNV_R_SMDS_Mesh;
+
+ myReader->SetMesh(myMesh);
+ myReader->SetFile(myFile);
+ //myReader->SetFileId(myFileId);
+
+ myReader->Read();
+
+}
--- /dev/null
+#ifndef _INCLUDE_DRIVERUNV_R_SMESHDS_MESH
+#define _INCLUDE_DRIVERUNV_R_SMESHDS_MESH
+
+#include <stdio.h>
+
+#include "SMESHDS_Mesh.hxx"
+#include "Mesh_Reader.h"
+
+class DriverUNV_R_SMESHDS_Mesh : public Mesh_Reader {
+
+ public :
+ DriverUNV_R_SMESHDS_Mesh();
+ ~DriverUNV_R_SMESHDS_Mesh();
+
+ void Add();
+ void Read();
+ void SetMesh(Handle(SMDS_Mesh)& aMesh);
+ void SetFile(string);
+
+ void SetFileId(FILE*);
+ void SetMeshId(int);
+
+private :
+ Handle_SMDS_Mesh myMesh;
+ string myFile;
+ FILE* myFileId;
+ int myMeshId;
+
+};
+#endif
--- /dev/null
+using namespace std;
+#include "DriverUNV_W_SMDS_Mesh.h"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_MeshEdgesIterator.hxx"
+#include "SMDS_MeshFacesIterator.hxx"
+#include "SMDS_MeshNodesIterator.hxx"
+#include "SMDS_MeshVolumesIterator.hxx"
+
+#include <utilities.h>
+
+#define sNODE_UNV_ID " 2411"
+#define sELT_UNV_ID " 2412"
+#define sUNV_SEPARATOR " -1"
+#define sNODE_UNV_DESCR "%10d 1 1 11\n"
+#define sELT_SURF_DESC "%10d %2d 1 1 11 %1d\n"
+#define sELT_VOLU_DESC "%10d %2d 1 1 9 %1d\n"
+#define sELT_BEAM_DESC1 "%10d %2d 1 1 7 %1d\n"
+#define sELT_BEAM_DESC2 " 0 1 1\n"
+
+DriverUNV_W_SMDS_Mesh::DriverUNV_W_SMDS_Mesh() {
+;
+}
+
+DriverUNV_W_SMDS_Mesh::~DriverUNV_W_SMDS_Mesh() {
+;
+}
+
+void DriverUNV_W_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+ myMesh = aMesh;
+}
+
+void DriverUNV_W_SMDS_Mesh::SetFile(string aFile) {
+ myFile = aFile;
+}
+
+void DriverUNV_W_SMDS_Mesh::SetFileId(FILE* aFileId) {
+ myFileId = aFileId;
+}
+
+void DriverUNV_W_SMDS_Mesh::SetMeshId(int aMeshId) {
+ myMeshId = aMeshId;
+}
+
+void DriverUNV_W_SMDS_Mesh::Add() {
+ ;
+}
+
+void DriverUNV_W_SMDS_Mesh::Write() {
+
+ int nbNodes,nbCells;
+ int i;
+
+ char* file2Read = (char*)myFile.c_str();
+ myFileId = fopen(file2Read,"w+");
+ if (myFileId < 0)
+ {
+ fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+ exit(EXIT_FAILURE);
+ }
+ SCRUTE(myMesh);
+ /****************************************************************************
+ * NOMBRES D'OBJETS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(****************************)\n");
+ fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n");
+ fprintf(stdout,"(****************************)\n");
+
+ /* Combien de noeuds ? */
+ nbNodes = myMesh->NbNodes();
+
+ /* Combien de mailles, faces ou aretes ? */
+ Standard_Integer nb_of_nodes, nb_of_edges,nb_of_faces, nb_of_volumes;
+ nb_of_edges = myMesh->NbEdges();
+ nb_of_faces = myMesh->NbFaces();
+ nb_of_volumes = myMesh->NbVolumes();
+ nbCells = nb_of_edges + nb_of_faces + nb_of_volumes;
+ SCRUTE(nb_of_edges);
+ SCRUTE(nb_of_faces);
+ SCRUTE(nb_of_volumes);
+
+ fprintf(stdout,"%d %d\n",nbNodes,nbCells);
+ fprintf(myFileId,"%d %d\n",nbNodes,nbCells);
+
+ /****************************************************************************
+ * ECRITURE DES NOEUDS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(************************)\n");
+ fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
+ fprintf(stdout,"(************************)\n");
+
+ SMDS_MeshNodesIterator itNodes(myMesh);
+
+ fprintf(myFileId,"%s\n", sUNV_SEPARATOR);
+ fprintf(myFileId,"%s\n", sNODE_UNV_ID );
+
+ for (;itNodes.More();itNodes.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itNodes.Value();
+ const Handle(SMDS_MeshNode )& node = myMesh->GetNode(1, elem);
+
+ fprintf(myFileId, sNODE_UNV_DESCR, node->GetID());
+ fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(), node->Z());
+ }
+ fprintf(myFileId,"%s\n", sUNV_SEPARATOR);
+
+ /****************************************************************************
+ * ECRITURE DES ELEMENTS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(**************************)\n");
+ fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
+ fprintf(stdout,"(**************************)");
+ /* Ecriture des connectivites, noms, numeros des mailles */
+
+ fprintf(myFileId,"%s\n", sUNV_SEPARATOR);
+ fprintf(myFileId,"%s\n", sELT_UNV_ID );
+
+ SMDS_MeshEdgesIterator itEdges(myMesh);
+ for (;itEdges.More();itEdges.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itEdges.Value();
+
+ switch (elem->NbNodes()) {
+ case 2 : {
+ fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 21, elem->NbNodes());
+ fprintf(myFileId, sELT_BEAM_DESC2);
+ fprintf(myFileId, "%10d%10d\n", elem->GetConnection(1), elem->GetConnection(2));
+ break;
+ }
+ case 3 : {
+ fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 24, elem->NbNodes());
+ fprintf(myFileId, sELT_BEAM_DESC2);
+ fprintf(myFileId, "%10d%10d%10d\n",elem->GetConnection(1), elem->GetConnection(2), elem->GetConnection(3));
+ break;
+ }
+ }
+ }
+
+ SMDS_MeshFacesIterator itFaces(myMesh);
+ for (;itFaces.More();itFaces.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itFaces.Value();
+
+ switch (elem->NbNodes()) {
+ case 3 :
+ // linear triangle
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 74, elem->NbNodes());
+ break;
+ case 4 :
+ // linear quadrilateral
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 71, elem->NbNodes());
+ break;
+ case 6 :
+ // parabolic triangle
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 72, elem->NbNodes());
+ break;
+ case 8 :
+ // parabolic quadrilateral
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 75, elem->NbNodes());
+ break;
+ default:
+ fprintf(myFileId, "element not registered\n");
+ }
+
+ for (i=0;i<elem->NbNodes();i++)
+ fprintf(myFileId,"%10d",elem->GetConnection(i+1));
+
+ fprintf(myFileId,"\n");
+ }
+
+ SMDS_MeshVolumesIterator itVolumes(myMesh);
+ for (;itVolumes.More();itVolumes.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
+
+ switch (elem->NbNodes()) {
+ case 4 :
+ // linear tetrahedron
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 111, elem->NbNodes());
+ break;
+ case 6 :
+ // linear tetrahedron
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 112, elem->NbNodes());
+ break;
+ case 8 :
+ // linear brick
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 115, elem->NbNodes());
+ break;
+ }
+
+ for (i=0;i<elem->NbNodes();i++)
+ fprintf(myFileId,"%10d",elem->GetConnection(i+1));
+
+ fprintf(myFileId,"\n");
+ }
+ fprintf(myFileId,"%s\n", sUNV_SEPARATOR);
+
+ fclose (myFileId);
+}
--- /dev/null
+#ifndef _INCLUDE_DRIVERUNV_W_SMDS_MESH
+#define _INCLUDE_DRIVERUNV_W_SMDS_MESH
+
+#include <stdio.h>
+#include <string>
+
+#include "SMDS_Mesh.hxx"
+#include "Mesh_Writer.h"
+
+class DriverUNV_W_SMDS_Mesh : public Mesh_Writer {
+
+ public :
+ DriverUNV_W_SMDS_Mesh();
+ ~DriverUNV_W_SMDS_Mesh();
+
+ void Add();
+ void Write();
+ void SetMesh(Handle(SMDS_Mesh)& aMesh);
+ void SetFile(string);
+
+ void SetFileId(FILE*);
+ void SetMeshId(int);
+
+private :
+ Handle_SMDS_Mesh myMesh;
+ string myFile;
+ FILE* myFileId;
+ int myMeshId;
+
+};
+#endif
--- /dev/null
+using namespace std;
+#include "DriverUNV_W_SMESHDS_Document.h"
+#include "DriverUNV_W_SMESHDS_Mesh.h"
+
+#include "utilities.h"
+
+extern "C"
+{
+ Document_Writer* Wmaker() {
+ return new DriverUNV_W_SMESHDS_Document;
+ }
+}
+
+DriverUNV_W_SMESHDS_Document::DriverUNV_W_SMESHDS_Document() {
+;
+}
+
+DriverUNV_W_SMESHDS_Document::~DriverUNV_W_SMESHDS_Document() {
+;
+}
+
+//void DriverUNV_W_SMESHDS_Document::SetFile(string aFile) {
+//myFile = aFile;
+//}
+
+//void DriverUNV_W_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDocument) {
+//myDocument = aDocument;
+//}
+
+void DriverUNV_W_SMESHDS_Document::Write() {
+
+ Handle(SMESHDS_Mesh) myMesh;
+
+ /****************************************************************************
+ * OUVERTURE DU FICHIER EN ECRITURE *
+ ****************************************************************************/
+ char* file2Write = (char*)myFile.c_str();
+ FILE* fid = fopen(file2Write,"w+");
+ if (fid < 0)
+ {
+ fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Write);
+ exit(EXIT_FAILURE);
+ }
+
+ /****************************************************************************
+ * FERMETURE DU FICHIER *
+ ****************************************************************************/
+
+ fclose(fid);
+
+ /******** Nombre de maillages ********/
+ int nb_of_meshes = myDocument->NbMeshes(); //voir avec Yves
+ //nb_of_meshes = 1;
+ int numero = 0;
+
+ string myClass = string("SMESHDS_Mesh");
+ string myExtension = string("UNV");
+
+ //while (numero<nb_of_meshes) {
+ //numero++;
+ //myMesh = myDocument->GetMesh(numero);
+ myDocument->InitMeshesIterator();
+ for (;myDocument->MoreMesh();myDocument->NextMesh()) {
+ numero++;
+ myMesh = myDocument->CurrentMesh();
+
+ DriverUNV_W_SMESHDS_Mesh* myWriter = new DriverUNV_W_SMESHDS_Mesh;
+ //Mesh_Writer* myWriter = Driver::GetMeshWriter(myExtension, myClass);
+
+ myWriter->SetMesh(myMesh);
+ myWriter->SetFile(myFile);
+ SCRUTE(myMesh);
+ //myWriter->SetFileId(fid);
+ myWriter->SetMeshId(numero);
+ myWriter->Write();
+ }
+
+}
--- /dev/null
+#ifndef _INCLUDE_DRIVERUNV_W_SMESHDS_DOCUMENT
+#define _INCLUDE_DRIVERUNV_W_SMESHDS_DOCUMENT
+
+#include <stdio.h>
+#include <string>
+
+#include "SMESHDS_Document.hxx"
+#include "Document_Writer.h"
+
+class DriverUNV_W_SMESHDS_Document : public Document_Writer {
+
+public :
+ DriverUNV_W_SMESHDS_Document();
+ ~DriverUNV_W_SMESHDS_Document();
+
+ void Write();
+ //void SetFile(string);
+ //void SetDocument(Handle(SMESHDS_Document)&);
+
+private :
+ //Handle_SMESHDS_Document myDocument;
+ //string myFile;
+
+};
+#endif
--- /dev/null
+using namespace std;
+#include "DriverUNV_W_SMESHDS_Mesh.h"
+#include "DriverUNV_W_SMDS_Mesh.h"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_MeshEdgesIterator.hxx"
+#include "SMDS_MeshFacesIterator.hxx"
+#include "SMDS_MeshNodesIterator.hxx"
+#include "SMDS_MeshVolumesIterator.hxx"
+
+#include "utilities.h"
+
+#define sNODE_UNV_ID " 2411"
+#define sELT_UNV_ID " 2412"
+#define sUNV_SEPARATOR " -1"
+#define sNODE_UNV_DESCR "%10d 1 1 11\n"
+#define sELT_SURF_DESC "%10d %2d 1 1 11 %1d\n"
+#define sELT_VOLU_DESC "%10d %2d 1 1 9 %1d\n"
+#define sELT_BEAM_DESC1 "%10d %2d 1 1 7 %1d\n"
+#define sELT_BEAM_DESC2 " 0 1 1\n"
+
+DriverUNV_W_SMESHDS_Mesh::DriverUNV_W_SMESHDS_Mesh() {
+;
+}
+
+DriverUNV_W_SMESHDS_Mesh::~DriverUNV_W_SMESHDS_Mesh() {
+;
+}
+
+void DriverUNV_W_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
+ //myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh);
+ myMesh = aMesh;
+}
+
+void DriverUNV_W_SMESHDS_Mesh::SetFile(string aFile) {
+ myFile = aFile;
+}
+
+void DriverUNV_W_SMESHDS_Mesh::SetFileId(FILE* aFileId) {
+ myFileId = aFileId;
+}
+
+void DriverUNV_W_SMESHDS_Mesh::SetMeshId(int aMeshId) {
+ myMeshId = aMeshId;
+}
+
+void DriverUNV_W_SMESHDS_Mesh::Write() {
+
+ string myClass = string("SMDS_Mesh");
+ string myExtension = string("UNV");
+
+ DriverUNV_W_SMDS_Mesh* myWriter = new DriverUNV_W_SMDS_Mesh;
+
+ myWriter->SetMesh(myMesh);
+ myWriter->SetFile(myFile);
+ myWriter->SetMeshId(myMeshId);
+ //myWriter->SetFileId(myFileId);
+
+ myWriter->Write();
+
+
+}
+void DriverUNV_W_SMESHDS_Mesh::Add() {
+ int nbNodes,nbCells;
+ int i;
+
+ char* file2Read = (char*)myFile.c_str();
+ myFileId = fopen(file2Read,"w+");
+ if (myFileId < 0)
+ {
+ fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
+ exit(EXIT_FAILURE);
+ }
+
+ /****************************************************************************
+ * NOMBRES D'OBJETS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(****************************)\n");
+ fprintf(stdout,"(* INFORMATIONS GENERALES : *)\n");
+ fprintf(stdout,"(****************************)\n");
+
+ /* Combien de noeuds ? */
+ nbNodes = myMesh->NbNodes();
+
+ /* Combien de mailles, faces ou aretes ? */
+ Standard_Integer nb_of_nodes, nb_of_edges,nb_of_faces, nb_of_volumes;
+ nb_of_edges = myMesh->NbEdges();
+ nb_of_faces = myMesh->NbFaces();
+ nb_of_volumes = myMesh->NbVolumes();
+ nbCells = nb_of_edges + nb_of_faces + nb_of_volumes;
+
+ fprintf(stdout,"%d %d\n",nbNodes,nbCells);
+//fprintf(myFileId,"%d %d\n",nbNodes,nbCells);
+
+ /****************************************************************************
+ * ECRITURE DES NOEUDS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(************************)\n");
+ fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
+ fprintf(stdout,"(************************)\n");
+
+ SMDS_MeshNodesIterator itNodes(myMesh);
+
+ fprintf(myFileId,"%s\n", sUNV_SEPARATOR);
+ fprintf(myFileId,"%s\n", sNODE_UNV_ID );
+
+ for (;itNodes.More();itNodes.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itNodes.Value();
+ const Handle(SMDS_MeshNode )& node = myMesh->GetNode(1, elem);
+
+ fprintf(myFileId, sNODE_UNV_DESCR, node->GetID());
+ fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(), node->Z());
+ }
+ fprintf(myFileId,"%s\n", sUNV_SEPARATOR);
+
+ /****************************************************************************
+ * ECRITURE DES ELEMENTS *
+ ****************************************************************************/
+ fprintf(stdout,"\n(**************************)\n");
+ fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
+ fprintf(stdout,"(**************************)");
+ /* Ecriture des connectivites, noms, numeros des mailles */
+
+ fprintf(myFileId,"%s\n", sUNV_SEPARATOR);
+ fprintf(myFileId,"%s\n", sELT_UNV_ID );
+
+ SMDS_MeshEdgesIterator itEdges(myMesh);
+ for (;itEdges.More();itEdges.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itEdges.Value();
+
+ switch (elem->NbNodes()) {
+ case 2 : {
+ fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 21, elem->NbNodes());
+ fprintf(myFileId, sELT_BEAM_DESC2);
+ fprintf(myFileId, "%10d%10d\n", elem->GetConnection(1), elem->GetConnection(2));
+ break;
+ }
+ case 3 : {
+ fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 24, elem->NbNodes());
+ fprintf(myFileId, sELT_BEAM_DESC2);
+ fprintf(myFileId, "%10d%10d%10d\n",elem->GetConnection(1), elem->GetConnection(2), elem->GetConnection(3));
+ break;
+ }
+ }
+ }
+
+ SMDS_MeshFacesIterator itFaces(myMesh);
+ for (;itFaces.More();itFaces.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itFaces.Value();
+
+ switch (elem->NbNodes()) {
+ case 3 :
+ // linear triangle
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 74, elem->NbNodes());
+ break;
+ case 4 :
+ // linear quadrilateral
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 71, elem->NbNodes());
+ break;
+ case 6 :
+ // parabolic triangle
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 72, elem->NbNodes());
+ break;
+ case 8 :
+ // parabolic quadrilateral
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 75, elem->NbNodes());
+ break;
+ default:
+ fprintf(myFileId, "element not registered\n");
+ }
+
+ for (i=0;i<elem->NbNodes();i++)
+ fprintf(myFileId,"%10d",elem->GetConnection(i+1));
+
+ fprintf(myFileId,"\n");
+ }
+
+ SMDS_MeshVolumesIterator itVolumes(myMesh);
+ for (;itVolumes.More();itVolumes.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
+
+ switch (elem->NbNodes()) {
+ case 4 :
+ // linear tetrahedron
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 111, elem->NbNodes());
+ break;
+ case 6 :
+ // linear tetrahedron
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 112, elem->NbNodes());
+ break;
+ case 8 :
+ // linear brick
+ fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 115, elem->NbNodes());
+ break;
+ }
+
+ for (i=0;i<elem->NbNodes();i++)
+ fprintf(myFileId,"%10d",elem->GetConnection(i+1));
+
+ fprintf(myFileId,"\n");
+ }
+ fprintf(myFileId,"%s\n", sUNV_SEPARATOR);
+
+ fclose (myFileId);
+}
+
--- /dev/null
+#ifndef _INCLUDE_DRIVERUNV_W_SMESHDS_MESH
+#define _INCLUDE_DRIVERUNV_W_SMESHDS_MESH
+
+#include <stdio.h>
+#include <string>
+
+#include "SMESHDS_Mesh.hxx"
+#include "Mesh_Writer.h"
+
+class DriverUNV_W_SMESHDS_Mesh : public Mesh_Writer {
+
+ public :
+ DriverUNV_W_SMESHDS_Mesh();
+ ~DriverUNV_W_SMESHDS_Mesh();
+
+ void Add();
+ void Write();
+ void SetMesh(Handle(SMDS_Mesh)& aMesh);
+ void SetFile(string);
+
+ void SetFileId(FILE*);
+ void SetMeshId(int);
+
+private :
+ Handle_SMDS_Mesh myMesh;
+ string myFile;
+ FILE* myFileId;
+ int myMeshId;
+
+};
+#endif
--- /dev/null
+# -* Makefile *-
+#
+# Author : Marc Tajchman (CEA)
+# Date : 5/07/2001
+# $Header$
+#
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@
+
+
+@COMMENCE@
+
+# header files
+EXPORT_HEADERS= DriverUNV_R_SMDS_Mesh.h DriverUNV_R_SMESHDS_Mesh.h DriverUNV_R_SMESHDS_Document.h \
+ DriverUNV_W_SMDS_Mesh.h DriverUNV_W_SMESHDS_Mesh.h DriverUNV_W_SMESHDS_Document.h
+
+# Libraries targets
+LIB = libMeshDriverUNV.la
+LIB_SRC = DriverUNV_R_SMDS_Mesh.cxx DriverUNV_R_SMESHDS_Mesh.cxx DriverUNV_R_SMESHDS_Document.cxx \
+ DriverUNV_W_SMDS_Mesh.cxx DriverUNV_W_SMESHDS_Mesh.cxx DriverUNV_W_SMESHDS_Document.cxx
+
+LIB_CLIENT_IDL =
+
+LIB_SERVER_IDL =
+
+# additionnal information to compil and link file
+CPPFLAGS += $(OCC_INCLUDES)
+CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES)
+LDFLAGS += $(OCC_LIBS) $(MED2_LIBS) -lMeshDriver
+
+%_moc.cxx: %.h
+ $(MOC) $< -o $@
+
+@CONCLUDE@
+
+
+
--- /dev/null
+#==============================================================================
+# File : Makefile.in
+# Created : lun mai 6 13:33:11 CEST 2002
+# Author : Paul RASCLE, EDF
+# Project : SALOME
+# Copyright : EDF 2002
+# $Header$
+#==============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
+
+
+@COMMENCE@
+
+# header files
+EXPORT_HEADERS= \
+ SMESH_Gen.hxx \
+ SMESH_Mesh.hxx \
+ SMESH_subMesh.hxx \
+ SMESH_Hypothesis.hxx \
+ SMESH_HypothesisFactory.hxx \
+ SMESH_Algo.hxx \
+ SMESH_1D_Algo.hxx \
+ SMESH_2D_Algo.hxx \
+ SMESH_3D_Algo.hxx \
+ SMESH_NumberOfSegments.hxx \
+ SMESH_LocalLength.hxx \
+ SMESH_LengthFromEdges.hxx \
+ SMESH_MaxElementArea.hxx \
+ SMESH_MaxElementVolume.hxx \
+ SMESH_Regular_1D.hxx \
+ SMESH_Quadrangle_2D.hxx \
+ SMESH_MEFISTO_2D.hxx \
+ SMESH_Hexa_3D.hxx \
+ SMESH_HypothesisCreator.hxx
+
+EXPORT_PYSCRIPTS =
+
+# Libraries targets
+
+LIB= libSMESHimpl.la
+
+LIB_SRC = SMESH_Gen.cxx SMESH_Mesh.cxx SMESH_subMesh.cxx \
+ SMESH_Hypothesis.cxx \
+ SMESH_HypothesisFactory.cxx \
+ SMESH_Algo.cxx \
+ SMESH_1D_Algo.cxx \
+ SMESH_2D_Algo.cxx \
+ SMESH_3D_Algo.cxx \
+ SMESH_NumberOfSegments.cxx \
+ SMESH_LocalLength.cxx \
+ SMESH_LengthFromEdges.cxx \
+ SMESH_MaxElementArea.cxx \
+ SMESH_MaxElementVolume.cxx \
+ SMESH_Regular_1D.cxx \
+ SMESH_Quadrangle_2D.cxx \
+ SMESH_MEFISTO_2D.cxx \
+ SMESH_Hexa_3D.cxx
+
+LIB_SERVER_IDL =
+
+LIB_CLIENT_IDL =
+
+# Executables targets
+BIN =
+BIN_SRC =
+
+# additionnal information to compil and link file
+CPPFLAGS+= $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES)
+CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES)
+
+#IDLCXXFLAGS+= -Wbtp
+
+LDFLAGS+= $(OCC_LIBS) $(HDF5_LIBS) $(MED2_LIBS) -lOpUtil -lSMESHDS -lSMDS -lMEFISTO2D -lMeshDriverDAT -lMeshDriverMED -lMeshDriverUNV
+
+@CONCLUDE@
+
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_1D_Algo.cxx
+// Created : sam mai 18 09:22:56 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_1D_Algo.hxx"
+#include "SMESH_Gen.hxx"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_1D_Algo::SMESH_1D_Algo(int hypId, int studyId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, studyId, gen)
+{
+// _compatibleHypothesis.push_back("hypothese_1D_bidon");
+ _type = ALGO_1D;
+ gen->_map1D_Algo[hypId] = this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_1D_Algo::~SMESH_1D_Algo()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_1D_Algo::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_1D_Algo::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream& operator << (ostream & save, SMESH_1D_Algo & hyp)
+{
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream& operator >> (istream & load, SMESH_1D_Algo & hyp)
+{
+ return load;
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_1D_Algo.hxx
+// Created : sam mai 18 09:23:02 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_1D_ALGO_HXX_
+#define _SMESH_1D_ALGO_HXX_
+
+#include "SMESH_Algo.hxx"
+
+class SMESH_1D_Algo:
+ public SMESH_Algo
+{
+public:
+ SMESH_1D_Algo(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_1D_Algo();
+
+ virtual ostream & SaveTo(ostream & save);
+ virtual istream & LoadFrom(istream & load);
+ friend ostream& operator << (ostream & save, SMESH_1D_Algo & hyp);
+ friend istream& operator >> (istream & load, SMESH_1D_Algo & hyp);
+
+protected:
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_2D_Algo.cxx
+// Created : sam mai 18 09:23:44 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_2D_Algo.hxx"
+#include "SMESH_Gen.hxx"
+
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, studyId, gen)
+{
+// _compatibleHypothesis.push_back("hypothese_2D_bidon");
+ _type = ALGO_2D;
+ gen->_map2D_Algo[hypId] = this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_2D_Algo::~SMESH_2D_Algo()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_2D_Algo::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_2D_Algo::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream& operator << (ostream & save, SMESH_2D_Algo & hyp)
+{
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream& operator >> (istream & load, SMESH_2D_Algo & hyp)
+{
+ return load;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_2D_Algo::NumberOfWires(const TopoDS_Shape& S)
+{
+ int i = 0;
+ for (TopExp_Explorer exp(S,TopAbs_WIRE); exp.More(); exp.Next())
+ i++;
+ return i;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_2D_Algo::NumberOfPoints(SMESH_Mesh& aMesh, const TopoDS_Wire& W)
+{
+ int nbPoints = 0;
+ for (TopExp_Explorer exp(W,TopAbs_EDGE); exp.More(); exp.Next())
+ {
+ const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
+ int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+ //SCRUTE(nb);
+ nbPoints += nb +1; // internal points plus 1 vertex of 2 (last point ?)
+ }
+ //SCRUTE(nbPoints);
+ return nbPoints;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_2D_Algo.hxx
+// Created : sam mai 18 09:23:37 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_2D_ALGO_HXX_
+#define _SMESH_2D_ALGO_HXX_
+
+#include "SMESH_Algo.hxx"
+#include <TopoDS_Wire.hxx>
+
+class SMESH_2D_Algo:
+ public SMESH_Algo
+{
+public:
+ SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_2D_Algo();
+
+ int NumberOfWires(const TopoDS_Shape& S);
+ int NumberOfPoints(SMESH_Mesh& aMesh,const TopoDS_Wire& W);
+
+ virtual ostream & SaveTo(ostream & save);
+ virtual istream & LoadFrom(istream & load);
+ friend ostream& operator << (ostream & save, SMESH_2D_Algo & hyp);
+ friend istream& operator >> (istream & load, SMESH_2D_Algo & hyp);
+
+protected:
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_3D_Algo.cxx
+// Created : sam mai 18 09:24:52 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_3D_Algo.hxx"
+#include "SMESH_Gen.hxx"
+
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen)
+ : SMESH_Algo(hypId, studyId, gen)
+{
+// _compatibleHypothesis.push_back("hypothese_3D_bidon");
+ _type = ALGO_3D;
+ gen->_map3D_Algo[hypId] = this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_3D_Algo::~SMESH_3D_Algo()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_3D_Algo::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_3D_Algo::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream& operator << (ostream & save, SMESH_3D_Algo & hyp)
+{
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream& operator >> (istream & load, SMESH_3D_Algo & hyp)
+{
+ return load;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_3D_Algo.hxx
+// Created : sam mai 18 09:24:47 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_3D_ALGO_HXX_
+#define _SMESH_3D_ALGO_HXX_
+
+#include "SMESH_Algo.hxx"
+
+class SMESH_3D_Algo:
+ public SMESH_Algo
+{
+public:
+ SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_3D_Algo();
+
+ virtual ostream & SaveTo(ostream & save);
+ virtual istream & LoadFrom(istream & load);
+ friend ostream& operator << (ostream & save, SMESH_3D_Algo & hyp);
+ friend istream& operator >> (istream & load, SMESH_3D_Algo & hyp);
+
+protected:
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Algo.cxx
+// Created : sam mai 18 09:20:53 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Algo.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include "SMESHDS_ListOfPtrHypothesis.hxx"
+#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
+
+#include <GeomAdaptor_Curve.hxx>
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+
+#include "utilities.h"
+
+#include <algorithm>
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Algo::SMESH_Algo(int hypId, int studyId, SMESH_Gen* gen)
+ : SMESH_Hypothesis(hypId, studyId, gen)
+{
+// _compatibleHypothesis.push_back("hypothese_bidon");
+ _type = ALGO;
+ gen->_mapAlgo[hypId] = this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Algo::~SMESH_Algo()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+const vector<string> & SMESH_Algo::GetCompatibleHypothesis()
+{
+ return _compatibleHypothesis;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_Algo::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_Algo::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream& operator << (ostream & save, SMESH_Algo & hyp)
+{
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream& operator >> (istream & load, SMESH_Algo & hyp)
+{
+ return load;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Algo::CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ MESSAGE("SMESH_Algo::CheckHypothesis");
+ ASSERT(0); // use method from derived classes
+ return false;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Algo::Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ MESSAGE("SMESH_Algo::Compute");
+ ASSERT(0); // use method from derived classes
+ return false;
+}
+
+//=============================================================================
+/*!
+ * List the hypothesis used by the algorithm associated to the shape.
+ * Hypothesis associated to father shape -are- taken into account (see
+ * GetAppliedHypothesis). Relevant hypothesis have a name (type) listed in
+ * the algorithm. This method could be surcharged by specific algorithms, in
+ * case of several hypothesis simultaneously applicable.
+ */
+//=============================================================================
+
+const list<SMESHDS_Hypothesis*>&
+SMESH_Algo::GetUsedHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ _usedHypList.clear();
+ _usedHypList = GetAppliedHypothesis(aMesh, aShape); // copy
+ int nbHyp = _usedHypList.size();
+ if (nbHyp == 0)
+ {
+ TopoDS_Shape mainShape = aMesh.GetMeshDS()->ShapeToMesh();
+ if (!mainShape.IsSame(aShape))
+ {
+ _usedHypList = GetAppliedHypothesis(aMesh, mainShape); // copy
+ nbHyp = _usedHypList.size();
+ }
+ }
+ if (nbHyp > 1) _usedHypList.clear(); //only one compatible hypothesis allowed
+ return _usedHypList;
+}
+
+//=============================================================================
+/*!
+ * List the relevant hypothesis associated to the shape. Relevant hypothesis
+ * have a name (type) listed in the algorithm. Hypothesis associated to
+ * father shape -are not- taken into account (see GetUsedHypothesis)
+ */
+//=============================================================================
+
+const list<SMESHDS_Hypothesis*>&
+SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
+ const SMESHDS_ListOfPtrHypothesis& listHyp = meshDS->GetHypothesis(aShape);
+ SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp);
+
+ int hypType;
+ string hypName;
+
+ _appliedHypList.clear();
+ while (it.More())
+ {
+ SMESHDS_Hypothesis* anHyp = it.Value();
+ hypType = anHyp->GetType();
+ //SCRUTE(hypType);
+ if (hypType == SMESHDS_Hypothesis::PARAM_ALGO)
+ {
+ hypName = anHyp->GetName();
+ vector<string>::iterator ith = find(_compatibleHypothesis.begin(),
+ _compatibleHypothesis.end(),
+ hypName);
+ if (ith != _compatibleHypothesis.end()) // count only relevant
+ {
+ _appliedHypList.push_back(anHyp);
+ //SCRUTE(hypName);
+ }
+ }
+ it.Next();
+ }
+ return _appliedHypList;
+}
+
+
+//=============================================================================
+/*!
+ * Compute length of an edge
+ */
+//=============================================================================
+
+double SMESH_Algo::EdgeLength(const TopoDS_Edge& E)
+{
+ double UMin = 0, UMax = 0;
+ TopLoc_Location L;
+ if (BRep_Tool::Degenerated(E)) return 0;
+ Handle (Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
+ GeomAdaptor_Curve AdaptCurve(C);
+ GCPnts_AbscissaPoint gabs;
+ double length = gabs.Length(AdaptCurve, UMin, UMax);
+ return length;
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_Algo.hxx
+// Created : sam mai 18 09:20:46 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_ALGO_HXX_
+#define _SMESH_ALGO_HXX_
+
+#include "SMESH_Hypothesis.hxx"
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <string>
+#include <vector>
+#include <list>
+
+class SMESH_gen;
+class SMESH_Mesh;
+
+class SMESH_Algo:
+ public SMESH_Hypothesis
+{
+public:
+ SMESH_Algo(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_Algo();
+
+ const vector<string> & GetCompatibleHypothesis();
+ virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ virtual bool Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ virtual const list<SMESHDS_Hypothesis*>&
+ GetUsedHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ const list<SMESHDS_Hypothesis*>&
+ GetAppliedHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ static double EdgeLength(const TopoDS_Edge& E);
+
+ virtual ostream & SaveTo(ostream & save);
+ virtual istream & LoadFrom(istream & load);
+ friend ostream& operator << (ostream & save, SMESH_Algo & hyp);
+ friend istream& operator >> (istream & load, SMESH_Algo & hyp);
+
+protected:
+ vector<string> _compatibleHypothesis;
+ list<SMESHDS_Hypothesis*> _appliedHypList;
+ list<SMESHDS_Hypothesis*> _usedHypList;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Gen.cxx
+// Created : sam mai 18 09:34:35 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Gen.hxx"
+
+#include "SMESH_subMesh.hxx"
+
+#include "SMESHDS_ListOfPtrHypothesis.hxx"
+#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+
+#include <gp_Pnt.hxx>
+#include <BRep_Tool.hxx>
+
+#include "utilities.h"
+#include "OpUtil.hxx"
+
+//=============================================================================
+/*!
+ * default constructor:
+ */
+//=============================================================================
+
+SMESH_Gen::SMESH_Gen()
+{
+ MESSAGE("SMESH_Gen::SMESH_Gen");
+ _localId = 0;
+ _hypothesisFactory.SetGen(this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Gen::~SMESH_Gen()
+{
+ MESSAGE("SMESH_Gen::~SMESH_Gen");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hypothesis* SMESH_Gen::CreateHypothesis(const char* anHyp,
+ int studyId)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Gen::CreateHypothesis");
+
+ // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
+
+ StudyContextStruct* myStudyContext = GetStudyContext(studyId);
+
+ // create a new hypothesis object, store its ref. in studyContext
+
+ SMESH_Hypothesis* myHypothesis = _hypothesisFactory.Create(anHyp, studyId);
+ int hypId = myHypothesis->GetID();
+ myStudyContext->mapHypothesis[hypId] = myHypothesis;
+ SCRUTE(studyId);
+ SCRUTE(hypId);
+
+ // store hypothesis in SMESHDS document
+
+ myStudyContext->myDocument->AddHypothesis(myHypothesis);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Mesh* SMESH_Gen::Init(int studyId, const TopoDS_Shape& aShape)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Gen::Init");
+// 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
+
+ StudyContextStruct* myStudyContext = GetStudyContext(studyId);
+
+ // create a new SMESH_mesh object
+
+ 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;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Gen::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Gen::Compute");
+// bool isDone = false;
+/*
+Algo : s'appuie ou non sur une geometrie
+Si geometrie:
+Vertex : rien à faire (range le point)
+Edge, Wire, collection d'edge et wire : 1D
+Face, Shell, collection de Face et Shells : 2D
+Solid, Collection de Solid : 3D
+*/
+// *** corriger commentaires
+ // check hypothesis associated to the mesh :
+ // - only one algo : type compatible with the type of the shape
+ // - hypothesis = compatible with algo
+ // - check if hypothesis are applicable to this algo
+ // - check contradictions within hypothesis
+ // (test if enough hypothesis is done further)
+
+ bool ret = true;
+
+ SMESH_subMesh* sm = aMesh.GetSubMesh(aShape);
+// SCRUTE(sm);
+ SMESH_subMesh* smToCompute = sm->GetFirstToCompute();
+ while (smToCompute)
+ {
+ TopoDS_Shape subShape = smToCompute->GetSubShape();
+ int dim = GetShapeDim(subShape);
+ //SCRUTE(dim);
+ if (dim > 0)
+ {
+ bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
+ ret = ret && ret1;
+ }
+ else
+ {
+ ASSERT(dim == 0);
+ ASSERT(smToCompute->_vertexSet == false);
+ TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
+ gp_Pnt P1 = BRep_Tool::Pnt(V1);
+ const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
+ int nodeId = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
+ //MESSAGE("point "<<nodeId<<" "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z());
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ meshDS->SetNodeOnVertex(node, V1);
+ const Handle(SMESHDS_SubMesh)& subMeshDS
+ = smToCompute->GetSubMeshDS();
+ smToCompute->_vertexSet = true;
+ bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
+ }
+ smToCompute = sm->GetFirstToCompute();
+ }
+
+ return ret;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ //MESSAGE("SMESH_Gen::GetAlgo");
+
+ SMESHDS_Hypothesis* theHyp = NULL;
+ SMESH_Algo* algo = NULL;
+ const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
+ int hypType;
+ int hypId;
+ int algoDim;
+
+ // try shape first, then main shape
+
+ TopoDS_Shape mainShape = meshDS->ShapeToMesh();
+ const TopoDS_Shape* shapeToTry[2] = {&aShape, &mainShape};
+
+ for (int iShape=0; iShape<2; iShape++)
+ {
+ TopoDS_Shape tryShape = (*shapeToTry[iShape]);
+
+ const SMESHDS_ListOfPtrHypothesis& listHyp
+ = meshDS->GetHypothesis(tryShape);
+ SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp);
+
+ int nb_algo = 0;
+ int shapeDim = GetShapeDim(aShape);
+ int typeOfShape = aShape.ShapeType();
+
+ while (it.More())
+ {
+ SMESHDS_Hypothesis* anHyp = it.Value();
+ hypType = anHyp->GetType();
+// SCRUTE(hypType);
+ if (hypType > SMESHDS_Hypothesis::PARAM_ALGO)
+ {
+ switch (hypType)
+ {
+ case SMESHDS_Hypothesis::ALGO_1D: algoDim=1; break;
+ case SMESHDS_Hypothesis::ALGO_2D: algoDim=2; break;
+ case SMESHDS_Hypothesis::ALGO_3D: algoDim=3; break;
+ default: algoDim=0; break;
+ }
+// SCRUTE(algoDim);
+// SCRUTE(shapeDim);
+// SCRUTE(typeOfShape);
+ if (shapeDim == algoDim) // count only algos of shape dim.
+ { // discard algos for subshapes
+ hypId = anHyp->GetID(); // (of lower dim.)
+ ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
+ SMESH_Algo* anAlgo = _mapAlgo[hypId];
+ //SCRUTE(anAlgo->GetShapeType());
+// if (anAlgo->GetShapeType() == typeOfShape)
+ if ((anAlgo->GetShapeType()) & (1 << typeOfShape))
+ { // only specific TopoDS_Shape
+ nb_algo++;
+ theHyp = anHyp;
+ }
+ }
+ }
+ if (nb_algo > 1) return NULL; // more than one algo
+ it.Next();
+ }
+ if (nb_algo == 1) // one algo found : OK
+ break; // do not try a parent shape
+ }
+
+ if (!theHyp) return NULL; // no algo found
+
+ hypType = theHyp->GetType();
+ hypId = theHyp->GetID();
+
+ ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
+ algo = _mapAlgo[hypId];
+ const char* algoName = algo->GetName();
+ //MESSAGE("Algo found " << algoName << " Id " << hypId);
+ return algo;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+StudyContextStruct* SMESH_Gen::GetStudyContext(int studyId)
+{
+ // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
+
+ if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
+ {
+ _mapStudyContext[studyId] = new StudyContextStruct;
+ _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
+ }
+ StudyContextStruct* myStudyContext = _mapStudyContext[studyId];
+// ASSERT(_mapStudyContext.find(studyId) != _mapStudyContext.end());
+ return myStudyContext;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Gen::Save(int studyId, const char *aUrlOfFile)
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Gen::Close(int studyId)
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+const char* SMESH_Gen::ComponentDataType()
+{
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+const char* SMESH_Gen::IORToLocalPersistentID(const char* IORString,
+ bool& IsAFile)
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+const char* SMESH_Gen::LocalPersistentIDToIOR(const char* aLocalPersistentID)
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_Gen::GetShapeDim(const TopoDS_Shape& aShape)
+{
+ int shapeDim = -1; // Shape dimension: 0D, 1D, 2D, 3D
+ int type = aShape.ShapeType();
+ switch (type)
+ {
+// case TopAbs_COMPOUND:
+// {
+// break;
+// }
+ case TopAbs_COMPOUND:
+ case TopAbs_COMPSOLID:
+ case TopAbs_SOLID:
+ case TopAbs_SHELL:
+ {
+ shapeDim = 3;
+ break;
+ }
+ // case TopAbs_SHELL:
+ case TopAbs_FACE:
+ {
+ shapeDim = 2;
+ break;
+ }
+ case TopAbs_WIRE:
+ case TopAbs_EDGE:
+ {
+ shapeDim = 1;
+ break;
+ }
+ case TopAbs_VERTEX:
+ {
+ shapeDim = 0;
+ break;
+ }
+ }
+// SCRUTE(shapeDim);
+ return shapeDim;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Gen.hxx
+// Created : jeu mai 16 22:53:13 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_GEN_HXX_
+#define _SMESH_GEN_HXX_
+
+#include "Utils_SALOME_Exception.hxx"
+
+#include "SMESH_HypothesisFactory.hxx"
+#include "SMESH_Hypothesis.hxx"
+#include "SMESH_Algo.hxx"
+#include "SMESH_1D_Algo.hxx"
+#include "SMESH_2D_Algo.hxx"
+#include "SMESH_3D_Algo.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include "SMESHDS_Document.hxx"
+
+#include <TopoDS_Shape.hxx>
+
+#include <map>
+
+typedef struct studyContextStruct
+{
+ map<int, SMESH_Hypothesis*> mapHypothesis;
+ map<int, SMESH_Mesh*> mapMesh;
+ Handle (SMESHDS_Document) myDocument;
+} StudyContextStruct ;
+
+class SMESH_Gen
+{
+public:
+ SMESH_Gen();
+ ~SMESH_Gen();
+
+ SMESH_Hypothesis* CreateHypothesis(const char* anHyp, int studyId)
+ throw (SALOME_Exception);
+ SMESH_Mesh* Init(int studyId, const TopoDS_Shape& aShape)
+ throw (SALOME_Exception);
+ bool Compute(::SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
+ throw (SALOME_Exception);
+ StudyContextStruct* GetStudyContext(int studyId);
+
+ static int GetShapeDim(const TopoDS_Shape& aShape);
+ SMESH_Algo* GetAlgo(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
+
+ // inherited methods from SALOMEDS::Driver
+
+ void Save(int studyId, const char *aUrlOfFile);
+ void Load(int studyId, const char *aUrlOfFile);
+ void Close(int studyId);
+ const char* ComponentDataType();
+
+ const char* IORToLocalPersistentID(const char* IORString, bool& IsAFile);
+ const char* LocalPersistentIDToIOR(const char* aLocalPersistentID);
+
+ SMESH_HypothesisFactory _hypothesisFactory;
+
+ map<int, SMESH_Algo*> _mapAlgo;
+ map<int, SMESH_1D_Algo*> _map1D_Algo;
+ map<int, SMESH_2D_Algo*> _map2D_Algo;
+ map<int, SMESH_3D_Algo*> _map3D_Algo;
+
+private:
+ int _localId; // unique Id of created objects, within SMESH_Gen entity
+ map<int, StudyContextStruct*> _mapStudyContext;
+ map<int, SMESH_Hypothesis*> _mapHypothesis;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Hexa_3D.cxx
+// Created : sam mai 18 23:15:30 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Hexa_3D.hxx"
+#include "SMESH_Quadrangle_2D.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_FacePosition.hxx"
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+#include <BRep_Tool.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Handle_Geom2d_Curve.hxx>
+#include <Handle_Geom_Curve.hxx>
+
+#include "utilities.h"
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hexa_3D::SMESH_Hexa_3D(int hypId, int studyId,
+ SMESH_Gen* gen)
+ : SMESH_3D_Algo(hypId, studyId, gen)
+{
+ MESSAGE("SMESH_Hexa_3D::SMESH_Hexa_3D");
+ _name = "Hexa_3D";
+// _shapeType = TopAbs_SOLID;
+ _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
+// MESSAGE("_shapeType octal " << oct << _shapeType);
+ for (int i=0; i<6; i++) _quads[i] = 0;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hexa_3D::~SMESH_Hexa_3D()
+{
+ MESSAGE("SMESH_Hexa_3D::~SMESH_Hexa_3D");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Hexa_3D::CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ MESSAGE("SMESH_Hexa_3D::CheckHypothesis");
+
+ bool isOk = true;
+
+ // nothing to check
+
+ return isOk;
+}
+
+//=============================================================================
+/*!
+ * Hexahedron mesh on hexaedron like form
+ * -0. - shape and face mesh verification
+ * -1. - identify faces and vertices of the "cube"
+ * -2. - Algorithm from:
+ * "Application de l'interpolation transfinie à la création de maillages
+ * C0 ou G1 continus sur des triangles, quadrangles, tetraedres, pentaedres
+ * et hexaedres déformés."
+ * Alain PERONNET - 8 janvier 1999
+ */
+//=============================================================================
+
+bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Hexa_3D::Compute");
+
+ bool isOk = false;
+ const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
+ SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
+ //const Handle(SMESHDS_SubMesh)& subMeshDS = theSubMesh->GetSubMeshDS();
+
+ // 0. - shape and face mesh verification
+ // 0.1 - shape must be a solid (or a shell) with 6 faces
+ MESSAGE("---");
+
+ vector<SMESH_subMesh*> meshFaces;
+ for (TopExp_Explorer exp(aShape,TopAbs_FACE);exp.More();exp.Next())
+ {
+ SMESH_subMesh* aSubMesh = aMesh.GetSubMeshContaining(exp.Current());
+ ASSERT (aSubMesh);
+ meshFaces.push_back(aSubMesh);
+ }
+ if (meshFaces.size() != 6)
+ {
+ SCRUTE(meshFaces.size());
+ ASSERT(0);
+ return false;
+ }
+
+ // 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges)
+ MESSAGE("---");
+
+ for (int i=0; i<6; i++)
+ {
+ TopoDS_Shape aShape = meshFaces[i]->GetSubShape();
+ SMESH_Algo* algo = _gen->GetAlgo(aMesh, aShape);
+ string algoName = algo->GetName();
+ if (algoName != "Quadrangle_2D")
+ {
+ // *** delete _quads
+ SCRUTE(algoName);
+ ASSERT(0);
+ return false;
+ }
+ SMESH_Quadrangle_2D* quadAlgo =dynamic_cast<SMESH_Quadrangle_2D*> (algo);
+ ASSERT(quadAlgo);
+ try
+ {
+ _quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aShape);
+ // *** to delete after usage
+ }
+ catch (SALOME_Exception& S_ex)
+ {
+ // *** delete _quads
+ // *** throw exception
+ ASSERT(0);
+ }
+ }
+
+ // 1. - identify faces and vertices of the "cube"
+ // 1.1 - ancestor maps vertex->edges in the cube
+ MESSAGE("---");
+
+ TopTools_IndexedDataMapOfShapeListOfShape MS;
+ TopExp::MapShapesAndAncestors(aShape, TopAbs_VERTEX, TopAbs_EDGE, MS);
+
+ // 1.2 - first face is choosen as face Y=0 of the unit cube
+ MESSAGE("---");
+
+ const TopoDS_Shape& aFace = meshFaces[0]->GetSubShape();
+ const TopoDS_Face& F = TopoDS::Face(aFace);
+
+ // 1.3 - identify the 4 vertices of the face Y=0: V000, V100, V101, V001
+ MESSAGE("---");
+
+ int i = 0;
+ TopoDS_Edge E = _quads[0]->edge[i]; //edge will be Y=0,Z=0 on unit cube
+ double f,l;
+ Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
+ TopoDS_Vertex VFirst, VLast;
+ TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
+ bool isForward = (((l-f)*(_quads[0]->last[i] - _quads[0]->first[i])) > 0);
+
+ if (isForward)
+ {
+ _cube.V000 = VFirst; // will be (0,0,0) on the unit cube
+ _cube.V100 = VLast; // will be (1,0,0) on the unit cube
+ }
+ else
+ {
+ _cube.V000 = VLast;
+ _cube.V100 = VFirst;
+ }
+
+ i = 1;
+ E = _quads[0]->edge[i];
+ C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
+ TopExp::Vertices(E, VFirst, VLast);
+ isForward = (((l-f)*(_quads[0]->last[i] - _quads[0]->first[i])) > 0);
+ if (isForward) _cube.V101 = VLast; // will be (1,0,1) on the unit cube
+ else _cube.V101 = VFirst;
+
+ i = 2;
+ E = _quads[0]->edge[i];
+ C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
+ TopExp::Vertices(E, VFirst, VLast);
+ isForward = (((l-f)*(_quads[0]->last[i] - _quads[0]->first[i])) > 0);
+ if (isForward) _cube.V001 = VLast; // will be (0,0,1) on the unit cube
+ else _cube.V001 = VFirst;
+
+ // 1.4 - find edge X=0, Z=0 (ancestor of V000 not in face Y=0)
+ // - find edge X=1, Z=0 (ancestor of V100 not in face Y=0)
+ // - find edge X=1, Z=1 (ancestor of V101 not in face Y=0)
+ // - find edge X=0, Z=1 (ancestor of V001 not in face Y=0)
+ MESSAGE("---");
+
+ TopoDS_Edge E_0Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V000, MS);
+ ASSERT(! E_0Y0.IsNull());
+
+ TopoDS_Edge E_1Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V100, MS);
+ ASSERT(! E_1Y0.IsNull());
+
+ TopoDS_Edge E_1Y1 = EdgeNotInFace(aMesh, aShape, F, _cube.V101, MS);
+ ASSERT(! E_1Y1.IsNull());
+
+ TopoDS_Edge E_0Y1 = EdgeNotInFace(aMesh, aShape, F, _cube.V001, MS);
+ ASSERT(! E_0Y1.IsNull());
+
+ // 1.5 - identify the 4 vertices in face Y=1: V010, V110, V111, V011
+ MESSAGE("---");
+
+ TopExp::Vertices(E_0Y0, VFirst, VLast);
+ if (VFirst.IsSame(_cube.V000)) _cube.V010 = VLast;
+ else _cube.V010 = VFirst;
+
+ TopExp::Vertices(E_1Y0, VFirst, VLast);
+ if (VFirst.IsSame(_cube.V100)) _cube.V110 = VLast;
+ else _cube.V110 = VFirst;
+
+ TopExp::Vertices(E_1Y1, VFirst, VLast);
+ if (VFirst.IsSame(_cube.V101)) _cube.V111 = VLast;
+ else _cube.V111 = VFirst;
+
+ TopExp::Vertices(E_0Y1, VFirst, VLast);
+ if (VFirst.IsSame(_cube.V001)) _cube.V011 = VLast;
+ else _cube.V011 = VFirst;
+
+ // 1.6 - find remaining faces given 4 vertices
+ MESSAGE("---");
+
+ _indY0 = 0;
+ _cube.quad_Y0 = _quads[_indY0];
+
+ _indY1 = GetFaceIndex(aMesh, aShape, meshFaces,
+ _cube.V010,_cube.V011,_cube.V110,_cube.V111);
+ _cube.quad_Y1 = _quads[_indY1];
+
+ _indZ0 = GetFaceIndex(aMesh, aShape, meshFaces,
+ _cube.V000,_cube.V010,_cube.V100,_cube.V110);
+ _cube.quad_Z0 = _quads[_indZ0];
+
+ _indZ1 = GetFaceIndex(aMesh, aShape, meshFaces,
+ _cube.V001,_cube.V011,_cube.V101,_cube.V111);
+ _cube.quad_Z1 = _quads[_indZ1];
+
+ _indX0 = GetFaceIndex(aMesh, aShape, meshFaces,
+ _cube.V000,_cube.V001,_cube.V010,_cube.V011);
+ _cube.quad_X0 = _quads[_indX0];
+
+ _indX1 = GetFaceIndex(aMesh, aShape, meshFaces,
+ _cube.V100,_cube.V101,_cube.V110,_cube.V111);
+ _cube.quad_X1 = _quads[_indX1];
+
+ MESSAGE("---");
+
+ // 1.7 - get convertion coefs from face 2D normalized to 3D normalized
+
+ Conv2DStruct cx0; // for face X=0
+ Conv2DStruct cx1; // for face X=1
+ Conv2DStruct cy0;
+ Conv2DStruct cy1;
+ Conv2DStruct cz0;
+ Conv2DStruct cz1;
+
+ GetConv2DCoefs(*_cube.quad_X0, meshFaces[_indX0]->GetSubShape(),
+ _cube.V000,_cube.V010,_cube.V011,_cube.V001,
+ cx0);
+ GetConv2DCoefs(*_cube.quad_X1, meshFaces[_indX1]->GetSubShape(),
+ _cube.V100,_cube.V110,_cube.V111,_cube.V101,
+ cx1);
+ GetConv2DCoefs(*_cube.quad_Y0, meshFaces[_indY0]->GetSubShape(),
+ _cube.V000,_cube.V100,_cube.V101,_cube.V001,
+ cy0);
+ GetConv2DCoefs(*_cube.quad_Y1, meshFaces[_indY1]->GetSubShape(),
+ _cube.V010,_cube.V110,_cube.V111,_cube.V011,
+ cy1);
+ GetConv2DCoefs(*_cube.quad_Z0, meshFaces[_indZ0]->GetSubShape(),
+ _cube.V000,_cube.V100,_cube.V110,_cube.V010,
+ cz0);
+ GetConv2DCoefs(*_cube.quad_Z1, meshFaces[_indZ1]->GetSubShape(),
+ _cube.V001,_cube.V101,_cube.V111,_cube.V011,
+ cz1);
+
+ // 1.8 - create a 3D structure for normalized values
+
+ MESSAGE("---");
+ int nbx = _cube.quad_Y0->nbPts[0];
+ int nby = _cube.quad_Y0->nbPts[1];
+ int nbz;
+ if (cx0.a1 != 0) nbz = _cube.quad_X0->nbPts[1];
+ else nbz = _cube.quad_X0->nbPts[0];
+ //SCRUTE(nbx);
+ //SCRUTE(nby);
+ //SCRUTE(nbz);
+ int nbxyz= nbx*nby*nbz;
+ Point3DStruct* np = new Point3DStruct[nbxyz];
+
+ // 1.9 - store node indexes of faces
+
+ {
+ const TopoDS_Face& F = TopoDS::Face(meshFaces[_indX0]->GetSubShape());
+ const TColStd_ListOfInteger& indElt
+ = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+ TColStd_ListIteratorOfListOfInteger itf(indElt);
+
+ faceQuadStruct* quad = _cube.quad_X0;
+ int i=0; // j = x/face , k = y/face
+ int nbdown = quad->nbPts[0];
+ int nbright = quad->nbPts[1];
+
+ for (; itf.More(); itf.Next())
+ {
+ int nodeId = itf.Value();
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ Handle (SMDS_FacePosition) fpos
+ = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
+ double ri = fpos->GetUParameter();
+ double rj = fpos->GetVParameter();
+ int i1 = int(ri);
+ int j1 = int(rj);
+ int ij1 = j1*nbdown +i1;
+ quad->uv_grid[ij1].nodeId = nodeId;
+ }
+
+ for (int i1=0; i1<nbdown; i1++)
+ for (int j1=0; j1<nbright; j1++)
+ {
+ int ij1 = j1*nbdown +i1;
+ int j = cx0.ia*i1 + cx0.ib*j1 + cx0.ic; // j = x/face
+ int k = cx0.ja*i1 + cx0.jb*j1 + cx0.jc; // k = y/face
+ int ijk = k*nbx*nby + j*nbx + i;
+ //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+ np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+ //SCRUTE(np[ijk].nodeId);
+ }
+ }
+
+ {
+ const TopoDS_Face& F = TopoDS::Face(meshFaces[_indX1]->GetSubShape());
+ const TColStd_ListOfInteger& indElt
+ = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+ TColStd_ListIteratorOfListOfInteger itf(indElt);
+
+ faceQuadStruct* quad = _cube.quad_X1;
+ int i=nbx-1; // j = x/face , k = y/face
+ int nbdown = quad->nbPts[0];
+ int nbright = quad->nbPts[1];
+
+ for (; itf.More(); itf.Next())
+ {
+ int nodeId = itf.Value();
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ Handle (SMDS_FacePosition) fpos
+ = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
+ double ri = fpos->GetUParameter();
+ double rj = fpos->GetVParameter();
+ int i1 = int(ri);
+ int j1 = int(rj);
+ int ij1 = j1*nbdown +i1;
+ quad->uv_grid[ij1].nodeId = nodeId;
+ }
+
+ for (int i1=0; i1<nbdown; i1++)
+ for (int j1=0; j1<nbright; j1++)
+ {
+ int ij1 = j1*nbdown +i1;
+ int j = cx1.ia*i1 + cx1.ib*j1 + cx1.ic; // j = x/face
+ int k = cx1.ja*i1 + cx1.jb*j1 + cx1.jc; // k = y/face
+ int ijk = k*nbx*nby + j*nbx + i;
+ //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+ np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+ //SCRUTE(np[ijk].nodeId);
+ }
+ }
+
+ {
+ const TopoDS_Face& F = TopoDS::Face(meshFaces[_indY0]->GetSubShape());
+ const TColStd_ListOfInteger& indElt
+ = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+ TColStd_ListIteratorOfListOfInteger itf(indElt);
+
+ faceQuadStruct* quad = _cube.quad_Y0;
+ int j=0; // i = x/face , k = y/face
+ int nbdown = quad->nbPts[0];
+ int nbright = quad->nbPts[1];
+
+ for (; itf.More(); itf.Next())
+ {
+ int nodeId = itf.Value();
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ Handle (SMDS_FacePosition) fpos
+ = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
+ double ri = fpos->GetUParameter();
+ double rj = fpos->GetVParameter();
+ int i1 = int(ri);
+ int j1 = int(rj);
+ int ij1 = j1*nbdown +i1;
+ quad->uv_grid[ij1].nodeId = nodeId;
+ }
+
+ for (int i1=0; i1<nbdown; i1++)
+ for (int j1=0; j1<nbright; j1++)
+ {
+ int ij1 = j1*nbdown +i1;
+ int i = cy0.ia*i1 + cy0.ib*j1 + cy0.ic; // i = x/face
+ int k = cy0.ja*i1 + cy0.jb*j1 + cy0.jc; // k = y/face
+ int ijk = k*nbx*nby + j*nbx + i;
+ //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+ np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+ //SCRUTE(np[ijk].nodeId);
+ }
+ }
+
+ {
+ const TopoDS_Face& F = TopoDS::Face(meshFaces[_indY1]->GetSubShape());
+ const TColStd_ListOfInteger& indElt
+ = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+ TColStd_ListIteratorOfListOfInteger itf(indElt);
+
+ faceQuadStruct* quad = _cube.quad_Y1;
+ int j=nby-1; // i = x/face , k = y/face
+ int nbdown = quad->nbPts[0];
+ int nbright = quad->nbPts[1];
+
+ for (; itf.More(); itf.Next())
+ {
+ int nodeId = itf.Value();
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ Handle (SMDS_FacePosition) fpos
+ = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
+ double ri = fpos->GetUParameter();
+ double rj = fpos->GetVParameter();
+ int i1 = int(ri);
+ int j1 = int(rj);
+ int ij1 = j1*nbdown +i1;
+ quad->uv_grid[ij1].nodeId = nodeId;
+ }
+
+ for (int i1=0; i1<nbdown; i1++)
+ for (int j1=0; j1<nbright; j1++)
+ {
+ int ij1 = j1*nbdown +i1;
+ int i = cy1.ia*i1 + cy1.ib*j1 + cy1.ic; // i = x/face
+ int k = cy1.ja*i1 + cy1.jb*j1 + cy1.jc; // k = y/face
+ int ijk = k*nbx*nby + j*nbx + i;
+ //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+ np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+ //SCRUTE(np[ijk].nodeId);
+ }
+ }
+
+ {
+ const TopoDS_Face& F = TopoDS::Face(meshFaces[_indZ0]->GetSubShape());
+ const TColStd_ListOfInteger& indElt
+ = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+ TColStd_ListIteratorOfListOfInteger itf(indElt);
+
+ faceQuadStruct* quad = _cube.quad_Z0;
+ int k=0; // i = x/face , j = y/face
+ int nbdown = quad->nbPts[0];
+ int nbright = quad->nbPts[1];
+
+ for (; itf.More(); itf.Next())
+ {
+ int nodeId = itf.Value();
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ Handle (SMDS_FacePosition) fpos
+ = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
+ double ri = fpos->GetUParameter();
+ double rj = fpos->GetVParameter();
+ int i1 = int(ri);
+ int j1 = int(rj);
+ int ij1 = j1*nbdown +i1;
+ quad->uv_grid[ij1].nodeId = nodeId;
+ }
+
+ for (int i1=0; i1<nbdown; i1++)
+ for (int j1=0; j1<nbright; j1++)
+ {
+ int ij1 = j1*nbdown +i1;
+ int i = cz0.ia*i1 + cz0.ib*j1 + cz0.ic; // i = x/face
+ int j = cz0.ja*i1 + cz0.jb*j1 + cz0.jc; // j = y/face
+ int ijk = k*nbx*nby + j*nbx + i;
+ //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+ np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+ //SCRUTE(np[ijk].nodeId);
+ }
+ }
+
+ {
+ const TopoDS_Face& F = TopoDS::Face(meshFaces[_indZ1]->GetSubShape());
+ const TColStd_ListOfInteger& indElt
+ = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+ TColStd_ListIteratorOfListOfInteger itf(indElt);
+
+ faceQuadStruct* quad = _cube.quad_Z1;
+ int k=nbz-1; // i = x/face , j = y/face
+ int nbdown = quad->nbPts[0];
+ int nbright = quad->nbPts[1];
+
+ for (; itf.More(); itf.Next())
+ {
+ int nodeId = itf.Value();
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ Handle (SMDS_FacePosition) fpos
+ = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
+ double ri = fpos->GetUParameter();
+ double rj = fpos->GetVParameter();
+ int i1 = int(ri);
+ int j1 = int(rj);
+ int ij1 = j1*nbdown +i1;
+ quad->uv_grid[ij1].nodeId = nodeId;
+ }
+
+ for (int i1=0; i1<nbdown; i1++)
+ for (int j1=0; j1<nbright; j1++)
+ {
+ int ij1 = j1*nbdown +i1;
+ int i = cz1.ia*i1 + cz1.ib*j1 + cz1.ic; // i = x/face
+ int j = cz1.ja*i1 + cz1.jb*j1 + cz1.jc; // j = y/face
+ int ijk = k*nbx*nby + j*nbx + i;
+ //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+ np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+ //SCRUTE(np[ijk].nodeId);
+ }
+ }
+
+ // 2.0 - for each node of the cube:
+ // - get the 8 points 3D = 8 vertices of the cube
+ // - get the 12 points 3D on the 12 edges of the cube
+ // - get the 6 points 3D on the 6 faces with their ID
+ // - compute the point 3D
+ // - store the point 3D in SMESHDS, store its ID in 3D structure
+
+ TopoDS_Shell aShell;
+ TopExp_Explorer exp(aShape,TopAbs_SHELL);
+ if (exp.More())
+ {
+ aShell = TopoDS::Shell(exp.Current());
+ }
+ else
+ {
+ MESSAGE("no shell...");
+ ASSERT(0);
+ }
+
+ MESSAGE("---");
+ Pt3 p000, p001, p010, p011, p100, p101, p110, p111;
+ Pt3 px00, px01, px10, px11;
+ Pt3 p0y0, p0y1, p1y0, p1y1;
+ Pt3 p00z, p01z, p10z, p11z;
+ Pt3 pxy0, pxy1, px0z, px1z, p0yz, p1yz;
+
+ GetPoint(p000, 0, 0, 0, nbx, nby, nbz, np, meshDS);
+ GetPoint(p001, 0, 0, nbz-1, nbx, nby, nbz, np, meshDS);
+ GetPoint(p010, 0, nby-1, 0, nbx, nby, nbz, np, meshDS);
+ GetPoint(p011, 0, nby-1, nbz-1, nbx, nby, nbz, np, meshDS);
+ GetPoint(p100, nbx-1, 0, 0, nbx, nby, nbz, np, meshDS);
+ GetPoint(p101, nbx-1, 0, nbz-1, nbx, nby, nbz, np, meshDS);
+ GetPoint(p110, nbx-1, nby-1, 0, nbx, nby, nbz, np, meshDS);
+ GetPoint(p111, nbx-1, nby-1, nbz-1, nbx, nby, nbz, np, meshDS);
+
+ for (int i=1; i<nbx-1; i++)
+ {
+ for (int j=1; j<nby-1; j++)
+ {
+ for (int k=1; k<nbz-1; k++)
+ {
+ // *** seulement maillage regulier
+ // 12 points on edges
+ GetPoint(px00, i, 0, 0, nbx, nby, nbz, np, meshDS);
+ GetPoint(px01, i, 0, nbz-1, nbx, nby, nbz, np, meshDS);
+ GetPoint(px10, i, nby-1, 0, nbx, nby, nbz, np, meshDS);
+ GetPoint(px11, i, nby-1, nbz-1, nbx, nby, nbz, np, meshDS);
+
+ GetPoint(p0y0, 0, j, 0, nbx, nby, nbz, np, meshDS);
+ GetPoint(p0y1, 0, j, nbz-1, nbx, nby, nbz, np, meshDS);
+ GetPoint(p1y0, nbx-1, j, 0, nbx, nby, nbz, np, meshDS);
+ GetPoint(p1y1, nbx-1, j, nbz-1, nbx, nby, nbz, np, meshDS);
+
+ GetPoint(p00z, 0, 0, k, nbx, nby, nbz, np, meshDS);
+ GetPoint(p01z, 0, nby-1, k, nbx, nby, nbz, np, meshDS);
+ GetPoint(p10z, nbx-1, 0, k, nbx, nby, nbz, np, meshDS);
+ GetPoint(p11z, nbx-1, nby-1, k, nbx, nby, nbz, np, meshDS);
+
+ // 12 points on faces
+ GetPoint(pxy0, i, j, 0, nbx, nby, nbz, np, meshDS);
+ GetPoint(pxy1, i, j, nbz-1, nbx, nby, nbz, np, meshDS);
+ GetPoint(px0z, i, 0, k, nbx, nby, nbz, np, meshDS);
+ GetPoint(px1z, i, nby-1, k, nbx, nby, nbz, np, meshDS);
+ GetPoint(p0yz, 0, j, k, nbx, nby, nbz, np, meshDS);
+ GetPoint(p1yz, nbx-1, j, k, nbx, nby, nbz, np, meshDS);
+
+ int ijk = k*nbx*nby + j*nbx + i;
+ double x = double(i)/double(nbx-1); // *** seulement
+ double y = double(j)/double(nby-1); // *** maillage
+ double z = double(k)/double(nbz-1); // *** regulier
+
+ Pt3 X;
+ for (int i=0; i<3; i++)
+ {
+ X[i] =
+ (1-x)*p0yz[i] + x*p1yz[i]
+ +(1-y)*px0z[i] + y*px1z[i]
+ +(1-z)*pxy0[i] + z*pxy1[i]
+ -(1-x)*((1-y)*p00z[i] + y*p01z[i])
+ - x *((1-y)*p10z[i] + y*p11z[i])
+ -(1-y)*((1-z)*px00[i] + z*px01[i])
+ - y *((1-z)*px10[i] + z*px11[i])
+ -(1-z)*((1-x)*p0y0[i] + x*p1y0[i])
+ - z *((1-x)*p0y1[i] + x*p1y1[i])
+ +(1-x)*( (1-y)*((1-z)*p000[i] + z*p001[i])
+ + y *((1-z)*p010[i] + z*p011[i]))
+ + x *( (1-y)*((1-z)*p100[i] + z*p101[i])
+ + y *((1-z)*p110[i] + z*p111[i]));
+ }
+
+
+ int myNodeId = meshDS->AddNode(X[0],X[1],X[2]);
+ //MESSAGE("point "<<myNodeId<<" "<<X[0]<<" "<<X[1]<<" "<<X[2]);
+ np[ijk].nodeId = myNodeId;
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(myNodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+
+ //meshDS->SetNodeInVolume(node, TopoDS::Solid(aShape));
+ meshDS->SetNodeInVolume(node, aShell);
+ }
+ }
+ }
+
+ //2.1 - for each node of the cube (less 3 *1 Faces):
+ // - store hexahedron in SMESHDS
+
+ for (int i=0; i<nbx-1; i++)
+ for (int j=0; j<nby-1; j++)
+ for (int k=0; k<nbz-1; k++)
+ {
+ int n1 = k *nbx*nby + j *nbx + i;
+ int n2 = k *nbx*nby + j *nbx + i+1;
+ int n3 = k *nbx*nby + (j+1)*nbx + i+1;
+ int n4 = k *nbx*nby + (j+1)*nbx + i;
+ int n5 = (k+1)*nbx*nby + j *nbx + i;
+ int n6 = (k+1)*nbx*nby + j *nbx + i+1;
+ int n7 = (k+1)*nbx*nby + (j+1)*nbx + i+1;
+ int n8 = (k+1)*nbx*nby + (j+1)*nbx + i;
+
+// MESSAGE(" "<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<" "<<n7<<" "<<n8);
+ //MESSAGE(" "<<np[n1].nodeId<<" "<<np[n2].nodeId<<" "<<np[n3].nodeId<<" "<<np[n4].nodeId<<" "<<np[n5].nodeId<<" "<<np[n6].nodeId<<" "<<np[n7].nodeId<<" "<<np[n8].nodeId);
+
+ int hexa = meshDS->AddVolume(np[n1].nodeId,
+ np[n2].nodeId,
+ np[n3].nodeId,
+ np[n4].nodeId,
+ np[n5].nodeId,
+ np[n6].nodeId,
+ np[n7].nodeId,
+ np[n8].nodeId);
+ Handle (SMDS_MeshElement) elt = meshDS->FindElement(hexa);
+ meshDS->SetMeshElementOnShape(elt, aShell);
+
+ // *** 5 tetrahedres ... verifier orientations,
+ // mettre en coherence &vec quadrangles-> triangles
+ // choisir afficher 1 parmi edges, face et volumes
+// int tetra1 = meshDS->AddVolume(np[n1].nodeId,
+// np[n2].nodeId,
+// np[n4].nodeId,
+// np[n5].nodeId);
+// int tetra2 = meshDS->AddVolume(np[n2].nodeId,
+// np[n3].nodeId,
+// np[n4].nodeId,
+// np[n7].nodeId);
+// int tetra3 = meshDS->AddVolume(np[n5].nodeId,
+// np[n6].nodeId,
+// np[n7].nodeId,
+// np[n2].nodeId);
+// int tetra4 = meshDS->AddVolume(np[n5].nodeId,
+// np[n7].nodeId,
+// np[n8].nodeId,
+// np[n4].nodeId);
+// int tetra5 = meshDS->AddVolume(np[n5].nodeId,
+// np[n7].nodeId,
+// np[n2].nodeId,
+// np[n4].nodeId);
+
+ }
+
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Hexa_3D::GetPoint(Pt3 p,
+ int i, int j, int k,
+ int nbx, int nby, int nbz,
+ Point3DStruct *np,
+ const Handle(SMESHDS_Mesh)& meshDS)
+{
+ int ijk = k*nbx*nby + j*nbx + i;
+ int nodeId = np[ijk].nodeId;
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ p[0] = node->X();
+ p[1] = node->Y();
+ p[2] = node->Z();
+ //MESSAGE(" "<<i<<" "<<j<<" "<<k<<" "<<p[0]<<" "<<p[1]<<" "<<p[2]);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_Hexa_3D::GetFaceIndex(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ const vector<SMESH_subMesh*>& meshFaces,
+ const TopoDS_Vertex& V0,
+ const TopoDS_Vertex& V1,
+ const TopoDS_Vertex& V2,
+ const TopoDS_Vertex& V3)
+{
+ MESSAGE("SMESH_Hexa_3D::GetFaceIndex");
+ int faceIndex = -1;
+ for (int i=1; i<6; i++)
+ {
+ const TopoDS_Shape& aFace = meshFaces[i]->GetSubShape();
+ //const TopoDS_Face& F = TopoDS::Face(aFace);
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(aFace, TopAbs_VERTEX, M);
+ bool verticesInShape = false;
+ if (M.Contains(V0))
+ if (M.Contains(V1))
+ if (M.Contains(V2))
+ if (M.Contains(V3)) verticesInShape = true;
+ if (verticesInShape)
+ {
+ faceIndex = i;
+ break;
+ }
+ }
+ ASSERT(faceIndex>0);
+ SCRUTE(faceIndex);
+ return faceIndex;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+TopoDS_Edge
+SMESH_Hexa_3D::EdgeNotInFace(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ const TopoDS_Face& aFace,
+ const TopoDS_Vertex& aVertex,
+ const TopTools_IndexedDataMapOfShapeListOfShape& MS)
+{
+ MESSAGE("SMESH_Hexa_3D::EdgeNotInFace");
+ TopTools_IndexedDataMapOfShapeListOfShape MF;
+ TopExp::MapShapesAndAncestors(aFace, TopAbs_VERTEX, TopAbs_EDGE, MF);
+ const TopTools_ListOfShape& ancestorsInSolid = MS.FindFromKey(aVertex);
+ const TopTools_ListOfShape& ancestorsInFace = MF.FindFromKey(aVertex);
+ SCRUTE(ancestorsInSolid.Extent());
+ SCRUTE(ancestorsInFace.Extent());
+ ASSERT(ancestorsInSolid.Extent() == 6); // 6 (edges doublees)
+ ASSERT(ancestorsInFace.Extent() == 2);
+
+ TopoDS_Edge E;
+ E.Nullify();
+ TopTools_ListIteratorOfListOfShape its(ancestorsInSolid);
+ for ( ; its.More();its.Next())
+ {
+ TopoDS_Shape ancestor = its.Value();
+ TopTools_ListIteratorOfListOfShape itf(ancestorsInFace);
+ bool isInFace = false;
+ for ( ; itf.More();itf.Next())
+ {
+ TopoDS_Shape ancestorInFace = itf.Value();
+ if (ancestorInFace.IsSame(ancestor))
+ {
+ isInFace = true;
+ break;
+ }
+ }
+ if (! isInFace)
+ {
+ E = TopoDS::Edge(ancestor);
+ break;
+ }
+ }
+ return E;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ void SMESH_Hexa_3D::GetConv2DCoefs(const faceQuadStruct& quad,
+ const TopoDS_Shape& aShape,
+ const TopoDS_Vertex& V0,
+ const TopoDS_Vertex& V1,
+ const TopoDS_Vertex& V2,
+ const TopoDS_Vertex& V3,
+ Conv2DStruct& conv)
+{
+ MESSAGE("SMESH_Hexa_3D::GetConv2DCoefs");
+ const TopoDS_Face& F = TopoDS::Face(aShape);
+ TopoDS_Edge E = quad.edge[0];
+ double f,l;
+ Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
+ TopoDS_Vertex VFirst, VLast;
+ TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
+ bool isForward = (((l-f)*(quad.last[0] - quad.first[0])) > 0);
+ TopoDS_Vertex VA, VB;
+ if (isForward)
+ {
+ VA = VFirst; VB = VLast;
+ }
+ else
+ {
+ VA = VLast; VB = VFirst;
+ }
+ int a1,b1,c1,a2,b2,c2;
+ if (VA.IsSame(V0))
+ if (VB.IsSame(V1))
+ {
+ a1= 1; b1= 0; c1= 0; // x
+ a2= 0; b2= 1; c2= 0; // y
+ }
+ else
+ {
+ ASSERT(VB.IsSame(V3));
+ a1= 0; b1= 1; c1= 0; // y
+ a2= 1; b2= 0; c2= 0; // x
+ }
+ if (VA.IsSame(V1))
+ if (VB.IsSame(V2))
+ {
+ a1= 0; b1=-1; c1= 1; // 1-y
+ a2= 1; b2= 0; c2= 0; // x
+ }
+ else
+ {
+ ASSERT(VB.IsSame(V0));
+ a1=-1; b1= 0; c1= 1; // 1-x
+ a2= 0; b2= 1; c2= 0; // y
+ }
+ if (VA.IsSame(V2))
+ if (VB.IsSame(V3))
+ {
+ a1=-1; b1= 0; c1= 1; // 1-x
+ a2= 0; b2=-1; c2= 1; // 1-y
+ }
+ else
+ {
+ ASSERT(VB.IsSame(V1));
+ a1= 0; b1=-1; c1= 1; // 1-y
+ a2=-1; b2= 0; c2= 1; // 1-x
+ }
+ if (VA.IsSame(V3))
+ if (VB.IsSame(V0))
+ {
+ a1= 0; b1= 1; c1= 0; // y
+ a2=-1; b2= 0; c2= 1; // 1-x
+ }
+ else
+ {
+ ASSERT(VB.IsSame(V2));
+ a1= 1; b1= 0; c1= 0; // x
+ a2= 0; b2=-1; c2= 1; // 1-y
+ }
+ MESSAGE("X = "<<c1<<"+ "<<a1<<"*x + "<<b1<<"*y");
+ MESSAGE("Y = "<<c2<<"+ "<<a2<<"*x + "<<b2<<"*y");
+ conv.a1=a1; conv.b1=b1; conv.c1=c1;
+ conv.a2=a2; conv.b2=b2; conv.c2=c2;
+
+ int nbdown = quad.nbPts[0];
+ int nbright = quad.nbPts[1];
+ conv.ia = int(a1);
+ conv.ib = int(b1);
+ conv.ic = int(c1*a1*a1)*(nbdown-1) + int(c1*b1*b1)*(nbright-1);
+ conv.ja = int(a2);
+ conv.jb = int(b2);
+ conv.jc = int(c2*a2*a2)*(nbdown-1) + int(c2*b2*b2)*(nbright-1);
+ MESSAGE("I "<<conv.ia<<" "<<conv.ib<<" "<<conv.ic);
+ MESSAGE("J "<<conv.ja<<" "<<conv.jb<<" "<<conv.jc);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_Hexa_3D::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_Hexa_3D::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & operator << (ostream & save, SMESH_Hexa_3D & hyp)
+{
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & operator >> (istream & load, SMESH_Hexa_3D & hyp)
+{
+ return load;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Hexa_3D.hxx
+// Created : sam mai 18 23:15:26 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_HEXA_3D_HXX_
+#define _SMESH_HEXA_3D_HXX_
+
+#include "SMESH_3D_Algo.hxx"
+#include "SMESH_Mesh.hxx"
+#include "SMESH_Quadrangle_2D.hxx"
+#include "Utils_SALOME_Exception.hxx"
+
+typedef struct point3Dstruct
+{
+ int nodeId;
+} Point3DStruct;
+
+typedef double Pt3[3];
+
+typedef struct conv2dstruct
+{
+ double a1; // X = a1*x + b1*y + c1
+ double b1; // Y = a2*x + b2*y + c2
+ double c1; // a1, b1 a2, b2 in {-1,0,1}
+ double a2; // c1, c2 in {0,1}
+ double b2;
+ double c2;
+ int ia; // I = ia*i + ib*j + ic
+ int ib;
+ int ic;
+ int ja; // J = ja*i + jb*j + jc
+ int jb;
+ int jc;
+} Conv2DStruct;
+
+typedef struct cubeStruct
+{
+ TopoDS_Vertex V000;
+ TopoDS_Vertex V001;
+ TopoDS_Vertex V010;
+ TopoDS_Vertex V011;
+ TopoDS_Vertex V100;
+ TopoDS_Vertex V101;
+ TopoDS_Vertex V110;
+ TopoDS_Vertex V111;
+ faceQuadStruct* quad_X0;
+ faceQuadStruct* quad_X1;
+ faceQuadStruct* quad_Y0;
+ faceQuadStruct* quad_Y1;
+ faceQuadStruct* quad_Z0;
+ faceQuadStruct* quad_Z1;
+ Point3DStruct* np; // normalised 3D coordinates
+} CubeStruct;
+
+class SMESH_Hexa_3D:
+ public SMESH_3D_Algo
+{
+public:
+ SMESH_Hexa_3D(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_Hexa_3D();
+
+ virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ virtual bool Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+ throw (SALOME_Exception);
+
+ ostream & SaveTo(ostream & save);
+ istream & LoadFrom(istream & load);
+ friend ostream & operator << (ostream & save, SMESH_Hexa_3D & hyp);
+ friend istream & operator >> (istream & load, SMESH_Hexa_3D & hyp);
+
+protected:
+ TopoDS_Edge
+ EdgeNotInFace(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ const TopoDS_Face& aFace,
+ const TopoDS_Vertex& aVertex,
+ const TopTools_IndexedDataMapOfShapeListOfShape& MS);
+
+ int GetFaceIndex(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ const vector<SMESH_subMesh*>& meshFaces,
+ const TopoDS_Vertex& V0,
+ const TopoDS_Vertex& V1,
+ const TopoDS_Vertex& V2,
+ const TopoDS_Vertex& V3);
+
+ void GetConv2DCoefs(const faceQuadStruct& quad,
+ const TopoDS_Shape& aShape,
+ const TopoDS_Vertex& V0,
+ const TopoDS_Vertex& V1,
+ const TopoDS_Vertex& V2,
+ const TopoDS_Vertex& V3,
+ Conv2DStruct& conv);
+
+ void GetPoint(Pt3 p,
+ int i, int j, int k,
+ int nbx, int nby, int nbz,
+ Point3DStruct *np,
+ const Handle(SMESHDS_Mesh)& meshDS);
+
+ CubeStruct _cube;
+ FaceQuadStruct* _quads[6];
+ int _indX0;
+ int _indX1;
+ int _indY0;
+ int _indY1;
+ int _indZ0;
+ int _indZ1;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Hypothesis.cxx
+// Created : sam mai 18 08:08:50 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Hypothesis.hxx"
+#include "SMESH_Gen.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hypothesis::SMESH_Hypothesis(int hypId,
+ int studyId,
+ SMESH_Gen* gen) : SMESHDS_Hypothesis(hypId)
+{
+ //MESSAGE("SMESH_Hypothesis::SMESH_Hypothesis");
+ _gen = gen;
+ _studyId = studyId;
+ StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
+ myStudyContext->mapHypothesis[_hypId] = this;
+ _type = PARAM_ALGO;
+// _shapeType = -1; // to be set by algo with TopAbs_Enum
+ _shapeType = 0; // to be set by algo with TopAbs_Enum
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hypothesis::~SMESH_Hypothesis()
+{
+ MESSAGE("SMESH_Hypothesis::~SMESH_Hypothesis");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_Hypothesis::GetDim()
+{
+ int dim = -1;
+ switch (_type)
+ {
+ case ALGO_1D: dim = 1; break;
+ case ALGO_2D: dim = 2; break;
+ case ALGO_3D: dim = 3; break;
+ }
+ return dim;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_Hypothesis::GetShapeType()
+{
+ return _shapeType;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_Hypothesis::GetStudyId()
+{
+ return _studyId;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
+{
+ MESSAGE("SMESH_Hypothesis::NotifySubMeshesHypothesisModification");
+
+ // for all meshes in study
+
+ StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
+ map<int, SMESH_Mesh*>::iterator itm;
+ for (itm = myStudyContext->mapMesh.begin();
+ itm != myStudyContext->mapMesh.end();
+ itm++)
+ {
+ SMESH_Mesh* mesh = (*itm).second;
+ const list<SMESH_subMesh*>& subMeshes =
+ mesh->GetSubMeshUsingHypothesis(this);
+
+ //for all subMeshes using hypothesis
+
+ list<SMESH_subMesh*>::const_iterator its;
+ for (its = subMeshes.begin(); its != subMeshes.end(); its++)
+ (*its)->ComputeStateEngine(SMESH_subMesh::MODIF_HYP);
+ }
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_Hypothesis.hxx
+// Created : sam mai 18 08:07:54 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_HYPOTHESIS_HXX_
+#define _SMESH_HYPOTHESIS_HXX_
+
+#include "SMESHDS_Hypothesis.hxx"
+
+class SMESH_Gen;
+
+class SMESH_Hypothesis: public SMESHDS_Hypothesis
+{
+public:
+ SMESH_Hypothesis(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_Hypothesis();
+ int GetDim();
+ int GetStudyId();
+ void NotifySubMeshesHypothesisModification();
+ int GetShapeType();
+
+protected:
+ SMESH_Gen* _gen;
+ int _studyId;
+ int _shapeType;
+};
+
+#endif
--- /dev/null
+//=============================================================================
+// File : SMESH_HypothesisCreator.hxx
+// Created : lun mai 27 15:28:35 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_HYPOTHESISCREATOR_HXX_
+#define _SMESH_HYPOTHESISCREATOR_HXX_
+
+#include "SMESH_HypothesisFactory.hxx"
+
+class SMESH_gen;
+
+//=============================================================================
+/*!
+ * Specific Hypothesis Creators are generated with a template which inherits a
+ * generic hypothesis creator. Each creator returns an hypothesis of the type
+ * given in the template.
+ */
+//=============================================================================
+
+template <class T> class SMESH_HypothesisCreator
+ : public GenericHypothesisCreator
+{
+public:
+// map<int, T*> _instances;
+
+// virtual T* GetInstance(int hypId)
+// {
+// if (_instances.find(hypId) != _instances.end())
+// return _instances[hypId];
+// else
+// return NULL;
+// }
+
+ virtual T* Create (int hypId, int studyId, SMESH_Gen* gen)
+ {
+ T* anInstance= new T(hypId, studyId, gen);
+// _gen->StoreHypothesisInstance(anInstance);
+// _instances[hypId] = anInstance;
+ return anInstance;
+ };
+};
+
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_HypothesisFactory.cxx
+// Created : mer mai 15 13:45:50 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_HypothesisFactory.hxx"
+#include "SMESH_Hypothesis.hxx"
+#include "SMESH_HypothesisCreator.hxx"
+#include "SMESH_Gen.hxx"
+
+#include "utilities.h"
+
+// Add new hypothesis here (include file)
+//---------------------------------------
+#include "SMESH_LocalLength.hxx"
+#include "SMESH_LengthFromEdges.hxx"
+#include "SMESH_NumberOfSegments.hxx"
+#include "SMESH_MaxElementArea.hxx"
+#include "SMESH_Regular_1D.hxx"
+#include "SMESH_MEFISTO_2D.hxx"
+#include "SMESH_Quadrangle_2D.hxx"
+#include "SMESH_Hexa_3D.hxx"
+
+//---------------------------------------
+
+//=============================================================================
+/*!
+ * Specific Hypothesis Creators are generated with a template which inherits a
+ * generic hypothesis creator. Each creator returns an hypothesis of the type
+ * given in the template.
+ */
+//=============================================================================
+
+// template <class T> class HypothesisCreator: public GenericHypothesisCreator
+// {
+// public:
+// virtual T* Create (int hypId)
+// {
+// // return new T(hypId);
+// };
+
+// };
+
+//=============================================================================
+/*!
+ * Constructor: instanciate specific hypothesis creators, fill a private map
+ * indexed by hypothesis names. THIS METHOD MUST BE COMPLETED WHEN A NEW
+ * HYPOTHESIS IS ADDED.
+ * Specific hypothesis creator are defined with the above template.
+ * Hypothesis names are related to the corresponding class names:
+ * prefix = SMESH_ ; suffix = .
+ */
+//=============================================================================
+
+SMESH_HypothesisFactory::SMESH_HypothesisFactory()
+{
+ _hypId = 0;
+
+// Add new hypothesis here (creators)
+//---------------------------------------
+_creatorMap["LocalLength"] = new SMESH_HypothesisCreator<SMESH_LocalLength>;
+_creatorMap["NumberOfSegments"] = new SMESH_HypothesisCreator<SMESH_NumberOfSegments>;
+_creatorMap["LengthFromEdges"] = new SMESH_HypothesisCreator<SMESH_LengthFromEdges>;
+_creatorMap["MaxElementArea"] = new SMESH_HypothesisCreator<SMESH_MaxElementArea>;
+_creatorMap["Regular_1D"] = new SMESH_HypothesisCreator<SMESH_Regular_1D>;
+_creatorMap["MEFISTO_2D"] = new SMESH_HypothesisCreator<SMESH_MEFISTO_2D>;
+_creatorMap["Quadrangle_2D"] = new SMESH_HypothesisCreator<SMESH_Quadrangle_2D>;
+_creatorMap["Hexa_3D"] = new SMESH_HypothesisCreator<SMESH_Hexa_3D>;
+
+//---------------------------------------
+}
+
+//=============================================================================
+/*!
+ * Destructor: deletes specific hypothesis creators instanciated in the
+ * constructor.
+ */
+//=============================================================================
+
+SMESH_HypothesisFactory::~SMESH_HypothesisFactory()
+{
+ map<string, GenericHypothesisCreator*>::iterator it;
+ for (it = _creatorMap.begin(); it != _creatorMap.end(); it++)
+ {
+ delete (*it).second;
+ }
+ _creatorMap.clear();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hypothesis* SMESH_HypothesisFactory::Create(const char* anHypName,
+ int studyId)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_HypothesisFactory::Create " << anHypName);
+ if (_creatorMap.find(anHypName) == _creatorMap.end())
+ throw(SALOME_Exception(LOCALIZED("bad hypothesis type name")));
+ SMESH_Hypothesis* myHyp = _creatorMap[anHypName]->Create(_hypId++,
+ studyId,
+ _gen);
+ return myHyp;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+GenericHypothesisCreator*
+SMESH_HypothesisFactory::GetCreator(const char* anHypName)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_HypothesisFactory::GetCreator " << anHypName);
+ if (_creatorMap.find(anHypName) == _creatorMap.end())
+ throw(SALOME_Exception(LOCALIZED("bad hypothesis type name")));
+ return _creatorMap[anHypName];
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_HypothesisFactory::GetANewId()
+{
+ //MESSAGE("SMESH_HypothesisFactory::GetANewId");
+ return _hypId++;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_HypothesisFactory::SetGen(SMESH_Gen* gen)
+{
+ //MESSAGE("SMESH_HypothesisFactory::SetGen");
+ _gen = gen;
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_HypothesisFactory.hxx
+// Created : mer mai 15 13:45:47 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_HYPOTHESISFACTORY_HXX_
+#define _SMESH_HYPOTHESISFACTORY_HXX_
+
+#include "SMESH_Hypothesis.hxx"
+
+#include "Utils_SALOME_Exception.hxx"
+
+#include <map>
+
+class SMESH_Gen;
+
+class GenericHypothesisCreator
+{
+public:
+// virtual SMESH_Hypothesis* GetInstance(int hypId) = 0;
+ virtual SMESH_Hypothesis* Create(int hypId, int studyId, SMESH_Gen* gen) = 0;
+};
+
+class SMESH_HypothesisFactory
+{
+public:
+ SMESH_HypothesisFactory();
+ virtual ~SMESH_HypothesisFactory();
+
+ void SetGen(SMESH_Gen* gen);
+
+ SMESH_Hypothesis* Create(const char* anHypName, int studyId)
+ throw (SALOME_Exception);
+
+ GenericHypothesisCreator* GetCreator(const char* anHypName)
+ throw (SALOME_Exception);
+
+ int GetANewId();
+
+private:
+ map<string, GenericHypothesisCreator*> _creatorMap;
+ int _hypId;
+ SMESH_Gen* _gen;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_LengthFromEdges.cxx
+// Created : mar jun 11 22:42:30 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_LengthFromEdges.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_LengthFromEdges::SMESH_LengthFromEdges(int hypId, int studyId, SMESH_Gen* gen)
+ : SMESH_Hypothesis(hypId, studyId, gen)
+{
+ _mode =1;
+ _name = "LengthFromEdges";
+// SCRUTE(_name);
+// SCRUTE(&_name);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_LengthFromEdges::~SMESH_LengthFromEdges()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_LengthFromEdges::SetMode(int mode)
+ throw (SALOME_Exception)
+{
+ int oldMode = _mode;
+ if (mode <= 0)
+ throw SALOME_Exception(LOCALIZED("mode must be positive"));
+ _mode = mode;
+ if (oldMode != _mode)
+ NotifySubMeshesHypothesisModification();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_LengthFromEdges::GetMode()
+{
+ return _mode;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_LengthFromEdges::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_LengthFromEdges::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & operator << (ostream & save, SMESH_LengthFromEdges & hyp)
+{
+ save << hyp._mode;
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & operator >> (istream & load, SMESH_LengthFromEdges & hyp)
+{
+ bool isOK = true;
+ int a;
+ isOK = (load >> a);
+ if (isOK) hyp._mode = a;
+ else load.clear(ios::badbit | load.rdstate());
+ return load;
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_LengthFromEdges.hxx
+// Created : mar jun 11 22:42:20 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_LENGTHFROMEDGES_HXX_
+#define _SMESH_LENGTHFROMEDGES_HXX_
+
+#include "SMESH_Hypothesis.hxx"
+#include "Utils_SALOME_Exception.hxx"
+
+class SMESH_LengthFromEdges:
+ public SMESH_Hypothesis
+{
+public:
+ SMESH_LengthFromEdges(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_LengthFromEdges();
+
+ void SetMode(int mode)
+ throw (SALOME_Exception);
+
+ int GetMode();
+
+ virtual ostream & SaveTo(ostream & save);
+ virtual istream & LoadFrom(istream & load);
+ friend ostream & operator << (ostream & save, SMESH_LengthFromEdges & hyp);
+ friend istream & operator >> (istream & load, SMESH_LengthFromEdges & hyp);
+
+protected:
+ int _mode;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_LocalLength.cxx
+// Created : sam mai 18 08:10:23 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_LocalLength.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_LocalLength::SMESH_LocalLength(int hypId, int studyId, SMESH_Gen* gen)
+ : SMESH_Hypothesis(hypId, studyId, gen)
+{
+ _length =1.;
+ _name = "LocalLength";
+// SCRUTE(_name);
+// SCRUTE(&_name);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_LocalLength::~SMESH_LocalLength()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_LocalLength::SetLength(double length)
+ throw (SALOME_Exception)
+{
+ double oldLength = _length;
+ if (length <= 0)
+ throw SALOME_Exception(LOCALIZED("length must be positive"));
+ _length = length;
+ if (oldLength != _length)
+ NotifySubMeshesHypothesisModification();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+double SMESH_LocalLength::GetLength()
+{
+ return _length;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_LocalLength::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_LocalLength::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & operator << (ostream & save, SMESH_LocalLength & hyp)
+{
+ save << hyp._length;
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & operator >> (istream & load, SMESH_LocalLength & hyp)
+{
+ bool isOK = true;
+ double a;
+ isOK = (load >> a);
+ if (isOK) hyp._length = a;
+ else load.clear(ios::badbit | load.rdstate());
+ return load;
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_LocalLength.hxx
+// Created : sam mai 18 08:10:19 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_LOCALLENGTH_HXX_
+#define _SMESH_LOCALLENGTH_HXX_
+
+#include "SMESH_Hypothesis.hxx"
+#include "Utils_SALOME_Exception.hxx"
+
+class SMESH_LocalLength:
+ public SMESH_Hypothesis
+{
+public:
+ SMESH_LocalLength(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_LocalLength();
+
+ void SetLength(double length)
+ throw (SALOME_Exception);
+
+ double GetLength();
+
+ virtual ostream & SaveTo(ostream & save);
+ virtual istream & LoadFrom(istream & load);
+ friend ostream & operator << (ostream & save, SMESH_LocalLength & hyp);
+ friend istream & operator >> (istream & load, SMESH_LocalLength & hyp);
+
+protected:
+ double _length;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_MEFISTO_2D.cxx
+// Created : sam mai 18 08:10:55 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_MEFISTO_2D.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include "SMESH_MaxElementArea.hxx"
+#include "SMESH_LengthFromEdges.hxx"
+
+#include "Rn.h"
+#include "aptrte.h"
+
+#include "SMESHDS_ListOfPtrHypothesis.hxx"
+#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_EdgePosition.hxx"
+#include "SMDS_FacePosition.hxx"
+
+#include "utilities.h"
+
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <Geom_Surface.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom2d_Curve.hxx>
+#include <gp_Pnt2d.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GCPnts_UniformAbscissa.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+#include <string>
+#include <algorithm>
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen)
+ : SMESH_2D_Algo(hypId, studyId, gen)
+{
+ MESSAGE("SMESH_MEFISTO_2D::SMESH_MEFISTO_2D");
+ _name = "MEFISTO_2D";
+// _shapeType = TopAbs_FACE;
+ _shapeType = (1<<TopAbs_FACE);
+ _compatibleHypothesis.push_back("MaxElementArea");
+ _compatibleHypothesis.push_back("LengthFromEdges");
+
+ _edgeLength = 0;
+ _maxElementArea = 0;
+ _hypMaxElementArea = NULL;
+ _hypLengthFromEdges = NULL;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D()
+{
+ MESSAGE("SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ //MESSAGE("SMESH_MEFISTO_2D::CheckHypothesis");
+
+ _hypMaxElementArea = NULL;
+ _hypLengthFromEdges = NULL;
+
+ list<SMESHDS_Hypothesis*>::const_iterator itl;
+ SMESHDS_Hypothesis* theHyp;
+
+ const list<SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
+ int nbHyp = hyps.size();
+ if (nbHyp != 1) return false; // only one compatible hypothesis allowed
+
+ itl = hyps.begin();
+ theHyp = (*itl);
+
+ string hypName = theHyp->GetName();
+ int hypId = theHyp->GetID();
+ //SCRUTE(hypName);
+
+ bool isOk = false;
+
+ if (hypName == "MaxElementArea")
+ {
+ _hypMaxElementArea = dynamic_cast<SMESH_MaxElementArea*> (theHyp);
+ ASSERT(_hypMaxElementArea);
+ _maxElementArea = _hypMaxElementArea->GetMaxArea();
+ _edgeLength = 0;
+ isOk =true;
+ }
+
+ if (hypName == "LengthFromEdges")
+ {
+ _hypLengthFromEdges = dynamic_cast<SMESH_LengthFromEdges*> (theHyp);
+ ASSERT(_hypLengthFromEdges);
+ _edgeLength = 0;
+ _maxElementArea = 0;
+ isOk =true;
+ }
+
+
+ if (isOk)
+ {
+ isOk = false;
+ if (_maxElementArea > 0)
+ {
+ _edgeLength = 2*sqrt(_maxElementArea); // triangles : minorant
+ isOk = true;
+ }
+ else isOk = (_hypLengthFromEdges != NULL); // **** check mode
+ }
+
+ //SCRUTE(_edgeLength);
+ //SCRUTE(_maxElementArea);
+ return isOk;
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ MESSAGE("SMESH_MEFISTO_2D::Compute");
+
+ if (_hypLengthFromEdges)
+ _edgeLength = ComputeEdgeElementLength(aMesh, aShape);
+
+ bool isOk = false;
+ const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
+ SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
+
+ const TopoDS_Face& FF = TopoDS::Face(aShape);
+ bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
+ TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+
+ Z nblf; //nombre de lignes fermees (enveloppe en tete)
+ Z *nudslf=NULL; //numero du dernier sommet de chaque ligne fermee
+ R2 *uvslf=NULL;
+ Z nbpti=0; //nombre points internes futurs sommets de la triangulation
+ R2 *uvpti=NULL;
+
+ Z nbst;
+ R2 *uvst=NULL;
+ Z nbt;
+ Z *nust=NULL;
+ Z ierr=0;
+
+ Z nutysu=1; // 1: il existe un fonction areteideale_()
+ // Z nutysu=0; // 0: on utilise aretmx
+ R aretmx=_edgeLength; // longueur max aretes future triangulation
+ //SCRUTE(aretmx);
+
+ nblf = NumberOfWires(F);
+ //SCRUTE(nblf);
+
+ nudslf = new Z[1+nblf];
+ nudslf[0] = 0;
+ int iw = 1;
+ int nbpnt = 0;
+
+ const TopoDS_Wire OW1 = BRepTools::OuterWire(F);
+ nbpnt += NumberOfPoints (aMesh, OW1);
+ nudslf [iw++] = nbpnt;
+ //SCRUTE(nbpnt);
+
+ for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next())
+ {
+ const TopoDS_Wire& W = TopoDS::Wire(exp.Current());
+ if (!OW1.IsSame(W))
+ {
+ nbpnt += NumberOfPoints (aMesh, W);
+ nudslf [iw++] = nbpnt;
+ //SCRUTE(nbpnt);
+ }
+ }
+
+ uvslf = new R2[nudslf[nblf]];
+ //SCRUTE(nudslf[nblf]);
+ int m = 0;
+
+ map<int,int> mefistoToDS; // correspondence mefisto index--> points IDNodes
+ TopoDS_Wire OW = BRepTools::OuterWire(F);
+ LoadPoints (aMesh, F, OW, uvslf, m, mefistoToDS);
+ //SCRUTE(m);
+
+ for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next())
+ {
+ const TopoDS_Wire& W = TopoDS::Wire(exp.Current());
+ if (!OW.IsSame(W))
+ {
+ LoadPoints (aMesh, F, W, uvslf, m, mefistoToDS);
+ //SCRUTE(m);
+ }
+ }
+// SCRUTE(nudslf[nblf]);
+// for (int i=0; i<=nblf; i++)
+// {
+// MESSAGE(" -+- " <<i<< " "<< nudslf[i]);
+// }
+// for (int i=0; i<nudslf[nblf]; i++)
+// {
+// MESSAGE(" -+- " <<i<< " "<< uvslf[i]);
+// }
+// SCRUTE(nutysu);
+// SCRUTE(aretmx);
+// SCRUTE(nblf);
+
+ MESSAGE("MEFISTO triangulation ...");
+ uvst = NULL;
+ nust = NULL;
+ aptrte( nutysu, aretmx,
+ nblf, nudslf, uvslf,
+ nbpti, uvpti,
+ nbst, uvst, nbt, nust,
+ ierr );
+
+ if( ierr == 0 )
+ {
+ MESSAGE("... End Triangulation");
+ //SCRUTE(nbst);
+ //SCRUTE(nbt);
+ StoreResult (aMesh, nbst, uvst, nbt, nust, F,
+ faceIsForward, mefistoToDS);
+ isOk = true;
+ }
+ else
+ {
+ MESSAGE("Error in Triangulation");
+ isOk = false;
+ }
+ if (nudslf != NULL) delete [] nudslf;
+ if (uvslf != NULL) delete [] uvslf;
+ if (uvst != NULL) delete [] uvst;
+ if (nust != NULL) delete [] nust;
+ return isOk;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
+ const TopoDS_Face& FF,
+ const TopoDS_Wire& WW,
+ R2* uvslf,
+ int& m,
+ map<int,int>& mefistoToDS)
+{
+ MESSAGE("SMESH_MEFISTO_2D::LoadPoints");
+
+ Handle (SMDS_Mesh) meshDS = aMesh.GetMeshDS();
+
+ double scalex;
+ double scaley;
+ TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+ ComputeScaleOnFace(aMesh, F, scalex, scaley);
+
+ TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
+ BRepTools_WireExplorer wexp(W,F);
+ for (wexp.Init(W,F);wexp.More(); wexp.Next())
+ {
+ const TopoDS_Edge& E = wexp.Current();
+
+ // --- IDNodes of first and last Vertex
+
+ TopoDS_Vertex VFirst, VLast;
+ TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
+
+ ASSERT(!VFirst.IsNull());
+ SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst);
+ const TColStd_ListOfInteger& lidf
+ = firstSubMesh->GetSubMeshDS()->GetIDNodes();
+ int idFirst= lidf.First();
+// SCRUTE(idFirst);
+
+ ASSERT(!VLast.IsNull());
+ SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast);
+ const TColStd_ListOfInteger& lidl
+ = lastSubMesh->GetSubMeshDS()->GetIDNodes();
+ int idLast= lidl.First();
+// SCRUTE(idLast);
+
+ // --- edge internal IDNodes (relies on good order storage, not checked)
+
+ int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+ //SCRUTE(nbPoints);
+
+ Standard_Real f,l;
+ Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
+
+ const TColStd_ListOfInteger& indElt
+ = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
+ TColStd_ListIteratorOfListOfInteger ite(indElt);
+ //SCRUTE(nbPoints);
+ //SCRUTE(indElt.Extent());
+ ASSERT(nbPoints == indElt.Extent());
+ bool isForward = (E.Orientation() == TopAbs_FORWARD);
+ map<double,int> params;
+ for (; ite.More(); ite.Next())
+ {
+ int nodeId = ite.Value();
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ Handle (SMDS_EdgePosition) epos
+ = Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
+ double param = epos->GetUParameter();
+ params[param] = nodeId;
+// MESSAGE(" " << param << " " << params[param]);
+ }
+
+ // --- load 2D values into MEFISTO structure,
+ // add IDNodes in mefistoToDS map
+
+ if (E.Orientation() == TopAbs_FORWARD)
+ {
+ gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
+ uvslf [m].x = scalex * p.X();
+ uvslf [m].y = scaley * p.Y();
+ mefistoToDS[m+1] = idFirst;
+ //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+ //MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+ m++;
+ map<double,int>::iterator itp = params.begin();
+ for (Standard_Integer i = 1; i<=nbPoints; i++) // nbPoints internal
+ {
+ double param = (*itp).first;
+ gp_Pnt2d p = C2d->Value(param);
+ uvslf [m].x = scalex * p.X();
+ uvslf [m].y = scaley * p.Y();
+ mefistoToDS[m+1] = (*itp).second;
+// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+ m++;
+ itp++;
+ }
+ }
+ else
+ {
+ gp_Pnt2d p = C2d->Value(l); // last point = Vertex Reversed
+ uvslf [m].x = scalex * p.X();
+ uvslf [m].y = scaley * p.Y();
+ mefistoToDS[m+1] = idLast;
+// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+// MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+ m++;
+ map<double,int>::reverse_iterator itp = params.rbegin();
+ for (Standard_Integer i = nbPoints ; i >= 1; i--)
+ {
+ double param = (*itp).first;
+ gp_Pnt2d p = C2d->Value(param);
+ uvslf [m].x = scalex * p.X();
+ uvslf [m].y = scaley * p.Y();
+ mefistoToDS[m+1] = (*itp).second;
+// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+ m++;
+ itp++;
+ }
+ }
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+// **** a mettre dans SMESH_Algo ou SMESH_2D_Algo
+
+void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
+ const TopoDS_Face& aFace,
+ double& scalex,
+ double& scaley)
+{
+ //MESSAGE("SMESH_MEFISTO_2D::ComputeScaleOnFace");
+ TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD));
+ TopoDS_Wire W = BRepTools::OuterWire(F);
+
+ BRepTools_WireExplorer wexp(W,F);
+
+ double xmin = 1.e300; // min & max of face 2D parametric coord.
+ double xmax = -1.e300;
+ double ymin = 1.e300;
+ double ymax = -1.e300;
+ int nbp = 50;
+ scalex = 1;
+ scaley = 1;
+ for (wexp.Init(W,F);wexp.More(); wexp.Next())
+ {
+ const TopoDS_Edge& E = wexp.Current();
+ double f,l;
+ Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
+ for (int i = 0; i<= nbp; i++)
+ {
+ double param = f + (double(i)/double(nbp))*(l-f);
+ gp_Pnt2d p = C2d->Value(param);
+ if (p.X() < xmin) xmin = p.X();
+ if (p.X() > xmax) xmax = p.X();
+ if (p.Y() < ymin) ymin = p.Y();
+ if (p.Y() > ymax) ymax = p.Y();
+// MESSAGE(" "<< f<<" "<<l<<" "<<param<<" "<<xmin<<" "<<xmax<<" "<<ymin<<" "<<ymax);
+ }
+ }
+// SCRUTE(xmin);
+// SCRUTE(xmax);
+// SCRUTE(ymin);
+// SCRUTE(ymax);
+ double xmoy = (xmax + xmin)/2.;
+ double ymoy = (ymax + ymin)/2.;
+
+ Handle(Geom_Surface) S = BRep_Tool::Surface(F); // 3D surface
+
+ double length_x = 0;
+ double length_y = 0;
+ gp_Pnt PX0 = S->Value(xmin, ymoy);
+ gp_Pnt PY0 = S->Value(xmoy, ymin);
+ for (Standard_Integer i = 1; i<= nbp; i++)
+ {
+ double x = xmin + (double(i)/double(nbp))*(xmax-xmin);
+ gp_Pnt PX = S->Value(x,ymoy);
+ double y = ymin + (double(i)/double(nbp))*(ymax-ymin);
+ gp_Pnt PY = S->Value(xmoy,y);
+ length_x += PX.Distance(PX0);
+ length_y += PY.Distance(PY0);
+ PX0.SetCoord(PX.X(),PX.Y(),PX.Z());
+ PY0.SetCoord(PY.X(),PY.Y(),PY.Z());
+ }
+// SCRUTE(length_x);
+// SCRUTE(length_y);
+ scalex = length_x/(xmax - xmin);
+ scaley = length_y/(ymax - ymin);
+// SCRUTE(scalex);
+// SCRUTE(scaley);
+ ASSERT(scalex);
+ ASSERT(scaley);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh,
+ Z nbst, R2* uvst, Z nbt, Z* nust,
+ const TopoDS_Face& F, bool faceIsForward,
+ map<int,int>& mefistoToDS)
+{
+ double scalex;
+ double scaley;
+ ComputeScaleOnFace(aMesh, F, scalex, scaley);
+
+ Handle (SMESHDS_Mesh) meshDS = aMesh.GetMeshDS();
+
+ Z n,m;
+ Handle(Geom_Surface) S = BRep_Tool::Surface(F);
+
+ for ( n=0; n<nbst; n++ )
+ {
+ double u = uvst[n][0]/scalex;
+ double v = uvst[n][1]/scaley;
+ gp_Pnt P = S->Value(u,v);
+
+ if (mefistoToDS.find(n+1) == mefistoToDS.end())
+ {
+ int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ meshDS->SetNodeOnFace(node, F);
+
+ //MESSAGE(nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
+ mefistoToDS[n+1] = nodeId;
+ //MESSAGE(" "<<n<<" "<<mefistoToDS[n+1]);
+ Handle (SMDS_FacePosition) fpos
+ = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
+ fpos->SetUParameter(u);
+ fpos->SetVParameter(v);
+ }
+ }
+
+ m=0;
+ int mt=0;
+
+ //SCRUTE(faceIsForward);
+ for ( n=1; n<=nbt; n++ )
+ {
+ int inode1 = nust[m++];
+ int inode2 = nust[m++];
+ int inode3 = nust[m++];
+
+ int nodeId1 = mefistoToDS[inode1];
+ int nodeId2 = mefistoToDS[inode2];
+ int nodeId3 = mefistoToDS[inode3];
+ //MESSAGE("-- "<<inode1<<" "<<inode2<<" "<<inode3<<" ++ "<<nodeId1<<" "<<nodeId2<<" "<<nodeId3);
+
+ // triangle points must be in trigonometric order if face is Forward
+ // else they must be put clockwise
+
+ bool triangleIsWellOriented = faceIsForward;
+ int faceId;
+ if (triangleIsWellOriented)
+ {
+ faceId = meshDS->AddFace(nodeId1, nodeId2, nodeId3);
+ }
+ else
+ {
+ faceId = meshDS->AddFace(nodeId1, nodeId3, nodeId2);
+ }
+ Handle (SMDS_MeshElement) elt = meshDS->FindElement(faceId);
+ meshDS->SetMeshElementOnShape(elt, F);
+ m++;
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ MESSAGE("SMESH_MEFISTO_2D::ComputeEdgeElementLength");
+ // **** a mettre dans SMESH_2D_Algo ?
+
+ const TopoDS_Face& FF = TopoDS::Face(aShape);
+ bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
+ TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+
+ double meanElementLength = 100;
+ double wireLength =0;
+ int wireElementsNumber =0;
+ for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next())
+ {
+ const TopoDS_Wire& W = TopoDS::Wire(exp.Current());
+ for (TopExp_Explorer expe(W,TopAbs_EDGE); expe.More(); expe.Next())
+ {
+ const TopoDS_Edge& E = TopoDS::Edge(expe.Current());
+ int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+ double length = EdgeLength(E);
+ wireLength += length;
+ wireElementsNumber += nb;
+ }
+ }
+ if (wireElementsNumber)
+ meanElementLength = wireLength/wireElementsNumber;
+ //SCRUTE(meanElementLength);
+ return meanElementLength;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_MEFISTO_2D::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_MEFISTO_2D::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & operator << (ostream & save, SMESH_MEFISTO_2D & hyp)
+{
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & operator >> (istream & load, SMESH_MEFISTO_2D & hyp)
+{
+ return load;
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_MEFISTO_2D.hxx
+// Created : sam mai 18 08:10:50 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_MEFISTO_2D_HXX_
+#define _SMESH_MEFISTO_2D_HXX_
+
+#include "SMESH_2D_Algo.hxx"
+#include "SMESH_MaxElementArea.hxx"
+#include "SMESH_LengthFromEdges.hxx"
+#include "Rn.h"
+
+#include <TopoDS_Face.hxx>
+
+#include <map>
+
+class SMESH_MEFISTO_2D:
+ public SMESH_2D_Algo
+{
+public:
+ SMESH_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_MEFISTO_2D();
+
+ virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ virtual bool Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ double ComputeEdgeElementLength(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ void LoadPoints(SMESH_Mesh& aMesh,
+ const TopoDS_Face& F,
+ const TopoDS_Wire& W,
+ R2* uvslf,
+ int& m,
+ map<int,int>& mefistoToDS);
+
+ void ComputeScaleOnFace(SMESH_Mesh& aMesh,
+ const TopoDS_Face& aFace,
+ double& scalex,
+ double& scaley);
+
+ void StoreResult (SMESH_Mesh& aMesh,
+ Z nbst, R2* uvst, Z nbt, Z* nust,
+ const TopoDS_Face& F, bool faceIsForward,
+ map<int,int>& mefistoToDS);
+
+ ostream & SaveTo(ostream & save);
+ istream & LoadFrom(istream & load);
+ friend ostream & operator << (ostream & save, SMESH_MEFISTO_2D & hyp);
+ friend istream & operator >> (istream & load, SMESH_MEFISTO_2D & hyp);
+
+protected:
+ double _edgeLength;
+ double _maxElementArea;
+ SMESH_MaxElementArea* _hypMaxElementArea;
+ SMESH_LengthFromEdges* _hypLengthFromEdges;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_MaxElementArea.cxx
+// Created : sam mai 18 23:14:08 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_MaxElementArea.hxx"
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_MaxElementArea::SMESH_MaxElementArea(int hypId, int studyId, SMESH_Gen* gen)
+ : SMESH_Hypothesis(hypId, studyId, gen)
+{
+ _maxArea =1.;
+ _name = "MaxElementArea";
+// SCRUTE(_name);
+// SCRUTE(&_name);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_MaxElementArea::~SMESH_MaxElementArea()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_MaxElementArea::SetMaxArea(double maxArea)
+ throw (SALOME_Exception)
+{
+ double oldArea = _maxArea;
+ if (maxArea <= 0)
+ throw SALOME_Exception(LOCALIZED("maxArea must be positive"));
+ _maxArea = maxArea;
+ if (_maxArea != oldArea)
+ NotifySubMeshesHypothesisModification();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+double SMESH_MaxElementArea::GetMaxArea()
+{
+ return _maxArea;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_MaxElementArea::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_MaxElementArea::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & operator << (ostream & save, SMESH_MaxElementArea & hyp)
+{
+ save << hyp._maxArea;
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & operator >> (istream & load, SMESH_MaxElementArea & hyp)
+{
+ bool isOK = true;
+ double a;
+ isOK = (load >> a);
+ if (isOK) hyp._maxArea = a;
+ else load.clear(ios::badbit | load.rdstate());
+ return load;
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_MaxElementArea.hxx
+// Created : sam mai 18 23:14:04 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_MAXELEMENTAREA_HXX_
+#define _SMESH_MAXELEMENTAREA_HXX_
+
+#include "SMESH_Hypothesis.hxx"
+#include "Utils_SALOME_Exception.hxx"
+
+class SMESH_MaxElementArea:
+ public SMESH_Hypothesis
+{
+public:
+ SMESH_MaxElementArea(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_MaxElementArea();
+
+ void SetMaxArea(double maxArea)
+ throw (SALOME_Exception);
+
+ double GetMaxArea();
+
+ virtual ostream & SaveTo(ostream & save);
+ virtual istream & LoadFrom(istream & load);
+ friend ostream & operator << (ostream & save, SMESH_MaxElementArea & hyp);
+ friend istream & operator >> (istream & load, SMESH_MaxElementArea & hyp);
+
+protected:
+ double _maxArea;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_MaxElementVolume.cxx
+// Created : sam mai 18 23:14:45 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
--- /dev/null
+//=============================================================================
+// File : SMESH_MaxElementVolume.hxx
+// Created : sam mai 18 23:14:41 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Mesh.cxx
+// Created : sam mai 18 08:08:43 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Mesh.hxx"
+#include "SMESH_subMesh.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_Hypothesis.hxx"
+#include "SMESHDS_Script.hxx"
+//#include "SMESHDS_ListOfAsciiString.hxx"
+//#include "SMESHDS_ListIteratorOfListOfAsciiString.hxx"
+#include "SMESHDS_ListOfPtrHypothesis.hxx"
+#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshFacesIterator.hxx"
+#include "SMDS_MeshVolumesIterator.hxx"
+#include "TCollection_AsciiString.hxx"
+
+#include "utilities.h"
+
+#include "Mesh_Writer.h"
+#include "DriverMED_W_SMESHDS_Mesh.h"
+#include "DriverDAT_W_SMESHDS_Mesh.h"
+#include "DriverUNV_W_SMESHDS_Mesh.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Mesh::SMESH_Mesh()
+{
+ MESSAGE("SMESH_Mesh::SMESH_Mesh");
+ _id = -1;
+ ASSERT(0);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Mesh::SMESH_Mesh(int localId,
+ int studyId,
+ SMESH_Gen* gen,
+ const Handle(SMESHDS_Document)& myDocument)
+{
+ MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
+ _id = localId;
+ _studyId = studyId;
+ _gen = gen;
+ _myDocument = myDocument;
+ _idDoc = _myDocument->NewMesh();
+ _myMeshDS = _myDocument->GetMesh(_idDoc);
+ _isShapeToMesh = false;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Mesh::~SMESH_Mesh()
+{
+ MESSAGE("SMESH_Mesh::~SMESH_Mesh");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape& aShape)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh::ShapeToMesh");
+ if (_isShapeToMesh)
+ throw SALOME_Exception(LOCALIZED("a shape to mesh as already been defined"));
+ _isShapeToMesh = true;
+ _myMeshDS->ShapeToMesh(aShape);
+
+ // NRI : 24/02/03
+ TopExp::MapShapes(aShape,_subShapes);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape& aSubShape,
+ int anHypId)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh::AddHypothesis");
+
+ StudyContextStruct* sc = _gen->GetStudyContext(_studyId);
+ if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
+ {
+ MESSAGE("Hypothesis ID does not give an hypothesis");
+ SCRUTE(_studyId);
+ SCRUTE(anHypId);
+ throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
+ }
+
+ SMESH_subMesh* subMesh = GetSubMesh(aSubShape);
+ SMESH_Hypothesis* anHyp = sc->mapHypothesis[anHypId];
+ int event;
+
+ // shape
+
+ if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+ event = SMESH_subMesh::ADD_HYP;
+ else
+ event = SMESH_subMesh::ADD_ALGO;
+ int ret = subMesh->AlgoStateEngine(event, anHyp);
+
+ // subShapes (only when shape is mainShape)
+ TopoDS_Shape mainShape = _myMeshDS->ShapeToMesh();
+ if (aSubShape.IsSame(mainShape))
+ {
+ if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+ event = SMESH_subMesh::ADD_FATHER_HYP;
+ else
+ event = SMESH_subMesh::ADD_FATHER_ALGO;
+ subMesh->SubMeshesAlgoStateEngine(event, anHyp);
+ }
+
+ subMesh->DumpAlgoState(true);
+ //SCRUTE(ret);
+ return ret;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape& aSubShape,
+ int anHypId)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh::RemoveHypothesis");
+
+ StudyContextStruct* sc = _gen->GetStudyContext(_studyId);
+ if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
+ throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
+
+ SMESH_subMesh* subMesh = GetSubMesh(aSubShape);
+ SMESH_Hypothesis* anHyp = sc->mapHypothesis[anHypId];
+ int hypType = anHyp->GetType();
+ SCRUTE(hypType);
+ int event;
+
+ // shape
+
+ if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+ event = SMESH_subMesh::REMOVE_HYP;
+ else
+ event = SMESH_subMesh::REMOVE_ALGO;
+ int ret = subMesh->AlgoStateEngine(event, anHyp);
+
+ // subShapes (only when shape is mainShape)
+
+ TopoDS_Shape mainShape = _myMeshDS->ShapeToMesh();
+ if (aSubShape.IsSame(mainShape))
+ {
+ if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+ event = SMESH_subMesh::REMOVE_FATHER_HYP;
+ else
+ event = SMESH_subMesh::REMOVE_FATHER_ALGO;
+ subMesh->SubMeshesAlgoStateEngine(event, anHyp);
+ }
+
+ subMesh->DumpAlgoState(true);
+ SCRUTE(ret);
+ return ret;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+const Handle(SMESHDS_Mesh)& SMESH_Mesh::GetMeshDS()
+{
+ return _myMeshDS;
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+const list<SMESHDS_Hypothesis*>&
+SMESH_Mesh::GetHypothesisList(const TopoDS_Shape& aSubShape)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh::GetHypothesisList");
+ _subShapeHypothesisList.clear();
+ const SMESHDS_ListOfPtrHypothesis& listHyp
+ = _myMeshDS->GetHypothesis(aSubShape);
+ SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp);
+ while (it.More())
+ {
+ SMESHDS_Hypothesis* anHyp = it.Value();
+ _subShapeHypothesisList.push_back(anHyp);
+ it.Next();
+ }
+ return _subShapeHypothesisList;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+const SMESHDS_ListOfCommand& SMESH_Mesh::GetLog()
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh::GetLog");
+ Handle (SMESHDS_Script) scriptDS = _myMeshDS->GetScript();
+ const SMESHDS_ListOfCommand& logDS = scriptDS->GetCommands();
+// SMESHDS_ListIteratorOfListOfCommand its;
+// const SMESHDS_ListOfAsciiString& logDS = scriptDS->GetCommands();
+// SMESHDS_ListIteratorOfListOfAsciiString its;
+// for (its.Initialize(logDS); its.More(); its.Next())
+// {
+// SCRUTE(its.Value().ToCString());
+// }
+ return logDS;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SMESH_Mesh::ClearLog()
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh::ClearLog");
+ Handle (SMESHDS_Script) scriptDS = _myMeshDS->GetScript();
+ scriptDS->Clear();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_Mesh::GetId()
+{
+ MESSAGE("SMESH_Mesh::GetId");
+ return _id;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Gen* SMESH_Mesh::GetGen()
+{
+ return _gen;
+}
+
+//=============================================================================
+/*!
+ * Get or Create the SMESH_subMesh object implementation
+ */
+//=============================================================================
+
+SMESH_subMesh* SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
+ throw (SALOME_Exception)
+{
+ //MESSAGE("SMESH_Mesh::GetSubMesh");
+ SMESH_subMesh* aSubMesh;
+ int index = _subShapes.FindIndex(aSubShape);
+ if ( _mapSubMesh.find(index) != _mapSubMesh.end() ) {
+ aSubMesh = _mapSubMesh[index];
+ } else {
+ aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
+ _mapSubMesh[index] = aSubMesh;
+ }
+
+ /* NRI 24/02/2003
+ int index = -1;
+ if (_subShapes.Contains(aSubShape))
+ {
+ index = _subShapes.FindIndex(aSubShape);
+ ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end());
+ aSubMesh = _mapSubMesh[index];
+ //MESSAGE("found submesh " << index);
+ }
+ else
+ {
+ index = _subShapes.Add(aSubShape);
+ aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
+ _mapSubMesh[index] = aSubMesh;
+ //MESSAGE("created submesh " << index);
+ }
+ */
+ return aSubMesh;
+}
+
+//=============================================================================
+/*!
+ * Get the SMESH_subMesh object implementation. Dont create it, return null
+ * if it does not exist.
+ */
+//=============================================================================
+//
+// * Given a subShape, find if there is a subMesh associated to this subShape
+// * or to a collection of shapes containing this subShape. Collection =
+// * compsolid, shell, wire.
+// *
+// * WARNING : with arg = compsolid, shell or wire returns always NULL.
+// * with a face inside a shell, and submesh created for both, if arg is face,
+// * returns first created submesh of the two.
+// * subMesh is not created, return may be NULL.
+
+SMESH_subMesh* SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
+ throw (SALOME_Exception)
+{
+ //MESSAGE("SMESH_Mesh::GetSubMeshContaining");
+ bool isFound = false;
+ SMESH_subMesh* aSubMesh = NULL;
+
+ int index = _subShapes.FindIndex(aSubShape);
+ if ( _mapSubMesh.find(index) != _mapSubMesh.end() ) {
+ aSubMesh = _mapSubMesh[index];
+ isFound = true;
+ }
+
+ /* NRI 24/02/2003
+ int index = -1;
+ if (_subShapes.Contains(aSubShape))
+ {
+ index = _subShapes.FindIndex(aSubShape);
+ ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end());
+ aSubMesh = _mapSubMesh[index];
+ isFound = true;
+ //MESSAGE("found submesh " << index);
+ }
+ */
+
+// map<int, SMESH_subMesh*>::iterator itsm;
+// for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
+// {
+// aSubMesh = (*itsm).second;
+// isFound = aSubMesh->Contains(aSubShape);
+// if (isFound) break;
+// }
+
+ if (! isFound) aSubMesh = NULL;
+ return aSubMesh;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+const list <SMESH_subMesh*>&
+SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis* anHyp)
+ throw (SALOME_Exception)
+{
+ MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
+ map<int, SMESH_subMesh*>::iterator itsm;
+ _subMeshesUsingHypothesisList.clear();
+ for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
+ {
+ SMESH_subMesh* aSubMesh = (*itsm).second;
+ bool usesHyp = false;
+ SMESH_Algo* algo = _gen->GetAlgo(*this, aSubMesh->GetSubShape());
+ if (algo != NULL)
+ {
+ const list<SMESHDS_Hypothesis*>& usedHyps
+ = algo->GetUsedHypothesis(*this, aSubMesh->GetSubShape());
+ list<SMESHDS_Hypothesis*>::const_iterator itl;
+ for(itl=usedHyps.begin(); itl != usedHyps.end(); itl++)
+ if (anHyp == (*itl))
+ {
+ usesHyp = true;
+ break;
+ }
+ }
+ if (usesHyp) _subMeshesUsingHypothesisList.push_back(aSubMesh);
+ }
+ return _subMeshesUsingHypothesisList;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Mesh::ExportMED( const char* file )
+ throw (SALOME_Exception)
+{
+ Mesh_Writer* myWriter = new DriverMED_W_SMESHDS_Mesh;
+ myWriter->SetFile( string(file) );
+ myWriter->SetMesh( _myMeshDS );
+ MESSAGE ( " _idDoc " << _idDoc )
+ myWriter->SetMeshId( _idDoc );
+ myWriter->Add();
+}
+
+void SMESH_Mesh::ExportDAT( const char* file )
+ throw (SALOME_Exception)
+{
+ Mesh_Writer* myWriter = new DriverDAT_W_SMESHDS_Mesh;
+ myWriter->SetFile( string(file) );
+ myWriter->SetMesh( _myMeshDS );
+ myWriter->SetMeshId( _idDoc );
+ myWriter->Add();
+}
+
+void SMESH_Mesh::ExportUNV( const char* file )
+ throw (SALOME_Exception)
+{
+ Mesh_Writer* myWriter = new DriverUNV_W_SMESHDS_Mesh;
+ myWriter->SetFile( string(file) );
+ myWriter->SetMesh( _myMeshDS );
+ myWriter->SetMeshId( _idDoc );
+ myWriter->Add();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+int SMESH_Mesh::NbNodes()
+ throw (SALOME_Exception)
+{
+ return _myMeshDS->NbNodes();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+int SMESH_Mesh::NbEdges()
+ throw (SALOME_Exception)
+{
+ return _myMeshDS->NbEdges();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+int SMESH_Mesh::NbFaces()
+ throw (SALOME_Exception)
+{
+ return _myMeshDS->NbFaces();
+}
+int SMESH_Mesh::NbTriangles()
+ throw (SALOME_Exception)
+{
+ SMDS_MeshFacesIterator itFaces(_myMeshDS);
+ int Nb = 0;
+ for (;itFaces.More();itFaces.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itFaces.Value();
+
+ switch (elem->NbNodes()) {
+ case 3 : {
+ Nb++;
+ break;
+ }
+ }
+ }
+ return Nb;
+}
+int SMESH_Mesh::NbQuadrangles()
+ throw (SALOME_Exception)
+{
+ SMDS_MeshFacesIterator itFaces(_myMeshDS);
+ int Nb = 0;
+ for (;itFaces.More();itFaces.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itFaces.Value();
+
+ switch (elem->NbNodes()) {
+ case 4 : {
+ Nb++;
+ break;
+ }
+ }
+ }
+ return Nb;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+int SMESH_Mesh::NbVolumes()
+ throw (SALOME_Exception)
+{
+ return _myMeshDS->NbVolumes();
+}
+int SMESH_Mesh::NbTetras()
+ throw (SALOME_Exception)
+{
+ int Nb = 0;
+ SMDS_MeshVolumesIterator itVolumes(_myMeshDS);
+ for (;itVolumes.More();itVolumes.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
+
+ switch (elem->NbNodes()) {
+ case 4 : {
+ Nb++;
+ break;
+ }
+ }
+ }
+ return Nb;
+}
+int SMESH_Mesh::NbHexas()
+ throw (SALOME_Exception)
+{
+ int Nb = 0;
+ SMDS_MeshVolumesIterator itVolumes(_myMeshDS);
+ for (;itVolumes.More();itVolumes.Next()) {
+ const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
+
+ switch (elem->NbNodes()) {
+ case 8 : {
+ Nb++;
+ break;
+ }
+ }
+ }
+ return Nb;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+int SMESH_Mesh::NbSubMesh()
+ throw (SALOME_Exception)
+{
+ return _myMeshDS->NbSubMesh();
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Mesh.hxx
+// Created : sam mai 18 08:07:35 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_MESH_HXX_
+#define _SMESH_MESH_HXX_
+
+#include "SMESHDS_Document.hxx"
+#include "SMESHDS_Mesh.hxx"
+#include "SMESH_Hypothesis.hxx"
+#include "SMESH_subMesh.hxx"
+#include "SMESHDS_ListOfCommand.hxx"
+//#include "SMESHDS_ListOfAsciiString.hxx"
+//#include "SMESHDS_ListIteratorOfListOfAsciiString.hxx"
+
+
+#include "Utils_SALOME_Exception.hxx"
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_CompSolid.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <vector>
+#include <list>
+#include <map>
+
+class SMESH_Gen;
+
+class SMESH_Mesh
+{
+public:
+ SMESH_Mesh();
+ SMESH_Mesh(int localId,
+ int studyId,
+ SMESH_Gen* gen,
+ const Handle(SMESHDS_Document)& myDocument);
+
+ virtual ~SMESH_Mesh();
+
+ void ShapeToMesh(const TopoDS_Shape& aShape)
+ throw (SALOME_Exception);
+
+ bool AddHypothesis(const TopoDS_Shape& aSubShape,
+ int anHypId)
+ throw (SALOME_Exception);
+
+ bool RemoveHypothesis(const TopoDS_Shape& aSubShape,
+ int anHypId)
+ throw (SALOME_Exception);
+
+ const list<SMESHDS_Hypothesis*>&
+ GetHypothesisList(const TopoDS_Shape& aSubShape)
+ throw (SALOME_Exception);
+
+ const SMESHDS_ListOfCommand& GetLog()
+ throw (SALOME_Exception);
+
+// const SMESHDS_ListOfAsciiString& GetLog()
+// throw (SALOME_Exception);
+
+ void ClearLog()
+ throw (SALOME_Exception);
+
+ int GetId();
+
+ const Handle(SMESHDS_Mesh)& GetMeshDS();
+
+ SMESH_Gen* GetGen();
+
+ SMESH_subMesh* GetSubMesh(const TopoDS_Shape & aSubShape)
+ throw (SALOME_Exception);
+
+ SMESH_subMesh* GetSubMeshContaining(const TopoDS_Shape & aSubShape)
+ throw (SALOME_Exception);
+
+ const list <SMESH_subMesh*>&
+ GetSubMeshUsingHypothesis(SMESHDS_Hypothesis* anHyp)
+ throw (SALOME_Exception);
+
+ void ExportDAT( const char* file )
+ throw (SALOME_Exception);
+ void ExportMED( const char* file )
+ throw (SALOME_Exception);
+ void ExportUNV( const char* file )
+ throw (SALOME_Exception);
+
+ int NbNodes()
+ throw (SALOME_Exception);
+
+ int NbEdges()
+ throw (SALOME_Exception);
+
+ int NbFaces()
+ throw (SALOME_Exception);
+
+ int NbTriangles()
+ throw (SALOME_Exception);
+
+ int NbQuadrangles()
+ throw (SALOME_Exception);
+
+ int NbVolumes()
+ throw (SALOME_Exception);
+
+ int NbTetras()
+ throw (SALOME_Exception);
+
+ int NbHexas()
+ throw (SALOME_Exception);
+
+ int NbSubMesh()
+ throw (SALOME_Exception);
+
+
+private:
+
+ int _id; // id given by creator (unique within the creator instance)
+ int _studyId;
+ int _idDoc; // id given by SMESHDS_Document
+ bool _isShapeToMesh; // set to true when a shape is given (only once)
+ list<SMESHDS_Hypothesis*> _subShapeHypothesisList;
+ list<SMESH_subMesh*> _subMeshesUsingHypothesisList;
+ Handle (SMESHDS_Document) _myDocument;
+ Handle (SMESHDS_Mesh) _myMeshDS;
+ TopTools_IndexedMapOfShape _subShapes;
+ map<int, SMESH_subMesh*> _mapSubMesh;
+ SMESH_Gen* _gen;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_NumberOfSegments.cxx
+// Created : sam mai 18 08:11:15 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_NumberOfSegments.hxx"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_NumberOfSegments::SMESH_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen)
+ : SMESH_Hypothesis(hypId, studyId, gen)
+{
+ _numberOfSegments = 1;
+ _name = "NumberOfSegments";
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_NumberOfSegments::~SMESH_NumberOfSegments()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_NumberOfSegments::SetNumberOfSegments(int segmentsNumber)
+ throw (SALOME_Exception)
+{
+ int oldNumberOfSegments = _numberOfSegments;
+ if (segmentsNumber <= 0)
+ throw SALOME_Exception(LOCALIZED("number of segments must be positive"));
+ _numberOfSegments = segmentsNumber;
+
+ if (oldNumberOfSegments != _numberOfSegments)
+ NotifySubMeshesHypothesisModification();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_NumberOfSegments::GetNumberOfSegments()
+{
+ return _numberOfSegments;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_NumberOfSegments::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_NumberOfSegments::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream& operator << (ostream & save, SMESH_NumberOfSegments & hyp)
+{
+ save << hyp._numberOfSegments;
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream& operator >> (istream & load, SMESH_NumberOfSegments & hyp)
+{
+ bool isOK = true;
+ int a;
+ isOK = (load >> a);
+ if (isOK) hyp._numberOfSegments = a;
+ else load.clear(ios::badbit | load.rdstate());
+ return load;
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_NumberOfSegments.hxx
+// Created : sam mai 18 08:11:20 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_NUMBEROFSEGMENTS_HXX_
+#define _SMESH_NUMBEROFSEGMENTS_HXX_
+
+#include "SMESH_Hypothesis.hxx"
+#include "Utils_SALOME_Exception.hxx"
+
+class SMESH_NumberOfSegments:
+ public SMESH_Hypothesis
+{
+public:
+ SMESH_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_NumberOfSegments();
+
+ void SetNumberOfSegments(int segmentsNumber)
+ throw (SALOME_Exception);
+
+ int GetNumberOfSegments();
+
+ virtual ostream & SaveTo(ostream & save);
+ virtual istream & LoadFrom(istream & load);
+ friend ostream& operator << (ostream & save, SMESH_NumberOfSegments & hyp);
+ friend istream& operator >> (istream & load, SMESH_NumberOfSegments & hyp);
+
+protected:
+ int _numberOfSegments;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Quadrangle_2D.cxx
+// Created : sam mai 18 08:11:32 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Quadrangle_2D.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_EdgePosition.hxx"
+#include "SMDS_FacePosition.hxx"
+
+#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Handle_Geom2d_Curve.hxx>
+#include <Handle_Geom_Curve.hxx>
+#include <gp_Pnt2d.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Quadrangle_2D::SMESH_Quadrangle_2D(int hypId,
+ int studyId,
+ SMESH_Gen* gen)
+ : SMESH_2D_Algo(hypId, studyId, gen)
+{
+ MESSAGE("SMESH_Quadrangle_2D::SMESH_Quadrangle_2D");
+ _name = "Quadrangle_2D";
+ // _shapeType = TopAbs_FACE;
+ _shapeType = (1<<TopAbs_FACE);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Quadrangle_2D::~SMESH_Quadrangle_2D()
+{
+ MESSAGE("SMESH_Quadrangle_2D::~SMESH_Quadrangle_2D");
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Quadrangle_2D::CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ //MESSAGE("SMESH_Quadrangle_2D::CheckHypothesis");
+
+ bool isOk = true;
+
+ // nothing to check
+
+ return isOk;
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+ throw (SALOME_Exception)
+{
+ //MESSAGE("SMESH_Quadrangle_2D::Compute");
+ const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
+ SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
+
+ FaceQuadStruct* quad = CheckAnd2Dcompute(aMesh, aShape);
+ if (!quad) return false;
+
+ // --- compute 3D values on points, store points & quadrangles
+
+ int nbdown = quad->nbPts[0];
+ int nbright = quad->nbPts[1];
+ int nbVertices = nbdown*nbright;
+ int nbQuad = (nbdown-1)*(nbright-1);
+ //SCRUTE(nbVertices);
+ //SCRUTE(nbQuad);
+
+ // const TopoDS_Face& FF = TopoDS::Face(aShape);
+ // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
+ // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+ const TopoDS_Face& F = TopoDS::Face(aShape);
+ bool faceIsForward = (F.Orientation() == TopAbs_FORWARD);
+ Handle(Geom_Surface) S = BRep_Tool::Surface(F);
+
+ for (int i=1; i<nbdown-1; i++)
+ for (int j=1; j<nbright-1; j++) // internal points
+ {
+ int ij = j*nbdown +i;
+ double u = quad->uv_grid[ij].u;
+ double v = quad->uv_grid[ij].v;
+ gp_Pnt P = S->Value(u,v);
+ int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ //MESSAGE("point "<< nodeId<<" "<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ meshDS->SetNodeOnFace(node, F);
+ quad->uv_grid[ij].nodeId = nodeId;
+// Handle (SMDS_FacePosition) fpos
+// = new SMDS_FacePosition(theSubMesh->GetId(),i,j); // easier than u,v
+// node->SetPosition(fpos);
+ Handle (SMDS_FacePosition) fpos
+ = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
+ fpos->SetUParameter(i);
+ fpos->SetVParameter(j);
+ }
+
+ // bool isQuadForward = ( faceIsForward == quad->isEdgeForward[0]);
+ for (int i=0; i<nbdown-1; i++)
+ for (int j=0; j<nbright-1; j++) // faces
+ {
+ int a = quad->uv_grid[ j *nbdown +i ].nodeId;
+ int b = quad->uv_grid[ j *nbdown +i+1].nodeId;
+ int c = quad->uv_grid[(j+1)*nbdown +i+1].nodeId;
+ int d = quad->uv_grid[(j+1)*nbdown +i ].nodeId;
+ int faceId;
+ // if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d);
+ // else faceId = meshDS->AddFace(a,d,c,b);
+ faceId = meshDS->AddFace(a,b,c,d);
+ Handle (SMDS_MeshElement) elt = meshDS->FindElement(faceId);
+ meshDS->SetMeshElementOnShape(elt, F);
+ }
+
+ QuadDelete(quad);
+ bool isOk = true;
+ return isOk;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+FaceQuadStruct*
+SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+ throw (SALOME_Exception)
+{
+ //MESSAGE("SMESH_Quadrangle_2D::ComputeWithoutStore");
+
+ SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
+
+ // const TopoDS_Face& FF = TopoDS::Face(aShape);
+ // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
+ // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+ const TopoDS_Face& F = TopoDS::Face(aShape);
+ bool faceIsForward = (F.Orientation() == TopAbs_FORWARD);
+
+ // verify 1 wire only, with 4 edges, same number of points on opposite edges
+
+ if (NumberOfWires (F) != 1)
+ {
+ MESSAGE("only 1 wire by face (quadrangles)");
+ return 0;
+ //throw SALOME_Exception(LOCALIZED("only 1 wire by face (quadrangles)"));
+ }
+ // const TopoDS_Wire WW = BRepTools::OuterWire(F);
+ // TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
+ const TopoDS_Wire& W = BRepTools::OuterWire(F);
+ BRepTools_WireExplorer wexp(W,F);
+
+ FaceQuadStruct* quad = new FaceQuadStruct;
+ for (int i=0; i<4; i++) quad->uv_edges[i] = 0;
+ quad->uv_grid = 0;
+
+ int nbEdges = 0;
+ for (wexp.Init(W,F);wexp.More(); wexp.Next())
+ {
+ // const TopoDS_Edge& EE = wexp.Current();
+ // TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
+ const TopoDS_Edge& E = wexp.Current();
+ int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+ if (nbEdges < 4)
+ {
+ quad->edge[nbEdges] = E;
+ quad->nbPts[nbEdges] = nb +2; // internal points + 2 extrema
+ }
+ nbEdges++;
+ }
+
+ if (nbEdges != 4)
+ {
+ MESSAGE("face must have 4 edges /quadrangles");
+ QuadDelete(quad);
+ return 0;
+ //throw SALOME_Exception(LOCALIZED("face must have 4 edges /quadrangles"));
+ }
+
+ if (quad->nbPts[0] != quad->nbPts[2])
+ {
+ MESSAGE("different point number-opposed edge");
+ QuadDelete(quad);
+ return 0;
+ //throw SALOME_Exception(LOCALIZED("different point number-opposed edge"));
+ }
+
+ if (quad->nbPts[1] != quad->nbPts[3])
+ {
+ MESSAGE("different point number-opposed edge");
+ QuadDelete(quad);
+ return 0;
+ //throw SALOME_Exception(LOCALIZED("different point number-opposed edge"));
+ }
+
+ // set normalized grid on unit square in parametric domain
+
+ SetNormalizedGrid(aMesh, F, quad);
+
+ return quad;
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ void SMESH_Quadrangle_2D::QuadDelete(FaceQuadStruct* quad)
+{
+ //MESSAGE("SMESH_Quadrangle_2D::QuadDelete");
+ if (quad)
+ {
+ for (int i=0; i<4; i++)
+ {
+ if (quad->uv_edges[i]) delete [] quad->uv_edges[i];
+ quad->edge[i].Nullify();
+ }
+ if (quad->uv_grid) delete [] quad->uv_grid;
+ delete quad;
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ FaceQuadStruct* quad)
+ throw (SALOME_Exception)
+{
+ // Algorithme décrit dans "Génération automatique de maillages"
+ // P.L. GEORGE, MASSON, § 6.4.1 p. 84-85
+ // traitement dans le domaine paramétrique 2d u,v
+ // transport - projection sur le carré unité
+
+ const TopoDS_Face& F = TopoDS::Face(aShape);
+
+ // 1 --- find orientation of the 4 edges, by test on extrema
+
+ // max min 0 x1 1
+ // |<----north-2-------^ a3 -------------> a2
+ // | | ^1 1^
+ // west-3 east-1 =right | |
+ // | | ==> | |
+ // y0 | | y1 | |
+ // | | |0 0|
+ // v----south-0--------> a0 -------------> a1
+ // min max 0 x0 1
+ // =down
+ //
+
+ Handle (Geom2d_Curve) c2d[4];
+ gp_Pnt2d pf[4];
+ gp_Pnt2d pl[4];
+ for (int i=0; i<4; i++)
+ {
+ c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i],
+ F,
+ quad->first[i],
+ quad->last[i]);
+ pf[i] = c2d[i]->Value(quad->first[i]);
+ pl[i] = c2d[i]->Value(quad->last[i]);
+ quad->isEdgeForward[i] = false;
+ }
+
+ double eps2d = 1.e-3; // *** utiliser plutot TopExp::CommonVertex, puis
+ // distances si piece fausse
+ int i=0;
+ if ((pf[1].Distance(pl[0]) < eps2d) || (pl[1].Distance(pl[0]) < eps2d))
+ {
+ quad->isEdgeForward[0] = true;
+ }
+ else
+ {
+ double tmp =quad->first[0];
+ quad->first[0] = quad->last[0];
+ quad->last[0] = tmp;
+ pf[0] = c2d[0]->Value(quad->first[0]);
+ pl[0] = c2d[0]->Value(quad->last[0]);
+ }
+ for (int i=1; i<4; i++)
+ {
+ quad->isEdgeForward[i] = (pf[i].Distance(pl[i-1]) < eps2d);
+ if (! quad->isEdgeForward[i])
+ {
+ double tmp =quad->first[i];
+ quad->first[i] = quad->last[i];
+ quad->last[i] = tmp;
+ pf[i] = c2d[i]->Value(quad->first[i]);
+ pl[i] = c2d[i]->Value(quad->last[i]);
+ //SCRUTE(pf[i].Distance(pl[i-1]));
+ ASSERT(pf[i].Distance(pl[i-1]) < eps2d);
+ }
+ }
+ //SCRUTE(pf[0].Distance(pl[3]));
+ ASSERT(pf[0].Distance(pl[3]) < eps2d);
+
+// for (int i=0; i<4; i++)
+// {
+// SCRUTE(quad->isEdgeForward[i]);
+// MESSAGE(" -first "<<i<<" "<<pf[i].X()<<" "<<pf[i].Y());
+// MESSAGE(" -last "<<i<<" "<<pl[i].X()<<" "<<pl[i].Y());
+// }
+
+ // 2 --- load 2d edge points (u,v) with orientation and value on unit square
+
+ for (int i=0; i<2; i++)
+ {
+ quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
+ quad->edge[i],
+ quad->first[i],
+ quad->last[i]);
+
+ // quad->isEdgeForward[i]);
+ }
+ for (int i=2; i<4; i++)
+ {
+ quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
+ quad->edge[i],
+ quad->last[i],
+ quad->first[i]);
+
+ // !quad->isEdgeForward[i]);
+ }
+
+ // 3 --- 2D normalized values on unit square [0..1][0..1]
+
+ int nbdown = quad->nbPts[0];
+ int nbright = quad->nbPts[1];
+ quad->uv_grid = new UVPtStruct[nbright*nbdown];
+
+ UVPtStruct* uv_grid = quad->uv_grid;
+ UVPtStruct* uv_e0 = quad->uv_edges[0];
+ UVPtStruct* uv_e1 = quad->uv_edges[1];
+ UVPtStruct* uv_e2 = quad->uv_edges[2];
+ UVPtStruct* uv_e3 = quad->uv_edges[3];
+ gp_Pnt2d a0 = pf[0];
+ gp_Pnt2d a1 = pf[1];
+ gp_Pnt2d a2 = pf[2];
+ gp_Pnt2d a3 = pf[3];
+
+ // nodes Id on edges
+
+ int j = 0;
+ for (int i=0; i<nbdown; i++)
+ {
+ int ij = j*nbdown +i;
+ uv_grid[ij].nodeId = uv_e0[i].nodeId;
+ }
+ i = nbdown-1;
+ for (int j=0; j<nbright; j++)
+ {
+ int ij = j*nbdown +i;
+ uv_grid[ij].nodeId = uv_e1[j].nodeId;
+ }
+ j = nbright -1;
+ for (int i=0; i<nbdown; i++)
+ {
+ int ij = j*nbdown +i;
+ uv_grid[ij].nodeId = uv_e2[i].nodeId;
+ }
+ i = 0;
+ for (int j=0; j<nbright; j++)
+ {
+ int ij = j*nbdown +i;
+ uv_grid[ij].nodeId = uv_e3[j].nodeId;
+ }
+
+ // normalized 2d values on grid
+
+ for (int i=0; i<nbdown; i++)
+ for (int j=0; j<nbright; j++)
+ {
+ int ij = j*nbdown +i;
+ // --- droite i cste : x = x0 + y(x1-x0)
+ double x0 = uv_e0[i].normParam; // bas - sud
+ double x1 = uv_e2[i].normParam; // haut - nord
+ // --- droite j cste : y = y0 + x(y1-y0)
+ double y0 = uv_e3[j].normParam; // gauche-ouest
+ double y1 = uv_e1[j].normParam; // droite - est
+ // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0)
+ double x=(x0+y0*(x1-x0))/(1-(y1-y0)*(x1-x0));
+ double y=y0+x*(y1-y0);
+ uv_grid[ij].x = x;
+ uv_grid[ij].y = y;
+ //MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1);
+ //MESSAGE("-xy-norm "<<i<<" "<<j<<" "<<x<<" "<<y);
+ }
+
+ // 4 --- projection on 2d domain (u,v)
+
+ for (int i=0; i<nbdown; i++)
+ for (int j=0; j<nbright; j++)
+ {
+ int ij = j*nbdown +i;
+ double x = uv_grid[ij].x;
+ double y = uv_grid[ij].y;
+ double param_0 = uv_e0[0].param
+ + x*(uv_e0[nbdown-1].param -uv_e0[0].param); // sud
+ double param_2 = uv_e2[0].param
+ + x*(uv_e2[nbdown-1].param -uv_e2[0].param); // nord
+ double param_1 = uv_e1[0].param
+ + y*(uv_e1[nbright-1].param -uv_e1[0].param); // est
+ double param_3 = uv_e3[0].param
+ + y*(uv_e3[nbright-1].param -uv_e3[0].param); // ouest
+
+ //MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
+ gp_Pnt2d p0 = c2d[0]->Value(param_0);
+ gp_Pnt2d p1 = c2d[1]->Value(param_1);
+ gp_Pnt2d p2 = c2d[2]->Value(param_2);
+ gp_Pnt2d p3 = c2d[3]->Value(param_3);
+
+ double u = (1-y)*p0.X() + x*p1.X() + y*p2.X() + (1-x)*p3.X();
+ double v = (1-y)*p0.Y() + x*p1.Y() + y*p2.Y() + (1-x)*p3.Y();
+
+ u -= (1-x)*(1-y)*a0.X() + x*(1-y)*a1.X() + x*y*a2.X() + (1-x)*y*a3.X();
+ v -= (1-x)*(1-y)*a0.Y() + x*(1-y)*a1.Y() + x*y*a2.Y() + (1-x)*y*a3.Y();
+
+ uv_grid[ij].u = u;
+ uv_grid[ij].v = v;
+
+ //MESSAGE("-uv- "<<i<<" "<<j<<" "<<uv_grid[ij].u<<" "<<uv_grid[ij].v);
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+UVPtStruct* SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh& aMesh,
+ const TopoDS_Face& F,
+ const TopoDS_Edge& E,
+ double first,
+ double last)
+ // bool isForward)
+{
+ //MESSAGE("SMESH_Quadrangle_2D::LoadEdgePoints");
+
+ Handle (SMDS_Mesh) meshDS = aMesh.GetMeshDS();
+
+ // --- IDNodes of first and last Vertex
+
+ TopoDS_Vertex VFirst, VLast;
+ TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
+
+ ASSERT(!VFirst.IsNull());
+ SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst);
+ const TColStd_ListOfInteger& lidf
+ = firstSubMesh->GetSubMeshDS()->GetIDNodes();
+ int idFirst= lidf.First();
+ //SCRUTE(idFirst);
+
+ ASSERT(!VLast.IsNull());
+ SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast);
+ const TColStd_ListOfInteger& lidl
+ = lastSubMesh->GetSubMeshDS()->GetIDNodes();
+ int idLast= lidl.First();
+ //SCRUTE(idLast);
+
+ // --- edge internal IDNodes (relies on good order storage, not checked)
+
+ int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+ //SCRUTE(nbPoints);
+ UVPtStruct * uvslf = new UVPtStruct[nbPoints+2];
+
+ double f,l;
+ Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
+
+ const TColStd_ListOfInteger& indElt
+ = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
+ TColStd_ListIteratorOfListOfInteger ite(indElt);
+ //SCRUTE(nbPoints);
+ //SCRUTE(indElt.Extent());
+ ASSERT(nbPoints == indElt.Extent());
+
+ map<double,int> params;
+ for (; ite.More(); ite.Next())
+ {
+ int nodeId = ite.Value();
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ Handle (SMDS_EdgePosition) epos
+ = Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
+ double param = epos->GetUParameter();
+ params[param] = nodeId;
+ }
+
+ bool isForward = (((l-f)*(last-first)) > 0);
+ double paramin = 0;
+ double paramax = 0;
+ if (isForward)
+ {
+ paramin = f;
+ paramax = l;
+ gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
+ uvslf [0].x = p.X();
+ uvslf [0].y = p.Y();
+ uvslf [0].param = f;
+ uvslf [0].nodeId = idFirst;
+ //MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
+ map<double,int>::iterator itp = params.begin();
+ for (int i = 1; i <= nbPoints; i++) // nbPoints internal
+ {
+ double param = (*itp).first;
+ int nodeId = (*itp).second;
+ gp_Pnt2d p = C2d->Value(param);
+ uvslf [i].x = p.X();
+ uvslf [i].y = p.Y();
+ uvslf[i].param = param;
+ uvslf[i].nodeId = nodeId;
+ //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
+ itp++;
+ }
+ p = C2d->Value(l); // last point = Vertex Reversed
+ uvslf [nbPoints+1].x = p.X();
+ uvslf [nbPoints+1].y = p.Y();
+ uvslf [nbPoints+1].param = l;
+ uvslf [nbPoints+1].nodeId = idLast;
+ //MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
+ }
+ else
+ {
+ paramin = l;
+ paramax = f;
+ gp_Pnt2d p = C2d->Value(l); // first point = Vertex Reversed
+ uvslf [0].x = p.X();
+ uvslf [0].y = p.Y();
+ uvslf [0].param = l;
+ uvslf [0].nodeId = idLast;
+ //MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
+ map<double,int>::reverse_iterator itp = params.rbegin();
+ for (int j = nbPoints; j >= 1; j--) // nbPoints internal
+ {
+ double param = (*itp).first;
+ int nodeId = (*itp).second;
+ int i = nbPoints +1 -j;
+ gp_Pnt2d p = C2d->Value(param);
+ uvslf [i].x = p.X();
+ uvslf [i].y = p.Y();
+ uvslf[i].param = param;
+ uvslf[i].nodeId = nodeId;
+ //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
+ itp++;
+ }
+ p = C2d->Value(f); // last point = Vertex Forward
+ uvslf [nbPoints+1].x = p.X();
+ uvslf [nbPoints+1].y = p.Y();
+ uvslf [nbPoints+1].param = f;
+ uvslf [nbPoints+1].nodeId = idFirst;
+ //MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
+ }
+
+ ASSERT(paramin != paramax);
+ for (int i = 0; i< nbPoints+2; i++)
+ {
+ uvslf[i].normParam = (uvslf[i].param -paramin)/(paramax -paramin);
+ //SCRUTE(uvslf[i].normParam);
+ }
+
+ return uvslf;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_Quadrangle_2D::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_Quadrangle_2D::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & operator << (ostream & save, SMESH_Quadrangle_2D & hyp)
+{
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & operator >> (istream & load, SMESH_Quadrangle_2D & hyp)
+{
+ return load;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Quadrangle_2D.hxx
+// Created : sam mai 18 08:11:36 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_QUADRANGLE_2D_HXX_
+#define _SMESH_QUADRANGLE_2D_HXX_
+
+#include "SMESH_2D_Algo.hxx"
+#include "SMESH_Mesh.hxx"
+#include "Utils_SALOME_Exception.hxx"
+
+typedef struct uvPtStruct
+{
+ double param;
+ double normParam;
+ double u; // original 2d parameter
+ double v;
+ double x; // 2d parameter, normalized [0,1]
+ double y;
+ int nodeId;
+} UVPtStruct;
+
+typedef struct faceQuadStruct
+{
+ int nbPts[4];
+ TopoDS_Edge edge[4];
+ double first[4];
+ double last[4];
+ bool isEdgeForward[4];
+ UVPtStruct* uv_edges[4];
+ UVPtStruct* uv_grid;
+} FaceQuadStruct;
+
+class SMESH_Quadrangle_2D:
+ public SMESH_2D_Algo
+{
+public:
+ SMESH_Quadrangle_2D(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_Quadrangle_2D();
+
+ virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ virtual bool Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+ throw (SALOME_Exception);
+
+ FaceQuadStruct* CheckAnd2Dcompute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+ throw (SALOME_Exception);
+
+ void QuadDelete(FaceQuadStruct* quad);
+
+ ostream & SaveTo(ostream & save);
+ istream & LoadFrom(istream & load);
+ friend ostream & operator << (ostream & save, SMESH_Quadrangle_2D & hyp);
+ friend istream & operator >> (istream & load, SMESH_Quadrangle_2D & hyp);
+
+protected:
+
+ void SetNormalizedGrid(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ FaceQuadStruct* quad)
+ throw (SALOME_Exception);
+
+ UVPtStruct* LoadEdgePoints(SMESH_Mesh& aMesh,
+ const TopoDS_Face& F,
+ const TopoDS_Edge& E,
+ double first,
+ double last);
+// bool isForward);
+
+// FaceQuadStruct _quadDesc;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_Regular_1D.cxx
+// Created : sam mai 18 08:11:58 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+using namespace std;
+
+#include "SMESH_Regular_1D.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_Mesh.hxx"
+
+#include "SMESH_LocalLength.hxx"
+#include "SMESH_NumberOfSegments.hxx"
+
+#include "SMESHDS_ListOfPtrHypothesis.hxx"
+#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_EdgePosition.hxx"
+
+#include "utilities.h"
+
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GCPnts_UniformAbscissa.hxx>
+
+#include <string>
+#include <algorithm>
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Regular_1D::SMESH_Regular_1D(int hypId, int studyId, SMESH_Gen* gen)
+ : SMESH_1D_Algo(hypId, studyId, gen)
+{
+ MESSAGE("SMESH_Regular_1D::SMESH_Regular_1D");
+ _name = "Regular_1D";
+ // _shapeType = TopAbs_EDGE;
+ _shapeType = (1<<TopAbs_EDGE);
+ _compatibleHypothesis.push_back("LocalLength");
+ _compatibleHypothesis.push_back("NumberOfSegments");
+
+ _localLength = 0;
+ _numberOfSegments = 0;
+ _hypLocalLength = NULL;
+ _hypNumberOfSegments = NULL;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Regular_1D::~SMESH_Regular_1D()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & SMESH_Regular_1D::SaveTo(ostream & save)
+{
+ return save << this;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & SMESH_Regular_1D::LoadFrom(istream & load)
+{
+ return load >> (*this);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream& operator << (ostream & save, SMESH_Regular_1D & hyp)
+{
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream& operator >> (istream & load, SMESH_Regular_1D & hyp)
+{
+ return load;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ //MESSAGE("SMESH_Regular_1D::CheckHypothesis");
+
+ list<SMESHDS_Hypothesis*>::const_iterator itl;
+ SMESHDS_Hypothesis* theHyp;
+
+ const list<SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
+ int nbHyp = hyps.size();
+ if (nbHyp != 1) return false; // only one compatible hypothesis allowed
+
+ itl = hyps.begin();
+ theHyp = (*itl);
+
+ string hypName = theHyp->GetName();
+ int hypId = theHyp->GetID();
+ //SCRUTE(hypName);
+
+ bool isOk = false;
+
+ if (hypName == "LocalLength")
+ {
+ _hypLocalLength = dynamic_cast<SMESH_LocalLength*> (theHyp);
+ ASSERT(_hypLocalLength);
+ _localLength = _hypLocalLength->GetLength();
+ _numberOfSegments = 0;
+ isOk =true;
+ }
+
+ if (hypName == "NumberOfSegments")
+ {
+ _hypNumberOfSegments = dynamic_cast<SMESH_NumberOfSegments*> (theHyp);
+ ASSERT(_hypNumberOfSegments);
+ _numberOfSegments = _hypNumberOfSegments->GetNumberOfSegments();
+ _localLength = 0;
+ isOk = true;
+ }
+
+ //SCRUTE(_localLength);
+ //SCRUTE(_numberOfSegments);
+
+ return isOk;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape)
+{
+ //MESSAGE("SMESH_Regular_1D::Compute");
+
+ const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
+ SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
+
+ const TopoDS_Edge& EE = TopoDS::Edge(aShape);
+ TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
+
+ double f,l;
+ Handle(Geom_Curve) Curve = BRep_Tool::Curve(E,f,l);
+
+ TopoDS_Vertex VFirst, VLast;
+ TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l
+
+ double length = EdgeLength(E);
+ //SCRUTE(length);
+
+ double eltSize = 1;
+// if (_localLength > 0) eltSize = _localLength;
+ if (_localLength > 0)
+ {
+ double nbseg = ceil(length/_localLength); // integer sup
+ if (nbseg <=0) nbseg = 1; // degenerated edge
+ eltSize = length/nbseg;
+ }
+ else
+ {
+ ASSERT(_numberOfSegments> 0);
+ eltSize = length/_numberOfSegments;
+ }
+
+ ASSERT(!VFirst.IsNull());
+ SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst);
+ const TColStd_ListOfInteger& lidf
+ = firstSubMesh->GetSubMeshDS()->GetIDNodes();
+ int idFirst= lidf.First();
+ //SCRUTE(idFirst);
+
+ ASSERT(!VLast.IsNull());
+ SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast);
+ const TColStd_ListOfInteger& lidl
+ = lastSubMesh->GetSubMeshDS()->GetIDNodes();
+ int idLast= lidl.First();
+ //SCRUTE(idLast);
+
+ if (!Curve.IsNull())
+ {
+ GeomAdaptor_Curve C3d(Curve);
+ GCPnts_UniformAbscissa Discret(C3d,eltSize,f,l);
+ int NbPoints = Discret.NbPoints();
+ //MESSAGE("nb points on edge : "<<NbPoints);
+
+ // edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
+ // only internal nodes receive an edge position with param on curve
+
+ int idPrev = idFirst;
+ for (int i=2; i<NbPoints; i++)
+ {
+ double param = Discret.Parameter(i);
+ gp_Pnt P = Curve->Value(param);
+
+ //Add the Node in the DataStructure
+ int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ //MESSAGE("point "<<nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" - "<<i<<" "<<param);
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ meshDS->SetNodeOnEdge(node, E);
+
+ // **** edgePosition associe au point = param.
+// Handle (SMDS_EdgePosition) epos
+// = new SMDS_EdgePosition(theSubMesh->GetId(),param); // non, deja cree
+// node->SetPosition(epos);
+ Handle (SMDS_EdgePosition) epos
+ = Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
+ epos->SetUParameter(param);
+
+ int edgeId = meshDS->AddEdge(idPrev, nodeId);
+ elt = meshDS->FindElement(edgeId);
+ meshDS->SetMeshElementOnShape(elt, E);
+ idPrev = nodeId;
+ }
+ int edgeId = meshDS->AddEdge(idPrev, idLast);
+ Handle (SMDS_MeshElement) elt = meshDS->FindElement(edgeId);
+ meshDS->SetMeshElementOnShape(elt, E);
+ }
+ else
+ {
+// MESSAGE ("Edge Degeneree non traitee --- arret");
+// ASSERT(0);
+ if (BRep_Tool::Degenerated(E))
+ {
+ // Edge is a degenerated Edge : We put n = 5 points on the edge.
+ int NbPoints = 5;
+ BRep_Tool::Range(E,f,l);
+ double du = (l-f)/(NbPoints-1);
+ MESSAGE("************* Degenerated edge! *****************");
+
+ TopoDS_Vertex V1,V2;
+ TopExp::Vertices (E,V1,V2);
+ gp_Pnt P = BRep_Tool::Pnt(V1);
+
+ int idPrev = idFirst;
+ for (int i=2; i<NbPoints; i++)
+ {
+ double param = f + (i-1)*du;
+ //Add the Node in the DataStructure
+ int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
+ //MESSAGE("point "<<nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" - "<<i<<" "<<param);
+
+ Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+ meshDS->SetNodeOnEdge(node, E);
+
+// Handle (SMDS_EdgePosition) epos
+// = new SMDS_EdgePosition(theSubMesh->GetId(),param);
+// node->SetPosition(epos);
+ Handle (SMDS_EdgePosition) epos
+ = Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
+ epos->SetUParameter(param);
+
+ int edgeId = meshDS->AddEdge(idPrev, nodeId);
+ elt = meshDS->FindElement(edgeId);
+ meshDS->SetMeshElementOnShape(elt, E);
+ idPrev = nodeId;
+ }
+ int edgeId = meshDS->AddEdge(idPrev, idLast);
+ Handle (SMDS_MeshElement) elt = meshDS->FindElement(edgeId);
+ meshDS->SetMeshElementOnShape(elt, E);
+ }
+ else ASSERT(0);
+ }
+ return true;
+}
--- /dev/null
+//=============================================================================
+// File : SMESH_Regular_1D.hxx
+// Created : sam mai 18 08:11:54 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_REGULAR_1D_HXX_
+#define _SMESH_REGULAR_1D_HXX_
+
+#include "SMESH_1D_Algo.hxx"
+
+class SMESH_LocalLength;
+class SMESH_NumberOfSegments;
+
+class SMESH_Regular_1D:
+ public SMESH_1D_Algo
+{
+public:
+ SMESH_Regular_1D(int hypId, int studyId, SMESH_Gen* gen);
+ virtual ~SMESH_Regular_1D();
+
+ virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ virtual bool Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ ostream & SaveTo(ostream & save);
+ istream & LoadFrom(istream & load);
+ friend ostream & operator << (ostream & save, SMESH_Regular_1D & hyp);
+ friend istream & operator >> (istream & load, SMESH_Regular_1D & hyp);
+
+protected:
+ double _localLength;
+ int _numberOfSegments;
+ SMESH_LocalLength* _hypLocalLength;
+ SMESH_NumberOfSegments* _hypNumberOfSegments;
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : SMESH_subMesh.cxx
+// Created : jeu mai 30 13:28:32 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+using namespace std;
+
+#include "SMESH_subMesh.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_Mesh.hxx"
+#include "SMESH_Hypothesis.hxx"
+#include "SMESH_Algo.hxx"
+#include "utilities.h"
+#include "OpUtil.hxx"
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+//=============================================================================
+/*!
+ * default constructor:
+ */
+//=============================================================================
+
+SMESH_subMesh::SMESH_subMesh(int Id,
+ SMESH_Mesh* father,
+ const Handle(SMESHDS_Mesh)& meshDS,
+ const TopoDS_Shape & aSubShape)
+{
+ //MESSAGE("SMESH_subMesh::SMESH_subMesh");
+ _subShape = aSubShape;
+ _meshDS = meshDS;
+ _subMeshDS = meshDS->MeshElements(_subShape); // may be null ...
+ _father = father;
+ _Id = Id;
+ _vertexSet = false; // only for Vertex subMesh
+ _dependenceAnalysed = false;
+ _dependantsFound = false;
+
+ if (_subShape.ShapeType() == TopAbs_VERTEX)
+ {
+ _algoState = HYP_OK;
+ _computeState = READY_TO_COMPUTE;
+ }
+ else
+ {
+ _algoState = NO_ALGO;
+ _computeState = NOT_READY;
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_subMesh::~SMESH_subMesh()
+{
+ MESSAGE("SMESH_subMesh::~SMESH_subMesh");
+ // ****
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+int SMESH_subMesh::GetId()
+{
+ //MESSAGE("SMESH_subMesh::GetId");
+ return _Id;
+}
+
+//=============================================================================
+/*!
+ * Given a subShape, find the subMesh is associated to this subShape or
+ * to a collection of shapes containing this subShape. Collection = compsolid,
+ * shell, wire
+ */
+//=============================================================================
+
+// bool SMESH_subMesh::Contains(const TopoDS_Shape & aSubShape)
+// throw (SALOME_Exception)
+// {
+// //MESSAGE("SMESH_subMesh::Contains");
+// bool contains = false;
+// int type = _subShape.ShapeType();
+// int typesub = aSubShape.ShapeType();
+// //SCRUTE(type)
+// //SCRUTE(typesub)
+// switch (type)
+// {
+// // case TopAbs_COMPOUND:
+// // {
+// // //MESSAGE("---");
+// // throw SALOME_Exception(LOCALIZED("Compound not yet treated"));
+// // break;
+// // }
+// case TopAbs_COMPSOLID:
+// {
+// //MESSAGE("---");
+// for (TopExp_Explorer exp(aSubShape,TopAbs_SOLID);exp.More();exp.Next())
+// {
+// contains = _subShape.IsSame(exp.Current());
+// if (contains) break;
+// }
+// break;
+// }
+// case TopAbs_SHELL:
+// {
+// //MESSAGE("---");
+// for (TopExp_Explorer exp(aSubShape,TopAbs_FACE);exp.More();exp.Next())
+// {
+// contains = _subShape.IsSame(exp.Current());
+// if (contains) break;
+// }
+// break;
+// }
+// case TopAbs_WIRE:
+// {
+// //MESSAGE("---");
+// for (TopExp_Explorer exp(aSubShape,TopAbs_EDGE);exp.More();exp.Next())
+// {
+// contains = _subShape.IsSame(exp.Current());
+// if (contains) break;
+// }
+// break;
+// }
+// case TopAbs_COMPOUND:
+// case TopAbs_SOLID:
+// case TopAbs_FACE:
+// case TopAbs_EDGE:
+// case TopAbs_VERTEX:
+// {
+// //MESSAGE("---");
+// contains = _subShape.IsSame(aSubShape);
+// break;
+// }
+// default:
+// {
+// break;
+// }
+// }
+// //SCRUTE(contains);
+// return contains;
+// }
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+const Handle(SMESHDS_SubMesh)& SMESH_subMesh::GetSubMeshDS()
+ throw (SALOME_Exception)
+{
+ //MESSAGE("SMESH_subMesh::GetSubMeshDS");
+ if (_subMeshDS.IsNull())
+ {
+ //MESSAGE("subMesh pointer still null, trying to get it...");
+ _subMeshDS = _meshDS->MeshElements(_subShape); // may be null ...
+ if (_subMeshDS.IsNull())
+ {
+ MESSAGE("problem... subMesh still empty");
+ //NRI ASSERT(0);
+ //NRI throw SALOME_Exception(LOCALIZED(subMesh still empty));
+ }
+ }
+ return _subMeshDS;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_subMesh* SMESH_subMesh::GetFirstToCompute()
+ throw (SALOME_Exception)
+{
+ //MESSAGE("SMESH_subMesh::GetFirstToCompute");
+ const map<int, SMESH_subMesh*>& subMeshes = DependsOn();
+ SMESH_subMesh* firstToCompute = 0;
+
+ map<int, SMESH_subMesh*>::const_iterator itsub;
+ for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
+ {
+ SMESH_subMesh* sm = (*itsub).second;
+// SCRUTE(sm->GetId());
+// SCRUTE(sm->GetComputeState());
+ bool readyToCompute = (sm->GetComputeState() == READY_TO_COMPUTE);
+ if (readyToCompute)
+ {
+ firstToCompute = sm;
+ //SCRUTE(sm->GetId());
+ break;
+ }
+ }
+ if (firstToCompute)
+ {
+ //MESSAGE("--- submesh to compute");
+ return firstToCompute; // a subMesh of this
+ }
+ if (_computeState == READY_TO_COMPUTE)
+ {
+ //MESSAGE("--- this to compute");
+ return this; // this
+ }
+ //MESSAGE("--- nothing to compute");
+ return 0; // nothing to compute
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_subMesh::SubMeshesComputed()
+ throw (SALOME_Exception)
+{
+ //MESSAGE("SMESH_subMesh::SubMeshesComputed");
+ const map<int, SMESH_subMesh*>& subMeshes = DependsOn();
+
+ bool subMeshesComputed = true;
+ map<int, SMESH_subMesh*>::const_iterator itsub;
+ for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
+ {
+ SMESH_subMesh* sm = (*itsub).second;
+// SCRUTE(sm->GetId());
+// SCRUTE(sm->GetComputeState());
+ bool computeOk = (sm->GetComputeState() == COMPUTE_OK);
+ if (! computeOk)
+ {
+ subMeshesComputed = false;
+ SCRUTE(sm->GetId());
+ break;
+ }
+ }
+ return subMeshesComputed;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_subMesh::SubMeshesReady()
+{
+ MESSAGE("SMESH_subMesh::SubMeshesReady");
+ const map<int, SMESH_subMesh*>& subMeshes = DependsOn();
+
+ bool subMeshesReady = true;
+ map<int, SMESH_subMesh*>::const_iterator itsub;
+ for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
+ {
+ SMESH_subMesh* sm = (*itsub).second;
+// SCRUTE(sm->GetId());
+// SCRUTE(sm->GetComputeState());
+ bool computeOk = ( (sm->GetComputeState() == COMPUTE_OK)
+ || (sm->GetComputeState() == READY_TO_COMPUTE)) ;
+ if (! computeOk)
+ {
+ subMeshesReady = false;
+ SCRUTE(sm->GetId());
+ break;
+ }
+ }
+ return subMeshesReady;
+}
+
+//=============================================================================
+/*!
+ * Construct dependence on first level subMeshes. complex shapes (compsolid,
+ * shell, wire) are not analysed the same way as simple shapes (solid, face,
+ * edge).
+ * For collection shapes (compsolid, shell, wire) prepare a list of submeshes
+ * with possible multiples occurences. Multiples occurences corresponds to
+ * internal frontiers within shapes of the collection and must not be keeped.
+ * See FinalizeDependence.
+ */
+//=============================================================================
+
+const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
+{
+ if (_dependenceAnalysed) return _mapDepend;
+
+ //MESSAGE("SMESH_subMesh::DependsOn");
+
+ int type = _subShape.ShapeType();
+ //SCRUTE(type);
+ switch (type)
+ {
+ case TopAbs_COMPOUND:
+ {
+ //MESSAGE("compound");
+ list<TopoDS_Shape> shellInSolid;
+ for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next())
+ {
+ InsertDependence(exp.Current());
+ for (TopExp_Explorer
+ exp2(exp.Current(),TopAbs_SHELL);exp2.More();exp2.Next())
+ {
+ shellInSolid.push_back(exp2.Current());
+ }
+ }
+ for (TopExp_Explorer exp(_subShape,TopAbs_SHELL);exp.More();exp.Next())
+ {
+ list<TopoDS_Shape>::iterator it1;
+ bool isInSolid = false;
+ for (it1 = shellInSolid.begin(); it1 != shellInSolid.end(); it1++)
+ {
+ TopoDS_Shape aShape = (*it1);
+ if (aShape.IsSame(exp.Current()))
+ {
+ isInSolid = true;
+ break;
+ }
+ }
+ if (!isInSolid)
+ InsertDependence(exp.Current()); //only shell not in solid
+ }
+ for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
+ {
+ InsertDependence(exp.Current());
+ }
+ for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
+ {
+ InsertDependence(exp.Current());
+ }
+ break;
+ }
+ case TopAbs_COMPSOLID:
+ {
+ //MESSAGE("compsolid");
+ for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next())
+ {
+ InsertDependence(exp.Current());
+ }
+// list<TopoDS_Shape> shapeList;
+// for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next())
+// {
+// for (TopExp_Explorer
+// exp2(exp.Current(),TopAbs_FACE);exp2.More();exp2.Next())
+// {
+// shapeList.push_back(exp2.Current());
+// }
+// }
+// FinalizeDependence(shapeList);
+ break;
+ }
+ case TopAbs_SHELL:
+ {
+ //MESSAGE("shell");
+ for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
+ {
+ InsertDependence(exp.Current());
+ }
+// list<TopoDS_Shape> shapeList;
+// for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
+// {
+// for (TopExp_Explorer
+// exp2(exp.Current(),TopAbs_EDGE);exp2.More();exp2.Next())
+// {
+// shapeList.push_back(exp2.Current());
+// }
+// }
+// FinalizeDependence(shapeList);
+ break;
+ }
+ case TopAbs_WIRE:
+ {
+ //MESSAGE("wire");
+ for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
+ {
+ InsertDependence(exp.Current());
+ }
+// list<TopoDS_Shape> shapeList;
+// for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
+// {
+// for (TopExp_Explorer
+// exp2(exp.Current(),TopAbs_VERTEX);exp2.More();exp2.Next())
+// {
+// shapeList.push_back(exp2.Current());
+// }
+// }
+// FinalizeDependence(shapeList);
+ break;
+ }
+ case TopAbs_SOLID:
+ {
+ //MESSAGE("solid");
+// for (TopExp_Explorer exp(_subShape,TopAbs_SHELL);exp.More();exp.Next())
+// {
+// InsertDependence(exp.Current());
+// }
+ for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
+ {
+ InsertDependence(exp.Current());
+ }
+ break;
+ }
+ case TopAbs_FACE:
+ {
+ //MESSAGE("face");
+// for (TopExp_Explorer exp(_subShape,TopAbs_WIRE);exp.More();exp.Next())
+// {
+// InsertDependence(exp.Current());
+// }
+ for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
+ {
+ InsertDependence(exp.Current());
+ }
+ break;
+ }
+ case TopAbs_EDGE:
+ {
+ //MESSAGE("edge");
+ for (TopExp_Explorer exp(_subShape,TopAbs_VERTEX);exp.More();exp.Next())
+ {
+ InsertDependence(exp.Current());
+ }
+ break;
+ }
+ case TopAbs_VERTEX:
+ {
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ _dependenceAnalysed = true;
+ return _mapDepend;
+}
+
+//=============================================================================
+/*!
+ * For simple Shapes (solid, face, edge): add subMesh into dependence list.
+ */
+//=============================================================================
+
+void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
+{
+ //MESSAGE("SMESH_subMesh::InsertDependence");
+ //SMESH_subMesh* aSubMesh = _father->GetSubMeshContaining(aSubShape);
+ //SCRUTE(aSubMesh);
+ //if (! aSubMesh) aSubMesh = _father->GetSubMesh(aSubShape);
+
+ SMESH_subMesh* aSubMesh = _father->GetSubMesh(aSubShape);
+ int type = aSubShape.ShapeType();
+ int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid
+ int cle = aSubMesh->GetId();
+ cle += 10000000 * ordType; // sort map by ordType then index
+ if (_mapDepend.find(cle) == _mapDepend.end())
+ {
+ _mapDepend[cle] = aSubMesh;
+ const map<int, SMESH_subMesh*>& subMap = aSubMesh->DependsOn();
+ map<int, SMESH_subMesh*>::const_iterator im;
+ 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;
+ }
+ }
+
+}
+
+//=============================================================================
+/*!
+ * For collection shapes (compsolid, shell, wire).
+ * Add only subMesh figuring only once in multiset to dependence list
+ */
+//=============================================================================
+
+// void SMESH_subMesh::FinalizeDependence(list<TopoDS_Shape>& shapeList)
+// {
+// //MESSAGE("SMESH_subMesh::FinalizeDependence");
+// list<TopoDS_Shape>::iterator it1, it2;
+// for(it1 = shapeList.begin(); it1 != shapeList.end(); it1++)
+// {
+// TopoDS_Shape aSubShape = (*it1);
+// int count = 0;
+// for(it2 = shapeList.begin(); it2 != shapeList.end(); it2++)
+// {
+// TopoDS_Shape other = (*it2);
+// if (other.IsSame(aSubShape)) count++;
+// }
+// if (count == 1) InsertDependence(aSubShape);
+// SCRUTE(count);
+// }
+// }
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ const TopoDS_Shape& SMESH_subMesh::GetSubShape()
+{
+ //MESSAGE("SMESH_subMesh::GetSubShape");
+ return _subShape;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
+ throw (SALOME_Exception)
+{
+ // MESSAGE("SMESH_subMesh::AlgoStateEngine");
+ //SCRUTE(_algoState);
+ //SCRUTE(event);
+
+ // **** les retour des evenement shape sont significatifs
+ // (add ou remove fait ou non)
+ // le retour des evenement father n'indiquent pas que add ou remove fait
+ int dim = SMESH_Gen::GetShapeDim(_subShape);
+
+ if (dim < 1)
+ {
+ _algoState = HYP_OK;
+ //SCRUTE(_algoState);
+ return true;
+ }
+
+ SMESH_Gen* gen =_father->GetGen();
+ bool ret;
+ _oldAlgoState = _algoState;
+ bool modifiedHyp = false; // if set to true, force event MODIF_ALGO_STATE
+ // in ComputeStateEngine
+
+ switch (_algoState)
+ {
+
+ // ----------------------------------------------------------------------
+
+ case NO_ALGO:
+ switch (event)
+ {
+ case ADD_HYP:
+ ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+ ret = _meshDS->AddHypothesis(_subShape, anHyp);
+ break;
+ case ADD_ALGO:
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+ if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
+ {
+ ret = _meshDS->AddHypothesis(_subShape, anHyp);
+// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
+// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
+ if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ ASSERT(algo);
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ }
+ break;
+ case REMOVE_HYP:
+ ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+ ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+ break;
+ case REMOVE_ALGO:
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+ ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+ break;
+ case ADD_FATHER_HYP: // nothing to do
+ break;
+ case ADD_FATHER_ALGO: // Algo just added in father
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+// if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
+// if (anHyp->GetShapeType() == _subShape.ShapeType())
+ if (anHyp->GetShapeType() & (1<< _subShape.ShapeType()))
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ ASSERT(algo);
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ break;
+ case REMOVE_FATHER_HYP: // nothing to do
+ break;
+ case REMOVE_FATHER_ALGO: // nothing to do
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ break;
+
+ // ----------------------------------------------------------------------
+
+ case MISSING_HYP:
+ switch (event)
+ {
+ case ADD_HYP:
+ ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+ ret = _meshDS->AddHypothesis(_subShape, anHyp);
+ if (ret)
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ ASSERT(algo);
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ break;
+ case ADD_ALGO: //already existing algo : on father ?
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+ if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
+ {
+ ret = _meshDS->AddHypothesis(_subShape, anHyp);
+// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
+// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
+ if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ if (algo == NULL) // two algo on the same subShape...
+ {
+ MESSAGE("two algo on the same subshape not allowed");
+ ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+ ret = false;
+ }
+ else
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ }
+ }
+ break;
+ case REMOVE_HYP:
+ ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+ ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+ break;
+ case REMOVE_ALGO: // perhaps a father algo applies ?
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+ ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
+// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
+ if (ret &&(anHyp->GetShapeType() & (1<<_subShape.ShapeType())))
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ if (algo == NULL) // no more algo applying on subShape...
+ {
+ SetAlgoState(NO_ALGO);
+ }
+ else
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ }
+ break;
+ case ADD_FATHER_HYP:
+ ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ ASSERT(algo);
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ break;
+ case ADD_FATHER_ALGO: // detect if two algo of same dim on father
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+// if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
+// if (anHyp->GetShapeType() == _subShape.ShapeType())
+ if (anHyp->GetShapeType() & (1<< _subShape.ShapeType()))
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ if (algo == NULL) // two applying algo on father
+ {
+ MESSAGE("two applying algo on fatherShape...");
+ SetAlgoState(NO_ALGO);
+ }
+ else
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ }
+ break;
+ case REMOVE_FATHER_HYP: // nothing to do
+ break;
+ case REMOVE_FATHER_ALGO:
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+// if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
+// if (anHyp->GetShapeType() == _subShape.ShapeType())
+ if (anHyp->GetShapeType() & (1<< _subShape.ShapeType()))
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ if (algo == NULL) // no more applying algo on father
+ {
+ SetAlgoState(NO_ALGO);
+ }
+ else
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ }
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ break;
+
+ // ----------------------------------------------------------------------
+
+ case HYP_OK:
+ switch (event)
+ {
+ case ADD_HYP:
+ {
+ ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ ASSERT(algo);
+ list<SMESHDS_Hypothesis*> originalUsedHyps
+ = algo->GetUsedHypothesis((*_father), _subShape); // copy
+
+ ret = _meshDS->AddHypothesis(_subShape, anHyp);
+ if (ret)
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (! ret)
+ {
+ INFOS("two applying algo on the same shape not allowed");
+ ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+ ret = false;
+ }
+ else // compare SMESHDS_Hypothesis* lists (order important)
+ {
+ MESSAGE("---");
+ const list<SMESHDS_Hypothesis*>& newUsedHyps
+ = algo->GetUsedHypothesis((*_father), _subShape);
+ modifiedHyp = (originalUsedHyps != newUsedHyps);
+ }
+ }
+ }
+ break;
+ case ADD_ALGO: //already existing algo : on father ?
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+ if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
+ {
+ ret = _meshDS->AddHypothesis(_subShape, anHyp);
+// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
+// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
+ if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ if (algo == NULL) // two algo on the same subShape...
+ {
+ INFOS("two algo on the same subshape not allowed");
+ ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+ ret = false;
+ }
+ else
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ }
+ }
+ break;
+ case REMOVE_HYP:
+ ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+ ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+ if (ret)
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ ASSERT(algo);
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ modifiedHyp = true;
+ }
+ break;
+ case REMOVE_ALGO: // perhaps a father algo applies ?
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+ ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
+// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
+ if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ if (algo == NULL) // no more algo applying on subShape...
+ {
+ SetAlgoState(NO_ALGO);
+ }
+ else
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ }
+ break;
+ case ADD_FATHER_HYP:
+ ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ ASSERT(algo);
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ break;
+ case ADD_FATHER_ALGO: // detect if two algo of same dim on father
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+// if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
+// if (anHyp->GetShapeType() == _subShape.ShapeType())
+ if (anHyp->GetShapeType() & (1<< _subShape.ShapeType()))
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ if (algo == NULL) // two applying algo on father
+ {
+ MESSAGE("two applying algo on fatherShape...");
+ SetAlgoState(NO_ALGO);
+ }
+ else
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ }
+ break;
+ case REMOVE_FATHER_HYP:
+ ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ ASSERT(algo);
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ break;
+ case REMOVE_FATHER_ALGO:
+ ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+// if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
+// if (anHyp->GetShapeType() == _subShape.ShapeType())
+ if (anHyp->GetShapeType() & (1<< _subShape.ShapeType()))
+ {
+ SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
+ if (algo == NULL) // no more applying algo on father
+ {
+ SetAlgoState(NO_ALGO);
+ }
+ else
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) SetAlgoState(HYP_OK);
+ else SetAlgoState(MISSING_HYP);
+ }
+ }
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ break;
+
+ // ----------------------------------------------------------------------
+
+ default:
+ ASSERT(0);
+ break;
+ }
+ //SCRUTE(_algoState);
+ if ((_algoState != _oldAlgoState) || modifiedHyp)
+ int retc = ComputeStateEngine(MODIF_ALGO_STATE);
+ return ret;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_subMesh::SetAlgoState(int state)
+{
+ if (state != _oldAlgoState)
+// int retc = ComputeStateEngine(MODIF_ALGO_STATE);
+ _algoState = state;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_subMesh::SubMeshesAlgoStateEngine(int event,
+ SMESH_Hypothesis* anHyp)
+ throw (SALOME_Exception)
+{
+ //MESSAGE("SMESH_subMesh::SubMeshesAlgoStateEngine");
+ int dim = SMESH_Gen::GetShapeDim(_subShape);
+ if (dim > 1)
+ {
+ const map<int, SMESH_subMesh*>& subMeshes = DependsOn();
+
+ map<int, SMESH_subMesh*>::const_iterator itsub;
+ for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
+ {
+ SMESH_subMesh* sm = (*itsub).second;
+ sm->AlgoStateEngine(event, anHyp);
+ }
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_subMesh::DumpAlgoState(bool isMain)
+{
+ int dim = SMESH_Gen::GetShapeDim(_subShape);
+// if (dim < 1) return;
+ if (isMain)
+ {
+ const map<int, SMESH_subMesh*>& subMeshes = DependsOn();
+
+ map<int, SMESH_subMesh*>::const_iterator itsub;
+ for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
+ {
+ SMESH_subMesh* sm = (*itsub).second;
+ sm->DumpAlgoState(false);
+ }
+ }
+ int type = _subShape.ShapeType();
+ MESSAGE("dim = " << dim << " type of shape " << type);
+ switch(_algoState)
+ {
+ case NO_ALGO: MESSAGE(" AlgoState = NO_ALGO"); break;
+ case MISSING_HYP: MESSAGE(" AlgoState = MISSING_HYP"); break;
+ case HYP_OK: MESSAGE(" AlgoState = HYP_OK"); break;
+ }
+ switch (_computeState)
+ {
+ case NOT_READY: MESSAGE(" ComputeState = NOT_READY"); break;
+ case READY_TO_COMPUTE: MESSAGE(" ComputeState = READY_TO_COMPUTE"); break;
+ case COMPUTE_OK: MESSAGE(" ComputeState = COMPUTE_OK"); break;
+ case FAILED_TO_COMPUTE: MESSAGE(" ComputeState = FAILED_TO_COMPUTE");break;
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_subMesh::ComputeStateEngine(int event)
+ throw (SALOME_Exception)
+{
+ //MESSAGE("SMESH_subMesh::ComputeStateEngine");
+ //SCRUTE(_computeState);
+ //SCRUTE(event);
+
+ int dim = SMESH_Gen::GetShapeDim(_subShape);
+
+ if (dim < 1)
+ {
+ if (_vertexSet) _computeState = COMPUTE_OK;
+ else _computeState = READY_TO_COMPUTE;
+ //SCRUTE(_computeState);
+ return true;
+ }
+ SMESH_Gen* gen =_father->GetGen();
+ SMESH_Algo* algo = 0;
+ bool ret;
+
+ switch(_computeState)
+ {
+
+ // ----------------------------------------------------------------------
+
+ case NOT_READY:
+ switch (event)
+ {
+ case MODIF_HYP: // nothing to do
+ break;
+ case MODIF_ALGO_STATE:
+ if (_algoState == HYP_OK)
+ _computeState = READY_TO_COMPUTE;
+ break;
+ case COMPUTE: // nothing to do
+ break;
+ case CLEAN: // nothing to do
+ break;
+ case CLEANDEP: // nothing to do
+ RemoveSubMeshElementsAndNodes(); // recursive call...
+ break;
+ case SUBMESH_COMPUTED: // nothing to do
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ break;
+
+ // ----------------------------------------------------------------------
+
+ case READY_TO_COMPUTE:
+ switch (event)
+ {
+ case MODIF_HYP: // nothing to do
+ break;
+ case MODIF_ALGO_STATE:
+ _computeState = NOT_READY;
+ algo = gen->GetAlgo((*_father), _subShape);
+ if (algo)
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) _computeState = READY_TO_COMPUTE;
+ }
+ break;
+ case COMPUTE:
+ {
+ algo = gen->GetAlgo((*_father), _subShape);
+ ASSERT(algo);
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (! ret)
+ {
+ MESSAGE("***** verify compute state *****");
+ _computeState = NOT_READY;
+ break;
+ }
+ ret = SubMeshesComputed();
+ if (!ret)
+ {
+ MESSAGE("Some SubMeshes not computed");
+ _computeState = FAILED_TO_COMPUTE;
+ break;
+ }
+ ret = algo->Compute((*_father),_subShape);
+ if (!ret)
+ {
+ MESSAGE("problem in algo execution: failed to compute");
+ _computeState = FAILED_TO_COMPUTE;
+ break;
+ }
+ else
+ {
+ _computeState = COMPUTE_OK;
+ UpdateDependantsState(); // send event SUBMESH_COMPUTED
+ }
+ }
+ break;
+ case CLEAN:
+ _computeState = NOT_READY;
+ algo = gen->GetAlgo((*_father), _subShape);
+ if (algo)
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) _computeState = READY_TO_COMPUTE;
+ }
+ break;
+ case CLEANDEP:
+ RemoveSubMeshElementsAndNodes();
+ _computeState = NOT_READY;
+ algo = gen->GetAlgo((*_father), _subShape);
+ if (algo)
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) _computeState = READY_TO_COMPUTE;
+ }
+ break;
+ case SUBMESH_COMPUTED: // nothing to do
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ break;
+
+ // ----------------------------------------------------------------------
+
+ case COMPUTE_OK:
+ switch (event)
+ {
+ case MODIF_HYP:
+ CleanDependants(); // recursive recall with event CLEANDEP
+ break;
+ case MODIF_ALGO_STATE:
+ CleanDependants(); // recursive recall with event CLEANDEP
+ break;
+ case COMPUTE: // nothing to do
+ break;
+ case CLEAN:
+ CleanDependants(); // recursive recall with event CLEANDEP
+ break;
+ case CLEANDEP:
+ RemoveSubMeshElementsAndNodes();
+ _computeState = NOT_READY;
+ algo = gen->GetAlgo((*_father), _subShape);
+ if (algo)
+ {
+ ret = algo->CheckHypothesis((*_father),_subShape);
+ if (ret) _computeState = READY_TO_COMPUTE;
+ }
+ break;
+ case SUBMESH_COMPUTED: // nothing to do
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ break;
+
+ // ----------------------------------------------------------------------
+
+ case FAILED_TO_COMPUTE:
+ switch (event)
+ {
+ case MODIF_HYP:
+ if (_algoState == HYP_OK)
+ _computeState = READY_TO_COMPUTE;
+ else _computeState = NOT_READY;
+ break;
+ case MODIF_ALGO_STATE:
+ if (_algoState == HYP_OK)
+ _computeState = READY_TO_COMPUTE;
+ else _computeState = NOT_READY;
+ break;
+ case COMPUTE: // nothing to do
+ break;
+ case CLEAN:
+ break;
+ case CLEANDEP:
+ RemoveSubMeshElementsAndNodes();
+ if (_algoState == HYP_OK)
+ _computeState = READY_TO_COMPUTE;
+ else _computeState = NOT_READY;
+ break;
+ case SUBMESH_COMPUTED: // allow retry compute
+ if (_algoState == HYP_OK)
+ _computeState = READY_TO_COMPUTE;
+ else _computeState = NOT_READY;
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ break;
+
+ // ----------------------------------------------------------------------
+ default:
+ ASSERT(0);
+ break;
+ }
+
+ //SCRUTE(_computeState);
+ return ret;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_subMesh::UpdateDependantsState()
+{
+ //MESSAGE("SMESH_subMesh::UpdateDependantsState");
+
+ const map<int, SMESH_subMesh*>& dependants = Dependants();
+ map<int, SMESH_subMesh*>::const_iterator its;
+ for (its = dependants.begin(); its != dependants.end(); its++)
+ {
+ SMESH_subMesh* sm = (*its).second;
+ //SCRUTE((*its).first);
+ sm->ComputeStateEngine(SUBMESH_COMPUTED);
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_subMesh::CleanDependants()
+{
+ MESSAGE("SMESH_subMesh::CleanDependants");
+ // **** parcourir les ancetres dans l'ordre de dépendance
+
+ const map<int, SMESH_subMesh*>& dependants = Dependants();
+ map<int, SMESH_subMesh*>::const_iterator its;
+ for (its = dependants.begin(); its != dependants.end(); its++)
+ {
+ SMESH_subMesh* sm = (*its).second;
+ SCRUTE((*its).first);
+ sm->ComputeStateEngine(CLEANDEP);
+ }
+ ComputeStateEngine(CLEANDEP);
+}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_subMesh::RemoveSubMeshElementsAndNodes()
+{
+ MESSAGE("SMESH_subMesh::RemoveSubMeshElementsAndNodes");
+ SCRUTE(_subShape.ShapeType());
+ SCRUTE(_Id);
+
+ _subMeshDS = _meshDS->MeshElements(_subShape);
+ if (!_subMeshDS.IsNull())
+ {
+ const TColStd_ListOfInteger& indElt
+ = _subMeshDS->GetIDElements();
+ TColStd_ListIteratorOfListOfInteger ite(indElt);
+ for (; ite.More(); ite.Next())
+ {
+ int eltId = ite.Value();
+ SCRUTE(eltId);
+ Handle (SMDS_MeshElement) elt = _meshDS->FindElement(eltId);
+ _subMeshDS->RemoveElement(elt);
+ _meshDS->RemoveElement(eltId);
+ }
+
+ const TColStd_ListOfInteger& indNodes
+ = _subMeshDS->GetIDNodes();
+ TColStd_ListIteratorOfListOfInteger itn(indNodes);
+ for (; itn.More(); itn.Next())
+ {
+ int nodeId = itn.Value();
+ SCRUTE(nodeId);
+ Handle (SMDS_MeshElement) elt = _meshDS->FindNode(nodeId);
+ Handle (SMDS_MeshNode) node = _meshDS->GetNode(1, elt);
+ _subMeshDS->RemoveNode(node);
+ _meshDS->RemoveNode(nodeId);
+ }
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+const map<int, SMESH_subMesh*>& SMESH_subMesh::Dependants()
+{
+ if (_dependantsFound) return _mapDependants;
+
+ //MESSAGE("SMESH_subMesh::Dependants");
+
+ int shapeType = _subShape.ShapeType();
+ //SCRUTE(shapeType);
+ TopTools_IndexedDataMapOfShapeListOfShape M;
+ TopoDS_Shape mainShape = _meshDS->ShapeToMesh();
+
+ switch (shapeType)
+ {
+ case TopAbs_VERTEX:
+ break;
+ case TopAbs_EDGE:
+ case TopAbs_WIRE:
+ TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_WIRE, M);
+ TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_FACE, M);
+ TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_SHELL, M);
+ TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_SOLID, M);
+ TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_COMPSOLID, M);
+ ExtractDependants(M, TopAbs_EDGE);
+ break;
+ case TopAbs_FACE:
+ case TopAbs_SHELL:
+ TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_SHELL, M);
+ TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_SOLID, M);
+ TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_COMPSOLID, M);
+ ExtractDependants(M, TopAbs_FACE);
+ break;
+ case TopAbs_SOLID:
+ case TopAbs_COMPSOLID:
+ TopExp::MapShapesAndAncestors(mainShape, TopAbs_SOLID, TopAbs_COMPSOLID, M);
+ ExtractDependants(M, TopAbs_SOLID);
+ break;
+ case TopAbs_COMPOUND:
+ break;
+ }
+
+ _dependantsFound = true;
+ return _mapDependants;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_subMesh::ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape& M,
+ const TopAbs_ShapeEnum etype)
+{
+ //MESSAGE("SMESH_subMesh::ExtractDependants");
+
+ TopoDS_Shape mainShape = _meshDS->ShapeToMesh();
+ int lg = M.Extent();
+ //SCRUTE(lg);
+
+ int shapeType = _subShape.ShapeType();
+ switch (shapeType)
+ {
+ case TopAbs_VERTEX:
+ break;
+ case TopAbs_EDGE:
+ case TopAbs_FACE:
+ case TopAbs_SOLID:
+ {
+ const TopTools_ListOfShape& ancestors = M.FindFromKey(_subShape);
+ TopTools_ListIteratorOfListOfShape it(ancestors);
+ for ( ; it.More();it.Next())
+ {
+ TopoDS_Shape ancestor = it.Value();
+ SMESH_subMesh* aSubMesh = _father->GetSubMeshContaining(ancestor);
+ // if (! aSubMesh) aSubMesh = _father->GetSubMesh(ancestor);
+ if (aSubMesh)
+ {
+ int type = aSubMesh->_subShape.ShapeType();
+ int cle = aSubMesh->GetId();
+ cle += 10000000 * type; // sort map by ordType then index
+ if (_mapDependants.find(cle) == _mapDependants.end())
+ {
+ _mapDependants[cle] = aSubMesh;
+ //SCRUTE(cle);
+ }
+ }
+ }
+ }
+ break;
+ case TopAbs_WIRE:
+ case TopAbs_SHELL:
+ case TopAbs_COMPSOLID:
+ for (TopExp_Explorer expE(_subShape, etype); expE.More(); expE.Next())
+ {
+ TopoDS_Shape aShape = expE.Current();
+ const TopTools_ListOfShape& ancestors = M.FindFromKey( aShape);
+ TopTools_ListIteratorOfListOfShape it(ancestors);
+ for ( ; it.More();it.Next())
+ {
+ MESSAGE("---");
+ TopoDS_Shape ancestor = it.Value();
+ SMESH_subMesh* aSubMesh = _father->GetSubMeshContaining(ancestor);
+ if (! aSubMesh) aSubMesh = _father->GetSubMesh(ancestor);
+ int type = aSubMesh->_subShape.ShapeType();
+ int cle = aSubMesh->GetId();
+ cle += 10000000 * type; // sort map by ordType then index
+ if (_mapDependants.find(cle) == _mapDependants.end())
+ {
+ _mapDependants[cle] = aSubMesh;
+ SCRUTE(cle);
+ }
+ }
+ }
+ break;
+ case TopAbs_COMPOUND:
+ break;
+ }
+}
+
--- /dev/null
+//=============================================================================
+// File : SMESH_subMesh.hxx
+// Created : jeu mai 30 13:28:36 CEST 2002
+// Author : Paul RASCLE, EDF
+// Project : SALOME
+// Copyright : EDF 2002
+// $Header$
+//=============================================================================
+
+#ifndef _SMESH_SUBMESH_HXX_
+#define _SMESH_SUBMESH_HXX_
+
+#include "SMESHDS_Mesh.hxx"
+#include "SMESHDS_SubMesh.hxx"
+#include "Utils_SALOME_Exception.hxx"
+#include <TopoDS_Shape.hxx>
+#include <TColStd_IndexedMapOfTransient.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+
+#include <set>
+#include <list>
+#include <map>
+
+class SMESH_Mesh;
+class SMESH_Hypothesis;
+
+class SMESH_subMesh
+{
+public:
+ SMESH_subMesh(int Id,
+ SMESH_Mesh* father,
+ const Handle(SMESHDS_Mesh)& meshDS,
+ const TopoDS_Shape & aSubShape);
+ virtual ~SMESH_subMesh();
+
+ int GetId();
+
+// bool Contains(const TopoDS_Shape & aSubShape)
+// throw (SALOME_Exception);
+
+ const Handle(SMESHDS_SubMesh)& GetSubMeshDS()
+ throw (SALOME_Exception);
+
+ SMESH_subMesh* GetFirstToCompute()
+ throw (SALOME_Exception);
+
+ const map<int, SMESH_subMesh*>& DependsOn();
+ const map<int, SMESH_subMesh*>& Dependants();
+
+ const TopoDS_Shape& GetSubShape();
+
+ bool _vertexSet; // only for vertex subMesh, set to false for dim > 0
+
+ enum compute_state { NOT_READY, READY_TO_COMPUTE,
+ COMPUTE_OK, FAILED_TO_COMPUTE };
+ enum algo_state { NO_ALGO, MISSING_HYP, HYP_OK };
+ enum algo_event {ADD_HYP, ADD_ALGO,
+ REMOVE_HYP, REMOVE_ALGO,
+ ADD_FATHER_HYP, ADD_FATHER_ALGO,
+ REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO};
+ enum compute_event {MODIF_HYP, MODIF_ALGO_STATE, COMPUTE,
+ CLEAN, CLEANDEP, SUBMESH_COMPUTED};
+
+ bool AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
+ throw (SALOME_Exception);
+
+ void SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
+ throw (SALOME_Exception);
+
+ void DumpAlgoState(bool isMain);
+
+ bool ComputeStateEngine(int event)
+ throw (SALOME_Exception);
+
+ int GetComputeState() {return _computeState;};
+
+protected:
+ void InsertDependence(const TopoDS_Shape aSubShape);
+// void FinalizeDependence(list<TopoDS_Shape>& shapeList);
+
+ bool SubMeshesComputed()
+ throw (SALOME_Exception);
+
+ bool SubMeshesReady();
+
+ void RemoveSubMeshElementsAndNodes();
+ void UpdateDependantsState();
+ void CleanDependants();
+ void ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape& M,
+ const TopAbs_ShapeEnum etype);
+ void SetAlgoState(int state);
+
+ TopoDS_Shape _subShape;
+ Handle (SMESHDS_Mesh) _meshDS;
+ Handle (SMESHDS_SubMesh) _subMeshDS;
+ int _Id;
+ SMESH_Mesh* _father;
+ map<int, SMESH_subMesh*> _mapDepend;
+ map<int, SMESH_subMesh*> _mapDependants;
+ bool _dependenceAnalysed;
+ bool _dependantsFound;
+
+ int _algoState;
+ int _oldAlgoState;
+ int _computeState;
+
+};
+
+#endif