mesh_angle.png \
mesh_area.png \
mesh_aspect.png \
+mesh_aspect_3d.png \
mesh_compute.png \
mesh_connectivity.png \
mesh_diagonal.png \
standard_mesh_info.png \
mesh_init.png \
mesh_length.png \
+mesh_length_2d.png \
mesh_free_edges.png \
+mesh_free_edges_2d.png \
mesh_multi_edges.png \
+mesh_multi_edges_2d.png \
mesh_line_n.png \
mesh_line.png \
mesh_move_node.png \
mesh_renumbering_nodes.png \
mesh_renumbering_elements.png \
mesh_extrusion.png \
+mesh_extrusionpath.png \
mesh_revolution.png \
ModuleMesh.png \
mesh_unionGroups.png \
flight_solid.brep \
mesh_pattern.png \
pattern_sample_2d.png \
-pattern_sample_3D.png
+pattern_sample_3D.png \
+mesh_add.png \
+mesh_remove.png
BIN_SCRIPT= \
VERSION
HDF5_LIBS=@HDF5_LIBS@
HDF5_MT_LIBS=@HDF5_MT_LIBS@
-# MED2
-
-MED2_INCLUDES=@MED2_INCLUDES@
-MED2_LIBS=@MED2_LIBS@
-MED2_MT_LIBS=@MED2_MT_LIBS@
-
# OpenCasCade
OCC_INCLUDES=@CAS_CPPFLAGS@
ac_cxx_namespaces.m4 check_omniorb.m4 pyembed.m4 \
ac_cxx_partial_specialization.m4 check_opengl.m4 python.m4 \
ac_cxx_typename.m4 check_pthreads.m4 check_cas.m4 \
-ac_cc_warnings.m4 check_qt.m4 check_med2.m4 \
-check_swig.m4 check_boost.m4
+ac_cc_warnings.m4 check_qt.m4 check_boost.m4 \
+check_swig.m4
$(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%)
cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files
CHECK_HDF5
-echo
-echo ---------------------------------------------
-echo testing MED2
-echo ---------------------------------------------
-echo
-
-CHECK_MED2
-
echo
echo ---------------------------------------------
echo Testing OpenCascade
echo
echo Configure
-variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok Med_ok"
+variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok Med_ok"
for var in $variables
do
@COMMENCE@
+PYTHON_SCRIPTS = \
+ meshpy.py
+
docs:
cp -fr $(srcdir)/SMESH ./INPUT; \
cd INPUT; \
sed 's|../../../share/salome|$(root_srcdir)|' ./doxyfile > ./doxyfile1; \
mv -f doxyfile1 doxyfile; \
$(doxygen) ./doxyfile; \
- cd ..; \
+ mkdir py1; mkdir py2; \
+ cd ..
+ for file in $(PYTHON_SCRIPTS) dummy; do \
+ if [ $$file != "dummy" ]; then \
+ cp $(root_srcdir)/src/SMESH_SWIG/$$file INPUT/py1/; \
+ fi ; \
+ done
+ cd INPUT; \
+ python $(KERNEL_ROOT_DIR)/doc/salome/tui/KERNEL/pythfilter.py ./py1 ./py2; \
+ sed 's|list_py_files_to_process|$(PYTHON_SCRIPTS)|' ./doxyfile_py > py2/doxyfile_py; \
+ cd py2; \
+ $(doxygen) ./doxyfile_py; \
+ cd ../..; \
cp -fr $(srcdir)/SMESH/sources/static/*.* ./SMESH/
cp -fr $(srcdir)/SMESH/sources/ SMESH/
cp -fr $(srcdir)/SMESH/HTML/ SMESH/
--- /dev/null
+# Doxyfile 1.3-rc1
+
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = "SALOME - SMESH - v.2.1.0"
+PROJECT_NUMBER = id#1.1
+OUTPUT_DIRECTORY = ../
+OUTPUT_LANGUAGE = English
+EXTRACT_ALL = YES
+EXTRACT_PRIVATE = YES
+EXTRACT_STATIC = YES
+EXTRACT_LOCAL_CLASSES = YES
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = NO
+ALWAYS_DETAILED_SEC = YES
+INLINE_INHERITED_MEMB = YES
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+INTERNAL_DOCS = YES
+CASE_SENSE_NAMES = YES
+SHORT_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+VERBATIM_HEADERS = YES
+SHOW_INCLUDE_FILES = YES
+JAVADOC_AUTOBRIEF = YES
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = NO
+INHERIT_DOCS = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = NO
+DISTRIBUTE_GROUP_DOC = NO
+TAB_SIZE = 5
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ALIASES =
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 25
+OPTIMIZE_OUTPUT_FOR_C = YES
+OPTIMIZE_OUTPUT_JAVA = YES
+SHOW_USED_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE = log.txt
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = list_py_files_to_process
+FILE_PATTERNS =
+RECURSIVE = NO
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS =
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH = ../sources/
+INPUT_FILTER =
+FILTER_SOURCE_FILES = YES
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = ../SMESH/meshpy_doc
+HTML_FILE_EXTENSION = .html
+HTML_HEADER = ../sources/myheader_py2.html
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+BINARY_TOC = YES
+TOC_EXPAND = YES
+DISABLE_INDEX = YES
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = YES
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = NO
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+XML_SCHEMA =
+XML_DTD =
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = YES
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = NO
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HIDE_UNDOC_RELATIONS = NO
+HAVE_DOT = YES
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = NO
+TEMPLATE_RELATIONS = YES
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DOT_IMAGE_FORMAT = jpg
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1200
+GENERATE_LEGEND = NO
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
+CGI_NAME = search.cgi
+CGI_URL =
+DOC_URL =
+DOC_ABSPATH =
+BIN_ABSPATH = /usr/local/bin/
+EXT_DOC_PATHS =
--- /dev/null
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.73 [en] (WinNT; I) [Netscape]">
+ <title>Main Page</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+</head>
+<body>
+
+<center><table WIDTH="96%" >
+<tr>
+<td><a href="http://www.opencascade.com"><img src="../sources/logocorp.gif" BORDER=0 height=46 width=122></a></td>
+
+
+<td>
+<div align=right><a href="http://www.opencascade.org/SALOME/"><img src="../sources/application.gif" BORDER=0 height=46 width=108></a></div>
+</td>
+</tr>
+</table></center>
+
+
+</body>
+</html>
aux1 = insFld(foldersTree, gFld("IDL/Python mapping", ""))
insDoc(aux1, gLnk("Mapping of SMESH IDL definitions to Python language", "", "page2.html"))
+
+aux1 = insFld(foldersTree, gFld("Python Commands", "", "meshpy_doc/main.html"))
+ insDoc(aux1, gLnk("Package List", "", "meshpy_doc/namespaces.html"))
+ insDoc(aux1, gLnk("Data Structures", "", "meshpy_doc/annotated.html"))
+ insDoc(aux1, gLnk("Namespace Members", "", "meshpy_doc/namespacemembers.html"))
+ insDoc(aux1, gLnk("File List", "", "meshpy_doc/files.html"))
+
aux1 = insFld(foldersTree, gFld("Adding meshers in SMESH", ""))
insDoc(aux1, gLnk("Using Plugin mechanism in SMESH", "", "PluginMeshers.html"))
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
-// \r
-// This library is free software; you can redistribute it and/or \r
-// modify it under the terms of the GNU Lesser General Public \r
-// License as published by the Free Software Foundation; either \r
-// version 2.1 of the License. \r
-// \r
-// This library is distributed in the hope that it will be useful, \r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \r
-// Lesser General Public License for more details. \r
-// \r
-// You should have received a copy of the GNU Lesser General Public \r
-// License along with this library; if not, write to the Free Software \r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA \r
-// \r
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
-//\r
-//\r
-//\r
-// File : SMESH_Filter.idl\r
-// Author : Alexey Petrov, OCC\r
-\r
-#ifndef _SMESH_FILTER_IDL_\r
-#define _SMESH_FILTER_IDL_\r
-\r
-#include "SALOME_Exception.idl"\r
-#include "SALOME_GenericObj.idl"\r
-#include "SMESH_Mesh.idl"\r
-\r
-\r
-module GEOM\r
-{\r
- interface GEOM_Object;\r
-};\r
-\r
-\r
-module SMESH\r
-{\r
-\r
- /*!\r
- * Enumeration of functor types\r
- */\r
- enum FunctorType\r
- {\r
- FT_AspectRatio,\r
- FT_Warping, \r
- FT_MinimumAngle,\r
- FT_Taper, \r
- FT_Skew, \r
- FT_Area, \r
- FT_FreeBorders,\r
- FT_FreeEdges,\r
- FT_MultiConnection,\r
- FT_Length,\r
- FT_BelongToGeom,\r
- FT_BelongToPlane,\r
- FT_BelongToCylinder,\r
- FT_RangeOfIds,\r
- FT_LessThan,\r
- FT_MoreThan,\r
- FT_EqualTo,\r
- FT_LogicalNOT,\r
- FT_LogicalAND,\r
- FT_LogicalOR,\r
- FT_Undefined\r
- };\r
-\r
- /*!\r
- * Base interface for all functors ( i.e. numerical functors and predicates )\r
- */\r
- interface Functor: SALOME::GenericObj\r
- {\r
- void SetMesh( in SMESH_Mesh theMesh );\r
- FunctorType GetFunctorType();\r
- ElementType GetElementType();\r
- };\r
-\r
-\r
-\r
- /*!\r
- * Numerical functors are intended for calculating value by Id of mesh entity\r
- */\r
- interface NumericalFunctor: Functor\r
- {\r
- double GetValue( in long theElementId );\r
-\r
- /*!\r
- * Set precision for calculation. It is a position after point which is\r
- * used to functor value after calculation.\r
- */\r
- void SetPrecision( in long thePrecision );\r
- long GetPrecision();\r
- };\r
- interface MinimumAngle : NumericalFunctor{};\r
- interface AspectRatio : NumericalFunctor{};\r
- interface Warping : NumericalFunctor{};\r
- interface Taper : NumericalFunctor{};\r
- interface Skew : NumericalFunctor{};\r
- interface Area : NumericalFunctor{};\r
- interface Length : NumericalFunctor{};\r
- interface MultiConnection : NumericalFunctor{};\r
-\r
- /*!\r
- * Predicates are intended for verification of criteria,\r
- * must return bool value by mesh id\r
- */\r
- interface Predicate: Functor\r
- {\r
- boolean IsSatisfy( in long thEntityId );\r
- };\r
-\r
- /*!\r
- * Logical functor (predicate) "Belong To Geometry".\r
- * Verify whether mesh element or node belong to pointed Geom Object\r
- */\r
- interface BelongToGeom: Predicate\r
- {\r
- void SetGeom( in GEOM::GEOM_Object theGeom );\r
- void SetElementType( in ElementType theType );\r
-\r
- void SetShapeName( in string theName );\r
- string GetShapeName(); \r
- };\r
-\r
- /*!\r
- * Logical functor (predicate) "Belong To Surface".\r
- * Base interface for "belong to plane" and "belong to cylinder interfaces"\r
- */\r
- interface BelongToSurface: Predicate\r
- {\r
- void SetTolerance( in double theToler );\r
- double GetTolerance();\r
- void SetShapeName( in string theName, in ElementType theType );\r
- string GetShapeName();\r
- };\r
-\r
-\r
- /*!\r
- * Logical functor (predicate) "Belong To Plane".\r
- * Verify whether mesh element lie in pointed Geom planar object\r
- */\r
- interface BelongToPlane: BelongToSurface\r
- {\r
- void SetPlane( in GEOM::GEOM_Object theGeom, in ElementType theType );\r
- };\r
-\r
- /*!\r
- * Logical functor (predicate) "Belong To Culinder".\r
- * Verify whether mesh element lie in pointed Geom cylindrical object\r
- */\r
- interface BelongToCylinder: BelongToSurface\r
- {\r
- void SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType );\r
- };\r
-\r
- /*!\r
- * Logical functor (predicate) "Free borders".\r
- * Verify whether 1D mesh element is free ( i.e. connected to one face only )\r
- */\r
- interface FreeBorders: Predicate{};\r
-\r
- /*!\r
- * Logical functor (predicate) "Free edges".\r
- * Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )\r
- */\r
- interface FreeEdges: Predicate\r
-\r
- {\r
- struct Border\r
- {\r
- long myElemId;\r
- long myPnt1, myPnt2;\r
- };\r
- typedef sequence<Border> Borders;\r
- Borders GetBorders();\r
- };\r
-\r
-\r
- /*!\r
- * Abstract logical functor (predicate) "RangeOfIds".\r
- * Verify whether an Entity Id belongs to defined sequence of id's\r
- */\r
- interface RangeOfIds: Predicate\r
- {\r
- void SetRange( in long_array theIds );\r
- boolean SetRangeStr( in string theRange );\r
- string GetRangeStr();\r
-\r
- void SetElementType( in ElementType theType );\r
- };\r
-\r
- /*!\r
- * Comparator. Predicate for compare value calculated\r
- * by numerical functor with threshold value\r
- */\r
- interface Comparator: Predicate\r
- {\r
- void SetMargin( in double theValue );\r
- void SetNumFunctor( in NumericalFunctor theFunct );\r
- double GetMargin();\r
- };\r
- interface LessThan: Comparator{};\r
- interface MoreThan: Comparator{};\r
- interface EqualTo : Comparator\r
- {\r
- void SetTolerance( in double theToler );\r
- double GetTolerance();\r
- };\r
-\r
- /*!\r
- * Logical predicates are intended for compose predicates using boolean operations\r
- */\r
- interface Logical: Predicate{};\r
-\r
- interface LogicalNOT: Logical\r
- {\r
- void SetPredicate(in Predicate thePredicate);\r
- };\r
-\r
- interface LogicalBinary: Logical\r
-{\r
- void SetPredicate1( in Predicate thePredicate );\r
- void SetPredicate2( in Predicate thePredicate );\r
- };\r
-\r
- interface LogicalAND: LogicalBinary{};\r
- interface LogicalOR : LogicalBinary{};\r
-\r
- /*!\r
- * Filter\r
- */\r
- interface Filter: SALOME::GenericObj\r
- {\r
- /*!\r
- * Structure containing information about one criterion\r
- * Type - FT_Taper, FT_Skew ...\r
- * Compare - FT_LessThan, FT_MoreThan, FT_EqualTo\r
- * Threshold - threshold value\r
- * UnaryOp - unary logical operation: FT_LogicalNOT or FT_Undefined\r
- * BinaryOp - binary logical operation FT_LogicalAND, FT_LogicalOR or\r
- * (FT_Undefined must be for the last criterion)\r
- * ThresholdStr - Threshold value defined as string. Used for:\r
- * 1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29"\r
- * 2. BelongToGeom predicate for storing name of shape\r
- * Tolerance - Tolerance is used for comparators (EqualTo comparision) and for\r
- * "Belong to plane" and "Belong to cylinder" predicates\r
- * TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only)\r
- * Precision - Precision of numerical functors\r
- */\r
- struct Criterion\r
- {\r
- long Type;\r
- long Compare;\r
- double Threshold;\r
- string ThresholdStr;\r
- long UnaryOp;\r
- long BinaryOp;\r
- double Tolerance;\r
- ElementType TypeOfElement;\r
- long Precision;\r
- };\r
-\r
- typedef sequence<Criterion> Criteria;\r
-\r
- void SetPredicate( in Predicate thePredicate );\r
- long_array GetElementsId( in SMESH_Mesh theMesh );\r
- ElementType GetElementType();\r
- Predicate GetPredicate();\r
-\r
- boolean GetCriteria( out Criteria theCriteria );\r
- boolean SetCriteria( in Criteria theCriteria );\r
- };\r
-\r
-\r
- /*!\r
- * Interface for working with library of filters\r
- */\r
- interface FilterLibrary : SALOME::GenericObj\r
- {\r
- /*!\r
- * Copy filter from library by name (new filter is created)\r
- */\r
- Filter Copy( in string theFilterName );\r
-\r
- /*!\r
- * Methods for editing library\r
- */\r
- boolean Add ( in string theFilterName, in Filter theFilter );\r
- boolean AddEmpty( in string theFilterName, in ElementType theType ); // add empty filter\r
- boolean Delete ( in string theFilterName );\r
- boolean Replace ( in string theFilterName, in string theNewName, in Filter theFilter );\r
-\r
- /*!\r
- * Save library on disk\r
- */\r
- boolean Save();\r
- boolean SaveAs( in string aFileName );\r
-\r
- /*!\r
- * Query methods\r
- */\r
- boolean IsPresent( in string aFilterName );\r
- long NbFilters( in ElementType aType );\r
- string_array GetNames( in ElementType aType );\r
- string_array GetAllNames();\r
- void SetFileName( in string aFilterName );\r
- string GetFileName();\r
- };\r
-\r
-\r
- /*!\r
- * Interface of Filter manager\r
- */\r
- interface FilterManager: SALOME::GenericObj\r
- {\r
- /*!\r
- * Create numerical functors\r
- */\r
- MinimumAngle CreateMinimumAngle();\r
- AspectRatio CreateAspectRatio();\r
- Warping CreateWarping();\r
- Taper CreateTaper();\r
- Skew CreateSkew();\r
- Area CreateArea();\r
- Length CreateLength();\r
- MultiConnection CreateMultiConnection();\r
-\r
- /*!\r
- * Create logical functors ( predicates )\r
- */\r
- BelongToGeom CreateBelongToGeom();\r
- BelongToPlane CreateBelongToPlane();\r
- BelongToCylinder CreateBelongToCylinder();\r
-\r
- FreeBorders CreateFreeBorders();\r
- FreeEdges CreateFreeEdges();\r
-\r
- RangeOfIds CreateRangeOfIds();\r
-\r
- /*!\r
- * Create comparators ( predicates )\r
- */\r
- LessThan CreateLessThan();\r
- MoreThan CreateMoreThan();\r
- EqualTo CreateEqualTo();\r
-\r
- /*!\r
- * Create boolean operations ( predicates )\r
- */\r
- LogicalNOT CreateLogicalNOT();\r
- LogicalAND CreateLogicalAND();\r
- LogicalOR CreateLogicalOR();\r
-\r
- /*!\r
- * Create filter\r
- */\r
- Filter CreateFilter();\r
-\r
- /*!\r
- * Load filter library. If libary does not exist it is created\r
- */\r
- FilterLibrary LoadLibrary( in string aFileName );\r
-\r
- /*!\r
- * Create new library\r
- */\r
- FilterLibrary CreateLibrary();\r
-\r
- /*!\r
- * Delete library\r
- */\r
- boolean DeleteLibrary( in string aFileName );\r
- };\r
-};\r
-\r
-\r
-#endif\r
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESH_Filter.idl
+// Author : Alexey Petrov, OCC
+
+#ifndef _SMESH_FILTER_IDL_
+#define _SMESH_FILTER_IDL_
+
+#include "SALOME_Exception.idl"
+#include "SALOME_GenericObj.idl"
+#include "SMESH_Mesh.idl"
+
+
+module GEOM
+{
+ interface GEOM_Object;
+};
+
+
+module SMESH
+{
+
+ /*!
+ * Enumeration of functor types
+ */
+ enum FunctorType
+ {
+ FT_AspectRatio,
+ FT_AspectRatio3D,
+ FT_Warping,
+ FT_MinimumAngle,
+ FT_Taper,
+ FT_Skew,
+ FT_Area,
+ FT_FreeBorders,
+ FT_FreeEdges,
+ FT_MultiConnection,
+ FT_MultiConnection2D,
+ FT_Length,
+ FT_Length2D,
+ FT_BelongToGeom,
+ FT_BelongToPlane,
+ FT_BelongToCylinder,
+ FT_LyingOnGeom,
+ FT_RangeOfIds,
+ FT_LessThan,
+ FT_MoreThan,
+ FT_EqualTo,
+ FT_LogicalNOT,
+ FT_LogicalAND,
+ FT_LogicalOR,
+ FT_Undefined
+ };
+
+ /*!
+ * Base interface for all functors ( i.e. numerical functors and predicates )
+ */
+ interface Functor: SALOME::GenericObj
+ {
+ void SetMesh( in SMESH_Mesh theMesh );
+ FunctorType GetFunctorType();
+ ElementType GetElementType();
+ };
+
+
+
+ /*!
+ * Numerical functors are intended for calculating value by Id of mesh entity
+ */
+ interface NumericalFunctor: Functor
+ {
+ double GetValue( in long theElementId );
+
+ /*!
+ * Set precision for calculation. It is a position after point which is
+ * used to functor value after calculation.
+ */
+ void SetPrecision( in long thePrecision );
+ long GetPrecision();
+ };
+ interface MinimumAngle : NumericalFunctor{};
+ interface AspectRatio : NumericalFunctor{};
+ interface AspectRatio3D : NumericalFunctor{};
+ interface Warping : NumericalFunctor{};
+ interface Taper : NumericalFunctor{};
+ interface Skew : NumericalFunctor{};
+ interface Area : NumericalFunctor{};
+ interface Length : NumericalFunctor{};
+ interface Length2D : NumericalFunctor
+ {
+ struct Value
+ {
+ double myLength;
+ long myPnt1, myPnt2;
+ };
+ typedef sequence<Value> Values;
+ Values GetValues();
+ };
+ interface MultiConnection : NumericalFunctor{};
+ interface MultiConnection2D : NumericalFunctor
+ {
+ struct Value
+ {
+ long myNbConnects;
+ long myPnt1, myPnt2;
+ };
+
+ typedef sequence<Value> Values;
+ Values GetValues();
+ };
+
+ /*!
+ * Predicates are intended for verification of criteria,
+ * must return bool value by mesh id
+ */
+ interface Predicate: Functor
+ {
+ boolean IsSatisfy( in long thEntityId );
+ };
+
+ /*!
+ * Logical functor (predicate) "Belong To Geometry".
+ * Verify whether mesh element or node belong to pointed Geom Object
+ */
+ interface BelongToGeom: Predicate
+ {
+ void SetGeom( in GEOM::GEOM_Object theGeom );
+ void SetElementType( in ElementType theType );
+
+ void SetShapeName( in string theName );
+ string GetShapeName();
+ };
+
+ /*!
+ * Logical functor (predicate) "Belong To Surface".
+ * Base interface for "belong to plane" and "belong to cylinder interfaces"
+ */
+ interface BelongToSurface: Predicate
+ {
+ void SetTolerance( in double theToler );
+ double GetTolerance();
+ void SetShapeName( in string theName, in ElementType theType );
+ string GetShapeName();
+ };
+
+
+ /*!
+ * Logical functor (predicate) "Belong To Plane".
+ * Verify whether mesh element lie in pointed Geom planar object
+ */
+ interface BelongToPlane: BelongToSurface
+ {
+ void SetPlane( in GEOM::GEOM_Object theGeom, in ElementType theType );
+ };
+
+ /*!
+ * Logical functor (predicate) "Belong To Culinder".
+ * Verify whether mesh element lie in pointed Geom cylindrical object
+ */
+ interface BelongToCylinder: BelongToSurface
+ {
+ void SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType );
+ };
+
+ /*!
+ * Logical functor (predicate) "Lying On Geometry".
+ * Verify whether mesh element or node lying or partially lying on the pointed Geom Object
+ */
+ interface LyingOnGeom: Predicate
+ {
+ void SetGeom( in GEOM::GEOM_Object theGeom );
+ void SetElementType( in ElementType theType );
+
+ void SetShapeName( in string theName );
+ string GetShapeName();
+ };
+
+ /*!
+ * Logical functor (predicate) "Free borders".
+ * Verify whether 1D mesh element is free ( i.e. connected to one face only )
+ */
+ interface FreeBorders: Predicate{};
+
+ /*!
+ * Logical functor (predicate) "Free edges".
+ * Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )
+ */
+ interface FreeEdges: Predicate
+
+ {
+ struct Border
+ {
+ long myElemId;
+ long myPnt1, myPnt2;
+ };
+ typedef sequence<Border> Borders;
+ Borders GetBorders();
+ };
+
+
+ /*!
+ * Abstract logical functor (predicate) "RangeOfIds".
+ * Verify whether an Entity Id belongs to defined sequence of id's
+ */
+ interface RangeOfIds: Predicate
+ {
+ void SetRange( in long_array theIds );
+ boolean SetRangeStr( in string theRange );
+ string GetRangeStr();
+
+ void SetElementType( in ElementType theType );
+ };
+
+ /*!
+ * Comparator. Predicate for compare value calculated
+ * by numerical functor with threshold value
+ */
+ interface Comparator: Predicate
+ {
+ void SetMargin( in double theValue );
+ void SetNumFunctor( in NumericalFunctor theFunct );
+ double GetMargin();
+ };
+ interface LessThan: Comparator{};
+ interface MoreThan: Comparator{};
+ interface EqualTo : Comparator
+ {
+ void SetTolerance( in double theToler );
+ double GetTolerance();
+ };
+
+ /*!
+ * Logical predicates are intended for compose predicates using boolean operations
+ */
+ interface Logical: Predicate{};
+
+ interface LogicalNOT: Logical
+ {
+ void SetPredicate(in Predicate thePredicate);
+ };
+
+ interface LogicalBinary: Logical
+{
+ void SetPredicate1( in Predicate thePredicate );
+ void SetPredicate2( in Predicate thePredicate );
+ };
+
+ interface LogicalAND: LogicalBinary{};
+ interface LogicalOR : LogicalBinary{};
+
+ /*!
+ * Filter
+ */
+ interface Filter: SALOME::GenericObj
+ {
+ /*!
+ * Structure containing information about one criterion
+ * Type - FT_Taper, FT_Skew ...
+ * Compare - FT_LessThan, FT_MoreThan, FT_EqualTo
+ * Threshold - threshold value
+ * UnaryOp - unary logical operation: FT_LogicalNOT or FT_Undefined
+ * BinaryOp - binary logical operation FT_LogicalAND, FT_LogicalOR or
+ * (FT_Undefined must be for the last criterion)
+ * ThresholdStr - Threshold value defined as string. Used for:
+ * 1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29"
+ * 2. BelongToGeom predicate for storing name of shape
+ * Tolerance - Tolerance is used for comparators (EqualTo comparision) and for
+ * "Belong to plane" and "Belong to cylinder" predicates
+ * TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only)
+ * Precision - Precision of numerical functors
+ */
+ struct Criterion
+ {
+ long Type;
+ long Compare;
+ double Threshold;
+ string ThresholdStr;
+ long UnaryOp;
+ long BinaryOp;
+ double Tolerance;
+ ElementType TypeOfElement;
+ long Precision;
+ };
+
+ typedef sequence<Criterion> Criteria;
+
+ void SetPredicate( in Predicate thePredicate );
+ long_array GetElementsId( in SMESH_Mesh theMesh );
+ ElementType GetElementType();
+ Predicate GetPredicate();
+
+ boolean GetCriteria( out Criteria theCriteria );
+ boolean SetCriteria( in Criteria theCriteria );
+ };
+
+
+ /*!
+ * Interface for working with library of filters
+ */
+ interface FilterLibrary : SALOME::GenericObj
+ {
+ /*!
+ * Copy filter from library by name (new filter is created)
+ */
+ Filter Copy( in string theFilterName );
+
+ /*!
+ * Methods for editing library
+ */
+ boolean Add ( in string theFilterName, in Filter theFilter );
+ boolean AddEmpty( in string theFilterName, in ElementType theType ); // add empty filter
+ boolean Delete ( in string theFilterName );
+ boolean Replace ( in string theFilterName, in string theNewName, in Filter theFilter );
+
+ /*!
+ * Save library on disk
+ */
+ boolean Save();
+ boolean SaveAs( in string aFileName );
+
+ /*!
+ * Query methods
+ */
+ boolean IsPresent( in string aFilterName );
+ long NbFilters( in ElementType aType );
+ string_array GetNames( in ElementType aType );
+ string_array GetAllNames();
+ void SetFileName( in string aFilterName );
+ string GetFileName();
+ };
+
+
+ /*!
+ * Interface of Filter manager
+ */
+ interface FilterManager: SALOME::GenericObj
+ {
+ /*!
+ * Create numerical functors
+ */
+ MinimumAngle CreateMinimumAngle();
+ AspectRatio CreateAspectRatio();
+ AspectRatio3D CreateAspectRatio3D();
+ Warping CreateWarping();
+ Taper CreateTaper();
+ Skew CreateSkew();
+ Area CreateArea();
+ Length CreateLength();
+ Length2D CreateLength2D();
+ MultiConnection CreateMultiConnection();
+ MultiConnection2D CreateMultiConnection2D();
+
+ /*!
+ * Create logical functors ( predicates )
+ */
+ BelongToGeom CreateBelongToGeom();
+ BelongToPlane CreateBelongToPlane();
+ BelongToCylinder CreateBelongToCylinder();
+
+ LyingOnGeom CreateLyingOnGeom();
+
+ FreeBorders CreateFreeBorders();
+ FreeEdges CreateFreeEdges();
+
+ RangeOfIds CreateRangeOfIds();
+
+ /*!
+ * Create comparators ( predicates )
+ */
+ LessThan CreateLessThan();
+ MoreThan CreateMoreThan();
+ EqualTo CreateEqualTo();
+
+ /*!
+ * Create boolean operations ( predicates )
+ */
+ LogicalNOT CreateLogicalNOT();
+ LogicalAND CreateLogicalAND();
+ LogicalOR CreateLogicalOR();
+
+ /*!
+ * Create filter
+ */
+ Filter CreateFilter();
+
+ /*!
+ * Load filter library. If libary does not exist it is created
+ */
+ FilterLibrary LoadLibrary( in string aFileName );
+
+ /*!
+ * Create new library
+ */
+ FilterLibrary CreateLibrary();
+
+ /*!
+ * Delete library
+ */
+ boolean DeleteLibrary( in string aFileName );
+ };
+};
+
+
+#endif
DRS_FAIL // general failure (exception etc.)
};
+ /*!
+ * Enumeration for DriverMED (used by Perform() method)
+ */
+ enum MED_VERSION // in the order of severity
+ {
+ MED_V2_1,
+ MED_V2_2
+ };
+
typedef sequence<log_block> log_array;
raises (SALOME::SALOME_Exception);
/*!
- * Export Mesh with DAT and MED Formats
+ * Export Mesh to MED Formats
*/
- void ExportDAT( in string file )
+ void ExportToMED( in string file, in boolean auto_groups, in MED_VERSION theVersion )
raises (SALOME::SALOME_Exception);
void ExportMED( in string file, in boolean auto_groups )
raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Export Mesh to DAT, UNV and STL Formats
+ */
+ void ExportDAT( in string file )
+ raises (SALOME::SALOME_Exception);
void ExportUNV( in string file )
raises (SALOME::SALOME_Exception);
void ExportSTL( in string file, in boolean isascii )
long NbNodes()
raises (SALOME::SALOME_Exception);
+ long NbElements()
+ raises (SALOME::SALOME_Exception);
+
long NbEdges()
raises (SALOME::SALOME_Exception);
long NbSubMesh()
raises (SALOME::SALOME_Exception);
+ long_array GetElementsId()
+ raises (SALOME::SALOME_Exception);
+
+ long_array GetElementsByType( in ElementType theType )
+ raises (SALOME::SALOME_Exception);
+
+ long_array GetNodesId()
+ raises (SALOME::SALOME_Exception);
+
string Dump();
};
in DirStruct StepVector,
in long NbOfSteps);
+ void ExtrusionAlongPath(in long_array IDsOfElements,
+ in SMESH_Mesh PathMesh,
+ in GEOM::GEOM_Object PathShape,
+ in long NodeStart,
+ in boolean HasAngles,
+ in double_array Angles,
+ in boolean HasRefPoint,
+ in PointStruct RefPoint);
+
+ void ExtrusionAlongPathObject(in SMESH_IDSource theObject,
+ in SMESH_Mesh PathMesh,
+ in GEOM::GEOM_Object PathShape,
+ in long NodeStart,
+ in boolean HasAngles,
+ in double_array Angles,
+ in boolean HasRefPoint,
+ in PointStruct RefPoint);
+
enum MirrorType { POINT, AXIS, PLANE };
void Mirror (in long_array IDsOfElements,
in GEOM::GEOM_Object theVertex000,
in GEOM::GEOM_Object theVertex001);
+ /*!
+ * Compute nodes coordinates applying
+ * the loaded pattern to mesh faces. The first key-point
+ * will be mapped into <theNodeIndexOnKeyPoint1>-th node of each face
+ */
+ point_array ApplyToMeshFaces(in SMESH_Mesh theMesh,
+ in long_array theFacesIDs,
+ in long theNodeIndexOnKeyPoint1,
+ in boolean theReverse);
+
+ /*!
+ * Compute nodes coordinates applying
+ * the loaded pattern to hexahedrons. The (0,0,0) key-point
+ * will be mapped into <theNode000Index>-th node of each volume.
+ * The (0,0,1) key-point will be mapped into <theNode001Index>-th
+ * node of each volume.
+ */
+ point_array ApplyToHexahedrons(in SMESH_Mesh theMesh,
+ in long_array theVolumesIDs,
+ in long theNode000Index,
+ in long theNode001Index);
+
/*!
* Create nodes and elements in <theMesh> using nodes
* coordinates computed by either of Apply...() methods
<!-- ************************** Control (menubar) ************************************ -->
<menu-item label-id="Controls" item-id="60" pos-id="5">
+ <popup-item item-id="6003" pos-id="" label-id="Free Borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<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="Free Edges" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="6003" pos-id="" label-id="Free borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="6004" pos-id="" label-id="Borders at multi-connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6004" pos-id="" label-id="Borders at Multi-Connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="6002" pos-id="" label-id="Free Edges" icon-id="mesh_free_edges_2d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6018" pos-id="" label-id="Length 2D" icon-id="mesh_length_2d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6019" pos-id="" label-id="Borders at Multi-Connection 2D" icon-id="mesh_multi_edges_2d.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="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="Warping" 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=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="6017" pos-id="" label-id="Aspect Ratio 3D" icon-id="mesh_aspect_3d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
</menu-item>
<!-- ************************** Entity (menubar) ************************************ -->
<popup-item item-id="411" pos-id="" label-id="Cutting of quadrangles" icon-id="mesh_cutquad.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="412" pos-id="" label-id="Smoothing" icon-id="mesh_smoothing.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="413" pos-id="" label-id="Extrusion" icon-id="mesh_extrusion.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="416" pos-id="" label-id="Extrusion along a path" icon-id="mesh_extrusionpath.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="414" pos-id="" label-id="Revolution" icon-id="mesh_revolution.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="415" pos-id="" label-id="Pattern mapping" icon-id="mesh_pattern.png" tooltip-id="" accel-id="" toggle-id="" 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="">
+ <submenu label-id="Display Mode" item-id="1000" pos-id="">
<popup-item item-id="10001" pos-id="" label-id="Wireframe" icon-id="mesh_wireframe.png" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
<popup-item item-id="10002" pos-id="" label-id="Shading" icon-id="mesh_shading.png" tooltip-id="" accel-id="" toggle-id="true" execute-action=""/>
<popup-item item-id="10004" pos-id="" label-id="Nodes" icon-id="mesh_points.png" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
<separator pos-id=""/>
<popup-item item-id="1006" pos-id="" label-id="Selection" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<separator pos-id=""/>
- <popup-item item-id="1007" pos-id="" label-id="Quality controls" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <submenu label-id="Quality controls" item-id="1007" pos-id="">
+ <popup-item item-id="10070" pos-id="" label-id="Precision" icon-id="" tooltip-id="" accel-id="" toggle-id="false" execute-action=""/>
+ <popup-item item-id="10071" pos-id="" label-id="Display Entity" icon-id="" tooltip-id="" accel-id="" toggle-id="true" execute-action=""/>
+ </submenu>
+ <endsubmenu />
</submenu>
<endsubmenu />
<separator pos-id="-1"/>
<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 />
+ <submenu label-id="Display Entity" item-id="1135" pos-id="">
+ <popup-item item-id="217" pos-id="" label-id="Edges" icon-id="mesh_line.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="218" pos-id="" label-id="Faces" icon-id="mesh_triangle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="219" pos-id="" label-id="Volumes" icon-id="mesh_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="220" pos-id="" label-id="All" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
<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=""/>
<popup-item item-id="1134" pos-id="" label-id="Clipping" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<separator pos-id=""/>
<submenu label-id="Control" item-id="2000" pos-id="">
- <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="Free Edges" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="6003" pos-id="" label-id="Free borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="6004" pos-id="" label-id="Borders at multi-connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="200" pos-id="" label-id="Reset" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="6003" pos-id="" label-id="Free Borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <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="6004" pos-id="" label-id="Borders at Multi-Connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="6002" pos-id="" label-id="Free Edges" icon-id="mesh_free_edges_2d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6018" pos-id="" label-id="Length 2D" icon-id="mesh_length_2d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6019" pos-id="" label-id="Borders at Multi-Connection 2D" icon-id="mesh_multi_edges_2d.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="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="Warping" 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=""/>
<separator pos-id=""/>
- <popup-item item-id="200" pos-id="" label-id="Reset" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6017" pos-id="" label-id="Aspect Ratio 3D" icon-id="mesh_aspect_3d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<separator pos-id=""/>
<popup-item item-id="201" pos-id="" label-id="Scalar Bar Properties" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
</submenu>
<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 />
+ <submenu label-id="Display Entity" item-id="1135" pos-id="">
+ <popup-item item-id="217" pos-id="" label-id="Edges" icon-id="mesh_line.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="218" pos-id="" label-id="Faces" icon-id="mesh_triangle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="219" pos-id="" label-id="Volumes" icon-id="mesh_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="220" pos-id="" label-id="All" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
<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=""/>
<popup-item item-id="1134" pos-id="" label-id="Clipping" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<separator pos-id=""/>
<submenu label-id="Control" item-id="2000" pos-id="">
- <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="Free Edges" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="6003" pos-id="" label-id="Free borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="6004" pos-id="" label-id="Borders at multi-connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="200" pos-id="" label-id="Reset" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <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="6003" pos-id="" label-id="Free Borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6004" pos-id="" label-id="Borders at Multi-Connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="6002" pos-id="" label-id="Free Edges" icon-id="mesh_free_edges_2d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6018" pos-id="" label-id="Length 2D" icon-id="mesh_length_2d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6019" pos-id="" label-id="Borders at Multi-Connection 2D" icon-id="mesh_multi_edges_2d.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="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="Warping" 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=""/>
<separator pos-id=""/>
- <popup-item item-id="200" pos-id="" label-id="Reset" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6017" pos-id="" label-id="Aspect Ratio 3D" icon-id="mesh_aspect_3d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<separator pos-id=""/>
<popup-item item-id="201" pos-id="" label-id="Scalar Bar Properties" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
</submenu>
<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 />
+ <submenu label-id="Display Entity" item-id="1135" pos-id="">
+ <popup-item item-id="217" pos-id="" label-id="Edges" icon-id="mesh_line.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="218" pos-id="" label-id="Faces" icon-id="mesh_triangle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="219" pos-id="" label-id="Volumes" icon-id="mesh_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="220" pos-id="" label-id="All" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ </submenu>
+ <endsubmenu />
<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=""/>
<popup-item item-id="1134" pos-id="" label-id="Clipping" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<separator pos-id=""/>
<submenu label-id="Control" item-id="2000" pos-id="">
- <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="Free Edges" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="6003" pos-id="" label-id="Free borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
- <popup-item item-id="6004" pos-id="" label-id="Borders at multi-connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="200" pos-id="" label-id="Reset" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="6003" pos-id="" label-id="Free Borders" icon-id="mesh_free_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <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="6004" pos-id="" label-id="Borders at Multi-Connection" icon-id="mesh_multi_edges.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <separator pos-id=""/>
+ <popup-item item-id="6002" pos-id="" label-id="Free Edges" icon-id="mesh_free_edges_2d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6018" pos-id="" label-id="Length 2D" icon-id="mesh_length_2d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6019" pos-id="" label-id="Borders at Multi-Connection 2D" icon-id="mesh_multi_edges_2d.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="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="Warping" 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=""/>
<separator pos-id=""/>
- <popup-item item-id="200" pos-id="" label-id="Reset" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
+ <popup-item item-id="6017" pos-id="" label-id="Aspect Ratio 3D" icon-id="mesh_aspect_3d.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<separator pos-id=""/>
<popup-item item-id="201" pos-id="" label-id="Scalar Bar Properties" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
</submenu>
<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="Free Edges" icon-id="mesh_free_edges.png" tooltip-id="Free edges" accel-id="" toggle-id="" execute-action=""/>
- <toolbutton-item item-id="6003" label-id="Free borders" icon-id="mesh_free_edges.png" tooltip-id="Free borders" accel-id="" toggle-id="" execute-action=""/>
- <toolbutton-item item-id="6004" label-id="Borders at multi-connection" icon-id="mesh_multi_edges.png" tooltip-id="Borders at multi-connection" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6003" label-id="Free Borders" icon-id="mesh_free_edges.png" tooltip-id="Free borders" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6004" label-id="Borders at Multi-Connection" icon-id="mesh_multi_edges.png" tooltip-id="Borders at multi-connection" accel-id="" toggle-id="" execute-action=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="6002" label-id="Free Edges" icon-id="mesh_free_edges_2d.png" tooltip-id="Free edges" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6018" label-id="Length 2D" icon-id="mesh_length_2d.png" tooltip-id="Length2D" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="6019" label-id="Borders at Multi-Connection 2D" icon-id="mesh_multi_edges_2d.png" tooltip-id="Multiconnection 2D" 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="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="Warping" icon-id="mesh_wrap.png" tooltip-id="Warping angle" 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=""/>
+ <separatorTB/>
+ <toolbutton-item item-id="6017" label-id="Aspect Ratio 3D" icon-id="mesh_aspect_3d.png" tooltip-id="Aspect Ratio 3D" accel-id="" toggle-id="" execute-action=""/>
</toolbar>
<toolbar label-id="Add/Remove toolbar">
<toolbutton-item item-id="411" label-id="Cutting of quadrangles" icon-id="mesh_cutquad.png" tooltip-id="Cutting of quadrangles" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="412" label-id="Smoothing" icon-id="mesh_smoothing.png" tooltip-id="Smoothing" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="413" label-id="Extrusion" icon-id="mesh_extrusion.png" tooltip-id="Extrusion along a line" accel-id="" toggle-id="" execute-action=""/>
+ <toolbutton-item item-id="416" label-id="Extrusion along a path" icon-id="mesh_extrusionpath.png" tooltip-id="Extrusion along a path" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="414" label-id="Revolution" icon-id="mesh_revolution.png" tooltip-id="Revolution around an axis" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="415" label-id="Pattern mapping" icon-id="mesh_pattern.png" tooltip-id="2D and 3D pattern mapping" accel-id="" toggle-id="" execute-action=""/>
</toolbar>
@COMMENCE@
-EXPORT_HEADERS = SMESH_Controls.hxx
+EXPORT_HEADERS = SMESH_Controls.hxx SMESH_ControlsDef.hxx
# Libraries targets
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-#include "SMESH_Controls.hxx"
+#include "SMESH_ControlsDef.hxx"
int main(int argc, char** argv)
{
new Skew();
new Area();
new Length();
+ // new Length2D();
new MultiConnection();
+ // new MultiConnection2D();
new FreeBorders();
new LessThan();
new MoreThan();
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-#include "SMESH_Controls.hxx"
+#include "SMESH_ControlsDef.hxx"
#include <set>
#include <Geom_CylindricalSurface.hxx>
#include <Precision.hxx>
#include <TColgp_Array1OfXYZ.hxx>
-#include <TColgp_SequenceOfXYZ.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include "SMDS_MeshNode.hxx"
-
/*
AUXILIARY METHODS
*/
-static inline double getAngle( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 )
-{
- gp_Vec v1( P1 - P2 ), v2( P3 - P2 );
-
- return v1.Magnitude() < gp::Resolution() ||
- v2.Magnitude() < gp::Resolution() ? 0 : v1.Angle( v2 );
-}
-
-static inline double getArea( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 )
-{
- gp_Vec aVec1( P2 - P1 );
- gp_Vec aVec2( P3 - P1 );
- return ( aVec1 ^ aVec2 ).Magnitude() * 0.5;
-}
-
-static inline double getArea( const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3 )
-{
- return getArea( P1.XYZ(), P2.XYZ(), P3.XYZ() );
-}
+namespace{
+ inline double getAngle( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 )
+ {
+ gp_Vec v1( P1 - P2 ), v2( P3 - P2 );
+
+ return v1.Magnitude() < gp::Resolution() ||
+ v2.Magnitude() < gp::Resolution() ? 0 : v1.Angle( v2 );
+ }
-static inline double getDistance( const gp_XYZ& P1, const gp_XYZ& P2 )
-{
- double aDist = gp_Pnt( P1 ).Distance( gp_Pnt( P2 ) );
- return aDist;
-}
+ inline double getArea( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 )
+ {
+ gp_Vec aVec1( P2 - P1 );
+ gp_Vec aVec2( P3 - P1 );
+ return ( aVec1 ^ aVec2 ).Magnitude() * 0.5;
+ }
-static int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId )
-{
- if ( theMesh == 0 )
- return 0;
+ inline double getArea( const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3 )
+ {
+ return getArea( P1.XYZ(), P2.XYZ(), P3.XYZ() );
+ }
- const SMDS_MeshElement* anEdge = theMesh->FindElement( theId );
- if ( anEdge == 0 || anEdge->GetType() != SMDSAbs_Edge || anEdge->NbNodes() != 2 )
- return 0;
- TColStd_MapOfInteger aMap;
- int aResult = 0;
- SMDS_ElemIteratorPtr anIter = anEdge->nodesIterator();
- if ( anIter != 0 )
+ inline double getDistance( const gp_XYZ& P1, const gp_XYZ& P2 )
{
- while( anIter->more() )
- {
- const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
- if ( aNode == 0 )
- return 0;
- SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator();
- while( anElemIter->more() )
- {
- const SMDS_MeshElement* anElem = anElemIter->next();
- if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge )
- {
- int anId = anElem->GetID();
+ double aDist = gp_Pnt( P1 ).Distance( gp_Pnt( P2 ) );
+ return aDist;
+ }
- if ( anIter->more() ) // i.e. first node
- aMap.Add( anId );
- else if ( aMap.Contains( anId ) )
- aResult++;
- }
+ int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId )
+ {
+ if ( theMesh == 0 )
+ return 0;
+
+ const SMDS_MeshElement* anEdge = theMesh->FindElement( theId );
+ if ( anEdge == 0 || anEdge->GetType() != SMDSAbs_Edge || anEdge->NbNodes() != 2 )
+ return 0;
+
+ TColStd_MapOfInteger aMap;
+
+ int aResult = 0;
+ SMDS_ElemIteratorPtr anIter = anEdge->nodesIterator();
+ if ( anIter != 0 ) {
+ while( anIter->more() ) {
+ const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
+ if ( aNode == 0 )
+ return 0;
+ SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator();
+ while( anElemIter->more() ) {
+ const SMDS_MeshElement* anElem = anElemIter->next();
+ if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge ) {
+ int anId = anElem->GetID();
+
+ if ( anIter->more() ) // i.e. first node
+ aMap.Add( anId );
+ else if ( aMap.Contains( anId ) )
+ aResult++;
+ }
+ }
}
}
+
+ return aResult;
}
- return aResult;
}
+
using namespace SMESH::Controls;
/*
myMesh = theMesh;
}
-bool NumericalFunctor::GetPoints(const int theId,
- TColgp_SequenceOfXYZ& theRes ) const
+bool NumericalFunctor::GetPoints(const int theId,
+ TSequenceOfXYZ& theRes ) const
{
- theRes.Clear();
+ theRes.clear();
if ( myMesh == 0 )
return false;
}
bool NumericalFunctor::GetPoints(const SMDS_MeshElement* anElem,
- TColgp_SequenceOfXYZ& theRes )
+ TSequenceOfXYZ& theRes )
{
- theRes.Clear();
+ theRes.clear();
if ( anElem == 0)
return false;
while( anIter->more() )
{
const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
- if ( aNode != 0 )
- theRes.Append( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) );
+ if ( aNode != 0 ){
+ theRes.push_back( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) );
+ }
}
}
double NumericalFunctor::GetValue( long theId )
{
- TColgp_SequenceOfXYZ P;
+ TSequenceOfXYZ P;
if ( GetPoints( theId, P ))
{
double aVal = GetValue( P );
double prec = pow( 10., (double)( myPrecision ) );
aVal = floor( aVal * prec + 0.5 ) / prec;
}
-
return aVal;
}
Description : Functor for calculation of minimum angle
*/
-double MinimumAngle::GetValue( const TColgp_SequenceOfXYZ& P )
+double MinimumAngle::GetValue( const TSequenceOfXYZ& P )
{
double aMin;
- if ( P.Length() == 3 )
+ if ( P.size() == 3 )
{
double A0 = getAngle( P( 3 ), P( 1 ), P( 2 ) );
double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) );
aMin = Min( A0, Min( A1, A2 ) );
}
- else if ( P.Length() == 4 )
+ else if ( P.size() == 4 )
{
double A0 = getAngle( P( 4 ), P( 1 ), P( 2 ) );
double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) );
Class : AspectRatio
Description : Functor for calculating aspect ratio
*/
-double AspectRatio::GetValue( const TColgp_SequenceOfXYZ& P )
+double AspectRatio::GetValue( const TSequenceOfXYZ& P )
{
- int nbNodes = P.Length();
+ int nbNodes = P.size();
if ( nbNodes != 3 && nbNodes != 4 )
return 0;
Class : AspectRatio3D
Description : Functor for calculating aspect ratio
*/
+namespace{
-static inline double getHalfPerimeter(double theTria[3]){
- return (theTria[0] + theTria[1] + theTria[2])/2.0;
-}
+ inline double getHalfPerimeter(double theTria[3]){
+ return (theTria[0] + theTria[1] + theTria[2])/2.0;
+ }
-static inline double getArea(double theHalfPerim, double theTria[3]){
- return sqrt(theHalfPerim*
- (theHalfPerim-theTria[0])*
- (theHalfPerim-theTria[1])*
- (theHalfPerim-theTria[2]));
-}
+ inline double getArea(double theHalfPerim, double theTria[3]){
+ return sqrt(theHalfPerim*
+ (theHalfPerim-theTria[0])*
+ (theHalfPerim-theTria[1])*
+ (theHalfPerim-theTria[2]));
+ }
-static inline double getVolume(double theLen[6]){
- double a2 = theLen[0]*theLen[0];
- double b2 = theLen[1]*theLen[1];
- double c2 = theLen[2]*theLen[2];
- double d2 = theLen[3]*theLen[3];
- double e2 = theLen[4]*theLen[4];
- double f2 = theLen[5]*theLen[5];
- double P = 4.0*a2*b2*d2;
- double Q = a2*(b2+d2-e2)-b2*(a2+d2-f2)-d2*(a2+b2-c2);
- double R = (b2+d2-e2)*(a2+d2-f2)*(a2+d2-f2);
- return sqrt(P-Q+R)/12.0;
-}
+ inline double getVolume(double theLen[6]){
+ double a2 = theLen[0]*theLen[0];
+ double b2 = theLen[1]*theLen[1];
+ double c2 = theLen[2]*theLen[2];
+ double d2 = theLen[3]*theLen[3];
+ double e2 = theLen[4]*theLen[4];
+ double f2 = theLen[5]*theLen[5];
+ double P = 4.0*a2*b2*d2;
+ double Q = a2*(b2+d2-e2)-b2*(a2+d2-f2)-d2*(a2+b2-c2);
+ double R = (b2+d2-e2)*(a2+d2-f2)*(a2+d2-f2);
+ return sqrt(P-Q+R)/12.0;
+ }
-static inline double getHeight( const gp_Pnt& P1, const gp_Pnt& P2,
- const gp_Pnt& P3, const gp_Pnt& P4)
-{
- gp_Vec aVec1( P2.XYZ() - P1.XYZ() );
- gp_Vec aVec2( P3.XYZ() - P1.XYZ() );
- gp_Vec aNorm = aVec1 ^ aVec2;
- aNorm /= aNorm.Magnitude();
- gp_Vec aVec3( P4.XYZ() - P1.XYZ() );
- double aDist = aVec1 * aVec2;
- return fabs( aDist );
-}
+ inline double getVolume2(double theLen[6]){
+ double a2 = theLen[0]*theLen[0];
+ double b2 = theLen[1]*theLen[1];
+ double c2 = theLen[2]*theLen[2];
+ double d2 = theLen[3]*theLen[3];
+ double e2 = theLen[4]*theLen[4];
+ double f2 = theLen[5]*theLen[5];
+
+ double P = a2*e2*(b2+c2+d2+f2-a2-e2);
+ double Q = b2*f2*(a2+c2+d2+e2-b2-f2);
+ double R = c2*d2*(a2+b2+e2+f2-c2-d2);
+ double S = a2*b2*d2+b2*c2*e2+a2*c2*f2+d2*e2*f2;
+
+ return sqrt(P+Q+R-S)/12.0;
+ }
+
+ inline double getVolume(const TSequenceOfXYZ& P){
+ gp_Vec aVec1( P( 2 ) - P( 1 ) );
+ gp_Vec aVec2( P( 3 ) - P( 1 ) );
+ gp_Vec aVec3( P( 4 ) - P( 1 ) );
+ gp_Vec anAreaVec( aVec1 ^ aVec2 );
+ return abs(aVec3 * anAreaVec) / 6.0;
+ }
+
+ inline double getMaxHeight(double theLen[6])
+ {
+ double aHeight = max(theLen[0],theLen[1]);
+ aHeight = max(aHeight,theLen[2]);
+ aHeight = max(aHeight,theLen[3]);
+ aHeight = max(aHeight,theLen[4]);
+ aHeight = max(aHeight,theLen[5]);
+ return aHeight;
+ }
-static inline double getMaxHeight( const TColgp_SequenceOfXYZ& P )
-{
- double aHeight = getHeight(P(1),P(2),P(3),P(4));
- aHeight = max(aHeight,getHeight(P(1),P(2),P(4),P(3)));
- aHeight = max(aHeight,getHeight(P(1),P(3),P(4),P(2)));
- aHeight = max(aHeight,getHeight(P(2),P(3),P(4),P(1)));
- return aHeight;
}
-double AspectRatio3D::GetValue( const TColgp_SequenceOfXYZ& P )
+double AspectRatio3D::GetValue( const TSequenceOfXYZ& P )
{
double aQuality = 0.0;
- int nbNodes = P.Length();
+ int nbNodes = P.size();
switch(nbNodes){
case 4:{
double aLen[6] = {
- getDistance(P(1),P(2)), // a
- getDistance(P(2),P(3)), // b
- getDistance(P(3),P(1)), // c
- getDistance(P(2),P(4)), // d
- getDistance(P(3),P(4)), // e
- getDistance(P(1),P(4)) // f
+ getDistance(P( 1 ),P( 2 )), // a
+ getDistance(P( 2 ),P( 3 )), // b
+ getDistance(P( 3 ),P( 1 )), // c
+ getDistance(P( 2 ),P( 4 )), // d
+ getDistance(P( 3 ),P( 4 )), // e
+ getDistance(P( 1 ),P( 4 )) // f
};
double aTria[4][3] = {
{aLen[0],aLen[1],aLen[2]}, // abc
{aLen[1],aLen[3],aLen[4]}, // bde
{aLen[2],aLen[4],aLen[5]} // cef
};
- double aHalfPerim = getHalfPerimeter(aTria[0]);
- double anArea = getArea(aHalfPerim,aTria[0]);
- aHalfPerim = getHalfPerimeter(aTria[1]);
- anArea += getArea(aHalfPerim,aTria[1]);
- aHalfPerim = getHalfPerimeter(aTria[2]);
- anArea += getArea(aHalfPerim,aTria[2]);
- double aVolume = getVolume(aLen);
- double aHeight = getMaxHeight(P);
- aQuality = 1.0/3.0*aHeight*anArea/aVolume;
+ double aSumArea = 0.0;
+ double aHalfPerimeter = getHalfPerimeter(aTria[0]);
+ double anArea = getArea(aHalfPerimeter,aTria[0]);
+ aSumArea += anArea;
+ aHalfPerimeter = getHalfPerimeter(aTria[1]);
+ anArea = getArea(aHalfPerimeter,aTria[1]);
+ aSumArea += anArea;
+ aHalfPerimeter = getHalfPerimeter(aTria[2]);
+ anArea = getArea(aHalfPerimeter,aTria[2]);
+ aSumArea += anArea;
+ aHalfPerimeter = getHalfPerimeter(aTria[3]);
+ anArea = getArea(aHalfPerimeter,aTria[3]);
+ aSumArea += anArea;
+ double aVolume = getVolume(P);
+ //double aVolume = getVolume(aLen);
+ double aHeight = getMaxHeight(aLen);
+ static double aCoeff = sqrt(6.0)/36.0;
+ aQuality = aCoeff*aHeight*aSumArea/aVolume;
+ break;
+ }
+ case 5:{
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 3 ),P( 5 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 3 ),P( 4 ),P( 5 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 4 ),P( 5 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 2 ),P( 3 ),P( 4 ),P( 5 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ break;
+ }
+ case 6:{
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 4 ),P( 6 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 4 ),P( 3 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 5 ),P( 6 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 5 ),P( 3 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 2 ),P( 5 ),P( 4 ),P( 6 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 2 ),P( 5 ),P( 4 ),P( 3 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ break;
+ }
+ case 8:{
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 5 ),P( 3 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 5 ),P( 4 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 5 ),P( 7 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 5 ),P( 8 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 6 ),P( 3 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 6 ),P( 4 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 6 ),P( 7 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 6 ),P( 8 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 2 ),P( 6 ),P( 5 ),P( 3 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 2 ),P( 6 ),P( 5 ),P( 4 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 2 ),P( 6 ),P( 5 ),P( 7 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 2 ),P( 6 ),P( 5 ),P( 8 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 3 ),P( 4 ),P( 8 ),P( 1 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 3 ),P( 4 ),P( 8 ),P( 2 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 3 ),P( 4 ),P( 8 ),P( 5 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 3 ),P( 4 ),P( 8 ),P( 6 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 3 ),P( 4 ),P( 7 ),P( 1 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 3 ),P( 4 ),P( 7 ),P( 2 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 3 ),P( 4 ),P( 7 ),P( 5 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 3 ),P( 4 ),P( 7 ),P( 6 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 4 ),P( 8 ),P( 7 ),P( 1 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 4 ),P( 8 ),P( 7 ),P( 2 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 4 ),P( 8 ),P( 7 ),P( 5 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 4 ),P( 8 ),P( 7 ),P( 6 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 4 ),P( 8 ),P( 7 ),P( 2 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 4 ),P( 5 ),P( 8 ),P( 2 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 4 ),P( 5 ),P( 3 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 3 ),P( 6 ),P( 7 ),P( 1 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 2 ),P( 3 ),P( 6 ),P( 4 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 5 ),P( 6 ),P( 8 ),P( 3 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 7 ),P( 8 ),P( 6 ),P( 1 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 1 ),P( 2 ),P( 4 ),P( 7 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
+ {
+ gp_XYZ aXYZ[4] = {P( 3 ),P( 4 ),P( 2 ),P( 5 )};
+ aQuality = max(GetValue(TSequenceOfXYZ(&aXYZ[0],&aXYZ[4])),aQuality);
+ }
break;
}
}
Class : Warping
Description : Functor for calculating warping
*/
-double Warping::GetValue( const TColgp_SequenceOfXYZ& P )
+double Warping::GetValue( const TSequenceOfXYZ& P )
{
- if ( P.Length() != 4 )
+ if ( P.size() != 4 )
return 0;
gp_XYZ G = ( P( 1 ) + P( 2 ) + P( 3 ) + P( 4 ) ) / 4;
Class : Taper
Description : Functor for calculating taper
*/
-double Taper::GetValue( const TColgp_SequenceOfXYZ& P )
+double Taper::GetValue( const TSequenceOfXYZ& P )
{
- if ( P.Length() != 4 )
+ if ( P.size() != 4 )
return 0;
// Compute taper
return v1.Magnitude() < gp::Resolution() || v2.Magnitude() < gp::Resolution() ? 0 : v1.Angle( v2 );
}
-double Skew::GetValue( const TColgp_SequenceOfXYZ& P )
+double Skew::GetValue( const TSequenceOfXYZ& P )
{
- if ( P.Length() != 3 && P.Length() != 4 )
+ if ( P.size() != 3 && P.size() != 4 )
return 0;
// Compute skew
static double PI2 = PI / 2;
- if ( P.Length() == 3 )
+ if ( P.size() == 3 )
{
double A0 = fabs( PI2 - skewAngle( P( 3 ), P( 1 ), P( 2 ) ) );
double A1 = fabs( PI2 - skewAngle( P( 1 ), P( 2 ), P( 3 ) ) );
Class : Area
Description : Functor for calculating area
*/
-double Area::GetValue( const TColgp_SequenceOfXYZ& P )
+double Area::GetValue( const TSequenceOfXYZ& P )
{
- if ( P.Length() == 3 )
+ if ( P.size() == 3 )
return getArea( P( 1 ), P( 2 ), P( 3 ) );
- else if ( P.Length() == 4 )
+ else if ( P.size() == 4 )
return getArea( P( 1 ), P( 2 ), P( 3 ) ) + getArea( P( 1 ), P( 3 ), P( 4 ) );
else
return 0;
Class : Length
Description : Functor for calculating length off edge
*/
-double Length::GetValue( const TColgp_SequenceOfXYZ& P )
+double Length::GetValue( const TSequenceOfXYZ& P )
{
- return ( P.Length() == 2 ? getDistance( P( 1 ), P( 2 ) ) : 0 );
+ return ( P.size() == 2 ? getDistance( P( 1 ), P( 2 ) ) : 0 );
}
double Length::GetBadRate( double Value, int /*nbNodes*/ ) const
return SMDSAbs_Edge;
}
+/*
+ Class : Length2D
+ Description : Functor for calculating length of edge
+*/
+
+double Length2D::GetValue( long theElementId)
+{
+ TSequenceOfXYZ P;
+
+ if (GetPoints(theElementId,P)){
+
+ double aVal;// = GetValue( P );
+ const SMDS_MeshElement* aElem = myMesh->FindElement( theElementId );
+ SMDSAbs_ElementType aType = aElem->GetType();
+
+ int len = P.size();
+
+ switch (aType){
+ case SMDSAbs_All:
+ case SMDSAbs_Node:
+ case SMDSAbs_Edge:
+ if (len == 2){
+ aVal = getDistance( P( 1 ), P( 2 ) );
+ break;
+ }
+ case SMDSAbs_Face:
+ if (len == 3){ // triangles
+ double L1 = getDistance(P( 1 ),P( 2 ));
+ double L2 = getDistance(P( 2 ),P( 3 ));
+ double L3 = getDistance(P( 3 ),P( 1 ));
+ aVal = Max(L1,Max(L2,L3));
+ break;
+ }
+ else if (len == 4){ // quadrangles
+ double L1 = getDistance(P( 1 ),P( 2 ));
+ double L2 = getDistance(P( 2 ),P( 3 ));
+ double L3 = getDistance(P( 3 ),P( 4 ));
+ double L4 = getDistance(P( 4 ),P( 1 ));
+ aVal = Max(Max(L1,L2),Max(L3,L4));
+ break;
+ }
+ case SMDSAbs_Volume:
+ if (len == 4){ // tetraidrs
+ double L1 = getDistance(P( 1 ),P( 2 ));
+ double L2 = getDistance(P( 2 ),P( 3 ));
+ double L3 = getDistance(P( 3 ),P( 1 ));
+ double L4 = getDistance(P( 1 ),P( 4 ));
+ double L5 = getDistance(P( 2 ),P( 4 ));
+ double L6 = getDistance(P( 3 ),P( 4 ));
+ aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
+ break;
+ }
+ else if (len == 5){ // piramids
+ double L1 = getDistance(P( 1 ),P( 2 ));
+ double L2 = getDistance(P( 2 ),P( 3 ));
+ double L3 = getDistance(P( 3 ),P( 1 ));
+ double L4 = getDistance(P( 4 ),P( 1 ));
+ double L5 = getDistance(P( 1 ),P( 5 ));
+ double L6 = getDistance(P( 2 ),P( 5 ));
+ double L7 = getDistance(P( 3 ),P( 5 ));
+ double L8 = getDistance(P( 4 ),P( 5 ));
+
+ aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
+ aVal = Max(aVal,Max(L7,L8));
+ break;
+ }
+ else if (len == 6){ // pentaidres
+ double L1 = getDistance(P( 1 ),P( 2 ));
+ double L2 = getDistance(P( 2 ),P( 3 ));
+ double L3 = getDistance(P( 3 ),P( 1 ));
+ double L4 = getDistance(P( 4 ),P( 5 ));
+ double L5 = getDistance(P( 5 ),P( 6 ));
+ double L6 = getDistance(P( 6 ),P( 4 ));
+ double L7 = getDistance(P( 1 ),P( 4 ));
+ double L8 = getDistance(P( 2 ),P( 5 ));
+ double L9 = getDistance(P( 3 ),P( 6 ));
+
+ aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
+ aVal = Max(aVal,Max(Max(L7,L8),L9));
+ break;
+ }
+ else if (len == 8){ // hexaider
+ double L1 = getDistance(P( 1 ),P( 2 ));
+ double L2 = getDistance(P( 2 ),P( 3 ));
+ double L3 = getDistance(P( 3 ),P( 4 ));
+ double L4 = getDistance(P( 4 ),P( 1 ));
+ double L5 = getDistance(P( 5 ),P( 6 ));
+ double L6 = getDistance(P( 6 ),P( 7 ));
+ double L7 = getDistance(P( 7 ),P( 8 ));
+ double L8 = getDistance(P( 8 ),P( 5 ));
+ double L9 = getDistance(P( 1 ),P( 5 ));
+ double L10= getDistance(P( 2 ),P( 6 ));
+ double L11= getDistance(P( 3 ),P( 7 ));
+ double L12= getDistance(P( 4 ),P( 8 ));
+
+ aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
+ aVal = Max(aVal,Max(Max(L7,L8),Max(L9,L10)));
+ aVal = Max(aVal,Max(L11,L12));
+ break;
+
+ }
+
+ default: aVal=-1;
+ }
+
+ if (aVal <0){
+ return 0.;
+ }
+
+ if ( myPrecision >= 0 )
+ {
+ double prec = pow( 10., (double)( myPrecision ) );
+ aVal = floor( aVal * prec + 0.5 ) / prec;
+ }
+
+ return aVal;
+
+ }
+ return 0.;
+}
+
+double Length2D::GetBadRate( double Value, int /*nbNodes*/ ) const
+{
+ return Value;
+}
+
+SMDSAbs_ElementType Length2D::GetType() const
+{
+ return SMDSAbs_Face;
+}
+
+Length2D::Value::Value(double theLength,long thePntId1, long thePntId2):
+ myLength(theLength)
+{
+ myPntId[0] = thePntId1; myPntId[1] = thePntId2;
+ if(thePntId1 > thePntId2){
+ myPntId[1] = thePntId1; myPntId[0] = thePntId2;
+ }
+}
+
+bool Length2D::Value::operator<(const Length2D::Value& x) const{
+ if(myPntId[0] < x.myPntId[0]) return true;
+ if(myPntId[0] == x.myPntId[0])
+ if(myPntId[1] < x.myPntId[1]) return true;
+ return false;
+}
+
+void Length2D::GetValues(TValues& theValues){
+ TValues aValues;
+ SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
+ for(; anIter->more(); ){
+ const SMDS_MeshFace* anElem = anIter->next();
+ SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
+ long aNodeId[2];
+ gp_Pnt P[3];
+
+ double aLength;
+ const SMDS_MeshElement* aNode;
+ if(aNodesIter->more()){
+ aNode = aNodesIter->next();
+ const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
+ P[0] = P[1] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
+ aNodeId[0] = aNodeId[1] = aNode->GetID();
+ aLength = 0;
+ }
+ for(; aNodesIter->more(); ){
+ aNode = aNodesIter->next();
+ const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
+ long anId = aNode->GetID();
+
+ P[2] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
+
+ aLength = P[1].Distance(P[2]);
+
+ Value aValue(aLength,aNodeId[1],anId);
+ aNodeId[1] = anId;
+ P[1] = P[2];
+ theValues.insert(aValue);
+ }
+
+ aLength = P[0].Distance(P[1]);
+
+ Value aValue(aLength,aNodeId[0],aNodeId[1]);
+ theValues.insert(aValue);
+ }
+}
/*
Class : MultiConnection
Description : Functor for calculating number of faces conneted to the edge
*/
-double MultiConnection::GetValue( const TColgp_SequenceOfXYZ& P )
+double MultiConnection::GetValue( const TSequenceOfXYZ& P )
{
return 0;
}
return SMDSAbs_Edge;
}
+/*
+ Class : MultiConnection2D
+ Description : Functor for calculating number of faces conneted to the edge
+*/
+double MultiConnection2D::GetValue( const TSequenceOfXYZ& P )
+{
+ return 0;
+}
+
+double MultiConnection2D::GetValue( long theElementId )
+{
+ TSequenceOfXYZ P;
+ int aResult = 0;
+
+ if (GetPoints(theElementId,P)){
+ double aVal;
+ const SMDS_MeshElement* anFaceElem = myMesh->FindElement( theElementId );
+ SMDSAbs_ElementType aType = anFaceElem->GetType();
+
+ int len = P.size();
+
+ TColStd_MapOfInteger aMap;
+ int aResult = 0;
+
+ switch (aType){
+ case SMDSAbs_All:
+ case SMDSAbs_Node:
+ case SMDSAbs_Edge:
+ case SMDSAbs_Face:
+ if (len == 3){ // triangles
+ int Nb[3] = {0,0,0};
+
+ int i=0;
+ SMDS_ElemIteratorPtr anIter = anFaceElem->nodesIterator();
+ if ( anIter != 0 ) {
+ while( anIter->more() ) {
+ const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next();
+ if ( aNode == 0 ){
+ break;
+ }
+ SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator();
+ while( anElemIter->more() ) {
+ const SMDS_MeshElement* anElem = anElemIter->next();
+ if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge ) {
+ int anId = anElem->GetID();
+
+ if ( anIter->more() ) // i.e. first node
+ aMap.Add( anId );
+ else if ( aMap.Contains( anId ) ){
+ Nb[i]++;
+ }
+ }
+ else if ( anElem != 0 && anElem->GetType() == SMDSAbs_Edge ) i++;
+ }
+ }
+ }
+
+ aResult = Max(Max(Nb[0],Nb[1]),Nb[2]);
+ }
+ break;
+ case SMDSAbs_Volume:
+ default: aResult=0;
+ }
+
+ }
+ return aResult;//getNbMultiConnection( myMesh, theId );
+}
+
+double MultiConnection2D::GetBadRate( double Value, int /*nbNodes*/ ) const
+{
+ return Value;
+}
+
+SMDSAbs_ElementType MultiConnection2D::GetType() const
+{
+ return SMDSAbs_Face;
+}
+
+MultiConnection2D::Value::Value(long thePntId1, long thePntId2)
+{
+ myPntId[0] = thePntId1; myPntId[1] = thePntId2;
+ if(thePntId1 > thePntId2){
+ myPntId[1] = thePntId1; myPntId[0] = thePntId2;
+ }
+}
+
+bool MultiConnection2D::Value::operator<(const MultiConnection2D::Value& x) const{
+ if(myPntId[0] < x.myPntId[0]) return true;
+ if(myPntId[0] == x.myPntId[0])
+ if(myPntId[1] < x.myPntId[1]) return true;
+ return false;
+}
+
+void MultiConnection2D::GetValues(MValues& theValues){
+ SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
+ for(; anIter->more(); ){
+ const SMDS_MeshFace* anElem = anIter->next();
+ long anElemId = anElem->GetID();
+ SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
+ long aNodeId[3];
+
+ //int aNbConnects=0;
+ const SMDS_MeshNode* aNode0;
+ const SMDS_MeshNode* aNode1;
+ const SMDS_MeshNode* aNode2;
+ if(aNodesIter->more()){
+ aNode0 = (SMDS_MeshNode*) aNodesIter->next();
+ aNode1 = aNode0;
+ const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode1;
+ aNodeId[0] = aNodeId[1] = aNodes->GetID();
+ }
+ for(; aNodesIter->more(); ){
+ aNode2 = (SMDS_MeshNode*) aNodesIter->next();
+ long anId = aNode2->GetID();
+ aNodeId[2] = anId;
+
+ Value aValue(aNodeId[1],aNodeId[2]);
+ MValues::iterator aItr = theValues.find(aValue);
+ if (aItr != theValues.end()){
+ aItr->second += 1;
+ //aNbConnects = nb;
+ } else {
+ theValues[aValue] = 1;
+ //aNbConnects = 1;
+ }
+ //cout << "NodeIds: "<<aNodeId[1]<<","<<aNodeId[2]<<" nbconn="<<aNbConnects<<endl;
+ aNodeId[1] = aNodeId[2];
+ aNode1 = aNode2;
+ }
+ Value aValue(aNodeId[0],aNodeId[2]);
+ MValues::iterator aItr = theValues.find(aValue);
+ if (aItr != theValues.end()){
+ aItr->second += 1;
+ //aNbConnects = nb;
+ } else {
+ theValues[aValue] = 1;
+ //aNbConnects = 1;
+ }
+ //cout << "NodeIds: "<<aNodeId[0]<<","<<aNodeId[2]<<" nbconn="<<aNbConnects<<endl;
+ }
+
+}
/*
PREDICATES
gp_XYZ n;
int aNbNode = theFace->NbNodes();
TColgp_Array1OfXYZ anArrOfXYZ(1,4);
- gp_XYZ p1, p2, p3, p4;
SMDS_ElemIteratorPtr aNodeItr = theFace->nodesIterator();
int i = 1;
for ( ; aNodeItr->more() && i <= 4; i++ )
SMDS_MeshFace* aFace = (SMDS_MeshFace*)anItr->next();
if ( !aFace )
continue;
- aSetOfFaces.insert( aFace );
+ aSetOfFaces.Add( aFace );
}
// take all faces that shared second node
anItr = theLink.myNode2->facesIterator();
for ( ; anItr->more(); )
{
SMDS_MeshFace* aFace = (SMDS_MeshFace*)anItr->next();
- if ( aSetOfFaces.find( aFace ) != aSetOfFaces.end() )
+ if ( aSetOfFaces.Contains( aFace ) )
theFaces.push_back( aFace );
}
}
#ifndef _SMESH_CONTROLS_HXX_
#define _SMESH_CONTROLS_HXX_
-#include <set>
-#include <map>
-#include <vector>
#include <boost/shared_ptr.hpp>
-#include "SMDSAbs_ElementType.hxx"
-#include "SMDS_MeshNode.hxx"
-#include <Geom_Surface.hxx>
-#include <TColStd_SequenceOfInteger.hxx>
-#include <TColStd_MapOfInteger.hxx>
-#include <TCollection_AsciiString.hxx>
-
-class SMDS_Mesh;
-class SMESHDS_Mesh;
-class SMESHDS_SubMesh;
-class gp_Pnt;
-class gp_XYZ;
-class TColgp_SequenceOfXYZ;
-class TopoDS_Shape;
-class SMDS_MeshElement;
-class SMDS_MeshFace;
-class SMDS_MeshNode;
namespace SMESH{
namespace Controls{
- class Functor
- {
- public:
- ~Functor(){}
- virtual void SetMesh( SMDS_Mesh* theMesh ) = 0;
- virtual SMDSAbs_ElementType GetType() const = 0;
- };
+
+ class Functor;
typedef boost::shared_ptr<Functor> FunctorPtr;
- class NumericalFunctor: public virtual Functor{
- public:
- NumericalFunctor();
- virtual void SetMesh( SMDS_Mesh* theMesh );
- virtual double GetValue( long theElementId );
- virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ) = 0;
- virtual SMDSAbs_ElementType GetType() const = 0;
- virtual double GetBadRate( double Value, int nbNodes ) const = 0;
- long GetPrecision() const;
- void SetPrecision( const long thePrecision );
-
- bool GetPoints (const int theId,
- TColgp_SequenceOfXYZ& theRes ) const;
- static bool GetPoints (const SMDS_MeshElement* theElem,
- TColgp_SequenceOfXYZ& theRes );
- protected:
- SMDS_Mesh* myMesh;
- long myPrecision;
- };
+
+ class NumericalFunctor;
typedef boost::shared_ptr<NumericalFunctor> NumericalFunctorPtr;
- /*
- Class : SMESH_MinimumAngle
- Description : Functor for calculation of minimum angle
- */
- class MinimumAngle: public virtual NumericalFunctor{
- public:
- virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints );
- virtual double GetBadRate( double Value, int nbNodes ) const;
- virtual SMDSAbs_ElementType GetType() const;
- };
-
-
- /*
- Class : AspectRatio
- Description : Functor for calculating aspect ratio
- */
- class AspectRatio: public virtual NumericalFunctor{
- public:
- virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints );
- virtual double GetBadRate( double Value, int nbNodes ) const;
- virtual SMDSAbs_ElementType GetType() const;
- };
-
-
- /*
- Class : AspectRatio3D
- Description : Functor for calculating aspect ratio of 3D elems.
- */
- class AspectRatio3D: public virtual NumericalFunctor{
- public:
- virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints );
- virtual double GetBadRate( double Value, int nbNodes ) const;
- virtual SMDSAbs_ElementType GetType() const;
- };
-
-
- /*
- Class : Warping
- Description : Functor for calculating warping
- */
- class Warping: public virtual NumericalFunctor{
- public:
- virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints );
- virtual double GetBadRate( double Value, int nbNodes ) const;
- virtual SMDSAbs_ElementType GetType() const;
-
- private:
- double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
- };
-
-
- /*
- Class : Taper
- Description : Functor for calculating taper
- */
- class Taper: public virtual NumericalFunctor{
- public:
- virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints );
- virtual double GetBadRate( double Value, int nbNodes ) const;
- virtual SMDSAbs_ElementType GetType() const;
- };
-
-
- /*
- Class : Skew
- Description : Functor for calculating skew in degrees
- */
- class Skew: public virtual NumericalFunctor{
- public:
- virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints );
- virtual double GetBadRate( double Value, int nbNodes ) const;
- virtual SMDSAbs_ElementType GetType() const;
- };
-
-
- /*
- Class : Area
- Description : Functor for calculating area
- */
- class Area: public virtual NumericalFunctor{
- public:
- virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints );
- virtual double GetBadRate( double Value, int nbNodes ) const;
- virtual SMDSAbs_ElementType GetType() const;
- };
-
-
- /*
- Class : Length
- Description : Functor for calculating length of edge
- */
- class Length: public virtual NumericalFunctor{
- public:
- virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints );
- virtual double GetBadRate( double Value, int nbNodes ) const;
- virtual SMDSAbs_ElementType GetType() const;
- };
-
-
- /*
- Class : MultiConnection
- Description : Functor for calculating number of faces conneted to the edge
- */
- class MultiConnection: public virtual NumericalFunctor{
- public:
- virtual double GetValue( long theElementId );
- virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints );
- virtual double GetBadRate( double Value, int nbNodes ) const;
- virtual SMDSAbs_ElementType GetType() const;
- };
-
-
- /*
- PREDICATES
- */
- /*
- Class : Predicate
- Description : Base class for all predicates
- */
- class Predicate: public virtual Functor{
- public:
- virtual bool IsSatisfy( long theElementId ) = 0;
- virtual SMDSAbs_ElementType GetType() const = 0;
- };
+ class Predicate;
typedef boost::shared_ptr<Predicate> PredicatePtr;
-
-
-
- /*
- Class : FreeBorders
- Description : Predicate for free borders
- */
- class FreeBorders: public virtual Predicate{
- public:
- FreeBorders();
- virtual void SetMesh( SMDS_Mesh* theMesh );
- virtual bool IsSatisfy( long theElementId );
- virtual SMDSAbs_ElementType GetType() const;
-
- protected:
- SMDS_Mesh* myMesh;
- };
-
-
- /*
- Class : FreeEdges
- Description : Predicate for free Edges
- */
- class FreeEdges: public virtual Predicate{
- public:
- FreeEdges();
- virtual void SetMesh( SMDS_Mesh* theMesh );
- virtual bool IsSatisfy( long theElementId );
- virtual SMDSAbs_ElementType GetType() const;
- static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
- typedef long TElemId;
- struct Border{
- TElemId myElemId;
- TElemId myPntId[2];
- Border(long theElemId, long thePntId1, long thePntId2);
- bool operator<(const Border& x) const;
- };
- typedef std::set<Border> TBorders;
- void GetBoreders(TBorders& theBorders);
-
- protected:
- SMDS_Mesh* myMesh;
- };
- typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
-
- /*
- Class : RangeOfIds
- Description : Predicate for Range of Ids.
- Range may be specified with two ways.
- 1. Using AddToRange method
- 2. With SetRangeStr method. Parameter of this method is a string
- like as "1,2,3,50-60,63,67,70-"
- */
- class RangeOfIds: public virtual Predicate
- {
- public:
- RangeOfIds();
- virtual void SetMesh( SMDS_Mesh* theMesh );
- virtual bool IsSatisfy( long theNodeId );
- virtual SMDSAbs_ElementType GetType() const;
- virtual void SetType( SMDSAbs_ElementType theType );
-
- bool AddToRange( long theEntityId );
- void GetRangeStr( TCollection_AsciiString& );
- bool SetRangeStr( const TCollection_AsciiString& );
-
- protected:
- SMDS_Mesh* myMesh;
-
- TColStd_SequenceOfInteger myMin;
- TColStd_SequenceOfInteger myMax;
- TColStd_MapOfInteger myIds;
-
- SMDSAbs_ElementType myType;
- };
-
- typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
-
-
- /*
- Class : Comparator
- Description : Base class for comparators
- */
- class Comparator: public virtual Predicate{
- public:
- Comparator();
- virtual ~Comparator();
- virtual void SetMesh( SMDS_Mesh* theMesh );
- virtual void SetMargin(double theValue);
- virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
- virtual bool IsSatisfy( long theElementId ) = 0;
- virtual SMDSAbs_ElementType GetType() const;
- double GetMargin();
-
- protected:
- double myMargin;
- NumericalFunctorPtr myFunctor;
- };
- typedef boost::shared_ptr<Comparator> ComparatorPtr;
-
-
- /*
- Class : LessThan
- Description : Comparator "<"
- */
- class LessThan: public virtual Comparator{
- public:
- virtual bool IsSatisfy( long theElementId );
- };
-
-
- /*
- Class : MoreThan
- Description : Comparator ">"
- */
- class MoreThan: public virtual Comparator{
- public:
- virtual bool IsSatisfy( long theElementId );
- };
-
-
- /*
- Class : EqualTo
- Description : Comparator "="
- */
- class EqualTo: public virtual Comparator{
- public:
- EqualTo();
- virtual bool IsSatisfy( long theElementId );
- virtual void SetTolerance( double theTol );
- virtual double GetTolerance();
-
- private:
- double myToler;
- };
- typedef boost::shared_ptr<EqualTo> EqualToPtr;
-
-
- /*
- Class : LogicalNOT
- Description : Logical NOT predicate
- */
- class LogicalNOT: public virtual Predicate{
- public:
- LogicalNOT();
- virtual ~LogicalNOT();
- virtual bool IsSatisfy( long theElementId );
- virtual void SetMesh( SMDS_Mesh* theMesh );
- virtual void SetPredicate(PredicatePtr thePred);
- virtual SMDSAbs_ElementType GetType() const;
-
- private:
- PredicatePtr myPredicate;
- };
- typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
-
-
- /*
- Class : LogicalBinary
- Description : Base class for binary logical predicate
- */
- class LogicalBinary: public virtual Predicate{
- public:
- LogicalBinary();
- virtual ~LogicalBinary();
- virtual void SetMesh( SMDS_Mesh* theMesh );
- virtual void SetPredicate1(PredicatePtr thePred);
- virtual void SetPredicate2(PredicatePtr thePred);
- virtual SMDSAbs_ElementType GetType() const;
-
- protected:
- PredicatePtr myPredicate1;
- PredicatePtr myPredicate2;
- };
- typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
-
-
- /*
- Class : LogicalAND
- Description : Logical AND
- */
- class LogicalAND: public virtual LogicalBinary{
- public:
- virtual bool IsSatisfy( long theElementId );
- };
-
-
- /*
- Class : LogicalOR
- Description : Logical OR
- */
- class LogicalOR: public virtual LogicalBinary{
- public:
- virtual bool IsSatisfy( long theElementId );
- };
-
-
- /*
- Class : ManifoldPart
- Description : Predicate for manifold part of mesh
- */
- class ManifoldPart: public virtual Predicate{
- public:
-
- /* internal class for algorithm uses */
- class Link
- {
- public:
- Link( SMDS_MeshNode* theNode1,
- SMDS_MeshNode* theNode2 );
- ~Link();
-
- bool IsEqual( const ManifoldPart::Link& theLink ) const;
- bool operator<(const ManifoldPart::Link& x) const;
-
- SMDS_MeshNode* myNode1;
- SMDS_MeshNode* myNode2;
- };
-
- bool IsEqual( const ManifoldPart::Link& theLink1,
- const ManifoldPart::Link& theLink2 );
-
- typedef std::set<ManifoldPart::Link> TMapOfLink;
- typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
- typedef std::vector<ManifoldPart::Link> TVectorOfLink;
- typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
- typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
-
- ManifoldPart();
- ~ManifoldPart();
- virtual void SetMesh( SMDS_Mesh* theMesh );
- // inoke when all parameters already set
- virtual bool IsSatisfy( long theElementId );
- virtual SMDSAbs_ElementType GetType() const;
-
- void SetAngleTolerance( const double theAngToler );
- double GetAngleTolerance() const;
- void SetIsOnlyManifold( const bool theIsOnly );
- void SetStartElem( const long theStartElemId );
-
- private:
- bool process();
- bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
- SMDS_MeshFace* theStartFace,
- TMapOfLink& theNonManifold,
- TColStd_MapOfInteger& theResFaces );
- bool isInPlane( const SMDS_MeshFace* theFace1,
- const SMDS_MeshFace* theFace2 );
- void expandBoundary( TMapOfLink& theMapOfBoundary,
- TVectorOfLink& theSeqOfBoundary,
- TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
- TMapOfLink& theNonManifold,
- SMDS_MeshFace* theNextFace ) const;
-
- void getFacesByLink( const Link& theLink,
- TVectorOfFacePtr& theFaces ) const;
-
- private:
- SMDS_Mesh* myMesh;
- TColStd_MapOfInteger myMapIds;
- TColStd_MapOfInteger myMapBadGeomIds;
- TVectorOfFacePtr myAllFacePtr;
- TDataMapFacePtrInt myAllFacePtrIntDMap;
- double myAngToler;
- bool myIsOnlyManifold;
- long myStartElemId;
-
- };
- typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
-
-
- /*
- Class : ElementsOnSurface
- Description : Predicate elements that lying on indicated surface
- (plane or cylinder)
- */
- class ElementsOnSurface : public virtual Predicate {
- public:
- ElementsOnSurface();
- ~ElementsOnSurface();
- virtual void SetMesh( SMDS_Mesh* theMesh );
- virtual bool IsSatisfy( long theElementId );
- virtual SMDSAbs_ElementType GetType() const;
-
- void SetTolerance( const double theToler );
- double GetTolerance() const;
- void SetSurface( const TopoDS_Shape& theShape,
- const SMDSAbs_ElementType theType );
-
- private:
- void process();
- void process( const SMDS_MeshElement* theElem );
- bool isOnSurface( const SMDS_MeshNode* theNode ) const;
-
- private:
- SMDS_Mesh* myMesh;
- TColStd_MapOfInteger myIds;
- SMDSAbs_ElementType myType;
- Handle(Geom_Surface) mySurf;
- double myToler;
- };
-
- typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
-
-
- /*
- FILTER
- */
- class Filter{
- public:
- Filter();
- virtual ~Filter();
- virtual void SetPredicate(PredicatePtr thePred);
- typedef std::vector<long> TIdSequence;
- virtual TIdSequence GetElementsId( SMDS_Mesh* theMesh );
-
- protected:
- PredicatePtr myPredicate;
- };
- };
-};
+ }
+}
#endif
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+
+#ifndef _SMESH_CONTROLSDEF_HXX_
+#define _SMESH_CONTROLSDEF_HXX_
+
+#include <set>
+#include <map>
+#include <vector>
+#include <boost/shared_ptr.hpp>
+#include <gp_XYZ.hxx>
+#include <Geom_Surface.hxx>
+#include <TColStd_SequenceOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include "SMDSAbs_ElementType.hxx"
+#include "SMDS_MeshNode.hxx"
+
+#include "SMESH_Controls.hxx"
+
+class SMDS_MeshElement;
+class SMDS_MeshFace;
+class SMDS_MeshNode;
+class SMDS_Mesh;
+
+class SMESHDS_Mesh;
+class SMESHDS_SubMesh;
+
+class gp_Pnt;
+class TopoDS_Shape;
+
+
+namespace SMESH{
+ namespace Controls{
+
+ class TSequenceOfXYZ: public std::vector<gp_XYZ>
+ {
+ public:
+ typedef std::vector<gp_XYZ> TSuperClass;
+ TSequenceOfXYZ()
+ {}
+
+ TSequenceOfXYZ(size_type n):
+ TSuperClass(n)
+ {}
+
+ TSequenceOfXYZ(size_type n, const value_type& t):
+ TSuperClass(n,t)
+ {}
+
+ TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ):
+ TSuperClass(theSequenceOfXYZ)
+ {}
+
+ template <class InputIterator>
+ TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd):
+ TSuperClass(theBegin,theEnd)
+ {}
+
+ TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ){
+ TSuperClass::operator=(theSequenceOfXYZ);
+ return *this;
+ }
+
+ reference operator()(size_type n){
+ return TSuperClass::operator[](n-1);
+ }
+
+ const_reference operator()(size_type n) const{
+ return TSuperClass::operator[](n-1);
+ }
+
+ private:
+ reference operator[](size_type n);
+
+ const_reference operator[](size_type n) const;
+ };
+
+ class Functor
+ {
+ public:
+ ~Functor(){}
+ virtual void SetMesh( SMDS_Mesh* theMesh ) = 0;
+ virtual SMDSAbs_ElementType GetType() const = 0;
+ };
+
+ class NumericalFunctor: public virtual Functor{
+ public:
+ NumericalFunctor();
+ virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual double GetValue( long theElementId );
+ virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
+ virtual SMDSAbs_ElementType GetType() const = 0;
+ virtual double GetBadRate( double Value, int nbNodes ) const = 0;
+ long GetPrecision() const;
+ void SetPrecision( const long thePrecision );
+
+ bool GetPoints(const int theId,
+ TSequenceOfXYZ& theRes) const;
+ static bool GetPoints(const SMDS_MeshElement* theElem,
+ TSequenceOfXYZ& theRes);
+ protected:
+ SMDS_Mesh* myMesh;
+ long myPrecision;
+ };
+
+
+ /*
+ Class : SMESH_MinimumAngle
+ Description : Functor for calculation of minimum angle
+ */
+ class MinimumAngle: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( const TSequenceOfXYZ& thePoints );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+ };
+
+
+ /*
+ Class : AspectRatio
+ Description : Functor for calculating aspect ratio
+ */
+ class AspectRatio: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( const TSequenceOfXYZ& thePoints );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+ };
+
+
+ /*
+ Class : AspectRatio3D
+ Description : Functor for calculating aspect ratio of 3D elems.
+ */
+ class AspectRatio3D: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( const TSequenceOfXYZ& thePoints );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+ };
+
+
+ /*
+ Class : Warping
+ Description : Functor for calculating warping
+ */
+ class Warping: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( const TSequenceOfXYZ& thePoints );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+
+ private:
+ double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
+ };
+
+
+ /*
+ Class : Taper
+ Description : Functor for calculating taper
+ */
+ class Taper: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( const TSequenceOfXYZ& thePoints );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+ };
+
+
+ /*
+ Class : Skew
+ Description : Functor for calculating skew in degrees
+ */
+ class Skew: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( const TSequenceOfXYZ& thePoints );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+ };
+
+
+ /*
+ Class : Area
+ Description : Functor for calculating area
+ */
+ class Area: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( const TSequenceOfXYZ& thePoints );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+ };
+
+
+ /*
+ Class : Length
+ Description : Functor for calculating length of edge
+ */
+ class Length: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( const TSequenceOfXYZ& thePoints );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+ };
+
+ /*
+ Class : Length2D
+ Description : Functor for calculating length of edge
+ */
+ class Length2D: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( long theElementId );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+ struct Value{
+ double myLength;
+ long myPntId[2];
+ Value(double theLength, long thePntId1, long thePntId2);
+ bool operator<(const Value& x) const;
+ };
+ typedef std::set<Value> TValues;
+ void GetValues(TValues& theValues);
+
+ };
+ typedef boost::shared_ptr<Length2D> Length2DPtr;
+
+ /*
+ Class : MultiConnection
+ Description : Functor for calculating number of faces conneted to the edge
+ */
+ class MultiConnection: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( long theElementId );
+ virtual double GetValue( const TSequenceOfXYZ& thePoints );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+ };
+
+ /*
+ Class : MultiConnection2D
+ Description : Functor for calculating number of faces conneted to the edge
+ */
+ class MultiConnection2D: public virtual NumericalFunctor{
+ public:
+ virtual double GetValue( long theElementId );
+ virtual double GetValue( const TSequenceOfXYZ& thePoints );
+ virtual double GetBadRate( double Value, int nbNodes ) const;
+ virtual SMDSAbs_ElementType GetType() const;
+ struct Value{
+ long myPntId[2];
+ Value(long thePntId1, long thePntId2);
+ bool operator<(const Value& x) const;
+ };
+ typedef std::map<Value,int> MValues;
+
+ void GetValues(MValues& theValues);
+ };
+ typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
+ /*
+ PREDICATES
+ */
+ /*
+ Class : Predicate
+ Description : Base class for all predicates
+ */
+ class Predicate: public virtual Functor{
+ public:
+ virtual bool IsSatisfy( long theElementId ) = 0;
+ virtual SMDSAbs_ElementType GetType() const = 0;
+ };
+
+
+
+ /*
+ Class : FreeBorders
+ Description : Predicate for free borders
+ */
+ class FreeBorders: public virtual Predicate{
+ public:
+ FreeBorders();
+ virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual bool IsSatisfy( long theElementId );
+ virtual SMDSAbs_ElementType GetType() const;
+
+ protected:
+ SMDS_Mesh* myMesh;
+ };
+
+
+ /*
+ Class : FreeEdges
+ Description : Predicate for free Edges
+ */
+ class FreeEdges: public virtual Predicate{
+ public:
+ FreeEdges();
+ virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual bool IsSatisfy( long theElementId );
+ virtual SMDSAbs_ElementType GetType() const;
+ static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
+ typedef long TElemId;
+ struct Border{
+ TElemId myElemId;
+ TElemId myPntId[2];
+ Border(long theElemId, long thePntId1, long thePntId2);
+ bool operator<(const Border& x) const;
+ };
+ typedef std::set<Border> TBorders;
+ void GetBoreders(TBorders& theBorders);
+
+ protected:
+ SMDS_Mesh* myMesh;
+ };
+ typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
+
+
+ /*
+ Class : RangeOfIds
+ Description : Predicate for Range of Ids.
+ Range may be specified with two ways.
+ 1. Using AddToRange method
+ 2. With SetRangeStr method. Parameter of this method is a string
+ like as "1,2,3,50-60,63,67,70-"
+ */
+ class RangeOfIds: public virtual Predicate
+ {
+ public:
+ RangeOfIds();
+ virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual bool IsSatisfy( long theNodeId );
+ virtual SMDSAbs_ElementType GetType() const;
+ virtual void SetType( SMDSAbs_ElementType theType );
+
+ bool AddToRange( long theEntityId );
+ void GetRangeStr( TCollection_AsciiString& );
+ bool SetRangeStr( const TCollection_AsciiString& );
+
+ protected:
+ SMDS_Mesh* myMesh;
+
+ TColStd_SequenceOfInteger myMin;
+ TColStd_SequenceOfInteger myMax;
+ TColStd_MapOfInteger myIds;
+
+ SMDSAbs_ElementType myType;
+ };
+
+ typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
+
+
+ /*
+ Class : Comparator
+ Description : Base class for comparators
+ */
+ class Comparator: public virtual Predicate{
+ public:
+ Comparator();
+ virtual ~Comparator();
+ virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetMargin(double theValue);
+ virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
+ virtual bool IsSatisfy( long theElementId ) = 0;
+ virtual SMDSAbs_ElementType GetType() const;
+ double GetMargin();
+
+ protected:
+ double myMargin;
+ NumericalFunctorPtr myFunctor;
+ };
+ typedef boost::shared_ptr<Comparator> ComparatorPtr;
+
+
+ /*
+ Class : LessThan
+ Description : Comparator "<"
+ */
+ class LessThan: public virtual Comparator{
+ public:
+ virtual bool IsSatisfy( long theElementId );
+ };
+
+
+ /*
+ Class : MoreThan
+ Description : Comparator ">"
+ */
+ class MoreThan: public virtual Comparator{
+ public:
+ virtual bool IsSatisfy( long theElementId );
+ };
+
+
+ /*
+ Class : EqualTo
+ Description : Comparator "="
+ */
+ class EqualTo: public virtual Comparator{
+ public:
+ EqualTo();
+ virtual bool IsSatisfy( long theElementId );
+ virtual void SetTolerance( double theTol );
+ virtual double GetTolerance();
+
+ private:
+ double myToler;
+ };
+ typedef boost::shared_ptr<EqualTo> EqualToPtr;
+
+
+ /*
+ Class : LogicalNOT
+ Description : Logical NOT predicate
+ */
+ class LogicalNOT: public virtual Predicate{
+ public:
+ LogicalNOT();
+ virtual ~LogicalNOT();
+ virtual bool IsSatisfy( long theElementId );
+ virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetPredicate(PredicatePtr thePred);
+ virtual SMDSAbs_ElementType GetType() const;
+
+ private:
+ PredicatePtr myPredicate;
+ };
+ typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
+
+
+ /*
+ Class : LogicalBinary
+ Description : Base class for binary logical predicate
+ */
+ class LogicalBinary: public virtual Predicate{
+ public:
+ LogicalBinary();
+ virtual ~LogicalBinary();
+ virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetPredicate1(PredicatePtr thePred);
+ virtual void SetPredicate2(PredicatePtr thePred);
+ virtual SMDSAbs_ElementType GetType() const;
+
+ protected:
+ PredicatePtr myPredicate1;
+ PredicatePtr myPredicate2;
+ };
+ typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
+
+
+ /*
+ Class : LogicalAND
+ Description : Logical AND
+ */
+ class LogicalAND: public virtual LogicalBinary{
+ public:
+ virtual bool IsSatisfy( long theElementId );
+ };
+
+
+ /*
+ Class : LogicalOR
+ Description : Logical OR
+ */
+ class LogicalOR: public virtual LogicalBinary{
+ public:
+ virtual bool IsSatisfy( long theElementId );
+ };
+
+
+ /*
+ Class : ManifoldPart
+ Description : Predicate for manifold part of mesh
+ */
+ class ManifoldPart: public virtual Predicate{
+ public:
+
+ /* internal class for algorithm uses */
+ class Link
+ {
+ public:
+ Link( SMDS_MeshNode* theNode1,
+ SMDS_MeshNode* theNode2 );
+ ~Link();
+
+ bool IsEqual( const ManifoldPart::Link& theLink ) const;
+ bool operator<(const ManifoldPart::Link& x) const;
+
+ SMDS_MeshNode* myNode1;
+ SMDS_MeshNode* myNode2;
+ };
+
+ bool IsEqual( const ManifoldPart::Link& theLink1,
+ const ManifoldPart::Link& theLink2 );
+
+ typedef std::set<ManifoldPart::Link> TMapOfLink;
+ typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
+ typedef std::vector<ManifoldPart::Link> TVectorOfLink;
+ typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
+ typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
+
+ ManifoldPart();
+ ~ManifoldPart();
+ virtual void SetMesh( SMDS_Mesh* theMesh );
+ // inoke when all parameters already set
+ virtual bool IsSatisfy( long theElementId );
+ virtual SMDSAbs_ElementType GetType() const;
+
+ void SetAngleTolerance( const double theAngToler );
+ double GetAngleTolerance() const;
+ void SetIsOnlyManifold( const bool theIsOnly );
+ void SetStartElem( const long theStartElemId );
+
+ private:
+ bool process();
+ bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
+ SMDS_MeshFace* theStartFace,
+ TMapOfLink& theNonManifold,
+ TColStd_MapOfInteger& theResFaces );
+ bool isInPlane( const SMDS_MeshFace* theFace1,
+ const SMDS_MeshFace* theFace2 );
+ void expandBoundary( TMapOfLink& theMapOfBoundary,
+ TVectorOfLink& theSeqOfBoundary,
+ TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
+ TMapOfLink& theNonManifold,
+ SMDS_MeshFace* theNextFace ) const;
+
+ void getFacesByLink( const Link& theLink,
+ TVectorOfFacePtr& theFaces ) const;
+
+ private:
+ SMDS_Mesh* myMesh;
+ TColStd_MapOfInteger myMapIds;
+ TColStd_MapOfInteger myMapBadGeomIds;
+ TVectorOfFacePtr myAllFacePtr;
+ TDataMapFacePtrInt myAllFacePtrIntDMap;
+ double myAngToler;
+ bool myIsOnlyManifold;
+ long myStartElemId;
+
+ };
+ typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
+
+
+ /*
+ Class : ElementsOnSurface
+ Description : Predicate elements that lying on indicated surface
+ (plane or cylinder)
+ */
+ class ElementsOnSurface : public virtual Predicate {
+ public:
+ ElementsOnSurface();
+ ~ElementsOnSurface();
+ virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual bool IsSatisfy( long theElementId );
+ virtual SMDSAbs_ElementType GetType() const;
+
+ void SetTolerance( const double theToler );
+ double GetTolerance() const;
+ void SetSurface( const TopoDS_Shape& theShape,
+ const SMDSAbs_ElementType theType );
+
+ private:
+ void process();
+ void process( const SMDS_MeshElement* theElem );
+ bool isOnSurface( const SMDS_MeshNode* theNode ) const;
+
+ private:
+ SMDS_Mesh* myMesh;
+ TColStd_MapOfInteger myIds;
+ SMDSAbs_ElementType myType;
+ Handle(Geom_Surface) mySurf;
+ double myToler;
+ };
+
+ typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
+
+
+ /*
+ FILTER
+ */
+ class Filter{
+ public:
+ Filter();
+ virtual ~Filter();
+ virtual void SetPredicate(PredicatePtr thePred);
+ typedef std::vector<long> TIdSequence;
+ virtual TIdSequence GetElementsId( SMDS_Mesh* theMesh );
+
+ protected:
+ PredicatePtr myPredicate;
+ };
+ };
+};
+
+
+#endif
LIB_SERVER_IDL =
# additionnal information to compil and link file
-CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
+CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(OCC_INCLUDES) $(BOOST_CPPFLAGS)
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome
-LDFLAGS += -lMeshDriver
+LDFLAGS += -lMeshDriver $(OCC_KERNEL_LIBS)
LDFLAGSFORBIN += -lMeshDriver -lSMDS -L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lSALOMELocalTrace
// $Header$
#include "DriverMED_Family.h"
+#include "MED_Factory.hxx"
+
#include <sstream>
using namespace std;
* Create TFamilyInfo for this family
*/
//=============================================================================
-MEDA::PFamilyInfo DriverMED_Family::GetFamilyInfo
- (const MEDA::PMeshInfo& theMeshInfo) const
+MED::PFamilyInfo
+DriverMED_Family::GetFamilyInfo(const MED::PWrapper& theWrapper,
+ const MED::PMeshInfo& theMeshInfo) const
{
string aValue;
ostringstream aStr;
MED::TIntVector anAttrIds (1, myId); // Id=0,
MED::TIntVector anAttrVals (1, myId); // Value=0
- MEDA::PFamilyInfo anInfo = MEDA::TWrapper::CrFamilyInfo(theMeshInfo,
- aValue,
- myId,
- myGroupNames,
- anAttrDescs,anAttrIds,anAttrVals);
+ MED::PFamilyInfo anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
+ aValue,
+ myId,
+ myGroupNames,
+ anAttrDescs,
+ anAttrIds,
+ anAttrVals);
// cout << endl;
// cout << "Groups: ";
#include "SMDS_Mesh.hxx"
#include "SMESHDS_GroupBase.hxx"
#include "SMESHDS_SubMesh.hxx"
-#include "MEDA_Wrapper.hxx"
+#include "MED_Common.hxx"
#include <boost/shared_ptr.hpp>
#include <set>
// from <theGroups> and other sub-meshes from <theSubMeshes>.
// Resulting families have no common elements.
- MEDA::PFamilyInfo GetFamilyInfo (const MEDA::PMeshInfo& theMeshInfo) const;
+ MED::PFamilyInfo GetFamilyInfo (const MED::PWrapper& theWrapper,
+ const MED::PMeshInfo& theMeshInfo) const;
// Create TFamilyInfo for this family
const std::set<const SMDS_MeshElement *>& GetElements () const { return myElements; }
#include "SMESHDS_Group.hxx"
-#include "MEDA_Wrapper.hxx"
+#include "MED_Factory.hxx"
#include "MED_Utilities.hxx"
#include <stdlib.h>
#define _EDF_NODE_IDS_
+using namespace MED;
+
void DriverMED_R_SMESHDS_Mesh::SetMeshName(string theMeshName)
{
myMeshName = theMeshName;
}
static const SMDS_MeshNode*
-FindNode(const SMDS_Mesh* theMesh, med_int theId){
+FindNode(const SMDS_Mesh* theMesh, TInt theId){
const SMDS_MeshNode* aNode = theMesh->FindNode(theId);
if(aNode) return aNode;
EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
enum ECoordName{eX, eY, eZ, eNone};
-typedef med_float (*TGetCoord)(MEDA::PNodeInfo&, med_int);
+typedef TFloat (*TGetCoord)(MED::PNodeInfo&, TInt);
template<ECoordName TheCoordId>
-med_float GetCoord(MEDA::PNodeInfo& thePNodeInfo, med_int theElemId){
+TFloat GetCoord(MED::PNodeInfo& thePNodeInfo, TInt theElemId){
return thePNodeInfo->GetNodeCoord(theElemId,TheCoordId);
}
template<>
-med_float GetCoord<eNone>(MEDA::PNodeInfo& thePNodeInfo, med_int theElemId){
+TFloat GetCoord<eNone>(MED::PNodeInfo& thePNodeInfo, TInt theElemId){
return 0.0;
}
class TCoordHelper{
- MEDA::PNodeInfo myPNodeInfo;
+ MED::PNodeInfo myPNodeInfo;
TGetCoord* myGetCoord;
public:
- TCoordHelper(const MEDA::PNodeInfo& thePNodeInfo,
+ TCoordHelper(const MED::PNodeInfo& thePNodeInfo,
TGetCoord* theGetCoord):
myPNodeInfo(thePNodeInfo),
myGetCoord(theGetCoord)
{}
virtual ~TCoordHelper(){}
- med_float GetCoord(med_int theElemId, med_int theCoodId){
+ TFloat GetCoord(TInt theElemId, TInt theCoodId){
return (*myGetCoord[theCoodId])(myPNodeInfo,theElemId);
}
};
{
Status aResult = DRS_FAIL;
try{
- using namespace MEDA;
-
myFamilies.clear();
MESSAGE("Perform - myFile : "<<myFile);
- TWrapper aMed(myFile);
+ PWrapper aMed = CrWrapper(myFile);
aResult = DRS_EMPTY;
- if(med_int aNbMeshes = aMed.GetNbMeshes()){
+ if(TInt aNbMeshes = aMed->GetNbMeshes()){
for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){
// Reading the MED mesh
//---------------------
- PMeshInfo aMeshInfo = aMed.GetMeshInfo(iMesh);
+ PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh+1);
string aMeshName;
if (myMeshId != -1) {
ostringstream aMeshNameStr;
MESSAGE("Perform - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
if(aMeshName != aMeshInfo->GetName()) continue;
aResult = DRS_OK;
- med_int aMeshDim = aMeshInfo->GetDim();
+ //TInt aMeshDim = aMeshInfo->GetDim();
// Reading MED families to the temporary structure
//------------------------------------------------
- med_int aNbFams = aMed.GetNbFamilies(aMeshInfo);
+ TInt aNbFams = aMed->GetNbFamilies(aMeshInfo);
MESSAGE("Read " << aNbFams << " families");
- for (med_int iFam = 0; iFam < aNbFams; iFam++) {
- PFamilyInfo aFamilyInfo = aMed.GetFamilyInfo(aMeshInfo, iFam);
- med_int aFamId = aFamilyInfo->GetId();
+ for (TInt iFam = 0; iFam < aNbFams; iFam++) {
+ PFamilyInfo aFamilyInfo = aMed->GetPFamilyInfo(aMeshInfo, iFam+1);
+ TInt aFamId = aFamilyInfo->GetId();
MESSAGE("Family " << aFamId << " :");
DriverMED_FamilyPtr aFamily (new DriverMED_Family);
- med_int aNbGrp = aFamilyInfo->GetNbGroup();
+ TInt aNbGrp = aFamilyInfo->GetNbGroup();
MESSAGE("belong to " << aNbGrp << " groups");
- for (med_int iGr = 0; iGr < aNbGrp; iGr++) {
+ for (TInt iGr = 0; iGr < aNbGrp; iGr++) {
string aGroupName = aFamilyInfo->GetGroupName(iGr);
MESSAGE(aGroupName);
aFamily->AddGroupName(aGroupName);
// Reading MED nodes to the corresponding SMDS structure
//------------------------------------------------------
- PNodeInfo aNodeInfo = aMed.GetNodeInfo(aMeshInfo);
+ PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
TCoordHelperPtr aCoordHelperPtr;
{
- med_int aMeshDimension = aMeshInfo->GetDim();
+ TInt aMeshDimension = aMeshInfo->GetDim();
bool anIsDimPresent[3] = {false, false, false};
- for(med_int iDim = 0; iDim < aMeshDimension; iDim++){
+ for(TInt iDim = 0; iDim < aMeshDimension; iDim++){
string aDimName = aNodeInfo->GetCoordName(iDim);
if(aDimName == "x" || aDimName == "X")
anIsDimPresent[eX] = true;
}
}
- med_booleen anIsNodeNum = aNodeInfo->IsElemNum();
- med_int aNbElems = aNodeInfo->GetNbElem();
+ EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
+ TInt aNbElems = aNodeInfo->GetNbElem();
MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
- for(med_int iElem = 0; iElem < aNbElems; iElem++){
+ for(TInt iElem = 0; iElem < aNbElems; iElem++){
double aCoords[3] = {0.0, 0.0, 0.0};
- for(med_int iDim = 0; iDim < 3; iDim++)
+ for(TInt iDim = 0; iDim < 3; iDim++)
aCoords[iDim] = aCoordHelperPtr->GetCoord(iElem,iDim);
const SMDS_MeshNode* aNode;
if(anIsNodeNum) {
//cout<<aNode->GetID()<<": "<<aNode->X()<<", "<<aNode->Y()<<", "<<aNode->Z()<<endl;
// Save reference to this node from its family
- med_int aFamNum = aNodeInfo->GetFamNum(iElem);
+ TInt aFamNum = aNodeInfo->GetFamNum(iElem);
if (myFamilies.find(aFamNum) != myFamilies.end())
{
myFamilies[aFamNum]->AddElement(aNode);
// Reading pre information about all MED cells
//--------------------------------------------
bool takeNumbers = true; // initially we trust the numbers from file
- MED::TEntityInfo aEntityInfo = aMed.GetEntityInfo(aMeshInfo);
+ MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin();
for(; anEntityIter != aEntityInfo.end(); anEntityIter++){
- const med_entite_maillage& anEntity = anEntityIter->first;
- if(anEntity == MED_NOEUD) continue;
+ const EEntiteMaillage& anEntity = anEntityIter->first;
+ if(anEntity == eNOEUD) continue;
// Reading MED cells to the corresponding SMDS structure
//------------------------------------------------------
const MED::TGeom& aTGeom = anEntityIter->second;
MED::TGeom::const_iterator anTGeomIter = aTGeom.begin();
for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
- const med_geometrie_element& aGeom = anTGeomIter->first;
- if(aGeom == MED_POINT1) continue;
- PCellInfo aCellInfo = aMed.GetCellInfo(aMeshInfo,anEntity,aGeom);
- med_booleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : MED_FAUX;
- med_int aNbElems = aCellInfo->GetNbElem();
+ const EGeometrieElement& aGeom = anTGeomIter->first;
+ if(aGeom == ePOINT1) continue;
+ PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
+ EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
+ TInt aNbElems = aCellInfo->GetNbElem();
MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
for(int iElem = 0; iElem < aNbElems; iElem++){
- med_int aNbNodes = -1;
+ TInt aNbNodes = -1;
switch(aGeom){
- case MED_SEG2:
- case MED_SEG3:
+ case eSEG2:
+ case eSEG3:
aNbNodes = 2;
break;
- case MED_TRIA3:
- case MED_TRIA6:
+ case eTRIA3:
+ case eTRIA6:
aNbNodes = 3;
break;
break;
- case MED_QUAD4:
- case MED_QUAD8:
+ case eQUAD4:
+ case eQUAD8:
aNbNodes = 4;
break;
- case MED_TETRA4:
- case MED_TETRA10:
+ case eTETRA4:
+ case eTETRA10:
aNbNodes = 4;
break;
- case MED_PYRA5:
- case MED_PYRA13:
+ case ePYRA5:
+ case ePYRA13:
aNbNodes = 5;
break;
- case MED_PENTA6:
- case MED_PENTA15:
+ case ePENTA6:
+ case ePENTA15:
aNbNodes = 6;
break;
- case MED_HEXA8:
- case MED_HEXA20:
+ case eHEXA8:
+ case eHEXA20:
aNbNodes = 8;
break;
}
- vector<med_int> aNodeIds(aNbNodes);
+ vector<TInt> aNodeIds(aNbNodes);
#ifdef _EDF_NODE_IDS_
if(anIsNodeNum) {
for(int i = 0; i < aNbNodes; i++){
bool isRenum = false;
SMDS_MeshElement* anElement = NULL;
- med_int aFamNum = aCellInfo->GetFamNum(iElem);
+ TInt aFamNum = aCellInfo->GetFamNum(iElem);
try{
switch(aGeom){
- case MED_SEG2:
- case MED_SEG3:
+ case eSEG2:
+ case eSEG3:
if(anIsElemNum)
anElement = myMesh->AddEdgeWithID(aNodeIds[0],
aNodeIds[1],
isRenum = anIsElemNum;
}
break;
- case MED_TRIA3:
- case MED_TRIA6:
+ case eTRIA3:
+ case eTRIA6:
aNbNodes = 3;
if(anIsElemNum)
anElement = myMesh->AddFaceWithID(aNodeIds[0],
isRenum = anIsElemNum;
}
break;
- case MED_QUAD4:
- case MED_QUAD8:
+ case eQUAD4:
+ case eQUAD8:
aNbNodes = 4;
// There is some differnce between SMDS and MED
if(anIsElemNum)
isRenum = anIsElemNum;
}
break;
- case MED_TETRA4:
- case MED_TETRA10:
+ case eTETRA4:
+ case eTETRA10:
aNbNodes = 4;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0],
isRenum = anIsElemNum;
}
break;
- case MED_PYRA5:
- case MED_PYRA13:
+ case ePYRA5:
+ case ePYRA13:
aNbNodes = 5;
// There is some differnce between SMDS and MED
if(anIsElemNum)
isRenum = anIsElemNum;
}
break;
- case MED_PENTA6:
- case MED_PENTA15:
+ case ePENTA6:
+ case ePENTA15:
aNbNodes = 6;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0],
isRenum = anIsElemNum;
}
break;
- case MED_HEXA8:
- case MED_HEXA20:
+ case eHEXA8:
+ case eHEXA20:
aNbNodes = 8;
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0],
}
else {
if (isRenum) {
- anIsElemNum = MED_FAUX;
+ anIsElemNum = eFAUX;
takeNumbers = false;
if (aResult < DRS_WARN_RENUMBER)
aResult = DRS_WARN_RENUMBER;
list<string> aMeshNames;
try {
- using namespace MEDA;
-
MESSAGE("GetMeshNames - myFile : " << myFile);
theStatus = DRS_OK;
- TWrapper aMed (myFile);
+ PWrapper aMed = CrWrapper(myFile);
- if (med_int aNbMeshes = aMed.GetNbMeshes()) {
+ if (TInt aNbMeshes = aMed->GetNbMeshes()) {
for (int iMesh = 0; iMesh < aNbMeshes; iMesh++) {
// Reading the MED mesh
//---------------------
- PMeshInfo aMeshInfo = aMed.GetMeshInfo(iMesh);
+ PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh+1);
aMeshNames.push_back(aMeshInfo->GetName());
}
}
#include "SMDS_MeshNode.hxx"
#include "utilities.h"
-#include "MEDA_Wrapper.hxx"
+#include "MED_Factory.hxx"
#include "MED_Utilities.hxx"
#define _EDF_NODE_IDS_
//#define _ELEMENTS_BY_DIM_
using namespace std;
+using namespace MED;
+
DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh():
myAllSubMeshes (false),
myDoGroupOfVolumes (false)
{}
+void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName, MED::EVersion theId)
+{
+ myMed = CrWrapper(theFileName,theId);
+ Driver_SMESHDS_Mesh::SetFile(theFileName);
+}
+
+void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName)
+{
+ return SetFile(theFileName,MED::eV2_1);
+}
+
void DriverMED_W_SMESHDS_Mesh::SetMeshName(const std::string& theMeshName)
{
myMeshName = theMeshName;
myDoGroupOfVolumes = true;
}
-typedef double (SMDS_MeshNode::* TGetCoord)() const;
-typedef const char* TName;
-typedef const char* TUnit;
-
-static TUnit aUnit[3] = {"m","m","m"};
-
-static TGetCoord aXYZGetCoord[3] = {
- &SMDS_MeshNode::X,
- &SMDS_MeshNode::Y,
- &SMDS_MeshNode::Z
-};
-static TName aXYZName[3] = {"x","y","z"};
-
-
-static TGetCoord aXYGetCoord[2] = {
- &SMDS_MeshNode::X,
- &SMDS_MeshNode::Y
-};
-static TName aXYName[2] = {"x","y"};
-
-static TGetCoord aYZGetCoord[2] = {
- &SMDS_MeshNode::Y,
- &SMDS_MeshNode::Z
-};
-static TName aYZName[2] = {"y","z"};
-
-static TGetCoord aXZGetCoord[2] = {
- &SMDS_MeshNode::X,
- &SMDS_MeshNode::Z
-};
-static TName aXZName[2] = {"x","z"};
-
-
-static TGetCoord aXGetCoord[1] = {
- &SMDS_MeshNode::X
-};
-static TName aXName[1] = {"x"};
-
-static TGetCoord aYGetCoord[1] = {
- &SMDS_MeshNode::Y
-};
-static TName aYName[1] = {"y"};
-
-static TGetCoord aZGetCoord[1] = {
- &SMDS_MeshNode::Z
-};
-static TName aZName[1] = {"z"};
-
-
-class TCoordHelper{
- SMDS_NodeIteratorPtr myNodeIter;
- const SMDS_MeshNode* myCurrentNode;
- TGetCoord* myGetCoord;
- TName* myName;
- TUnit* myUnit;
-public:
- TCoordHelper(const SMDS_NodeIteratorPtr& theNodeIter,
- TGetCoord* theGetCoord,
- TName* theName,
- TUnit* theUnit = aUnit):
- myNodeIter(theNodeIter),
- myGetCoord(theGetCoord),
- myName(theName),
- myUnit(theUnit)
- {}
- virtual ~TCoordHelper(){}
- bool Next(){
- return myNodeIter->more() &&
- (myCurrentNode = myNodeIter->next());
- }
- const SMDS_MeshNode* GetNode(){
- return myCurrentNode;
- }
- MED::TIntVector::value_type GetID(){
- return myCurrentNode->GetID();
- }
- MED::TFloatVector::value_type GetCoord(med_int theCoodId){
- return (myCurrentNode->*myGetCoord[theCoodId])();
- }
- MED::TStringVector::value_type GetName(med_int theDimId){
- return myName[theDimId];
- }
- MED::TStringVector::value_type GetUnit(med_int theDimId){
- return myUnit[theDimId];
- }
-};
-typedef boost::shared_ptr<TCoordHelper> TCoordHelperPtr;
-
+namespace{
+ typedef double (SMDS_MeshNode::* TGetCoord)() const;
+ typedef const char* TName;
+ typedef const char* TUnit;
+
+ TUnit aUnit[3] = {"m","m","m"};
+
+ TGetCoord aXYZGetCoord[3] = {
+ &SMDS_MeshNode::X,
+ &SMDS_MeshNode::Y,
+ &SMDS_MeshNode::Z
+ };
+ TName aXYZName[3] = {"x","y","z"};
+
+
+ TGetCoord aXYGetCoord[2] = {
+ &SMDS_MeshNode::X,
+ &SMDS_MeshNode::Y
+ };
+ TName aXYName[2] = {"x","y"};
+
+ TGetCoord aYZGetCoord[2] = {
+ &SMDS_MeshNode::Y,
+ &SMDS_MeshNode::Z
+ };
+ TName aYZName[2] = {"y","z"};
+
+ TGetCoord aXZGetCoord[2] = {
+ &SMDS_MeshNode::X,
+ &SMDS_MeshNode::Z
+ };
+ TName aXZName[2] = {"x","z"};
+
+
+ TGetCoord aXGetCoord[1] = {
+ &SMDS_MeshNode::X
+ };
+ TName aXName[1] = {"x"};
+
+ TGetCoord aYGetCoord[1] = {
+ &SMDS_MeshNode::Y
+ };
+ TName aYName[1] = {"y"};
+
+ TGetCoord aZGetCoord[1] = {
+ &SMDS_MeshNode::Z
+ };
+ TName aZName[1] = {"z"};
+
+
+ class TCoordHelper{
+ SMDS_NodeIteratorPtr myNodeIter;
+ const SMDS_MeshNode* myCurrentNode;
+ TGetCoord* myGetCoord;
+ TName* myName;
+ TUnit* myUnit;
+ public:
+ TCoordHelper(const SMDS_NodeIteratorPtr& theNodeIter,
+ TGetCoord* theGetCoord,
+ TName* theName,
+ TUnit* theUnit = aUnit):
+ myNodeIter(theNodeIter),
+ myGetCoord(theGetCoord),
+ myName(theName),
+ myUnit(theUnit)
+ {}
+ virtual ~TCoordHelper(){}
+ bool Next(){
+ return myNodeIter->more() &&
+ (myCurrentNode = myNodeIter->next());
+ }
+ const SMDS_MeshNode* GetNode(){
+ return myCurrentNode;
+ }
+ MED::TIntVector::value_type GetID(){
+ return myCurrentNode->GetID();
+ }
+ MED::TFloatVector::value_type GetCoord(TInt theCoodId){
+ return (myCurrentNode->*myGetCoord[theCoodId])();
+ }
+ MED::TStringVector::value_type GetName(TInt theDimId){
+ return myName[theDimId];
+ }
+ MED::TStringVector::value_type GetUnit(TInt theDimId){
+ return myUnit[theDimId];
+ }
+ };
+ typedef boost::shared_ptr<TCoordHelper> TCoordHelperPtr;
+
+}
+
Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
{
Status aResult = DRS_OK;
return DRS_FAIL;
}
try{
- using namespace MEDA;
- using namespace boost;
-
MESSAGE("Perform - myFile : "<<myFile);
- TWrapper aMed(myFile);
// Creating the MED mesh for corresponding SMDS structure
//-------------------------------------------------------
}
// Mesh dimension definition
- med_int aMeshDimension;
+ TInt aMeshDimension;
TCoordHelperPtr aCoordHelperPtr;
{
bool anIsXDimension = false;
anIsXDimension = (aBounds[1] - aBounds[0]) + abs(aBounds[1]) + abs(aBounds[0]) > EPS;
anIsYDimension = (aBounds[3] - aBounds[2]) + abs(aBounds[3]) + abs(aBounds[2]) > EPS;
anIsZDimension = (aBounds[5] - aBounds[4]) + abs(aBounds[5]) + abs(aBounds[4]) > EPS;
-
aMeshDimension = anIsXDimension + anIsYDimension + anIsZDimension;
if(!aMeshDimension)
aMeshDimension = 3;
}
- PMeshInfo aMeshInfo = TWrapper::CrMeshInfo(aMeshDimension,aMeshName);
+ PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aMeshName);
MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
- aMed.SetMeshInfo(aMeshInfo);
+ myMed->SetMeshInfo(aMeshInfo);
// Storing SMDS groups and sub-meshes
//-----------------------------------
for (; aFamsIter != aFamilies.end(); aFamsIter++)
{
- PFamilyInfo aFamilyInfo = (*aFamsIter)->GetFamilyInfo(aMeshInfo);
- aMed.SetFamilyInfo(aFamilyInfo);
+ PFamilyInfo aFamilyInfo = (*aFamsIter)->GetFamilyInfo(myMed,aMeshInfo);
+ myMed->SetFamilyInfo(aFamilyInfo);
int aFamId = (*aFamsIter)->GetId();
const set<const SMDS_MeshElement *>& anElems = (*aFamsIter)->GetElements();
// Storing SMDS nodes to the MED file for the MED mesh
//----------------------------------------------------
#ifdef _EDF_NODE_IDS_
- typedef map<med_int,med_int> TNodeIdMap;
+ typedef map<TInt,TInt> TNodeIdMap;
TNodeIdMap aNodeIdMap;
#endif
- med_int aNbElems = myMesh->NbNodes();
+ TInt aNbElems = myMesh->NbNodes();
MED::TIntVector anElemNums(aNbElems);
MED::TIntVector aFamilyNums(aNbElems);
MED::TFloatVector aCoordinates(aNbElems*aMeshDimension);
- for(med_int iNode = 0, aStartId = 0; aCoordHelperPtr->Next(); iNode++, aStartId += aMeshDimension){
- for(med_int iCoord = 0; iCoord < aMeshDimension; iCoord++){
+ for(TInt iNode = 0, aStartId = 0; aCoordHelperPtr->Next(); iNode++, aStartId += aMeshDimension){
+ for(TInt iCoord = 0; iCoord < aMeshDimension; iCoord++){
aCoordinates[aStartId+iCoord] = aCoordHelperPtr->GetCoord(iCoord);
}
int aNodeID = aCoordHelperPtr->GetID();
MED::TStringVector aCoordNames(aMeshDimension);
MED::TStringVector aCoordUnits(aMeshDimension);
- for(med_int iCoord = 0; iCoord < aMeshDimension; iCoord++){
+ for(TInt iCoord = 0; iCoord < aMeshDimension; iCoord++){
aCoordNames[iCoord] = aCoordHelperPtr->GetName(iCoord);
aCoordUnits[iCoord] = aCoordHelperPtr->GetUnit(iCoord);
}
- const med_repere SMDS_COORDINATE_SYSTEM = MED_CART;
+ const ERepere SMDS_COORDINATE_SYSTEM = eCART;
- PNodeInfo aNodeInfo = TWrapper::CrNodeInfo(aMeshInfo,
- SMDS_COORDINATE_SYSTEM,
- aCoordinates,
- aCoordNames,
- aCoordUnits,
- aFamilyNums,
- anElemNums);
+ PNodeInfo aNodeInfo = myMed->CrNodeInfo(aMeshInfo,
+ SMDS_COORDINATE_SYSTEM,
+ aCoordinates,
+ aCoordNames,
+ aCoordUnits,
+ aFamilyNums,
+ anElemNums);
MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems);
- aMed.SetNodeInfo(aNodeInfo);
+ myMed->SetNodeInfo(aNodeInfo);
// Storing others SMDS elements to the MED file for the MED mesh
//--------------------------------------------------------------
- med_entite_maillage SMDS_MED_ENTITY = MED_MAILLE;
- const med_connectivite SMDS_MED_CONNECTIVITY = MED_NOD;
+ EEntiteMaillage SMDS_MED_ENTITY = eMAILLE;
+ const EConnectivite SMDS_MED_CONNECTIVITY = eNOD;
// Storing SMDS Edges
- if(med_int aNbElems = myMesh->NbEdges()){
+ if(TInt aNbElems = myMesh->NbEdges()){
#ifdef _ELEMENTS_BY_DIM_
- SMDS_MED_ENTITY = MED_ARETE;
+ SMDS_MED_ENTITY = eARETE;
#endif
SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
- med_int aNbConnectivity = MED::GetNbConn(SMDS_MED_ENTITY,MED_SEG2,aMeshDimension);
+ TInt aNbConnectivity = MED::GetNbConn(SMDS_MED_ENTITY,eSEG2,aMeshDimension);
MED::TIntVector anElemNums(aNbElems);
MED::TIntVector aFamilyNums(aNbElems);
MED::TIntVector aConnectivity(aNbElems*aNbConnectivity);
- for(med_int iElem = 0, iConn = 0; anIter->more(); iElem++, iConn+=aNbConnectivity){
+ for(TInt iElem = 0, iConn = 0; anIter->more(); iElem++, iConn+=aNbConnectivity){
const SMDS_MeshEdge* anElem = anIter->next();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
- for(med_int iNode = 0; iNode < aNbConnectivity && aNodesIter->more(); iNode++){
+ for(TInt iNode = 0; iNode < aNbConnectivity && aNodesIter->more(); iNode++){
const SMDS_MeshElement* aNode = aNodesIter->next();
#ifdef _EDF_NODE_IDS_
aConnectivity[iConn+iNode] = aNodeIdMap[aNode->GetID()];
aFamilyNums[iElem] = myEdgesDefaultFamilyId;
}
- PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
- SMDS_MED_ENTITY,
- MED_SEG2,
- SMDS_MED_CONNECTIVITY,
- aConnectivity,
- aFamilyNums,
- anElemNums);
- aMed.SetCellInfo(aCellInfo);
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eSEG2,
+ SMDS_MED_CONNECTIVITY,
+ aConnectivity,
+ aFamilyNums,
+ anElemNums);
+ myMed->SetCellInfo(aCellInfo);
}
// Storing SMDS Faces
- if(med_int aNbElems = myMesh->NbFaces()){
+ if(TInt aNbElems = myMesh->NbFaces()){
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
#ifdef _ELEMENTS_BY_DIM_
- SMDS_MED_ENTITY = MED_FACE;
+ SMDS_MED_ENTITY = eFACE;
#endif
- med_int aNbTriaConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_TRIA3,aMeshDimension);
+ TInt aNbTriaConn = MED::GetNbConn(SMDS_MED_ENTITY,eTRIA3,aMeshDimension);
MED::TIntVector anTriaElemNums;
anTriaElemNums.reserve(aNbElems);
MED::TIntVector aTriaFamilyNums;
MED::TIntVector aTriaConn;
aTriaConn.reserve(aNbElems*aNbTriaConn);
- med_int aNbQuadConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_QUAD4,aMeshDimension);
+ TInt aNbQuadConn = MED::GetNbConn(SMDS_MED_ENTITY,eQUAD4,aMeshDimension);
MED::TIntVector aQuadElemNums;
aQuadElemNums.reserve(aNbElems);
MED::TIntVector aQuadFamilyNums;
MED::TIntVector aQuadConn;
aQuadConn.reserve(aNbElems*aNbQuadConn);
- for(med_int iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
+ for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
const SMDS_MeshFace* anElem = anIter->next();
- med_int aNbNodes = anElem->NbNodes();
+ TInt aNbNodes = anElem->NbNodes();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
- med_int aNbConnectivity;
+ TInt aNbConnectivity;
MED::TIntVector* anElemNums;
MED::TIntVector* aFamilyNums;
MED::TIntVector* aConnectivity;
break;
}
MED::TIntVector aVector(aNbNodes);
- for(med_int iNode = 0; aNodesIter->more(); iNode++){
+ for(TInt iNode = 0; aNodesIter->more(); iNode++){
const SMDS_MeshElement* aNode = aNodesIter->next();
aVector[iNode] = aNode->GetID();
}
- med_int aSize = aConnectivity->size();
+ TInt aSize = aConnectivity->size();
aConnectivity->resize(aSize+aNbConnectivity);
// There is some differnce between SMDS and MED in cells mapping
#ifdef _EDF_NODE_IDS_
(*aConnectivity)[aSize+2] = aNodeIdMap[aVector[3]];
(*aConnectivity)[aSize+3] = aNodeIdMap[aVector[2]];
default:
- for(med_int iNode = 0; iNode < aNbNodes; iNode++)
+ for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aNodeIdMap[aVector[iNode]];
}
#else
(*aConnectivity)[aSize+2] = aVector[3];
(*aConnectivity)[aSize+3] = aVector[2];
default:
- for(med_int iNode = 0; iNode < aNbNodes; iNode++)
+ for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aVector[iNode];
}
#endif
else
aFamilyNums->push_back(myFacesDefaultFamilyId);
}
- if(med_int aNbElems = anTriaElemNums.size()){
- PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
- SMDS_MED_ENTITY,
- MED_TRIA3,
- SMDS_MED_CONNECTIVITY,
- aTriaConn,
- aTriaFamilyNums,
- anTriaElemNums);
- MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_TRIA3<<"; aNbElems = "<<aNbElems);
- aMed.SetCellInfo(aCellInfo);
+ if(TInt aNbElems = anTriaElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eTRIA3,
+ SMDS_MED_CONNECTIVITY,
+ aTriaConn,
+ aTriaFamilyNums,
+ anTriaElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTRIA3<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
}
- if(med_int aNbElems = aQuadElemNums.size()){
- PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
- SMDS_MED_ENTITY,
- MED_QUAD4,
- SMDS_MED_CONNECTIVITY,
- aQuadConn,
- aQuadFamilyNums,
- aQuadElemNums);
- MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_QUAD4<<"; aNbElems = "<<aNbElems);
- aMed.SetCellInfo(aCellInfo);
+ if(TInt aNbElems = aQuadElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eQUAD4,
+ SMDS_MED_CONNECTIVITY,
+ aQuadConn,
+ aQuadFamilyNums,
+ aQuadElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD4<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
}
}
// Storing SMDS Volumes
- if(med_int aNbElems = myMesh->NbVolumes()){
+ if(TInt aNbElems = myMesh->NbVolumes()){
SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
#ifdef _ELEMENTS_BY_DIM_
- SMDS_MED_ENTITY = MED_MAILLE;
+ SMDS_MED_ENTITY = eMAILLE;
#endif
- med_int aNbTetraConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_TETRA4,aMeshDimension);
+ TInt aNbTetraConn = MED::GetNbConn(SMDS_MED_ENTITY,eTETRA4,aMeshDimension);
MED::TIntVector anTetraElemNums;
anTetraElemNums.reserve(aNbElems);
MED::TIntVector aTetraFamilyNums;
MED::TIntVector aTetraConn;
aTetraConn.reserve(aNbElems*aNbTetraConn);
- med_int aNbPyraConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_PYRA5,aMeshDimension);
+ TInt aNbPyraConn = MED::GetNbConn(SMDS_MED_ENTITY,ePYRA5,aMeshDimension);
MED::TIntVector anPyraElemNums;
anPyraElemNums.reserve(aNbElems);
MED::TIntVector aPyraFamilyNums;
MED::TIntVector aPyraConn;
aPyraConn.reserve(aNbElems*aNbPyraConn);
- med_int aNbPentaConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_PENTA6,aMeshDimension);
+ TInt aNbPentaConn = MED::GetNbConn(SMDS_MED_ENTITY,ePENTA6,aMeshDimension);
MED::TIntVector anPentaElemNums;
anPentaElemNums.reserve(aNbElems);
MED::TIntVector aPentaFamilyNums;
MED::TIntVector aPentaConn;
aPentaConn.reserve(aNbElems*aNbPentaConn);
- med_int aNbHexaConn = MED::GetNbConn(SMDS_MED_ENTITY,MED_HEXA8,aMeshDimension);
+ TInt aNbHexaConn = MED::GetNbConn(SMDS_MED_ENTITY,eHEXA8,aMeshDimension);
MED::TIntVector aHexaElemNums;
aHexaElemNums.reserve(aNbElems);
MED::TIntVector aHexaFamilyNums;
MED::TIntVector aHexaConn;
aHexaConn.reserve(aNbElems*aNbHexaConn);
- for(med_int iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
+ for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
const SMDS_MeshVolume* anElem = anIter->next();
- med_int aNbNodes = anElem->NbNodes();
+ TInt aNbNodes = anElem->NbNodes();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
- med_int aNbConnectivity;
+ TInt aNbConnectivity;
MED::TIntVector* anElemNums;
MED::TIntVector* aFamilyNums;
MED::TIntVector* aConnectivity;
}
MED::TIntVector aVector(aNbNodes);
- for(med_int iNode = 0; aNodesIter->more(); iNode++){
+ for(TInt iNode = 0; aNodesIter->more(); iNode++){
const SMDS_MeshElement* aNode = aNodesIter->next();
aVector[iNode] = aNode->GetID();
}
- med_int aSize = aConnectivity->size();
+ TInt aSize = aConnectivity->size();
aConnectivity->resize(aSize+aNbConnectivity);
// There is some difference between SMDS and MED in cells mapping
#ifdef _EDF_NODE_IDS_
(*aConnectivity)[aSize+3] = aNodeIdMap[aVector[1]];
(*aConnectivity)[aSize+4] = aNodeIdMap[aVector[4]];
default:
- for(med_int iNode = 0; iNode < aNbNodes; iNode++)
+ for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aNodeIdMap[aVector[iNode]];
}
#else
(*aConnectivity)[aSize+3] = aVector[1];
(*aConnectivity)[aSize+4] = aVector[4];
default:
- for(med_int iNode = 0; iNode < aNbNodes; iNode++)
+ for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aVector[iNode];
}
#endif
aFamilyNums->push_back(myVolumesDefaultFamilyId);
}
- if(med_int aNbElems = anTetraElemNums.size()){
- PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
- SMDS_MED_ENTITY,
- MED_TETRA4,
- SMDS_MED_CONNECTIVITY,
- aTetraConn,
- aTetraFamilyNums,
- anTetraElemNums);
- MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_TETRA4<<"; aNbElems = "<<aNbElems);
- aMed.SetCellInfo(aCellInfo);
+ if(TInt aNbElems = anTetraElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eTETRA4,
+ SMDS_MED_CONNECTIVITY,
+ aTetraConn,
+ aTetraFamilyNums,
+ anTetraElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTETRA4<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
}
- if(med_int aNbElems = anPyraElemNums.size()){
- PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
- SMDS_MED_ENTITY,
- MED_PYRA5,
- SMDS_MED_CONNECTIVITY,
- aPyraConn,
- aPyraFamilyNums,
- anPyraElemNums);
- MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_PYRA5<<"; aNbElems = "<<aNbElems);
- aMed.SetCellInfo(aCellInfo);
+ if(TInt aNbElems = anPyraElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ ePYRA5,
+ SMDS_MED_CONNECTIVITY,
+ aPyraConn,
+ aPyraFamilyNums,
+ anPyraElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePYRA5<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
}
- if(med_int aNbElems = anPentaElemNums.size()){
- PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
- SMDS_MED_ENTITY,
- MED_PENTA6,
- SMDS_MED_CONNECTIVITY,
- aPentaConn,
- aPentaFamilyNums,
- anPentaElemNums);
- MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_PENTA6<<"; aNbElems = "<<aNbElems);
- aMed.SetCellInfo(aCellInfo);
+ if(TInt aNbElems = anPentaElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ ePENTA6,
+ SMDS_MED_CONNECTIVITY,
+ aPentaConn,
+ aPentaFamilyNums,
+ anPentaElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePENTA6<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
}
- if(med_int aNbElems = aHexaElemNums.size()){
- PCellInfo aCellInfo = TWrapper::CrCellInfo(aMeshInfo,
- SMDS_MED_ENTITY,
- MED_HEXA8,
- SMDS_MED_CONNECTIVITY,
- aHexaConn,
- aHexaFamilyNums,
- aHexaElemNums);
- MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<MED_HEXA8<<"; aNbElems = "<<aNbElems);
- aMed.SetCellInfo(aCellInfo);
+ if(TInt aNbElems = aHexaElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eHEXA8,
+ SMDS_MED_CONNECTIVITY,
+ aHexaConn,
+ aHexaFamilyNums,
+ aHexaElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA8<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
}
}
}catch(const std::exception& exc){
#define _INCLUDE_DRIVERMED_W_SMESHDS_MESH
#include "Driver_SMESHDS_Mesh.h"
+#include "MED_Factory.hxx"
#include <string>
#include <list>
DriverMED_W_SMESHDS_Mesh();
+ virtual void SetFile(const std::string& theFileName);
+ void SetFile(const std::string& theFileName, MED::EVersion theId);
+
/*! sets file name; only for usage with Add(), not Write()
*/
void AddGroupOfNodes();
private:
+ MED::PWrapper myMed;
std::string myMeshName;
std::list<SMESHDS_GroupBase*> myGroups;
bool myAllSubMeshes;
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
-CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CXXFLAGS += $(OCC_CXXFLAGS) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS += -lMeshDriver -L${KERNEL_ROOT_DIR}/lib/salome -lMEDWrapper
LDFLAGSFORBIN += -lMeshDriver -lSMDS -lSMESHDS -L${KERNEL_ROOT_DIR}/lib/salome -lMEDWrapper -lOpUtil -lSALOMELocalTrace
LIB_SERVER_IDL =
# additionnal information to compil and link file
-CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
+CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(OCC_INCLUDES) $(BOOST_CPPFLAGS)
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome
-LDFLAGS += -lMeshDriver
+LDFLAGS += -lMeshDriver $(OCC_KERNEL_LIBS)
LDFLAGSFORBIN += -lMeshDriver -lSMDS -L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lSALOMELocalTrace
@COMMENCE@
-EXPORT_HEADERS = SMESH_Actor.h SMESH_Object.h SMESH_ActorUtils.h
+EXPORT_HEADERS = SMESH_Actor.h SMESH_Object.h SMESH_ObjectDef.h SMESH_ActorUtils.h
# Libraries targets
// $Header$
-#include "SMESH_Actor.h"
+#include "SMESH_ActorDef.h"
#include "SMESH_ActorUtils.h"
#include "SMESH_DeviceActor.h"
+#include "SMESH_ControlsDef.hxx"
#include "SALOME_ExtractUnstructuredGrid.h"
#include "QAD_Config.h"
-#include "utilities.h"
#include <qstringlist.h>
#include <vtkTimeStamp.h>
#include <vtkPlane.h>
#include <vtkImplicitBoolean.h>
+#include "utilities.h"
+
#ifdef _DEBUG_
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#else
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#endif
static int aLineWidthInc = 2;
static int aPointSizeInc = 2;
-SMESH_Actor* SMESH_Actor::New(){
- return new SMESH_Actor();
+SMESH_ActorDef* SMESH_ActorDef::New(){
+ return new SMESH_ActorDef();
}
const char* theName,
int theIsClear)
{
- SMESH_Actor* anActor = SMESH_Actor::New();
+ SMESH_ActorDef* anActor = SMESH_ActorDef::New();
if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
anActor->Delete();
anActor = NULL;
}
-SMESH_Actor::SMESH_Actor(){
- if(MYDEBUG) MESSAGE("SMESH_Actor");
+SMESH_ActorDef::SMESH_ActorDef(){
+ if(MYDEBUG) MESSAGE("SMESH_ActorDef");
myTimeStamp = vtkTimeStamp::New();
myName = "";
myIO = NULL;
- myColorMode = eNone;
- my1DColorMode = e1DNone;
+ myControlMode = eNone;
myControlActor = my2DActor;
//Definition of myScalarBarActor
aPtsTextProp->SetShadow(0);
myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
aPtsTextProp->Delete();
-
+
+ myEntityMode = eAllEntity;
+
myIsPointsLabeled = false;
myPointLabels = vtkActor2D::New();
}
-SMESH_Actor::~SMESH_Actor(){
- if(MYDEBUG) MESSAGE("~SMESH_Actor");
+SMESH_ActorDef::~SMESH_ActorDef(){
+ if(MYDEBUG) MESSAGE("~SMESH_ActorDef");
myScalarBarActor->Delete();
myLookupTable->Delete();
}
-void SMESH_Actor::SetPointsLabeled( bool theIsPointsLabeled )
+void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
{
vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
}
-void SMESH_Actor::SetCellsLabeled(bool theIsCellsLabeled){
+void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled){
vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
if(myIsCellsLabeled){
}
-void SMESH_Actor::SetControlMode(eControl theMode){
- myColorMode = eNone;
- my1DColorMode = e1DNone;
+void SMESH_ActorDef::SetControlMode(eControl theMode){
+ myControlMode = eNone;
my1DActor->GetMapper()->SetScalarVisibility(false);
my2DActor->GetMapper()->SetScalarVisibility(false);
if(anIsScalarVisible){
SMESH::Controls::FunctorPtr aFunctor;
switch(theMode){
- case eLengthEdges:
+ case eLength:
{
SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
aControl->SetPrecision( myControlsPrecision );
myControlActor = my1DActor;
break;
}
+ case eLength2D:
+ {
+ aFunctor.reset(new SMESH::Controls::Length2D());
+ myControlActor = my2DActor;
+ break;
+ }
case eFreeBorders:
aFunctor.reset(new SMESH::Controls::FreeBorders());
myControlActor = my1DActor;
aFunctor.reset(new SMESH::Controls::MultiConnection());
myControlActor = my1DActor;
break;
+ case eMultiConnection2D:
+ aFunctor.reset(new SMESH::Controls::MultiConnection2D());
+ myControlActor = my2DActor;
+ break;
case eArea:
{
SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
myControlActor = my2DActor;
break;
}
+ case eAspectRatio3D:
+ {
+ SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
+ aControl->SetPrecision( myControlsPrecision );
+ aFunctor.reset( aControl );
+ myControlActor = my3DActor;
+ break;
+ }
case eMinimumAngle:
{
SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
vtkIdType aNbCells = aGrid->GetNumberOfCells();
if(aNbCells){
- myColorMode = theMode;
- if(theMode == eFreeBorders || theMode == eFreeEdges){
- my1DColorMode = e1DHighlited;
+ myControlMode = theMode;
+ switch(myControlMode){
+ case eFreeEdges:
+ case eFreeBorders:
my1DExtActor->SetExtControlMode(aFunctor,myControlActor);
- }else{
- if(myControlActor == my1DActor)
- my1DColorMode = e1DColored;
+ break;
+ case eLength2D:
+ my1DExtActor->SetExtControlMode(aFunctor,myControlActor,myScalarBarActor,myLookupTable);
+ break;
+ case eMultiConnection2D:
+ my1DExtActor->SetExtControlMode(aFunctor,myControlActor,myScalarBarActor,myLookupTable);
+ break;
+ default:
myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
}
}
+
+ if(QAD_CONFIG->getSetting("SMESH:DispayEntity") == "true"){
+ if(myControlActor == my1DActor)
+ myEntityMode = eEdges;
+ else if(myControlActor == my2DActor)
+ myEntityMode = eFaces;
+ else if(myControlActor == my3DActor)
+ myEntityMode = eVolumes;
+ }
+
+ }else if(QAD_CONFIG->getSetting("SMESH:DispayEntity") == "true"){
+ myEntityMode = eAllEntity;
}
+
SetRepresentation(GetRepresentation());
myTimeStamp->Modified();
}
-void SMESH_Actor::AddToRender(vtkRenderer* theRenderer){
+void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
SALOME_Actor::AddToRender(theRenderer);
theRenderer->AddActor(myNodeActor);
theRenderer->AddActor2D(myCellsLabels);
}
-void SMESH_Actor::RemoveFromRender(vtkRenderer* theRenderer){
+void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
SALOME_Actor::RemoveFromRender(theRenderer);
theRenderer->RemoveActor(myNodeActor);
}
-bool SMESH_Actor::Init(TVisualObjPtr theVisualObj,
- const char* theEntry,
- const char* theName,
- int theIsClear)
+bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
+ const char* theEntry,
+ const char* theName,
+ int theIsClear)
{
Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
setIO(anIO);
my3DActor->Init(myVisualObj,myImplicitBoolean);
my1DActor->GetMapper()->SetLookupTable(myLookupTable);
+ my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
+
my2DActor->GetMapper()->SetLookupTable(myLookupTable);
my3DActor->GetMapper()->SetLookupTable(myLookupTable);
}
-float* SMESH_Actor::GetBounds(){
+float* SMESH_ActorDef::GetBounds(){
return myNodeActor->GetBounds();
}
-vtkDataSet* SMESH_Actor::GetInput(){
+vtkDataSet* SMESH_ActorDef::GetInput(){
return GetUnstructuredGrid();
}
-void SMESH_Actor::SetTransform(SALOME_Transform* theTransform){
+void SMESH_ActorDef::SetTransform(SALOME_Transform* theTransform){
myNodeActor->SetTransform(theTransform);
myBaseActor->SetTransform(theTransform);
}
-void SMESH_Actor::SetMapper(vtkMapper* theMapper){
+void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
vtkLODActor::SetMapper(theMapper);
}
-void SMESH_Actor::ShallowCopy(vtkProp *prop){
+void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
SALOME_Actor::ShallowCopy(prop);
}
-vtkMapper* SMESH_Actor::GetMapper(){
+vtkMapper* SMESH_ActorDef::GetMapper(){
return myPickableActor->GetMapper();
}
-vtkUnstructuredGrid* SMESH_Actor::GetUnstructuredGrid(){
+vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
return myVisualObj->GetUnstructuredGrid();
}
-bool SMESH_Actor::IsInfinitive(){
+bool SMESH_ActorDef::IsInfinitive(){
vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
aDataSet->Update();
myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
}
-void SMESH_Actor::SetIsShrunkable(bool theShrunkable){
+void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
myIsShrinkable = theShrunkable;
Modified();
}
-float SMESH_Actor::GetShrinkFactor(){
+float SMESH_ActorDef::GetShrinkFactor(){
return myBaseActor->GetShrinkFactor();
}
-void SMESH_Actor::SetShrinkFactor(float theValue){
+void SMESH_ActorDef::SetShrinkFactor(float theValue){
myBaseActor->SetShrinkFactor(theValue);
my1DActor->SetShrinkFactor(theValue);
Modified();
}
-void SMESH_Actor::SetShrink(){
+void SMESH_ActorDef::SetShrink(){
if(!myIsShrinkable) return;
myBaseActor->SetShrink();
Modified();
}
-void SMESH_Actor::UnShrink(){
+void SMESH_ActorDef::UnShrink(){
if(!myIsShrunk) return;
myBaseActor->UnShrink();
}
-int SMESH_Actor::GetNodeObjId(int theVtkID){
+int SMESH_ActorDef::GetNodeObjId(int theVtkID){
return myPickableActor->GetNodeObjId(theVtkID);
}
-float* SMESH_Actor::GetNodeCoord(int theObjID){
+float* SMESH_ActorDef::GetNodeCoord(int theObjID){
return myPickableActor->GetNodeCoord(theObjID);
}
-int SMESH_Actor::GetElemObjId(int theVtkID){
+int SMESH_ActorDef::GetElemObjId(int theVtkID){
return myPickableActor->GetElemObjId(theVtkID);
}
-vtkCell* SMESH_Actor::GetElemCell(int theObjID){
+vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
return myPickableActor->GetElemCell(theObjID);
}
-void SMESH_Actor::SetVisibility(int theMode){
+void SMESH_ActorDef::SetVisibility(int theMode){
SetVisibility(theMode,true);
}
-void SMESH_Actor::SetVisibility(int theMode, bool theIsUpdateRepersentation){
+void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
SALOME_Actor::SetVisibility(theMode);
+
+ myNodeActor->VisibilityOff();
+ myBaseActor->VisibilityOff();
+
+ my1DActor->VisibilityOff();
+ my1DExtActor->VisibilityOff();
+
+ my2DActor->VisibilityOff();
+ my3DActor->VisibilityOff();
+
+ myScalarBarActor->VisibilityOff();
+ myPointLabels->VisibilityOff();
+ myCellsLabels->VisibilityOff();
+
if(GetVisibility()){
if(theIsUpdateRepersentation)
SetRepresentation(GetRepresentation());
- if(myColorMode != eNone){
- if(my1DColorMode == e1DHighlited)
+ if(myControlMode != eNone){
+ switch(myControlMode){
+ case eFreeEdges:
+ case eFreeBorders:
+ my1DExtActor->VisibilityOn();
+ break;
+ case eLength2D:
my1DExtActor->VisibilityOn();
- else if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
- myScalarBarActor->VisibilityOn();
+ case eMultiConnection2D:
+ my1DExtActor->VisibilityOn();
+ default:
+ if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
+ myScalarBarActor->VisibilityOn();
+ }
}
if(myRepresentation != ePoint)
myPickableActor->VisibilityOn();
- my1DActor->VisibilityOn();
+ if(myEntityMode & eEdges)
+ my1DActor->VisibilityOn();
+
+ if(myEntityMode & eFaces)
+ my2DActor->VisibilityOn();
+
+ if(myEntityMode & eVolumes)
+ my3DActor->VisibilityOn();
+
+ if(myIsPointsLabeled)
+ myPointLabels->VisibilityOn();
- my2DActor->VisibilityOn();
- my3DActor->VisibilityOn();
+ if(myIsCellsLabeled)
+ myCellsLabels->VisibilityOn();
+ }
- if(myIsPointsLabeled) myPointLabels->VisibilityOn();
- if(myIsCellsLabeled) myCellsLabels->VisibilityOn();
- }else{
- myNodeActor->VisibilityOff();
- myBaseActor->VisibilityOff();
+ Modified();
+}
- my1DActor->VisibilityOff();
- my1DExtActor->VisibilityOff();
- my2DActor->VisibilityOff();
- my3DActor->VisibilityOff();
+void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
+ if(!myVisualObj->GetNbEntities(SMDSAbs_Edge))
+ theMode &= ~eEdges;
- myScalarBarActor->VisibilityOff();
- myPointLabels->VisibilityOff();
- myCellsLabels->VisibilityOff();
- }
- Modified();
-}
+ if(!myVisualObj->GetNbEntities(SMDSAbs_Face))
+ theMode &= ~eFaces;
+
+ if(!myVisualObj->GetNbEntities(SMDSAbs_Volume))
+ theMode &= ~eVolumes;
+ if(!theMode)
+ return;
-void SMESH_Actor::SetRepresentation(int theMode){
- int aNbEdges = myVisualObj->GetNbEntities(SMESH::EDGE);
- int aNbFaces = myVisualObj->GetNbEntities(SMESH::FACE);
- int aNbVolumes = myVisualObj->GetNbEntities(SMESH::VOLUME);
+ myEntityMode = theMode;
+
+ SetVisibility(GetVisibility(),false);
+}
+
+void SMESH_ActorDef::SetRepresentation(int theMode){
+ int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
+ int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
+ int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
if(theMode < 0){
myRepresentation = eSurface;
if(!aNbFaces && !aNbVolumes && aNbEdges){
my3DActor->SetRepresentation(aReperesent);
my1DExtActor->SetVisibility(false);
- switch(my1DColorMode){
- case e1DColored:
+
+ switch(myControlMode){
+ case eLength:
+ case eMultiConnection:
aProp = aBackProp = my1DProp;
if(myRepresentation != ePoint)
aReperesent = SMESH_DeviceActor::eInsideframe;
break;
- case e1DHighlited:
- my1DExtActor->SetVisibility(true);
- break;
}
my1DActor->SetProperty(aProp);
}
-void SMESH_Actor::SetPointRepresentation(bool theIsPointsVisible){
+void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
myIsPointsVisible = theIsPointsVisible;
SetRepresentation(GetRepresentation());
}
-bool SMESH_Actor::GetPointRepresentation(){
+bool SMESH_ActorDef::GetPointRepresentation(){
return myIsPointsVisible || myIsPointsLabeled;
}
-void SMESH_Actor::UpdateHighlight(){
+void SMESH_ActorDef::UpdateHighlight(){
myHighlitableActor->SetVisibility(false);
myHighlitableActor->SetHighlited(false);
}
-void SMESH_Actor::highlight(bool theHighlight){
+void SMESH_ActorDef::highlight(bool theHighlight){
myIsHighlighted = theHighlight;
UpdateHighlight();
}
-void SMESH_Actor::SetPreSelected(bool thePreselect){
+void SMESH_ActorDef::SetPreSelected(bool thePreselect){
myIsPreselected = thePreselect;
UpdateHighlight();
}
// From vtkFollower
-int SMESH_Actor::RenderOpaqueGeometry(vtkViewport *vp)
+int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
{
if (myPickableActor->GetIsOpaque())
{
}
-int SMESH_Actor::RenderTranslucentGeometry(vtkViewport *vp)
+int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
{
if (!myPickableActor->GetIsOpaque())
{
}
-void SMESH_Actor::Render(vtkRenderer *ren){
- unsigned long mTime = myTimeStamp->GetMTime();
+void SMESH_ActorDef::Render(vtkRenderer *ren){
+ unsigned long aTime = myTimeStamp->GetMTime();
unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
- if(anObjTime > mTime)
+ unsigned long aClippingTime = myImplicitBoolean->GetMTime();
+ if(anObjTime > aTime || aClippingTime > aTime)
Update();
}
-void SMESH_Actor::Update(){
- SetVisibility(GetVisibility());
- unsigned long int anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
- unsigned long int aClippingTime = myImplicitBoolean->GetMTime();
- unsigned long int aTime = myTimeStamp->GetMTime();
- if(MYDEBUG) MESSAGE("SMESH_Actor::Update");
+void SMESH_ActorDef::Update(){
+ if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
if(GetControlMode() != eNone) {
- if(anObjTime > aTime || aClippingTime > aTime){
- SetControlMode(GetControlMode());
- SetVisibility(GetVisibility());
- }
+ SetControlMode(GetControlMode());
}
if(myIsPointsLabeled){
- if(anObjTime > aTime || aClippingTime > aTime)
- SetPointsLabeled(myIsPointsLabeled);
+ SetPointsLabeled(myIsPointsLabeled);
}
if(myIsCellsLabeled){
- if(anObjTime > aTime || aClippingTime > aTime)
- SetCellsLabeled(myIsCellsLabeled);
+ SetCellsLabeled(myIsCellsLabeled);
}
-
+ SetVisibility(GetVisibility());
+
myTimeStamp->Modified();
Modified();
}
-void SMESH_Actor::ReleaseGraphicsResources(vtkWindow *renWin){
+void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
SALOME_Actor::ReleaseGraphicsResources(renWin);
myPickableActor->ReleaseGraphicsResources(renWin);
}
-void SMESH_Actor::SetOpacity(float theValue){
+void SMESH_ActorDef::SetOpacity(float theValue){
mySurfaceProp->SetOpacity(theValue);
myBackSurfaceProp->SetOpacity(theValue);
myEdgeProp->SetOpacity(theValue);
}
-float SMESH_Actor::GetOpacity(){
+float SMESH_ActorDef::GetOpacity(){
return mySurfaceProp->GetOpacity();
}
-void SMESH_Actor::SetSufaceColor(float r,float g,float b){
+void SMESH_ActorDef::SetSufaceColor(float r,float g,float b){
mySurfaceProp->SetColor(r,g,b);
Modified();
}
-void SMESH_Actor::GetSufaceColor(float& r,float& g,float& b){
+void SMESH_ActorDef::GetSufaceColor(float& r,float& g,float& b){
::GetColor(mySurfaceProp,r,g,b);
}
-void SMESH_Actor::SetBackSufaceColor(float r,float g,float b){
+void SMESH_ActorDef::SetBackSufaceColor(float r,float g,float b){
myBackSurfaceProp->SetColor(r,g,b);
Modified();
}
-void SMESH_Actor::GetBackSufaceColor(float& r,float& g,float& b){
+void SMESH_ActorDef::GetBackSufaceColor(float& r,float& g,float& b){
::GetColor(myBackSurfaceProp,r,g,b);
}
-void SMESH_Actor::SetEdgeColor(float r,float g,float b){
+void SMESH_ActorDef::SetEdgeColor(float r,float g,float b){
myEdgeProp->SetColor(r,g,b);
my1DProp->SetColor(r,g,b);
my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
Modified();
}
-void SMESH_Actor::GetEdgeColor(float& r,float& g,float& b){
+void SMESH_ActorDef::GetEdgeColor(float& r,float& g,float& b){
::GetColor(myEdgeProp,r,g,b);
}
-void SMESH_Actor::SetNodeColor(float r,float g,float b){
+void SMESH_ActorDef::SetNodeColor(float r,float g,float b){
myNodeProp->SetColor(r,g,b);
Modified();
}
-void SMESH_Actor::GetNodeColor(float& r,float& g,float& b){
+void SMESH_ActorDef::GetNodeColor(float& r,float& g,float& b){
::GetColor(myNodeProp,r,g,b);
}
-void SMESH_Actor::SetHighlightColor(float r,float g,float b){
+void SMESH_ActorDef::SetHighlightColor(float r,float g,float b){
myHighlightProp->SetColor(r,g,b);
Modified();
}
-void SMESH_Actor::GetHighlightColor(float& r,float& g,float& b){
+void SMESH_ActorDef::GetHighlightColor(float& r,float& g,float& b){
::GetColor(myHighlightProp,r,g,b);
}
-void SMESH_Actor::SetPreHighlightColor(float r,float g,float b){
+void SMESH_ActorDef::SetPreHighlightColor(float r,float g,float b){
myPreselectProp->SetColor(r,g,b);
Modified();
}
-void SMESH_Actor::GetPreHighlightColor(float& r,float& g,float& b){
+void SMESH_ActorDef::GetPreHighlightColor(float& r,float& g,float& b){
::GetColor(myPreselectProp,r,g,b);
}
-float SMESH_Actor::GetLineWidth(){
+float SMESH_ActorDef::GetLineWidth(){
return myEdgeProp->GetLineWidth();
}
-void SMESH_Actor::SetLineWidth(float theVal){
+void SMESH_ActorDef::SetLineWidth(float theVal){
myEdgeProp->SetLineWidth(theVal);
my1DProp->SetLineWidth(theVal + aLineWidthInc);
}
-void SMESH_Actor::SetNodeSize(float theVal){
+void SMESH_ActorDef::SetNodeSize(float theVal){
myNodeProp->SetPointSize(theVal);
myHighlightProp->SetPointSize(theVal);
myPreselectProp->SetPointSize(theVal);
Modified();
}
-float SMESH_Actor::GetNodeSize(){
+float SMESH_ActorDef::GetNodeSize(){
return myNodeProp->GetPointSize();
}
-int SMESH_Actor::GetObjDimension( const int theObjId )
+int SMESH_ActorDef::GetObjDimension( const int theObjId )
{
return myVisualObj->GetElemDimension( theObjId );
}
-vtkImplicitBoolean* SMESH_Actor::GetPlaneContainer(){
+vtkImplicitBoolean* SMESH_ActorDef::GetPlaneContainer(){
return myImplicitBoolean;
}
}
-void SMESH_Actor::SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane)
+void SMESH_ActorDef::SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane)
{
thePlane->SetNormal(theDir);
float anOrigin[3];
::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
thePlane->SetOrigin(anOrigin);
- Update();
}
-void SMESH_Actor::GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane)
+void SMESH_ActorDef::GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane)
{
thePlane->GetNormal(theDir);
#include "SALOME_Actor.h"
#include "SMESH_Object.h"
-class vtkProperty;
-class vtkShrinkFilter;
-class vtkPolyDataMapper;
class vtkUnstructuredGrid;
-class vtkMergeFilter;
-class vtkPolyData;
-
-class vtkMapper;
-class vtkActor2D;
-class vtkMaskPoints;
-class vtkCellCenters;
-class vtkLabeledDataMapper;
-class vtkSelectVisiblePoints;
class vtkScalarBarActor;
-class vtkLookupTable;
class vtkPlane;
class vtkImplicitBoolean;
-class vtkTimeStamp;
-
-class SMESH_DeviceActor;
-
-
-class SMESH_Actor : public SALOME_Actor{
- friend class SMESH_VisualObj;
+class SMESH_Actor: public SALOME_Actor
+{
+ static SMESH_Actor* New() { return NULL;}
public:
vtkTypeMacro(SMESH_Actor,SALOME_Actor);
const char* theName,
int theIsClear);
- virtual void ReleaseGraphicsResources(vtkWindow *renWin);
- virtual int RenderOpaqueGeometry(vtkViewport *viewport);
- virtual int RenderTranslucentGeometry(vtkViewport *viewport);
- virtual void Render(vtkRenderer *ren);
-
- virtual void AddToRender(vtkRenderer* theRenderer);
- virtual void RemoveFromRender(vtkRenderer* theRenderer);
-
- virtual bool hasHighlight() { return true; }
- virtual void highlight(bool theHighlight);
- virtual void SetPreSelected(bool thePreselect = false);
-
- virtual bool IsInfinitive();
-
- virtual void SetOpacity(float theValue);
- virtual float GetOpacity();
-
- void SetSufaceColor(float r,float g,float b);
- void GetSufaceColor(float& r,float& g,float& b);
-
- void SetBackSufaceColor(float r,float g,float b);
- void GetBackSufaceColor(float& r,float& g,float& b);
-
- void SetEdgeColor(float r,float g,float b);
- void GetEdgeColor(float& r,float& g,float& b);
+ virtual void SetSufaceColor(float r,float g,float b) = 0;
+ virtual void GetSufaceColor(float& r,float& g,float& b) = 0;
+
+ virtual void SetBackSufaceColor(float r,float g,float b) = 0;
+ virtual void GetBackSufaceColor(float& r,float& g,float& b) = 0;
+
+ virtual void SetEdgeColor(float r,float g,float b) = 0;
+ virtual void GetEdgeColor(float& r,float& g,float& b) = 0;
- void SetNodeColor(float r,float g,float b);
- void GetNodeColor(float& r,float& g,float& b);
+ virtual void SetNodeColor(float r,float g,float b) = 0;
+ virtual void GetNodeColor(float& r,float& g,float& b) = 0;
- void SetHighlightColor(float r,float g,float b);
- void GetHighlightColor(float& r,float& g,float& b);
+ virtual void SetHighlightColor(float r,float g,float b) = 0;
+ virtual void GetHighlightColor(float& r,float& g,float& b) = 0;
- void SetPreHighlightColor(float r,float g,float b);
- void GetPreHighlightColor(float& r,float& g,float& b);
+ virtual void SetPreHighlightColor(float r,float g,float b) = 0;
+ virtual void GetPreHighlightColor(float& r,float& g,float& b) = 0;
- float GetLineWidth();
- void SetLineWidth(float theVal);
-
- void SetNodeSize(float size) ;
- float GetNodeSize() ;
-
- virtual int GetNodeObjId(int theVtkID);
- virtual float* GetNodeCoord(int theObjID);
+ virtual float GetLineWidth() = 0;
+ virtual void SetLineWidth(float theVal) = 0;
- virtual int GetElemObjId(int theVtkID);
- virtual vtkCell* GetElemCell(int theObjID);
-
- virtual int GetObjDimension( const int theObjId );
-
- virtual void SetVisibility(int theMode);
- void SetVisibility(int theMode, bool theIsUpdateRepersentation);
+ virtual void SetNodeSize(float size) = 0;
+ virtual float GetNodeSize() = 0;
enum EReperesent { ePoint, eEdge, eSurface};
- virtual void SetRepresentation(int theMode);
- void SetPointRepresentation(bool theIsPointsVisible);
- bool GetPointRepresentation();
-
- virtual float* GetBounds();
- virtual void SetTransform(SALOME_Transform* theTransform);
-
- vtkUnstructuredGrid* GetUnstructuredGrid();
- virtual vtkDataSet* GetInput();
- virtual vtkMapper* GetMapper();
-
- virtual float GetShrinkFactor();
- virtual void SetShrinkFactor(float value );
-
- virtual bool IsShrunkable() { return myIsShrinkable;}
- virtual bool IsShrunk() { return myIsShrunk;}
- virtual void SetShrink();
- virtual void UnShrink();
-
- void SetPointsLabeled(bool theIsPointsLabeled);
- bool GetPointsLabeled(){ return myIsPointsLabeled;}
-
- void SetCellsLabeled(bool theIsCellsLabeled);
- bool GetCellsLabeled(){ return myIsCellsLabeled;}
-
- enum eControl{eNone, eLengthEdges, eFreeBorders, eFreeEdges, eMultiConnection,
- eArea, eTaper, eAspectRatio, eMinimumAngle, eWarping, eSkew};
- void SetControlMode(eControl theMode);
- eControl GetControlMode(){ return myColorMode;}
-
- enum e1DControl{e1DNone, e1DColored, e1DHighlited};
- e1DControl Get1DControlMode(){ return my1DColorMode;}
-
- vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
-
- void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
- void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane);
-
- vtkImplicitBoolean* GetPlaneContainer();
+
+ enum EEntityMode { eEdges = 0x01, eFaces = 0x02, eVolumes = 0x04, eAllEntity = 0x07};
+ virtual void SetEntityMode(unsigned int theMode) = 0;
+ virtual unsigned int GetEntityMode() const = 0;
- TVisualObjPtr GetObject() { return myVisualObj;}
+ virtual void SetPointRepresentation(bool theIsPointsVisible) = 0;
+ virtual bool GetPointRepresentation() = 0;
- void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
- long GetControlsPrecision() const { return myControlsPrecision; }
+ virtual vtkUnstructuredGrid* GetUnstructuredGrid() = 0;
- protected:
- TVisualObjPtr myVisualObj;
- vtkTimeStamp* myTimeStamp;
+ virtual void SetShrinkFactor(float theValue) = 0;
- vtkScalarBarActor* myScalarBarActor;
- vtkLookupTable* myLookupTable;
+ virtual void SetPointsLabeled(bool theIsPointsLabeled) = 0;
+ virtual bool GetPointsLabeled() = 0;
- vtkProperty* mySurfaceProp;
- vtkProperty* myBackSurfaceProp;
- vtkProperty* myEdgeProp;
- vtkProperty* myNodeProp;
+ virtual void SetCellsLabeled(bool theIsCellsLabeled) = 0;
+ virtual bool GetCellsLabeled() = 0;
- SMESH_DeviceActor* myBaseActor;
- SMESH_DeviceActor* myNodeActor;
- SMESH_DeviceActor* myPickableActor;
+ enum eControl{eNone, eLength, eLength2D, eFreeBorders, eFreeEdges, eMultiConnection,
+ eArea, eTaper, eAspectRatio, eMinimumAngle, eWarping, eSkew,
+ eAspectRatio3D, eMultiConnection2D};
+ virtual void SetControlMode(eControl theMode) = 0;
+ virtual eControl GetControlMode() = 0;
- vtkProperty* myHighlightProp;
- vtkProperty* myPreselectProp;
- SMESH_DeviceActor* myHighlitableActor;
- SMESH_DeviceActor* myNodeHighlitableActor;
+ virtual vtkScalarBarActor* GetScalarBarActor() = 0;
- eControl myColorMode;
- SMESH_DeviceActor* my2DActor;
- SMESH_DeviceActor* my3DActor;
- SMESH_DeviceActor* myControlActor;
+ virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane) = 0;
+ virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane) = 0;
- e1DControl my1DColorMode;
- vtkProperty* my1DProp;
- SMESH_DeviceActor* my1DActor;
- vtkProperty* my1DExtProp;
- SMESH_DeviceActor* my1DExtActor;
+ virtual vtkImplicitBoolean* GetPlaneContainer() = 0;
- bool myIsPointsVisible;
+ virtual TVisualObjPtr GetObject() = 0;
- bool myIsShrinkable;
- bool myIsShrunk;
-
- bool myIsPointsLabeled;
- vtkUnstructuredGrid* myPointsNumDataSet;
- vtkActor2D *myPointLabels;
- vtkMaskPoints* myPtsMaskPoints;
- vtkLabeledDataMapper* myPtsLabeledDataMapper;
- vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
-
- bool myIsCellsLabeled;
- vtkUnstructuredGrid* myCellsNumDataSet;
- vtkActor2D *myCellsLabels;
- vtkMaskPoints* myClsMaskPoints;
- vtkCellCenters* myCellCenters;
- vtkLabeledDataMapper* myClsLabeledDataMapper;
- vtkSelectVisiblePoints* myClsSelectVisiblePoints;
-
- vtkImplicitBoolean* myImplicitBoolean;
-
- long myControlsPrecision;
-
- SMESH_Actor();
- ~SMESH_Actor();
-
- bool Init(TVisualObjPtr theVisualObj,
- const char* theEntry,
- const char* theName,
- int theIsClear);
-
- void SetIsShrunkable(bool theShrunkable);
- void UpdateHighlight();
- void Update();
-
- private:
- // hide the two parameter Render() method from the user and the compiler.
- virtual void Render(vtkRenderer *, vtkMapper *) {};
- virtual void ShallowCopy(vtkProp *prop);
- virtual void SetMapper(vtkMapper *);
- static SMESH_Actor* New();
-
- // Not implemented.
- SMESH_Actor(const SMESH_Actor&);
- void operator=(const SMESH_Actor&);
+ virtual void SetControlsPrecision( const long ) = 0;
+ virtual long GetControlsPrecision() const = 0;
};
--- /dev/null
+// SMESH OBJECT : interactive object for SMESH visualization
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESH_ActorDef.h
+// Author : Nicolas REJNERI
+// Module : SMESH
+// $Header$
+
+#ifndef SMESH_ACTORDEF_H
+#define SMESH_ACTORDEF_H
+
+#include "SMESH_Actor.h"
+#include "SMESH_Object.h"
+
+class vtkProperty;
+class vtkShrinkFilter;
+class vtkPolyDataMapper;
+class vtkUnstructuredGrid;
+class vtkMergeFilter;
+class vtkPolyData;
+
+class vtkMapper;
+class vtkActor2D;
+class vtkMaskPoints;
+class vtkCellCenters;
+class vtkLabeledDataMapper;
+class vtkSelectVisiblePoints;
+
+class vtkScalarBarActor;
+class vtkLookupTable;
+
+class vtkPlane;
+class vtkImplicitBoolean;
+
+class vtkTimeStamp;
+
+class SMESH_DeviceActor;
+
+
+class SMESH_ActorDef : public SMESH_Actor{
+ friend class SMESH_VisualObj;
+ friend class SMESH_Actor;
+
+ public:
+ vtkTypeMacro(SMESH_ActorDef,SMESH_Actor);
+
+ virtual void ReleaseGraphicsResources(vtkWindow *renWin);
+ virtual int RenderOpaqueGeometry(vtkViewport *viewport);
+ virtual int RenderTranslucentGeometry(vtkViewport *viewport);
+ virtual void Render(vtkRenderer *ren);
+
+ virtual void AddToRender(vtkRenderer* theRenderer);
+ virtual void RemoveFromRender(vtkRenderer* theRenderer);
+
+ virtual bool hasHighlight() { return true; }
+ virtual void highlight(bool theHighlight);
+ virtual void SetPreSelected(bool thePreselect = false);
+
+ virtual bool IsInfinitive();
+
+ virtual void SetOpacity(float theValue);
+ virtual float GetOpacity();
+
+ virtual void SetSufaceColor(float r,float g,float b);
+ virtual void GetSufaceColor(float& r,float& g,float& b);
+
+ virtual void SetBackSufaceColor(float r,float g,float b);
+ virtual void GetBackSufaceColor(float& r,float& g,float& b);
+
+ virtual void SetEdgeColor(float r,float g,float b);
+ virtual void GetEdgeColor(float& r,float& g,float& b);
+
+ virtual void SetNodeColor(float r,float g,float b);
+ virtual void GetNodeColor(float& r,float& g,float& b);
+
+ virtual void SetHighlightColor(float r,float g,float b);
+ virtual void GetHighlightColor(float& r,float& g,float& b);
+
+ virtual void SetPreHighlightColor(float r,float g,float b);
+ virtual void GetPreHighlightColor(float& r,float& g,float& b);
+
+ virtual float GetLineWidth();
+ virtual void SetLineWidth(float theVal);
+
+ virtual void SetNodeSize(float size) ;
+ virtual float GetNodeSize() ;
+
+ virtual int GetNodeObjId(int theVtkID);
+ virtual float* GetNodeCoord(int theObjID);
+
+ virtual int GetElemObjId(int theVtkID);
+ virtual vtkCell* GetElemCell(int theObjID);
+
+ virtual int GetObjDimension( const int theObjId );
+
+ virtual void SetVisibility(int theMode);
+ void SetVisibility(int theMode, bool theIsUpdateRepersentation);
+
+ virtual void SetRepresentation(int theMode);
+
+ virtual unsigned int GetEntityMode() const { return myEntityMode;}
+ virtual void SetEntityMode(unsigned int theMode);
+
+ virtual void SetPointRepresentation(bool theIsPointsVisible);
+ virtual bool GetPointRepresentation();
+
+ virtual float* GetBounds();
+ virtual void SetTransform(SALOME_Transform* theTransform);
+
+ virtual vtkUnstructuredGrid* GetUnstructuredGrid();
+ virtual vtkDataSet* GetInput();
+ virtual vtkMapper* GetMapper();
+
+ virtual float GetShrinkFactor();
+ virtual void SetShrinkFactor(float theValue);
+
+ virtual bool IsShrunkable() { return myIsShrinkable;}
+ virtual bool IsShrunk() { return myIsShrunk;}
+ virtual void SetShrink();
+ virtual void UnShrink();
+
+ virtual void SetPointsLabeled(bool theIsPointsLabeled);
+ virtual bool GetPointsLabeled(){ return myIsPointsLabeled;}
+
+ virtual void SetCellsLabeled(bool theIsCellsLabeled);
+ virtual bool GetCellsLabeled(){ return myIsCellsLabeled;}
+
+ virtual void SetControlMode(eControl theMode);
+ virtual eControl GetControlMode(){ return myControlMode;}
+
+ virtual vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
+
+ virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
+ virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane);
+
+ virtual vtkImplicitBoolean* GetPlaneContainer();
+
+ virtual TVisualObjPtr GetObject() { return myVisualObj;}
+
+ virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
+ virtual long GetControlsPrecision() const { return myControlsPrecision; }
+
+ protected:
+ TVisualObjPtr myVisualObj;
+ vtkTimeStamp* myTimeStamp;
+
+ vtkScalarBarActor* myScalarBarActor;
+ vtkLookupTable* myLookupTable;
+
+ vtkProperty* mySurfaceProp;
+ vtkProperty* myBackSurfaceProp;
+ vtkProperty* myEdgeProp;
+ vtkProperty* myNodeProp;
+
+ SMESH_DeviceActor* myBaseActor;
+ SMESH_DeviceActor* myNodeActor;
+ SMESH_DeviceActor* myPickableActor;
+
+ vtkProperty* myHighlightProp;
+ vtkProperty* myPreselectProp;
+ SMESH_DeviceActor* myHighlitableActor;
+ SMESH_DeviceActor* myNodeHighlitableActor;
+
+ eControl myControlMode;
+ SMESH_DeviceActor* my2DActor;
+ SMESH_DeviceActor* my3DActor;
+ SMESH_DeviceActor* myControlActor;
+
+ vtkProperty* my1DProp;
+ SMESH_DeviceActor* my1DActor;
+ vtkProperty* my1DExtProp;
+ SMESH_DeviceActor* my1DExtActor;
+
+ unsigned int myEntityMode;
+ bool myIsPointsVisible;
+
+ bool myIsShrinkable;
+ bool myIsShrunk;
+
+ bool myIsPointsLabeled;
+ vtkUnstructuredGrid* myPointsNumDataSet;
+ vtkActor2D *myPointLabels;
+ vtkMaskPoints* myPtsMaskPoints;
+ vtkLabeledDataMapper* myPtsLabeledDataMapper;
+ vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
+
+ bool myIsCellsLabeled;
+ vtkUnstructuredGrid* myCellsNumDataSet;
+ vtkActor2D *myCellsLabels;
+ vtkMaskPoints* myClsMaskPoints;
+ vtkCellCenters* myCellCenters;
+ vtkLabeledDataMapper* myClsLabeledDataMapper;
+ vtkSelectVisiblePoints* myClsSelectVisiblePoints;
+
+ vtkImplicitBoolean* myImplicitBoolean;
+
+ long myControlsPrecision;
+
+ SMESH_ActorDef();
+ ~SMESH_ActorDef();
+
+ bool Init(TVisualObjPtr theVisualObj,
+ const char* theEntry,
+ const char* theName,
+ int theIsClear);
+
+ void SetIsShrunkable(bool theShrunkable);
+ void UpdateHighlight();
+ void Update();
+
+ private:
+ // hide the two parameter Render() method from the user and the compiler.
+ virtual void Render(vtkRenderer *, vtkMapper *) {};
+ virtual void ShallowCopy(vtkProp *prop);
+ virtual void SetMapper(vtkMapper *);
+ static SMESH_ActorDef* New();
+
+ // Not implemented.
+ SMESH_ActorDef(const SMESH_ActorDef&);
+ void operator=(const SMESH_ActorDef&);
+};
+
+
+#endif //SMESH_ACTORDEF_H
#include "QAD_Config.h"
#include "utilities.h"
+#include <vtkUnstructuredGrid.h>
+#include <vtkUnstructuredGridWriter.h>
+
#ifdef _DEBUG_
static int MYDEBUG = 1;
#else
#endif
namespace SMESH{
+
float GetFloat(const QString& theValue, float theDefault){
if(theValue.isEmpty()) return theDefault;
QString aValue = QAD_CONFIG->getSetting(theValue);
if(aValue.isEmpty()) return theDefault;
return aValue.toFloat();
}
+
+ void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName){
+ vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
+ aWriter->SetFileName(theFileName);
+ aWriter->SetInput(theGrid);
+ if(theGrid->GetNumberOfCells()){
+ aWriter->Write();
+ }
+ aWriter->Delete();
+ }
+
}
#include <qstring.h>
+class vtkUnstructuredGrid;
namespace SMESH{
+
float GetFloat(const QString& theValue, float theDefault = 0);
-}
+ void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName);
+
+}
#endif
// File : SMESH_Actor.cxx
// Author : Nicolas REJNERI
// Module : SMESH
-// $Header$
+// $Header$Header$
#include "SMESH_DeviceActor.h"
#include "SMESH_ExtractGeometry.h"
+#include "SMESH_ControlsDef.hxx"
+#include "SMESH_ActorUtils.h"
#include "SALOME_Transform.h"
#include "SALOME_TransformFilter.h"
#include "SALOME_PassThroughFilter.h"
#include "SALOME_ExtractUnstructuredGrid.h"
-#include "utilities.h"
-
// VTK Includes
#include <vtkObjectFactory.h>
#include <vtkShrinkFilter.h>
#include <vtkImplicitBoolean.h>
+#include "utilities.h"
+
#ifdef _DEBUG_
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#else
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#endif
using namespace std;
myExtractUnstructuredGrid->SetInput(myExtractGeometry->GetOutput());
myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput());
-
+
theGrid = static_cast<vtkUnstructuredGrid*>(myMergeFilter->GetOutput());
int anId = 0;
theScalarBarActor->SetVisibility(anIsInitialized);
}
+void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
+ SMESH_DeviceActor* theDeviceActor,
+ vtkScalarBarActor* theScalarBarActor,
+ vtkLookupTable* theLookupTable)
+{
+ bool anIsInitialized = theFunctor;
+
+ using namespace SMESH::Controls;
+ if (anIsInitialized){
+ if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
+ SMESH::Controls::Length2D::TValues aValues;
+
+ myVisualObj->UpdateFunctor(theFunctor);
+
+ aLength2D->GetValues(aValues);
+ vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+ vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+
+ aDataSet->SetPoints(aGrid->GetPoints());
+
+ vtkIdType aNbCells = aValues.size();
+
+ vtkDoubleArray *aScalars = vtkDoubleArray::New();
+ aScalars->SetNumberOfComponents(1);
+ aScalars->SetNumberOfTuples(aNbCells);
+
+ vtkIdType aCellsSize = 3*aNbCells;
+ vtkCellArray* aConnectivity = vtkCellArray::New();
+ aConnectivity->Allocate( aCellsSize, 0 );
+
+ vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+ aCellTypesArray->SetNumberOfComponents( 1 );
+ aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
+
+ vtkIdList *anIdList = vtkIdList::New();
+ anIdList->SetNumberOfIds(2);
+
+ Length2D::TValues::const_iterator anIter = aValues.begin();
+ for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
+ const Length2D::Value& aValue = *anIter;
+ int aNode[2] = {
+ myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
+ myVisualObj->GetNodeVTKId(aValue.myPntId[1])
+ };
+ if(aNode[0] >= 0 && aNode[1] >= 0){
+ anIdList->SetId( 0, aNode[0] );
+ anIdList->SetId( 1, aNode[1] );
+ aConnectivity->InsertNextCell( anIdList );
+ aCellTypesArray->InsertNextValue( VTK_LINE );
+ aScalars->SetValue(aVtkId,aValue.myLength);
+ }
+ }
+
+ vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+ aCellLocationsArray->SetNumberOfComponents( 1 );
+ aCellLocationsArray->SetNumberOfTuples( aNbCells );
+
+ aConnectivity->InitTraversal();
+ for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
+ aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
+
+ aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
+ SetUnstructuredGrid(aDataSet);
+
+ aDataSet->GetCellData()->SetScalars(aScalars);
+ aScalars->Delete();
+
+ theLookupTable->SetRange(aScalars->GetRange());
+ theLookupTable->Build();
+
+ myMergeFilter->SetScalars(aDataSet);
+ aDataSet->Delete();
+ }
+ else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
+ SMESH::Controls::MultiConnection2D::MValues aValues;
+
+ myVisualObj->UpdateFunctor(theFunctor);
+
+ aMultiConnection2D->GetValues(aValues);
+ vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+ vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+ aDataSet->SetPoints(aGrid->GetPoints());
+
+ vtkIdType aNbCells = aValues.size();
+ vtkDoubleArray *aScalars = vtkDoubleArray::New();
+ aScalars->SetNumberOfComponents(1);
+ aScalars->SetNumberOfTuples(aNbCells);
+
+ vtkIdType aCellsSize = 3*aNbCells;
+ vtkCellArray* aConnectivity = vtkCellArray::New();
+ aConnectivity->Allocate( aCellsSize, 0 );
+
+ vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+ aCellTypesArray->SetNumberOfComponents( 1 );
+ aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
+
+ vtkIdList *anIdList = vtkIdList::New();
+ anIdList->SetNumberOfIds(2);
+
+ MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
+ int i = 0;
+ for(vtkIdType aVtkId; anIter != aValues.end(); anIter++,i++){
+ const MultiConnection2D::Value& aValue = (*anIter).first;
+ int aNode[2] = {
+ myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
+ myVisualObj->GetNodeVTKId(aValue.myPntId[1])
+ };
+ if(aNode[0] >= 0 && aNode[1] >= 0){
+ anIdList->SetId( 0, aNode[0] );
+ anIdList->SetId( 1, aNode[1] );
+ aConnectivity->InsertNextCell( anIdList );
+ aCellTypesArray->InsertNextValue( VTK_LINE );
+ aScalars->SetValue(i,(*anIter).second);
+ }
+ }
+
+ vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+ aCellLocationsArray->SetNumberOfComponents( 1 );
+ aCellLocationsArray->SetNumberOfTuples( aNbCells );
+
+ aConnectivity->InitTraversal();
+ for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
+ aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
+
+ aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
+ SetUnstructuredGrid(aDataSet);
+
+ aDataSet->GetCellData()->SetScalars(aScalars);
+ aScalars->Delete();
+
+ theLookupTable->SetRange(aScalars->GetRange());
+ theLookupTable->Build();
+
+ myMergeFilter->SetScalars(aDataSet);
+ aDataSet->Delete();
+ }
+ }
+ GetMapper()->SetScalarVisibility(anIsInitialized);
+ theScalarBarActor->SetVisibility(anIsInitialized);
+}
void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
SMESH_DeviceActor* theDeviceActor)
anIdList->SetNumberOfIds(2);
FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
- for(vtkIdType aVtkId; anIter != aBorders.end(); anIter++){
+ for(; anIter != aBorders.end(); anIter++){
const FreeEdges::Border& aBorder = *anIter;
int aNode[2] = {
myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
SetUnstructuredGrid(aDataSet);
aDataSet->Delete();
- }
+ }
}
+
+
unsigned long int SMESH_DeviceActor::GetMTime(){
unsigned long mTime = this->Superclass::GetMTime();
mTime = max(mTime,myExtractGeometry->GetMTime());
class SMESH_DeviceActor: public vtkLODActor{
- friend class SMESH_Actor;
+ friend class SMESH_ActorDef;
public:
vtkTypeMacro(SMESH_DeviceActor,vtkLODActor);
void SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
vtkScalarBarActor* theScalarBarActor,
vtkLookupTable* theLookupTable);
+ void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
+ SMESH_DeviceActor* theDeviceActor,
+ vtkScalarBarActor* theScalarBarActor,
+ vtkLookupTable* theLookupTable);
void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
SMESH_DeviceActor* theDeviceActor);
// Author : Nicolas REJNERI
// Module : SMESH
-#include "SMESH_Object.h"
+#include "SMESH_ObjectDef.h"
+#include "SMESH_ActorUtils.h"
+
#include "SMDS_Mesh.hxx"
-#include "SALOME_ExtractUnstructuredGrid.h"
#include "SMESH_Actor.h"
+#include "SMESH_ControlsDef.hxx"
+#include "SALOME_ExtractUnstructuredGrid.h"
#include CORBA_SERVER_HEADER(SALOME_Exception)
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
-#include <vtkUnstructuredGridWriter.h>
-#include <vtkUnstructuredGridReader.h>
#include <memory>
#include <sstream>
#endif
-void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName){
- vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
- aWriter->SetFileName(theFileName);
- aWriter->SetInput(theGrid);
- if(theGrid->GetNumberOfCells()){
- aWriter->Write();
- }
- aWriter->Delete();
-}
-
-
namespace{
inline const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, int theId){
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
- const SMESH::double_array& aCoords = theSeq[theId].coords;
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(3*aNbElems != anIndexes.length())
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
- const SMESH::double_array& aCoords = theSeq[theId].coords;
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(4*aNbElems != anIndexes.length())
SMESH::log_array_var theSeq,
CORBA::Long theId)
{
- const SMESH::double_array& aCoords = theSeq[theId].coords;
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(5*aNbElems != anIndexes.length())
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
- const SMESH::double_array& aCoords = theSeq[theId].coords;
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(5*aNbElems != anIndexes.length())
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
- const SMESH::double_array& aCoords = theSeq[theId].coords;
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(6*aNbElems != anIndexes.length())
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
- const SMESH::double_array& aCoords = theSeq[theId].coords;
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(7*aNbElems != anIndexes.length())
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
- const SMESH::double_array& aCoords = theSeq[theId].coords;
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
if(9*aNbElems != anIndexes.length())
}
/*
- Class : SMESH_VisualObj
+ Class : SMESH_VisualObjDef
Description : Base class for all mesh objects to be visuilised
*/
// function : getCellType
// purpose : Get type of VTK cell
//=================================================================================
-static inline vtkIdType getCellType( const SMESH::ElementType theType,
+static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
const int theNbNodes )
{
switch( theType )
{
- case SMESH::EDGE: return theNbNodes == 2 ? VTK_LINE : VTK_EMPTY_CELL;
-
- case SMESH::FACE : if ( theNbNodes == 3 ) return VTK_TRIANGLE;
- else if ( theNbNodes == 4 ) return VTK_QUAD;
- else return VTK_EMPTY_CELL;
+ case SMDSAbs_Edge:
+ return theNbNodes == 2 ? VTK_LINE : VTK_EMPTY_CELL;
- case SMESH::VOLUME: if ( theNbNodes == 4 ) return VTK_TETRA;
- else if ( theNbNodes == 5 ) return VTK_PYRAMID;
- else if ( theNbNodes == 6 ) return VTK_WEDGE;
- else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON;
- else return VTK_EMPTY_CELL;
+ case SMDSAbs_Face :
+ if ( theNbNodes == 3 ) return VTK_TRIANGLE;
+ else if ( theNbNodes == 4 ) return VTK_QUAD;
+ else return VTK_EMPTY_CELL;
+
+ case SMDSAbs_Volume:
+ if ( theNbNodes == 4 ) return VTK_TETRA;
+ else if ( theNbNodes == 5 ) return VTK_PYRAMID;
+ else if ( theNbNodes == 6 ) return VTK_WEDGE;
+ else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON;
+ else return VTK_EMPTY_CELL;
default: return VTK_EMPTY_CELL;
}
}
//=================================================================================
-// functions : SMESH_VisualObj
+// functions : SMESH_VisualObjDef
// purpose : Constructor
//=================================================================================
-SMESH_VisualObj::SMESH_VisualObj()
+SMESH_VisualObjDef::SMESH_VisualObjDef()
{
myGrid = vtkUnstructuredGrid::New();
}
-SMESH_VisualObj::~SMESH_VisualObj()
+SMESH_VisualObjDef::~SMESH_VisualObjDef()
{
if ( MYDEBUG )
MESSAGE( "~SMESH_MeshObj - myGrid->GetReferenceCount() = " << myGrid->GetReferenceCount() );
// functions : GetNodeObjId, GetNodeVTKId, GetElemObjId, GetElemVTKId
// purpose : Methods for retrieving VTK IDs by SMDS IDs and vice versa
//=================================================================================
-vtkIdType SMESH_VisualObj::GetNodeObjId( int theVTKID )
+vtkIdType SMESH_VisualObjDef::GetNodeObjId( int theVTKID )
{
return myVTK2SMDSNodes.find(theVTKID) == myVTK2SMDSNodes.end() ? -1 : myVTK2SMDSNodes[theVTKID];
}
-vtkIdType SMESH_VisualObj::GetNodeVTKId( int theObjID )
+vtkIdType SMESH_VisualObjDef::GetNodeVTKId( int theObjID )
{
return mySMDS2VTKNodes.find(theObjID) == mySMDS2VTKNodes.end() ? -1 : mySMDS2VTKNodes[theObjID];
}
-vtkIdType SMESH_VisualObj::GetElemObjId( int theVTKID )
+vtkIdType SMESH_VisualObjDef::GetElemObjId( int theVTKID )
{
return myVTK2SMDSElems.find(theVTKID) == myVTK2SMDSElems.end() ? -1 : myVTK2SMDSElems[theVTKID];
}
-vtkIdType SMESH_VisualObj::GetElemVTKId( int theObjID )
+vtkIdType SMESH_VisualObjDef::GetElemVTKId( int theObjID )
{
return mySMDS2VTKElems.find(theObjID) == mySMDS2VTKElems.end() ? -1 : mySMDS2VTKElems[theObjID];
}
//=================================================================================
-// function : SMESH_VisualObj::createPoints
+// function : SMESH_VisualObjDef::createPoints
// purpose : Create points from nodes
//=================================================================================
-void SMESH_VisualObj::createPoints( vtkPoints* thePoints )
+void SMESH_VisualObjDef::createPoints( vtkPoints* thePoints )
{
if ( thePoints == 0 )
return;
TEntityList aNodes;
- vtkIdType nbNodes = GetEntities( SMESH::NODE, aNodes );
+ vtkIdType nbNodes = GetEntities( SMDSAbs_Node, aNodes );
thePoints->SetNumberOfPoints( nbNodes );
int nbPoints = 0;
// function : buildPrs
// purpose : create VTK cells( fill unstructured grid )
//=================================================================================
-void SMESH_VisualObj::buildPrs()
+void SMESH_VisualObjDef::buildPrs()
{
try
{
}
if( MYDEBUG ) MESSAGE( "Update - myGrid->GetNumberOfCells() = "<<myGrid->GetNumberOfCells() );
- if( MYDEBUGWITHFILES ) WriteUnstructuredGrid( myGrid,"/tmp/buildPrs" );
+ if( MYDEBUGWITHFILES ) SMESH::WriteUnstructuredGrid( myGrid,"/tmp/buildPrs" );
}
//=================================================================================
// function : buildNodePrs
// purpose : create VTK cells for nodes
//=================================================================================
-void SMESH_VisualObj::buildNodePrs()
+void SMESH_VisualObjDef::buildNodePrs()
{
vtkPoints* aPoints = vtkPoints::New();
createPoints( aPoints );
- int nbPoints = aPoints->GetNumberOfPoints();
myGrid->SetPoints( aPoints );
aPoints->Delete();
// Create cells
/*
+ int nbPoints = aPoints->GetNumberOfPoints();
vtkIdList *anIdList = vtkIdList::New();
anIdList->SetNumberOfIds( 1 );
// function : buildElemPrs
// purpose : Create VTK cells for elements
//=================================================================================
-void SMESH_VisualObj::buildElemPrs()
+
+namespace{
+ typedef std::vector<const SMDS_MeshElement*> TConnect;
+
+ int GetConnect(const SMDS_ElemIteratorPtr& theNodesIter,
+ TConnect& theConnect)
+ {
+ theConnect.clear();
+ for(; theNodesIter->more();)
+ theConnect.push_back(theNodesIter->next());
+ return theConnect.size();
+ }
+
+ inline
+ void SetId(vtkIdList *theIdList,
+ const SMESH_VisualObjDef::TMapOfIds& theSMDS2VTKNodes,
+ const TConnect& theConnect,
+ int thePosition,
+ int theId)
+ {
+ theIdList->SetId(thePosition,theSMDS2VTKNodes.find(theConnect[theId]->GetID())->second);
+ }
+
+}
+
+
+void SMESH_VisualObjDef::buildElemPrs()
{
// Create points
// Calculate cells size
- static SMESH::ElementType aTypes[ 3 ] = { SMESH::EDGE, SMESH::FACE, SMESH::VOLUME };
+ static SMDSAbs_ElementType aTypes[ 3 ] = { SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Volume };
// get entity data
- map< int, int > nbEnts;
- map< int, TEntityList > anEnts;
+ map<SMDSAbs_ElementType,int> nbEnts;
+ map<SMDSAbs_ElementType,TEntityList> anEnts;
for ( int i = 0; i <= 2; i++ )
nbEnts[ aTypes[ i ] ] = GetEntities( aTypes[ i ], anEnts[ aTypes[ i ] ] );
- vtkIdType aCellsSize = 3 * nbEnts[ SMESH::EDGE ];
+ vtkIdType aCellsSize = 3 * nbEnts[ SMDSAbs_Edge ];
for ( int i = 1; i <= 2; i++ ) // iterate through faces and volumes
{
}
}
- vtkIdType aNbCells = nbEnts[ SMESH::EDGE ] + nbEnts[ SMESH::FACE ] + nbEnts[ SMESH::VOLUME ];
+ vtkIdType aNbCells = nbEnts[ SMDSAbs_Edge ] + nbEnts[ SMDSAbs_Face ] + nbEnts[ SMDSAbs_Volume ];
if ( MYDEBUG )
MESSAGE( "Update - aNbCells = "<<aNbCells<<"; aCellsSize = "<<aCellsSize );
vtkIdList *anIdList = vtkIdList::New();
vtkIdType iElem = 0;
-
+
+ TConnect aConnect;
+ aConnect.reserve(VTK_CELL_SIZE);
+
for ( int i = 0; i <= 2; i++ ) // iterate through edges, faces and volumes
{
if( nbEnts[ aTypes[ i ] ] > 0 )
{
- const TEntityList& aList = anEnts[ aTypes[ i ] ];
+ const SMDSAbs_ElementType& aType = aTypes[ i ];
+ const TEntityList& aList = anEnts[ aType ];
TEntityList::const_iterator anIter;
for ( anIter = aList.begin(); anIter != aList.end(); ++anIter )
{
myVTK2SMDSElems.insert( TMapOfIds::value_type( iElem, anId ) );
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
- for( vtkIdType aNodeId = 0; aNodesIter->more(); aNodeId++ )
- {
- const SMDS_MeshElement* aNode = aNodesIter->next();
- anIdList->SetId( aNodeId, mySMDS2VTKNodes[aNode->GetID()] );
- }
+ switch(aType){
+ case SMDSAbs_Volume:{
+ int* aConnectivities = NULL;
+ GetConnect(aNodesIter,aConnect);
+ // Convertions connectivities from SMDS to VTK
+ switch(aNbNodes){
+ case 4:{
+ static int anIds[] = {0,2,1,3};
+ aConnectivities = anIds;
+ break;
+ }
+ case 5:{
+ static int anIds[] = {0,3,2,1,4};
+ aConnectivities = anIds;
+ break;
+ }
+ case 6:{
+ static int anIds[] = {0,1,2,3,4,5};
+ aConnectivities = anIds;
+ break;
+ }
+ case 8:{
+ static int anIds[] = {0,3,2,1,4,7,6,5};
+ aConnectivities = anIds;
+ break;
+ }}
+
+ if(aConnectivities)
+ for( vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++ )
+ SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]);
+
+ break;
+ }
+ default:
+ for( vtkIdType aNodeId = 0; aNodesIter->more(); aNodeId++ ){
+ const SMDS_MeshElement* aNode = aNodesIter->next();
+ anIdList->SetId( aNodeId, mySMDS2VTKNodes[aNode->GetID()] );
+ }
+ }
aConnectivity->InsertNextCell( anIdList );
- aCellTypesArray->InsertNextValue( getCellType( aTypes[ i ], aNbNodes ) );
+ aCellTypesArray->InsertNextValue( getCellType( aType, aNbNodes ) );
iElem++;
}
// function : GetEdgeNodes
// purpose : Retrieve ids of nodes from edge of elements ( edge is numbered from 1 )
//=================================================================================
-bool SMESH_VisualObj::GetEdgeNodes( const int theElemId,
- const int theEdgeNum,
- int& theNodeId1,
- int& theNodeId2 ) const
+bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
+ const int theEdgeNum,
+ int& theNodeId1,
+ int& theNodeId2 ) const
{
const SMDS_Mesh* aMesh = GetMesh();
if ( aMesh == 0 )
const SMESH::double_array& aCoords = aSeq[anId].coords;
const SMESH::long_array& anIndexes = aSeq[anId].indexes;
CORBA::Long anElemId = 0, aNbElems = aSeq[anId].number;
- SMDS_MeshElement* anElem = NULL;
CORBA::Long aCommand = aSeq[anId].commandType;
switch(aCommand)
// function : GetEntities
// purpose : Get entities of specified type. Return number of entities
//=================================================================================
-int SMESH_MeshObj::GetNbEntities( const SMESH::ElementType theType) const
+int SMESH_MeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
{
switch ( theType )
{
- case SMESH::NODE:
+ case SMDSAbs_Node:
{
return myMesh->NbNodes();
}
break;
- case SMESH::EDGE:
+ case SMDSAbs_Edge:
{
return myMesh->NbEdges();
}
break;
- case SMESH::FACE:
+ case SMDSAbs_Face:
{
return myMesh->NbFaces();
}
break;
- case SMESH::VOLUME:
+ case SMDSAbs_Volume:
{
return myMesh->NbVolumes();
}
}
}
-int SMESH_MeshObj::GetEntities( const SMESH::ElementType theType, TEntityList& theObjs ) const
+int SMESH_MeshObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList& theObjs ) const
{
theObjs.clear();
switch ( theType )
{
- case SMESH::NODE:
+ case SMDSAbs_Node:
{
SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() );
}
break;
- case SMESH::EDGE:
+ case SMDSAbs_Edge:
{
SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() );
}
break;
- case SMESH::FACE:
+ case SMDSAbs_Face:
{
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() );
}
break;
- case SMESH::VOLUME:
+ case SMDSAbs_Volume:
{
SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
while ( anIter->more() ) theObjs.push_back( anIter->next() );
// function : getPointers
// purpose : Get std::list<const SMDS_MeshElement*> from list of IDs
//=================================================================================
-static int getPointers( const SMESH::ElementType theRequestType,
+static int getPointers( const SMDSAbs_ElementType theRequestType,
SMESH::long_array_var& theElemIds,
const SMDS_Mesh* theMesh,
std::list<const SMDS_MeshElement*>& theResList )
{
for ( CORBA::Long i = 0, n = theElemIds->length(); i < n; i++ )
{
- const SMDS_MeshElement* anElem = theRequestType == SMESH::NODE
+ const SMDS_MeshElement* anElem = theRequestType == SMDSAbs_Node
? theMesh->FindNode( theElemIds[ i ] ) : theMesh->FindElement( theElemIds[ i ] );
if ( anElem != 0 )
// function : GetEntities
// purpose : Get entities of specified type. Return number of entities
//=================================================================================
-int SMESH_GroupObj::GetNbEntities( const SMESH::ElementType theType) const
+int SMESH_GroupObj::GetNbEntities( const SMDSAbs_ElementType theType) const
{
- if(myGroupServer->GetType() == theType){
+ if(SMDSAbs_ElementType(myGroupServer->GetType()) == theType){
return myGroupServer->Size();
}
return 0;
}
-int SMESH_GroupObj::GetEntities( const SMESH::ElementType theType, TEntityList& theResList ) const
+int SMESH_GroupObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList& theResList ) const
{
theResList.clear();
SMDS_Mesh* aMesh = myMeshObj->GetMesh();
if ( myGroupServer->Size() == 0 || aMesh == 0 )
return 0;
- SMESH::ElementType aGrpType = myGroupServer->GetType();
+ SMDSAbs_ElementType aGrpType = SMDSAbs_ElementType(myGroupServer->GetType());
SMESH::long_array_var anIds = myGroupServer->GetListOfID();
if ( aGrpType == theType )
return getPointers( theType, anIds, aMesh, theResList );
- else if ( theType == SMESH::NODE )
+ else if ( theType == SMDSAbs_Node )
return getNodesFromElems( anIds, aMesh, theResList );
else
return 0;
// function : GetEntities
// purpose : Get entities of specified type. Return number of entities
//=================================================================================
-int SMESH_subMeshObj::GetNbEntities( const SMESH::ElementType theType) const
+int SMESH_subMeshObj::GetNbEntities( const SMDSAbs_ElementType theType) const
{
switch ( theType )
{
- case SMESH::NODE:
+ case SMDSAbs_Node:
{
return mySubMeshServer->GetNumberOfNodes( false );
}
break;
- case SMESH::EDGE:
- case SMESH::FACE:
- case SMESH::VOLUME:
+ case SMDSAbs_Edge:
+ case SMDSAbs_Face:
+ case SMDSAbs_Volume:
{
- SMESH::long_array_var anIds = mySubMeshServer->GetElementsByType( theType );
+ SMESH::long_array_var anIds =
+ mySubMeshServer->GetElementsByType( SMESH::ElementType(theType) );
return anIds->length();
}
default:
}
}
-int SMESH_subMeshObj::GetEntities( const SMESH::ElementType theType, TEntityList& theResList ) const
+int SMESH_subMeshObj::GetEntities( const SMDSAbs_ElementType theType, TEntityList& theResList ) const
{
theResList.clear();
if ( isNodal )
{
- if ( theType == SMESH::NODE )
+ if ( theType == SMDSAbs_Node )
{
SMESH::long_array_var anIds = mySubMeshServer->GetNodesId();
- return getPointers( SMESH::NODE, anIds, aMesh, theResList );
+ return getPointers( SMDSAbs_Node, anIds, aMesh, theResList );
}
}
else
{
- if ( theType == SMESH::NODE )
+ if ( theType == SMDSAbs_Node )
{
SMESH::long_array_var anIds = mySubMeshServer->GetElementsId();
return getNodesFromElems( anIds, aMesh, theResList );
}
else
{
- SMESH::long_array_var anIds = mySubMeshServer->GetElementsByType( theType );
+ SMESH::long_array_var anIds =
+ mySubMeshServer->GetElementsByType( SMESH::ElementType(theType) );
return getPointers( theType, anIds, aMesh, theResList );
}
}
#ifndef SMESH_OBJECT_H
#define SMESH_OBJECT_H
-// IDL Headers
-#include "SALOMEconfig.h"
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
-#include CORBA_SERVER_HEADER(SMESH_Group)
-
-#include <map>
-#include <list>
#include <boost/shared_ptr.hpp>
#include <vtkSystemIncludes.h>
#include "SMESH_Controls.hxx"
+#include "SMDSAbs_ElementType.hxx"
-class vtkUnstructuredGrid;
-class vtkPoints;
-class SALOME_ExtractUnstructuredGrid;
-
-class SMESH_Actor;
class SMDS_Mesh;
-class SMDS_MeshNode;
-class SMDS_MeshElement;
-
-class SMESH_VisualObj;
-typedef boost::shared_ptr<SMESH_VisualObj> TVisualObjPtr;
-
+class vtkUnstructuredGrid;
/*
Class : SMESH_VisualObj
*/
class SMESH_VisualObj
{
-protected:
-
- typedef std::list<const SMDS_MeshElement*> TEntityList;
- typedef std::map<vtkIdType,vtkIdType> TMapOfIds;
-
-public:
- SMESH_VisualObj();
- virtual ~SMESH_VisualObj();
-
- virtual void Update( int theIsClear = true ) = 0;
- virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
- virtual int GetElemDimension( const int theObjId ) = 0;
-
- virtual int GetNbEntities( const SMESH::ElementType) const = 0;
- virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const = 0;
- virtual bool IsNodePrs() const = 0;
- virtual SMDS_Mesh* GetMesh() const = 0;
-
- bool GetEdgeNodes( const int theElemId,
- const int theEdgeNum,
- int& theNodeId1,
- int& theNodeId2 ) const;
-
- vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; }
-
- vtkIdType GetNodeObjId( int theVTKID );
- vtkIdType GetNodeVTKId( int theObjID );
- vtkIdType GetElemObjId( int theVTKID );
- vtkIdType GetElemVTKId( int theObjID );
-
-protected:
-
- void createPoints( vtkPoints* );
- void buildPrs();
- void buildNodePrs();
- void buildElemPrs();
-
-private:
-
- TMapOfIds mySMDS2VTKNodes;
- TMapOfIds myVTK2SMDSNodes;
- TMapOfIds mySMDS2VTKElems;
- TMapOfIds myVTK2SMDSElems;
-
- vtkUnstructuredGrid* myGrid;
-};
-
-
-/*
- Class : SMESH_MeshObj
- Description : Class for visualisation of mesh
-*/
-
-class SMESH_MeshObj: public SMESH_VisualObj
-{
-public:
-
- SMESH_MeshObj( SMESH::SMESH_Mesh_ptr );
- virtual ~SMESH_MeshObj();
-
- virtual void Update( int theIsClear = true );
-
- virtual int GetNbEntities( const SMESH::ElementType) const;
- virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
- virtual bool IsNodePrs() const;
-
- virtual int GetElemDimension( const int theObjId );
-
- virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
-
- SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); }
- SMDS_Mesh* GetMesh() const { return myMesh; }
-
-protected:
-
- SMESH::SMESH_Mesh_var myMeshServer;
- SMDS_Mesh* myMesh;
-};
-
-
-/*
- Class : SMESH_SubMeshObj
- Description : Base class for visualisation of submeshes and groups
-*/
-
-class SMESH_SubMeshObj: public SMESH_VisualObj
-{
public:
+ virtual void Update( int theIsClear = true ) = 0;
+ virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
+ virtual int GetElemDimension( const int theObjId ) = 0;
- SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj);
- virtual ~SMESH_SubMeshObj();
+ virtual int GetNbEntities( const SMDSAbs_ElementType theType) const = 0;
+ virtual SMDS_Mesh* GetMesh() const = 0;
- virtual void Update( int theIsClear = true );
+ virtual bool GetEdgeNodes( const int theElemId,
+ const int theEdgeNum,
+ int& theNodeId1,
+ int& theNodeId2 ) const = 0;
- virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
- virtual int GetElemDimension( const int theObjId );
- virtual SMDS_Mesh* GetMesh() const { return myMeshObj->GetMesh(); }
+ virtual vtkUnstructuredGrid* GetUnstructuredGrid() = 0;
-protected:
-
- SMESH_MeshObj* myMeshObj;
+ virtual vtkIdType GetNodeObjId( int theVTKID ) = 0;
+ virtual vtkIdType GetNodeVTKId( int theObjID ) = 0;
+ virtual vtkIdType GetElemObjId( int theVTKID ) = 0;
+ virtual vtkIdType GetElemVTKId( int theObjID ) = 0;
};
-
-/*
- Class : SMESH_GroupObj
- Description : Class for visualisation of groups
-*/
-
-class SMESH_GroupObj: public SMESH_SubMeshObj
-{
-public:
- SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr, SMESH_MeshObj* );
- virtual ~SMESH_GroupObj();
-
- virtual int GetNbEntities( const SMESH::ElementType) const;
- virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
- virtual bool IsNodePrs() const;
-
-private:
-
- SMESH::SMESH_GroupBase_var myGroupServer;
-};
-
-
-/*
- Class : SMESH_subMeshObj
- Description : Class for visualisation of submeshes
-*/
-
-class SMESH_subMeshObj : public SMESH_SubMeshObj
-{
-public:
-
- SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr,
- SMESH_MeshObj* );
- virtual ~SMESH_subMeshObj();
-
- virtual int GetNbEntities( const SMESH::ElementType) const;
- virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const;
- virtual bool IsNodePrs() const;
-
-protected:
-
- SMESH::SMESH_subMesh_var mySubMeshServer;
-};
-
-
-extern void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName);
-
+typedef boost::shared_ptr<SMESH_VisualObj> TVisualObjPtr;
#endif
--- /dev/null
+// SMESH OBJECT : interactive object for SMESH visualization
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESH_Object.h
+// Author : Nicolas REJNERI
+// Module : SMESH
+// $Header$
+
+#ifndef SMESH_OBJECTDEF_H
+#define SMESH_OBJECTDEF_H
+
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
+#include <map>
+#include <list>
+
+#include "SMESH_Controls.hxx"
+#include "SMESH_Object.h"
+
+class vtkPoints;
+class SALOME_ExtractUnstructuredGrid;
+
+class SMESH_Actor;
+class SMDS_MeshNode;
+class SMDS_MeshElement;
+
+/*
+ Class : SMESH_VisualObj
+ Description : Base class for all mesh objects to be visuilised
+*/
+class SMESH_VisualObjDef: public SMESH_VisualObj
+{
+public:
+ typedef std::list<const SMDS_MeshElement*> TEntityList;
+ typedef std::map<vtkIdType,vtkIdType> TMapOfIds;
+
+ SMESH_VisualObjDef();
+ virtual ~SMESH_VisualObjDef();
+
+ virtual void Update( int theIsClear = true ) = 0;
+ virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
+ virtual int GetElemDimension( const int theObjId ) = 0;
+
+ virtual int GetNbEntities( const SMDSAbs_ElementType theType) const = 0;
+ virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const = 0;
+ virtual bool IsNodePrs() const = 0;
+ virtual SMDS_Mesh* GetMesh() const = 0;
+
+ virtual bool GetEdgeNodes( const int theElemId,
+ const int theEdgeNum,
+ int& theNodeId1,
+ int& theNodeId2 ) const;
+
+ virtual vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; }
+
+ virtual vtkIdType GetNodeObjId( int theVTKID );
+ virtual vtkIdType GetNodeVTKId( int theObjID );
+ virtual vtkIdType GetElemObjId( int theVTKID );
+ virtual vtkIdType GetElemVTKId( int theObjID );
+
+protected:
+
+ void createPoints( vtkPoints* );
+ void buildPrs();
+ void buildNodePrs();
+ void buildElemPrs();
+
+private:
+
+ TMapOfIds mySMDS2VTKNodes;
+ TMapOfIds myVTK2SMDSNodes;
+ TMapOfIds mySMDS2VTKElems;
+ TMapOfIds myVTK2SMDSElems;
+
+ vtkUnstructuredGrid* myGrid;
+};
+
+
+/*
+ Class : SMESH_MeshObj
+ Description : Class for visualisation of mesh
+*/
+
+class SMESH_MeshObj: public SMESH_VisualObjDef
+{
+public:
+
+ SMESH_MeshObj( SMESH::SMESH_Mesh_ptr );
+ virtual ~SMESH_MeshObj();
+
+ virtual void Update( int theIsClear = true );
+
+ virtual int GetNbEntities( const SMDSAbs_ElementType) const;
+ virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
+ virtual bool IsNodePrs() const;
+
+ virtual int GetElemDimension( const int theObjId );
+
+ virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
+
+ SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); }
+ SMDS_Mesh* GetMesh() const { return myMesh; }
+
+protected:
+
+ SMESH::SMESH_Mesh_var myMeshServer;
+ SMDS_Mesh* myMesh;
+};
+
+
+/*
+ Class : SMESH_SubMeshObj
+ Description : Base class for visualisation of submeshes and groups
+*/
+
+class SMESH_SubMeshObj: public SMESH_VisualObjDef
+{
+public:
+
+ SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj);
+ virtual ~SMESH_SubMeshObj();
+
+ virtual void Update( int theIsClear = true );
+
+ virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor );
+ virtual int GetElemDimension( const int theObjId );
+ virtual SMDS_Mesh* GetMesh() const { return myMeshObj->GetMesh(); }
+
+protected:
+
+ SMESH_MeshObj* myMeshObj;
+};
+
+
+/*
+ Class : SMESH_GroupObj
+ Description : Class for visualisation of groups
+*/
+
+class SMESH_GroupObj: public SMESH_SubMeshObj
+{
+public:
+ SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr, SMESH_MeshObj* );
+ virtual ~SMESH_GroupObj();
+
+ virtual int GetNbEntities( const SMDSAbs_ElementType) const;
+ virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
+ virtual bool IsNodePrs() const;
+
+private:
+
+ SMESH::SMESH_GroupBase_var myGroupServer;
+};
+
+
+/*
+ Class : SMESH_subMeshObj
+ Description : Class for visualisation of submeshes
+*/
+
+class SMESH_subMeshObj : public SMESH_SubMeshObj
+{
+public:
+
+ SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr,
+ SMESH_MeshObj* );
+ virtual ~SMESH_subMeshObj();
+
+ virtual int GetNbEntities( const SMDSAbs_ElementType) const;
+ virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
+ virtual bool IsNodePrs() const;
+
+protected:
+
+ SMESH::SMESH_subMesh_var mySubMeshServer;
+};
+
+
+#endif
SMDS_TypeOfPosition.hxx \
SMDSAbs_ElementType.hxx \
SMDS_EdgePosition.hxx \
+ SMDS_ElemIterator.hxx \
SMDS_FacePosition.hxx \
SMDS_Mesh.hxx \
SMDS_MeshEdge.hxx \
#SMDS_MeshNodeIDFactory.hxx
# additionnal information to compil and link file
-CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
+CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(OCC_INCLUDES) $(BOOST_CPPFLAGS)
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome
-LDFLAGS += -L${KERNEL_ROOT_DIR}/lib/salome
+LDFLAGS += -L${KERNEL_ROOT_DIR}/lib/salome $(OCC_KERNEL_LIBS)
# additional file to be cleaned
--- /dev/null
+// SMESH SMDS : implementaion of Salome mesh data structure
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMDS_MeshElement.hxx
+// Module : SMESH
+// Created: 12.01.05 18:02:52
+// Author: Michael Sazonov
+
+#ifndef SMDS_ElemIterator_HeaderFile
+#define SMDS_ElemIterator_HeaderFile
+
+#include "SMDS_Iterator.hxx"
+#include <boost/shared_ptr.hpp>
+
+class SMDS_MeshElement;
+
+typedef SMDS_Iterator<const SMDS_MeshElement *> SMDS_ElemIterator;
+typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshElement *> > SMDS_ElemIteratorPtr;
+
+#endif
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
+
#include "SMDS_FaceOfEdges.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
int SMDS_FaceOfEdges::NbEdges() const
{
- return myEdges.size();
+ return myNbEdges;
}
int SMDS_FaceOfEdges::NbFaces() const
return SMDSAbs_Face;
}
+//=======================================================================
+//function : elementsIterator
+//purpose :
+//=======================================================================
+
class SMDS_FaceOfEdges_MyIterator:public SMDS_ElemIterator
{
- const vector<const SMDS_MeshEdge*>& mySet;
+ const SMDS_MeshEdge* const *mySet;
+ int myLength;
int index;
public:
- SMDS_FaceOfEdges_MyIterator(const vector<const SMDS_MeshEdge*>& s):
- mySet(s),index(0) {}
+ SMDS_FaceOfEdges_MyIterator(const SMDS_MeshEdge* const *s, int l):
+ mySet(s),myLength(l),index(0) {}
bool more()
{
- return index<mySet.size();
+ return index<myLength;
}
const SMDS_MeshElement* next()
return mySet[index-1];
}
};
-SMDS_ElemIteratorPtr SMDS_FaceOfEdges::
- elementsIterator(SMDSAbs_ElementType type) const
+
+SMDS_ElemIteratorPtr SMDS_FaceOfEdges::elementsIterator
+ (SMDSAbs_ElementType type) const
{
- switch(type)
- {
- case SMDSAbs_Face:
- return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
- case SMDSAbs_Edge:
- return SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges));
- default:
- return SMDS_ElemIteratorPtr
- (new SMDS_IteratorOfElements
- (this,type, SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges))));
- }
+ switch(type)
+ {
+ case SMDSAbs_Face:
+ return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
+ case SMDSAbs_Edge:
+ return SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges));
+ default:
+ return SMDS_ElemIteratorPtr
+ (new SMDS_IteratorOfElements
+ (this,type, SMDS_ElemIteratorPtr
+ (new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges))));
+ }
}
SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
const SMDS_MeshEdge* edge2,
const SMDS_MeshEdge* edge3)
{
- myEdges.resize(3);
+ myNbEdges = 3;
myEdges[0]=edge1;
myEdges[1]=edge2;
myEdges[2]=edge3;
+ myEdges[3]=0;
}
SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
const SMDS_MeshEdge* edge3,
const SMDS_MeshEdge* edge4)
{
- myEdges.resize(4);
+ myNbEdges = 4;
myEdges[0]=edge1;
myEdges[1]=edge2;
myEdges[2]=edge3;
elementsIterator(SMDSAbs_ElementType type) const;
private:
- std::vector<const SMDS_MeshEdge*> myEdges;
+ const SMDS_MeshEdge* myEdges[4];
+ int myNbEdges;
};
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
+
#include "SMDS_FaceOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
int SMDS_FaceOfNodes::NbNodes() const
{
- return myNodes.size();
+ return myNbNodes;
}
+
//=======================================================================
//function : Print
//purpose :
OS << myNodes[i] << ") " << endl;
}
+//=======================================================================
+//function : elementsIterator
+//purpose :
+//=======================================================================
+
class SMDS_FaceOfNodes_MyIterator:public SMDS_ElemIterator
{
- const vector<const SMDS_MeshNode*>& mySet;
+ const SMDS_MeshNode* const *mySet;
+ int myLength;
int index;
public:
- SMDS_FaceOfNodes_MyIterator(const vector<const SMDS_MeshNode*>& s):
- mySet(s),index(0) {}
+ SMDS_FaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l):
+ mySet(s),myLength(l),index(0) {}
bool more()
{
- return index<mySet.size();
+ return index<myLength;
}
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
- }
+ }
};
-SMDS_ElemIteratorPtr SMDS_FaceOfNodes::
- elementsIterator(SMDSAbs_ElementType type) const
+
+SMDS_ElemIteratorPtr SMDS_FaceOfNodes::elementsIterator
+ (SMDSAbs_ElementType type) const
{
switch(type)
{
case SMDSAbs_Face:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
case SMDSAbs_Node:
- return SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes));
+ return SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes,myNbNodes));
case SMDSAbs_Edge:
MESSAGE("Error : edge iterator for SMDS_FaceOfNodes not implemented");
break;
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
- (this,type,SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes))));
+ (this,type,SMDS_ElemIteratorPtr
+ (new SMDS_FaceOfNodes_MyIterator(myNodes,myNbNodes))));
}
return SMDS_ElemIteratorPtr();
}
const SMDS_MeshNode* node2,
const SMDS_MeshNode* node3)
{
- myNodes.resize(3);
+ myNbNodes = 3;
myNodes[0]=node1;
myNodes[1]=node2;
myNodes[2]=node3;
+ myNodes[3]=0;
}
SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
const SMDS_MeshNode* node3,
const SMDS_MeshNode* node4)
{
- myNodes.resize(4);
+ myNbNodes = 4;
myNodes[0]=node1;
myNodes[1]=node2;
myNodes[2]=node3;
bool SMDS_FaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes)
{
- if (nbNodes == 3) {
- myNodes.resize(3);
- myNodes[0]=nodes[0];
- myNodes[1]=nodes[1];
- myNodes[2]=nodes[2];
- }
- else if ( nbNodes == 4) {
- myNodes.resize(4);
- myNodes[0]=nodes[0];
- myNodes[1]=nodes[1];
- myNodes[2]=nodes[2];
+ myNbNodes = nbNodes;
+ myNodes[0]=nodes[0];
+ myNodes[1]=nodes[1];
+ myNodes[2]=nodes[2];
+ if (nbNodes == 4)
myNodes[3]=nodes[3];
- }
- else
+ else if (nbNodes != 3)
return false;
return true;
elementsIterator(SMDSAbs_ElementType type) const;
private:
- std::vector<const SMDS_MeshNode*> myNodes;
+ const SMDS_MeshNode* myNodes[4];
+ int myNbNodes;
};
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
+
#include "SMDS_IteratorOfElements.hxx"
bool SMDS_IteratorOfElements::subMore()
{
- if((t2Iterator==NULL)||(!t2Iterator->more()))
+ if((t2Iterator.get()==NULL)||(!t2Iterator->more()))
{
if(t1Iterator->more())
{
const SMDS_MeshElement * SMDS_IteratorOfElements::subNext()
{
- if((t2Iterator==NULL)||(!t2Iterator->more()))
+ if((t2Iterator.get()==NULL)||(!t2Iterator->more()))
if(t1Iterator->more())
t2Iterator=t1Iterator->next()->elementsIterator(myType);
return t2Iterator->next();
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
+
#include "utilities.h"
#include "SMDS_Mesh.hxx"
#include "SMDS_VolumeOfNodes.hxx"
#include "SMDS_FaceOfEdges.hxx"
#include <algorithm>
+#include <map>
using namespace std;
///////////////////////////////////////////////////////////////////////////////
/// Create a new mesh object
///////////////////////////////////////////////////////////////////////////////
SMDS_Mesh::SMDS_Mesh()
- :myNodeIDFactory(new SMDS_MeshElementIDFactory()),
+ :myParent(NULL),
+ myNodeIDFactory(new SMDS_MeshElementIDFactory()),
myElementIDFactory(new SMDS_MeshElementIDFactory()),
myHasConstructionEdges(false), myHasConstructionFaces(false),
myHasInverseElements(true)
const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID);
if(!node){
SMDS_MeshNode * node=new SMDS_MeshNode(x, y, z);
- myNodes.insert(node);
+ myNodes.Add(node);
myNodeIDFactory->BindID(ID,node);
return node;
}else
node2=const_cast<SMDS_MeshNode*>(n2);
node1->AddInverseElement(edge);
node2->AddInverseElement(edge);
- myEdges.insert(edge);
+ myEdges.Add(edge);
return edge;
}
else {
if (!hasConstructionEdges())
return NULL;
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3);
- myFaces.insert(face);
+ myFaces.Add(face);
if (!registerElement(ID, face)) {
RemoveElement(face, false);
if (!hasConstructionEdges())
return NULL;
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3,e4);
- myFaces.insert(face);
+ myFaces.Add(face);
if (!registerElement(ID, face))
{
SMDS_MeshFace * f3=FindFaceOrCreate(n1,n3,n4);
SMDS_MeshFace * f4=FindFaceOrCreate(n2,n3,n4);
volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
}
else if(hasConstructionEdges()) {
MESSAGE("Error : Not implemented");
}
else {
volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
}
if (!registerElement(ID, volume)) {
SMDS_MeshFace * f3=FindFaceOrCreate(n2,n3,n5);
SMDS_MeshFace * f4=FindFaceOrCreate(n3,n4,n5);
volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
}
else if(hasConstructionEdges()) {
MESSAGE("Error : Not implemented");
}
else {
volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
}
if (!registerElement(ID, volume)) {
SMDS_MeshFace * f4=FindFaceOrCreate(n2,n5,n6,n3);
SMDS_MeshFace * f5=FindFaceOrCreate(n3,n6,n4,n1);
volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
}
else if(hasConstructionEdges()) {
MESSAGE("Error : Not implemented");
}
else {
volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5,n6);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
}
if (!registerElement(ID, volume)) {
SMDS_MeshFace * f5=FindFaceOrCreate(n2,n3,n7,n6);
SMDS_MeshFace * f6=FindFaceOrCreate(n3,n4,n8,n7);
volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
}
else if(hasConstructionEdges()) {
MESSAGE("Error : Not implemented");
else {
// volume=new SMDS_HexahedronOfNodes(n1,n2,n3,n4,n5,n6,n7,n8);
volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5,n6,n7,n8);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
}
if (!registerElement(ID, volume)) {
if (!hasConstructionFaces())
return NULL;
SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
if (!registerElement(ID, volume)) {
RemoveElement(volume, false);
if (!hasConstructionFaces())
return NULL;
SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
if (!registerElement(ID, volume)) {
RemoveElement(volume, false);
if (!hasConstructionFaces())
return NULL;
SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6);
- myVolumes.insert(volume);
+ myVolumes.Add(volume);
if (!registerElement(ID, volume)) {
RemoveElement(volume, false);
edge3=FindEdgeOrCreate(node3,node1);
SMDS_MeshFace * face = new SMDS_FaceOfEdges(edge1,edge2,edge3);
- myFaces.insert(face);
+ myFaces.Add(face);
return face;
}
else
{
SMDS_MeshFace * face = new SMDS_FaceOfNodes(node1,node2,node3);
- myFaces.insert(face);
+ myFaces.Add(face);
return face;
}
}
edge4=FindEdgeOrCreate(node4,node1);
SMDS_MeshFace * face = new SMDS_FaceOfEdges(edge1,edge2,edge3,edge4);
- myFaces.insert(face);
+ myFaces.Add(face);
return face;
}
else
{
SMDS_MeshFace * face = new SMDS_FaceOfNodes(node1,node2,node3,node4);
- myFaces.insert(face);
+ myFaces.Add(face);
return face;
}
}
if(toReturn==NULL)
{
toReturn=new SMDS_MeshEdge(node1,node2);
- myEdges.insert(toReturn);
+ myEdges.Add(toReturn);
}
return toReturn;
}
///////////////////////////////////////////////////////////////////////////////
int SMDS_Mesh::NbNodes() const
{
- return myNodes.size();
+ return myNodes.Size();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int SMDS_Mesh::NbEdges() const
{
- return myEdges.size();
+ return myEdges.Size();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int SMDS_Mesh::NbFaces() const
{
- return myFaces.size();
+ return myFaces.Size();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int SMDS_Mesh::NbVolumes() const
{
- return myVolumes.size();
+ return myVolumes.Size();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
SMDS_Mesh::~SMDS_Mesh()
{
- if(myParent==NULL)
- {
- delete myNodeIDFactory;
- delete myElementIDFactory;
- }
+ list<SMDS_Mesh*>::iterator itc=myChildren.begin();
+ while(itc!=myChildren.end())
+ {
+ delete *itc;
+ itc++;
+ }
- list<SMDS_Mesh*>::iterator itc=myChildren.begin();
- while(itc!=myChildren.end())
- {
- delete *itc;
- itc++;
- }
-
- SMDS_NodeIteratorPtr itn=nodesIterator();
- while(itn->more())
- {
- delete itn->next();
- }
+ SetOfNodes::Iterator itn(myNodes);
+ for (; itn.More(); itn.Next())
+ delete itn.Value();
- set<SMDS_MeshEdge*>::iterator ite=myEdges.begin();
- while(ite!=myEdges.end())
- {
- delete *ite;
- ite++;
- }
+ SetOfEdges::Iterator ite(myEdges);
+ for (; ite.More(); ite.Next())
+ {
+ SMDS_MeshElement* elem = ite.Value();
+ if(myParent!=NULL)
+ myElementIDFactory->ReleaseID(elem->GetID());
+ delete elem;
+ }
- set<SMDS_MeshFace*>::iterator itf=myFaces.begin();
- while(itf!=myFaces.end())
- {
- delete *itf;
- itf++;
- }
+ SetOfFaces::Iterator itf(myFaces);
+ for (; itf.More(); itf.Next())
+ {
+ SMDS_MeshElement* elem = itf.Value();
+ if(myParent!=NULL)
+ myElementIDFactory->ReleaseID(elem->GetID());
+ delete elem;
+ }
- set<SMDS_MeshVolume*>::iterator itv=myVolumes.begin();
- while(itv!=myVolumes.end())
- {
- delete *itv;
- itv++;
- }
+ SetOfVolumes::Iterator itv(myVolumes);
+ for (; itv.More(); itv.Next())
+ {
+ SMDS_MeshElement* elem = itv.Value();
+ if(myParent!=NULL)
+ myElementIDFactory->ReleaseID(elem->GetID());
+ delete elem;
+ }
+
+ if(myParent==NULL)
+ {
+ delete myNodeIDFactory;
+ delete myElementIDFactory;
+ }
}
///////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////
-/// Return an iterator on nodes of the current mesh
+/// Return an iterator on nodes of the current mesh factory
///////////////////////////////////////////////////////////////////////////////
class SMDS_Mesh_MyNodeIterator:public SMDS_NodeIterator
{
- const SMDS_IdElementMap& myIdElemMap;
- SMDS_IdElementMap::const_iterator myIterator;
+ SMDS_ElemIteratorPtr myIterator;
public:
- SMDS_Mesh_MyNodeIterator(const SMDS_IdElementMap& s):myIdElemMap(s)
- {
- myIterator=myIdElemMap.begin();
- }
+ SMDS_Mesh_MyNodeIterator(const SMDS_ElemIteratorPtr& it):myIterator(it)
+ {}
bool more()
{
- return myIterator!=myIdElemMap.end();
+ return myIterator->more();
}
const SMDS_MeshNode* next()
{
- const SMDS_MeshElement* current=(*myIterator).second;
- myIterator++;
- return static_cast<const SMDS_MeshNode*>( current );
+ return static_cast<const SMDS_MeshNode*>(myIterator->next());
}
};
SMDS_NodeIteratorPtr SMDS_Mesh::nodesIterator() const
{
return SMDS_NodeIteratorPtr
- (new SMDS_Mesh_MyNodeIterator(myNodeIDFactory->GetIdElementMap()));
+ (new SMDS_Mesh_MyNodeIterator(myNodeIDFactory->elementsIterator()));
}
+
///////////////////////////////////////////////////////////////////////////////
-/// Return an iterator on nodes of the current mesh
+/// Return an iterator on elements of the current mesh factory
///////////////////////////////////////////////////////////////////////////////
-class SMDS_Mesh_MyElemIterator:public SMDS_ElemIterator
-{
- const SMDS_IdElementMap& myIdElemMap;
- SMDS_IdElementMap::const_iterator myIterator;
- public:
- SMDS_Mesh_MyElemIterator(const SMDS_IdElementMap& s):myIdElemMap(s)
- {
- myIterator=myIdElemMap.begin();
- }
-
- bool more()
- {
- return myIterator!=myIdElemMap.end();
- }
-
- const SMDS_MeshElement* next()
- {
- const SMDS_MeshElement* current=(*myIterator).second;
- myIterator++;
- return current;
- }
-};
-
SMDS_ElemIteratorPtr SMDS_Mesh::elementsIterator() const
{
- return SMDS_ElemIteratorPtr
- (new SMDS_Mesh_MyElemIterator(myElementIDFactory->GetIdElementMap()));
+ return myElementIDFactory->elementsIterator();
}
///////////////////////////////////////////////////////////////////////////////
-///Return an iterator on volumes of the current mesh.
+///Return an iterator on edges of the current mesh.
///////////////////////////////////////////////////////////////////////////////
class SMDS_Mesh_MyEdgeIterator:public SMDS_EdgeIterator
{
typedef SMDS_Mesh::SetOfEdges SetOfEdges;
- const SetOfEdges& mySet;
- const SMDS_MeshEdge * myEdge;
- SetOfEdges::iterator myIterator;
+ SetOfEdges::Iterator myIterator;
public:
- SMDS_Mesh_MyEdgeIterator(const SetOfEdges& s):mySet(s)
- {
- myIterator=mySet.begin();
- }
+ SMDS_Mesh_MyEdgeIterator(const SetOfEdges& s):myIterator(s)
+ {}
bool more()
{
- while((myIterator!=mySet.end()))
+ while(myIterator.More())
{
- if((*myIterator)->GetID()!=-1)
+ if(myIterator.Value()->GetID()!=-1)
return true;
- myIterator++;
+ myIterator.Next();
}
return false;
}
const SMDS_MeshEdge* next()
{
- const SMDS_MeshEdge* current=*myIterator;
- myIterator++;
- return current;
- }
+ const SMDS_MeshEdge* current = myIterator.Value();
+ myIterator.Next();
+ return current;
+ }
};
SMDS_EdgeIteratorPtr SMDS_Mesh::edgesIterator() const
}
///////////////////////////////////////////////////////////////////////////////
-///Return an iterator on faces of the current mesh. Once used this iterator
-///must be free by the caller
+///Return an iterator on faces of the current mesh.
///////////////////////////////////////////////////////////////////////////////
class SMDS_Mesh_MyFaceIterator:public SMDS_FaceIterator
{
typedef SMDS_Mesh::SetOfFaces SetOfFaces;
- const SetOfFaces& mySet;
- SetOfFaces::iterator myIterator;
+ SetOfFaces::Iterator myIterator;
public:
- SMDS_Mesh_MyFaceIterator(const SetOfFaces& s):mySet(s)
- {
- myIterator=mySet.begin();
- }
+ SMDS_Mesh_MyFaceIterator(const SetOfFaces& s):myIterator(s)
+ {}
bool more()
{
- while((myIterator!=mySet.end()))
+ while(myIterator.More())
{
- if((*myIterator)->GetID()!=-1)
+ if(myIterator.Value()->GetID()!=-1)
return true;
- myIterator++;
+ myIterator.Next();
}
return false;
}
const SMDS_MeshFace* next()
{
- const SMDS_MeshFace* current=*myIterator;
- myIterator++;
- return current;
- }
+ const SMDS_MeshFace* current = myIterator.Value();
+ myIterator.Next();
+ return current;
+ }
};
SMDS_FaceIteratorPtr SMDS_Mesh::facesIterator() const
}
///////////////////////////////////////////////////////////////////////////////
-///Return an iterator on volumes of the current mesh. Once used this iterator
-///must be free by the caller
+///Return an iterator on volumes of the current mesh.
///////////////////////////////////////////////////////////////////////////////
class SMDS_Mesh_MyVolumeIterator:public SMDS_VolumeIterator
{
typedef SMDS_Mesh::SetOfVolumes SetOfVolumes;
- const SetOfVolumes& mySet;
- SetOfVolumes::iterator myIterator;
+ SetOfVolumes::Iterator myIterator;
public:
- SMDS_Mesh_MyVolumeIterator(const SetOfVolumes& s):mySet(s)
- {
- myIterator=mySet.begin();
- }
+ SMDS_Mesh_MyVolumeIterator(const SetOfVolumes& s):myIterator(s)
+ {}
bool more()
{
- return myIterator!=mySet.end();
+ return myIterator.More() != Standard_False;
}
const SMDS_MeshVolume* next()
{
- const SMDS_MeshVolume* current=*myIterator;
- myIterator++;
- return current;
- }
+ const SMDS_MeshVolume* current = myIterator.Value();
+ myIterator.Next();
+ return current;
+ }
};
SMDS_VolumeIteratorPtr SMDS_Mesh::volumesIterator() const
static set<const SMDS_MeshElement*> * getFinitElements(const SMDS_MeshElement * element)
{
int numberOfSets=element->NbNodes();
- set<const SMDS_MeshElement*> initSet[numberOfSets];
+ auto_ptr<set<const SMDS_MeshElement*> > pInitSet
+ (new set<const SMDS_MeshElement*>[numberOfSets]);
+ set<const SMDS_MeshElement*> *initSet = &(*pInitSet);
SMDS_ElemIteratorPtr itNodes=element->nodesIterator();
MESSAGE("Internal Error: This should not happen");
break;
case SMDSAbs_Edge:
- myEdges.erase(static_cast<SMDS_MeshEdge*>
+ myEdges.Remove(static_cast<SMDS_MeshEdge*>
(const_cast<SMDS_MeshElement*>(*it)));
break;
case SMDSAbs_Face:
- myFaces.erase(static_cast<SMDS_MeshFace*>
+ myFaces.Remove(static_cast<SMDS_MeshFace*>
(const_cast<SMDS_MeshElement*>(*it)));
break;
case SMDSAbs_Volume:
- myVolumes.erase(static_cast<SMDS_MeshVolume*>
+ myVolumes.Remove(static_cast<SMDS_MeshVolume*>
(const_cast<SMDS_MeshElement*>(*it)));
break;
}
while(it!=s2->end())
{
//MESSAGE( "SMDS: RM node " << (*it)->GetID() );
- myNodes.erase(static_cast<SMDS_MeshNode*>
+ myNodes.Remove(static_cast<SMDS_MeshNode*>
(const_cast<SMDS_MeshElement*>(*it)));
myNodeIDFactory->ReleaseID((*it)->GetID());
removedNodes.push_back( (*it) );
SMDS_MeshElementIDFactory * idFactory =
isNodes ? myNodeIDFactory : myElementIDFactory;
- // get existing elements in the order of ID increasing and release their ids
- list< SMDS_MeshElement * > elemList;
- const SMDS_IdElementMap& idElemMap = idFactory->GetIdElementMap();
- SMDS_IdElementMap::const_iterator idElemIt = idElemMap.begin();
- while ( idElemIt != idElemMap.end() ) {
- SMDS_MeshElement* elem = (*idElemIt).second;
- int id = (*idElemIt).first;
- idElemIt++;
- elemList.push_back( elem );
+ // get existing elements in the order of ID increasing
+ map<int,SMDS_MeshElement*> elemMap;
+ SMDS_ElemIteratorPtr idElemIt = idFactory->elementsIterator();
+ while ( idElemIt->more() ) {
+ SMDS_MeshElement* elem = const_cast<SMDS_MeshElement*>(idElemIt->next());
+ int id = elem->GetID();
+ elemMap.insert(map<int,SMDS_MeshElement*>::value_type(id, elem));
+ }
+ // release their ids
+ map<int,SMDS_MeshElement*>::iterator elemIt = elemMap.begin();
+ for ( ; elemIt != elemMap.end(); elemIt++ )
+ {
+ int id = (*elemIt).first;
idFactory->ReleaseID( id );
}
// set new IDs
int ID = startID;
- list< SMDS_MeshElement * >::iterator elemIt = elemList.begin();
- for ( ; elemIt != elemList.end(); elemIt++ )
+ elemIt = elemMap.begin();
+ for ( ; elemIt != elemMap.end(); elemIt++ )
{
- idFactory->BindID( ID, *elemIt );
+ idFactory->BindID( ID, (*elemIt).second );
ID += deltaID;
}
}
#include "SMDS_MeshFace.hxx"
#include "SMDS_MeshVolume.hxx"
#include "SMDS_MeshElementIDFactory.hxx"
-#include "SMDS_Iterator.hxx"
+#include "SMDS_ElemIterator.hxx"
+#include <NCollection_Map.hxx>
#include <boost/shared_ptr.hpp>
#include <set>
*/
bool Contains (const SMDS_MeshElement* elem) const;
- typedef std::set<SMDS_MeshNode *> SetOfNodes;
- typedef std::set<SMDS_MeshEdge *> SetOfEdges;
- typedef std::set<SMDS_MeshFace *> SetOfFaces;
- typedef std::set<SMDS_MeshVolume *> SetOfVolumes;
+ typedef NCollection_Map<SMDS_MeshNode *> SetOfNodes;
+ typedef NCollection_Map<SMDS_MeshEdge *> SetOfEdges;
+ typedef NCollection_Map<SMDS_MeshFace *> SetOfFaces;
+ typedef NCollection_Map<SMDS_MeshVolume *> SetOfVolumes;
private:
SMDS_Mesh(SMDS_Mesh * parent);
// Author : Jean-Michel BOULCOURT
// Module : SMESH
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
#include "SMDS_MeshEdge.hxx"
#include "SMDS_IteratorOfElements.hxx"
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
+
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_MeshEdge.hxx"
#include "SMDSAbs_ElementType.hxx"
#include "SMDS_MeshObject.hxx"
-#include "SMDS_Iterator.hxx"
+#include "SMDS_ElemIterator.hxx"
#include "SMDS_MeshElementIDFactory.hxx"
-#include <boost/shared_ptr.hpp>
#include <vector>
#include <iostream>
class SMDS_MeshNode;
class SMDS_MeshEdge;
class SMDS_MeshFace;
-class SMDS_MeshElement;
-
-typedef SMDS_Iterator<const SMDS_MeshElement *> SMDS_ElemIterator;
-typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshElement *> > SMDS_ElemIteratorPtr;
///////////////////////////////////////////////////////////////////////////////
/// Base class for elements
// Author : Jean-Michel BOULCOURT
// Module : SMESH
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
#include "SMDS_MeshElementIDFactory.hxx"
#include "SMDS_MeshElement.hxx"
//function : SMDS_MeshElementIDFactory
//purpose :
//=======================================================================
-SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():SMDS_MeshIDFactory()
+SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
+ SMDS_MeshIDFactory(),
+ myMin(0), myMax(0)
{
}
//=======================================================================
bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
{
- bool bound=myIDElements.insert(
- map<int, SMDS_MeshElement*>::value_type(ID,elem)).second;
- if(bound) elem->myID=ID;
- return bound;
+ if (myIDElements.IsBound(ID))
+ return false;
+ myIDElements.Bind(ID,elem);
+ elem->myID=ID;
+ updateMinMax (ID);
+ return true;
}
//=======================================================================
//=======================================================================
SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
{
- map<int, SMDS_MeshElement*>::iterator it=myIDElements.find(ID);
- if(it==myIDElements.end()) return NULL; else return (*it).second;
+ if (!myIDElements.IsBound(ID))
+ return NULL;
+ return myIDElements.Find(ID);
}
int ID;
do {
ID = SMDS_MeshIDFactory::GetFreeID();
- } while (myIDElements.find(ID) != myIDElements.end());
+ } while (myIDElements.IsBound(ID));
return ID;
}
//=======================================================================
void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
{
- myIDElements.erase(ID);
+ myIDElements.UnBind(ID);
SMDS_MeshIDFactory::ReleaseID(ID);
+ if (ID == myMax)
+ myMax = 0;
+ if (ID == myMin)
+ myMin = 0;
}
//=======================================================================
int SMDS_MeshElementIDFactory::GetMaxID() const
{
- map<int, SMDS_MeshElement*>::const_reverse_iterator it = myIDElements.rbegin();
- if ( it != myIDElements.rend() )
- return (*it).first;
-
- return 0;
+ if (myMax == 0)
+ updateMinMax();
+ return myMax;
}
//=======================================================================
int SMDS_MeshElementIDFactory::GetMinID() const
{
- map<int, SMDS_MeshElement*>::const_iterator it = myIDElements.begin();
- if ( it != myIDElements.end() )
- return (*it).first;
+ if (myMin == 0)
+ updateMinMax();
+ return myMin;
+}
- return 0;
+//=======================================================================
+//function : updateMinMax
+//purpose :
+//=======================================================================
+
+void SMDS_MeshElementIDFactory::updateMinMax() const
+{
+ myMin = IntegerLast();
+ myMax = 0;
+ SMDS_IdElementMap::Iterator it(myIDElements);
+ for (; it.More(); it.Next())
+ updateMinMax (it.Key());
+ if (myMin == IntegerLast())
+ myMin = 0;
}
+//=======================================================================
+//function : elementsIterator
+//purpose : Return an iterator on elements of the factory
+//=======================================================================
+
+class SMDS_Fact_MyElemIterator:public SMDS_ElemIterator
+{
+ SMDS_IdElementMap::Iterator myIterator;
+ public:
+ SMDS_Fact_MyElemIterator(const SMDS_IdElementMap& s):myIterator(s)
+ {}
+
+ bool more()
+ {
+ return myIterator.More() != Standard_False;
+ }
+
+ const SMDS_MeshElement* next()
+ {
+ const SMDS_MeshElement* current = myIterator.Value();
+ myIterator.Next();
+ return current;
+ }
+};
+
+SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const
+{
+ return SMDS_ElemIteratorPtr
+ (new SMDS_Fact_MyElemIterator(myIDElements));
+}
#define _SMDS_MeshElementIDFactory_HeaderFile
#include "SMDS_MeshIDFactory.hxx"
+#include "SMDS_ElemIterator.hxx"
-#include <map>
+#include <NCollection_DataMap.hxx>
class SMDS_MeshElement;
-typedef std::map<int, SMDS_MeshElement *> SMDS_IdElementMap;
+typedef NCollection_DataMap<int, SMDS_MeshElement *> SMDS_IdElementMap;
class SMDS_MeshElementIDFactory:public SMDS_MeshIDFactory
{
- public:
- SMDS_MeshElementIDFactory();
- bool BindID(int ID, SMDS_MeshElement * elem);
- SMDS_MeshElement * MeshElement(int ID);
- virtual int GetFreeID();
- virtual void ReleaseID(int ID);
- int GetMaxID() const;
- int GetMinID() const;
- const SMDS_IdElementMap & GetIdElementMap() const { return myIDElements; }
- private:
- SMDS_IdElementMap myIDElements;
+public:
+ SMDS_MeshElementIDFactory();
+ bool BindID(int ID, SMDS_MeshElement * elem);
+ SMDS_MeshElement * MeshElement(int ID);
+ virtual int GetFreeID();
+ virtual void ReleaseID(int ID);
+ int GetMaxID() const;
+ int GetMinID() const;
+ SMDS_ElemIteratorPtr elementsIterator() const;
+private:
+ void updateMinMax() const;
+ void updateMinMax(int id) const
+ {
+ if (id > myMax) myMax = id;
+ if (id < myMin) myMin = id;
+ }
+
+ SMDS_IdElementMap myIDElements;
+ mutable int myMin, myMax;
};
// Author : Jean-Michel BOULCOURT
// Module : SMESH
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
+
#include "SMDS_MeshGroup.hxx"
#include "utilities.h"
SMDS_MeshGroup(SMDS_MeshGroup* theParent,
const SMDSAbs_ElementType theType = SMDSAbs_All);
- typedef std::set<const SMDS_MeshElement *>::iterator TIterator;
+ typedef std::set<const SMDS_MeshElement *>::const_iterator TIterator;
const SMDS_Mesh * myMesh;
SMDSAbs_ElementType myType;
std::set<const SMDS_MeshElement *> myElements;
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
#include "SMDS_MeshNode.hxx"
#include "SMDS_SpacePosition.hxx"
void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * parent)
{
- myInverseElements.erase(parent);
+ NCollection_List<const SMDS_MeshElement*>::Iterator it(myInverseElements);
+ while (it.More()) {
+ const SMDS_MeshElement* elem = it.Value();
+ if (elem == parent)
+ myInverseElements.Remove(it);
+ else
+ it.Next();
+ }
}
//=======================================================================
class SMDS_MeshNode_MyInvIterator:public SMDS_ElemIterator
{
- const set<const SMDS_MeshElement*>& mySet;
- set<const SMDS_MeshElement*>::iterator myIterator;
+ NCollection_List<const SMDS_MeshElement*>::Iterator myIterator;
public:
- SMDS_MeshNode_MyInvIterator(const set<const SMDS_MeshElement*>& s):
- mySet(s)
- {
- myIterator=mySet.begin();
- }
+ SMDS_MeshNode_MyInvIterator(const NCollection_List<const SMDS_MeshElement*>& s):
+ myIterator(s)
+ {}
bool more()
{
- return myIterator!=mySet.end();
+ return myIterator.More() != Standard_False;
}
const SMDS_MeshElement* next()
{
- const SMDS_MeshElement* current=*myIterator;
- myIterator++;
- return current;
+ const SMDS_MeshElement* current=myIterator.Value();
+ myIterator.Next();
+ return current;
}
};
// wanted type elements.
class SMDS_MeshNode_MyIterator:public SMDS_ElemIterator
{
- set<const SMDS_MeshElement*> mySet;
- set<const SMDS_MeshElement*>::iterator myIterator;
+ NCollection_List<const SMDS_MeshElement*> mySet;
+ NCollection_List<const SMDS_MeshElement*>::Iterator myIterator;
public:
SMDS_MeshNode_MyIterator(SMDSAbs_ElementType type,
- const set<const SMDS_MeshElement*>& s)
+ const NCollection_List<const SMDS_MeshElement*>& s)
{
const SMDS_MeshElement * e;
bool toInsert;
- set<const SMDS_MeshElement*>::iterator it=s.begin();
- while(it!=s.end())
+ NCollection_List<const SMDS_MeshElement*>::Iterator it(s);
+ for(; it.More(); it.Next())
{
- e=*it;
+ e=it.Value();
switch(type)
{
case SMDSAbs_Edge: toInsert=true; break;
case SMDSAbs_Face: toInsert=(e->GetType()!=SMDSAbs_Edge); break;
case SMDSAbs_Volume: toInsert=(e->GetType()==SMDSAbs_Volume); break;
}
- if(toInsert) mySet.insert(e);
- it++;
+ if(toInsert) mySet.Append(e);
}
- myIterator=mySet.begin();
+ myIterator.Init(mySet);
}
bool more()
{
- return myIterator!=mySet.end();
+ return myIterator.More() != Standard_False;
}
const SMDS_MeshElement* next()
{
- const SMDS_MeshElement* current=*myIterator;
- myIterator++;
+ const SMDS_MeshElement* current=myIterator.Value();
+ myIterator.Next();
return current;
}
};
//=======================================================================
void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
{
- myInverseElements.insert(ME);
+ NCollection_List<const SMDS_MeshElement*>::Iterator it(myInverseElements);
+ for (; it.More(); it.Next()) {
+ const SMDS_MeshElement* elem = it.Value();
+ if (elem == ME)
+ return;
+ }
+ myInverseElements.Append(ME);
}
//=======================================================================
//=======================================================================
void SMDS_MeshNode::ClearInverseElements()
{
- myInverseElements.clear();
+ myInverseElements.Clear();
}
bool SMDS_MeshNode::emptyInverseElements()
{
- return myInverseElements.empty();
+ return myInverseElements.IsEmpty() != Standard_False;
}
///////////////////////////////////////////////////////////////////////////////
#include "SMDS_MeshElement.hxx"
#include "SMDS_Position.hxx"
-
-#include <set>
-
+#include <NCollection_List.hxx>
class SMDS_MeshNode:public SMDS_MeshElement
{
private:
double myX, myY, myZ;
SMDS_PositionPtr myPosition;
- std::set<const SMDS_MeshElement*> myInverseElements;
+ NCollection_List<const SMDS_MeshElement*> myInverseElements;
};
#endif
const double *SMDS_VertexPosition::Coords() const
{
const static double origin[]={0,0,0};
- MESSAGE("SMDS_EdgePosition::Coords not implemented");
+ MESSAGE("SMDS_VertexPosition::Coords not implemented");
return origin;
}
// Author : Jean-Michel BOULCOURT
// Module : SMESH
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
+
#include "SMDS_VolumeOfFaces.hxx"
#include "SMDS_IteratorOfElements.hxx"
{
OS << "volume <" << GetID() << "> : ";
int i;
- for (i = 0; i < myFaces.size()-1; ++i) OS << myFaces[i] << ",";
+ for (i = 0; i < NbFaces()-1; ++i) OS << myFaces[i] << ",";
OS << myFaces[i]<< ") " << endl;
}
int SMDS_VolumeOfFaces::NbFaces() const
{
- return myFaces.size();
+ return myNbFaces;
}
class SMDS_VolumeOfFaces_MyIterator:public SMDS_ElemIterator
{
- const vector<const SMDS_MeshFace*>& mySet;
+ const SMDS_MeshFace* const *mySet;
+ int myLength;
int index;
public:
- SMDS_VolumeOfFaces_MyIterator(const vector<const SMDS_MeshFace*>& s):
- mySet(s),index(0) {}
+ SMDS_VolumeOfFaces_MyIterator(const SMDS_MeshFace* const *s, int l):
+ mySet(s),myLength(l),index(0) {}
bool more()
{
- return index<mySet.size();
+ return index<myLength;
}
const SMDS_MeshElement* next()
case SMDSAbs_Volume:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
case SMDSAbs_Face:
- return SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces));
+ return SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces));
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
- (this,type,SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces))));
+ (this,type,SMDS_ElemIteratorPtr
+ (new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces))));
}
}
const SMDS_MeshFace * face3,
const SMDS_MeshFace * face4)
{
- myFaces.resize(4);
+ myNbFaces = 4;
myFaces[0]=face1;
myFaces[1]=face2;
myFaces[2]=face3;
myFaces[3]=face4;
+ myFaces[4]=0;
+ myFaces[5]=0;
}
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
const SMDS_MeshFace * face4,
const SMDS_MeshFace * face5)
{
- myFaces.resize(5);
+ myNbFaces = 5;
myFaces[0]=face1;
myFaces[1]=face2;
myFaces[2]=face3;
myFaces[3]=face4;
myFaces[4]=face5;
+ myFaces[5]=0;
}
SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
const SMDS_MeshFace * face5,
const SMDS_MeshFace * face6)
{
- myFaces.resize(6);
+ myNbFaces = 6;
myFaces[0]=face1;
myFaces[1]=face2;
myFaces[2]=face3;
#include "SMDS_MeshVolume.hxx"
#include "SMDS_MeshFace.hxx"
#include "SMDS_Iterator.hxx"
-#include <vector>
#include <iostream>
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
- std::vector<const SMDS_MeshFace *> myFaces;
+ const SMDS_MeshFace * myFaces[6];
+ int myNbFaces;
};
#endif
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
+
#include "SMDS_VolumeOfNodes.hxx"
#include "SMDS_MeshNode.hxx"
#include "utilities.h"
const SMDS_MeshNode * node7,
const SMDS_MeshNode * node8)
{
- myNodes.resize(8);
+ myNbNodes = 8;
+ myNodes = new const SMDS_MeshNode* [myNbNodes];
myNodes[0]=node1;
myNodes[1]=node2;
myNodes[2]=node3;
const SMDS_MeshNode * node3,
const SMDS_MeshNode * node4)
{
- myNodes.resize(4);
+ myNbNodes = 4;
+ myNodes = new const SMDS_MeshNode* [myNbNodes];
myNodes[0]=node1;
myNodes[1]=node2;
myNodes[2]=node3;
const SMDS_MeshNode * node4,
const SMDS_MeshNode * node5)
{
- myNodes.resize(5);
+ myNbNodes = 5;
+ myNodes = new const SMDS_MeshNode* [myNbNodes];
myNodes[0]=node1;
myNodes[1]=node2;
myNodes[2]=node3;
const SMDS_MeshNode * node5,
const SMDS_MeshNode * node6)
{
- myNodes.resize(6);
+ myNbNodes = 6;
+ myNodes = new const SMDS_MeshNode* [myNbNodes];
myNodes[0]=node1;
myNodes[1]=node2;
myNodes[2]=node3;
myNodes[4]=node5;
myNodes[5]=node6;
}
+
bool SMDS_VolumeOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes)
{
if (nbNodes < 4 || nbNodes > 8 || nbNodes == 7)
return false;
- myNodes.resize( nbNodes );
+ delete [] myNodes;
+ myNbNodes = nbNodes;
+ myNodes = new const SMDS_MeshNode* [myNbNodes];
for ( int i = 0; i < nbNodes; i++ )
myNodes[ i ] = nodes [ i ];
return true;
}
+
+SMDS_VolumeOfNodes::~SMDS_VolumeOfNodes()
+{
+ if (myNodes != NULL) {
+ delete [] myNodes;
+ myNodes = NULL;
+ }
+}
+
//=======================================================================
//function : Print
//purpose :
int SMDS_VolumeOfNodes::NbNodes() const
{
- return myNodes.size();
+ return myNbNodes;
}
int SMDS_VolumeOfNodes::NbEdges() const
class SMDS_VolumeOfNodes_MyIterator:public SMDS_ElemIterator
{
- const vector<const SMDS_MeshNode*>& mySet;
+ const SMDS_MeshNode* const* mySet;
+ int myLength;
int index;
public:
- SMDS_VolumeOfNodes_MyIterator(const vector<const SMDS_MeshNode*>& s):
- mySet(s),index(0) {}
+ SMDS_VolumeOfNodes_MyIterator(const SMDS_MeshNode* const* s, int l):
+ mySet(s),myLength(l),index(0) {}
bool more()
{
- return index<mySet.size();
+ return index<myLength;
}
const SMDS_MeshElement* next()
case SMDSAbs_Volume:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
case SMDSAbs_Node:
- return SMDS_ElemIteratorPtr(new SMDS_VolumeOfNodes_MyIterator(myNodes));
+ return SMDS_ElemIteratorPtr(new SMDS_VolumeOfNodes_MyIterator(myNodes,myNbNodes));
default:
MESSAGE("ERROR : Iterator not implemented");
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
#define _SMDS_VolumeOfNodes_HeaderFile
#include "SMDS_MeshVolume.hxx"
-#include <vector>
class SMDS_VolumeOfNodes:public SMDS_MeshVolume
const SMDS_MeshNode * node8);
bool ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes);
+ ~SMDS_VolumeOfNodes();
void Print(std::ostream & OS) const;
int NbFaces() const;
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
- std::vector<const SMDS_MeshNode *> myNodes;
+ const SMDS_MeshNode** myNodes;
+ int myNbNodes;
};
#endif
// Author : Edward AGAPOV (eap)
// Copyright : Open CASCADE
+#ifdef _MSC_VER
+#pragma warning(disable:4786)
+#endif
#include "SMDS_VolumeTool.hxx"
#include "SMDS_MeshNode.hxx"
#include <map>
#include <float.h>
+#include <math.h>
using namespace std;
+// ======================================================
+// Node indices in faces depending on volume orientation
+// making most faces normals external
+// ======================================================
+
/*
// N3
// +
// /|\
// / | \
// / | \
-// N0 +---|---+ N2 TETRAHEDRON
+// N0 +---|---+ N1 TETRAHEDRON
// \ | /
// \ | /
// \ | /
// \|/
// +
-// N1
+// N2
*/
-static int Tetra_F [4][4] = { // FORWARD == REVERSED EXTERNAL
- { 0, 1, 2, 0 }, // Bottom face has an internal normal, other - external
+static int Tetra_F [4][4] = { // FORWARD == EXTERNAL
+ { 0, 1, 2, 0 }, // All faces have external normals
+ { 0, 3, 1, 0 },
+ { 1, 3, 2, 1 },
+ { 0, 2, 3, 0 }};
+static int Tetra_R [4][4] = { // REVERSED
+ { 0, 1, 2, 0 }, // All faces but a bottom have external normals
{ 0, 1, 3, 0 },
{ 1, 2, 3, 1 },
- { 0, 3, 2, 0 }};
-static int Tetra_R [4][4] = { // REVERSED == FORWARD EXTERNAL
- { 0, 2, 1, 0 }, // All faces have external normals
+ { 0, 3, 2, 0 }};
+static int Tetra_RE [4][4] = { // REVERSED -> FORWARD (EXTERNAL)
+ { 0, 2, 1, 0 }, // All faces have external normals
{ 0, 1, 3, 0 },
{ 1, 2, 3, 1 },
- { 0, 3, 2, 0 }};
+ { 0, 3, 2, 0 }};
static int Tetra_nbN [] = { 3, 3, 3, 3 };
+//
+// PYRAMID
+//
+static int Pyramid_F [5][5] = { // FORWARD == EXTERNAL
+ { 0, 1, 2, 3, 0 }, // All faces have external normals
+ { 0, 4, 1, 0, 4 },
+ { 1, 4, 2, 1, 4 },
+ { 2, 4, 3, 2, 4 },
+ { 3, 4, 0, 3, 4 }};
+static int Pyramid_R [5][5] = { // REVERSED
+ { 0, 1, 2, 3, 0 }, // All faces but a bottom have external normals
+ { 0, 1, 4, 0, 4 },
+ { 1, 2, 4, 1, 4 },
+ { 2, 3, 4, 2, 4 },
+ { 3, 0, 4, 3, 4 }};
+static int Pyramid_RE [5][5] = { // REVERSED -> FORWARD (EXTERNAL)
+ { 0, 3, 2, 1, 0 }, // All faces but a bottom have external normals
+ { 0, 1, 4, 0, 4 },
+ { 1, 2, 4, 1, 4 },
+ { 2, 3, 4, 2, 4 },
+ { 3, 0, 4, 3, 4 }};
+static int Pyramid_nbN [] = { 4, 3, 3, 3, 3 };
+
/*
// + N4
// /|\
{ 0, 1, 2, 0, 0 }, // Top face has an internal normal, other - external
{ 3, 4, 5, 3, 3 }, // 0 is bottom, 1 is top face
{ 0, 2, 5, 3, 0 },
- { 1, 2, 5, 4, 1 },
- { 1, 0, 3, 4, 1 }};
+ { 1, 4, 5, 2, 1 },
+ { 0, 3, 4, 1, 0 }};
static int Penta_R [5][5] = { // REVERSED
- { 0, 2, 1, 0, 0 }, // Bottom face has an internal normal, other - external
- { 3, 5, 4, 3, 3 }, // 0 is bottom, 1 is top face
- { 0, 2, 5, 3, 0 },
+ { 0, 1, 2, 0, 0 }, // Bottom face has an internal normal, other - external
+ { 3, 4, 5, 3, 3 }, // 0 is bottom, 1 is top face
+ { 0, 3, 5, 2, 0 },
{ 1, 2, 5, 4, 1 },
- { 1, 0, 3, 4, 1 }};
-static int Penta_FE [5][5] = { // EXTERNAL
+ { 0, 1, 4, 3, 0 }};
+static int Penta_FE [5][5] = { // FORWARD -> EXTERNAL
{ 0, 1, 2, 0, 0 },
{ 3, 5, 4, 3, 3 },
{ 0, 2, 5, 3, 0 },
+ { 1, 4, 5, 2, 1 },
+ { 0, 3, 4, 1, 0 }};
+static int Penta_RE [5][5] = { // REVERSED -> EXTERNAL
+ { 0, 2, 1, 0, 0 },
+ { 3, 4, 5, 3, 3 },
+ { 0, 3, 5, 2, 0 },
{ 1, 2, 5, 4, 1 },
- { 1, 0, 3, 4, 1 }};
-static int Penta_RE [5][5] = { // REVERSED EXTERNAL
- { 0, 0, 2, 1, 0 },
- { 3, 3, 4, 5, 3 },
- { 0, 2, 5, 3, 0 },
- { 1, 2, 5, 4, 1 },
- { 1, 0, 3, 4, 1 }};
+ { 0, 1, 4, 3, 0 }};
static int Penta_nbN [] = { 3, 3, 4, 4, 4 };
/*
-// N7+----------+N6
+// N5+----------+N6
// /| /|
// / | / |
// / | / |
-// N4+----------+N5 |
+// N4+----------+N7 |
// | | | | HEXAHEDRON
// | | | |
// | | | |
-// | N3+------|---+N2
+// | N1+------|---+N2
// | / | /
// | / | /
// |/ |/
-// N0+----------+N1
+// N0+----------+N3
*/
static int Hexa_F [6][5] = { // FORWARD
{ 0, 1, 2, 3, 0 }, // opposite faces are neighbouring,
- { 4, 5, 6, 7, 4 }, // even face normal is internal, odd - external
- { 1, 0, 4, 5, 1 }, // same index nodes nodes of opposite faces are linked
+ { 4, 5, 6, 7, 4 }, // odd face(1,3,5) normal is internal, even(0,2,4) - external
+ { 1, 0, 4, 5, 1 }, // same index nodes of opposite faces are linked
{ 2, 3, 7, 6, 2 },
{ 0, 3, 7, 4, 0 },
- { 1, 2, 6, 5, 1 }};
-static int Hexa_R [6][5] = { // REVERSED
- { 0, 3, 2, 1, 0 }, // opposite faces are neighbouring,
- { 4, 7, 6, 5, 4 }, // even face normal is external, odd - internal
- { 1, 5, 4, 0, 1 }, // same index nodes nodes of opposite faces are linked
- { 2, 6, 7, 3, 2 },
- { 0, 4, 7, 3, 0 },
- { 1, 5, 6, 2, 1 }};
-static int Hexa_FE [6][5] = { // EXTERNAL
- { 0, 3, 2, 1, 0 }, // opposite faces are neighbouring,
- { 4, 5, 6, 7, 4 }, // all face normals are external,
- { 0, 1, 5, 4, 0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1
- { 3, 7, 6, 2, 3 },
- { 1, 2, 6, 5, 1 },
- { 0, 4, 7, 3, 0 }};
-static int Hexa_RE [6][5] = { // REVERSED EXTERNAL
- { 0, 1, 2, 3, 0 }, // opposite faces are neighbouring,
- { 4, 7, 6, 5, 4 }, // all face normals are external,
- { 0, 1, 5, 4, 0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1
+ { 1, 2, 6, 5, 1 }};
+// static int Hexa_R [6][5] = { // REVERSED
+// { 0, 3, 2, 1, 0 }, // opposite faces are neighbouring,
+// { 4, 7, 6, 5, 4 }, // odd face(1,3,5) normal is external, even(0,2,4) - internal
+// { 1, 5, 4, 0, 1 }, // same index nodes of opposite faces are linked
+// { 2, 6, 7, 3, 2 },
+// { 0, 4, 7, 3, 0 },
+// { 1, 5, 6, 2, 1 }};
+static int Hexa_FE [6][5] = { // FORWARD -> EXTERNAL
+ { 0, 1, 2, 3, 0 } , // opposite faces are neighbouring,
+ { 4, 7, 6, 5, 4 }, // all face normals are external,
+ { 0, 4, 5, 1, 0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1
+ { 3, 2, 6, 7, 3 },
+ { 0, 3, 7, 4, 0 },
+ { 1, 5, 6, 2, 1 }};
+static int Hexa_RE [6][5] = { // REVERSED -> EXTERNAL
+ { 0, 3, 2, 1, 0 }, // opposite faces are neighbouring,
+ { 4, 5, 6, 7, 4 }, // all face normals are external,
+ { 0, 1, 5, 4, 0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1
{ 3, 7, 6, 2, 3 },
- { 1, 2, 6, 5, 1 },
- { 0, 4, 7, 3, 0 }};
+ { 0, 4, 7, 3, 0 },
+ { 1, 2, 6, 5, 1 }};
static int Hexa_nbN [] = { 4, 4, 4, 4, 4, 4 };
// ========================================================
myVolForward( true ),
myNbFaces( 0 ),
myVolumeNbNodes( 0 ),
- myForwardFaces( false ),
myExternalFaces( false )
{
}
//=======================================================================
SMDS_VolumeTool::SMDS_VolumeTool (const SMDS_MeshElement* theVolume)
- : myForwardFaces( false ),
- myExternalFaces( false )
+ : myExternalFaces( false )
{
Set( theVolume );
}
myVolumeNbNodes = theVolume->NbNodes();
switch ( myVolumeNbNodes ) {
case 4:
+ case 5:
case 6:
case 8:
{
// nb nodes in each face
if ( myVolumeNbNodes == 4 )
myFaceNbNodes = Tetra_nbN;
+ else if ( myVolumeNbNodes == 5 )
+ myFaceNbNodes = Pyramid_nbN;
else if ( myVolumeNbNodes == 6 )
myFaceNbNodes = Penta_nbN;
else
myFaceNbNodes = Hexa_nbN;
- break;
+
// define volume orientation
XYZ botNormal;
GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z );
XYZ upDir (topNode->X() - botNode->X(),
topNode->Y() - botNode->Y(),
topNode->Z() - botNode->Z() );
- bool diffDir = ( botNormal.Dot( upDir ) < 0 );
- myVolForward = ( myVolumeNbNodes == 6 ? diffDir : !diffDir );
-
+ myVolForward = ( botNormal.Dot( upDir ) < 0 );
+ break;
}
default: myVolume = 0;
}
//purpose : Return nodes vector of an inverse volume
//=======================================================================
-#define SWAP_NODES(nodes,i1,i2) \
-{ \
+#define SWAP_NODES(nodes,i1,i2) \
+{ \
const SMDS_MeshNode* tmp = nodes[ i1 ]; \
- nodes[ i1 ] = nodes[ i2 ]; \
+ nodes[ i1 ] = nodes[ i2 ]; \
nodes[ i2 ] = tmp; \
}
void SMDS_VolumeTool::Inverse ()
case 4:
SWAP_NODES( myVolumeNodes, 1, 2 );
break;
+ case 5:
+ SWAP_NODES( myVolumeNodes, 1, 3 );
+ break;
case 6:
SWAP_NODES( myVolumeNodes, 1, 2 );
SWAP_NODES( myVolumeNodes, 4, 5 );
return true;
}
-//=======================================================================
-//function : SetForwardOrientation
-//purpose : Node order will be as for forward orientation
-//=======================================================================
-
-void SMDS_VolumeTool::SetForwardOrientation ()
-{
- myForwardFaces = true;
-}
-
//=======================================================================
//function : SetExternalNormal
//purpose : Node order will be so that faces normals are external
void SMDS_VolumeTool::SetExternalNormal ()
{
myExternalFaces = true;
+ myCurFace = -1;
}
//=======================================================================
//purpose : Return a set of face nodes.
//=======================================================================
-bool SMDS_VolumeTool::GetFaceNodes (int faceIndex,
- std::set<const SMDS_MeshNode*>& theFaceNodes )
+bool SMDS_VolumeTool::GetFaceNodes (int faceIndex,
+ set<const SMDS_MeshNode*>& theFaceNodes )
{
if ( !setFace( faceIndex ))
return false;
theFaceNodes.clear();
int iNode, nbNode = myFaceNbNodes[ faceIndex ];
- for ( int iNode = 0; iNode < nbNode; iNode++ )
+ for ( iNode = 0; iNode < nbNode; iNode++ )
theFaceNodes.insert( myFaceNodes[ iNode ]);
return true;
if ( myExternalFaces || !myVolume )
return true;
- bool reversed = ( !myForwardFaces && !myVolForward );
switch ( myVolumeNbNodes ) {
case 4:
- // only the bottom of a forward tetrahedron can be internal
- return ( reversed || faceIndex != 0 );
+ case 5:
+ // only the bottom of a reversed tetrahedron can be internal
+ return ( myVolForward || faceIndex != 0 );
case 6:
// in a forward pentahedron, the top is internal, in a reversed one - bottom
- return ( reversed ? faceIndex != 0 : faceIndex != 1 );
+ return ( myVolForward ? faceIndex != 1 : faceIndex != 0 );
case 8: {
- // in a forward hexahedron, odd face normal is external, else vice versa
+ // in a forward hexahedron, even face normal is external, odd - internal
bool odd = faceIndex % 2;
- return ( reversed ? !odd : odd );
+ return ( myVolForward ? !odd : odd );
}
default:;
}
switch ( myVolumeNbNodes ) {
case 4:
return true;
+ case 5:
+ if ( maxInd == 4 )
+ return true;
+ switch ( maxInd - minInd ) {
+ case 1:
+ case 3: return true;
+ default:;
+ }
+ break;
case 6:
switch ( maxInd - minInd ) {
case 1: return minInd != 2;
switch ( myVolumeNbNodes ) {
case 4:
if ( myExternalFaces )
- myFaceNodeIndices = myVolForward ? Tetra_R[ faceIndex ] : Tetra_F[ faceIndex ];
- else if ( myForwardFaces )
+ myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_RE[ faceIndex ];
+ else
myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_R[ faceIndex ];
+ break;
+ case 5:
+ if ( myExternalFaces )
+ myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_RE[ faceIndex ];
else
- myFaceNodeIndices = Tetra_F[ faceIndex ];
+ myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_R[ faceIndex ];
break;
case 6:
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Penta_FE[ faceIndex ] : Penta_RE[ faceIndex ];
- else if ( myForwardFaces )
- myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ];
else
- myFaceNodeIndices = Penta_F[ faceIndex ];
+ myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ];
break;
case 8:
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Hexa_FE[ faceIndex ] : Hexa_RE[ faceIndex ];
- else if ( myForwardFaces )
- myFaceNodeIndices = myVolForward ? Hexa_F[ faceIndex ] : Hexa_R[ faceIndex ];
else
myFaceNodeIndices = Hexa_F[ faceIndex ];
break;
bool IsForward() const { return myVolForward; }
// Check volume orientation. can be changed by Inverse().
- // See node order of forward volumes at file bottom
+ // See node order of forward volumes at the file bottom
void Inverse();
// Change nodes order as if the volume changes its orientation:
// info on faces
// -------------
- void SetForwardOrientation ();
- // Node order in faces will be as for forward orientation
-
void SetExternalNormal ();
// Node order in faces will be so that faces normals are external.
- // It overrides SetForwardOrientation()
int NbFaces() const { return myNbFaces; }
// Return number of faces of the volume. In the following
bool IsFaceExternal( int faceIndex );
// Check normal orientation of a face.
- // SetForwardOrientation() and SetForwardOrientation() are taken
- // into account.
+ // SetExternalNormal() is taken into account.
bool IsFreeFace( int faceIndex );
// Check that all volumes built on the face nodes lays on one side
int myVolumeNbNodes;
const SMDS_MeshNode* myVolumeNodes[ 8 ];
- bool myForwardFaces;
bool myExternalFaces;
int* myFaceNodeIndices;
int* myFaceNbNodes;
// /|\
// / | \
// / | \
-// N0 +---|---+ N2 TETRAHEDRON
+// N0 +---|---+ N1 TETRAHEDRON
// \ | /
// \ | /
// \ | /
// \|/
// +
-// N1
+// N2
// + N4
// /|\
// |/ \|
// N0 +---------+ N2
-// N7+----------+N6
+// N5+----------+N6
// /| /|
// / | / |
// / | / |
-// N4+----------+N5 |
+// N4+----------+N7 |
// | | | | HEXAHEDRON
// | | | |
// | | | |
-// | N3+------|---+N2
+// | N1+------|---+N2
// | / | /
// | / | /
// |/ |/
-// N0+----------+N1
+// N0+----------+N3
//
*/
BIN_SRC =
# additionnal information to compile and link file
-CPPFLAGS+= $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
+CPPFLAGS+= $(OCC_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
-CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
+CXXFLAGS+= $(OCC_CXXFLAGS) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome
LDFLAGS+= -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lNMTTools -lSMESHDS -lMeshDriverDAT -lMeshDriverSTL -lMeshDriverMED -lMeshDriverUNV
#include <gp_Vec.hxx>
#include <math_FunctionSetRoot.hxx>
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_MeshVolume.hxx"
+#include "SMDS_VolumeTool.hxx"
#include "utilities.h"
#include <list>
double SMESH_Block::TEdge::GetU( const gp_XYZ& theParams ) const
{
double u = theParams.Coord( myCoordInd );
+ if ( myC3d.IsNull() ) // if mesh block
+ return u;
return ( 1 - u ) * myFirst + u * myLast;
}
gp_XYZ SMESH_Block::TEdge::Point( const gp_XYZ& theParams ) const
{
- gp_XYZ p = myC3d->Value( GetU( theParams )).XYZ();
+ double u = GetU( theParams );
+
+ if ( myC3d.IsNull() ) // if mesh block
+ return myNodes[0] * ( 1 - u ) + myNodes[1] * u;
+
+ gp_XYZ p = myC3d->Value( u ).XYZ();
if ( myTrsf.Form() != gp_Identity )
myTrsf.Transforms( p );
return p;
}
+//=======================================================================
+//function : SMESH_Block::TFace::GetCoefs
+//purpose : return coefficients for addition of [0-3]-th edge and vertex
+//=======================================================================
+
+void SMESH_Block::TFace::GetCoefs(int iE,
+ const gp_XYZ& theParams,
+ double& Ecoef,
+ double& Vcoef ) const
+{
+ double dU = theParams.Coord( GetUInd() );
+ double dV = theParams.Coord( GetVInd() );
+ switch ( iE ) {
+ case 0:
+ Ecoef = ( 1 - dV ); // u0
+ Vcoef = ( 1 - dU ) * ( 1 - dV ); break; // 00
+ case 1:
+ Ecoef = dV; // u1
+ Vcoef = dU * ( 1 - dV ); break; // 10
+ case 2:
+ Ecoef = ( 1 - dU ); // 0v
+ Vcoef = dU * dV ; break; // 11
+ case 3:
+ Ecoef = dU ; // 1v
+ Vcoef = ( 1 - dU ) * dV ; break; // 01
+ default: ASSERT(0);
+ }
+}
+
//=======================================================================
//function : SMESH_Block::TFace::GetUV
//purpose :
gp_XY SMESH_Block::TFace::GetUV( const gp_XYZ& theParams ) const
{
gp_XY uv(0.,0.);
- double dU = theParams.Coord( GetUInd() );
- double dV = theParams.Coord( GetVInd() );
for ( int iE = 0; iE < 4; iE++ ) // loop on 4 edges
{
double Ecoef = 0, Vcoef = 0;
- switch ( iE ) {
- case 0:
- Ecoef = ( 1 - dV ); // u0
- Vcoef = ( 1 - dU ) * ( 1 - dV ); break; // 00
- case 1:
- Ecoef = dV; // u1
- Vcoef = dU * ( 1 - dV ); break; // 10
- case 2:
- Ecoef = ( 1 - dU ); // 0v
- Vcoef = dU * dV ; break; // 11
- case 3:
- Ecoef = dU ; // 1v
- Vcoef = ( 1 - dU ) * dV ; break; // 01
- default:;
- }
+ GetCoefs( iE, theParams, Ecoef, Vcoef );
// edge addition
double u = theParams.Coord( myCoordInd[ iE ] );
u = ( 1 - u ) * myFirst[ iE ] + u * myLast[ iE ];
gp_XYZ SMESH_Block::TFace::Point( const gp_XYZ& theParams ) const
{
- gp_XY uv = GetUV( theParams );
- gp_XYZ p = myS->Value( uv.X(), uv.Y() ).XYZ();
- if ( myTrsf.Form() != gp_Identity )
- myTrsf.Transforms( p );
+ gp_XYZ p(0.,0.,0.);
+ if ( myS.IsNull() ) // if mesh block
+ {
+ for ( int iE = 0; iE < 4; iE++ ) // loop on 4 edges
+ {
+ double Ecoef = 0, Vcoef = 0;
+ GetCoefs( iE, theParams, Ecoef, Vcoef );
+ // edge addition
+ double u = theParams.Coord( myCoordInd[ iE ] );
+ int i1 = 0, i2 = 1;
+ switch ( iE ) {
+ case 1: i1 = 3; i2 = 2; break;
+ case 2: i1 = 1; i2 = 2; break;
+ case 3: i1 = 0; i2 = 3; break;
+ }
+ p += Ecoef * ( myNodes[ i1 ] * ( 1 - u ) + myNodes[ i2 ] * u );
+ // corner addition
+ p -= Vcoef * myNodes[ iE ];
+ }
+
+ }
+ else // shape block
+ {
+ gp_XY uv = GetUV( theParams );
+ p = myS->Value( uv.X(), uv.Y() ).XYZ();
+ if ( myTrsf.Form() != gp_Identity )
+ myTrsf.Transforms( p );
+ }
return p;
}
return true;
}
- if ( theFxyz(1) < myValues[0] )
+ if ( theFxyz(1) < myValues[0] ) // a better guess
{
// 3 partial derivatives
gp_Vec drv[ 3 ];
return aWireList.size();
}
+//=======================================================================
+//function : LoadMeshBlock
+//purpose : prepare to work with theVolume
+//=======================================================================
+
+#define gpXYZ(n) gp_XYZ(n->X(),n->Y(),n->Z())
+
+bool SMESH_Block::LoadMeshBlock(const SMDS_MeshVolume* theVolume,
+ const int theNode000Index,
+ const int theNode001Index,
+ vector<const SMDS_MeshNode*>& theOrderedNodes)
+{
+ MESSAGE(" ::LoadMeshBlock()");
+
+ myNbIterations = 0;
+ mySumDist = 0;
+ myGridComputed = false;
+
+ SMDS_VolumeTool vTool;
+ if (!vTool.Set( theVolume ) || vTool.NbNodes() != 8 ||
+ !vTool.IsLinked( theNode000Index, theNode001Index )) {
+ MESSAGE(" Bad arguments ");
+ return false;
+ }
+ vTool.SetExternalNormal();
+ // In terms of indices used for access to nodes and faces in SMDS_VolumeTool:
+ int V000, V100, V010, V110, V001, V101, V011, V111; // 8 vertices
+ int Fxy0, Fxy1; // bottom and top faces
+ // vertices of faces
+ vector<int> vFxy0, vFxy1;
+
+ V000 = theNode000Index;
+ V001 = theNode001Index;
+
+ // get faces sharing V000 and V001
+ list<int> fV000, fV001;
+ int i, iF, iE, iN;
+ for ( iF = 0; iF < vTool.NbFaces(); ++iF ) {
+ const int* nid = vTool.GetFaceNodesIndices( iF );
+ for ( iN = 0; iN < 4; ++iN )
+ if ( nid[ iN ] == V000 ) {
+ fV000.push_back( iF );
+ } else if ( nid[ iN ] == V001 ) {
+ fV001.push_back( iF );
+ }
+ }
+
+ // find the bottom (Fxy0), the top (Fxy1) faces
+ list<int>::iterator fIt1, fIt2, Fxy0Pos;
+ for ( fIt1 = fV000.begin(); fIt1 != fV000.end(); fIt1++) {
+ fIt2 = std::find( fV001.begin(), fV001.end(), *fIt1 );
+ if ( fIt2 != fV001.end() ) { // *fIt1 is in the both lists
+ fV001.erase( fIt2 ); // erase Fx0z or F0yz from fV001
+ } else { // *fIt1 is in fV000 only
+ Fxy0Pos = fIt1; // points to Fxy0
+ }
+ }
+ Fxy0 = *Fxy0Pos;
+ Fxy1 = fV001.front();
+ const SMDS_MeshNode** nn = vTool.GetNodes();
+
+ // find bottom veritices, their order is that a face normal is external
+ vFxy0.resize(4);
+ const int* nid = vTool.GetFaceNodesIndices( Fxy0 );
+ for ( i = 0; i < 4; ++i )
+ if ( nid[ i ] == V000 )
+ break;
+ for ( iN = 0; iN < 4; ++iN, ++i ) {
+ if ( i == 4 ) i = 0;
+ vFxy0[ iN ] = nid[ i ];
+ }
+ // find top veritices, their order is that a face normal is external
+ vFxy1.resize(4);
+ nid = vTool.GetFaceNodesIndices( Fxy1 );
+ for ( i = 0; i < 4; ++i )
+ if ( nid[ i ] == V001 )
+ break;
+ for ( iN = 0; iN < 4; ++iN, ++i ) {
+ if ( i == 4 ) i = 0;
+ vFxy1[ iN ] = nid[ i ];
+ }
+ // find indices of the rest veritices
+ V100 = vFxy0[3];
+ V010 = vFxy0[1];
+ V110 = vFxy0[2];
+ V101 = vFxy1[1];
+ V011 = vFxy1[3];
+ V111 = vFxy1[2];
+
+ // set points coordinates
+ myPnt[ ID_V000 - 1 ] = gpXYZ( nn[ V000 ] );
+ myPnt[ ID_V100 - 1 ] = gpXYZ( nn[ V100 ] );
+ myPnt[ ID_V010 - 1 ] = gpXYZ( nn[ V010 ] );
+ myPnt[ ID_V110 - 1 ] = gpXYZ( nn[ V110 ] );
+ myPnt[ ID_V001 - 1 ] = gpXYZ( nn[ V001 ] );
+ myPnt[ ID_V101 - 1 ] = gpXYZ( nn[ V101 ] );
+ myPnt[ ID_V011 - 1 ] = gpXYZ( nn[ V011 ] );
+ myPnt[ ID_V111 - 1 ] = gpXYZ( nn[ V111 ] );
+
+ // fill theOrderedNodes
+ theOrderedNodes.resize( 8 );
+ theOrderedNodes[ 0 ] = nn[ V000 ];
+ theOrderedNodes[ 1 ] = nn[ V100 ];
+ theOrderedNodes[ 2 ] = nn[ V010 ];
+ theOrderedNodes[ 3 ] = nn[ V110 ];
+ theOrderedNodes[ 4 ] = nn[ V001 ];
+ theOrderedNodes[ 5 ] = nn[ V101 ];
+ theOrderedNodes[ 6 ] = nn[ V011 ];
+ theOrderedNodes[ 7 ] = nn[ V111 ];
+
+ // fill edges
+ myEdge[ ID_Ex00 - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V000 - 1 ];
+ myEdge[ ID_Ex00 - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V100 - 1 ];
+
+ myEdge[ ID_Ex10 - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V010 - 1 ];
+ myEdge[ ID_Ex10 - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V110 - 1 ];
+
+ myEdge[ ID_Ex01 - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V001 - 1 ];
+ myEdge[ ID_Ex01 - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V101 - 1 ];
+
+ myEdge[ ID_Ex11 - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V011 - 1 ];
+ myEdge[ ID_Ex11 - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V111 - 1 ];
+
+ myEdge[ ID_E0y0 - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V000 - 1 ];
+ myEdge[ ID_E0y0 - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V010 - 1 ];
+
+ myEdge[ ID_E1y0 - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V100 - 1 ];
+ myEdge[ ID_E1y0 - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V110 - 1 ];
+
+ myEdge[ ID_E0y1 - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V001 - 1 ];
+ myEdge[ ID_E0y1 - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V011 - 1 ];
+
+ myEdge[ ID_E1y1 - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V101 - 1 ];
+ myEdge[ ID_E1y1 - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V111 - 1 ];
+
+ myEdge[ ID_E00z - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V000 - 1 ];
+ myEdge[ ID_E00z - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V001 - 1 ];
+
+ myEdge[ ID_E10z - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V100 - 1 ];
+ myEdge[ ID_E10z - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V101 - 1 ];
+
+ myEdge[ ID_E01z - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V010 - 1 ];
+ myEdge[ ID_E01z - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V011 - 1 ];
+
+ myEdge[ ID_E11z - ID_Ex00 ].myNodes[ 0 ] = myPnt[ ID_V110 - 1 ];
+ myEdge[ ID_E11z - ID_Ex00 ].myNodes[ 1 ] = myPnt[ ID_V111 - 1 ];
+
+ for ( iE = ID_Ex00; iE <= ID_E11z; ++iE )
+ myEdge[ iE - ID_Ex00 ].myCoordInd = GetCoordIndOnEdge( iE );
+
+ // fill faces corners
+ for ( iF = ID_Fxy0; iF < ID_Shell; ++iF )
+ {
+ TFace& tFace = myFace[ iF - ID_Fxy0 ];
+ vector< int > edgeIdVec(4, -1);
+ GetFaceEdgesIDs( iF, edgeIdVec );
+ tFace.myNodes[ 0 ] = myEdge[ edgeIdVec [ 0 ] - ID_Ex00 ].myNodes[ 1 ];
+ tFace.myNodes[ 1 ] = myEdge[ edgeIdVec [ 0 ] - ID_Ex00 ].myNodes[ 0 ];
+ tFace.myNodes[ 2 ] = myEdge[ edgeIdVec [ 1 ] - ID_Ex00 ].myNodes[ 0 ];
+ tFace.myNodes[ 3 ] = myEdge[ edgeIdVec [ 1 ] - ID_Ex00 ].myNodes[ 1 ];
+ tFace.myCoordInd[ 0 ] = GetCoordIndOnEdge( edgeIdVec[ 0 ] );
+ tFace.myCoordInd[ 1 ] = GetCoordIndOnEdge( edgeIdVec[ 1 ] );
+ tFace.myCoordInd[ 2 ] = GetCoordIndOnEdge( edgeIdVec[ 2 ] );
+ tFace.myCoordInd[ 3 ] = GetCoordIndOnEdge( edgeIdVec[ 3 ] );
+ }
+
+ return true;
+}
+
//=======================================================================
//function : LoadBlockShapes
//purpose : add sub-shapes of theBlock to theShapeIDMap so that they get
bool SMESH_Block::LoadBlockShapes(const TopoDS_Shell& theShell,
const TopoDS_Vertex& theVertex000,
const TopoDS_Vertex& theVertex001,
-// TopTools_IndexedMapOfShape& theShapeIDMap
TopTools_IndexedMapOfOrientedShape& theShapeIDMap )
{
MESSAGE(" ::LoadBlockShapes()");
mySumDist = 0;
myGridComputed = false;
- // 6 vertices
+ // 8 vertices
TopoDS_Shape V000, V100, V010, V110, V001, V101, V011, V111;
// 12 edges
TopoDS_Shape Ex00, Ex10, Ex01, Ex11;
void SMESH_Block::GetFaceEdgesIDs (const int faceID, vector< int >& edgeVec )
{
+ edgeVec.resize( 4 );
switch ( faceID ) {
case ID_Fxy0:
edgeVec[ 0 ] = ID_Ex00;
MESSAGE(" GetFaceEdgesIDs(), wrong face ID: " << faceID );
}
}
+
+//=======================================================================
+//function : GetEdgeVertexIDs
+//purpose : return vertex IDs of an edge
+//=======================================================================
+
+void SMESH_Block::GetEdgeVertexIDs (const int edgeID, vector< int >& vertexVec )
+{
+ vertexVec.resize( 2 );
+ switch ( edgeID ) {
+
+ case ID_Ex00:
+ vertexVec[ 0 ] = ID_V000;
+ vertexVec[ 1 ] = ID_V100;
+ break;
+ case ID_Ex10:
+ vertexVec[ 0 ] = ID_V010;
+ vertexVec[ 1 ] = ID_V110;
+ break;
+ case ID_Ex01:
+ vertexVec[ 0 ] = ID_V001;
+ vertexVec[ 1 ] = ID_V101;
+ break;
+ case ID_Ex11:
+ vertexVec[ 0 ] = ID_V011;
+ vertexVec[ 1 ] = ID_V111;
+ break;
+
+ case ID_E0y0:
+ vertexVec[ 0 ] = ID_V000;
+ vertexVec[ 1 ] = ID_V010;
+ break;
+ case ID_E1y0:
+ vertexVec[ 0 ] = ID_V100;
+ vertexVec[ 1 ] = ID_V110;
+ break;
+ case ID_E0y1:
+ vertexVec[ 0 ] = ID_V001;
+ vertexVec[ 1 ] = ID_V011;
+ break;
+ case ID_E1y1:
+ vertexVec[ 0 ] = ID_V101;
+ vertexVec[ 1 ] = ID_V111;
+ break;
+
+ case ID_E00z:
+ vertexVec[ 0 ] = ID_V000;
+ vertexVec[ 1 ] = ID_V001;
+ break;
+ case ID_E10z:
+ vertexVec[ 0 ] = ID_V100;
+ vertexVec[ 1 ] = ID_V101;
+ break;
+ case ID_E01z:
+ vertexVec[ 0 ] = ID_V010;
+ vertexVec[ 1 ] = ID_V011;
+ break;
+ case ID_E11z:
+ vertexVec[ 0 ] = ID_V110;
+ vertexVec[ 1 ] = ID_V111;
+ break;
+ default:
+ MESSAGE(" GetEdgeVertexIDs(), wrong edge ID: " << edgeID );
+ }
+}
+
#include <ostream>
#include <vector>
+class SMDS_MeshVolume;
+class SMDS_MeshNode;
+
// =========================================================
// class calculating coordinates of 3D points by normalized
// parameters inside the block and vice versa
// add sub-shapes of theBlock to theShapeIDMap so that they get
// IDs acoording to enum TShapeID
+ bool LoadMeshBlock(const SMDS_MeshVolume* theVolume,
+ const int theNode000Index,
+ const int theNode001Index,
+ vector<const SMDS_MeshNode*>& theOrderedNodes);
+ // prepare to work with theVolume and
+ // return nodes in the order of TShapeID enum
+
static int GetShapeIDByParams ( const gp_XYZ& theParams );
// define an id of the block sub-shape by point parameters
static void GetFaceEdgesIDs (const int faceID, vector< int >& edgeVec );
// return edges IDs of a face in the order u0, u1, 0v, 1v
+ static void GetEdgeVertexIDs (const int edgeID, vector< int >& vertexVec );
+ // return vertex IDs of an edge
+
static int GetCoordIndOnEdge (const int theEdgeID)
{ return (theEdgeID < ID_E0y0) ? 1 : (theEdgeID < ID_E00z) ? 2 : 3; }
// return an index of a coordinate which varies along the edge
gp_Trsf myTrsf;
double GetU( const gp_XYZ& theParams ) const;
gp_XYZ Point( const gp_XYZ& theParams ) const;
+ // if mesh volume
+ gp_XYZ myNodes[2];
};
struct TFace {
gp_XYZ Point( const gp_XYZ& theParams ) const;
int GetUInd() const { return myCoordInd[ 0 ]; }
int GetVInd() const { return myCoordInd[ 2 ]; }
+ void GetCoefs( int i, const gp_XYZ& theParams, double& eCoef, double& vCoef ) const;
+ // if mesh volume
+ gp_XYZ myNodes[4];
};
TopoDS_Shell myShell;
- // geometry:
+ // geometry in the order as in TShapeID:
// 8 vertices
gp_XYZ myPnt[ 8 ];
// 12 edges
*/
//=============================================================================
-void SMESH_Mesh::ExportMED(const char *file, const char* theMeshName, bool theAutoGroups) throw(SALOME_Exception)
+void SMESH_Mesh::ExportMED(const char *file,
+ const char* theMeshName,
+ bool theAutoGroups,
+ int theVersion)
+ throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
DriverMED_W_SMESHDS_Mesh myWriter;
- myWriter.SetFile ( file );
+ myWriter.SetFile ( file, MED::EVersion(theVersion) );
myWriter.SetMesh ( _myMeshDS );
if ( !theMeshName )
myWriter.SetMeshId ( _idDoc );
// return list of ancestors of theSubShape in the order
// that lower dimention shapes come first.
+ void ExportMED(const char *file,
+ const char* theMeshName = NULL,
+ bool theAutoGroups = true,
+ int theVersion = 0)
+ throw(SALOME_Exception);
+
void ExportDAT(const char *file) throw(SALOME_Exception);
- void ExportMED(const char *file, const char* theMeshName = NULL, bool theAutoGroups = true) throw(SALOME_Exception);
void ExportUNV(const char *file) throw(SALOME_Exception);
void ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception);
#include "SMESH_MeshEditor.hxx"
+#include "SMESH_ControlsDef.hxx"
+
#include "SMDS_FaceOfNodes.hxx"
#include "SMDS_VolumeTool.hxx"
#include "SMESHDS_Group.hxx"
#include "SMESHDS_Mesh.hxx"
#include "SMESH_subMesh.hxx"
+#include "SMESH_ControlsDef.hxx"
#include "utilities.h"
-#include <TColgp_SequenceOfXYZ.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
+#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <gp_Ax1.hxx>
#include <gp_Trsf.hxx>
#include <gp_Lin.hxx>
+#include <gp_XYZ.hxx>
#include <gp.hxx>
#include <gp_Pln.hxx>
+#include <BRep_Tool.hxx>
+#include <SMDS_EdgePosition.hxx>
+#include <Geom_Curve.hxx>
+
#include <map>
+#include "utilities.h"
+
using namespace std;
+using namespace SMESH::Controls;
-typedef map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
-typedef map<const SMDS_MeshNode*, list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
-typedef map<const SMDS_MeshElement*, list<const SMDS_MeshNode*> > TElemOfNodeListMap;
+typedef map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
+typedef map<const SMDS_MeshElement*, list<const SMDS_MeshNode*> > TElemOfNodeListMap;
+typedef map<const SMDS_MeshElement*, list<const SMDS_MeshElement*> > TElemOfElemListMap;
+typedef map<const SMDS_MeshNode*, list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
+typedef TNodeOfNodeListMap::iterator TNodeOfNodeListMapItr;
+typedef map<const SMDS_MeshElement*, vector<TNodeOfNodeListMapItr> > TElemOfVecOfNnlmiMap;
//=======================================================================
//function : SMESH_MeshEditor
static double getBadRate (const SMDS_MeshElement* theElem,
SMESH::Controls::NumericalFunctorPtr& theCrit)
{
- TColgp_SequenceOfXYZ P;
+ SMESH::Controls::TSequenceOfXYZ P;
if ( !theElem || !theCrit->GetPoints( theElem, P ))
return 1e100;
return theCrit->GetBadRate( theCrit->GetValue( P ), theElem->NbNodes() );
}
//=======================================================================
-//function : addToSameGroups
+//function : AddToSameGroups
//purpose : add elemToAdd to the groups the elemInGroups belongs to
//=======================================================================
-static void addToSameGroups (const SMDS_MeshElement* elemToAdd,
- const SMDS_MeshElement* elemInGroups,
- SMESHDS_Mesh * aMesh)
+void SMESH_MeshEditor::AddToSameGroups (const SMDS_MeshElement* elemToAdd,
+ const SMDS_MeshElement* elemInGroups,
+ SMESHDS_Mesh * aMesh)
{
const set<SMESHDS_GroupBase*>& groups = aMesh->GetGroups();
set<SMESHDS_GroupBase*>::const_iterator grIt = groups.begin();
if ( aShapeId )
aMesh->SetMeshElementOnShape( newElem, aShapeId );
- addToSameGroups( newElem, elem, aMesh );
+ AddToSameGroups( newElem, elem, aMesh );
}
return true;
double angle = 2*PI; // bad angle
// get normals
- TColgp_SequenceOfXYZ P1, P2;
+ SMESH::Controls::TSequenceOfXYZ P1, P2;
if ( !SMESH::Controls::NumericalFunctor::GetPoints( tr1, P1 ) ||
!SMESH::Controls::NumericalFunctor::GetPoints( tr2, P2 ))
return angle;
nbElems++;
gp_XYZ elemCenter(0.,0.,0.);
- TColgp_SequenceOfXYZ aNodePoints;
+ SMESH::Controls::TSequenceOfXYZ aNodePoints;
SMDS_ElemIteratorPtr itN = elem->nodesIterator();
while ( itN->more() )
{
const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>( itN->next() );
gp_XYZ aP( aNode->X(), aNode->Y(), aNode->Z() );
- aNodePoints.Append( aP );
+ aNodePoints.push_back( aP );
elemCenter += aP;
}
double elemArea = anAreaFunc.GetValue( aNodePoints );
const SMDS_MeshElement* elem = (*itElem);
if ( !elem || elem->GetType() != SMDSAbs_Face )
continue;
- TColgp_SequenceOfXYZ aPoints;
+ SMESH::Controls::TSequenceOfXYZ aPoints;
if ( aQualityFunc.GetPoints( elem, aPoints )) {
double aValue = aQualityFunc.GetValue( aPoints );
if ( aValue > maxRatio )
//=======================================================================
//function : isReverse
-//purpose :
+//purpose : Return true if normal of prevNodes is not co-directied with
+// gp_Vec(prevNodes[iNotSame],nextNodes[iNotSame]).
+// iNotSame is where prevNodes and nextNodes are different
//=======================================================================
static bool isReverse(const SMDS_MeshNode* prevNodes[],
//=======================================================================
//function : sweepElement
-//purpose :
+//purpose :
//=======================================================================
-static void sweepElement(SMESHDS_Mesh* aMesh,
- const SMDS_MeshElement* elem,
- const TNodeOfNodeListMap& mapNewNodes )
+static void sweepElement(SMESHDS_Mesh* aMesh,
+ const SMDS_MeshElement* elem,
+ const vector<TNodeOfNodeListMapItr> & newNodesItVec,
+ list<const SMDS_MeshElement*>& newElems)
{
// Loop on elem nodes:
// find new nodes and detect same nodes indices
- list<const SMDS_MeshNode*>::const_iterator itNN[ 4 ];
- const SMDS_MeshNode* prevNod[ 4 ], *nextNod[ 4 ];
- int nbSame = 0, iNotSameNode = 0, iSameNode = 0;
-
- TNodeOfNodeListMap::const_iterator mapIt;
- int iNode = 0;
- SMDS_ElemIteratorPtr itN = elem->nodesIterator();
- while ( itN->more() )
+ int nbNodes = elem->NbNodes();
+ list<const SMDS_MeshNode*>::const_iterator itNN[ nbNodes ];
+ const SMDS_MeshNode* prevNod[ nbNodes ], *nextNod[ nbNodes ];
+ int iNode, nbSame = 0, iNotSameNode = 0, iSameNode = 0;
+
+ for ( iNode = 0; iNode < nbNodes; iNode++ )
{
- const SMDS_MeshNode* node =
- static_cast<const SMDS_MeshNode*>( itN->next() );
- mapIt = mapNewNodes.find( node );
- if ( mapIt == mapNewNodes.end() )
- return; // not duplicated node
+ TNodeOfNodeListMapItr nnIt = newNodesItVec[ iNode ];
+ const SMDS_MeshNode* node = nnIt->first;
+ const list< const SMDS_MeshNode* > & listNewNodes = nnIt->second;
+ if ( listNewNodes.empty() )
+ return;
- itNN[ iNode ] = (*mapIt).second.begin();
+ itNN[ iNode ] = listNewNodes.begin();
prevNod[ iNode ] = node;
- nextNod[ iNode ] = (*mapIt).second.front();
+ nextNod[ iNode ] = listNewNodes.front();
if ( prevNod[ iNode ] != nextNod [ iNode ])
iNotSameNode = iNode;
else {
iSameNode = iNode;
nbSame++;
}
- iNode++;
}
- int nbNodes = iNode;
if ( nbSame == nbNodes || nbSame > 2) {
MESSAGE( " Too many same nodes of element " << elem->GetID() );
return;
// check element orientation
int i0 = 0, i2 = 2;
- if ( nbNodes > 2 && isReverse( prevNod, nextNod, nbNodes, iNotSameNode )) {
-// MESSAGE("Reversed elem " << elem->GetID() );
+ if ( nbNodes > 2 && !isReverse( prevNod, nextNod, nbNodes, iNotSameNode )) {
+ //MESSAGE("Reversed elem " << elem );
i0 = 2;
i2 = 0;
if ( nbSame > 0 ) {
}
// make new elements
- int iStep, nbSteps = (*mapIt).second.size();
+ int iStep, nbSteps = newNodesItVec[ 0 ]->second.size();
for (iStep = 0; iStep < nbSteps; iStep++ )
{
// get next nodes
nextNod[ iNode ] = *itNN[ iNode ];
itNN[ iNode ]++;
}
+ SMDS_MeshElement* aNewElem = 0;
switch ( nbNodes )
{
+ case 1: { // NODE
+ if ( nbSame == 0 )
+ aNewElem = aMesh->AddEdge( prevNod[ 0 ], nextNod[ 0 ] );
+ break;
+ }
case 2: { // EDGE
if ( nbSame == 0 )
- aMesh->AddFace( prevNod[ 0 ], prevNod[ 1 ], nextNod[ 1 ], nextNod[ 0 ] );
+ aNewElem = aMesh->AddFace(prevNod[ 0 ], prevNod[ 1 ],
+ nextNod[ 1 ], nextNod[ 0 ] );
else
- aMesh->AddFace( prevNod[ 0 ], prevNod[ 1 ], nextNod[ iNotSameNode ] );
+ aNewElem = aMesh->AddFace(prevNod[ 0 ], prevNod[ 1 ],
+ nextNod[ iNotSameNode ] );
break;
}
case 3: { // TRIANGLE
- if ( nbSame == 0 ) // --- 1 pentahedron
- {
- aMesh->AddVolume (prevNod[ i2 ], prevNod[ 1 ], prevNod[ i0 ],
- nextNod[ i2 ], nextNod[ 1 ], nextNod[ i0 ] );
- }
- else if ( nbSame == 1 ) // --- 2 tetrahedrons
- {
- aMesh->AddVolume (prevNod[ i0 ], prevNod[ 1 ], prevNod[ i2 ],
- nextNod[ iBeforeSame ]);
- aMesh->AddVolume (nextNod[ i2 ], nextNod[ 1 ], nextNod[ i0 ],
- prevNod[ iAfterSame ]);
- }
- else // 2 same nodes: --- 1 tetrahedron
- {
- aMesh->AddVolume (prevNod[ i0 ], prevNod[ 1 ], prevNod[ i2 ],
- nextNod[ iNotSameNode ]);
- }
+ if ( nbSame == 0 ) // --- pentahedron
+ aNewElem = aMesh->AddVolume (prevNod[ i0 ], prevNod[ 1 ], prevNod[ i2 ],
+ nextNod[ i0 ], nextNod[ 1 ], nextNod[ i2 ] );
+
+ else if ( nbSame == 1 ) // --- pyramid
+ aNewElem = aMesh->AddVolume (prevNod[ iAfterSame ], prevNod[ iBeforeSame ],
+ nextNod[ iBeforeSame ], nextNod[ iAfterSame ],
+ nextNod[ iSameNode ]);
+
+ else // 2 same nodes: --- tetrahedron
+ aNewElem = aMesh->AddVolume (prevNod[ i0 ], prevNod[ 1 ], prevNod[ i2 ],
+ nextNod[ iNotSameNode ]);
break;
}
case 4: { // QUADRANGLE
- if ( nbSame == 0 ) // --- 1 hexahedron
- {
- aMesh->AddVolume (prevNod[ i0 ], prevNod[ 1 ], prevNod[ i2 ], prevNod[ 3 ],
- nextNod[ i0 ], nextNod[ 1 ], nextNod[ i2 ], nextNod[ 3 ]);
- }
- else if ( nbSame == 1 ) // --- 2 tetrahedrons + 1 pentahedron
+ if ( nbSame == 0 ) // --- hexahedron
+ aNewElem = aMesh->AddVolume (prevNod[ i0 ], prevNod[ 1 ], prevNod[ i2 ], prevNod[ 3 ],
+ nextNod[ i0 ], nextNod[ 1 ], nextNod[ i2 ], nextNod[ 3 ]);
+
+ else if ( nbSame == 1 ) // --- pyramid + pentahedron
{
- aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iSameNode ],
- prevNod[ iAfterSame ], nextNod[ iBeforeSame ]);
- aMesh->AddVolume (nextNod[ iAfterSame ], nextNod[ iSameNode ],
- nextNod[ iBeforeSame ], prevNod[ iAfterSame ]);
- aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iOpposSame ], prevNod[ iAfterSame ],
- nextNod[ iBeforeSame ], nextNod[ iOpposSame ], nextNod[ iAfterSame ] );
+ aNewElem = aMesh->AddVolume (prevNod[ iAfterSame ], prevNod[ iBeforeSame ],
+ nextNod[ iBeforeSame ], nextNod[ iAfterSame ],
+ nextNod[ iSameNode ]);
+ newElems.push_back( aNewElem );
+ aNewElem = aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iOpposSame ],
+ prevNod[ iAfterSame ], nextNod[ iBeforeSame ],
+ nextNod[ iOpposSame ], nextNod[ iAfterSame ] );
}
- else if ( nbSame == 2 ) // 1 pentahedron
+ else if ( nbSame == 2 ) // pentahedron
{
if ( prevNod[ iBeforeSame ] == nextNod[ iBeforeSame ] )
// iBeforeSame is same too
- aMesh->AddVolume (prevNod[ iOpposSame ], prevNod[ iBeforeSame ], nextNod[ iOpposSame ],
- prevNod[ iAfterSame ], prevNod[ iSameNode ], nextNod[ iAfterSame ]);
+ aNewElem = aMesh->AddVolume (prevNod[ iOpposSame ], prevNod[ iBeforeSame ],
+ nextNod[ iOpposSame ], prevNod[ iAfterSame ],
+ prevNod[ iSameNode ], nextNod[ iAfterSame ]);
else
// iAfterSame is same too
- aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iSameNode ], nextNod[ iBeforeSame ],
- prevNod[ iOpposSame ], prevNod[ iAfterSame ], nextNod[ iOpposSame ]);
+ aNewElem = aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iSameNode ],
+ nextNod[ iBeforeSame ], prevNod[ iOpposSame ],
+ prevNod[ iAfterSame ], nextNod[ iOpposSame ]);
}
break;
}
default:
return;
}
+ if ( aNewElem )
+ newElems.push_back( aNewElem );
// set new prev nodes
for ( iNode = 0; iNode < nbNodes; iNode++ )
} // for steps
}
+//=======================================================================
+//function : makeWalls
+//purpose : create 1D and 2D elements around swept elements
+//=======================================================================
+
+static void makeWalls (SMESHDS_Mesh* aMesh,
+ TNodeOfNodeListMap & mapNewNodes,
+ TElemOfElemListMap & newElemsMap,
+ TElemOfVecOfNnlmiMap & elemNewNodesMap,
+ set<const SMDS_MeshElement*>& elemSet)
+{
+ ASSERT( newElemsMap.size() == elemNewNodesMap.size() );
+
+ // Find nodes belonging to only one initial element - sweep them to get edges.
+
+ TNodeOfNodeListMapItr nList = mapNewNodes.begin();
+ for ( ; nList != mapNewNodes.end(); nList++ )
+ {
+ const SMDS_MeshNode* node =
+ static_cast<const SMDS_MeshNode*>( nList->first );
+ SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator();
+ int nbInitElems = 0;
+ while ( eIt->more() && nbInitElems < 2 )
+ if ( elemSet.find( eIt->next() ) != elemSet.end() )
+ nbInitElems++;
+ if ( nbInitElems < 2 ) {
+ vector<TNodeOfNodeListMapItr> newNodesItVec( 1, nList );
+ list<const SMDS_MeshElement*> newEdges;
+ sweepElement( aMesh, node, newNodesItVec, newEdges );
+ }
+ }
+
+ // Make a ceiling for each element ie an equal element of last new nodes.
+ // Find free links of faces - make edges and sweep them into faces.
+
+ TElemOfElemListMap::iterator itElem = newElemsMap.begin();
+ TElemOfVecOfNnlmiMap::iterator itElemNodes = elemNewNodesMap.begin();
+ for ( ; itElem != newElemsMap.end(); itElem++, itElemNodes++ )
+ {
+ const SMDS_MeshElement* elem = itElem->first;
+ vector<TNodeOfNodeListMapItr>& vecNewNodes = itElemNodes->second;
+
+ if ( elem->GetType() == SMDSAbs_Edge )
+ {
+ // create a ceiling edge
+ aMesh->AddEdge(vecNewNodes[ 0 ]->second.back(),
+ vecNewNodes[ 1 ]->second.back() );
+ }
+ if ( elem->GetType() != SMDSAbs_Face )
+ continue;
+
+ bool hasFreeLinks = false;
+
+ set<const SMDS_MeshElement*> avoidSet;
+ avoidSet.insert( elem );
+
+ // loop on a face nodes
+ set<const SMDS_MeshNode*> aFaceLastNodes;
+ int iNode, nbNodes = vecNewNodes.size();
+ for ( iNode = 0; iNode < nbNodes; iNode++ )
+ {
+ aFaceLastNodes.insert( vecNewNodes[ iNode ]->second.back() );
+ // look for free links of a face
+ int iNext = ( iNode + 1 == nbNodes ) ? 0 : iNode + 1;
+ const SMDS_MeshNode* n1 = vecNewNodes[ iNode ]->first;
+ const SMDS_MeshNode* n2 = vecNewNodes[ iNext ]->first;
+ // check if a link is free
+ if ( ! SMESH_MeshEditor::FindFaceInSet ( n1, n2, elemSet, avoidSet ))
+ {
+ hasFreeLinks = true;
+ // make an edge and a ceiling for a new edge
+ if ( !aMesh->FindEdge( n1, n2 ))
+ aMesh->AddEdge( n1, n2 );
+ n1 = vecNewNodes[ iNode ]->second.back();
+ n2 = vecNewNodes[ iNext ]->second.back();
+ if ( !aMesh->FindEdge( n1, n2 ))
+ aMesh->AddEdge( n1, n2 );
+ }
+ }
+ // sweep free links into faces
+
+ if ( hasFreeLinks )
+ {
+ list<const SMDS_MeshElement*> & newVolumes = itElem->second;
+ int iStep, nbSteps = vecNewNodes[0]->second.size();
+ int iVol, volNb, nbVolumesByStep = newVolumes.size() / nbSteps;
+
+ set<const SMDS_MeshNode*> initNodeSet, faceNodeSet;
+ for ( iNode = 0; iNode < nbNodes; iNode++ )
+ initNodeSet.insert( vecNewNodes[ iNode ]->first );
+
+ for ( volNb = 0; volNb < nbVolumesByStep; volNb++ )
+ {
+ list<const SMDS_MeshElement*>::iterator v = newVolumes.begin();
+ iVol = 0;
+ while ( iVol++ < volNb ) v++;
+ // find indices of free faces of a volume
+ list< int > fInd;
+ SMDS_VolumeTool vTool( *v );
+ int iF, nbF = vTool.NbFaces();
+ for ( iF = 0; iF < nbF; iF ++ )
+ if (vTool.IsFreeFace( iF ) &&
+ vTool.GetFaceNodes( iF, faceNodeSet ) &&
+ initNodeSet != faceNodeSet) // except an initial face
+ fInd.push_back( iF );
+ if ( fInd.empty() )
+ continue;
+
+ // create faces for all steps
+ for ( iStep = 0; iStep < nbSteps; iStep++ )
+ {
+ vTool.Set( *v );
+ vTool.SetExternalNormal();
+ list< int >::iterator ind = fInd.begin();
+ for ( ; ind != fInd.end(); ind++ )
+ {
+ const SMDS_MeshNode** nodes = vTool.GetFaceNodes( *ind );
+ switch ( vTool.NbFaceNodes( *ind ) ) {
+ case 3:
+ aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] ); break;
+ case 4:
+ aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ], nodes[ 3 ] ); break;
+ }
+ }
+ // go to the next volume
+ iVol = 0;
+ while ( iVol++ < nbVolumesByStep ) v++;
+ }
+ }
+ } // sweep free links into faces
+
+ // make a ceiling face with a normal external to a volume
+
+ SMDS_VolumeTool lastVol( itElem->second.back() );
+ int iF = lastVol.GetFaceIndex( aFaceLastNodes );
+ if ( iF >= 0 )
+ {
+ lastVol.SetExternalNormal();
+ const SMDS_MeshNode** nodes = lastVol.GetFaceNodes( iF );
+ switch ( lastVol.NbFaceNodes( iF ) ) {
+ case 3:
+ if (!hasFreeLinks ||
+ !aMesh->FindFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ]))
+ aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] );
+ break;
+ case 4:
+ if (!hasFreeLinks ||
+ !aMesh->FindFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ], nodes[ 3 ]))
+ aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ], nodes[ 3 ] );
+ break;
+ }
+ }
+
+ } // loop on swept elements
+}
+
//=======================================================================
//function : RotationSweep
//purpose :
const int theNbSteps,
const double theTol)
{
+ MESSAGE( "RotationSweep()");
gp_Trsf aTrsf;
aTrsf.SetRotation( theAxis, theAngle );
SMESHDS_Mesh* aMesh = GetMeshDS();
TNodeOfNodeListMap mapNewNodes;
+ TElemOfVecOfNnlmiMap mapElemNewNodes;
+ TElemOfElemListMap newElemsMap;
// loop on theElems
set< const SMDS_MeshElement* >::iterator itElem;
for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ )
{
- // check element type
const SMDS_MeshElement* elem = (*itElem);
- if ( !elem ||
- (elem->GetType() != SMDSAbs_Face &&
- elem->GetType() != SMDSAbs_Edge ))
+ if ( !elem )
continue;
+ vector<TNodeOfNodeListMapItr> & newNodesItVec = mapElemNewNodes[ elem ];
+ newNodesItVec.reserve( elem->NbNodes() );
// loop on elem nodes
SMDS_ElemIteratorPtr itN = elem->nodesIterator();
// check if a node has been already sweeped
const SMDS_MeshNode* node =
static_cast<const SMDS_MeshNode*>( itN->next() );
- if (mapNewNodes.find( node ) != mapNewNodes.end() )
- continue;
-
- list<const SMDS_MeshNode*>& listNewNodes = mapNewNodes[ node ];
-
- // make new nodes
- gp_XYZ aXYZ( node->X(), node->Y(), node->Z() );
- double coord[3];
- aXYZ.Coord( coord[0], coord[1], coord[2] );
- bool isOnAxis = ( aLine.SquareDistance( aXYZ ) <= aSqTol );
- const SMDS_MeshNode * newNode = node;
- for ( int i = 0; i < theNbSteps; i++ ) {
- if ( !isOnAxis ) {
- aTrsf.Transforms( coord[0], coord[1], coord[2] );
- newNode = aMesh->AddNode( coord[0], coord[1], coord[2] );
+ TNodeOfNodeListMapItr nIt = mapNewNodes.find( node );
+ if ( nIt == mapNewNodes.end() )
+ {
+ nIt = mapNewNodes.insert( make_pair( node, list<const SMDS_MeshNode*>() )).first;
+ list<const SMDS_MeshNode*>& listNewNodes = nIt->second;
+
+ // make new nodes
+ gp_XYZ aXYZ( node->X(), node->Y(), node->Z() );
+ double coord[3];
+ aXYZ.Coord( coord[0], coord[1], coord[2] );
+ bool isOnAxis = ( aLine.SquareDistance( aXYZ ) <= aSqTol );
+ const SMDS_MeshNode * newNode = node;
+ for ( int i = 0; i < theNbSteps; i++ ) {
+ if ( !isOnAxis ) {
+ aTrsf.Transforms( coord[0], coord[1], coord[2] );
+ newNode = aMesh->AddNode( coord[0], coord[1], coord[2] );
+ }
+ listNewNodes.push_back( newNode );
}
- listNewNodes.push_back( newNode );
}
+ newNodesItVec.push_back( nIt );
}
// make new elements
- sweepElement( aMesh, elem, mapNewNodes );
+ sweepElement( aMesh, elem, newNodesItVec, newElemsMap[elem] );
}
+
+ makeWalls( aMesh, mapNewNodes, newElemsMap, mapElemNewNodes, theElems );
+
}
//=======================================================================
//function : ExtrusionSweep
SMESHDS_Mesh* aMesh = GetMeshDS();
TNodeOfNodeListMap mapNewNodes;
+ TElemOfVecOfNnlmiMap mapElemNewNodes;
+ TElemOfElemListMap newElemsMap;
// loop on theElems
set< const SMDS_MeshElement* >::iterator itElem;
{
// check element type
const SMDS_MeshElement* elem = (*itElem);
- if ( !elem ||
- (elem->GetType() != SMDSAbs_Face &&
- elem->GetType() != SMDSAbs_Edge))
+ if ( !elem )
continue;
+ vector<TNodeOfNodeListMapItr> & newNodesItVec = mapElemNewNodes[ elem ];
+ newNodesItVec.reserve( elem->NbNodes() );
+
// loop on elem nodes
SMDS_ElemIteratorPtr itN = elem->nodesIterator();
while ( itN->more() ) {
// check if a node has been already sweeped
const SMDS_MeshNode* node =
static_cast<const SMDS_MeshNode*>( itN->next() );
- if (mapNewNodes.find( node ) != mapNewNodes.end() )
- continue;
+ TNodeOfNodeListMap::iterator nIt = mapNewNodes.find( node );
+ if ( nIt == mapNewNodes.end() )
+ {
+ nIt = mapNewNodes.insert( make_pair( node, list<const SMDS_MeshNode*>() )).first;
+ list<const SMDS_MeshNode*>& listNewNodes = nIt->second;
- list<const SMDS_MeshNode*>& listNewNodes = mapNewNodes[ node ];
+ // make new nodes
+ double coord[] = { node->X(), node->Y(), node->Z() };
+ for ( int i = 0; i < theNbSteps; i++ ) {
+ aTrsf.Transforms( coord[0], coord[1], coord[2] );
+ const SMDS_MeshNode * newNode = aMesh->AddNode( coord[0], coord[1], coord[2] );
+ listNewNodes.push_back( newNode );
+ }
+ }
+ newNodesItVec.push_back( nIt );
+ }
+ // make new elements
+ sweepElement( aMesh, elem, newNodesItVec, newElemsMap[elem] );
+ }
- // make new nodes
- double coord[3];
- coord[0] = node->X();
- coord[1] = node->Y();
- coord[2] = node->Z();
- for ( int i = 0; i < theNbSteps; i++ ) {
- aTrsf.Transforms( coord[0], coord[1], coord[2] );
- const SMDS_MeshNode * newNode = aMesh->AddNode( coord[0], coord[1], coord[2] );
- listNewNodes.push_back( newNode );
+ makeWalls( aMesh, mapNewNodes, newElemsMap, mapElemNewNodes, theElems );
+
+}
+
+class SMESH_MeshEditor_PathPoint {
+public:
+ SMESH_MeshEditor_PathPoint() {
+ myPnt.SetCoord(99., 99., 99.);
+ myTgt.SetCoord(1.,0.,0.);
+ myAngle=0.;
+ myPrm=0.;
+ }
+ void SetPnt(const gp_Pnt& aP3D){
+ myPnt=aP3D;
+ }
+ void SetTangent(const gp_Dir& aTgt){
+ myTgt=aTgt;
+ }
+ void SetAngle(const double& aBeta){
+ myAngle=aBeta;
+ }
+ void SetParameter(const double& aPrm){
+ myPrm=aPrm;
+ }
+ const gp_Pnt& Pnt()const{
+ return myPnt;
+ }
+ const gp_Dir& Tangent()const{
+ return myTgt;
+ }
+ double Angle()const{
+ return myAngle;
+ }
+ double Parameter()const{
+ return myPrm;
+ }
+
+protected:
+ gp_Pnt myPnt;
+ gp_Dir myTgt;
+ double myAngle;
+ double myPrm;
+};
+
+//=======================================================================
+//function : ExtrusionAlongTrack
+//purpose :
+//=======================================================================
+int SMESH_MeshEditor::ExtrusionAlongTrack (std::set<const SMDS_MeshElement*> & theElements,
+ SMESH_subMesh* theTrack,
+ const SMDS_MeshNode* theN1,
+ const bool theHasAngles,
+ std::list<double>& theAngles,
+ const bool theHasRefPoint,
+ const gp_Pnt& theRefPoint)
+{
+ MESSAGE("SMESH_MeshEditor::ExtrusionAlongTrack")
+ int j, iErr, aNbTP, aNbAngles, aNbE, aNb;
+ double aT1, aT2, aT, aAngle, aX, aY, aZ;
+ std::list<double> aPrms;
+ std::list<double>::iterator aItD;
+ std::set< const SMDS_MeshElement* >::iterator itElem;
+
+ Standard_Real aTx1, aTx2, aL2, aTolVec, aTolVec2;
+ gp_Pnt aP3D, aV0;
+ gp_Vec aVec;
+ gp_XYZ aGC;
+ Handle(Geom_Curve) aC3D;
+ TopoDS_Edge aTrackEdge;
+ TopoDS_Vertex aV1, aV2;
+
+ SMDS_ElemIteratorPtr aItE;
+ SMDS_NodeIteratorPtr aItN;
+ SMDSAbs_ElementType aTypeE;
+
+ TNodeOfNodeListMap mapNewNodes;
+ TElemOfVecOfNnlmiMap mapElemNewNodes;
+ TElemOfElemListMap newElemsMap;
+
+ aTolVec=1.e-7;
+ aTolVec2=aTolVec*aTolVec;
+ iErr=0;
+
+ // 1. Check data
+ aNbE=theElements.size();
+ if ( !aNbE ) {
+ iErr = 10; // nothing to do
+ return iErr;
+ }
+
+ // 1.1 Track Pattern
+ ASSERT( theTrack );
+
+ SMESHDS_SubMesh* pSubMeshDS=theTrack->GetSubMeshDS();
+
+ if ( !pSubMeshDS->Contains( theN1 ) ) {
+ iErr = 2; // No match found for start node
+ return iErr;
+ }
+
+ aItE = pSubMeshDS->GetElements();
+ while ( aItE->more() ) {
+ const SMDS_MeshElement* pE = aItE->next();
+ aTypeE = pE->GetType();
+ if ( aTypeE != SMDSAbs_Edge ) {
+ iErr = 3; // Pattern must contain links only
+ return iErr;
+ }
+ }
+
+ const TopoDS_Shape& aS = theTrack->GetSubShape();
+ if ( aS.ShapeType() != TopAbs_EDGE) {
+ iErr = 3; // Sub shape for the Pattern must be an Edge
+ return iErr;
+ aTrackEdge = TopoDS::Edge( aS );
+ if ( BRep_Tool::Degenerated( aTrackEdge ) ) {
+ iErr = 4; // the Edge must not be degenerated
+ return iErr;
+ }
+ }
+
+ TopExp::Vertices( aTrackEdge, aV1, aV2 );
+ aT1=BRep_Tool::Parameter( aV1, aTrackEdge );
+ aT2=BRep_Tool::Parameter( aV2, aTrackEdge );
+
+ aItN = myMesh->GetSubMesh( aV1 )->GetSubMeshDS()->GetNodes();
+ const SMDS_MeshNode* aN1 = aItN->next();
+
+ aItN = myMesh->GetSubMesh( aV2 )->GetSubMeshDS()->GetNodes();
+ const SMDS_MeshNode* aN2 = aItN->next();
+
+ if ( !( aN1 == theN1 || aN2 == theN1 ) ) {
+ iErr = 5; // starting node must be aN1 or aN2
+ return iErr;
+ }
+
+ aNbTP = pSubMeshDS->NbNodes() + 2;
+
+ // 1.2. Angles
+ vector<double> aAngles( aNbTP );
+
+ if ( theHasAngles ) {
+ aNbAngles = theAngles.size();
+ if ( aNbTP != aNbAngles ) {
+ iErr = 6; // number of Angles does not match to the number of track points
+ return iErr;
+ }
+ aItD = theAngles.begin();
+ for ( j=0; aItD != aPrms.end(); ++aItD, ++j ) {
+ aAngle = *aItD;
+ aAngles[j] = aAngle;
+ }
+ }
+ else {
+ for ( j=0; j < aNbTP; ++j ) {
+ aAngles[j] = 0.;
+ }
+ }
+
+ // 2. Collect parameters on the track edge
+ aPrms.push_back( aT1 );
+ aPrms.push_back( aT2 );
+
+ aItN = pSubMeshDS->GetNodes();
+ while ( aItN->more() ) {
+ const SMDS_MeshNode* pNode = aItN->next();
+ const SMDS_EdgePosition* pEPos =
+ static_cast<const SMDS_EdgePosition*>( pNode->GetPosition().get() );
+ aT = pEPos->GetUParameter();
+ aPrms.push_back( aT );
+ }
+
+ // sort parameters
+ aPrms.sort();
+ if ( aN1 == theN1 ) {
+ if ( aT1 > aT2 ) {
+ aPrms.reverse();
+ }
+ }
+ else {
+ if ( aT2 > aT1 ) {
+ aPrms.reverse();
+ }
+ }
+
+ // 3. Path Points
+ SMESH_MeshEditor_PathPoint aPP;
+ vector<SMESH_MeshEditor_PathPoint> aPPs( aNbTP );
+ //
+ aC3D = BRep_Tool::Curve( aTrackEdge, aTx1, aTx2 );
+ //
+ aItD = aPrms.begin();
+ for ( j=0; aItD != aPrms.end(); ++aItD, ++j ) {
+ aT = *aItD;
+ aC3D->D1( aT, aP3D, aVec );
+ aL2 = aVec.SquareMagnitude();
+ if ( aL2 < aTolVec2 ) {
+ iErr = 20; // can not obtain the tangent;
+ return iErr;
+ }
+ gp_Dir aTgt( aVec );
+ aAngle = aAngles[j];
+
+ aPP.SetPnt( aP3D );
+ aPP.SetTangent( aTgt );
+ aPP.SetAngle( aAngle );
+ aPP.SetParameter( aT );
+ aPPs[j]=aPP;
+ }
+
+ // 3. Center of rotation aV0
+ aV0 = theRefPoint;
+ if ( !theHasRefPoint ) {
+ aNb = 0;
+ aGC.SetCoord( 0.,0.,0. );
+
+ itElem = theElements.begin();
+ for ( ; itElem != theElements.end(); itElem++ ) {
+ const SMDS_MeshElement* elem = (*itElem);
+
+ SMDS_ElemIteratorPtr itN = elem->nodesIterator();
+ while ( itN->more() ) {
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( itN->next() );
+ aX = node->X();
+ aY = node->Y();
+ aZ = node->Z();
+
+ if ( mapNewNodes.find( node ) == mapNewNodes.end() ) {
+ list<const SMDS_MeshNode*> aLNx;
+ mapNewNodes[node] = aLNx;
+ //
+ gp_XYZ aXYZ( aX, aY, aZ );
+ aGC += aXYZ;
+ ++aNb;
+ }
}
}
+ aGC /= aNb;
+ aV0.SetXYZ( aGC );
+ } // if (!theHasRefPoint) {
+ mapNewNodes.clear();
+
+ // 4. Processing the elements
+ SMESHDS_Mesh* aMesh = GetMeshDS();
+
+ for ( itElem = theElements.begin(); itElem != theElements.end(); itElem++ ) {
+ // check element type
+ const SMDS_MeshElement* elem = (*itElem);
+ aTypeE = elem->GetType();
+ if ( !elem || ( aTypeE != SMDSAbs_Face && aTypeE != SMDSAbs_Edge ) )
+ continue;
+
+ vector<TNodeOfNodeListMapItr> & newNodesItVec = mapElemNewNodes[ elem ];
+ newNodesItVec.reserve( elem->NbNodes() );
+
+ // loop on elem nodes
+ SMDS_ElemIteratorPtr itN = elem->nodesIterator();
+ while ( itN->more() ) {
+
+ // check if a node has been already processed
+ const SMDS_MeshNode* node =
+ static_cast<const SMDS_MeshNode*>( itN->next() );
+ TNodeOfNodeListMap::iterator nIt = mapNewNodes.find( node );
+ if ( nIt == mapNewNodes.end() ) {
+ nIt = mapNewNodes.insert( make_pair( node, list<const SMDS_MeshNode*>() )).first;
+ list<const SMDS_MeshNode*>& listNewNodes = nIt->second;
+
+ // make new nodes
+ aX = node->X(); aY = node->Y(); aZ = node->Z();
+
+ Standard_Real aAngle1x;
+ gp_Pnt aP0x, aP1x, aPN0, aPN1, aV0x, aV1x;
+ gp_Ax1 anAx1;
+
+ aV0x = aV0;
+ aPN0.SetCoord(aX, aY, aZ);
+
+ const SMESH_MeshEditor_PathPoint& aPP0 = aPPs[0];
+ aP0x = aPP0.Pnt();
+
+ for ( j = 1; j < aNbTP; ++j ) {
+ const SMESH_MeshEditor_PathPoint& aPP1 = aPPs[j];
+ aP1x = aPP1.Pnt();
+ const gp_Dir& aDT1x = aPP1.Tangent();
+ aAngle1x = aPP1.Angle();
+
+ gp_Trsf aTrsf, aTrsfRot;
+ // Translation
+ gp_Vec aV01x( aP0x, aP1x );
+ aTrsf.SetTranslation( aV01x );
+
+ // traslated point
+ aV1x = aV0x.Transformed( aTrsf );
+ aPN1 = aPN0.Transformed( aTrsf );
+
+ if ( theHasAngles ) {
+ anAx1.SetLocation( aV1x );
+ anAx1.SetDirection( aDT1x );
+ aTrsfRot.SetRotation( anAx1, aAngle1x );
+
+ aPN1 = aPN1.Transformed( aTrsfRot );
+ }
+
+ // make new node
+ aX = aPN1.X();
+ aY = aPN1.X();
+ aZ = aPN1.X();
+ const SMDS_MeshNode* newNode = aMesh->AddNode( aX, aY, aZ );
+ listNewNodes.push_back( newNode );
+
+ aPN0 = aPN1;
+ aP0x = aP1x;
+ aV0x = aV1x;
+ }
+ }
+ newNodesItVec.push_back( nIt );
+ }
// make new elements
- sweepElement( aMesh, elem, mapNewNodes );
+ sweepElement( aMesh, elem, newNodesItVec, newElemsMap[elem] );
}
+
+ makeWalls( aMesh, mapNewNodes, newElemsMap, mapElemNewNodes, theElements );
+ return iErr;
}
//=======================================================================
//=======================================================================
//function : FindCoincidentNodes
//purpose : Return list of group of nodes close to each other within theTolerance
+// Search among theNodes or in the whole mesh if theNodes is empty.
//=======================================================================
-void SMESH_MeshEditor::FindCoincidentNodes (const double theTolerance,
- TListOfListOfNodes & theGroupsOfNodes)
+void SMESH_MeshEditor::FindCoincidentNodes (set<const SMDS_MeshNode*> & theNodes,
+ const double theTolerance,
+ TListOfListOfNodes & theGroupsOfNodes)
{
double tol2 = theTolerance * theTolerance;
list<const SMDS_MeshNode*> nodes;
- SMDS_NodeIteratorPtr nIt = GetMeshDS()->nodesIterator();
- while ( nIt->more() )
- nodes.push_back( nIt->next() );
+ if ( theNodes.empty() )
+ { // get all nodes in the mesh
+ SMDS_NodeIteratorPtr nIt = GetMeshDS()->nodesIterator();
+ while ( nIt->more() )
+ nodes.push_back( nIt->next() );
+ }
+ else
+ {
+ nodes.insert( nodes.end(), theNodes.begin(), theNodes.end() );
+ }
list<const SMDS_MeshNode*>::iterator it2, it1 = nodes.begin();
for ( ; it1 != nodes.end(); it1++ )
nodeNodeMap.insert( TNodeNodeMap::value_type( nToRemove, nToKeep ));
if ( nToRemove != nToKeep ) {
rmNodeIds.push_back( nToRemove->GetID() );
- addToSameGroups( nToKeep, nToRemove, aMesh );
+ AddToSameGroups( nToKeep, nToRemove, aMesh );
}
SMDS_ElemIteratorPtr invElemIt = nToRemove->GetInverseElementIterator();
Remove( rmElemIds, false );
}
+//=======================================================================
+//function : FindFaceInSet
+//purpose : Return a face having linked nodes n1 and n2 and which is
+// - not in avoidSet,
+// - in elemSet provided that !elemSet.empty()
+//=======================================================================
+
+const SMDS_MeshElement*
+ SMESH_MeshEditor::FindFaceInSet(const SMDS_MeshNode* n1,
+ const SMDS_MeshNode* n2,
+ const set<const SMDS_MeshElement*>& elemSet,
+ const set<const SMDS_MeshElement*>& avoidSet)
+
+{
+ SMDS_ElemIteratorPtr invElemIt = n1->GetInverseElementIterator();
+ while ( invElemIt->more() ) { // loop on inverse elements of n1
+ const SMDS_MeshElement* elem = invElemIt->next();
+ if (elem->GetType() != SMDSAbs_Face ||
+ avoidSet.find( elem ) != avoidSet.end() )
+ continue;
+ if ( !elemSet.empty() && elemSet.find( elem ) == elemSet.end())
+ continue;
+ // get face nodes and find index of n1
+ int i1, nbN = elem->NbNodes(), iNode = 0;
+ const SMDS_MeshNode* faceNodes[ nbN ], *n;
+ SMDS_ElemIteratorPtr nIt = elem->nodesIterator();
+ while ( nIt->more() ) {
+ faceNodes[ iNode ] = static_cast<const SMDS_MeshNode*>( nIt->next() );
+ if ( faceNodes[ iNode++ ] == n1 )
+ i1 = iNode - 1;
+ }
+ // find a n2 linked to n1
+ for ( iNode = 0; iNode < 2; iNode++ ) {
+ if ( iNode ) // node before n1
+ n = faceNodes[ i1 == 0 ? nbN - 1 : i1 - 1 ];
+ else // node after n1
+ n = faceNodes[ i1 + 1 == nbN ? 0 : i1 + 1 ];
+ if ( n == n2 )
+ return elem;
+ }
+ }
+ return 0;
+}
+
//=======================================================================
//function : findAdjacentFace
//purpose :
//=======================================================================
-#define CHECKIND(max,val) {if ( (val) >= (max) ) \
static const SMDS_MeshElement* findAdjacentFace(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshElement* elem)
{
- SMDS_ElemIteratorPtr invElemIt = n1->facesIterator();
- while ( invElemIt->more() ) { // loop on inverse elements of n1
- const SMDS_MeshElement* adjElem = invElemIt->next();
- if ( elem != adjElem ) {
- // get face nodes and find index of n1
- int i1, nbN = adjElem->NbNodes(), iNode = 0;
- const SMDS_MeshNode* faceNodes[ nbN ], *n;
- SMDS_ElemIteratorPtr nIt = adjElem->nodesIterator();
- while ( nIt->more() ) {
- faceNodes[ iNode ] = static_cast<const SMDS_MeshNode*>( nIt->next() );
- if ( faceNodes[ iNode++ ] == n1 )
- i1 = iNode - 1;
- }
- // find a n2 linked to n1
- for ( iNode = 0; iNode < 2; iNode++ ) {
- if ( iNode ) // node before n1
- n = faceNodes[ i1 == 0 ? nbN - 1 : i1 - 1 ];
- else // node after n1
- n = faceNodes[ i1 + 1 == nbN ? 0 : i1 + 1 ];
- if ( n == n2 )
- return adjElem;
- }
- }
- }
- return 0;
+ set<const SMDS_MeshElement*> elemSet, avoidSet;
+ if ( elem )
+ avoidSet.insert ( elem );
+ SMESH_MeshEditor::FindFaceInSet( n1, n2, elemSet, avoidSet );
}
//=======================================================================
class SMDS_MeshNode;
class gp_Ax1;
class gp_Vec;
+class gp_Pnt;
class SMESH_MeshEditor {
public:
// Generate new elements by extrusion of theElements
// by theStep by theNbSteps
+ int ExtrusionAlongTrack (std::set<const SMDS_MeshElement*> & theElements,
+ SMESH_subMesh* theTrackPattern,
+ const SMDS_MeshNode* theNodeStart,
+ const bool theHasAngles,
+ std::list<double>& theAngles,
+ const bool theHasRefPoint,
+ const gp_Pnt& theRefPoint);
+ // Generate new elements by extrusion of theElements along path given by theTrackPattern,
+ // theHasAngles are the rotation angles, base point can be given by theRefPoint
void Transform (std::set<const SMDS_MeshElement*> & theElements,
const gp_Trsf& theTrsf,
const bool theCopy);
// Move or copy theElements applying theTrsf to their nodes
-
typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
- void FindCoincidentNodes (const double theTolerance,
- TListOfListOfNodes & theGroupsOfNodes);
- // Return list of group of nodes close to each other within theTolerance
+ void FindCoincidentNodes (std::set<const SMDS_MeshNode*> & theNodes,
+ const double theTolerance,
+ TListOfListOfNodes & theGroupsOfNodes);
+ // Return list of group of nodes close to each other within theTolerance.
+ // Search among theNodes or in the whole mesh if theNodes is empty.
void MergeNodes (TListOfListOfNodes & theNodeGroups);
// In each group, the cdr of nodes are substituted by the first one
int theNodeIds[] );
// Set 8 nodes of a hexahedron in a good order.
// Return success status
-
+
+ static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
+ const SMDS_MeshElement* elemInGroups,
+ SMESHDS_Mesh * aMesh);
+ // Add elemToAdd to the groups the elemInGroups belongs to
+
+ static const SMDS_MeshElement*
+ FindFaceInSet(const SMDS_MeshNode* n1,
+ const SMDS_MeshNode* n2,
+ const std::set<const SMDS_MeshElement*>& elemSet,
+ const std::set<const SMDS_MeshElement*>& avoidSet);
+ // Return a face having linked nodes n1 and n2 and which is
+ // - not in avoidSet,
+ // - in elemSet provided that !elemSet.empty()
int FindShape (const SMDS_MeshElement * theElem);
// Return an index of the shape theElem is on
#include "SMESH_Pattern.hxx"
-#include <Bnd_Box2d.hxx>
#include <BRepTools.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <BRep_Tool.hxx>
+#include <Bnd_Box.hxx>
+#include <Bnd_Box2d.hxx>
+#include <ElSLib.hxx>
+#include <Extrema_GenExtPS.hxx>
+#include <Extrema_POnSurf.hxx>
#include <Geom2d_Curve.hxx>
+#include <GeomAdaptor_Surface.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <IntAna2d_AnaIntersection.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
+#include <gp_Ax2.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Trsf.hxx>
#include <gp_XY.hxx>
#include <gp_XYZ.hxx>
-#include <Extrema_GenExtPS.hxx>
-#include <Extrema_POnSurf.hxx>
-#include <GeomAdaptor_Surface.hxx>
#include "SMDS_EdgePosition.hxx"
#include "SMDS_FacePosition.hxx"
#include "SMDS_MeshElement.hxx"
+#include "SMDS_MeshFace.hxx"
#include "SMDS_MeshNode.hxx"
+#include "SMESHDS_Group.hxx"
#include "SMESHDS_Mesh.hxx"
#include "SMESHDS_SubMesh.hxx"
-#include "SMESH_Mesh.hxx"
#include "SMESH_Block.hxx"
+#include "SMESH_Mesh.hxx"
+#include "SMESH_MeshEditor.hxx"
#include "SMESH_subMesh.hxx"
#include "utilities.h"
template<typename T> void sortBySize( list< list < T > > & theListOfList )
{
if ( theListOfList.size() > 2 ) {
- // keep the car
- //list < T > & aFront = theListOfList.front();
- // sort the whole list
TSizeCmp< T > SizeCmp;
theListOfList.sort( SizeCmp );
}
if ( nIdIt == nodePointIDMap.end() )
{
elemPoints.push_back( iPoint );
- nodePointIDMap.insert( TNodePointIDMap::value_type( node, iPoint++ ));
+ nodePointIDMap.insert( make_pair( node, iPoint++ ));
}
else
elemPoints.push_back( (*nIdIt).second );
myKeyPointIDs.push_back( iPoint );
SMDS_NodeIteratorPtr nIt = vSubMesh->GetNodes();
const SMDS_MeshNode* node = nIt->next();
- nodePointIDMap.insert( TNodePointIDMap::value_type( node, iPoint ));
+ nodePointIDMap.insert( make_pair( node, iPoint ));
TPoint* keyPoint = &myPoints[ iPoint++ ];
vPoint.push_back( keyPoint );
TPoint* p = & myPoints[ iPoint ];
ePoints.push_back( p );
const SMDS_MeshNode* node = isForward ? (*unIt).second : (*unRIt).second;
- nodePointIDMap.insert ( TNodePointIDMap::value_type( node, iPoint ));
+ nodePointIDMap.insert ( make_pair( node, iPoint ));
if ( theProject )
p->myInitUV = project( node, projector );
myKeyPointIDs.push_back( iPoint );
SMDS_NodeIteratorPtr nIt = vSubMesh->GetNodes();
const SMDS_MeshNode* node = nIt->next();
- nodePointIDMap.insert( TNodePointIDMap::value_type( node, iPoint ));
+ nodePointIDMap.insert( make_pair( node, iPoint ));
TPoint* keyPoint = &myPoints[ iPoint++ ];
vPoint2.push_back( keyPoint );
{
const SMDS_MeshNode* node =
static_cast<const SMDS_MeshNode*>( nIt->next() );
- nodePointIDMap.insert( TNodePointIDMap::value_type( node, iPoint ));
+ nodePointIDMap.insert( make_pair( node, iPoint ));
TPoint* p = &myPoints[ iPoint++ ];
fPoints.push_back( p );
if ( theProject )
}
int nbVertices = myShapeIDMap.Extent();
- //int nbSeamShapes = 0; // count twice seam edge and its vertices
for ( elIt = eList.begin(); elIt != eList.end(); elIt++ )
myShapeIDMap.Add( *elIt );
return setErrorCode( ERR_OK );
}
+//=======================================================================
+//function : Apply
+//purpose : Compute nodes coordinates applying
+// the loaded pattern to <theFace>. The first key-point
+// will be mapped into <theNodeIndexOnKeyPoint1>-th node
+//=======================================================================
+
+bool SMESH_Pattern::Apply (const SMDS_MeshFace* theFace,
+ const int theNodeIndexOnKeyPoint1,
+ const bool theReverse)
+{
+ MESSAGE(" ::Apply(MeshFace) " );
+
+ if ( !IsLoaded() ) {
+ MESSAGE( "Pattern not loaded" );
+ return setErrorCode( ERR_APPL_NOT_LOADED );
+ }
+
+ // check nb of nodes
+ if (theFace->NbNodes() != myNbKeyPntInBoundary.front() ) {
+ MESSAGE( myKeyPointIDs.size() << " != " << theFace->NbNodes() );
+ return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
+ }
+
+ // find points on edges, it fills myNbKeyPntInBoundary
+ if ( !findBoundaryPoints() )
+ return false;
+
+ // check that there are no holes in a pattern
+ if (myNbKeyPntInBoundary.size() > 1 ) {
+ return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
+ }
+
+ // Define the nodes order
+
+ list< const SMDS_MeshNode* > nodes;
+ list< const SMDS_MeshNode* >::iterator n = nodes.end();
+ SMDS_ElemIteratorPtr noIt = theFace->nodesIterator();
+ int iSub = 0;
+ while ( noIt->more() ) {
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( noIt->next() );
+ nodes.push_back( node );
+ if ( iSub++ == theNodeIndexOnKeyPoint1 )
+ n = --nodes.end();
+ }
+ if ( n != nodes.end() ) {
+ if ( theReverse ) {
+ if ( n != --nodes.end() )
+ nodes.splice( nodes.begin(), nodes, ++n, nodes.end() );
+ nodes.reverse();
+ }
+ else if ( n != nodes.begin() )
+ nodes.splice( nodes.end(), nodes, nodes.begin(), n );
+ }
+ list< gp_XYZ > xyzList;
+ myOrderedNodes.resize( theFace->NbNodes() );
+ for ( iSub = 0, n = nodes.begin(); n != nodes.end(); ++n ) {
+ xyzList.push_back( gp_XYZ( (*n)->X(), (*n)->Y(), (*n)->Z() ));
+ myOrderedNodes[ iSub++] = *n;
+ }
+
+ // Define a face plane
+
+ list< gp_XYZ >::iterator xyzIt = xyzList.begin();
+ gp_Pnt P ( *xyzIt++ );
+ gp_Vec Vx( P, *xyzIt++ ), N;
+ do {
+ N = Vx ^ gp_Vec( P, *xyzIt++ );
+ } while ( N.SquareMagnitude() <= DBL_MIN && xyzIt != xyzList.end() );
+ if ( N.SquareMagnitude() <= DBL_MIN )
+ return setErrorCode( ERR_APPLF_BAD_FACE_GEOM );
+ gp_Ax2 pos( P, N, Vx );
+
+ // Compute UV of key-points on a plane
+ for ( xyzIt = xyzList.begin(), iSub = 1; xyzIt != xyzList.end(); xyzIt++, iSub++ )
+ {
+ gp_Vec vec ( pos.Location(), *xyzIt );
+ TPoint* p = getShapePoints( iSub ).front();
+ p->myUV.SetX( vec * pos.XDirection() );
+ p->myUV.SetY( vec * pos.YDirection() );
+ p->myXYZ = *xyzIt;
+ }
+
+ // points on edges to be used for UV computation of in-face points
+ list< list< TPoint* > > edgesPointsList;
+ edgesPointsList.push_back( list< TPoint* >() );
+ list< TPoint* > * edgesPoints = & edgesPointsList.back();
+ list< TPoint* >::iterator pIt;
+
+ // compute UV and XYZ of points on edges
+
+ for ( xyzIt = xyzList.begin(); xyzIt != xyzList.end(); iSub++ )
+ {
+ gp_XYZ& xyz1 = *xyzIt++;
+ gp_XYZ& xyz2 = ( xyzIt != xyzList.end() ) ? *xyzIt : xyzList.front();
+
+ list< TPoint* > & ePoints = getShapePoints( iSub );
+ ePoints.back()->myInitU = 1.0;
+ list< TPoint* >::const_iterator pIt = ++ePoints.begin();
+ while ( *pIt != ePoints.back() )
+ {
+ TPoint* p = *pIt++;
+ p->myXYZ = xyz1 * ( 1 - p->myInitU ) + xyz2 * p->myInitU;
+ gp_Vec vec ( pos.Location(), p->myXYZ );
+ p->myUV.SetX( vec * pos.XDirection() );
+ p->myUV.SetY( vec * pos.YDirection() );
+ }
+ // collect on-edge points (excluding the last one)
+ edgesPoints->insert( edgesPoints->end(), ePoints.begin(), --ePoints.end());
+ }
+
+ // Compute UV and XYZ of in-face points
+
+ // try to use a simple algo to compute UV
+ list< TPoint* > & fPoints = getShapePoints( iSub );
+ bool isDeformed = false;
+ for ( pIt = fPoints.begin(); !isDeformed && pIt != fPoints.end(); pIt++ )
+ if ( !compUVByIsoIntersection( edgesPointsList, (*pIt)->myInitUV,
+ (*pIt)->myUV, isDeformed )) {
+ MESSAGE("cant Apply(face)");
+ return false;
+ }
+ // try to use a complex algo if it is a difficult case
+ if ( isDeformed && !compUVByElasticIsolines( edgesPointsList, fPoints ))
+ {
+ for ( ; pIt != fPoints.end(); pIt++ ) // continue with the simple algo
+ if ( !compUVByIsoIntersection( edgesPointsList, (*pIt)->myInitUV,
+ (*pIt)->myUV, isDeformed )) {
+ MESSAGE("cant Apply(face)");
+ return false;
+ }
+ }
+
+ for ( pIt = fPoints.begin(); pIt != fPoints.end(); pIt++ )
+ {
+ (*pIt)->myXYZ = ElSLib::PlaneValue( (*pIt)->myUV.X(), (*pIt)->myUV.Y(), pos );
+ }
+
+ myIsComputed = true;
+
+ return setErrorCode( ERR_OK );
+}
+
+//=======================================================================
+//function : undefinedXYZ
+//purpose :
+//=======================================================================
+
+static const gp_XYZ& undefinedXYZ()
+{
+ static gp_XYZ xyz( 1.e100, 0., 0. );
+ return xyz;
+}
+
+//=======================================================================
+//function : isDefined
+//purpose :
+//=======================================================================
+
+inline static bool isDefined(const gp_XYZ& theXYZ)
+{
+ return theXYZ.X() < 1.e100;
+}
+
+//=======================================================================
+//function : mergePoints
+//purpose : Look for coincident points between myXYZs indexed with
+// list<int> of each element of xyzIndGroups. Coincident indices
+// are merged in myElemXYZIDs.
+//=======================================================================
+
+void SMESH_Pattern::mergePoints (map<TNodeSet, list<list<int> > >& indGroups,
+ map< int, list< list< int >* > > & reverseConnectivity)
+{
+ map< TNodeSet, list< list< int > > >::iterator indListIt;
+ for ( indListIt = indGroups.begin(); indListIt != indGroups.end(); indListIt++ )
+ {
+ list<list< int > > groups = indListIt->second;
+ if ( groups.size() < 2 )
+ continue;
+
+// const TNodeSet & nodes = indListIt->first;
+// TNodeSet::const_iterator n = nodes.begin();
+// for ( ; n != nodes.end(); n++ )
+// cout << *n ;
+
+ // find tolerance
+ Bnd_Box box;
+ list< int >& indices = groups.front();
+ list< int >::iterator ind, ind1, ind2;
+ for ( ind = indices.begin(); ind != indices.end(); ind++ )
+ box.Add( gp_Pnt( myXYZ[ *ind ]));
+ double x, y, z, X, Y, Z;
+ box.Get( x, y, z, X, Y, Z );
+ gp_Pnt p( x, y, z ), P( X, Y, Z );
+ double tol2 = 1.e-4 * p.SquareDistance( P );
+
+ // compare points, replace indices
+
+ list< list< int > >::iterator grpIt1, grpIt2;
+ for ( grpIt1 = groups.begin(); grpIt1 != groups.end(); grpIt1++ )
+ {
+ list< int >& indices1 = *grpIt1;
+ grpIt2 = grpIt1;
+ for ( grpIt2++; grpIt2 != groups.end(); grpIt2++ )
+ {
+ list< int >& indices2 = *grpIt2;
+ for ( ind1 = indices1.begin(); ind1 != indices1.end(); ind1++ )
+ {
+ gp_XYZ& p1 = myXYZ[ *ind1 ];
+ ind2 = indices2.begin();
+ while ( ind2 != indices2.end() )
+ {
+ gp_XYZ& p2 = myXYZ[ *ind2 ];
+ //MESSAGE("COMP: " << *ind1 << " " << *ind2 << " X: " << p2.X() << " tol2: " << tol2);
+ if ( ( p1 - p2 ).SquareModulus() <= tol2 )
+ {
+ ASSERT( reverseConnectivity.find( *ind2 ) != reverseConnectivity.end() );
+ list< list< int >* > & elemXYZIDsList = reverseConnectivity[ *ind2 ];
+ list< list< int >* >::iterator elemXYZIDs = elemXYZIDsList.begin();
+ for ( ; elemXYZIDs != elemXYZIDsList.end(); elemXYZIDs++ )
+ {
+ ind = find( (*elemXYZIDs)->begin(), (*elemXYZIDs)->end(), *ind2 );
+ //MESSAGE( " Replace " << *ind << " with " << *ind1 );
+ myXYZ[ *ind ] = undefinedXYZ();
+ *ind = *ind1;
+ }
+ ind2 = indices2.erase( ind2 );
+ }
+ else
+ ind2++;
+ }
+ }
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : Apply
+//purpose : Compute nodes coordinates applying
+// the loaded pattern to <theFaces>. The first key-point
+// will be mapped into <theNodeIndexOnKeyPoint1>-th node
+//=======================================================================
+
+bool SMESH_Pattern::Apply (std::set<const SMDS_MeshFace*> theFaces,
+ const int theNodeIndexOnKeyPoint1,
+ const bool theReverse)
+{
+ MESSAGE(" ::Apply(set<MeshFace>) " );
+
+ if ( !IsLoaded() ) {
+ MESSAGE( "Pattern not loaded" );
+ return setErrorCode( ERR_APPL_NOT_LOADED );
+ }
+
+ // find points on edges, it fills myNbKeyPntInBoundary
+ if ( !findBoundaryPoints() )
+ return false;
+
+ // check that there are no holes in a pattern
+ if (myNbKeyPntInBoundary.size() > 1 ) {
+ return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
+ }
+
+ myXYZ.clear();
+ myElemXYZIDs.clear();
+ myXYZIdToNodeMap.clear();
+ myElements.clear();
+
+ myXYZ.resize( myPoints.size() * theFaces.size(), undefinedXYZ() );
+ myElements.reserve( theFaces.size() );
+
+ // to find point index
+ map< TPoint*, int > pointIndex;
+ for ( int i = 0; i < myPoints.size(); i++ )
+ pointIndex.insert( make_pair( & myPoints[ i ], i ));
+
+ // to merge nodes on edges of the elements being refined
+ typedef set<const SMDS_MeshNode*> TLink;
+ map< TLink, list< list< int > > > linkPointIndListMap;
+ map< int, list< list< int >* > > reverseConnectivity;
+
+ int ind1 = 0; // lowest point index for a face
+
+ // apply to each face in theFaces set
+ set<const SMDS_MeshFace*>::iterator face = theFaces.begin();
+ for ( ; face != theFaces.end(); ++face )
+ {
+ if ( !Apply( *face, theNodeIndexOnKeyPoint1, theReverse )) {
+ MESSAGE( "Failed on " << *face );
+ continue;
+ }
+ myElements.push_back( *face );
+
+ // store computed points belonging to elements
+ list< list< int > >::iterator ll = myElemPointIDs.begin();
+ for ( ; ll != myElemPointIDs.end(); ++ll )
+ {
+ myElemXYZIDs.push_back();
+ list< int >& xyzIds = myElemXYZIDs.back();
+ list< int >& pIds = *ll;
+ for ( list<int>::iterator id = pIds.begin(); id != pIds.end(); id++ ) {
+ int pIndex = *id + ind1;
+ xyzIds.push_back( pIndex );
+ myXYZ[ pIndex ] = myPoints[ *id ].myXYZ.XYZ();
+ reverseConnectivity[ pIndex ].push_back( & xyzIds );
+ }
+ }
+ // put points on links to linkPointIndListMap
+ int nbNodes = (*face)->NbNodes(), eID = nbNodes + 1;
+ for ( int i = 0; i < nbNodes; i++ )
+ {
+ const SMDS_MeshNode* n1 = myOrderedNodes[ i ];
+ const SMDS_MeshNode* n2 = myOrderedNodes[ i + 1 == nbNodes ? 0 : i + 1 ];
+ // make a link of node pointers
+ TLink link;
+ link.insert( n1 );
+ link.insert( n2 );
+ // add the link to the map
+ list< list< int > >& groups = linkPointIndListMap[ link ];
+ groups.push_back();
+ list< int >& indList = groups.back();
+ list< TPoint* > & linkPoints = getShapePoints( eID++ );
+ list< TPoint* >::iterator p = linkPoints.begin();
+ // map the first link point to n1
+ myXYZIdToNodeMap[ pointIndex[ *p ] + ind1 ] = n1;
+ // add points to the map excluding the end points
+ for ( p++; *p != linkPoints.back(); p++ )
+ indList.push_back( pointIndex[ *p ] + ind1 );
+ }
+ ind1 += myPoints.size();
+ }
+
+ mergePoints( linkPointIndListMap, reverseConnectivity );
+
+ return !myElemXYZIDs.empty();
+}
+
+//=======================================================================
+//function : Apply
+//purpose : Compute nodes coordinates applying
+// the loaded pattern to <theVolumes>. The (0,0,0) key-point
+// will be mapped into <theNode000Index>-th node. The
+// (0,0,1) key-point will be mapped into <theNode000Index>-th
+// node.
+//=======================================================================
+
+bool SMESH_Pattern::Apply (std::set<const SMDS_MeshVolume*> theVolumes,
+ const int theNode000Index,
+ const int theNode001Index)
+{
+ MESSAGE(" ::Apply(set<MeshVolumes>) " );
+
+ if ( !IsLoaded() ) {
+ MESSAGE( "Pattern not loaded" );
+ return setErrorCode( ERR_APPL_NOT_LOADED );
+ }
+
+ // bind ID to points
+ if ( !findBoundaryPoints() )
+ return false;
+
+ // check that there are no holes in a pattern
+ if (myNbKeyPntInBoundary.size() > 1 ) {
+ return setErrorCode( ERR_APPL_BAD_NB_VERTICES );
+ }
+
+ myXYZ.clear();
+ myElemXYZIDs.clear();
+ myXYZIdToNodeMap.clear();
+ myElements.clear();
+
+ myXYZ.resize( myPoints.size() * theVolumes.size(), undefinedXYZ() );
+ myElements.reserve( theVolumes.size() );
+
+ // to find point index
+ map< TPoint*, int > pointIndex;
+ for ( int i = 0; i < myPoints.size(); i++ )
+ pointIndex.insert( make_pair( & myPoints[ i ], i ));
+
+ // to merge nodes on edges and faces of the elements being refined
+ map< TNodeSet, list< list< int > > > subPointIndListMap;
+ map< int, list< list< int >* > > reverseConnectivity;
+
+ int ind1 = 0; // lowest point index for an element
+
+ // apply to each element in theVolumes set
+ set<const SMDS_MeshVolume*>::iterator vol = theVolumes.begin();
+ for ( ; vol != theVolumes.end(); ++vol )
+ {
+ if ( !Apply( *vol, theNode000Index, theNode001Index )) {
+ MESSAGE( "Failed on " << *vol );
+ continue;
+ }
+ myElements.push_back( *vol );
+
+ // store computed points belonging to elements
+ list< list< int > >::iterator ll = myElemPointIDs.begin();
+ for ( ; ll != myElemPointIDs.end(); ++ll )
+ {
+ myElemXYZIDs.push_back();
+ list< int >& xyzIds = myElemXYZIDs.back();
+ list< int >& pIds = *ll;
+ for ( list<int>::iterator id = pIds.begin(); id != pIds.end(); id++ ) {
+ int pIndex = *id + ind1;
+ xyzIds.push_back( pIndex );
+ myXYZ[ pIndex ] = myPoints[ *id ].myXYZ.XYZ();
+ reverseConnectivity[ pIndex ].push_back( & xyzIds );
+ }
+ }
+ // put points on edges and faces to subPointIndListMap
+ for ( int Id = SMESH_Block::ID_V000; Id <= SMESH_Block::ID_F1yz; Id++ )
+ {
+ // make a set of sub-points
+ TNodeSet subNodes;
+ vector< int > subIDs;
+ if ( SMESH_Block::IsVertexID( Id )) {
+ // use nodes of refined volumes for merge
+ }
+ else if ( SMESH_Block::IsEdgeID( Id )) {
+ SMESH_Block::GetEdgeVertexIDs( Id, subIDs );
+ subNodes.insert( myOrderedNodes[ subIDs.front() - 1 ]);
+ subNodes.insert( myOrderedNodes[ subIDs.back() - 1 ]);
+ }
+ else {
+ SMESH_Block::GetFaceEdgesIDs( Id, subIDs );
+ int e1 = subIDs[ 0 ], e2 = subIDs[ 1 ];
+ SMESH_Block::GetEdgeVertexIDs( e1, subIDs );
+ subNodes.insert( myOrderedNodes[ subIDs.front() - 1 ]);
+ subNodes.insert( myOrderedNodes[ subIDs.back() - 1 ]);
+ SMESH_Block::GetEdgeVertexIDs( e2, subIDs );
+ subNodes.insert( myOrderedNodes[ subIDs.front() - 1 ]);
+ subNodes.insert( myOrderedNodes[ subIDs.back() - 1 ]);
+ }
+ list< list< int > >& groups = subPointIndListMap[ subNodes ];
+ groups.push_back();
+ list< int >& indList = groups.back();
+ // add points
+ list< TPoint* > & points = getShapePoints( Id );
+ list< TPoint* >::iterator p = points.begin();
+ if ( subNodes.empty() ) // vertex case
+ myXYZIdToNodeMap[ pointIndex[ *p ] + ind1 ] = myOrderedNodes[ Id - 1 ];
+ else
+ for ( ; p != points.end(); p++ )
+ indList.push_back( pointIndex[ *p ] + ind1 );
+ }
+ ind1 += myPoints.size();
+ }
+
+ mergePoints( subPointIndListMap, reverseConnectivity );
+
+ return !myElemXYZIDs.empty();
+}
+
//=======================================================================
//function : Load
//purpose : Create a pattern from the mesh built on <theBlock>
// store a node and a point
while ( nIt->more() ) {
const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nIt->next() );
- nodePointIDMap.insert( TNodePointIDMap::value_type( node, iPoint ));
+ nodePointIDMap.insert( make_pair( node, iPoint ));
if ( block.IsVertexID( shapeID ))
myKeyPointIDs.push_back( iPoint );
TPoint* p = & myPoints[ iPoint++ ];
return setErrorCode( ERR_OK );
}
+//=======================================================================
+//function : Apply
+//purpose : Compute nodes coordinates applying
+// the loaded pattern to <theVolume>. The (0,0,0) key-point
+// will be mapped into <theNode000Index>-th node. The
+// (0,0,1) key-point will be mapped into <theNode000Index>-th
+// node.
+//=======================================================================
+
+bool SMESH_Pattern::Apply (const SMDS_MeshVolume* theVolume,
+ const int theNode000Index,
+ const int theNode001Index)
+{
+ MESSAGE(" ::Apply(MeshVolume) " );
+
+ if (!findBoundaryPoints()) // bind ID to points
+ return false;
+
+ SMESH_Block block; // bind ID to shape
+ if (!block.LoadMeshBlock( theVolume, theNode000Index, theNode001Index, myOrderedNodes ))
+ return setErrorCode( ERR_APPLV_BAD_SHAPE );
+ // compute XYZ of points on shapes
+
+ for ( int ID = SMESH_Block::ID_V000; ID <= SMESH_Block::ID_Shell; ID++ )
+ {
+ list< TPoint* > & shapePoints = getShapePoints( ID );
+ list< TPoint* >::iterator pIt = shapePoints.begin();
+
+ if ( block.IsVertexID( ID ))
+ for ( ; pIt != shapePoints.end(); pIt++ ) {
+ block.VertexPoint( ID, (*pIt)->myXYZ.ChangeCoord() );
+ }
+ else if ( block.IsEdgeID( ID ))
+ for ( ; pIt != shapePoints.end(); pIt++ ) {
+ block.EdgePoint( ID, (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() );
+ }
+ else if ( block.IsFaceID( ID ))
+ for ( ; pIt != shapePoints.end(); pIt++ ) {
+ block.FacePoint( ID, (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() );
+ }
+ else
+ for ( ; pIt != shapePoints.end(); pIt++ )
+ block.ShellPoint( (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() );
+ } // loop on block sub-shapes
+
+ myIsComputed = true;
+
+ return setErrorCode( ERR_OK );
+}
+
//=======================================================================
//function : MakeMesh
//purpose : Create nodes and elements in <theMesh> using nodes
return setErrorCode( ERR_MAKEM_NOT_COMPUTED );
SMESHDS_Mesh* aMeshDS = theMesh->GetMeshDS();
+ SMESH_MeshEditor editor( theMesh );
// clear elements and nodes existing on myShape
- SMESH_subMesh * aSubMesh = theMesh->GetSubMeshContaining( myShape );
- SMESHDS_SubMesh * aSubMeshDS = aMeshDS->MeshElements( myShape );
- if ( aSubMesh )
- aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEAN );
- else if ( aSubMeshDS )
+
+ if ( !myShape.IsNull() )
{
- SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements();
- while ( eIt->more() )
- aMeshDS->RemoveElement( eIt->next() );
- SMDS_NodeIteratorPtr nIt = aSubMeshDS->GetNodes();
- while ( nIt->more() )
- aMeshDS->RemoveNode( static_cast<const SMDS_MeshNode*>( nIt->next() ));
+ SMESH_subMesh * aSubMesh = theMesh->GetSubMeshContaining( myShape );
+ SMESHDS_SubMesh * aSubMeshDS = aMeshDS->MeshElements( myShape );
+ if ( aSubMesh )
+ aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEAN );
+ else if ( aSubMeshDS )
+ {
+ SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements();
+ while ( eIt->more() )
+ aMeshDS->RemoveElement( eIt->next() );
+ SMDS_NodeIteratorPtr nIt = aSubMeshDS->GetNodes();
+ while ( nIt->more() )
+ aMeshDS->RemoveNode( static_cast<const SMDS_MeshNode*>( nIt->next() ));
+ }
}
+ bool onMeshElements = ( !myElements.empty() );
+
// loop on sub-shapes of myShape: create nodes and build point-node map
- typedef map< TPoint*, const SMDS_MeshNode* > TPointNodeMap;
- TPointNodeMap pointNodeMap;
- map< int, list< TPoint* > >::iterator idPointIt = myShapeIDToPointsMap.begin();
- for ( ; idPointIt != myShapeIDToPointsMap.end(); idPointIt++ )
+
+ vector< const SMDS_MeshNode* > nodesVector;
+ map< TPoint*, const SMDS_MeshNode* > pointNodeMap;
+ if ( onMeshElements )
+ {
+ nodesVector.resize( myXYZ.size() );
+ for ( int i = 0; i < myXYZ.size(); ++i ) {
+ map< int, const SMDS_MeshNode*>::iterator idNode = myXYZIdToNodeMap.find( i );
+ if ( idNode != myXYZIdToNodeMap.end() )
+ nodesVector[ i ] = idNode->second;
+ else if ( isDefined( myXYZ[ i ] ))
+ nodesVector[ i ] = aMeshDS->AddNode (myXYZ[ i ].X(),
+ myXYZ[ i ].Y(),
+ myXYZ[ i ].Z());
+ }
+ }
+ else
{
- const TopoDS_Shape & S = myShapeIDMap( (*idPointIt).first );
- list< TPoint* > & points = (*idPointIt).second;
- SMESHDS_SubMesh * subMeshDS = aMeshDS->MeshElements( S );
- SMESH_subMesh * subMesh = theMesh->GetSubMeshContaining( myShape );
- list< TPoint* >::iterator pIt = points.begin();
- for ( ; pIt != points.end(); pIt++ )
+ map< int, list< TPoint* > >::iterator idPointIt = myShapeIDToPointsMap.begin();
+ for ( ; idPointIt != myShapeIDToPointsMap.end(); idPointIt++ )
{
- TPoint* point = *pIt;
- if ( pointNodeMap.find( point ) != pointNodeMap.end() )
- continue;
- SMDS_MeshNode* node = aMeshDS->AddNode (point->myXYZ.X(),
- point->myXYZ.Y(),
- point->myXYZ.Z());
- pointNodeMap.insert( TPointNodeMap::value_type( point, node ));
- if ( subMeshDS ) {
- switch ( S.ShapeType() ) {
- case TopAbs_VERTEX: {
- aMeshDS->SetNodeOnVertex( node, TopoDS::Vertex( S ));
- break;
- }
- case TopAbs_EDGE: {
- aMeshDS->SetNodeOnEdge( node, TopoDS::Edge( S ));
- SMDS_EdgePosition* epos =
- dynamic_cast<SMDS_EdgePosition *>(node->GetPosition().get());
- epos->SetUParameter( point->myU );
- break;
- }
- case TopAbs_FACE: {
- aMeshDS->SetNodeOnFace( node, TopoDS::Face( S ));
- SMDS_FacePosition* pos =
- dynamic_cast<SMDS_FacePosition *>(node->GetPosition().get());
- pos->SetUParameter( point->myUV.X() );
- pos->SetVParameter( point->myUV.Y() );
- break;
- }
- default:
- aMeshDS->SetNodeInVolume( node, TopoDS::Shell( S ));
+ TopoDS_Shape S;
+ SMESHDS_SubMesh * subMeshDS = 0;
+ if ( !myShapeIDMap.IsEmpty() ) {
+ S = myShapeIDMap( idPointIt->first );
+ subMeshDS = aMeshDS->MeshElements( S );
+ }
+ list< TPoint* > & points = idPointIt->second;
+ list< TPoint* >::iterator pIt = points.begin();
+ for ( ; pIt != points.end(); pIt++ )
+ {
+ TPoint* point = *pIt;
+ if ( pointNodeMap.find( point ) != pointNodeMap.end() )
+ continue;
+ SMDS_MeshNode* node = aMeshDS->AddNode (point->myXYZ.X(),
+ point->myXYZ.Y(),
+ point->myXYZ.Z());
+ pointNodeMap.insert( make_pair( point, node ));
+ if ( subMeshDS ) {
+ switch ( S.ShapeType() ) {
+ case TopAbs_VERTEX: {
+ aMeshDS->SetNodeOnVertex( node, TopoDS::Vertex( S ));
+ break;
+ }
+ case TopAbs_EDGE: {
+ aMeshDS->SetNodeOnEdge( node, TopoDS::Edge( S ));
+ SMDS_EdgePosition* epos =
+ dynamic_cast<SMDS_EdgePosition *>(node->GetPosition().get());
+ epos->SetUParameter( point->myU );
+ break;
+ }
+ case TopAbs_FACE: {
+ aMeshDS->SetNodeOnFace( node, TopoDS::Face( S ));
+ SMDS_FacePosition* pos =
+ dynamic_cast<SMDS_FacePosition *>(node->GetPosition().get());
+ pos->SetUParameter( point->myUV.X() );
+ pos->SetVParameter( point->myUV.Y() );
+ break;
+ }
+ default:
+ aMeshDS->SetNodeInVolume( node, TopoDS::Shell( S ));
+ }
}
}
}
- // make that SMESH_subMesh::_computeState = COMPUTE_OK
- // so that operations with hypotheses will erase the mesh
- // being built
- if ( subMesh )
- subMesh->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
}
-
+
// create elements
- list<list< int > >::iterator epIt = myElemPointIDs.begin();
- for ( ; epIt != myElemPointIDs.end(); epIt++ )
+
+ // shapes and groups myElements are on
+ vector< int > shapeIDs;
+ vector< list< SMESHDS_Group* > > groups;
+ if ( onMeshElements )
+ {
+ shapeIDs.resize( myElements.size() );
+ groups.resize( myElements.size() );
+ const set<SMESHDS_GroupBase*>& allGroups = aMeshDS->GetGroups();
+ set<SMESHDS_GroupBase*>::const_iterator grIt;
+ for ( int i = 0; i < myElements.size(); i++ )
+ {
+ shapeIDs[ i ] = editor.FindShape( myElements[ i ] );
+ for ( grIt = allGroups.begin(); grIt != allGroups.end(); grIt++ ) {
+ SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
+ if ( group && group->SMDSGroup().Contains( myElements[ i ] ))
+ groups[ i ].push_back( group );
+ }
+ }
+ }
+ int nbElems = myElemPointIDs.size(); // nb elements in a pattern
+
+ list<list< int > >::iterator epIt, epEnd;
+ if ( onMeshElements ) {
+ epIt = myElemXYZIDs.begin();
+ epEnd = myElemXYZIDs.end();
+ }
+ else {
+ epIt = myElemPointIDs.begin();
+ epEnd = myElemPointIDs.end();
+ }
+ for ( int iElem = 0; epIt != epEnd; epIt++, iElem++ )
{
list< int > & elemPoints = *epIt;
// retrieve nodes
list< int >::iterator iIt = elemPoints.begin();
int nbNodes;
for ( nbNodes = 0; iIt != elemPoints.end(); iIt++ ) {
- nodes[ nbNodes++ ] = pointNodeMap[ & myPoints[ *iIt ]];
+ if ( onMeshElements )
+ nodes[ nbNodes++ ] = nodesVector[ *iIt ];
+ else
+ nodes[ nbNodes++ ] = pointNodeMap[ & myPoints[ *iIt ]];
}
// add an element
const SMDS_MeshElement* elem = 0;
elem = aMeshDS->AddFace( nodes[0], nodes[1], nodes[2] ); break;
case 4:
elem = aMeshDS->AddFace( nodes[0], nodes[1], nodes[2], nodes[3] ); break;
- default:;
+ default:
+ ASSERT( nbNodes < 8 );
}
}
else {
case 8:
elem = aMeshDS->AddVolume (nodes[0], nodes[1], nodes[2], nodes[3],
nodes[4], nodes[5], nodes[6], nodes[7] ); break;
- default:;
+ default:
+ ASSERT( nbNodes < 8 );
}
}
- if ( elem )
+ // set element on a shape
+ if ( elem && onMeshElements )
+ {
+ int elemIndex = iElem / nbElems;
+ if ( shapeIDs[ elemIndex ] > 0 )
+ aMeshDS->SetMeshElementOnShape( elem, shapeIDs[ elemIndex ] );
+ // add elem in groups
+ list< SMESHDS_Group* >::iterator g = groups[ elemIndex ].begin();
+ for ( ; g != groups[ elemIndex ].end(); ++g )
+ (*g)->SMDSGroup().Add( elem );
+ }
+ if ( elem && !myShape.IsNull() )
aMeshDS->SetMeshElementOnShape( elem, myShape );
}
+ // make that SMESH_subMesh::_computeState = COMPUTE_OK
+ // so that operations with hypotheses will erase the mesh being built
+
+ SMESH_subMesh * subMesh;
+ if ( !myShape.IsNull() ) {
+ subMesh = theMesh->GetSubMeshContaining( myShape );
+ if ( subMesh )
+ subMesh->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
+ }
+ if ( onMeshElements ) {
+ list< int > elemIDs;
+ for ( int i = 0; i < myElements.size(); i++ )
+ {
+ int shapeID = shapeIDs[ i ];
+ if ( shapeID > 0 ) {
+ TopoDS_Shape S = aMeshDS->IndexToShape( shapeID );
+ subMesh = theMesh->GetSubMeshContaining( S );
+ if ( subMesh )
+ subMesh->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
+ }
+ elemIDs.push_back( myElements[ i ]->GetID() );
+ }
+ // remove refined elements and their nodes
+ editor.Remove( elemIDs, false );
+ }
+
return setErrorCode( ERR_OK );
}
double edgeLength = 0;
list< TPoint* >::iterator pIt = boundary->begin();
getShapePoints( edgeID ).push_back( *pIt );
+ getShapePoints( vertexID++ ).push_back( *pIt );
for ( pIt++; pIt != boundary->end(); pIt++)
{
list< TPoint* > & edgePoints = getShapePoints( edgeID );
}
// begin the next edge treatment
edgeLength = 0;
- getShapePoints( vertexID++ ).push_back( point );
edgeID++;
- if ( point != boundary->front() )
+ if ( point != boundary->front() ) { // not the first key-point again
getShapePoints( edgeID ).push_back( point );
+ getShapePoints( vertexID++ ).push_back( point );
+ }
}
}
}
//purpose : Return nodes coordinates computed by Apply() method
//=======================================================================
-bool SMESH_Pattern::GetMappedPoints ( list< const gp_XYZ * > & thePoints )
+bool SMESH_Pattern::GetMappedPoints ( list< const gp_XYZ * > & thePoints ) const
{
thePoints.clear();
if ( !myIsComputed )
return false;
- vector< TPoint >::iterator pVecIt = myPoints.begin();
- for ( ; pVecIt != myPoints.end(); pVecIt++ )
- thePoints.push_back( & (*pVecIt).myXYZ.XYZ() );
-
- return ( thePoints.size() > 0 );
+ if ( myElements.empty() ) { // applied to shape
+ vector< TPoint >::const_iterator pVecIt = myPoints.begin();
+ for ( ; pVecIt != myPoints.end(); pVecIt++ )
+ thePoints.push_back( & (*pVecIt).myXYZ.XYZ() );
+ }
+ else { // applied to mesh elements
+ vector<gp_XYZ>::const_iterator xyz = myXYZ.begin();
+ for ( ; xyz != myXYZ.end(); ++xyz )
+ thePoints.push_back( & (*xyz) );
+ }
+ return !thePoints.empty();
}
#include <vector>
#include <list>
#include <map>
+#include <set>
#include <iostream>
#include <TopoDS_Shape.hxx>
#include <gp_XY.hxx>
#include <gp_Pnt.hxx>
+class SMDS_MeshElement;
+class SMDS_MeshFace;
+class SMDS_MeshVolume;
+class SMDS_MeshNode;
class SMESH_Mesh;
class TopoDS_Shell;
class TopoDS_Vertex;
// clear fields
bool Load (const char* theFileContents);
- // Load a pattern from <theFile>
+ // Load a pattern from <theFileContents>
bool Load (SMESH_Mesh* theMesh,
const TopoDS_Face& theFace,
// will be mapped into <theVertex000>. The
// (0,0,1) key-point will be mapped into <theVertex001>.
- bool GetMappedPoints ( std::list<const gp_XYZ *> & thePoints );
+ bool Apply (const SMDS_MeshFace* theFace,
+ const int theNodeIndexOnKeyPoint1,
+ const bool theReverse);
+ // Compute nodes coordinates applying
+ // the loaded pattern to <theFace>. The first key-point
+ // will be mapped into <theNodeIndexOnKeyPoint1>-th node
+
+ bool Apply (std::set<const SMDS_MeshFace*> theFaces,
+ const int theNodeIndexOnKeyPoint1,
+ const bool theReverse);
+ // Compute nodes coordinates applying
+ // the loaded pattern to <theFaces>. The first key-point
+ // will be mapped into <theNodeIndexOnKeyPoint1>-th node
+
+ bool Apply (const SMDS_MeshVolume* theVolume,
+ const int theNode000Index,
+ const int theNode001Index);
+ // Compute nodes coordinates applying
+ // the loaded pattern to <theVolume>. The (0,0,0) key-point
+ // will be mapped into <theNode000Index>-th node. The
+ // (0,0,1) key-point will be mapped into <theNode000Index>-th
+ // node.
+
+ bool Apply (std::set<const SMDS_MeshVolume*> theVolumes,
+ const int theNode000Index,
+ const int theNode001Index);
+ // Compute nodes coordinates applying
+ // the loaded pattern to <theVolumes>. The (0,0,0) key-point
+ // will be mapped into <theNode000Index>-th node. The
+ // (0,0,1) key-point will be mapped into <theNode000Index>-th
+ // node.
+
+ bool GetMappedPoints ( std::list<const gp_XYZ *> & thePoints ) const;
// Return nodes coordinates computed by Apply() method
bool MakeMesh(SMESH_Mesh* theMesh);
ERR_APPLF_INTERNAL_EEROR, // program error
// Apply(volume)
ERR_APPLV_BAD_SHAPE, // volume is not a brick of 6 faces
+ // Apply(mesh_face)
+ ERR_APPLF_BAD_FACE_GEOM, // bad face geometry
// MakeMesh
ERR_MAKEM_NOT_COMPUTED // mapping failed
};
// GetPoints() and GetMappedPoints()
const std::list< std::list< int > >& GetElementPointIDs () const
- { return myElemPointIDs; }
+ { return myElemXYZIDs.empty() ? myElemPointIDs : myElemXYZIDs; }
// Return nodal connectivity of the elements of the pattern
void DumpPoints() const;
// of boundaries; after sorting, edges in the wires are put
// in a good order, point UVs on edges are computed and points
// are appended to theEdgesPointsList
-
+
+ typedef std::set<const SMDS_MeshNode*> TNodeSet;
+ void mergePoints (std::map<TNodeSet,std::list<std::list<int> > >& xyzIndGroups,
+ std::map< int, std::list< std::list< int >* > >& reverseConnectivity);
+ // Look for coincident points between myXYZs indexed with
+ // list<int> of each element of xyzIndGroups. Coincident indices
+ // are merged in myElemXYZIDs using reverseConnectivity.
+
private:
// fields
TopoDS_Shape myShape;
// all functions assure that shapes are indexed so that first go
- // ordered vertices, then ordered edge, then faces and a shell
+ // ordered vertices, then ordered edge, then faces and maybe a shell
TopTools_IndexedMapOfOrientedShape myShapeIDMap;
//TopTools_IndexedMapOfShape myShapeIDMap;
std::map< int, list< TPoint* > > myShapeIDToPointsMap;
- std::list< int > myNbKeyPntInBoundary; //for the 2d case
+ // for the 2d case:
+ // nb of key-points in each of pattern boundaries
+ std::list< int > myNbKeyPntInBoundary;
+
+ // to compute while applying to mesh elements, not to shapes
+ std::vector<gp_XYZ> myXYZ;
+ std::list< std::list< int > > myElemXYZIDs;
+ std::map< int, const SMDS_MeshNode*> myXYZIdToNodeMap; // map id to node of a refined element
+ std::vector<const SMDS_MeshElement*> myElements; // refined elements
+ std::vector<const SMDS_MeshNode*> myOrderedNodes;
};
#include <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
+#include <map>
//Not portable see http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#5_4 to know more.
#ifdef __GNUC__
bool HasMeshElements(const TopoDS_Shape & S);
SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S);
SMESHDS_SubMesh * MeshElements(const int Index);
- list<int> SubMeshIndices();
+ std::list<int> SubMeshIndices();
const std::map<int,SMESHDS_SubMesh*>& SubMeshes()
{ return myShapeIndexToSubMesh; }
bool HasHypothesis(const TopoDS_Shape & S);
- const list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
+ const std::list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
SMESHDS_Script * GetScript();
void ClearScript();
int ShapeToIndex(const TopoDS_Shape & aShape);
void AddGroup (SMESHDS_GroupBase* theGroup) { myGroups.insert(theGroup); }
void RemoveGroup (SMESHDS_GroupBase* theGroup) { myGroups.erase(theGroup); }
int GetNbGroups() const { return myGroups.size(); }
- const set<SMESHDS_GroupBase*>& GetGroups() const { return myGroups; }
+ const std::set<SMESHDS_GroupBase*>& GetGroups() const { return myGroups; }
bool IsGroupOfSubShapes (const TopoDS_Shape& aSubShape) const;
int myMeshID;
TopoDS_Shape myShape;
TopTools_IndexedMapOfShape myIndexToShape;
- map<int,SMESHDS_SubMesh*> myShapeIndexToSubMesh;
- set<SMESHDS_GroupBase*> myGroups;
+ std::map<int,SMESHDS_SubMesh*> myShapeIndexToSubMesh;
+ std::set<SMESHDS_GroupBase*> myGroups;
SMESHDS_Script* myScript;
};
SMESHGUI_SmoothingDlg.cxx \
SMESHGUI_RenumberingDlg.cxx \
SMESHGUI_ExtrusionDlg.cxx \
+ SMESHGUI_ExtrusionAlongPathDlg.cxx \
SMESHGUI_RevolutionDlg.cxx \
SMESHGUI_RotationDlg.cxx \
SMESHGUI_TranslationDlg.cxx \
SMESHGUI_SmoothingDlg.h \
SMESHGUI_RenumberingDlg.h \
SMESHGUI_ExtrusionDlg.h \
+ SMESHGUI_ExtrusionAlongPathDlg.h \
SMESHGUI_RevolutionDlg.h \
SMESHGUI_RotationDlg.h \
SMESHGUI_TranslationDlg.h \
#BIN = SMESHBin
CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \
- $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \
+ -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \
$(BOOST_CPPFLAGS)
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome
#include "SMESHGUI_SmoothingDlg.h"
#include "SMESHGUI_RenumberingDlg.h"
#include "SMESHGUI_ExtrusionDlg.h"
+#include "SMESHGUI_ExtrusionAlongPathDlg.h"
#include "SMESHGUI_RevolutionDlg.h"
#include "SMESHGUI_TranslationDlg.h"
#include "SMESHGUI_RotationDlg.h"
void ExportMeshToFile(QAD_Desktop * parent, int theCommandID);
- void SetViewMode(int theCommandID);
+ void SetDisplayMode(int theCommandID);
+
+ void SetDisplayEntity(int theCommandID);
void Control( int theCommandID );
SMESH::SMESH_Gen_ptr theComponentMesh,
int theCommandID)
{
- QString filter;
+ QStringList filter;
string myExtension;
if(theCommandID == 113){
- filter = QObject::tr("MED files (*.med)");
+ filter.append(QObject::tr("MED files (*.med)"));
+ filter.append(QObject::tr("All files (*)"));
}else if (theCommandID == 112){
- filter = QObject::tr("IDEAS files (*.unv)");
+ filter.append(QObject::tr("IDEAS files (*.unv)"));
}else if (theCommandID == 111){
- filter = QObject::tr("DAT files (*.dat)");
+ filter.append(QObject::tr("DAT files (*.dat)"));
}
QString filename = QAD_FileDlg::getFileName(parent,
"",
SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
if ( !aMesh->_is_nil() ) {
QString aFilter, aTitle = QObject::tr("Export mesh");
+ QMap<QString, SMESH::MED_VERSION> aFilterMap;
switch ( theCommandID ) {
case 122:
- aFilter = QObject::tr("MED files (*.med)");
+ aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
+ aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
break;
case 121:
aFilter = QObject::tr("DAT files (*.dat)");
return;
}}
- QString aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
+ QString aFilename;
+ SMESH::MED_VERSION aFormat;
+
+ if ( theCommandID != 122)
+ aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
+ else
+ {
+ QStringList filters;
+ for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
+ filters.push_back( it.key() );
+
+ QAD_FileDlg* fd = new QAD_FileDlg( parent, false, true, true );
+ fd->setCaption( aTitle );
+ fd->setFilters( filters );
+ fd->exec();
+ aFilename = fd->selectedFile();
+ aFormat = aFilterMap[fd->selectedFilter()];
+ delete fd;
+ }
if ( !aFilename.isEmpty() ) {
// Check whether the file already exists and delete it if yes
QFile aFile( aFilename );
QAD_WaitCursor wc;
switch ( theCommandID ) {
case 122:
- aMesh->ExportMED( aFilename.latin1(), true ); // currently, automatic groups are always created
+ aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
break;
case 121:
aMesh->ExportDAT( aFilename.latin1() );
}
}
- void SetViewMode(int theCommandID){
+ inline void InverseEntityMode(unsigned int& theOutputMode,
+ unsigned int theMode)
+ {
+ bool anIsNotPresent = ~theOutputMode & theMode;
+ if(anIsNotPresent)
+ theOutputMode |= theMode;
+ else
+ theOutputMode &= ~theMode;
+ }
+
+ void SetDisplayEntity(int theCommandID){
+ SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
+ if(Sel->IObjectCount() >= 1){
+ SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+ for(; It.More(); It.Next()){
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ if(IObject->hasEntry()){
+ if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
+ unsigned int aMode = anActor->GetEntityMode();
+ switch(theCommandID){
+ case 217:
+ InverseEntityMode(aMode,SMESH_Actor::eEdges);
+ break;
+ case 218:
+ InverseEntityMode(aMode,SMESH_Actor::eFaces);
+ break;
+ case 219:
+ InverseEntityMode(aMode,SMESH_Actor::eVolumes);
+ break;
+ case 220:
+ aMode = SMESH_Actor::eAllEntity;
+ break;
+ }
+ if(aMode)
+ anActor->SetEntityMode(aMode);
+ }
+ }
+ }
+ }
+ }
+
+ void SetDisplayMode(int theCommandID){
SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
if(Sel->IObjectCount() >= 1){
switch(theCommandID){
case 1134:{
SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
- SMESHGUI_ClippingDlg *aDlg =
- new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false);
+ new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false);
return;
}
case 1133:{
SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
- SMESHGUI_TransparencyDlg *aDlg =
- new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
+ new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
return;
}}
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
switch ( theCommandID ){
case 6001:
aTitle = QObject::tr( "LENGTH_EDGES" );
- aControl = SMESH_Actor::eLengthEdges;
+ aControl = SMESH_Actor::eLength;
+ break;
+ case 6018:
+ aTitle = QObject::tr( "LENGTH2D_EDGES" );
+ aControl = SMESH_Actor::eLength2D;
break;
case 6002:
aTitle = QObject::tr( "FREE_EDGES" );
aTitle = QObject::tr( "MULTI_BORDERS" );
aControl = SMESH_Actor::eMultiConnection;
break;
+ case 6019:
+ aTitle = QObject::tr( "MULTI2D_BORDERS" );
+ aControl = SMESH_Actor::eMultiConnection2D;
+ break;
case 6011:
aTitle = QObject::tr( "AREA_ELEMENTS" );
aControl = SMESH_Actor::eArea;
aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
aControl = SMESH_Actor::eAspectRatio;
break;
+ case 6017:
+ aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
+ aControl = SMESH_Actor::eAspectRatio3D;
+ break;
case 6014:
aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
aControl = SMESH_Actor::eMinimumAngle;
case 1134: // Clipping
case 1133: // Tranparency
case 1132: // Colors / Size
- case 215:
- case 213:
- case 212:
- case 211:
- {
- ::SetViewMode(theCommandID);
- break;
- }
+
+ // Display Mode
+ case 215: // Nodes
+ case 213: // Nodes
+ case 212: // Nodes
+ case 211: // Nodes
+ ::SetDisplayMode(theCommandID);
+ break;
+
+ // Display Entity
+ case 217: // Edges
+ case 218: // Faces
+ case 219: // Volumes
+ case 220: // All Entity
+ ::SetDisplayEntity(theCommandID);
+ break;
case 214: // UPDATE
{
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_NodesDlg *aDlg = new SMESHGUI_NodesDlg(parent, "", Sel);
+ new SMESHGUI_NodesDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
{
EmitSignalDeactivateDialog();
- SMESHGUI_FilterDlg *aDlg = new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
+ new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
}
break;
}
if(checkLock(aStudy)) break;
SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
- SMESHGUI_MoveNodesDlg *aDlg = new SMESHGUI_MoveNodesDlg( parent, Sel );
+ new SMESHGUI_MoveNodesDlg( parent, Sel );
break;
}
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_AddSubMeshDlg *aDlg = new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
+ new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg(parent, "", Sel);
+ new SMESHGUI_InitMeshDlg(parent, "", Sel);
break;
}
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
+ new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
break;
}
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
+ new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
break;
}
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
+ new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
break;
}
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_SmoothingDlg *aDlg = new SMESHGUI_SmoothingDlg(parent, "", Sel);
+ new SMESHGUI_SmoothingDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_ExtrusionDlg *aDlg = new SMESHGUI_ExtrusionDlg(parent, "", Sel);
+ new SMESHGUI_ExtrusionDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_RevolutionDlg *aDlg = new SMESHGUI_RevolutionDlg(parent, "", Sel);
+ new SMESHGUI_RevolutionDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
}
break;
}
+ case 416: // Extrusion along a path
+ {
+ if(checkLock(aStudy)) break;
+ if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+ EmitSignalDeactivateDialog();
+ SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
+ new SMESHGUI_ExtrusionAlongPathDlg(parent, Sel);
+ }
+ else {
+ QAD_MessageBox::warn1(QAD_Application::getDesktop(),
+ tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
+ tr("SMESH_BUT_OK"));
+ }
+ break;
+ }
case 801: // CREATE GROUP
{
if(checkLock(aStudy)) break;
for ( ; It.More(); It.Next() ) {
Sel->ClearIObjects();
Sel->AddIObject( It.Value() );
- SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg(parent, "", false);
+ new SMESHGUI_MeshInfosDlg(parent, "", false);
}
// restore selection
Sel->ClearIObjects();
Sel->AddIObject( It.Value() );
}
else
- SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg(parent, "", false);
+ new SMESHGUI_MeshInfosDlg(parent, "", false);
break;
}
for ( ; It.More(); It.Next() ) {
Sel->ClearIObjects();
Sel->AddIObject( It.Value() );
- SMESHGUI_StandardMeshInfosDlg *aDlg = new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
+ new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
}
// restore selection
Sel->ClearIObjects();
Sel->AddIObject( It.Value() );
}
else
- SMESHGUI_StandardMeshInfosDlg *aDlg = new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
+ new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
break;
}
break;
}
- case 1007:
+ case 10070:
{
( new SMESHGUI_PrecisionDlg( parent ) )->exec();
break;
}
+ case 10071:
+ {
+ parent->menuBar()->setItemChecked(10071, !parent->menuBar()->isItemChecked(10071));
+ if (parent->menuBar()->isItemChecked(10071)) {
+ QAD_CONFIG->addSetting("SMESH:DispayEntity","true");
+ }
+ else {
+ QAD_CONFIG->addSetting("SMESH:DispayEntity","false");
+ }
+ break;
+ }
case 1006:
{
SMESHGUI_Preferences_SelectionDlg* aDlg =
type = SMDSAbs_Volume; nbNodes = 8; break;
default:;
}
- SMESHGUI_AddMeshElementDlg *aDlg =
- new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
+ new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_RemoveNodesDlg *aDlg = new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
+ new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_RemoveElementsDlg *aDlg = new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
+ new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
}
else
{
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_RenumberingDlg *aDlg = new SMESHGUI_RenumberingDlg(parent, "", Sel, 0);
+ new SMESHGUI_RenumberingDlg(parent, "", Sel, 0);
}
else
{
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_RenumberingDlg *aDlg = new SMESHGUI_RenumberingDlg(parent, "", Sel, 1);
+ new SMESHGUI_RenumberingDlg(parent, "", Sel, 1);
}
else
{
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_TranslationDlg *aDlg = new SMESHGUI_TranslationDlg(parent, "", Sel);
+ new SMESHGUI_TranslationDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_RotationDlg *aDlg = new SMESHGUI_RotationDlg(parent, "", Sel);
+ new SMESHGUI_RotationDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_SymmetryDlg *aDlg = new SMESHGUI_SymmetryDlg(parent, "", Sel);
+ new SMESHGUI_SymmetryDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_SewingDlg *aDlg = new SMESHGUI_SewingDlg(parent, "", Sel);
+ new SMESHGUI_SewingDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
- SMESHGUI_MergeNodesDlg *aDlg = new SMESHGUI_MergeNodesDlg(parent, "", Sel);
+ new SMESHGUI_MergeNodesDlg(parent, "", Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
{
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
- SMESHGUI_CreateHypothesesDlg *aDlg =
- new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
+ new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
break;
}
case 5010: // ALGO
{
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
- SMESHGUI_CreateHypothesesDlg *aDlg =
- new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
+ new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
break;
}
}
break;
- case 6016: // CONTROLS
+ case 6017: // CONTROLS
+ case 6016:
case 6015:
case 6014:
case 6013:
case 6012:
case 6011:
case 6001:
+ case 6018:
+ case 6019:
case 6002:
case 6003:
case 6004:
myAutomaticUpdate = false;
}
+ QString anIsDisplayEntity = QAD_CONFIG->getSetting("SMESH:DispayEntity");
+ if(anIsDisplayEntity.compare("true") == 0)
+ parent->menuBar()->setItemChecked(10071,true);
+ else
+ parent->menuBar()->setItemChecked(10071,false);
+
/* Selection */
SMESH::UpdateSelectionProp();
if ( !aGeomGroup->_is_nil() ) // group linked on geometry
popup->removeItem( 803 ); // EDIT GROUP
- SMESH_Actor* ac = SMESH::FindActorByEntry(IObject->getEntry());
+ SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
// if object has actor
- if ( ac && studyFrame->getTypeView() == VIEW_VTK ) {
+ if ( anActor && studyFrame->getTypeView() == VIEW_VTK ) {
VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
if ( myRenderInter->isVisible( IObject ) ) {
popup->removeItem( QAD_Display_Popup_ID );
- popup->setItemChecked( 9010, ac->GetPointsLabeled() ); // Numbering / Display Nodes #
- popup->setItemChecked( 9011, ac->GetCellsLabeled() ); // Numbering / Display Elements #
- TVisualObjPtr aVisualObj = ac->GetObject();
- int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE);
- int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE);
- int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME);
+ popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes #
+ popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements #
+ TVisualObjPtr aVisualObj = anActor->GetObject();
+ int aNbEdges = aVisualObj->GetNbEntities(SMDSAbs_Edge);
+ int aNbFaces = aVisualObj->GetNbEntities(SMDSAbs_Face);
+ int aNbVolumes = aVisualObj->GetNbEntities(SMDSAbs_Volume);
+
QMenuItem* mi = popup->findItem( 1131 );
if ( mi && mi->popup() ) {
- int prType = ac->GetRepresentation();
+ int prType = anActor->GetRepresentation();
// Display Mode / Wireframe
- if(!aNbFaces && !aNbVolumes && !aNbEdges){
+ if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){
mi->popup()->removeItem( 211 );
}else{
mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
}
// Display Mode / Shading
- if(!aNbFaces && !aNbVolumes){
+ if(aNbFaces == 0 && aNbVolumes == 0){
mi->popup()->removeItem( 212 );
}else{
mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface );
// Display Mode / Points
mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );
// Display Mode / Shrink
- bool isShrunk = ac->IsShrunk();
- bool isShrunkable = ac->IsShrunkable();
+ bool isShrunk = anActor->IsShrunk();
+ bool isShrunkable = anActor->IsShrunkable();
mi->popup()->setItemChecked( 213, isShrunk );
mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
}
- // Scalar Bar
+
+ // Display Entity
+ mi = popup->findItem( 1135 );
+ int aIsSomething=0;
+ if (aNbVolumes>0) aIsSomething++;
+ if (aNbFaces>0) aIsSomething++;
+ if (aNbEdges>0) aIsSomething++;
+ if ( mi && (aIsSomething <= 1)){
+ popup->removeItem(1135);
+ }else if ( mi && mi->popup() ) {
+ QPopupMenu* aPopup = mi->popup();
+ unsigned int aMode = anActor->GetEntityMode();
+
+ bool aIsVolumesMode = aMode & SMESH_Actor::eVolumes;
+ bool aIsFacesMode = aMode & SMESH_Actor::eFaces;
+ bool aIsEdgesMode = aMode & SMESH_Actor::eEdges;
+
+ if(aNbVolumes == 0)
+ aPopup->removeItem( 219 );
+ else
+ aPopup->setItemChecked( 219, aIsVolumesMode );
+
+ if(aNbFaces == 0)
+ aPopup->removeItem( 218 );
+ else
+ aPopup->setItemChecked( 218, aIsFacesMode );
+
+
+ if(aNbEdges == 0)
+ aPopup->removeItem( 217 );
+ else
+ aPopup->setItemChecked( 217, aIsEdgesMode );
+
+
+ bool aIsRemove = (aNbVolumes == 0 || aIsVolumesMode);
+ aIsRemove &= (aNbFaces == 0 || aIsFacesMode);
+ aIsRemove &= (aNbEdges == 0 || aIsEdgesMode);
+
+ if(aIsRemove)
+ aPopup->removeItem( 220 );
+ }
+
+ // Controls
mi = popup->findItem( 2000 );
if ( mi && mi->popup() ) {
- SMESH_Actor::eControl cMode = ac->GetControlMode();
+ SMESH_Actor::eControl cMode = anActor->GetControlMode();
switch ( cMode ) {
- case SMESH_Actor::eLengthEdges:
+ case SMESH_Actor::eLength:
mi->popup()->setItemChecked( 6001, true ); break;
+ case SMESH_Actor::eLength2D:
+ mi->popup()->setItemChecked( 6018, true ); break;
case SMESH_Actor::eFreeEdges:
mi->popup()->setItemChecked( 6002, true );
mi->popup()->removeItem( 201 );
break;
case SMESH_Actor::eMultiConnection:
mi->popup()->setItemChecked( 6004, true ); break;
+ case SMESH_Actor::eMultiConnection2D:
+ mi->popup()->setItemChecked( 6019, true ); break;
case SMESH_Actor::eArea:
mi->popup()->setItemChecked( 6011, true ); break;
case SMESH_Actor::eTaper:
mi->popup()->setItemChecked( 6012, true ); break;
case SMESH_Actor::eAspectRatio:
mi->popup()->setItemChecked( 6013, true ); break;
+ case SMESH_Actor::eAspectRatio3D:
+ mi->popup()->setItemChecked( 6017, true ); break;
case SMESH_Actor::eMinimumAngle:
mi->popup()->setItemChecked( 6014, true ); break;
case SMESH_Actor::eWarping:
mi->popup()->removeItem( 201 );
break;
}
- TVisualObjPtr aVisualObj = ac->GetObject();
- if(!aNbEdges){
+ TVisualObjPtr aVisualObj = anActor->GetObject();
+ if(aNbEdges == 0){
mi->popup()->removeItem( 6001 );
mi->popup()->removeItem( 6003 );
mi->popup()->removeItem( 6004 );
}
- if(!aNbFaces){
+ if(aNbFaces == 0){
+ mi->popup()->removeItem( 6018 );
mi->popup()->removeItem( 6002 );
mi->popup()->removeItem( 6011 );
mi->popup()->removeItem( 6012 );
mi->popup()->removeItem( 6014 );
mi->popup()->removeItem( 6015 );
mi->popup()->removeItem( 6016 );
+ mi->popup()->removeItem( 6019 );
+ }
+ if(aNbVolumes == 0){
+ mi->popup()->removeItem( 6017 );
}
- if(!aNbFaces && !aNbEdges)
+ if(aNbFaces == 0 && aNbEdges == 0 && aNbVolumes == 0)
popup->removeItem( 2000 ); // Scalar Bar
}
}
#include "SALOME_InteractiveObject.hxx"
#include "SMESH_ActorUtils.h"
+#include "VTKViewer_ViewFrame.h"
+#include "VTKViewer_RenderWindow.h"
+
+#include <vtkRenderer.h>
+
using namespace std;
myActor->SetInfinitive(true);
myActor->SetMapper( myMapper );
- static float anOpacity = 0.75;
-
vtkProperty* aProp = vtkProperty::New();
float anRGB[3];
anRGB[0] = SMESH::GetFloat("SMESH:SettingsFillColorRed", 0)/255.;
SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg()
{
// no need to delete child widgets, Qt does it all for us
- //cout<<"SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg\n";
std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
- SMESH::GetCurrentVtkView()->Repaint();
+ SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
}
aCollection->AddItem(anOrientedPlane);
anOrientedPlane->Delete();
}
-
- myActor->SetVisibility(myActor->GetVisibility());
-
- SMESH::GetCurrentVtkView()->Repaint();
+
+ SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
}
}
}
}
Sinchronize();
- SMESH::GetCurrentVtkView()->Repaint();
+ SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
}
// Orientation
SMESH::Orientation anOrientation = aPlane->GetOrientation();
- // Distance and Rotations
- float aDistance;
+ // Rotations
double aRot[2] = {aPlane->myAngle[0], aPlane->myAngle[1]};
// Set plane parameters in the dialog
ClickOnApply();
Sinchronize();
- SMESH::GetCurrentVtkView()->Repaint();
+ SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
}
myActor->SetPlaneParam(aNormal, getDistance(), aPlane);
- float* anOrig = aPlane->GetOrigin();
vtkDataSet* aDataSet = myActor->GetInput();
float *aPnt = aDataSet->GetCenter();
if(AutoApplyCheckBox->isChecked())
ClickOnApply();
- SMESH::GetCurrentVtkView()->Repaint();
+ SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
}
void SMESHGUI_ClippingDlg::OnPreviewToggle(bool theIsToggled){
std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled));
- SMESH::GetCurrentVtkView()->Repaint();
+ SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
}
--- /dev/null
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESHGUI_ExtrusionAlongPathDlg.cxx
+// Author : Vadim SANDLER
+// Module : SMESH
+// $Header:
+
+#include "SMESHGUI_ExtrusionAlongPathDlg.h"
+#include "SMESHGUI.h"
+#include "SMESHGUI_SpinBox.h"
+#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_VTKUtils.h"
+#include "SMESHGUI_MeshUtils.h"
+#include "SMESHGUI_IdValidator.h"
+#include "SMESH_Actor.h"
+#include "SMESH_NumberFilter.hxx"
+#include "SMDS_Mesh.hxx"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GEOMBase.h"
+
+#include "QAD_Application.h"
+#include "QAD_WaitCursor.h"
+#include "QAD_Desktop.h"
+#include "QAD_MessageBox.h"
+#include "utilities.h"
+
+#include <BRep_Tool.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <gp_Pnt.hxx>
+
+// QT Includes
+#include <qapplication.h>
+#include <qbuttongroup.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qtoolbutton.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+#include <qlistbox.h>
+#include <qlayout.h>
+#include <qvalidator.h>
+#include <qptrlist.h>
+
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
+using namespace std;
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg()
+// purpose : constructor
+//=================================================================================
+SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( QWidget* parent, SALOME_Selection* Sel, bool modal )
+ : QDialog( parent, "SMESHGUI_ExtrusionAlongPathDlg", modal,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose )
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg");
+ myType = -1;
+ QPixmap edgeImage ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_DLG_EDGE" ) ) );
+ QPixmap faceImage ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_DLG_TRIANGLE" ) ) );
+ QPixmap selectImage( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
+ QPixmap addImage ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_APPEND" ) ) );
+ QPixmap removeImage( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_REMOVE" ) ) );
+
+ setCaption( tr( "EXTRUSION_ALONG_PATH" ) );
+ setSizeGripEnabled( TRUE );
+
+ QGridLayout* topLayout = new QGridLayout( this );
+ topLayout->setSpacing( 6 ); topLayout->setMargin( 11 );
+
+ /***************************************************************/
+ // Elements type group box (1d / 2d elements)
+ ElementsTypeGrp = new QButtonGroup( tr( "SMESH_EXTRUSION" ), this );
+ ElementsTypeGrp->setColumnLayout( 0, Qt::Vertical );
+ ElementsTypeGrp->layout()->setSpacing( 0 ); ElementsTypeGrp->layout()->setMargin( 0 );
+ QGridLayout* ElementsTypeGrpLayout = new QGridLayout( ElementsTypeGrp->layout() );
+ ElementsTypeGrpLayout->setAlignment( Qt::AlignTop );
+ ElementsTypeGrpLayout->setSpacing( 6 ); ElementsTypeGrpLayout->setMargin( 11 );
+
+ Elements1dRB = new QRadioButton( ElementsTypeGrp );
+ Elements1dRB->setPixmap( edgeImage );
+ Elements2dRB = new QRadioButton( ElementsTypeGrp );
+ Elements2dRB->setPixmap( faceImage );
+ Elements1dRB->setChecked( true );
+
+ // layouting
+ ElementsTypeGrpLayout->addWidget( Elements1dRB, 0, 0 );
+ ElementsTypeGrpLayout->addWidget( Elements2dRB, 0, 2 );
+
+ /***************************************************************/
+ // Arguments group box
+ ArgumentsGrp = new QGroupBox( tr( "EXTRUSION_1D" ), this );
+ ArgumentsGrp->setColumnLayout( 0, Qt::Vertical );
+ ArgumentsGrp->layout()->setSpacing( 0 ); ArgumentsGrp->layout()->setMargin( 0 );
+ QGridLayout* ArgumentsGrpLayout = new QGridLayout( ArgumentsGrp->layout() );
+ ArgumentsGrpLayout->setAlignment( Qt::AlignTop );
+ ArgumentsGrpLayout->setSpacing( 6 ); ArgumentsGrpLayout->setMargin( 11 );
+
+ // Controls for elements selection
+ ElementsLab = new QLabel( tr( "SMESH_ID_ELEMENTS" ), ArgumentsGrp );
+
+ SelectElementsButton = new QToolButton( ArgumentsGrp );
+ SelectElementsButton->setPixmap( selectImage );
+
+ ElementsLineEdit = new QLineEdit( ArgumentsGrp );
+ ElementsLineEdit->setValidator( new SMESHGUI_IdValidator( this ) );
+
+ // Controls for the whole mesh selection
+ MeshCheck = new QCheckBox( tr( "SMESH_SELECT_WHOLE_MESH" ), ArgumentsGrp );
+
+ // Controls for path selection
+ PathGrp = new QGroupBox( tr( "SMESH_PATH" ), ArgumentsGrp );
+ PathGrp->setColumnLayout( 0, Qt::Vertical );
+ PathGrp->layout()->setSpacing( 0 ); PathGrp->layout()->setMargin( 0 );
+ QGridLayout* PathGrpLayout = new QGridLayout( PathGrp->layout() );
+ PathGrpLayout->setAlignment( Qt::AlignTop );
+ PathGrpLayout->setSpacing( 6 ); PathGrpLayout->setMargin( 11 );
+
+ // Controls for path mesh selection
+ PathMeshLab = new QLabel( tr( "SMESH_PATH_MESH" ), PathGrp );
+
+ SelectPathMeshButton = new QToolButton( PathGrp );
+ SelectPathMeshButton->setPixmap( selectImage );
+
+ PathMeshLineEdit = new QLineEdit( PathGrp );
+ PathMeshLineEdit->setReadOnly( true );
+
+ // Controls for path shape selection
+ PathShapeLab = new QLabel( tr( "SMESH_PATH_SHAPE" ), PathGrp );
+
+ SelectPathShapeButton = new QToolButton( PathGrp );
+ SelectPathShapeButton->setPixmap( selectImage );
+
+ PathShapeLineEdit = new QLineEdit( PathGrp );
+ PathShapeLineEdit->setReadOnly( true );
+
+ // Controls for path starting point selection
+ StartPointLab = new QLabel( tr( "SMESH_PATH_START" ), PathGrp );
+
+ SelectStartPointButton = new QToolButton( PathGrp );
+ SelectStartPointButton->setPixmap( selectImage );
+
+ StartPointLineEdit = new QLineEdit( PathGrp );
+ StartPointLineEdit->setValidator( new QIntValidator( this ) );
+
+ // layouting
+ PathGrpLayout->addWidget( PathMeshLab, 0, 0 );
+ PathGrpLayout->addWidget( SelectPathMeshButton, 0, 1 );
+ PathGrpLayout->addWidget( PathMeshLineEdit, 0, 2 );
+ PathGrpLayout->addWidget( PathShapeLab, 1, 0 );
+ PathGrpLayout->addWidget( SelectPathShapeButton, 1, 1 );
+ PathGrpLayout->addWidget( PathShapeLineEdit, 1, 2 );
+ PathGrpLayout->addWidget( StartPointLab, 2, 0 );
+ PathGrpLayout->addWidget( SelectStartPointButton, 2, 1 );
+ PathGrpLayout->addWidget( StartPointLineEdit, 2, 2 );
+
+ // Controls for angles defining
+ AnglesCheck = new QCheckBox( tr( "SMESH_USE_ANGLES" ), ArgumentsGrp );
+
+ AnglesGrp = new QGroupBox( tr( "SMESH_ANGLES" ), ArgumentsGrp );
+ AnglesGrp->setColumnLayout( 0, Qt::Vertical );
+ AnglesGrp->layout()->setSpacing( 0 ); AnglesGrp->layout()->setMargin( 0 );
+ QGridLayout* AnglesGrpLayout = new QGridLayout( AnglesGrp->layout() );
+ AnglesGrpLayout->setAlignment( Qt::AlignTop );
+ AnglesGrpLayout->setSpacing( 6 ); AnglesGrpLayout->setMargin( 11 );
+
+ AnglesList = new QListBox( AnglesGrp );
+ AnglesList->setSelectionMode( QListBox::Extended );
+
+ AddAngleButton = new QToolButton( AnglesGrp );
+ AddAngleButton->setPixmap( addImage );
+
+ RemoveAngleButton = new QToolButton( AnglesGrp );
+ RemoveAngleButton->setPixmap( removeImage );
+
+ AngleSpin = new SMESHGUI_SpinBox( AnglesGrp );
+
+ // layouting
+ QVBoxLayout* bLayout = new QVBoxLayout();
+ bLayout->addWidget( AddAngleButton );
+ bLayout->addSpacing( 6 );
+ bLayout->addWidget( RemoveAngleButton );
+ bLayout->addStretch();
+ AnglesGrpLayout->addMultiCellWidget( AnglesList, 0, 1, 0, 0 );
+ AnglesGrpLayout->addMultiCellLayout( bLayout, 0, 1, 1, 1 );
+ AnglesGrpLayout->addWidget( AngleSpin, 0, 2 );
+ AnglesGrpLayout->setRowStretch( 1, 10 );
+
+ // Controls for base point defining
+ BasePointCheck = new QCheckBox( tr( "SMESH_USE_BASE_POINT" ), ArgumentsGrp );
+
+ BasePointGrp = new QGroupBox( tr( "SMESH_BASE_POINT" ), ArgumentsGrp );
+ BasePointGrp->setColumnLayout( 0, Qt::Vertical );
+ BasePointGrp->layout()->setSpacing( 0 ); BasePointGrp->layout()->setMargin( 0 );
+ QGridLayout* BasePointGrpLayout = new QGridLayout( BasePointGrp->layout() );
+ BasePointGrpLayout->setAlignment( Qt::AlignTop );
+ BasePointGrpLayout->setSpacing( 6 ); BasePointGrpLayout->setMargin( 11 );
+
+ SelectBasePointButton = new QToolButton( BasePointGrp );
+ SelectBasePointButton->setPixmap( selectImage );
+
+ XLab = new QLabel( tr( "SMESH_X" ), BasePointGrp );
+ XSpin = new SMESHGUI_SpinBox( BasePointGrp );
+ YLab = new QLabel( tr( "SMESH_Y" ), BasePointGrp );
+ YSpin = new SMESHGUI_SpinBox( BasePointGrp );
+ ZLab = new QLabel( tr( "SMESH_Z" ), BasePointGrp );
+ ZSpin = new SMESHGUI_SpinBox( BasePointGrp );
+
+ // layouting
+ BasePointGrpLayout->addWidget( SelectBasePointButton, 0, 0 );
+ BasePointGrpLayout->addWidget( XLab, 0, 1 );
+ BasePointGrpLayout->addWidget( XSpin, 0, 2 );
+ BasePointGrpLayout->addWidget( YLab, 0, 3 );
+ BasePointGrpLayout->addWidget( YSpin, 0, 4 );
+ BasePointGrpLayout->addWidget( ZLab, 0, 5 );
+ BasePointGrpLayout->addWidget( ZSpin, 0, 6 );
+
+ // layouting
+ ArgumentsGrpLayout->addWidget( ElementsLab, 0, 0 );
+ ArgumentsGrpLayout->addWidget( SelectElementsButton, 0, 1 );
+ ArgumentsGrpLayout->addWidget( ElementsLineEdit, 0, 2 );
+ ArgumentsGrpLayout->addMultiCellWidget( MeshCheck, 1, 1, 0, 2 );
+ ArgumentsGrpLayout->addMultiCellWidget( PathGrp, 2, 2, 0, 2 );
+ ArgumentsGrpLayout->addWidget( AnglesCheck, 3, 0 );
+ ArgumentsGrpLayout->addMultiCellWidget( AnglesGrp, 3, 4, 1, 2 );
+ ArgumentsGrpLayout->addWidget( BasePointCheck, 5, 0 );
+ ArgumentsGrpLayout->addMultiCellWidget( BasePointGrp, 5, 6, 1, 2 );
+ ArgumentsGrpLayout->setRowStretch( 4, 10 );
+
+ /***************************************************************/
+ // common buttons group box
+ ButtonsGrp = new QGroupBox( this );
+ ButtonsGrp->setColumnLayout( 0, Qt::Vertical );
+ ButtonsGrp->layout()->setSpacing( 0 ); ButtonsGrp->layout()->setMargin( 0 );
+ QGridLayout* ButtonsGrpLayout = new QGridLayout( ButtonsGrp->layout() );
+ ButtonsGrpLayout->setAlignment( Qt::AlignTop );
+ ButtonsGrpLayout->setSpacing( 6 ); ButtonsGrpLayout->setMargin( 11 );
+
+ OkButton = new QPushButton( tr( "SMESH_BUT_OK" ), ButtonsGrp );
+ OkButton->setAutoDefault( true );
+ OkButton->setDefault( true );
+
+ ApplyButton = new QPushButton( tr( "SMESH_BUT_APPLY" ), ButtonsGrp );
+ ApplyButton->setAutoDefault( true );
+
+ CloseButton = new QPushButton( tr( "SMESH_BUT_CLOSE" ), ButtonsGrp );
+ CloseButton->setAutoDefault( true );
+
+ // layouting
+ ButtonsGrpLayout->addWidget( OkButton, 0, 0 );
+ ButtonsGrpLayout->addWidget( ApplyButton, 0, 1 );
+ ButtonsGrpLayout->addWidget( CloseButton, 0, 3 );
+ ButtonsGrpLayout->addColSpacing( 2, 10 );
+ ButtonsGrpLayout->setColStretch( 2, 10 );
+
+ /***************************************************************/
+ // layouting
+ topLayout->addWidget( ElementsTypeGrp, 0, 0 );
+ topLayout->addWidget( ArgumentsGrp, 1, 0 );
+ topLayout->addWidget( ButtonsGrp, 2, 0 );
+
+ /***************************************************************/
+ // Initialisations
+ XSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
+ YSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
+ ZSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
+ AngleSpin->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 );
+
+ mySelection = Sel;
+ mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
+ mySMESHGUI->SetActiveDialogBox( this ) ;
+
+ // Costruction of the logical filter for the elements: mesh/sub-mesh/group
+ SMESH_ListOfFilter aListOfFilters;
+ Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
+ if ( !aMeshOrSubMeshFilter.IsNull() )
+ aListOfFilters.Append( aMeshOrSubMeshFilter );
+ Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
+ if ( !aSmeshGroupFilter.IsNull() )
+ aListOfFilters.Append( aSmeshGroupFilter );
+
+ myElementsFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
+
+ myPathMeshFilter = new SMESH_TypeFilter( MESH );
+
+ Init();
+
+ /***************************************************************/
+ // signals-slots connections
+ connect( OkButton, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+ connect( CloseButton, SIGNAL( clicked() ), this, SLOT( reject() ) ) ;
+ connect( ApplyButton, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+
+ connect( AddAngleButton, SIGNAL( clicked() ), this, SLOT( OnAngleAdded() ) );
+ connect( RemoveAngleButton, SIGNAL( clicked() ), this, SLOT( OnAngleRemoved() ) );
+
+ connect( ElementsTypeGrp, SIGNAL( clicked( int ) ), SLOT( TypeChanged( int ) ) );
+
+ connect( SelectElementsButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectPathMeshButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectPathShapeButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectStartPointButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectBasePointButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+
+ connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
+ connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) ) ;
+
+ connect( ElementsLineEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( onTextChange( const QString& ) ) );
+ connect( StartPointLineEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( onTextChange( const QString& ) ) );
+
+ connect( MeshCheck, SIGNAL( toggled( bool ) ), SLOT( onSelectMesh() ) );
+ connect( AnglesCheck, SIGNAL( toggled( bool ) ), SLOT( onAnglesCheck() ) );
+ connect( BasePointCheck, SIGNAL( toggled( bool ) ), SLOT( onBasePointCheck() ) );
+
+ AnglesList->installEventFilter( this );
+ ElementsLineEdit->installEventFilter( this );
+ StartPointLineEdit->installEventFilter( this );
+ XSpin->editor()->installEventFilter( this );
+ YSpin->editor()->installEventFilter( this );
+ ZSpin->editor()->installEventFilter( this );
+
+ /***************************************************************/
+ // set position and show dialog box
+ int x, y ;
+ mySMESHGUI->DefineDlgPosition( this, x, y ) ;
+ this->move( x, y ) ;
+ this->show() ; // displays Dialog
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
+// purpose : destructor
+//=================================================================================
+SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg");
+ // no need to delete child widgets, Qt does it all for us
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::eventFilter
+// purpose : event filter
+//=================================================================================
+bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter( QObject* object, QEvent* event )
+{
+ if ( event->type() == QEvent::KeyPress ) {
+ QKeyEvent* ke = ( QKeyEvent* )event;
+ if ( object == AnglesList ) {
+ if ( ke->key() == Key_Delete )
+ OnAngleRemoved();
+ }
+ }
+ else if ( event->type() == QEvent::FocusIn ) {
+ if ( object == ElementsLineEdit ) {
+ if ( myEditCurrentArgument != ElementsLineEdit )
+ SetEditCurrentArgument( SelectElementsButton );
+ }
+ else if ( object == StartPointLineEdit ) {
+ if ( myEditCurrentArgument != StartPointLineEdit )
+ SetEditCurrentArgument( SelectStartPointButton );
+ }
+ else if ( object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor() ) {
+ if ( myEditCurrentArgument != XSpin )
+ SetEditCurrentArgument( SelectBasePointButton );
+ }
+ }
+ return QDialog::eventFilter( object, event );
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::Init()
+// purpose : initialization
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::Init( bool ResetControls )
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::Init");
+ myBusy = false;
+ myEditCurrentArgument = 0;
+
+ myMesh = SMESH::SMESH_Mesh::_nil();
+ myIDSource = SMESH::SMESH_IDSource::_nil();
+ myMeshActor = 0;
+ myPathMesh = SMESH::SMESH_Mesh::_nil();
+ myPathShape = GEOM::GEOM_Object::_nil();
+
+ ElementsLineEdit->clear();
+ PathMeshLineEdit->clear();
+ PathShapeLineEdit->clear();
+ StartPointLineEdit->clear();
+
+ if( ResetControls ) {
+ XSpin->SetValue( 0.0 );
+ YSpin->SetValue( 0.0 );
+ ZSpin->SetValue( 0.0 );
+
+ AngleSpin->SetValue( 45 );
+ MeshCheck->setChecked( false );
+ TypeChanged( 0 );
+ onSelectMesh();
+ onAnglesCheck();
+ onBasePointCheck();
+ }
+ SetEditCurrentArgument( 0 );
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::TypeChanged()
+// purpose : Called when user changes type of elements ( 1d / 2d )
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::TypeChanged( int type )
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::TypeChanged");
+ if ( myType != type ) {
+ disconnect( mySelection, 0, this, 0 );
+
+ if ( type == 0 )
+ ArgumentsGrp->setTitle( tr( "EXTRUSION_1D" ) );
+ else if ( type == 1 )
+ ArgumentsGrp->setTitle( tr( "EXTRUSION_2D" ) );
+
+ // clear elements ID list
+ if ( !MeshCheck->isChecked() ) {
+ ElementsLineEdit->clear();
+ }
+ // set selection mode if necessary
+ if( myEditCurrentArgument == ElementsLineEdit ) {
+ mySelection->ClearIObjects();
+ mySelection->ClearFilters();
+ SMESH::SetPickable();
+
+ SMESH::SetPointRepresentation( false );
+ if ( MeshCheck->isChecked() ) {
+ QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
+ mySelection->AddFilter( myElementsFilter );
+ }
+ else {
+ if ( type == 0 )
+ QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
+ if ( type == 1 )
+ QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
+ }
+ }
+ connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ }
+ myType = type;
+}
+
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
+// purpose : Called when user presses <Apply> button
+//=================================================================================
+bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply");
+ if ( mySMESHGUI->ActiveStudyLocked() ) {
+ return false;
+ }
+
+ if( myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() || !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil() ) {
+ return false;
+ }
+
+ SMESH::long_array_var anElementsId = new SMESH::long_array;
+
+ if ( MeshCheck->isChecked() ) {
+ // If "Select whole mesh, submesh or group" check box is on ->
+ // get all elements of the required type from the object selected
+
+ // if MESH object is selected
+ if ( !CORBA::is_nil( SMESH::SMESH_Mesh::_narrow( myIDSource ) ) ) {
+ // get mesh
+ SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( myIDSource );
+ // get IDs from mesh...
+ if ( Elements1dRB->isChecked() )
+ // 1d elements
+ anElementsId = aMesh->GetElementsByType( SMESH::EDGE );
+ else if ( Elements2dRB->isChecked() ) {
+ anElementsId = aMesh->GetElementsByType( SMESH::FACE );
+ }
+ }
+ // SUBMESH is selected
+ if ( !CORBA::is_nil( SMESH::SMESH_subMesh::_narrow( myIDSource ) ) ) {
+ // get submesh
+ SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( myIDSource );
+ // get IDs from submesh
+ if ( Elements1dRB->isChecked() )
+ // 1d elements
+ anElementsId = aSubMesh->GetElementsByType( SMESH::EDGE );
+ else if ( Elements2dRB->isChecked() )
+ // 2d elements
+ anElementsId = aSubMesh->GetElementsByType( SMESH::FACE );
+ }
+ // GROUP is selected
+ if ( !CORBA::is_nil( SMESH::SMESH_GroupBase::_narrow( myIDSource ) ) ) {
+ // get smesh group
+ SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( myIDSource );
+ // get IDs from group
+ // 1d elements or 2d elements
+ if ( Elements1dRB->isChecked() && aGroup->GetType() == SMESH::EDGE ||
+ Elements2dRB->isChecked() && aGroup->GetType() == SMESH::FACE )
+ anElementsId = aGroup->GetListOfID();
+ }
+ }
+ else {
+ // If "Select whole mesh, submesh or group" check box is off ->
+ // use only elements of given type selected by user
+
+ SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh();
+ if ( aMesh ) {
+ QStringList aListElementsId = QStringList::split( " ", ElementsLineEdit->text(), false );
+ anElementsId = new SMESH::long_array;
+ anElementsId->length( aListElementsId.count() );
+ bool bOk;
+ int j = 0;
+ for ( int i = 0; i < aListElementsId.count(); i++ ) {
+ long ind = aListElementsId[ i ].toLong( &bOk );
+ if ( bOk ) {
+ const SMDS_MeshElement* e = aMesh->FindElement( ind );
+ if ( e ) {
+ bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge ||
+ Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face;
+ if ( typeMatch )
+ anElementsId[ j++ ] = ind;
+ }
+ }
+ }
+ anElementsId->length( j );
+ }
+ }
+
+ if ( anElementsId->length() <= 0 ) {
+ return false;
+ }
+
+ if ( StartPointLineEdit->text().stripWhiteSpace().isEmpty() ) {
+ return false;
+ }
+
+ bool bOk;
+ long aNodeStart = StartPointLineEdit->text().toLong( &bOk );
+ if ( !bOk ) {
+ return false;
+ }
+
+ // get angles
+ SMESH::double_array_var anAngles = new SMESH::double_array;
+ if ( AnglesCheck->isChecked() ) {
+ anAngles->length( AnglesList->count() );
+ int j = 0;
+ bool bOk;
+ for ( int i = 0; i < AnglesList->count(); i++ ) {
+ long angle = AnglesList->text( i ).toLong( &bOk );
+ if ( bOk )
+ anAngles[ j++ ] = angle;
+ }
+ anAngles->length( j );
+ }
+
+ // get base point
+ SMESH::PointStruct aBasePoint;
+ if ( BasePointCheck->isChecked() ) {
+ aBasePoint.x = XSpin->GetValue();
+ aBasePoint.y = YSpin->GetValue();
+ aBasePoint.z = ZSpin->GetValue();
+ }
+
+ try {
+ QAD_WaitCursor wc;
+ SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
+ aMeshEditor->ExtrusionAlongPath( anElementsId.inout(), myPathMesh, myPathShape, aNodeStart,
+ AnglesCheck->isChecked(), anAngles.inout(),
+ BasePointCheck->isChecked(), aBasePoint );
+ }
+ catch( ... ) {
+ return false;
+ }
+
+ mySelection->ClearIObjects();
+ SMESH::UpdateView();
+ Init( false );
+ TypeChanged( GetConstructorId() );
+ return true;
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
+// purpose : Called when user presses <OK> button
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk");
+ if ( !ClickOnApply() )
+ return;
+ reject();
+}
+
+//=======================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::onTextChange
+// purpose :
+//=======================================================================
+
+void SMESHGUI_ExtrusionAlongPathDlg::onTextChange(const QString& theNewText)
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onTextChange");
+ QLineEdit* send = (QLineEdit*)sender();
+ if ( send != StartPointLineEdit && send != ElementsLineEdit )
+ send = ElementsLineEdit;
+
+ // return if busy
+ if ( myBusy )
+ return;
+
+ // set busy flag
+ SetBusy sb( this );
+
+ if ( send == ElementsLineEdit && myEditCurrentArgument == ElementsLineEdit ) {
+ // hilight entered elements
+ SMDS_Mesh* aMesh = 0;
+ if ( myMeshActor )
+ aMesh = myMeshActor->GetObject()->GetMesh();
+ if ( aMesh ) {
+ mySelection->ClearIObjects();
+ mySelection->AddIObject( myMeshActor->getIO() );
+
+ QStringList aListId = QStringList::split( " ", theNewText, false );
+ bool bOk;
+ for ( int i = 0; i < aListId.count(); i++ ) {
+ long ind = aListId[ i ].toLong( &bOk );
+ if ( bOk ) {
+ const SMDS_MeshElement* e = aMesh->FindElement( ind );
+ if ( e ) {
+ // check also type of element
+ bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge ||
+ Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face;
+ if ( typeMatch ) {
+ if ( !mySelection->IsIndexSelected( myMeshActor->getIO(), e->GetID() ) )
+ mySelection->AddOrRemoveIndex( myMeshActor->getIO(), e->GetID(), true );
+ }
+ }
+ }
+ }
+ }
+ }
+ else if ( send == StartPointLineEdit && myEditCurrentArgument == StartPointLineEdit ) {
+ if ( !myPathMesh->_is_nil() ) {
+ SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
+ SMDS_Mesh* aMesh = 0;
+ if ( aPathActor )
+ aMesh = aPathActor->GetObject()->GetMesh();
+ if ( aMesh ) {
+ mySelection->ClearIObjects();
+ mySelection->AddIObject( aPathActor->getIO() );
+
+ bool bOk;
+ long ind = theNewText.toLong( &bOk );
+ if ( bOk ) {
+ const SMDS_MeshNode* n = aMesh->FindNode( ind );
+ if ( n ) {
+ if ( !mySelection->IsIndexSelected( aPathActor->getIO(), n->GetID() ) ) {
+ mySelection->AddOrRemoveIndex( aPathActor->getIO(), n->GetID(), true );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument");
+ // return if busy
+ if ( myBusy )
+ return;
+
+ // return if dialog box is inactive
+ if ( !ButtonsGrp->isEnabled() )
+ return;
+
+ // selected objects count
+ int nbSel = mySelection->IObjectCount();
+
+ // set busy flag
+ SetBusy sb( this );
+
+ if ( myEditCurrentArgument == ElementsLineEdit ) {
+ // we are now selecting mesh elements (or whole mesh/submesh/group)
+ // reset
+ ElementsLineEdit->clear();
+ myMesh = SMESH::SMESH_Mesh::_nil();
+ myIDSource = SMESH::SMESH_IDSource::_nil();
+ myMeshActor = 0;
+
+ // only one object is acceptable
+ if( nbSel != 1 )
+ return;
+
+ // try to get mesh from selection
+ Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
+ myMesh = SMESH::GetMeshByIO( IO );
+ if( myMesh->_is_nil() )
+ return;
+ // find actor
+ myMeshActor = SMESH::FindActorByObject( myMesh );
+ if ( !myMeshActor )
+ return;
+
+ if ( MeshCheck->isChecked() ) {
+ // If "Select whole mesh, submesh or group" check box is on ->
+ // get ID source and put it's name to the edit box
+ QString aString;
+ SMESH::GetNameOfSelectedIObjects( mySelection, aString );
+
+ myIDSource = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
+ ElementsLineEdit->setText( aString );
+ }
+ else {
+ // If "Select whole mesh, submesh or group" check box is off ->
+ // try to get selected elements IDs
+ QString aString;
+ int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString );
+ ElementsLineEdit->setText( aString );
+ }
+ }
+ else if ( myEditCurrentArgument == PathMeshLineEdit ) {
+ // we are now selecting path mesh
+ // reset
+ PathMeshLineEdit->clear();
+ myPathMesh = SMESH::SMESH_Mesh::_nil();
+ PathShapeLineEdit->clear();
+ myPathShape = GEOM::GEOM_Object::_nil();
+ StartPointLineEdit->clear();
+
+ // only one object is acceptable
+ if( nbSel != 1 )
+ return;
+
+ // try to get mesh from selection
+ Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
+ myPathMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( IO );
+ if( myPathMesh->_is_nil() )
+ return;
+
+ QString aString;
+ SMESH::GetNameOfSelectedIObjects( mySelection, aString );
+ PathMeshLineEdit->setText( aString );
+ }
+ else if ( myEditCurrentArgument == PathShapeLineEdit ) {
+ // we are now selecting path mesh
+ // reset
+ PathShapeLineEdit->clear();
+ myPathShape = GEOM::GEOM_Object::_nil();
+ StartPointLineEdit->clear();
+
+ // return if path mesh is not yet selected
+ if ( myPathMesh->_is_nil() )
+ return;
+
+ // only one object is acceptable
+ if( nbSel != 1 )
+ return;
+
+ // try to get shape from selection
+ Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
+ myPathShape = SMESH::IObjectToInterface<GEOM::GEOM_Object>( IO );
+ if ( myPathShape->_is_nil() )
+ return;
+
+ QString aString;
+ SMESH::GetNameOfSelectedIObjects( mySelection, aString );
+ PathShapeLineEdit->setText( aString );
+ }
+ else if ( myEditCurrentArgument == StartPointLineEdit ) {
+ // we are now selecting start point of path
+ // reset
+ StartPointLineEdit->clear();
+
+ // return if path mesh or path shape is not yet selected
+ if ( myPathMesh->_is_nil() || myPathShape->_is_nil() )
+ return;
+
+ // only one object is acceptable
+ if( nbSel != 1 )
+ return;
+
+ // try to get shape from selection
+ Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
+
+ QString aString;
+ int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString );
+ if ( aNbUnits == 1 )
+ StartPointLineEdit->setText( aString.stripWhiteSpace() );
+ }
+ else if ( myEditCurrentArgument == XSpin ) {
+ // we are now selecting base point
+ // reset is not performed here!
+
+ // return if is not enabled
+ if ( !BasePointGrp->isEnabled() )
+ return;
+
+ // only one object is acceptable
+ if( nbSel != 1 )
+ return;
+
+ // try to get shape from selection
+ Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
+
+ // check if geom vertex is selected
+ GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>( IO );
+ TopoDS_Vertex aVertex;
+ if( !aGeomObj->_is_nil() ) {
+ if( aGeomObj->IsShape() && GEOMBase::GetShape( aGeomObj, aVertex ) && !aVertex.IsNull() ) {
+ gp_Pnt aPnt = BRep_Tool::Pnt( aVertex );
+ XSpin->SetValue( aPnt.X() );
+ YSpin->SetValue( aPnt.Y() );
+ ZSpin->SetValue( aPnt.Z() );
+ }
+ return;
+ }
+
+ // check if smesh node is selected
+ SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO );
+ if( aMesh->_is_nil() )
+ return;
+
+ QString aString;
+ int aNbUnits = SMESH::GetNameOfSelectedNodes( mySelection, aString );
+ // return if more than one node is selected
+ if( aNbUnits != 1 )
+ return;
+
+ SMESH_Actor* aMeshActor = SMESH::FindActorByObject( aMesh );
+ if ( !aMeshActor )
+ return;
+
+ SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh();
+ if (!mesh)
+ return;
+
+ const SMDS_MeshNode* n = mesh->FindNode( aString.toLong() );
+ if ( !n )
+ return;
+
+ XSpin->SetValue( n->X() );
+ YSpin->SetValue( n->Y() );
+ ZSpin->SetValue( n->Z() );
+ }
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument");
+ QToolButton* send = (QToolButton*)sender();
+ if ( send != SelectElementsButton &&
+ send != SelectPathMeshButton &&
+ send != SelectPathShapeButton &&
+ send != SelectStartPointButton &&
+ send != SelectBasePointButton )
+ return;
+ SetEditCurrentArgument( send );
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument( QToolButton* button )
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument(button)");
+ disconnect( mySelection, 0, this, 0 );
+ mySelection->ClearIObjects();
+ mySelection->ClearFilters();
+ SMESH::SetPickable();
+
+ if( button == SelectElementsButton ) {
+ myEditCurrentArgument = ElementsLineEdit;
+ SMESH::SetPointRepresentation( false );
+ if ( MeshCheck->isChecked() ) {
+ QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
+ mySelection->AddFilter( myElementsFilter );
+ }
+ else {
+ if ( Elements1dRB->isChecked() )
+ QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
+ else if ( Elements2dRB->isChecked() )
+ QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
+ }
+ }
+ else if ( button == SelectPathMeshButton ) {
+ myEditCurrentArgument = PathMeshLineEdit;
+ SMESH::SetPointRepresentation( false );
+ QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
+ mySelection->AddFilter( myPathMeshFilter );
+ }
+ else if ( button == SelectPathShapeButton ) {
+ myEditCurrentArgument = PathShapeLineEdit;
+ SMESH::SetPointRepresentation( false );
+ QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
+
+ if ( !myPathMesh->_is_nil() ) {
+ TColStd_MapOfInteger aTypes;
+ aTypes.Add( TopAbs_EDGE );
+ aTypes.Add( TopAbs_WIRE );
+ GEOM::GEOM_Object_var aMainShape = myPathMesh->GetShapeToMesh();
+ SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
+
+ if ( !aMainShape->_is_nil() && aPathActor )
+ mySelection->AddFilter( new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, aTypes, aMainShape ) );
+ //SMESH::SetPickable( aPathActor );
+ }
+ }
+ else if ( button == SelectStartPointButton ) {
+ myEditCurrentArgument = StartPointLineEdit;
+ if ( !myPathMesh->_is_nil() ) {
+ SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
+ if ( aPathActor ) {
+ SMESH::SetPointRepresentation( true );
+ QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
+ SMESH::SetPickable( aPathActor );
+ }
+ }
+ }
+ else if ( button == SelectBasePointButton ) {
+ myEditCurrentArgument = XSpin;
+ SMESH::SetPointRepresentation( true );
+ QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
+
+ SMESH_ListOfFilter aListOfFilters;
+ Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
+ if ( !aMeshOrSubMeshFilter.IsNull() )
+ aListOfFilters.Append( aMeshOrSubMeshFilter );
+ Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
+ if ( !aSmeshGroupFilter.IsNull() )
+ aListOfFilters.Append( aSmeshGroupFilter );
+ //Handle(GEOM_ShapeTypeFilter) aVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX );
+ Handle(SMESH_NumberFilter) aVertexFilter = new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, TopAbs_VERTEX, GEOM::GEOM_Object::_nil() );
+ if ( !aVertexFilter.IsNull() )
+ aListOfFilters.Append( aVertexFilter );
+
+ mySelection->AddFilter( new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ) );
+ }
+
+ if ( myEditCurrentArgument && !myEditCurrentArgument->hasFocus() )
+ myEditCurrentArgument->setFocus();
+
+ connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
+// purpose : Deactivates this dialog
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog");
+ if ( ElementsTypeGrp->isEnabled() ) {
+ ElementsTypeGrp->setEnabled( false );
+ ArgumentsGrp->setEnabled( false );
+ ButtonsGrp->setEnabled( false );
+ mySMESHGUI->ResetState();
+ mySMESHGUI->SetActiveDialogBox( 0 );
+ }
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
+// purpose : Activates this dialog
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog");
+ // Emit a signal to deactivate the active dialog
+ mySMESHGUI->EmitSignalDeactivateDialog();
+ ElementsTypeGrp->setEnabled( true );
+ ArgumentsGrp->setEnabled( true );
+ ButtonsGrp->setEnabled( true );
+
+ mySMESHGUI->SetActiveDialogBox( this );
+
+ TypeChanged( GetConstructorId() );
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::enterEvent()
+// purpose : Mouse enter event
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::enterEvent(QEvent* e)
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::enterEvent");
+ if ( ElementsTypeGrp->isEnabled() )
+ return;
+ ActivateThisDialog();
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::reject()
+// purpose : Called when dialog box is closed
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::reject()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::reject");
+ disconnect( mySelection, 0, this, 0 );
+ mySelection->ClearFilters();
+ mySelection->ClearIObjects();
+ SMESH::SetPickable();
+ SMESH::SetPointRepresentation( false );
+ QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
+ mySMESHGUI->ResetState() ;
+ QDialog::reject();
+}
+
+//=================================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
+// purpose :
+//=================================================================================
+int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId");
+ if ( ElementsTypeGrp != NULL && ElementsTypeGrp->selected() != NULL )
+ return ElementsTypeGrp->id( ElementsTypeGrp->selected() );
+ return -1;
+}
+
+//=======================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh
+// purpose :
+//=======================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh");
+ bool toSelectMesh = MeshCheck->isChecked();
+
+ ElementsLineEdit->setReadOnly( toSelectMesh );
+ ElementsLab->setText( toSelectMesh ? tr( "SMESH_NAME" ) : tr( "SMESH_ID_ELEMENTS" ) );
+ ElementsLineEdit->clear();
+
+ SetEditCurrentArgument( SelectElementsButton );
+}
+
+//=======================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck
+// purpose : called when "Use Angles" check box is switched
+//=======================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck");
+ AnglesGrp->setEnabled( AnglesCheck->isChecked() );
+}
+
+//=======================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck
+// purpose : called when "Use Base Point" check box is switched
+//=======================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck");
+ BasePointGrp->setEnabled( BasePointCheck->isChecked() );
+}
+
+//=======================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded
+// purpose : Called when user adds angle to the list
+//=======================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded");
+ AnglesList->insertItem( QString::number( AngleSpin->GetValue() ) );
+}
+
+//=======================================================================
+// function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved
+// purpose : Called when user removes angle(s) from the list
+//=======================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved()
+{
+ MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved");
+ QList<QListBoxItem> aList;
+ aList.setAutoDelete( false );
+ for ( int i = 0; i < AnglesList->count(); i++ )
+ if ( AnglesList->isSelected( i ) )
+ aList.append( AnglesList->item( i ) );
+
+ for ( int i = 0; i < aList.count(); i++ )
+ delete aList.at( i );
+}
+
--- /dev/null
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESHGUI_ExtrusionAlongPathDlg.h
+// Author : Vadim SANDLER
+// Module : SMESH
+// $Header:
+
+#ifndef DIALOGBOX_EXTRUSION_PATH_H
+#define DIALOGBOX_EXTRUSION_PATH_H
+
+#include "SALOME_Selection.h"
+#include "SMESH_LogicalFilter.hxx"
+#include "SMESH_TypeFilter.hxx"
+// QT Includes
+#include <qdialog.h>
+
+class QButtonGroup;
+class QRadioButton;
+class QGroupBox;
+class QLabel;
+class QToolButton;
+class QLineEdit;
+class QCheckBox;
+class QListBox;
+class QPushButton;
+class SMESHGUI_SpinBox;
+class SMESHGUI;
+class SMESH_Actor;
+
+// IDL Headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+//=================================================================================
+// class : SMESHGUI_ExtrusionAlongPathDlg
+// purpose :
+//=================================================================================
+class SMESHGUI_ExtrusionAlongPathDlg : public QDialog
+{
+ Q_OBJECT
+
+ class SetBusy {
+ public:
+ SetBusy( SMESHGUI_ExtrusionAlongPathDlg* _dlg ) { myDlg = _dlg; myDlg->myBusy = true; }
+ ~SetBusy() { myDlg->myBusy = false; }
+ private:
+ SMESHGUI_ExtrusionAlongPathDlg* myDlg;
+ };
+ friend class SetBusy;
+
+public:
+ SMESHGUI_ExtrusionAlongPathDlg( QWidget* parent = 0, SALOME_Selection* Sel = 0, bool modal = FALSE );
+ ~SMESHGUI_ExtrusionAlongPathDlg();
+
+ bool eventFilter( QObject* object, QEvent* event );
+
+protected slots:
+ void reject();
+
+private:
+ void Init( bool ResetControls = true ) ;
+ void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
+ int GetConstructorId();
+ void SetEditCurrentArgument( QToolButton* button );
+
+ SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
+ SALOME_Selection* mySelection ; /* User shape selection */
+ QWidget* myEditCurrentArgument; /* Current argument */
+
+ bool myBusy;
+ SMESH::SMESH_IDSource_var myIDSource;
+ SMESH::SMESH_Mesh_var myMesh;
+ SMESH_Actor* myMeshActor;
+ SMESH::SMESH_Mesh_var myPathMesh;
+ GEOM::GEOM_Object_var myPathShape;
+ Handle(SMESH_LogicalFilter) myElementsFilter;
+ Handle(SMESH_TypeFilter) myPathMeshFilter;
+ int myType;
+
+ // widgets
+ QButtonGroup* ElementsTypeGrp;
+ QRadioButton* Elements1dRB;
+ QRadioButton* Elements2dRB;
+ QGroupBox* ArgumentsGrp;
+ QLabel* ElementsLab;
+ QToolButton* SelectElementsButton;
+ QLineEdit* ElementsLineEdit;
+ QCheckBox* MeshCheck;
+ QGroupBox* PathGrp;
+ QLabel* PathMeshLab;
+ QToolButton* SelectPathMeshButton;
+ QLineEdit* PathMeshLineEdit;
+ QLabel* PathShapeLab;
+ QToolButton* SelectPathShapeButton;
+ QLineEdit* PathShapeLineEdit;
+ QLabel* StartPointLab;
+ QToolButton* SelectStartPointButton;
+ QLineEdit* StartPointLineEdit;
+ QCheckBox* AnglesCheck;
+ QGroupBox* AnglesGrp;
+ QListBox* AnglesList;
+ QToolButton* AddAngleButton;
+ QToolButton* RemoveAngleButton;
+ SMESHGUI_SpinBox* AngleSpin;
+ QCheckBox* BasePointCheck;
+ QGroupBox* BasePointGrp;
+ QToolButton* SelectBasePointButton;
+ QLabel* XLab;
+ SMESHGUI_SpinBox* XSpin;
+ QLabel* YLab;
+ SMESHGUI_SpinBox* YSpin;
+ QLabel* ZLab;
+ SMESHGUI_SpinBox* ZSpin;
+ QGroupBox* ButtonsGrp;
+ QPushButton* OkButton;
+ QPushButton* ApplyButton;
+ QPushButton* CloseButton;
+
+private slots:
+ void TypeChanged( int type );
+ void ClickOnOk();
+ bool ClickOnApply();
+ void SetEditCurrentArgument();
+ void SelectionIntoArgument();
+ void DeactivateActiveDialog();
+ void ActivateThisDialog();
+ void onTextChange(const QString&);
+ void onSelectMesh();
+ void onAnglesCheck();
+ void onBasePointCheck();
+ void OnAngleAdded();
+ void OnAngleRemoved();
+};
+
+#endif // DIALOGBOX_EXTRUSION_PATH_H
#include <qvalidator.h>
#include <qpixmap.h>
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
using namespace std;
//=================================================================================
#include <qobjectlist.h>
#include <qvalidator.h>
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
#define SPACING 5
#define MARGIN 10
if ( aCriterion == FT_RangeOfIds ||
aCriterion == FT_BelongToGeom ||
aCriterion == FT_BelongToPlane ||
- aCriterion == FT_BelongToCylinder )
+ aCriterion == FT_BelongToCylinder ||
+ aCriterion == FT_LyingOnGeom)
{
if ( aTable->text( i, 2 ).isEmpty() )
{
if ( aCriterionType != FT_RangeOfIds &&
aCriterionType != FT_BelongToGeom &&
aCriterionType != FT_BelongToPlane &&
- aCriterionType != FT_BelongToCylinder )
+ aCriterionType != FT_BelongToCylinder &&
+ aCriterionType != FT_LyingOnGeom)
{
theCriterion.Compare = ( (ComboItem*)aTable->item( theRow, 1 ) )->GetValue();
theCriterion.Threshold = aTable->item( theRow, 2 )->text().toDouble();
if ( theCriterion.Type != FT_RangeOfIds &&
theCriterion.Type != FT_BelongToGeom &&
theCriterion.Type != FT_BelongToPlane &&
- theCriterion.Type != FT_BelongToCylinder )
+ theCriterion.Type != FT_BelongToCylinder &&
+ theCriterion.Type != FT_LyingOnGeom)
aTable->setText( theRow, 2, QString( "%1" ).arg( theCriterion.Threshold, 0, 'g', 15 ) );
else
aTable->setText( theRow, 2, QString( theCriterion.ThresholdStr ) );
int aType = GetType();
addRow( myTables[ aType ], aType );
- Table* aTable = myTables[ aType ];
Update();
}
ComboItem* anItem = ( (ComboItem*)aTable->item( aRow, 0 ) );
bool toEnable = ( (ComboItem*)aTable->item( aRow, 1 ) )->GetValue() == FT_EqualTo &&
GetCriterionType( aRow ) != FT_BelongToGeom &&
+ GetCriterionType( aRow ) != FT_LyingOnGeom &&
GetCriterionType( aRow ) != FT_RangeOfIds &&
GetCriterionType( aRow ) != FT_FreeEdges;
if ( !myAddWidgets.contains( anItem ) )
else if ( aCriterionType == SMESH::FT_RangeOfIds ||
aCriterionType == SMESH::FT_BelongToGeom ||
aCriterionType == SMESH::FT_BelongToPlane ||
- aCriterionType == SMESH::FT_BelongToCylinder )
+ aCriterionType == SMESH::FT_BelongToCylinder ||
+ aCriterionType == SMESH::FT_LyingOnGeom)
{
QMap<int, QString> aMap;
aMap[ FT_EqualTo ] = tr( "EQUAL_TO" );
aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" );
aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" );
aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
+ aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" );
}
return aCriteria;
}
aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" );
aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" );
aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
+ aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" );
}
return aCriteria;
}
aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" );
aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" );
aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
+ aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" );
+ aCriteria[ SMESH::FT_Length2D ] = tr( "LENGTH2D" );
+ aCriteria[ SMESH::FT_MultiConnection2D] = tr( "MULTI2D_BORDERS" );
}
return aCriteria;
}
static QMap<int, QString> aCriteria;
if ( aCriteria.isEmpty() )
{
+ aCriteria[ SMESH::FT_AspectRatio3D] = tr( "ASPECT_RATIO_3D" );
aCriteria[ SMESH::FT_RangeOfIds ] = tr( "RANGE_OF_IDS" );
aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" );
+ aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" );
}
return aCriteria;
}
static int aLenCr = abs( aMaxLenCr -
aMetrics.width( tr( "CRITERION" ) ) ) / aMetrics.width( ' ' ) + 5;
- static int aLenCo = abs( maxLength( getCompare(), aMetrics ) -
- aMetrics.width( tr( "COMPARE" ) ) ) / aMetrics.width( ' ' ) + 5;
-
QString aCrStr;
aCrStr.fill( ' ', aLenCr );
QString aCoStr;
int aType = myTable->GetCriterionType( i );
if ( aType == FT_BelongToGeom ||
aType == FT_BelongToPlane ||
- aType == FT_BelongToCylinder )
+ aType == FT_BelongToCylinder ||
+ aType == FT_LyingOnGeom)
{
QString aName;
myTable->GetThreshold( i, aName );
if ( aSelMap.Extent() > 0 )
{
- if(SMESH_Actor *anActor = SMESH::FindActorByEntry( anIter.Key()->getEntry() ) )
+ if( SMESH::FindActorByEntry( anIter.Key()->getEntry() ) )
{
for ( int i = 1; i <= aSelMap.Extent(); i++ )
aToBeFiltered.Add( aSelMap(i) );
!myTable->CurrentCell( aRow, aCol ) ||
myTable->GetCriterionType( aRow ) != FT_BelongToGeom &&
myTable->GetCriterionType( aRow ) != FT_BelongToPlane &&
- myTable->GetCriterionType( aRow ) != FT_BelongToCylinder)
+ myTable->GetCriterionType( aRow ) != FT_BelongToCylinder &&
+ myTable->GetCriterionType( aRow ) != FT_LyingOnGeom )
return;
Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject() ;
if ( myTable->CurrentCell( aRow, aCol ) &&
( myTable->GetCriterionType( aRow ) == FT_BelongToGeom ||
myTable->GetCriterionType( aRow ) == FT_BelongToPlane ||
- myTable->GetCriterionType( aRow ) == FT_BelongToCylinder ) )
+ myTable->GetCriterionType( aRow ) == FT_BelongToCylinder ||
+ myTable->GetCriterionType( aRow ) == FT_LyingOnGeom) )
{
- if ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom )
+ if ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom || myTable->GetCriterionType( aRow ) == FT_LyingOnGeom )
mySelection->AddFilter( new SALOME_TypeFilter( "GEOM" ) );
else if ( myTable->GetCriterionType( aRow ) == FT_BelongToPlane )
mySelection->AddFilter( new GEOM_FaceFilter( StdSelect_Plane ) );
//=================================================================================
void SMESHGUI_GroupDlg::setSelectionMode(int theMode)
{
+ // PAL7314
+ if (myMesh->_is_nil())
+ return;
+
if (mySelectionMode != theMode) {
mySelection->ClearIObjects();
mySelection->ClearFilters();
-// SMESH SMESHGUI : GUI for SMESH component\r
-//\r
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
-// \r
-// This library is free software; you can redistribute it and/or \r
-// modify it under the terms of the GNU Lesser General Public \r
-// License as published by the Free Software Foundation; either \r
-// version 2.1 of the License. \r
-// \r
-// This library is distributed in the hope that it will be useful, \r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \r
-// Lesser General Public License for more details. \r
-// \r
-// You should have received a copy of the GNU Lesser General Public \r
-// License along with this library; if not, write to the Free Software \r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA \r
-// \r
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
-//\r
-//\r
-//\r
-// File : SMESHGUI_MeshPatternDlg.cxx\r
-// Author : Sergey LITONIN\r
-// Module : SMESH\r
-\r
-#include "SMESHGUI_MeshPatternDlg.h"\r
-\r
-#include "QAD_Desktop.h"\r
-#include "QAD_FileDlg.h"\r
-\r
-#include "SMESHGUI_SpinBox.h"\r
-#include "SMESHGUI.h"\r
-#include "SALOME_Selection.h"\r
-#include "SMESH_NumberFilter.hxx"\r
-#include "SMESHGUI_Utils.h"\r
-#include "SMESHGUI_VTKUtils.h"\r
-#include "SMESHGUI_CreatePatternDlg.h"\r
-#include "SMESHGUI_PatternWidget.h"\r
-#include "SMESH_Actor.h"\r
-#include "SALOMEGUI_QtCatchCorbaException.hxx"\r
-#include "VTKViewer_ViewFrame.h"\r
-#include "SMESHGUI_PatternUtils.h"\r
-#include "SMESH_ActorUtils.h"\r
-\r
-#include <TColStd_MapOfInteger.hxx>\r
-\r
-#include <qframe.h>\r
-#include <qlayout.h>\r
-#include <qlineedit.h>\r
-#include <qpushbutton.h>\r
-#include <qgroupbox.h>\r
-#include <qlabel.h>\r
-#include <qradiobutton.h>\r
-#include <qcheckbox.h>\r
-#include <qbuttongroup.h>\r
-#include <qmessagebox.h>\r
-#include <qcstring.h>\r
-\r
-#include <vtkCell.h>\r
-#include <vtkIdList.h>\r
-#include <vtkIntArray.h>\r
-#include <vtkCellArray.h>\r
-#include <vtkUnsignedCharArray.h>\r
-#include <vtkUnstructuredGrid.h>\r
-#include <vtkDataSetMapper.h>\r
-\r
-#define SPACING 5\r
-#define MARGIN 10\r
-\r
-/*\r
- Class : SMESHGUI_MeshPatternDlg\r
- Description : Dialog to specify filters for VTK viewer\r
-*/\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg\r
-// Purpose : Constructor\r
-//=======================================================================\r
-SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( QWidget* theParent,\r
- SALOME_Selection* theSelection,\r
- const char* theName )\r
-: QDialog( theParent, theName, false,\r
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )\r
-{\r
- setCaption( tr( "CAPTION" ) );\r
-\r
- QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING );\r
-\r
- QFrame* aMainFrame = createMainFrame ( this );\r
- QFrame* aBtnFrame = createButtonFrame( this );\r
-\r
-\r
-\r
-\r
- aDlgLay->addWidget( aMainFrame );\r
- aDlgLay->addWidget( aBtnFrame );\r
-\r
- aDlgLay->setStretchFactor( aMainFrame, 1 );\r
-\r
- myCreationDlg = 0;\r
- Init( theSelection );\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::createMainFrame\r
-// Purpose : Create frame containing dialog's input fields\r
-//=======================================================================\r
-QFrame* SMESHGUI_MeshPatternDlg::createMainFrame( QWidget* theParent )\r
-{\r
- QPixmap iconSlct( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );\r
- QPixmap icon2d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) );\r
- QPixmap icon3d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) );\r
- QPixmap iconOpen( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_FILE_OPEN" ) ) );\r
-\r
- QPixmap iconSample2d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) );\r
- QPixmap iconSample3d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_3D" ) ) );\r
-\r
- QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent );\r
- aMainGrp->setFrameStyle( QFrame::NoFrame );\r
- aMainGrp->setInsideMargin( 0 );\r
-\r
- // Pattern type group\r
- \r
- myTypeGrp = new QButtonGroup( 1, Qt::Vertical, tr( "PATTERN_TYPE" ), aMainGrp );\r
- mySwitch2d = new QRadioButton( myTypeGrp );\r
- mySwitch3d = new QRadioButton( myTypeGrp );\r
- mySwitch2d->setPixmap( icon2d );\r
- mySwitch3d->setPixmap( icon3d );\r
- myTypeGrp->insert( mySwitch2d, Type_2d );\r
- myTypeGrp->insert( mySwitch3d, Type_3d );\r
-\r
-\r
- // Mesh group\r
- \r
- QGroupBox* aMeshGrp = new QGroupBox( 1, Qt::Vertical, tr( "SMESH_MESH" ), aMainGrp );\r
- new QLabel( tr( "SMESH_MESH" ), aMeshGrp );\r
- mySelBtn[ Mesh ] = new QPushButton( aMeshGrp );\r
- mySelBtn[ Mesh ]->setPixmap( iconSlct );\r
- mySelEdit[ Mesh ] = new QLineEdit( aMeshGrp );\r
- mySelEdit[ Mesh ]->setReadOnly( true );\r
-\r
- // Pattern group\r
- \r
- QGroupBox* aPatGrp = new QGroupBox( 1, Qt::Horizontal, tr( "PATTERN" ), aMainGrp );\r
-\r
- // pattern name\r
- QGroupBox* aNameGrp = new QGroupBox( 1, Qt::Vertical, aPatGrp );\r
- aNameGrp->setFrameStyle( QFrame::NoFrame );\r
- aNameGrp->setInsideMargin( 0 );\r
- new QLabel( tr( "PATTERN" ), aNameGrp );\r
- myName = new QLineEdit( aNameGrp );\r
- myName->setReadOnly( true );\r
- myOpenBtn = new QPushButton( aNameGrp );\r
- myOpenBtn->setPixmap( iconOpen );\r
- myNewBtn = new QPushButton( tr( "NEW" ), aNameGrp );\r
-\r
- // selection widgets\r
- QGroupBox* aGrp = new QGroupBox( 3, Qt::Horizontal, aPatGrp );\r
- aGrp->setFrameStyle( QFrame::NoFrame );\r
- aGrp->setInsideMargin( 0 );\r
-\r
- for ( int i = Object; i <= Vertex2; i++ )\r
- {\r
- mySelLbl[ i ] = new QLabel( aGrp );\r
- mySelBtn[ i ] = new QPushButton( aGrp );\r
- mySelBtn[ i ]->setPixmap( iconSlct );\r
- mySelEdit[ i ] = new QLineEdit( aGrp );\r
- mySelEdit[ i ]->setReadOnly( true );\r
- }\r
-\r
- // reverse check box\r
- myReverseChk = new QCheckBox( tr( "REVERSE" ), aPatGrp );\r
-\r
- // Pictures 2d and 3d\r
- for ( int i = 0; i < 2; i++ )\r
- {\r
- QWidget* aPreview, *aPicture;\r
- if ( i == 0 )\r
- {\r
- myPicture2d = new SMESHGUI_PatternWidget( aPatGrp ),\r
- myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );\r
- }\r
- else\r
- {\r
- myPicture3d = new QFrame( aPatGrp ),\r
- myPreview3d = new QLabel( myPicture3d );\r
- myPreview3d->setPixmap( iconSample3d );\r
- QGridLayout* aLay = new QGridLayout( myPicture3d, 3, 3, 0, 0 );\r
- QSpacerItem* aSpacerH1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );\r
- QSpacerItem* aSpacerH2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );\r
- QSpacerItem* aSpacerV1 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );\r
- QSpacerItem* aSpacerV2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );\r
- aLay->addItem( aSpacerH1, 1, 0 );\r
- aLay->addItem( aSpacerH2, 1, 2 );\r
- aLay->addItem( aSpacerV1, 0, 1 );\r
- aLay->addItem( aSpacerV2, 2, 1 );\r
- aLay->addWidget( myPreview3d, 1, 1 );\r
- }\r
- }\r
-\r
- myPreviewChk = new QCheckBox( tr( "PREVIEW" ), aPatGrp );\r
-\r
- // Connect signals and slots\r
-\r
- connect( myTypeGrp, SIGNAL( clicked( int ) ), SLOT( onTypeChanged( int ) ) );\r
- connect( myOpenBtn, SIGNAL( clicked() ), SLOT( onOpen() ) );\r
- connect( myNewBtn, SIGNAL( clicked() ), SLOT( onNew() ) );\r
- connect( myReverseChk, SIGNAL( toggled( bool ) ), SLOT( onReverse( bool ) ) );\r
- connect( myPreviewChk, SIGNAL( toggled( bool ) ), SLOT( onPreview( bool ) ) );\r
-\r
- QMap< int, QPushButton* >::iterator anIter;\r
- for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter )\r
- connect( *anIter, SIGNAL( clicked() ), SLOT( onSelInputChanged() ) );\r
-\r
- return aMainGrp;\r
-}\r
-\r
-//=======================================================================\r
-\r
-// name : SMESHGUI_MeshPatternDlg::createButtonFrame\r
-// Purpose : Create frame containing buttons\r
-//=======================================================================\r
-QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame( QWidget* theParent )\r
-{\r
- QFrame* aFrame = new QFrame( theParent );\r
- aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );\r
-\r
- myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame );\r
- myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame );\r
- myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame );\r
-\r
- QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );\r
-\r
- QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING );\r
-\r
- aLay->addWidget( myOkBtn );\r
- aLay->addWidget( myApplyBtn );\r
- aLay->addItem( aSpacer);\r
- aLay->addWidget( myCloseBtn );\r
-\r
- connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) );\r
- connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ;\r
- connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) );\r
-\r
- return aFrame;\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg\r
-// Purpose : Destructor\r
-//=======================================================================\r
-SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg()\r
-{\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::Init\r
-// Purpose : Init dialog fields, connect signals and slots, show dialog\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::Init( SALOME_Selection* theSelection )\r
-{\r
- myPattern = SMESH::GetPattern();\r
- myPreviewActor = 0;\r
- myIsCreateDlgOpen = false;\r
- mySelInput = Mesh;\r
- myType = -1;\r
- myNbPoints = -1;\r
- mySelection = theSelection;\r
- SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI();\r
- aSMESHGUI->SetActiveDialogBox( ( QDialog* )this );\r
- myMesh = SMESH::SMESH_Mesh::_nil();\r
-\r
- myMeshShape = GEOM::GEOM_Object::_nil();\r
- myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();\r
- myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();\r
- myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();\r
-\r
- // selection and SMESHGUI\r
- connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );\r
- connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) );\r
- connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) );\r
-\r
- myTypeGrp->setButton( Type_2d );\r
- onTypeChanged( Type_2d );\r
-\r
- updateGeometry();\r
-\r
- resize( minimumSize() );\r
-\r
- activateSelection();\r
- onSelectionDone();\r
-\r
- int x, y ;\r
- aSMESHGUI->DefineDlgPosition( this, x, y );\r
- this->move( x, y );\r
- this->show();\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::isValid\r
-// Purpose : Verify validity of entry data\r
-//=======================================================================\r
-bool SMESHGUI_MeshPatternDlg::isValid( const bool theMess )\r
-{\r
- if ( myMesh->_is_nil() || myMeshShape->_is_nil() || myGeomObj[ Object ]->_is_nil() ||\r
- myGeomObj[ Vertex1 ]->_is_nil() || myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil() )\r
- {\r
- if ( theMess )\r
- QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),\r
- tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok );\r
- return false;\r
- }\r
- else\r
- return true;\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onApply\r
-// Purpose : SLOT called when "Apply" button pressed.\r
-//=======================================================================\r
-bool SMESHGUI_MeshPatternDlg::onApply()\r
-{\r
- try\r
- {\r
- if ( !isValid() )\r
- return false;\r
-\r
- if ( myType == Type_2d )\r
- myPattern->ApplyToFace(\r
- myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked() );\r
- else\r
- myPattern->ApplyTo3DBlock(\r
- myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ] );\r
-\r
- if ( myPattern->MakeMesh( myMesh ) )\r
- {\r
- mySelection->ClearIObjects();\r
- SMESH::UpdateView();\r
- SMESHGUI::GetSMESHGUI()->GetActiveStudy()->updateObjBrowser( true );\r
- return true;\r
- }\r
- else\r
- {\r
- QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),\r
- tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ), QMessageBox::Ok );\r
- return false;\r
- }\r
- }\r
- catch( const SALOME::SALOME_Exception& S_ex )\r
- {\r
- QtCatchCorbaException( S_ex ); \r
- }\r
- catch( ... )\r
- {\r
- }\r
-\r
- return false;\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onOk\r
-// Purpose : SLOT called when "Ok" button pressed.\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onOk()\r
-{\r
- if ( onApply() )\r
- onClose();\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onClose\r
-// Purpose : SLOT called when "Close" button pressed. Close dialog\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onClose()\r
-{\r
- mySelection->ClearFilters();\r
- QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );\r
- disconnect( mySelection, 0, this, 0 );\r
- disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 );\r
- SMESHGUI::GetSMESHGUI()->ResetState();\r
- erasePreview();\r
- reject();\r
-}\r
-\r
-\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onSelectionDone\r
-// Purpose : SLOT called when selection changed\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onSelectionDone()\r
-{\r
- try\r
- {\r
- if ( mySelection->IObjectCount() != 1 )\r
- return;\r
-\r
- if ( mySelInput == Mesh )\r
- {\r
- // Retrieve mesh from selection\r
- Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject();\r
- SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIO );\r
- if ( aMesh->_is_nil() )\r
- return;\r
-\r
- // Get geom object corresponding to the mesh\r
- SALOMEDS::Study_var aStudy =\r
- SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getStudyDocument();\r
-\r
- SALOMEDS::SObject_var aSO = SMESH::FindSObject( aMesh.in() );\r
- if ( aSO->_is_nil() )\r
- return;\r
-\r
- bool isFound = false;\r
- SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( aSO );\r
- for( ; anIter->More(); anIter->Next() )\r
- {\r
- SALOMEDS::SObject_var aSO = anIter->Value();\r
- SALOMEDS::SObject_var aRefSO;\r
-\r
- GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow(\r
- aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() );\r
-\r
- if ( !aMeshShape->_is_nil() )\r
- {\r
- isFound = true;\r
- myMeshShape = aMeshShape;\r
- break;\r
-\r
- }\r
- }\r
-\r
- if ( !isFound )\r
- return;\r
-\r
- // Clear fields of geom objects if mesh was changed\r
- if ( myMesh != aMesh )\r
- {\r
- for ( int i = Object; i <= Vertex2; i++ )\r
- {\r
- myGeomObj[ i ] = GEOM::GEOM_Object::_nil();\r
- mySelEdit[ i ]->setText( "" );\r
- }\r
- }\r
-\r
- myMesh = aMesh;\r
-\r
- // Set name of mesh in line edit\r
- QString aName;\r
- SMESH::GetNameOfSelectedIObjects( mySelection, aName );\r
- mySelEdit[ Mesh ]->setText( aName );\r
- }\r
- else\r
- {\r
- // Get geom object from selection\r
- Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject();\r
- GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>( anIO );\r
- if ( anObj->_is_nil() )\r
- return;\r
-\r
- // Clear fields of vertexes if face or 3d block was changed\r
- if ( anObj != myGeomObj[ mySelInput ] && mySelInput == Object )\r
- {\r
- for ( int i = Vertex1; i <= Vertex2; i++ )\r
- {\r
- myGeomObj[ i ] = GEOM::GEOM_Object::_nil();\r
- mySelEdit[ i ]->setText( "" );\r
- }\r
- }\r
-\r
- myGeomObj[ mySelInput ] = anObj;\r
-\r
- // Set name of geom object in line edit\r
- QString aName;\r
- SMESH::GetNameOfSelectedIObjects( mySelection, aName );\r
- mySelEdit[ mySelInput ]->setText( aName );\r
- }\r
- }\r
- catch( const SALOME::SALOME_Exception& S_ex )\r
- {\r
- QtCatchCorbaException( S_ex );\r
- resetSelInput();\r
- }\r
- catch( ... )\r
- {\r
- resetSelInput();\r
- }\r
-\r
- updateWgState();\r
- displayPreview();\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::resetSelInput\r
-// Purpose : Reset fields corresponding to the current selection input\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::resetSelInput()\r
-{\r
- if ( mySelInput == Mesh )\r
- {\r
- myMesh = SMESH::SMESH_Mesh::_nil();\r
- myMeshShape = GEOM::GEOM_Object::_nil();\r
- }\r
-\r
- else\r
- myGeomObj[ mySelInput ] = GEOM::GEOM_Object::_nil();\r
-\r
- mySelEdit[ mySelInput ]->setText( "" );\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onDeactivate\r
-// Purpose : SLOT called when dialog must be deativated\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onDeactivate()\r
-{\r
- mySelection->ClearFilters();\r
- //if ( myReverseChk->isChecked() )\r
- // erasePreview();\r
- disconnect( mySelection, 0, this, 0 );\r
- setEnabled( false );\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::enterEvent\r
-// Purpose : Event filter\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::enterEvent( QEvent* )\r
-{\r
- if ( myIsCreateDlgOpen )\r
- return;\r
- \r
- if ( myReverseChk->isChecked() )\r
- displayPreview();\r
- SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ;\r
- setEnabled( true );\r
- activateSelection();\r
- connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );\r
-}\r
-\r
-\r
-//=================================================================================\r
-// function : closeEvent()\r
-// purpose :\r
-//=================================================================================\r
-void SMESHGUI_MeshPatternDlg::closeEvent( QCloseEvent* e )\r
-{\r
- onClose() ;\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onSelInputChanged\r
-// Purpose : SLOT. Called when -> button clicked.\r
-// Change current selection input field\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onSelInputChanged()\r
-{\r
- const QObject* aSender = sender();\r
- for ( int i = Mesh; i <= Vertex2; i++ )\r
- if ( aSender == mySelBtn[ i ] )\r
- mySelInput = i;\r
-\r
- activateSelection();\r
- onSelectionDone();\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::prepareFilters\r
-// Purpose : Prepare filters for dialog\r
-//=======================================================================\r
-\r
-QStringList SMESHGUI_MeshPatternDlg::prepareFilters() const\r
-{\r
- static QStringList aList;\r
- if ( aList.isEmpty() )\r
- {\r
- aList.append( tr( "PATTERN_FILT" ) );\r
- //aList.append( tr( "ALL_FILES_FILTER" ) );\r
- }\r
-\r
- return aList;\r
-}\r
-\r
-//================================================================\r
-\r
-// Function : SMESHGUI_MeshPatternDlg::autoExtension\r
-// Purpose : Append extension to the file name\r
-//================================================================\r
-QString SMESHGUI_MeshPatternDlg::autoExtension( const QString& theFileName ) const\r
-{\r
- QString anExt = theFileName.section( '.', -1 );\r
- return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName;\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onOpen\r
-// Purpose : SLOT. Called when "Open" button clicked.\r
-// Displays file open dialog\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onOpen()\r
-{\r
- QAD_FileDlg* aDlg = new QAD_FileDlg( this, true );\r
- aDlg->setCaption( tr( "LOAD_PATTERN" ) );\r
- aDlg->setMode( QFileDialogP::ExistingFile );\r
- aDlg->setFilters( prepareFilters() );\r
- if ( myName->text() != "" )\r
- aDlg->setSelection( myName->text() + ".smp" );\r
- QPushButton* anOkBtn = ( QPushButton* )aDlg->child( "OK", "QPushButton" );\r
- if ( anOkBtn != 0 )\r
- anOkBtn->setText( tr( "SMESH_BUT_OK" ) );\r
-\r
- if ( aDlg->exec() != Accepted )\r
- return;\r
-\r
- QString fName = aDlg->selectedFile();\r
- if ( fName.isEmpty() )\r
- return;\r
-\r
- if ( QFileInfo( fName ).extension().isEmpty() )\r
- fName = autoExtension( fName );\r
-\r
- fName = QDir::convertSeparators( fName );\r
- \r
- QString prev = QDir::convertSeparators( myName->text() );\r
- if ( prev == fName )\r
- return;\r
-\r
- // Read string from file\r
- QFile aFile( fName );\r
- if ( !aFile.open( IO_ReadOnly ) )\r
- {\r
- QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),\r
- tr( "SMESH_ERROR" ), tr( "ERROR_OF_OPENING" ), QMessageBox::Ok );\r
- return;\r
- }\r
- \r
- QByteArray aDataArray = aFile.readAll();\r
- const char* aData = aDataArray.data();\r
- if ( aData == 0 )\r
- {\r
- QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),\r
- tr( "SMESH_ERROR" ), tr( "ERROR_OF_READING" ), QMessageBox::Ok );\r
- return;\r
- }\r
- \r
- if ( loadFromFile( aData ) )\r
- myName->setText( QFileInfo( fName ).baseName() );\r
- \r
- updateWgState();\r
- displayPreview();\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onCloseCreationDlg\r
-// Purpose : SLOT. Called when "Pattern creation" dialog closed with "Close"\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onCloseCreationDlg()\r
-{\r
- setEnabled( true );\r
- myIsCreateDlgOpen = false;\r
-}\r
-\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onOkCreationDlg\r
-// Purpose : SLOT. Called when "Pattern creation" dialog closed with OK\r
-// or SAVE buttons. Initialize myPattern field. Redisplay preview\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onOkCreationDlg()\r
-{\r
- myPattern = SMESH::SMESH_Pattern::_duplicate( myCreationDlg->GetPattern() );\r
- myName->setText( myCreationDlg->GetPatternName() );\r
- displayPreview();\r
- setEnabled( true );\r
- myIsCreateDlgOpen = false;\r
-}\r
-\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onNew\r
-// Purpose : SLOT. Called when "New..." button clicked. Create new pattern\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onNew()\r
-{\r
- setEnabled( false );\r
- myIsCreateDlgOpen = true;\r
- if ( myCreationDlg == 0 )\r
- {\r
- myCreationDlg = new SMESHGUI_CreatePatternDlg( this, mySelection, myType );\r
- connect( myCreationDlg, SIGNAL( NewPattern() ), SLOT( onOkCreationDlg() ) );\r
- connect( myCreationDlg, SIGNAL( Close() ), SLOT( onCloseCreationDlg() ) );\r
- }\r
- else\r
- myCreationDlg->Init( mySelection, myType );\r
-\r
- myCreationDlg->SetMesh( myMesh );\r
- myCreationDlg->show();\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onReverse\r
-// Purpose : SLOT. Called when state of "Reverse order..." checkbox chaged\r
-// Calculate new points of the mesh to be created. Redisplay preview\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onReverse( bool )\r
-{\r
- displayPreview();\r
-}\r
-\r
-//=======================================================================\r
-\r
-// name : SMESHGUI_MeshPatternDlg::onPreview\r
-// Purpose : SLOT. Called when state of "Preview" checkbox changed\r
-// Display/Erase preview\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onPreview( bool )\r
-{\r
- displayPreview();\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::displayPreview\r
-// Purpose : Display preview\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::displayPreview()\r
-{\r
- try\r
- {\r
- // Redisplay preview in dialog\r
-\r
- SMESH::point_array_var pnts = myPattern->GetPoints();\r
- SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();\r
- SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints();\r
-\r
- if ( pnts->length() == 0 ||\r
- keyPoints->length() == 0 ||\r
- elemPoints->length() == 0 )\r
- {\r
- erasePreview();\r
- return;\r
- }\r
-\r
- else\r
- {\r
- PointVector aPoints( pnts->length() );\r
- QValueVector<int> aKeyPoints( keyPoints->length() );\r
- ConnectivityVector anElemPoints( elemPoints->length() );\r
-\r
- for ( int i = 0, n = pnts->length(); i < n; i++ )\r
- aPoints[ i ] = pnts[ i ];\r
-\r
- for ( int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++ )\r
- aKeyPoints[ i2 ] = keyPoints[ i2 ];\r
-\r
- for ( int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++ )\r
- {\r
- QValueVector<int> aVec( elemPoints[ i3 ].length() );\r
- for ( int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++ )\r
- aVec[ i4 ] = elemPoints[ i3 ][ i4 ];\r
-\r
- anElemPoints[ i3 ] = aVec;\r
- }\r
-\r
- myPicture2d->SetPoints( aPoints, aKeyPoints, anElemPoints );\r
- }\r
-\r
-\r
- // Redisplay preview in 3D viewer\r
-\r
- if ( myPreviewActor != 0 )\r
- {\r
- if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() )\r
- {\r
- vf->RemoveActor(myPreviewActor);\r
- vf->Repaint();\r
- }\r
- myPreviewActor->Delete();\r
- myPreviewActor = 0;\r
- }\r
-\r
- if ( !myPreviewChk->isChecked() || !isValid( false ) )\r
- return;\r
-\r
- vtkUnstructuredGrid* aGrid = getGrid();\r
- if ( aGrid == 0 )\r
- return;\r
-\r
- // Create and display actor\r
- vtkDataSetMapper* aMapper = vtkDataSetMapper::New();\r
- aMapper->SetInput( aGrid );\r
-\r
- myPreviewActor = SALOME_Actor::New();\r
- myPreviewActor->PickableOff();\r
- myPreviewActor->SetMapper( aMapper );\r
-\r
- vtkProperty* aProp = vtkProperty::New();\r
- aProp->SetRepresentationToWireframe();\r
- aProp->SetColor( 250, 0, 250 );\r
- if ( SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh ) )\r
- aProp->SetLineWidth( SMESH::GetFloat( "SMESH:SettingsWidth", 1 ) +1 );\r
- else\r
- aProp->SetLineWidth( 1 );\r
- myPreviewActor->SetProperty( aProp );\r
-\r
- myPreviewActor->SetRepresentation( 3 );\r
-\r
- SMESH::GetCurrentVtkView()->AddActor( myPreviewActor );\r
- SMESH::GetCurrentVtkView()->Repaint();\r
-\r
- aProp->Delete();\r
- aGrid->Delete();\r
- }\r
- catch( const SALOME::SALOME_Exception& S_ex )\r
- {\r
- QtCatchCorbaException( S_ex );\r
- erasePreview();\r
- }\r
- catch( ... )\r
- {\r
- erasePreview();\r
- }\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::erasePreview\r
-// Purpose : Erase preview\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::erasePreview()\r
-{\r
- // Erase preview in 2D viewer\r
- myPicture2d->SetPoints( PointVector(), QValueVector<int>(), ConnectivityVector() );\r
-\r
- // Erase preview in 3D viewer\r
- if ( myPreviewActor == 0 )\r
- return;\r
-\r
-\r
- if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() )\r
- {\r
- vf->RemoveActor(myPreviewActor);\r
- vf->Repaint();\r
- }\r
- myPreviewActor->Delete();\r
- myPreviewActor = 0;\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::updateWgState\r
-// Purpose : Enable/disable selection widgets\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::updateWgState()\r
-{\r
- if ( myMesh->_is_nil() )\r
- {\r
- for ( int i = Object; i <= Vertex2; i++ )\r
- {\r
- mySelBtn [ i ]->setEnabled( false );\r
- mySelEdit[ i ]->setEnabled( false );\r
- mySelEdit[ i ]->setText( "" );\r
- }\r
- }\r
- else\r
- {\r
- mySelBtn [ Object ]->setEnabled( true );\r
- mySelEdit[ Object ]->setEnabled( true );\r
- \r
- if ( myGeomObj[ Object ]->_is_nil() )\r
- {\r
- for ( int i = Vertex1; i <= Vertex2; i++ )\r
- {\r
- mySelBtn [ i ]->setEnabled( false );\r
- mySelEdit[ i ]->setEnabled( false );\r
- mySelEdit[ i ]->setText( "" );\r
- }\r
- }\r
- else\r
- {\r
- for ( int i = Object; i <= Vertex2; i++ )\r
- {\r
- mySelBtn [ i ]->setEnabled( true );\r
- mySelEdit[ i ]->setEnabled( true );\r
- }\r
- }\r
- }\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::activateSelection\r
-// Purpose : Activate selection in accordance with current selection input\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::activateSelection()\r
-{\r
- mySelection->ClearFilters();\r
- QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );\r
- \r
- if ( mySelInput == Object && !myMeshShape->_is_nil() )\r
- {\r
- if ( myType == Type_2d )\r
- {\r
- if ( myNbPoints > 0 )\r
- mySelection->AddFilter( new SMESH_NumberFilter( \r
-\r
- "GEOM", TopAbs_VERTEX, myNbPoints, TopAbs_FACE, myMeshShape ) );\r
- else\r
- mySelection->AddFilter( new SMESH_NumberFilter(\r
- "GEOM", TopAbs_SHAPE, myNbPoints, TopAbs_FACE, myMeshShape ) );\r
- }\r
- else\r
- {\r
- TColStd_MapOfInteger aTypes;\r
- aTypes.Add( TopAbs_SHELL );\r
- aTypes.Add( TopAbs_SOLID );\r
- mySelection->AddFilter( new SMESH_NumberFilter(\r
- "GEOM", TopAbs_FACE, 6, aTypes, myMeshShape, true ) );\r
- }\r
- }\r
- else if ( ( mySelInput == Vertex1 || mySelInput == Vertex2 ) && !myGeomObj[ Object ]->_is_nil() )\r
- {\r
- mySelection->AddFilter( new SMESH_NumberFilter(\r
- "GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX, myGeomObj[ Object ] ) );\r
- }\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::loadFromFile\r
-// Purpose : Load pattern from file\r
-//=======================================================================\r
-bool SMESHGUI_MeshPatternDlg::loadFromFile( const QString& theName )\r
-{\r
- try\r
- {\r
- SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern();\r
-\r
- if ( !aPattern->LoadFromFile( theName.latin1() ) ||\r
- myType == Type_2d && !aPattern->Is2D())\r
- {\r
- SMESH::SMESH_Pattern::ErrorCode aCode = aPattern->GetErrorCode();\r
- QString aMess;\r
- if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr( "ERR_READ_NB_POINTS" );\r
- else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_POINT_COORDS ) aMess = tr( "ERR_READ_POINT_COORDS" );\r
- else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_TOO_FEW_POINTS ) aMess = tr( "ERR_READ_TOO_FEW_POINTS" );\r
- else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_3D_COORD ) aMess = tr( "ERR_READ_3D_COORD" );\r
- else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NO_KEYPOINT ) aMess = tr( "ERR_READ_NO_KEYPOINT" );\r
- else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_INDEX ) aMess = tr( "ERR_READ_BAD_INDEX" );\r
- else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_ELEM_POINTS ) aMess = tr( "ERR_READ_ELEM_POINTS" );\r
- else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NO_ELEMS ) aMess = tr( "ERR_READ_NO_ELEMS" );\r
- else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_KEY_POINT ) aMess = tr( "ERR_READ_BAD_KEY_POINT" );\r
- else aMess = tr( "ERROR_OF_LOADING" );\r
-\r
- QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),\r
- tr( "SMESH_ERROR" ), aMess, QMessageBox::Ok );\r
- return false;\r
- }\r
- else\r
- {\r
- myPattern = aPattern;\r
- return true;\r
- }\r
- }\r
- catch( const SALOME::SALOME_Exception& S_ex )\r
- {\r
- QtCatchCorbaException( S_ex );\r
- QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),\r
- tr( "SMESH_ERROR" ), tr( "ERROR_OF_LOADING" ), QMessageBox::Ok );\r
- return false;\r
- }\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::onTypeChanged\r
-\r
-// Purpose : SLOT. Called when pattern type changed.\r
-// Change dialog's look and feel\r
-//=======================================================================\r
-void SMESHGUI_MeshPatternDlg::onTypeChanged( int theType )\r
-{\r
- if ( myType == theType )\r
- return;\r
-\r
- myType = theType;\r
-\r
- myNbPoints = -1;\r
- myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();\r
- myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();\r
- myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();\r
- myPattern = SMESH::GetPattern();\r
-\r
- myName->setText( "" );\r
- mySelEdit[ Object ]->setText( "" );\r
- mySelEdit[ Vertex1 ]->setText( "" );\r
- mySelEdit[ Vertex2 ]->setText( "" );\r
-\r
- if ( theType == Type_2d )\r
- {\r
- mySelLbl [ Vertex2 ]->hide();\r
- mySelBtn [ Vertex2 ]->hide();\r
- mySelEdit[ Vertex2 ]->hide();\r
- myReverseChk->show();\r
- myPicture2d->show();\r
- myPicture3d->hide();\r
- mySelLbl[ Object ]->setText( tr( "FACE" ) );\r
- mySelLbl[ Vertex1 ]->setText( tr( "VERTEX" ) );\r
- }\r
- else\r
- {\r
- mySelLbl [ Vertex2 ]->show();\r
- mySelBtn [ Vertex2 ]->show();\r
- mySelEdit[ Vertex2 ]->show();\r
- myReverseChk->hide();\r
- myPicture2d->hide();\r
- myPicture3d->show();\r
- mySelLbl[ Object ]->setText( tr( "3D_BLOCK" ) );\r
- mySelLbl[ Vertex1 ]->setText( tr( "VERTEX1" ) );\r
- mySelLbl[ Vertex2 ]->setText( tr( "VERTEX2" ) );\r
- }\r
-\r
- mySelInput = Mesh;\r
- activateSelection();\r
- updateWgState();\r
- displayPreview();\r
-}\r
-\r
-//=======================================================================\r
-// name : SMESHGUI_MeshPatternDlg::getGrid\r
-// Purpose : Get unstructured grid for pattern\r
-//=======================================================================\r
-vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid()\r
-{\r
- try\r
- {\r
- // Get points from pattern\r
- SMESH::point_array_var pnts = myType == Type_2d\r
- ? myPattern->ApplyToFace( myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked() )\r
- : myPattern->ApplyTo3DBlock( myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ] );\r
-\r
- SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints();\r
-\r
- if ( pnts->length() == 0 || elemPoints->length() == 0 )\r
- return 0;\r
-\r
- \r
-\r
- // to do : to be removed /////////////////////////////////////////////\r
-\r
-#ifdef DEB_SLN\r
- for ( int i1 = 0, n1 = pnts->length(); i1 < n1; i1++ )\r
- printf( "%d: %g %g %g\n", i1, pnts[ i1 ].x, pnts[ i1 ].y, pnts[ i1 ].z );\r
-\r
- printf( "\nELEMENTS : \n" );\r
- for ( int i2 = 0, n2 = elemPoints->length(); i2 < n2; i2++ )\r
- {\r
-\r
- printf( "%d: ", i2 );\r
- for ( int i3 = 0, n3 = elemPoints[ i2 ].length(); i3 < n3; i3++ )\r
- printf( "%d ", elemPoints[ i2 ][ i3 ] );\r
-\r
- printf( "\n" );\r
-\r
- }\r
-#endif\r
- //////////////////////////////////////////////////////////////////////\r
-\r
- // Calculate number of points used for cell\r
- vtkIdType aNbCells = elemPoints->length();\r
- vtkIdType aCellsSize = 0;\r
- for ( int i = 0, n = elemPoints->length(); i < n; i++ )\r
- aCellsSize += elemPoints[ i ].length();\r
-\r
- // Create unstructured grid and other usefull arrays\r
- vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();\r
-\r
- vtkCellArray* aConnectivity = vtkCellArray::New();\r
- aConnectivity->Allocate( aCellsSize, 0 );\r
-\r
- vtkPoints* aPoints = vtkPoints::New();\r
- aPoints->SetNumberOfPoints( pnts->length() );\r
-\r
- vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();\r
- aCellTypesArray->SetNumberOfComponents( 1 );\r
- aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );\r
-\r
- vtkIdList *anIdList = vtkIdList::New();\r
-\r
- // Fill array of points\r
- for ( int p = 0, nbPnt = pnts->length(); p < nbPnt; p++ )\r
- aPoints->SetPoint( p, pnts[ p ].x, pnts[ p ].y, pnts[ p ].z );\r
-\r
- for ( int e = 0, nbElem = elemPoints->length(); e < nbElem; e++ )\r
- {\r
- int nbPoints = elemPoints[ e ].length();\r
- anIdList->SetNumberOfIds( nbPoints );\r
- for ( int i = 0; i < nbPoints; i++ )\r
- anIdList->SetId( i, elemPoints[ e ][ i ] );\r
-\r
- aConnectivity->InsertNextCell( anIdList );\r
-\r
- if ( nbPoints == 3 ) aCellTypesArray->InsertNextValue( VTK_TRIANGLE );\r
- else if ( nbPoints == 5 ) aCellTypesArray->InsertNextValue( VTK_PYRAMID );\r
- else if ( nbPoints == 6 ) aCellTypesArray->InsertNextValue( VTK_WEDGE );\r
- else if ( nbPoints == 8 ) aCellTypesArray->InsertNextValue( VTK_HEXAHEDRON );\r
- else if ( nbPoints == 4 && myType == Type_2d ) aCellTypesArray->InsertNextValue( VTK_QUAD );\r
- else if ( nbPoints == 4 && myType == Type_3d ) aCellTypesArray->InsertNextValue( VTK_TETRA );\r
- else aCellTypesArray->InsertNextValue( VTK_EMPTY_CELL );\r
- }\r
-\r
- vtkIntArray* aCellLocationsArray = vtkIntArray::New();\r
- aCellLocationsArray->SetNumberOfComponents( 1 );\r
- aCellLocationsArray->SetNumberOfTuples( aNbCells );\r
-\r
- aConnectivity->InitTraversal();\r
- for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )\r
- aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );\r
-\r
- aGrid->SetPoints( aPoints );\r
- aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );\r
-\r
- aConnectivity->Delete();\r
- aPoints->Delete();\r
- aCellTypesArray->Delete();\r
- anIdList->Delete();\r
- aCellLocationsArray->Delete();\r
-\r
- return aGrid;\r
- }\r
- catch( ... )\r
- {\r
- return 0;\r
- }\r
-}\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESHGUI_MeshPatternDlg.cxx
+// Author : Sergey LITONIN
+// Module : SMESH
+
+#include "SMESHGUI_MeshPatternDlg.h"
+
+#include "QAD_Desktop.h"
+#include "QAD_FileDlg.h"
+
+#include "SMESHGUI_SpinBox.h"
+#include "SMESHGUI.h"
+#include "SALOME_Selection.h"
+#include "SMESH_NumberFilter.hxx"
+#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_VTKUtils.h"
+#include "SMESHGUI_CreatePatternDlg.h"
+#include "SMESHGUI_PatternWidget.h"
+#include "SMESH_Actor.h"
+#include "SALOMEGUI_QtCatchCorbaException.hxx"
+#include "VTKViewer_ViewFrame.h"
+#include "SMESHGUI_PatternUtils.h"
+#include "SMESH_ActorUtils.h"
+#include "SMDS_MeshElement.hxx"
+#include "SMDS_Mesh.hxx"
+
+#include <TColStd_MapOfInteger.hxx>
+
+#include <qframe.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+#include <qbuttongroup.h>
+#include <qmessagebox.h>
+#include <qcstring.h>
+#include <qspinbox.h>
+#include <qvaluelist.h>
+
+#include <vtkCell.h>
+#include <vtkIdList.h>
+#include <vtkIntArray.h>
+#include <vtkCellArray.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkDataSetMapper.h>
+
+#define SPACING 5
+#define MARGIN 10
+
+/*
+ Class : SMESHGUI_MeshPatternDlg
+ Description : Dialog to specify filters for VTK viewer
+*/
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg
+// Purpose : Constructor
+//=======================================================================
+SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( QWidget* theParent,
+ SALOME_Selection* theSelection,
+ const char* theName )
+: QDialog( theParent, theName, false,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
+ myBusy( false )
+{
+ setCaption( tr( "CAPTION" ) );
+
+ QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING );
+
+ QFrame* aMainFrame = createMainFrame ( this );
+ QFrame* aBtnFrame = createButtonFrame( this );
+
+
+
+
+ aDlgLay->addWidget( aMainFrame );
+ aDlgLay->addWidget( aBtnFrame );
+
+ aDlgLay->setStretchFactor( aMainFrame, 1 );
+
+ myCreationDlg = 0;
+ Init( theSelection );
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::createMainFrame
+// Purpose : Create frame containing dialog's input fields
+//=======================================================================
+QFrame* SMESHGUI_MeshPatternDlg::createMainFrame( QWidget* theParent )
+{
+ QPixmap iconSlct( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
+ QPixmap icon2d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) );
+ QPixmap icon3d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) );
+ QPixmap iconOpen( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_FILE_OPEN" ) ) );
+
+ QPixmap iconSample2d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) );
+ QPixmap iconSample3d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_3D" ) ) );
+
+ QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent );
+ aMainGrp->setFrameStyle( QFrame::NoFrame );
+ aMainGrp->setInsideMargin( 0 );
+
+ // Pattern type group
+
+ myTypeGrp = new QButtonGroup( 1, Qt::Vertical, tr( "PATTERN_TYPE" ), aMainGrp );
+ mySwitch2d = new QRadioButton( myTypeGrp );
+ mySwitch3d = new QRadioButton( myTypeGrp );
+ mySwitch2d->setPixmap( icon2d );
+ mySwitch3d->setPixmap( icon3d );
+ myTypeGrp->insert( mySwitch2d, Type_2d );
+ myTypeGrp->insert( mySwitch3d, Type_3d );
+
+
+ // Mesh group
+
+ QGroupBox* aMeshGrp = new QGroupBox( 1, Qt::Vertical, tr( "SMESH_MESH" ), aMainGrp );
+ new QLabel( tr( "SMESH_MESH" ), aMeshGrp );
+ mySelBtn[ Mesh ] = new QPushButton( aMeshGrp );
+ mySelBtn[ Mesh ]->setPixmap( iconSlct );
+ mySelEdit[ Mesh ] = new QLineEdit( aMeshGrp );
+ mySelEdit[ Mesh ]->setReadOnly( true );
+
+ // Pattern group
+
+ QGroupBox* aPatGrp = new QGroupBox( 1, Qt::Horizontal, tr( "PATTERN" ), aMainGrp );
+
+ // pattern name
+ QGroupBox* aNameGrp = new QGroupBox( 1, Qt::Vertical, aPatGrp );
+ aNameGrp->setFrameStyle( QFrame::NoFrame );
+ aNameGrp->setInsideMargin( 0 );
+ new QLabel( tr( "PATTERN" ), aNameGrp );
+ myName = new QLineEdit( aNameGrp );
+ myName->setReadOnly( true );
+ myOpenBtn = new QPushButton( aNameGrp );
+ myOpenBtn->setPixmap( iconOpen );
+ myNewBtn = new QPushButton( tr( "NEW" ), aNameGrp );
+
+ // Mode selection check box
+ myRefine = new QCheckBox( tr( "REFINE" ), aPatGrp );
+
+ // selection widgets for Apply to geom mode
+ myGeomGrp = new QGroupBox( 3, Qt::Horizontal, aPatGrp );
+ myGeomGrp->setFrameStyle( QFrame::NoFrame );
+ myGeomGrp->setInsideMargin( 0 );
+
+ for ( int i = Object; i <= Vertex2; i++ )
+ {
+ mySelLbl[ i ] = new QLabel( myGeomGrp );
+ mySelBtn[ i ] = new QPushButton( myGeomGrp );
+ mySelBtn[ i ]->setPixmap( iconSlct );
+ mySelEdit[ i ] = new QLineEdit( myGeomGrp );
+ mySelEdit[ i ]->setReadOnly( true );
+ }
+
+ // Widgets for refinement of existing mesh elements
+ myRefineGrp = new QFrame( aPatGrp );
+ myRefineGrp->setFrameStyle( QFrame::NoFrame );
+ QGridLayout* aRefGrid = new QGridLayout( myRefineGrp, 3, 3, 0, 5 );
+
+ mySelLbl[ Ids ] = new QLabel( myRefineGrp );
+ mySelBtn[ Ids ] = new QPushButton( myRefineGrp );
+ mySelBtn[ Ids ]->setPixmap( iconSlct );
+ mySelEdit[ Ids ] = new QLineEdit( myRefineGrp );
+
+ QLabel* aNodeLbl = new QLabel( tr( "NODE_1" ), myRefineGrp );
+ myNode1 = new QSpinBox( myRefineGrp );
+ myNode2Lbl = new QLabel( tr( "NODE_2" ), myRefineGrp );
+ myNode2 = new QSpinBox( myRefineGrp );
+
+ aRefGrid->addWidget( mySelLbl [ Ids ], 0, 0 );
+ aRefGrid->addWidget( mySelBtn [ Ids ], 0, 1 );
+ aRefGrid->addWidget( mySelEdit[ Ids ], 0, 2 );
+ aRefGrid->addWidget( aNodeLbl, 1, 0 );
+ aRefGrid->addMultiCellWidget( myNode1, 1, 1, 1, 2 );
+ aRefGrid->addWidget( myNode2Lbl, 2, 0 );
+ aRefGrid->addMultiCellWidget( myNode2, 2, 2, 1, 2 );
+
+ // reverse check box
+ myReverseChk = new QCheckBox( tr( "REVERSE" ), aPatGrp );
+
+ // Pictures 2d and 3d
+ for ( int i = 0; i < 2; i++ )
+ {
+ if ( i == 0 )
+ {
+ myPicture2d = new SMESHGUI_PatternWidget( aPatGrp ),
+ myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+ }
+ else
+ {
+ myPicture3d = new QFrame( aPatGrp ),
+ myPreview3d = new QLabel( myPicture3d );
+ myPreview3d->setPixmap( iconSample3d );
+ QGridLayout* aLay = new QGridLayout( myPicture3d, 3, 3, 0, 0 );
+ QSpacerItem* aSpacerH1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ QSpacerItem* aSpacerH2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ QSpacerItem* aSpacerV1 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ QSpacerItem* aSpacerV2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ aLay->addItem( aSpacerH1, 1, 0 );
+ aLay->addItem( aSpacerH2, 1, 2 );
+ aLay->addItem( aSpacerV1, 0, 1 );
+ aLay->addItem( aSpacerV2, 2, 1 );
+ aLay->addWidget( myPreview3d, 1, 1 );
+ }
+ }
+
+ myPreviewChk = new QCheckBox( tr( "PREVIEW" ), aPatGrp );
+
+ // Connect signals and slots
+
+ connect( myTypeGrp, SIGNAL( clicked( int ) ), SLOT( onTypeChanged( int ) ) );
+ connect( myOpenBtn, SIGNAL( clicked() ), SLOT( onOpen() ) );
+ connect( myNewBtn, SIGNAL( clicked() ), SLOT( onNew() ) );
+ connect( myReverseChk, SIGNAL( toggled( bool ) ), SLOT( onReverse( bool ) ) );
+ connect( myPreviewChk, SIGNAL( toggled( bool ) ), SLOT( onPreview( bool ) ) );
+ connect( myRefine, SIGNAL( toggled( bool ) ), SLOT( onModeToggled( bool ) ) );
+ connect( myNode1, SIGNAL( valueChanged( int ) ), SLOT( onNodeChanged( int ) ) );
+ connect( myNode2, SIGNAL( valueChanged( int ) ), SLOT( onNodeChanged( int ) ) );
+ connect( mySelEdit[Ids], SIGNAL( textChanged( const QString& ) ), SLOT( onTextChanged( const QString& ) ) );
+
+ QMap< int, QPushButton* >::iterator anIter;
+ for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter )
+ connect( *anIter, SIGNAL( clicked() ), SLOT( onSelInputChanged() ) );
+
+ return aMainGrp;
+}
+
+//=======================================================================
+
+// name : SMESHGUI_MeshPatternDlg::createButtonFrame
+// Purpose : Create frame containing buttons
+//=======================================================================
+QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame( QWidget* theParent )
+{
+ QFrame* aFrame = new QFrame( theParent );
+ aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
+
+ myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame );
+ myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame );
+ myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame );
+
+ QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
+
+ QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING );
+
+ aLay->addWidget( myOkBtn );
+ aLay->addWidget( myApplyBtn );
+ aLay->addItem( aSpacer);
+ aLay->addWidget( myCloseBtn );
+
+ connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) );
+ connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ;
+ connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) );
+
+ return aFrame;
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg
+// Purpose : Destructor
+//=======================================================================
+SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg()
+{
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::Init
+// Purpose : Init dialog fields, connect signals and slots, show dialog
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::Init( SALOME_Selection* theSelection )
+{
+ myPattern = SMESH::GetPattern();
+ myPreviewActor = 0;
+ myIsCreateDlgOpen = false;
+ mySelInput = Mesh;
+ myType = -1;
+ myNbPoints = -1;
+ mySelection = theSelection;
+ SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI();
+ aSMESHGUI->SetActiveDialogBox( ( QDialog* )this );
+ myMesh = SMESH::SMESH_Mesh::_nil();
+
+ myMeshShape = GEOM::GEOM_Object::_nil();
+ myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();
+ myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();
+ myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();
+
+ // selection and SMESHGUI
+ connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
+ connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) );
+ connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) );
+
+ myTypeGrp->setButton( Type_2d );
+ onTypeChanged( Type_2d );
+ onModeToggled( isRefine() );
+
+ updateGeometry();
+
+ resize( minimumSize() );
+
+ activateSelection();
+ onSelectionDone();
+
+ int x, y ;
+ aSMESHGUI->DefineDlgPosition( this, x, y );
+ this->move( x, y );
+ this->show();
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::isValid
+// Purpose : Verify validity of entry data
+//=======================================================================
+bool SMESHGUI_MeshPatternDlg::isValid( const bool theMess )
+{
+ QValueList<int> ids;
+ if ( ( isRefine() && ( myMesh->_is_nil() || !getIds( ids ) || getNode( false ) < 0 || myType == Type_3d && ( getNode( true ) < 0 || getNode( false ) == getNode( true ) ) ) )
+ || ( !isRefine() && ( myMesh->_is_nil() || myMeshShape->_is_nil() || myGeomObj[ Object ]->_is_nil() ||
+ myGeomObj[ Vertex1 ]->_is_nil() || myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil() ) ) )
+ {
+ if ( theMess )
+ QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
+ tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok );
+ return false;
+ }
+ else
+ return true;
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onApply
+// Purpose : SLOT called when "Apply" button pressed.
+//=======================================================================
+bool SMESHGUI_MeshPatternDlg::onApply()
+{
+ try
+ {
+ if ( !isValid() )
+ return false;
+
+ erasePreview();
+
+ if ( isRefine() ) { // Refining existing mesh elements
+ QValueList<int> ids;
+ getIds( ids );
+ SMESH::long_array_var varIds = new SMESH::long_array();
+ varIds->length( ids.count() );
+ int i = 0;
+ for ( QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it )
+ varIds[i++] = *it;
+ myType == Type_2d
+ ? myPattern->ApplyToMeshFaces ( myMesh, varIds, getNode( false ), myReverseChk->isChecked() )
+ : myPattern->ApplyToHexahedrons( myMesh, varIds, getNode( false ), getNode( true ) );
+ }
+ else { // Applying a pattern to geometrical object
+ if ( myType == Type_2d )
+ myPattern->ApplyToFace(
+ myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked() );
+ else
+ myPattern->ApplyTo3DBlock(
+ myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ] );
+ }
+
+ if ( myPattern->MakeMesh( myMesh ) )
+ {
+ mySelection->ClearIObjects();
+ SMESH::UpdateView();
+ SMESHGUI::GetSMESHGUI()->GetActiveStudy()->updateObjBrowser( true );
+ return true;
+ }
+ else
+ {
+ QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
+ tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ), QMessageBox::Ok );
+ return false;
+ }
+ }
+ catch( const SALOME::SALOME_Exception& S_ex )
+ {
+ QtCatchCorbaException( S_ex );
+ }
+ catch( ... )
+ {
+ }
+
+ return false;
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onOk
+// Purpose : SLOT called when "Ok" button pressed.
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onOk()
+{
+ if ( onApply() )
+ onClose();
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onClose
+// Purpose : SLOT called when "Close" button pressed. Close dialog
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onClose()
+{
+ mySelection->ClearFilters();
+ SMESH::SetPickable();
+ QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
+ disconnect( mySelection, 0, this, 0 );
+ disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 );
+ SMESHGUI::GetSMESHGUI()->ResetState();
+ erasePreview();
+ reject();
+}
+
+
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onSelectionDone
+// Purpose : SLOT called when selection changed
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onSelectionDone()
+{
+ if ( myBusy )
+ return;
+
+ try
+ {
+ if ( mySelInput == Mesh )
+ {
+ if ( mySelection->IObjectCount() != 1 )
+ return;
+
+ // Retrieve mesh from selection
+ Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject();
+ SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIO );
+ if ( aMesh->_is_nil() )
+ return;
+
+ // Get geom object corresponding to the mesh
+ SALOMEDS::Study_var aStudy =
+ SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getStudyDocument();
+
+ SALOMEDS::SObject_var aSO = SMESH::FindSObject( aMesh.in() );
+ if ( aSO->_is_nil() )
+ return;
+
+ bool isFound = false;
+ SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( aSO );
+ for( ; anIter->More(); anIter->Next() )
+ {
+ SALOMEDS::SObject_var aSO = anIter->Value();
+ SALOMEDS::SObject_var aRefSO;
+
+ GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow(
+ aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() );
+
+ if ( !aMeshShape->_is_nil() )
+ {
+ isFound = true;
+ myMeshShape = aMeshShape;
+ break;
+
+ }
+ }
+
+ if ( !isFound )
+ myMeshShape = GEOM::GEOM_Object::_nil();
+
+ // Clear fields of geom objects if mesh was changed
+ if ( myMesh != aMesh )
+ {
+ for ( int i = Object; i <= Ids; i++ )
+ {
+ myGeomObj[ i ] = GEOM::GEOM_Object::_nil();
+ mySelEdit[ i ]->setText( "" );
+ }
+ }
+
+ myMesh = aMesh;
+
+ // Set name of mesh in line edit
+ QString aName;
+ SMESH::GetNameOfSelectedIObjects( mySelection, aName );
+ mySelEdit[ Mesh ]->setText( aName );
+ }
+ else if ( mySelInput == Ids ) {
+ QString anIds;
+ if ( !SMESH::GetNameOfSelectedElements( mySelection, anIds ) )
+ anIds = "";
+
+ myBusy = true;
+ mySelEdit[ Ids ]->setText( anIds );
+ myBusy = false;
+ }
+ else
+ {
+ if ( mySelection->IObjectCount() != 1 )
+ return;
+
+ // Get geom object from selection
+ Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject();
+ GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>( anIO );
+ if ( anObj->_is_nil() )
+ return;
+
+ // Clear fields of vertexes if face or 3d block was changed
+ if ( anObj != myGeomObj[ mySelInput ] && mySelInput == Object )
+ {
+ for ( int i = Vertex1; i <= Vertex2; i++ )
+ {
+ myGeomObj[ i ] = GEOM::GEOM_Object::_nil();
+ mySelEdit[ i ]->setText( "" );
+ }
+ }
+
+ myGeomObj[ mySelInput ] = anObj;
+
+ // Set name of geom object in line edit
+ QString aName;
+ SMESH::GetNameOfSelectedIObjects( mySelection, aName );
+ mySelEdit[ mySelInput ]->setText( aName );
+ }
+ }
+ catch( const SALOME::SALOME_Exception& S_ex )
+ {
+ QtCatchCorbaException( S_ex );
+ resetSelInput();
+ }
+ catch( ... )
+ {
+ resetSelInput();
+ }
+
+ updateWgState();
+ displayPreview();
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::resetSelInput
+// Purpose : Reset fields corresponding to the current selection input
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::resetSelInput()
+{
+ if ( mySelInput == Mesh )
+ {
+ myMesh = SMESH::SMESH_Mesh::_nil();
+ myMeshShape = GEOM::GEOM_Object::_nil();
+ }
+
+ else
+ myGeomObj[ mySelInput ] = GEOM::GEOM_Object::_nil();
+
+ mySelEdit[ mySelInput ]->setText( "" );
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onDeactivate
+// Purpose : SLOT called when dialog must be deativated
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onDeactivate()
+{
+ mySelection->ClearFilters();
+ //if ( myReverseChk->isChecked() )
+ // erasePreview();
+ disconnect( mySelection, 0, this, 0 );
+ setEnabled( false );
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::enterEvent
+// Purpose : Event filter
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::enterEvent( QEvent* )
+{
+ if ( myIsCreateDlgOpen )
+ return;
+
+ if ( myReverseChk->isChecked() )
+ displayPreview();
+ SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ;
+ setEnabled( true );
+ activateSelection();
+ connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
+ onTextChanged( mySelEdit[Ids]->text() );
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void SMESHGUI_MeshPatternDlg::closeEvent( QCloseEvent* e )
+{
+ onClose() ;
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onSelInputChanged
+// Purpose : SLOT. Called when -> button clicked.
+// Change current selection input field
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onSelInputChanged()
+{
+ const QObject* aSender = sender();
+ for ( int i = Mesh; i <= Ids; i++ )
+ if ( aSender == mySelBtn[ i ] )
+ mySelInput = i;
+
+ activateSelection();
+ onSelectionDone();
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::prepareFilters
+// Purpose : Prepare filters for dialog
+//=======================================================================
+
+QStringList SMESHGUI_MeshPatternDlg::prepareFilters() const
+{
+ static QStringList aList;
+ if ( aList.isEmpty() )
+ {
+ aList.append( tr( "PATTERN_FILT" ) );
+ //aList.append( tr( "ALL_FILES_FILTER" ) );
+ }
+
+ return aList;
+}
+
+//================================================================
+
+// Function : SMESHGUI_MeshPatternDlg::autoExtension
+// Purpose : Append extension to the file name
+//================================================================
+QString SMESHGUI_MeshPatternDlg::autoExtension( const QString& theFileName ) const
+{
+ QString anExt = theFileName.section( '.', -1 );
+ return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName;
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onOpen
+// Purpose : SLOT. Called when "Open" button clicked.
+// Displays file open dialog
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onOpen()
+{
+ QAD_FileDlg* aDlg = new QAD_FileDlg( this, true );
+ aDlg->setCaption( tr( "LOAD_PATTERN" ) );
+ aDlg->setMode( QFileDialogP::ExistingFile );
+ aDlg->setFilters( prepareFilters() );
+ if ( myName->text() != "" )
+ aDlg->setSelection( myName->text() + ".smp" );
+ QPushButton* anOkBtn = ( QPushButton* )aDlg->child( "OK", "QPushButton" );
+ if ( anOkBtn != 0 )
+ anOkBtn->setText( tr( "SMESH_BUT_OK" ) );
+
+ if ( aDlg->exec() != Accepted )
+ return;
+
+ QString fName = aDlg->selectedFile();
+ if ( fName.isEmpty() )
+ return;
+
+ if ( QFileInfo( fName ).extension().isEmpty() )
+ fName = autoExtension( fName );
+
+ fName = QDir::convertSeparators( fName );
+
+ QString prev = QDir::convertSeparators( myName->text() );
+ if ( prev == fName )
+ return;
+
+ // Read string from file
+ QFile aFile( fName );
+ if ( !aFile.open( IO_ReadOnly ) )
+ {
+ QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
+ tr( "SMESH_ERROR" ), tr( "ERROR_OF_OPENING" ), QMessageBox::Ok );
+ return;
+ }
+
+ QByteArray aDataArray = aFile.readAll();
+ const char* aData = aDataArray.data();
+ if ( aData == 0 )
+ {
+ QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
+ tr( "SMESH_ERROR" ), tr( "ERROR_OF_READING" ), QMessageBox::Ok );
+ return;
+ }
+
+ if ( loadFromFile( aData ) )
+ myName->setText( QFileInfo( fName ).baseName() );
+
+ updateWgState();
+ displayPreview();
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onCloseCreationDlg
+// Purpose : SLOT. Called when "Pattern creation" dialog closed with "Close"
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onCloseCreationDlg()
+{
+ setEnabled( true );
+ myIsCreateDlgOpen = false;
+}
+
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onOkCreationDlg
+// Purpose : SLOT. Called when "Pattern creation" dialog closed with OK
+// or SAVE buttons. Initialize myPattern field. Redisplay preview
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onOkCreationDlg()
+{
+ myPattern = SMESH::SMESH_Pattern::_duplicate( myCreationDlg->GetPattern() );
+ myName->setText( myCreationDlg->GetPatternName() );
+ displayPreview();
+ setEnabled( true );
+ myIsCreateDlgOpen = false;
+}
+
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onNew
+// Purpose : SLOT. Called when "New..." button clicked. Create new pattern
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onNew()
+{
+ setEnabled( false );
+ myIsCreateDlgOpen = true;
+ if ( myCreationDlg == 0 )
+ {
+ myCreationDlg = new SMESHGUI_CreatePatternDlg( this, mySelection, myType );
+ connect( myCreationDlg, SIGNAL( NewPattern() ), SLOT( onOkCreationDlg() ) );
+ connect( myCreationDlg, SIGNAL( Close() ), SLOT( onCloseCreationDlg() ) );
+ }
+ else
+ myCreationDlg->Init( mySelection, myType );
+
+ myCreationDlg->SetMesh( myMesh );
+ myCreationDlg->show();
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onReverse
+// Purpose : SLOT. Called when state of "Reverse order..." checkbox chaged
+// Calculate new points of the mesh to be created. Redisplay preview
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onReverse( bool )
+{
+ displayPreview();
+}
+
+//=======================================================================
+
+// name : SMESHGUI_MeshPatternDlg::onPreview
+// Purpose : SLOT. Called when state of "Preview" checkbox changed
+// Display/Erase preview
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onPreview( bool )
+{
+ displayPreview();
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::displayPreview
+// Purpose : Display preview
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::displayPreview()
+{
+ try
+ {
+ // Redisplay preview in dialog
+
+ SMESH::point_array_var pnts = myPattern->GetPoints();
+ SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
+ SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints();
+
+ if ( pnts->length() == 0 ||
+ keyPoints->length() == 0 ||
+ elemPoints->length() == 0 )
+ {
+ erasePreview();
+ return;
+ }
+
+ else
+ {
+ PointVector aPoints( pnts->length() );
+ QValueVector<int> aKeyPoints( keyPoints->length() );
+ ConnectivityVector anElemPoints( elemPoints->length() );
+
+ for ( int i = 0, n = pnts->length(); i < n; i++ )
+ aPoints[ i ] = pnts[ i ];
+
+ for ( int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++ )
+ aKeyPoints[ i2 ] = keyPoints[ i2 ];
+
+ for ( int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++ )
+ {
+ QValueVector<int> aVec( elemPoints[ i3 ].length() );
+ for ( int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++ )
+ aVec[ i4 ] = elemPoints[ i3 ][ i4 ];
+
+ anElemPoints[ i3 ] = aVec;
+ }
+
+ myPicture2d->SetPoints( aPoints, aKeyPoints, anElemPoints );
+ }
+
+
+ // Redisplay preview in 3D viewer
+
+ if ( myPreviewActor != 0 )
+ {
+ if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() )
+ {
+ vf->RemoveActor(myPreviewActor);
+ vf->Repaint();
+ }
+ myPreviewActor->Delete();
+ myPreviewActor = 0;
+ }
+
+ if ( !myPreviewChk->isChecked() || !isValid( false ) )
+ return;
+
+ vtkUnstructuredGrid* aGrid = getGrid();
+ if ( aGrid == 0 )
+ return;
+
+ // Create and display actor
+ vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
+ aMapper->SetInput( aGrid );
+
+ myPreviewActor = SALOME_Actor::New();
+ myPreviewActor->PickableOff();
+ myPreviewActor->SetMapper( aMapper );
+
+ vtkProperty* aProp = vtkProperty::New();
+ aProp->SetRepresentationToWireframe();
+ aProp->SetColor( 250, 0, 250 );
+ if ( SMESH::FindActorByObject( myMesh ) )
+ aProp->SetLineWidth( SMESH::GetFloat( "SMESH:SettingsWidth", 1 ) +1 );
+ else
+ aProp->SetLineWidth( 1 );
+ myPreviewActor->SetProperty( aProp );
+
+ myPreviewActor->SetRepresentation( 3 );
+
+ SMESH::GetCurrentVtkView()->AddActor( myPreviewActor );
+ SMESH::GetCurrentVtkView()->Repaint();
+
+ aProp->Delete();
+ aGrid->Delete();
+ }
+ catch( const SALOME::SALOME_Exception& S_ex )
+ {
+ QtCatchCorbaException( S_ex );
+ erasePreview();
+ }
+ catch( ... )
+ {
+ erasePreview();
+ }
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::erasePreview
+// Purpose : Erase preview
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::erasePreview()
+{
+ // Erase preview in 2D viewer
+ myPicture2d->SetPoints( PointVector(), QValueVector<int>(), ConnectivityVector() );
+
+ // Erase preview in 3D viewer
+ if ( myPreviewActor == 0 )
+ return;
+
+
+ if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() )
+ {
+ vf->RemoveActor(myPreviewActor);
+ vf->Repaint();
+ }
+ myPreviewActor->Delete();
+ myPreviewActor = 0;
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::updateWgState
+// Purpose : Enable/disable selection widgets
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::updateWgState()
+{
+ if ( myMesh->_is_nil() )
+ {
+ for ( int i = Object; i <= Ids; i++ )
+ {
+ mySelBtn [ i ]->setEnabled( false );
+ mySelEdit[ i ]->setEnabled( false );
+ mySelEdit[ i ]->setText( "" );
+ }
+ myNode1->setEnabled( false );
+ myNode2->setEnabled( false );
+ myNode1->setRange( 0, 0 );
+ myNode2->setRange( 0, 0 );
+ }
+ else
+ {
+ mySelBtn [ Object ]->setEnabled( true );
+ mySelEdit[ Object ]->setEnabled( true );
+ mySelBtn [ Ids ] ->setEnabled( true );
+ mySelEdit[ Ids ] ->setEnabled( true );
+
+ if ( myGeomObj[ Object ]->_is_nil() )
+ {
+ for ( int i = Vertex1; i <= Vertex2; i++ )
+ {
+ mySelBtn [ i ]->setEnabled( false );
+ mySelEdit[ i ]->setEnabled( false );
+ mySelEdit[ i ]->setText( "" );
+ }
+ }
+ else
+ {
+ for ( int i = Object; i <= Vertex2; i++ )
+ {
+ mySelBtn [ i ]->setEnabled( true );
+ mySelEdit[ i ]->setEnabled( true );
+ }
+ }
+
+ QValueList<int> ids;
+ if ( !CORBA::is_nil( myPattern ) && getIds( ids ) ) {
+ SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
+ if ( keyPoints->length() ) {
+ myNode1->setEnabled( true );
+ myNode2->setEnabled( true );
+ myNode1->setRange( 1, keyPoints->length() );
+ myNode2->setRange( 1, keyPoints->length() );
+ return;
+ }
+ }
+
+ myNode1->setEnabled( false );
+ myNode2->setEnabled( false );
+ myNode1->setRange( 0, 0 );
+ myNode2->setRange( 0, 0 );
+ }
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::activateSelection
+// Purpose : Activate selection in accordance with current selection input
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::activateSelection()
+{
+ mySelection->ClearFilters();
+ if ( mySelInput == Ids ) {
+ SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh );
+ if ( anActor )
+ SMESH::SetPickable(anActor);
+
+ if ( myType == Type_2d )
+ QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
+ else
+ QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
+ }
+ else {
+ SMESH::SetPickable();
+ QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
+ }
+
+ if ( mySelInput == Object && !myMeshShape->_is_nil() )
+ {
+ if ( myType == Type_2d )
+ {
+ if ( myNbPoints > 0 )
+ mySelection->AddFilter( new SMESH_NumberFilter(
+
+ "GEOM", TopAbs_VERTEX, myNbPoints, TopAbs_FACE, myMeshShape ) );
+ else
+ mySelection->AddFilter( new SMESH_NumberFilter(
+ "GEOM", TopAbs_SHAPE, myNbPoints, TopAbs_FACE, myMeshShape ) );
+ }
+ else
+ {
+ TColStd_MapOfInteger aTypes;
+ aTypes.Add( TopAbs_SHELL );
+ aTypes.Add( TopAbs_SOLID );
+ mySelection->AddFilter( new SMESH_NumberFilter(
+ "GEOM", TopAbs_FACE, 6, aTypes, myMeshShape, true ) );
+ }
+ }
+ else if ( ( mySelInput == Vertex1 || mySelInput == Vertex2 ) && !myGeomObj[ Object ]->_is_nil() )
+ {
+ mySelection->AddFilter( new SMESH_NumberFilter(
+ "GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX, myGeomObj[ Object ] ) );
+ }
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::loadFromFile
+// Purpose : Load pattern from file
+//=======================================================================
+bool SMESHGUI_MeshPatternDlg::loadFromFile( const QString& theName )
+{
+ try
+ {
+ SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern();
+
+ if ( !aPattern->LoadFromFile( theName.latin1() ) ||
+ myType == Type_2d && !aPattern->Is2D())
+ {
+ SMESH::SMESH_Pattern::ErrorCode aCode = aPattern->GetErrorCode();
+ QString aMess;
+ if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr( "ERR_READ_NB_POINTS" );
+ else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_POINT_COORDS ) aMess = tr( "ERR_READ_POINT_COORDS" );
+ else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_TOO_FEW_POINTS ) aMess = tr( "ERR_READ_TOO_FEW_POINTS" );
+ else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_3D_COORD ) aMess = tr( "ERR_READ_3D_COORD" );
+ else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NO_KEYPOINT ) aMess = tr( "ERR_READ_NO_KEYPOINT" );
+ else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_INDEX ) aMess = tr( "ERR_READ_BAD_INDEX" );
+ else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_ELEM_POINTS ) aMess = tr( "ERR_READ_ELEM_POINTS" );
+ else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NO_ELEMS ) aMess = tr( "ERR_READ_NO_ELEMS" );
+ else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_KEY_POINT ) aMess = tr( "ERR_READ_BAD_KEY_POINT" );
+ else aMess = tr( "ERROR_OF_LOADING" );
+
+ QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
+ tr( "SMESH_ERROR" ), aMess, QMessageBox::Ok );
+ return false;
+ }
+ else
+ {
+ myPattern = aPattern;
+ return true;
+ }
+ }
+ catch( const SALOME::SALOME_Exception& S_ex )
+ {
+ QtCatchCorbaException( S_ex );
+ QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
+ tr( "SMESH_ERROR" ), tr( "ERROR_OF_LOADING" ), QMessageBox::Ok );
+ return false;
+ }
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::onTypeChanged
+
+// Purpose : SLOT. Called when pattern type changed.
+// Change dialog's look and feel
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onTypeChanged( int theType )
+{
+ if ( myType == theType )
+ return;
+
+ myType = theType;
+
+ myNbPoints = -1;
+ myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();
+ myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();
+ myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();
+ myPattern = SMESH::GetPattern();
+
+ myName->setText( "" );
+ mySelEdit[ Object ]->setText( "" );
+ mySelEdit[ Vertex1 ]->setText( "" );
+ mySelEdit[ Vertex2 ]->setText( "" );
+ mySelEdit[ Ids ] ->setText( "" );
+
+ if ( theType == Type_2d )
+ {
+ // Geom widgets
+ mySelLbl [ Vertex2 ]->hide();
+ mySelBtn [ Vertex2 ]->hide();
+ mySelEdit[ Vertex2 ]->hide();
+ myReverseChk->show();
+ myPicture2d->show();
+ myPicture3d->hide();
+ mySelLbl[ Object ]->setText( tr( "FACE" ) );
+ mySelLbl[ Vertex1 ]->setText( tr( "VERTEX" ) );
+ // Refine widgets
+ mySelLbl[ Ids ]->setText( tr( "MESH_FACES" ) );
+ myNode2Lbl->hide();
+ myNode2 ->hide();
+ }
+ else
+ {
+ // Geom widgets
+ mySelLbl [ Vertex2 ]->show();
+ mySelBtn [ Vertex2 ]->show();
+ mySelEdit[ Vertex2 ]->show();
+ myReverseChk->hide();
+ myPicture2d->hide();
+ myPicture3d->show();
+ mySelLbl[ Object ]->setText( tr( "3D_BLOCK" ) );
+ mySelLbl[ Vertex1 ]->setText( tr( "VERTEX1" ) );
+ mySelLbl[ Vertex2 ]->setText( tr( "VERTEX2" ) );
+ // Refine widgets
+ mySelLbl[ Ids ]->setText( tr( "MESH_VOLUMES" ) );
+ myNode2Lbl->show();
+ myNode2 ->show();
+ }
+
+ mySelInput = Mesh;
+ activateSelection();
+ updateWgState();
+ displayPreview();
+}
+
+//=======================================================================
+// name : SMESHGUI_MeshPatternDlg::getGrid
+// Purpose : Get unstructured grid for pattern
+//=======================================================================
+vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid()
+{
+ try
+ {
+ // Get points from pattern
+ SMESH::point_array_var pnts;
+ QValueList<int> ids;
+ if ( isRefine() && getIds( ids ) ) {
+ SMESH::long_array_var varIds = new SMESH::long_array();
+ varIds->length( ids.count() );
+ int i = 0;
+ for ( QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it )
+ varIds[i++] = *it;
+ pnts = myType == Type_2d
+ ? myPattern->ApplyToMeshFaces ( myMesh, varIds, getNode( false ), myReverseChk->isChecked() )
+ : myPattern->ApplyToHexahedrons( myMesh, varIds, getNode( false ), getNode( true ) );
+ }
+ else {
+ pnts = myType == Type_2d
+ ? myPattern->ApplyToFace ( myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked() )
+ : myPattern->ApplyTo3DBlock( myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ] );
+ }
+
+ SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints();
+
+ if ( pnts->length() == 0 || elemPoints->length() == 0 )
+ return 0;
+
+
+
+ // to do : to be removed /////////////////////////////////////////////
+
+#ifdef DEB_SLN
+ for ( int i1 = 0, n1 = pnts->length(); i1 < n1; i1++ )
+ printf( "%d: %g %g %g\n", i1, pnts[ i1 ].x, pnts[ i1 ].y, pnts[ i1 ].z );
+
+ printf( "\nELEMENTS : \n" );
+ for ( int i2 = 0, n2 = elemPoints->length(); i2 < n2; i2++ )
+ {
+
+ printf( "%d: ", i2 );
+ for ( int i3 = 0, n3 = elemPoints[ i2 ].length(); i3 < n3; i3++ )
+ printf( "%d ", elemPoints[ i2 ][ i3 ] );
+
+ printf( "\n" );
+
+ }
+#endif
+ //////////////////////////////////////////////////////////////////////
+
+ // Calculate number of points used for cell
+ vtkIdType aNbCells = elemPoints->length();
+ vtkIdType aCellsSize = 0;
+ for ( int i = 0, n = elemPoints->length(); i < n; i++ )
+ aCellsSize += elemPoints[ i ].length();
+
+ // Create unstructured grid and other usefull arrays
+ vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
+
+ vtkCellArray* aConnectivity = vtkCellArray::New();
+ aConnectivity->Allocate( aCellsSize, 0 );
+
+ vtkPoints* aPoints = vtkPoints::New();
+ aPoints->SetNumberOfPoints( pnts->length() );
+
+ vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+ aCellTypesArray->SetNumberOfComponents( 1 );
+ aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
+
+ vtkIdList *anIdList = vtkIdList::New();
+
+ // Fill array of points
+ for ( int p = 0, nbPnt = pnts->length(); p < nbPnt; p++ )
+ aPoints->SetPoint( p, pnts[ p ].x, pnts[ p ].y, pnts[ p ].z );
+
+ for ( int e = 0, nbElem = elemPoints->length(); e < nbElem; e++ )
+ {
+ int nbPoints = elemPoints[ e ].length();
+ anIdList->SetNumberOfIds( nbPoints );
+ for ( int i = 0; i < nbPoints; i++ )
+ anIdList->SetId( i, elemPoints[ e ][ i ] );
+
+ aConnectivity->InsertNextCell( anIdList );
+
+ if ( nbPoints == 3 ) aCellTypesArray->InsertNextValue( VTK_TRIANGLE );
+ else if ( nbPoints == 5 ) aCellTypesArray->InsertNextValue( VTK_PYRAMID );
+ else if ( nbPoints == 6 ) aCellTypesArray->InsertNextValue( VTK_WEDGE );
+ else if ( nbPoints == 8 ) aCellTypesArray->InsertNextValue( VTK_HEXAHEDRON );
+ else if ( nbPoints == 4 && myType == Type_2d ) aCellTypesArray->InsertNextValue( VTK_QUAD );
+ else if ( nbPoints == 4 && myType == Type_3d ) aCellTypesArray->InsertNextValue( VTK_TETRA );
+ else aCellTypesArray->InsertNextValue( VTK_EMPTY_CELL );
+ }
+
+ vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+ aCellLocationsArray->SetNumberOfComponents( 1 );
+ aCellLocationsArray->SetNumberOfTuples( aNbCells );
+
+ aConnectivity->InitTraversal();
+ for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
+ aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
+
+ aGrid->SetPoints( aPoints );
+ aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
+
+ aConnectivity->Delete();
+ aPoints->Delete();
+ aCellTypesArray->Delete();
+ anIdList->Delete();
+ aCellLocationsArray->Delete();
+
+ return aGrid;
+ }
+ catch( ... )
+ {
+ return 0;
+ }
+}
+
+//=======================================================================
+// name : onModeToggled
+// Purpose :
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onModeToggled( bool on )
+{
+ on ? myRefineGrp->show() : myRefineGrp->hide();
+ on ? myGeomGrp->hide() : myGeomGrp->show();
+}
+
+//=======================================================================
+// name : isRefine
+// Purpose :
+//=======================================================================
+bool SMESHGUI_MeshPatternDlg::isRefine() const
+{
+ return myRefine->isChecked();
+}
+
+//=======================================================================
+//function : onTextChanged
+//purpose :
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onTextChanged(const QString& theNewText)
+{
+ if ( myBusy || !isRefine() )
+ return;
+
+ myBusy = true;
+
+ if ( mySelInput != Ids ) {
+ mySelInput = Ids;
+ activateSelection();
+ }
+
+ // hilight entered elements/nodes
+ SMDS_Mesh* aMesh = 0;
+ SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh );
+ if ( anActor )
+ aMesh = anActor->GetObject()->GetMesh();
+
+ if ( aMesh ) {
+ mySelection->ClearIObjects();
+ mySelection->AddIObject( anActor->getIO() );
+
+ QStringList aListId = QStringList::split( " ", theNewText, false);
+
+ for ( int i = 0; i < aListId.count(); i++ ) {
+ const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
+ if ( e && e->GetType() == ( myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume ) ) {
+ if ( !mySelection->IsIndexSelected( anActor->getIO(), e->GetID() ) )
+ mySelection->AddOrRemoveIndex( anActor->getIO(), e->GetID(), true );
+ }
+ }
+ }
+
+ myBusy = false;
+}
+
+//=======================================================================
+//function : onNodeChanged
+//purpose :
+//=======================================================================
+void SMESHGUI_MeshPatternDlg::onNodeChanged( int value )
+{
+ if ( myType == Type_3d ) {
+ QSpinBox* first = (QSpinBox*)sender();
+ QSpinBox* second = first == myNode1 ? myNode2 : myNode1;
+ int secondVal = second->value();
+ if ( secondVal == value ) {
+ secondVal = value == second->maxValue() ? second->minValue() : value + 1;
+ bool blocked = second->signalsBlocked();
+ second->blockSignals( true );
+ second->setValue( secondVal );
+ second->blockSignals( blocked );
+ }
+ }
+
+ displayPreview();
+}
+
+//=======================================================================
+//function : getIds
+//purpose :
+//=======================================================================
+bool SMESHGUI_MeshPatternDlg::getIds( QValueList<int>& ids ) const
+{
+ ids.clear();
+ QStringList strIds = QStringList::split( " ", mySelEdit[Ids]->text() );
+ bool isOk;
+ int val;
+ for ( QStringList::iterator it = strIds.begin(); it != strIds.end(); ++it ) {
+ val = (*it).toInt( &isOk );
+ if ( isOk )
+ ids.append( val );
+ }
+
+ return ids.count();
+}
+
+//=======================================================================
+//function : getNode1
+//purpose :
+//=======================================================================
+int SMESHGUI_MeshPatternDlg::getNode( bool second ) const
+{
+ return second ? myNode2->value() - 1 : myNode1->value() - 1;
+}
+
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
-// \r
-// This library is free software; you can redistribute it and/or \r
-// modify it under the terms of the GNU Lesser General Public \r
-// License as published by the Free Software Foundation; either \r
-// version 2.1 of the License. \r
-// \r
-// This library is distributed in the hope that it will be useful, \r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \r
-// Lesser General Public License for more details. \r
-// \r
-// You should have received a copy of the GNU Lesser General Public \r
-// License along with this library; if not, write to the Free Software \r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA \r
-// \r
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
-//\r
-//\r
-//\r
-// File : SMESHGUI_MeshPatternDlg.h\r
-// Author : Sergey LITONIN\r
-// Module : SMESH\r
-\r
-\r
-#ifndef SMESHGUI_MeshPatternDlg_H\r
-#define SMESHGUI_MeshPatternDlg_H\r
-\r
-#include <qdialog.h>\r
-\r
-// IDL Headers\r
-#include <SALOMEconfig.h>\r
-#include CORBA_SERVER_HEADER(GEOM_Gen)\r
-#include CORBA_SERVER_HEADER(SMESH_Mesh)\r
-#include CORBA_SERVER_HEADER(SMESH_Pattern)\r
-\r
-class QCloseEvent;\r
-class QFrame;\r
-class QLineEdit;\r
-class SMESHGUI_SpinBox;\r
-class QPushButton;\r
-class SALOME_Selection;\r
-class QRadioButton;\r
-class QCheckBox;\r
-class QButtonGroup;\r
-class QLabel;\r
-class SMESHGUI_CreatePatternDlg;\r
-class SMESHGUI_PatternWidget;\r
-class vtkUnstructuredGrid;\r
-class SALOME_Actor;\r
-\r
-/*\r
- Class : SMESHGUI_MeshPatternDlg\r
- Description : Dialog to specify filters for VTK viewer\r
-*/\r
-\r
-class SMESHGUI_MeshPatternDlg : public QDialog\r
-{\r
- Q_OBJECT\r
-\r
- // Pattern type\r
- enum { Type_2d, Type_3d };\r
-\r
- // selection input\r
- enum { Mesh, Object, Vertex1, Vertex2 };\r
-\r
-public:\r
- SMESHGUI_MeshPatternDlg( QWidget*,\r
- SALOME_Selection*,\r
- const char* = 0 );\r
- virtual ~SMESHGUI_MeshPatternDlg();\r
-\r
- void Init( SALOME_Selection* );\r
- \r
-private slots:\r
-\r
- void onOk();\r
- bool onApply();\r
- void onClose();\r
-\r
- void onDeactivate();\r
-\r
- void onSelectionDone();\r
- void onSelInputChanged();\r
-\r
- void onTypeChanged( int );\r
- void onOpen();\r
- void onNew();\r
- void onReverse( bool );\r
- void onPreview( bool );\r
- void onOkCreationDlg();\r
- void onCloseCreationDlg();\r
-\r
-private:\r
-\r
- QFrame* createButtonFrame( QWidget* );\r
- QFrame* createMainFrame ( QWidget* );\r
- void displayPreview();\r
- vtkUnstructuredGrid* getGrid();\r
- void erasePreview();\r
- void updateWgState();\r
- bool loadFromFile( const QString& );\r
- void activateSelection();\r
- QStringList prepareFilters() const;\r
- QString autoExtension( const QString& theFileName ) const;\r
- void closeEvent( QCloseEvent* e ) ;\r
- void enterEvent ( QEvent * ) ;\r
- bool isValid( const bool theMess = true );\r
- void resetSelInput();\r
-\r
-private:\r
-\r
- QPushButton* myOkBtn;\r
- QPushButton* myApplyBtn;\r
- QPushButton* myCloseBtn;\r
-\r
- QButtonGroup* myTypeGrp;\r
- QRadioButton* mySwitch2d;\r
- QRadioButton* mySwitch3d;\r
-\r
- QMap< int, QPushButton* > mySelBtn;\r
- QMap< int, QLineEdit* > mySelEdit;\r
- QMap< int, QLabel* > mySelLbl;\r
-\r
- QLineEdit* myName;\r
- QPushButton* myOpenBtn;\r
- QPushButton* myNewBtn;\r
-\r
- QCheckBox* myReverseChk;\r
- SMESHGUI_PatternWidget* myPicture2d;\r
- QFrame* myPicture3d;\r
- QLabel* myPreview3d;\r
-\r
- QCheckBox* myPreviewChk;\r
- \r
- SALOME_Selection* mySelection;\r
- int mySelInput;\r
- int myNbPoints;\r
- int myType;\r
- bool myIsCreateDlgOpen;\r
-\r
- SMESH::SMESH_Mesh_var myMesh;\r
- GEOM::GEOM_Object_var myMeshShape;\r
- QMap< int, GEOM::GEOM_Object_var > myGeomObj;\r
- \r
- SMESHGUI_CreatePatternDlg* myCreationDlg;\r
- SMESH::SMESH_Pattern_var myPattern;\r
- SALOME_Actor* myPreviewActor;\r
-};\r
-\r
-#endif\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESHGUI_MeshPatternDlg.h
+// Author : Sergey LITONIN
+// Module : SMESH
+
+
+#ifndef SMESHGUI_MeshPatternDlg_H
+#define SMESHGUI_MeshPatternDlg_H
+
+#include <qdialog.h>
+
+// IDL Headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_Pattern)
+
+class QCloseEvent;
+class QFrame;
+class QLineEdit;
+class SMESHGUI_SpinBox;
+class QPushButton;
+class SALOME_Selection;
+class QRadioButton;
+class QCheckBox;
+class QButtonGroup;
+class QLabel;
+class QSpinBox;
+class QGroupBox;
+class SMESHGUI_CreatePatternDlg;
+class SMESHGUI_PatternWidget;
+class vtkUnstructuredGrid;
+class SALOME_Actor;
+
+/*
+ Class : SMESHGUI_MeshPatternDlg
+ Description : Dialog to specify filters for VTK viewer
+*/
+
+class SMESHGUI_MeshPatternDlg : public QDialog
+{
+ Q_OBJECT
+
+ // Pattern type
+ enum { Type_2d, Type_3d };
+
+ // selection input
+ enum { Mesh, Object, Vertex1, Vertex2, Ids };
+
+public:
+ SMESHGUI_MeshPatternDlg( QWidget*,
+ SALOME_Selection*,
+ const char* = 0 );
+ virtual ~SMESHGUI_MeshPatternDlg();
+
+ void Init( SALOME_Selection* );
+
+private slots:
+
+ void onOk();
+ bool onApply();
+ void onClose();
+
+ void onDeactivate();
+
+ void onSelectionDone();
+ void onSelInputChanged();
+
+ void onTypeChanged( int );
+ void onModeToggled( bool );
+ void onOpen();
+ void onNew();
+ void onReverse( bool );
+ void onPreview( bool );
+ void onOkCreationDlg();
+ void onCloseCreationDlg();
+ void onTextChanged( const QString& );
+ void onNodeChanged( int value );
+
+private:
+
+ QFrame* createButtonFrame( QWidget* );
+ QFrame* createMainFrame ( QWidget* );
+ void displayPreview();
+ vtkUnstructuredGrid* getGrid();
+ void erasePreview();
+ void updateWgState();
+ bool loadFromFile( const QString& );
+ void activateSelection();
+ QStringList prepareFilters() const;
+ QString autoExtension( const QString& theFileName ) const;
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent ( QEvent * ) ;
+ bool isValid( const bool theMess = true );
+ void resetSelInput();
+ bool isRefine() const;
+
+ bool getIds( QValueList<int>& ) const;
+ int getNode( bool = false ) const;
+
+private:
+
+ QPushButton* myOkBtn;
+ QPushButton* myApplyBtn;
+ QPushButton* myCloseBtn;
+
+ QButtonGroup* myTypeGrp;
+ QRadioButton* mySwitch2d;
+ QRadioButton* mySwitch3d;
+
+ QCheckBox* myRefine;
+
+ QFrame* myRefineGrp;
+ QSpinBox* myNode1;
+ QSpinBox* myNode2;
+ QLabel* myNode2Lbl;
+
+ QGroupBox* myGeomGrp;
+ QMap< int, QPushButton* > mySelBtn;
+ QMap< int, QLineEdit* > mySelEdit;
+ QMap< int, QLabel* > mySelLbl;
+
+ QLineEdit* myName;
+ QPushButton* myOpenBtn;
+ QPushButton* myNewBtn;
+
+ QCheckBox* myReverseChk;
+ SMESHGUI_PatternWidget* myPicture2d;
+ QFrame* myPicture3d;
+ QLabel* myPreview3d;
+
+ QCheckBox* myPreviewChk;
+
+ SALOME_Selection* mySelection;
+ int mySelInput;
+ int myNbPoints;
+ int myType;
+ bool myIsCreateDlgOpen;
+ bool myBusy;
+
+ SMESH::SMESH_Mesh_var myMesh;
+ GEOM::GEOM_Object_var myMeshShape;
+ QMap< int, GEOM::GEOM_Object_var > myGeomObj;
+
+ SMESHGUI_CreatePatternDlg* myCreationDlg;
+ SMESH::SMESH_Pattern_var myPattern;
+ SALOME_Actor* myPreviewActor;
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#include <qpushbutton.h>
#include <qapplication.h>
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
#define SPACING 5
#define MARGIN 10
mySubmeshChk = new QCheckBox( tr( "SMESH_SUBMESH" ), aGrp );
mySubmeshBtn = new QPushButton( aGrp );
mySubmesh = new QLineEdit( aGrp );
+ mySubmesh->setReadOnly( true );
mySubmeshBtn->setPixmap( aPix );
myGroupChk = new QCheckBox( tr( "GROUP" ), aGrp );
myGroupBtn = new QPushButton( aGrp );
myGroup = new QLineEdit( aGrp );
+ myGroup->setReadOnly( true );
myGroupBtn->setPixmap( aPix );
return aMainGrp;
#include "QAD_MessageBox.h"
#include "SMESH_Actor.h"
+#include "SMESH_ObjectDef.h"
+
#include "SMDS_Mesh.hxx"
#include "SMDS_MeshNode.hxx"
myActor = anActor;
vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
- double aMin = 0.0, aMax = 0.0;
if ( myScalarBarActor->GetLookupTable() ) {
float *range = myScalarBarActor->GetLookupTable()->GetRange();
myMinEdit->setText( QString::number( range[0] ) );
if ( !myMesh->_is_nil())
{
- bool aResult = false;
try
{
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
#include <qvalidator.h>
#include <qpixmap.h>
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
using namespace std;
//=================================================================================
#include <qlayout.h>
#include <qpixmap.h>
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
using namespace std;
//=================================================================================
#include <qvalidator.h>
#include <qpixmap.h>
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
using namespace std;
//=================================================================================
SMESHGUI_SpinBox( QWidget* parent, const char* name = 0 ) ;
~SMESHGUI_SpinBox() ;
- void RangeStepAndValidator( double min = -1000000.0,
- double max = +1000000.0,
- double step = 100.0,
- unsigned short decimals = 3 ) ;
- void SetValue( double v ) ;
- double GetValue() ;
- QString GetString() ;
+ void RangeStepAndValidator( double min = -1000000.0,
+ double max = +1000000.0,
+ double step = 100.0,
+ unsigned short decimals = 3 ) ;
+ void SetValue( double v ) ;
+ double GetValue() ;
+ QString GetString() ;
+ QLineEdit* editor() { return QAD_SpinBoxDbl::editor(); }
public slots:
- void SetStep( double newStep );
+ void SetStep( double newStep );
};
#endif // SMESHSPINBOX_H
#include <qlayout.h>
#include <qpixmap.h>
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
using namespace std;
//=================================================================================
#include <qspinbox.h>
#include <qpixmap.h>
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
using namespace std;
//=================================================================================
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
#include "SMESH_Actor.h"
+#include "SMESH_ObjectDef.h"
using namespace std;
}
+ void RepaintViewFrame(VTKViewer_ViewFrame* theFrame)
+ {
+ theFrame->Repaint();
+ }
+
+
+ void RenderViewFrame(VTKViewer_ViewFrame* theFrame)
+ {
+ theFrame->getRW()->getRenderWindow()->Render();
+ theFrame->Repaint();
+ }
+
+
SMESH_Actor* FindActorByEntry(QAD_StudyFrame *theStudyFrame,
const char* theEntry)
{
{
theName = "";
if(theIO->hasEntry()){
- if(SMESH_Actor *anActor = FindActorByEntry(theIO->getEntry())){
+ if(FindActorByEntry(theIO->getEntry())){
TColStd_IndexedMapOfInteger aMapIndex;
theSel->GetIndex(theIO,aMapIndex);
for(int i = 1; i <= aMapIndex.Extent(); i++){
{
theName = "";
if(theIO->hasEntry()){
- if(SMESH_Actor *anActor = FindActorByEntry(theIO->getEntry())){
+ if(FindActorByEntry(theIO->getEntry())){
TColStd_IndexedMapOfInteger aMapIndex;
theSel->GetIndex(theIO,aMapIndex);
typedef std::set<int> TIdContainer;
VTKViewer_ViewFrame* GetCurrentVtkView();
+ void RepaintViewFrame(VTKViewer_ViewFrame* theFrame);
+
+ void RenderViewFrame(VTKViewer_ViewFrame* theFrame);
//----------------------------------------------------------------------------
SMESH_Actor* FindActorByEntry(QAD_StudyFrame *theStudyFrame,
msgid "ICON_PATTERN_SAMPLE_3D"
msgstr "pattern_sample_3D.png"
+#-----------------------------------------------------------
+# Add/Remove buttons
+#-----------------------------------------------------------
+msgid "ICON_APPEND"
+msgstr "mesh_add.png"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+msgid "ICON_REMOVE"
+msgstr "mesh_remove.png"
\ No newline at end of file
msgid "SMESHGUI_FilterTable::MULTI_BORDERS"
msgstr "Borders at multi-connections"
+#msgid "SMESHGUI_FilterTable::MULTI2D_BORDERS"
+#msgstr "Borders at multi-connections 2D"
+
msgid "SMESHGUI_FilterTable::LENGTH"
msgstr "Length"
+#msgid "SMESHGUI_FilterTable::LENGTH2D"
+#msgstr "Length2D"
+
msgid "SMESHGUI_FilterTable::ASPECT_RATIO"
msgstr "Aspect ratio"
+msgid "SMESHGUI_FilterTable::ASPECT_RATIO_3D"
+msgstr "Aspect ratio 3D"
+
msgid "SMESHGUI_FilterTable::WARPING"
msgstr "Warping"
msgid "SMESHGUI_FilterTable::BELONG_TO_CYLINDER"
msgstr "Belong to Cylinder"
+msgid "SMESHGUI_FilterTable::LYING_ON_GEOM"
+msgstr "Lying on Geom"
+
# -------------- SMESHGUI_FilterDlg --------------
msgid "SMESHGUI_FilterDlg::TLT"
msgstr "Selection filter"
msgid "LENGTH_EDGES"
msgstr "Length"
+msgid "LENGTH2D_EDGES"
+msgstr "Length 2D"
+
msgid "FREE_BORDERS"
-msgstr "Free borders"
+msgstr "Free Borders"
msgid "MULTI_BORDERS"
-msgstr "Borders at multi-connections"
+msgstr "Borders at Multi-Connections"
+
+msgid "MULTI2D_BORDERS"
+msgstr "Borders at Multi-Connections 2D"
msgid "AREA_ELEMENTS"
msgstr "Area"
msgid "ASPECTRATIO_ELEMENTS"
msgstr "Aspect Ratio"
+msgid "ASPECTRATIO_3D_ELEMENTS"
+msgstr "Aspect Ratio 3D"
+
msgid "MINIMUMANGLE_ELEMENTS"
msgstr "Minimum Angle"
msgid "SMESHGUI_ExtrusionDlg::EXTRUSION_ALONG_LINE"
msgstr "Extrusion along a line"
-
msgid "SMESHGUI_ExtrusionDlg::EXTRUSION_1D"
msgstr "Extrusion of 1D elements"
#----------------------------------------------------
+msgid "SMESHGUI_ExtrusionAlongPathDlg::EXTRUSION_ALONG_PATH"
+msgstr "Extrusion along a path"
+
+msgid "SMESHGUI_ExtrusionAlongPathDlg::EXTRUSION_1D"
+msgstr "Extrusion of 1D elements"
+
+msgid "SMESHGUI_ExtrusionAlongPathDlg::EXTRUSION_2D"
+msgstr "Extrusion of 2D elements"
+
+msgid "SMESHGUI_ExtrusionAlongPathDlg::SMESH_PATH"
+msgstr "Path"
+
+msgid "SMESHGUI_ExtrusionAlongPathDlg::SMESH_PATH_MESH"
+msgstr "Mesh"
+
+msgid "SMESHGUI_ExtrusionAlongPathDlg::SMESH_PATH_SHAPE"
+msgstr "Shape (edge or wire)"
+
+msgid "SMESHGUI_ExtrusionAlongPathDlg::SMESH_PATH_START"
+msgstr "Start point"
+
+msgid "SMESHGUI_ExtrusionAlongPathDlg::SMESH_USE_ANGLES"
+msgstr "Use Angles"
+
+msgid "SMESHGUI_ExtrusionAlongPathDlg::SMESH_ANGLES"
+msgstr "Angles"
+
+msgid "SMESHGUI_ExtrusionAlongPathDlg::SMESH_USE_BASE_POINT"
+msgstr "Use Base Point"
+
+msgid "SMESHGUI_ExtrusionAlongPathDlg::SMESH_BASE_POINT"
+msgstr "Base Point"
+
+#----------------------------------------------------
+
msgid "SMESHGUI_RevolutionDlg::REVOLUTION_AROUND_AXIS"
msgstr "Revolution around an axis"
msgid "SMESHGUI_MeshPatternDlg::ERR_READ_BAD_KEY_POINT"
msgstr "It is impossible to load pattern\nKey-point not on a boundary"
+msgid "SMESHGUI_MeshPatternDlg::REFINE"
+msgstr "Refine selected mesh elements"
+
+msgid "SMESHGUI_MeshPatternDlg::NODE_1"
+msgstr "Node 1"
+
+msgid "SMESHGUI_MeshPatternDlg::NODE_2"
+msgstr "Node 2"
+
+msgid "SMESHGUI_MeshPatternDlg::MESH_FACES"
+msgstr "Mesh faces"
+
+msgid "SMESHGUI_MeshPatternDlg::MESH_VOLUMES"
+msgstr "Mesh volumes"
#----------------------------------------------------
SMESH_Hypothesis_i.hxx \
SMESH.hxx
-EXPORT_PYSCRIPTS = smeshpy.py SMESH_test.py
+EXPORT_PYSCRIPTS = smeshpy.py
# Libraries targets
BIN_SRC =
# additionnal information to compil and link file
-CPPFLAGS+= $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
+CPPFLAGS+= $(OCC_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
-CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
+CXXFLAGS+= $(OCC_CXXFLAGS) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome
LDFLAGS+= -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeContainer -lSalomeNS -lRegistry -lSalomeHDFPersist -lSalomeLifeCycleCORBA -lTOOLSDS -lSalomeGenericObj \
TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE )
{
TopExp_Explorer anExp( theShape,theFindShapeEnum,theAvoidShapeEnum );
-
+
while( anExp.More() )
{
const TopoDS_Shape& aShape = anExp.Current();
return myMeshDS;
}
+/*
+ Class : LyingOnGeom
+ Description : Predicate for verifying whether entiy lying or partially lying on
+ specified geometrical support
+*/
+
+Controls::LyingOnGeom::LyingOnGeom()
+: myMeshDS(NULL),
+ myType(SMDSAbs_All)
+{}
+
+void Controls::LyingOnGeom::SetMesh( SMDS_Mesh* theMesh )
+{
+ myMeshDS = dynamic_cast<SMESHDS_Mesh*>(theMesh);
+}
+
+void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
+{
+ myShape = theShape;
+}
+
+bool Controls::LyingOnGeom::IsSatisfy( long theId )
+{
+ if ( myMeshDS == 0 || myShape.IsNull() )
+ return false;
+
+ if( myType == SMDSAbs_Node )
+ {
+ if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
+ {
+ const SMDS_PositionPtr& aPosition = aNode->GetPosition();
+ SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
+ switch( aTypeOfPosition )
+ {
+ case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
+ case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
+ case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
+ case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
+ }
+ }
+ }
+ else
+ {
+ if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
+ {
+ if( myType == SMDSAbs_All )
+ {
+ return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
+ Contains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
+ Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
+ Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
+ }
+ else if( myType == anElem->GetType() )
+ {
+ switch( myType )
+ {
+ case SMDSAbs_Edge : return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE );
+ case SMDSAbs_Face : return Contains( myMeshDS,myShape,anElem,TopAbs_FACE );
+ case SMDSAbs_Volume: return Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
+ Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+void Controls::LyingOnGeom::SetType( SMDSAbs_ElementType theType )
+{
+ myType = theType;
+}
+
+SMDSAbs_ElementType Controls::LyingOnGeom::GetType() const
+{
+ return myType;
+}
+
+TopoDS_Shape Controls::LyingOnGeom::GetShape()
+{
+ return myShape;
+}
+
+SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS()
+{
+ return myMeshDS;
+}
+
+bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh* theMeshDS,
+ const TopoDS_Shape& theShape,
+ const SMDS_MeshElement* theElem,
+ TopAbs_ShapeEnum theFindShapeEnum,
+ TopAbs_ShapeEnum theAvoidShapeEnum )
+{
+ if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum))
+ return true;
+
+ if ( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( theShape ) )
+ {
+ SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
+ while ( aNodeIt->more() )
+ {
+ const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
+ SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
+ while ( anElemIt->more() )
+ {
+ const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
+ if (anElement == theElem)
+ return true;
+ }
+ }
+ }
+
+ TopExp_Explorer anExp( theShape,TopAbs_VERTEX,theAvoidShapeEnum );
+
+ while( anExp.More() )
+ {
+ const TopoDS_Shape& aShape = anExp.Current();
+ if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
+ SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
+ while ( aNodeIt->more() )
+ {
+ const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
+ SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
+ while ( anElemIt->more() )
+ {
+ const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
+ if (anElement == theElem)
+ return true;
+ }
+ }
+ }
+ anExp.Next();
+ }
+ return false;
+}
+
/*
AUXILIARY METHODS
}
+/*
+ Class : AspectRatio3D
+ Description : Functor for calculating aspect ratio 3D
+*/
+AspectRatio3D_i::AspectRatio3D_i()
+{
+ myNumericalFunctorPtr.reset( new Controls::AspectRatio3D() );
+ myFunctorPtr = myNumericalFunctorPtr;
+}
+
+FunctorType AspectRatio3D_i::GetFunctorType()
+{
+ return SMESH::FT_AspectRatio3D;
+}
+
+
/*
Class : Warping_i
Description : Functor for calculating warping
return SMESH::FT_Length;
}
+/*
+ Class : Length2D_i
+ Description : Functor for calculating length of edge
+*/
+Length2D_i::Length2D_i()
+{
+ myNumericalFunctorPtr.reset( new Controls::Length2D() );
+ myFunctorPtr = myNumericalFunctorPtr;
+}
+
+FunctorType Length2D_i::GetFunctorType()
+{
+ return SMESH::FT_Length2D;
+}
+
+SMESH::Length2D::Values* Length2D_i::GetValues()
+{
+ INFOS("Length2D_i::GetValues");
+ SMESH::Controls::Length2D::TValues aValues;
+ myLength2DPtr->GetValues( aValues );
+
+ long i = 0, iEnd = aValues.size();
+
+ SMESH::Length2D::Values_var aResult = new SMESH::Length2D::Values(iEnd);
+
+ SMESH::Controls::Length2D::TValues::const_iterator anIter;
+ for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
+ {
+ const SMESH::Controls::Length2D::Value& aVal = *anIter;
+ SMESH::Length2D::Value &aValue = aResult[ i ];
+
+ aValue.myLength = aVal.myLength;
+ aValue.myPnt1 = aVal.myPntId[ 0 ];
+ aValue.myPnt2 = aVal.myPntId[ 1 ];
+
+ }
+
+ INFOS("Length2D_i::GetValuess~");
+ return aResult._retn();
+}
+
/*
Class : MultiConnection_i
Description : Functor for calculating number of faces conneted to the edge
return SMESH::FT_MultiConnection;
}
+/*
+ Class : MultiConnection2D_i
+ Description : Functor for calculating number of faces conneted to the edge
+*/
+MultiConnection2D_i::MultiConnection2D_i()
+{
+ myNumericalFunctorPtr.reset( new Controls::MultiConnection2D() );
+ myFunctorPtr = myNumericalFunctorPtr;
+}
+
+FunctorType MultiConnection2D_i::GetFunctorType()
+{
+ return SMESH::FT_MultiConnection2D;
+}
+
+SMESH::MultiConnection2D::Values* MultiConnection2D_i::GetValues()
+{
+ INFOS("MultiConnection2D_i::GetValues");
+ SMESH::Controls::MultiConnection2D::MValues aValues;
+ myMulticonnection2DPtr->GetValues( aValues );
+
+ long i = 0, iEnd = aValues.size();
+
+ SMESH::MultiConnection2D::Values_var aResult = new SMESH::MultiConnection2D::Values(iEnd);
+
+ SMESH::Controls::MultiConnection2D::MValues::const_iterator anIter;
+ for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
+ {
+ const SMESH::Controls::MultiConnection2D::Value& aVal = (*anIter).first;
+ SMESH::MultiConnection2D::Value &aValue = aResult[ i ];
+
+ aValue.myPnt1 = aVal.myPntId[ 0 ];
+ aValue.myPnt2 = aVal.myPntId[ 1 ];
+ aValue.myNbConnects = (*anIter).second;
+
+ }
+
+ INFOS("Multiconnection2D_i::GetValuess~");
+ return aResult._retn();
+}
/*
PREDICATES
return FT_BelongToCylinder;
}
+/*
+ Class : LyingOnGeom_i
+ Description : Predicate for selection on geometrical support
+*/
+LyingOnGeom_i::LyingOnGeom_i()
+{
+ myLyingOnGeomPtr.reset( new Controls::LyingOnGeom() );
+ myFunctorPtr = myPredicatePtr = myLyingOnGeomPtr;
+ myShapeName = 0;
+}
+
+LyingOnGeom_i::~LyingOnGeom_i()
+{
+ delete myShapeName;
+}
+
+void LyingOnGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
+{
+ if ( theGeom->_is_nil() )
+ return;
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
+ TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
+ myLyingOnGeomPtr->SetGeom( aLocShape );
+}
+void LyingOnGeom_i::SetGeom( const TopoDS_Shape& theShape )
+{
+ myLyingOnGeomPtr->SetGeom( theShape );
+}
+
+void LyingOnGeom_i::SetElementType(ElementType theType){
+ myLyingOnGeomPtr->SetType(SMDSAbs_ElementType(theType));
+}
+
+FunctorType LyingOnGeom_i::GetFunctorType()
+{
+ return SMESH::FT_LyingOnGeom;
+}
+
+void LyingOnGeom_i::SetShapeName( const char* theName )
+{
+ delete myShapeName;
+ myShapeName = strdup( theName );
+ myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
+}
+
+char* LyingOnGeom_i::GetShapeName()
+{
+ return CORBA::string_dup( myShapeName );
+}
/*
Class : FreeBorders_i
}
+AspectRatio3D_ptr FilterManager_i::CreateAspectRatio3D()
+{
+ SMESH::AspectRatio3D_i* aServant = new SMESH::AspectRatio3D_i();
+ SMESH::AspectRatio3D_var anObj = aServant->_this();
+ return anObj._retn();
+}
+
+
Warping_ptr FilterManager_i::CreateWarping()
{
SMESH::Warping_i* aServant = new SMESH::Warping_i();
return anObj._retn();
}
+Length2D_ptr FilterManager_i::CreateLength2D()
+{
+ SMESH::Length2D_i* aServant = new SMESH::Length2D_i();
+ SMESH::Length2D_var anObj = aServant->_this();
+ return anObj._retn();
+}
MultiConnection_ptr FilterManager_i::CreateMultiConnection()
{
return anObj._retn();
}
+MultiConnection2D_ptr FilterManager_i::CreateMultiConnection2D()
+{
+ SMESH::MultiConnection2D_i* aServant = new SMESH::MultiConnection2D_i();
+ SMESH::MultiConnection2D_var anObj = aServant->_this();
+ return anObj._retn();
+}
BelongToGeom_ptr FilterManager_i::CreateBelongToGeom()
{
return anObj._retn();
}
+LyingOnGeom_ptr FilterManager_i::CreateLyingOnGeom()
+{
+ SMESH::LyingOnGeom_i* aServant = new SMESH::LyingOnGeom_i();
+ SMESH::LyingOnGeom_var anObj = aServant->_this();
+ return anObj._retn();
+}
+
FreeBorders_ptr FilterManager_i::CreateFreeBorders()
{
SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i();
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
theCriteria[ i ].Tolerance = aPred->GetTolerance();
+ return true;
+ }
+ case FT_LyingOnGeom:
+ {
+ LyingOnGeom_i* aPred = dynamic_cast<LyingOnGeom_i*>( thePred );
+
+ CORBA::ULong i = theCriteria->length();
+ theCriteria->length( i + 1 );
+
+ theCriteria[ i ] = createCriterion();
+
+ theCriteria[ i ].Type = FT_LyingOnGeom;
+ theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
+ theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+
return true;
}
case FT_RangeOfIds:
case SMESH::FT_MultiConnection:
aFunctor = aFilterMgr->CreateMultiConnection();
break;
+ case SMESH::FT_MultiConnection2D:
+ aFunctor = aFilterMgr->CreateMultiConnection2D();
+ break;
case SMESH::FT_Length:
aFunctor = aFilterMgr->CreateLength();
break;
+ case SMESH::FT_Length2D:
+ aFunctor = aFilterMgr->CreateLength2D();
+ break;
case SMESH::FT_AspectRatio:
aFunctor = aFilterMgr->CreateAspectRatio();
break;
+ case SMESH::FT_AspectRatio3D:
+ aFunctor = aFilterMgr->CreateAspectRatio3D();
+ break;
case SMESH::FT_Warping:
aFunctor = aFilterMgr->CreateWarping();
break;
aPredicate = tmpPred;
}
break;
+ case SMESH::FT_LyingOnGeom:
+ {
+ SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom();
+ tmpPred->SetElementType( aTypeOfElem );
+ tmpPred->SetShapeName( aThresholdStr );
+ aPredicate = tmpPred;
+ }
+ break;
case SMESH::FT_RangeOfIds:
{
SMESH::RangeOfIds_ptr tmpPred = aFilterMgr->CreateRangeOfIds();
case FT_BelongToGeom : return "Belong to Geom";
case FT_BelongToPlane : return "Belong to Plane";
case FT_BelongToCylinder: return "Belong to Cylinder";
+ case FT_LyingOnGeom : return "Lying on Geom";
case FT_RangeOfIds : return "Range of IDs";
case FT_FreeBorders : return "Free borders";
case FT_FreeEdges : return "Free edges";
case FT_MultiConnection : return "Borders at multi-connections";
+ case FT_MultiConnection2D: return "Borders at multi-connections 2D";
case FT_Length : return "Length";
+ case FT_Length2D : return "Length2D";
case FT_LessThan : return "Less than";
case FT_MoreThan : return "More than";
case FT_EqualTo : return "Equal to";
else if ( theStr.equals( "Belong to Geom" ) ) return FT_BelongToGeom;
else if ( theStr.equals( "Belong to Plane" ) ) return FT_BelongToPlane;
else if ( theStr.equals( "Belong to Cylinder" ) ) return FT_BelongToCylinder;
+ else if ( theStr.equals( "Lying on Geom" ) ) return FT_LyingOnGeom;
else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders;
else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges;
else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection;
+ // else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D;
else if ( theStr.equals( "Length" ) ) return FT_Length;
+ // else if ( theStr.equals( "Length2D" ) ) return FT_Length2D;
else if ( theStr.equals( "Range of IDs" ) ) return FT_RangeOfIds;
else if ( theStr.equals( "Less than" ) ) return FT_LessThan;
else if ( theStr.equals( "More than" ) ) return FT_MoreThan;
return aResArray._retn();
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#include <TopoDS_Shape.hxx>
#include "SALOME_GenericObj_i.hh"
-#include "SMESH_Controls.hxx"
+#include "SMESH_ControlsDef.hxx"
class SMESHDS_Mesh;
SMDSAbs_ElementType myType;
};
typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
+
+/*
+ Class : LyingOnGeom
+ Description : Predicate for verifying whether entiy lying or partially lying on
+ specified geometrical support
+*/
+class LyingOnGeom: public virtual Predicate
+{
+public:
+ LyingOnGeom();
+
+ virtual void SetMesh( SMDS_Mesh* theMesh );
+ virtual void SetGeom( const TopoDS_Shape& theShape );
+
+ virtual bool IsSatisfy( long theElementId );
+
+ virtual void SetType( SMDSAbs_ElementType theType );
+ virtual SMDSAbs_ElementType GetType() const;
+
+ TopoDS_Shape GetShape();
+ SMESHDS_Mesh* GetMeshDS();
+
+ virtual bool Contains( SMESHDS_Mesh* theMeshDS,
+ const TopoDS_Shape& theShape,
+ const SMDS_MeshElement* theElem,
+ TopAbs_ShapeEnum theFindShapeEnum,
+ TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE );
+private:
+ TopoDS_Shape myShape;
+ SMESHDS_Mesh* myMeshDS;
+ SMDSAbs_ElementType myType;
+};
+typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
}
/*
};
+/*
+ Class : AspectRatio3D_i
+ Description : Functor for calculating aspect ratio for 3D
+*/
+class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D,
+ public virtual NumericalFunctor_i
+{
+public:
+ AspectRatio3D_i();
+ FunctorType GetFunctorType();
+};
+
+
/*
Class : Warping_i
Description : Functor for calculating warping
FunctorType GetFunctorType();
};
+/*
+ Class : Length2D_i
+ Description : Functor for calculating length of edge
+*/
+class Length2D_i: public virtual POA_SMESH::Length2D,
+ public virtual NumericalFunctor_i
+{
+public:
+ Length2D_i();
+ SMESH::Length2D::Values* GetValues();
+ FunctorType GetFunctorType();
+
+protected:
+ Controls::Length2DPtr myLength2DPtr;
+};
+
/*
Class : MultiConnection_i
FunctorType GetFunctorType();
};
+/*
+ Class : MultiConnection2D_i
+ Description : Functor for calculating number of faces conneted to the edge
+*/
+class MultiConnection2D_i: public virtual POA_SMESH::MultiConnection2D,
+ public virtual NumericalFunctor_i
+{
+public:
+ MultiConnection2D_i();
+ SMESH::MultiConnection2D::Values* GetValues();
+ FunctorType GetFunctorType();
+
+protected:
+ Controls::MultiConnection2DPtr myMulticonnection2DPtr;
+};
+
/*
PREDICATES
FunctorType GetFunctorType();
};
+/*
+ Class : LyingOnGeom_i
+ Description : Predicate for selection on geometrical support(lying or partially lying)
+*/
+class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom,
+ public virtual Predicate_i
+{
+public:
+ LyingOnGeom_i();
+ virtual ~LyingOnGeom_i();
+
+ void SetGeom( GEOM::GEOM_Object_ptr theGeom );
+ void SetElementType( ElementType theType );
+ FunctorType GetFunctorType();
+
+ void SetGeom( const TopoDS_Shape& theShape );
+
+ void SetShapeName( const char* theName );
+ char* GetShapeName();
+
+protected:
+ Controls::LyingOnGeomPtr myLyingOnGeomPtr;
+ char* myShapeName;
+};
/*
Class : FreeBorders_i
FilterManager_i();
MinimumAngle_ptr CreateMinimumAngle();
AspectRatio_ptr CreateAspectRatio();
+ AspectRatio3D_ptr CreateAspectRatio3D();
Warping_ptr CreateWarping();
Taper_ptr CreateTaper();
Skew_ptr CreateSkew();
Area_ptr CreateArea();
Length_ptr CreateLength();
+ Length2D_ptr CreateLength2D();
MultiConnection_ptr CreateMultiConnection();
+ MultiConnection2D_ptr CreateMultiConnection2D();
BelongToGeom_ptr CreateBelongToGeom();
BelongToPlane_ptr CreateBelongToPlane();
BelongToCylinder_ptr CreateBelongToCylinder();
+ LyingOnGeom_ptr CreateLyingOnGeom();
+
FreeBorders_ptr CreateFreeBorders();
FreeEdges_ptr CreateFreeEdges();
ExtrusionSweep(anElementsId, theStepVector, theNbOfSteps);
}
+//=======================================================================
+//function : ExtrusionAlongPath
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
+ SMESH::SMESH_Mesh_ptr thePathMesh,
+ GEOM::GEOM_Object_ptr thePathShape,
+ CORBA::Long theNodeStart,
+ CORBA::Boolean theHasAngles,
+ const SMESH::double_array & theAngles,
+ CORBA::Boolean theHasRefPoint,
+ const SMESH::PointStruct & theRefPoint)
+{
+ SMESHDS_Mesh* aMesh = GetMeshDS();
+
+ if ( thePathMesh->_is_nil() || thePathShape->_is_nil() )
+ return;
+
+ SMESH_Mesh_i* aMeshImp = dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( thePathMesh ).in() );
+ TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
+ SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
+
+ if ( !aSubMesh )
+ return;
+
+ SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
+ if ( !nodeStart )
+ return;
+
+ set<const SMDS_MeshElement*> elements;
+ for (int i = 0; i < theIDsOfElements.length(); i++)
+ {
+ CORBA::Long index = theIDsOfElements[i];
+ const SMDS_MeshElement * elem = aMesh->FindElement(index);
+ if ( elem )
+ elements.insert( elem );
+ }
+
+ list<double> angles;
+ for (int i = 0; i < theAngles.length(); i++)
+ {
+ angles.push_back( theAngles[i] );
+ }
+
+ gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
+
+ ::SMESH_MeshEditor anEditor( _myMesh );
+ int res = anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, theHasAngles, angles, theHasRefPoint, refPnt );
+}
+
+//=======================================================================
+//function : ExtrusionAlongPathObject
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::SMESH_Mesh_ptr thePathMesh,
+ GEOM::GEOM_Object_ptr thePathShape,
+ CORBA::Long theNodeStart,
+ CORBA::Boolean theHasAngles,
+ const SMESH::double_array & theAngles,
+ CORBA::Boolean theHasRefPoint,
+ const SMESH::PointStruct & theRefPoint)
+{
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ ExtrusionAlongPath( anElementsId, thePathMesh, thePathShape, theNodeStart, theHasAngles, theAngles, theHasRefPoint, theRefPoint );
+}
+
//=======================================================================
//function : Mirror
//purpose :
{
::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
::SMESH_MeshEditor anEditor( _myMesh );
- anEditor.FindCoincidentNodes( Tolerance, aListOfListOfNodes );
+ set<const SMDS_MeshNode*> nodes; // no input nodes
+ anEditor.FindCoincidentNodes( nodes, Tolerance, aListOfListOfNodes );
GroupsOfNodes = new SMESH::array_of_long_array;
GroupsOfNodes->length( aListOfListOfNodes.size() );
const SMESH::DirStruct & StepVector,
CORBA::Long NbOfSteps);
+ void ExtrusionAlongPath(const SMESH::long_array & IDsOfElements,
+ SMESH::SMESH_Mesh_ptr PathMesh,
+ GEOM::GEOM_Object_ptr PathShape,
+ CORBA::Long NodeStart,
+ CORBA::Boolean HasAngles,
+ const SMESH::double_array & Angles,
+ CORBA::Boolean HasRefPoint,
+ const SMESH::PointStruct & RefPoint);
+
+ void ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::SMESH_Mesh_ptr PathMesh,
+ GEOM::GEOM_Object_ptr PathShape,
+ CORBA::Long NodeStart,
+ CORBA::Boolean HasAngles,
+ const SMESH::double_array & Angles,
+ CORBA::Boolean HasRefPoint,
+ const SMESH::PointStruct & RefPoint);
+
void Mirror(const SMESH::long_array & IDsOfElements,
const SMESH::AxisStruct & Axis,
SMESH::SMESH_MeshEditor::MirrorType MirrorType,
#include "OpUtil.hxx"
#include "TCollection_AsciiString.hxx"
-#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_MapIteratorOfMapOfInteger.hxx>
-#include <TColStd_SequenceOfInteger.hxx>
#include "SMESHDS_Command.hxx"
#include "SMESHDS_CommandType.hxx"
#include "SMESH_MeshEditor_i.hxx"
#include "SMESH_Gen_i.hxx"
#include "DriverMED_R_SMESHDS_Mesh.h"
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+#include <TColStd_SequenceOfInteger.hxx>
+
#include <string>
#include <iostream>
-// _CS_gbo_050504 Ajout explicite du sstream pour ostringstream
#include <sstream>
#ifdef _DEBUG_
catch(SALOME_Exception & S_ex) {
THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
}
- return subMesh;
+ return subMesh._retn();
}
//=============================================================================
*/
//=============================================================================
-void SMESH_Mesh_i::ExportMED(const char *file, CORBA::Boolean auto_groups) throw(SALOME::SALOME_Exception)
+void SMESH_Mesh_i::ExportToMED( const char* file,
+ CORBA::Boolean auto_groups,
+ SMESH::MED_VERSION theVersion )
+ throw(SALOME::SALOME_Exception)
{
Unexpect aCatch(SALOME_SalomeException);
-
+
char* aMeshName = "Mesh";
SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
if ( !aStudy->_is_nil() ) {
//SCRUTE(file);
//SCRUTE(aMeshName);
//SCRUTE(aMeshSO->GetID());
-
+
// asv : 27.10.04 : fix of 6903: check for StudyLocked before adding attributes
if ( !aStudy->GetProperties()->IsLocked() )
- {
+ {
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
SALOMEDS::AttributeExternalFileDef_var aFileName;
aFileType = SALOMEDS::AttributeFileType::_narrow(anAttr);
ASSERT(!aFileType->_is_nil());
aFileType->SetValue("FICHIERMED");
- }
+ }
}
}
- _impl->ExportMED( file, aMeshName, auto_groups );
+ _impl->ExportMED( file, aMeshName, auto_groups, theVersion );
+}
+
+void SMESH_Mesh_i::ExportMED( const char* file,
+ CORBA::Boolean auto_groups)
+ throw(SALOME::SALOME_Exception)
+{
+ ExportToMED(file,auto_groups,SMESH::MED_V2_1);
}
void SMESH_Mesh_i::ExportDAT(const char *file) throw(SALOME::SALOME_Exception)
return _impl->NbNodes();
}
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+CORBA::Long SMESH_Mesh_i::NbElements()throw (SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ return NbEdges() + NbFaces() + NbVolumes();
+}
+
//=============================================================================
/*!
*
return aResult._retn();
}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::long_array* SMESH_Mesh_i::GetElementsId()
+ throw (SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ MESSAGE("SMESH_Mesh_i::GetElementsId");
+ SMESH::long_array_var aResult = new SMESH::long_array();
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+
+ if ( aSMESHDS_Mesh == NULL )
+ return aResult._retn();
+
+ long nbElements = NbElements();
+ aResult->length( nbElements );
+ SMDS_ElemIteratorPtr anIt = aSMESHDS_Mesh->elementsIterator();
+ for ( int i = 0, n = nbElements; i < n && anIt->more(); i++ )
+ aResult[i] = anIt->next()->GetID();
+
+ return aResult._retn();
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::long_array* SMESH_Mesh_i::GetElementsByType( SMESH::ElementType theElemType )
+ throw (SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ MESSAGE("SMESH_subMesh_i::GetElementsByType");
+ SMESH::long_array_var aResult = new SMESH::long_array();
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+
+ if ( aSMESHDS_Mesh == NULL )
+ return aResult._retn();
+
+ long nbElements = NbElements();
+
+ // No sense in returning ids of elements along with ids of nodes:
+ // when theElemType == SMESH::ALL, return node ids only if
+ // there are no elements
+ if ( theElemType == SMESH::NODE || theElemType == SMESH::ALL && nbElements == 0 )
+ return GetNodesId();
+
+ aResult->length( nbElements );
+
+ int i = 0;
+
+ SMDS_ElemIteratorPtr anIt = aSMESHDS_Mesh->elementsIterator();
+ while ( i < nbElements && anIt->more() ) {
+ const SMDS_MeshElement* anElem = anIt->next();
+ if ( theElemType == SMESH::ALL || anElem->GetType() == (SMDSAbs_ElementType)theElemType )
+ aResult[i++] = anElem->GetID();
+ }
+
+ aResult->length( i );
+
+ return aResult._retn();
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::long_array* SMESH_Mesh_i::GetNodesId()
+ throw (SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ MESSAGE("SMESH_subMesh_i::GetNodesId");
+ SMESH::long_array_var aResult = new SMESH::long_array();
+ SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+
+ if ( aSMESHDS_Mesh == NULL )
+ return aResult._retn();
+
+ long nbNodes = NbNodes();
+ aResult->length( nbNodes );
+ SMDS_NodeIteratorPtr anIt = aSMESHDS_Mesh->nodesIterator();
+ for ( int i = 0, n = nbNodes; i < n && anIt->more(); i++ )
+ aResult[i] = anIt->next()->GetID();
+
+ return aResult._retn();
+}
+
SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
throw (SALOME::SALOME_Exception);
+ void ExportToMED( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion )
+ throw (SALOME::SALOME_Exception);
void ExportMED( const char* file, CORBA::Boolean auto_groups )
throw (SALOME::SALOME_Exception);
+
void ExportDAT( const char* file )
throw (SALOME::SALOME_Exception);
void ExportUNV( const char* file )
CORBA::Long NbNodes()
throw (SALOME::SALOME_Exception);
+ CORBA::Long NbElements()
+ throw (SALOME::SALOME_Exception);
+
CORBA::Long NbEdges()
throw (SALOME::SALOME_Exception);
CORBA::Long NbSubMesh()
throw (SALOME::SALOME_Exception);
+ SMESH::long_array* GetElementsId()
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::long_array* GetNodesId()
+ throw (SALOME::SALOME_Exception);
+
char* Dump();
// Internal methods not available through CORBA
#include "SMESH_Gen_i.hxx"
#include "SMESH_Mesh.hxx"
#include "SMESH_Mesh_i.hxx"
+#include "SMDS_MeshFace.hxx"
+#include "SMDS_MeshVolume.hxx"
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <sstream>
+#include <set>
+// =============================================================================
//=============================================================================
/*!
+// =============================================================================
* SMESH_Gen_i::GetPattern
*
* Create pattern mapper
{
}
-//=======================================================================
-//function : getShape
-//purpose :
-//=======================================================================
-
-TopoDS_Shape SMESH_Pattern_i::getShape( GEOM::GEOM_Object_ptr & theGeomObject )
-{
- return myGen->GetShapeReader()->GetShape( SMESH_Gen_i::GetGeomEngine(), theGeomObject );
-}
-
//=======================================================================
//function : getMesh
//purpose :
if ( !aMesh )
return false;
- TopoDS_Face aFace = TopoDS::Face( getShape( theFace ));
+ TopoDS_Face aFace = TopoDS::Face( myGen->GeomObjectToShape( theFace ));
if ( aFace.IsNull() )
return false;
if ( !aMesh )
return false;
- TopoDS_Shape aShape = getShape( theBlock );
+ TopoDS_Shape aShape = myGen->GeomObjectToShape( theBlock );
if ( aShape.IsNull())
return false;
SMESH::point_array_var points = new SMESH::point_array;
list<const gp_XYZ *> xyzList;
- TopoDS_Shape F = getShape( theFace );
- TopoDS_Shape V = getShape( theVertexOnKeyPoint1 );
+ TopoDS_Shape F = myGen->GeomObjectToShape( theFace );
+ TopoDS_Shape V = myGen->GeomObjectToShape( theVertexOnKeyPoint1 );
if (!F.IsNull() && F.ShapeType() == TopAbs_FACE &&
!V.IsNull() && V.ShapeType() == TopAbs_VERTEX
SMESH::point_array_var points = new SMESH::point_array;
list<const gp_XYZ *> xyzList;
- TopExp_Explorer exp( getShape( theBlock ), TopAbs_SHELL );
- TopoDS_Shape V000 = getShape( theVertex000 );
- TopoDS_Shape V001 = getShape( theVertex001 );
+ TopExp_Explorer exp( myGen->GeomObjectToShape( theBlock ), TopAbs_SHELL );
+ TopoDS_Shape V000 = myGen->GeomObjectToShape( theVertex000 );
+ TopoDS_Shape V001 = myGen->GeomObjectToShape( theVertex001 );
if (exp.More() &&
!V000.IsNull() && V000.ShapeType() == TopAbs_VERTEX &&
return points._retn();
}
+//=======================================================================
+//function : ApplyToMeshFaces
+//purpose :
+//=======================================================================
+
+SMESH::point_array*
+ SMESH_Pattern_i::ApplyToMeshFaces(SMESH::SMESH_Mesh_ptr theMesh,
+ const SMESH::long_array& theFacesIDs,
+ CORBA::Long theNodeIndexOnKeyPoint1,
+ CORBA::Boolean theReverse)
+{
+ SMESH::point_array_var points = new SMESH::point_array;
+
+ ::SMESH_Mesh* aMesh = getMesh( theMesh );
+ if ( !aMesh )
+ return points._retn();
+
+ list<const gp_XYZ *> xyzList;
+ set<const SMDS_MeshFace*> fset;
+ for (int i = 0; i < theFacesIDs.length(); i++)
+ {
+ CORBA::Long index = theFacesIDs[i];
+ const SMDS_MeshElement * elem = aMesh->GetMeshDS()->FindElement(index);
+ if ( elem && elem->GetType() == SMDSAbs_Face )
+ fset.insert( static_cast<const SMDS_MeshFace *>( elem ));
+ }
+ if (myPattern.Apply( fset, theNodeIndexOnKeyPoint1, theReverse ) &&
+ myPattern.GetMappedPoints( xyzList ))
+ {
+ points->length( xyzList.size() );
+ list<const gp_XYZ *>::iterator xyzIt = xyzList.begin();
+ for ( int i = 0; xyzIt != xyzList.end(); xyzIt++ ) {
+ SMESH::PointStruct & p = points[ i++ ];
+ (*xyzIt)->Coord( p.x, p.y, p.z );
+ }
+ }
+
+ return points._retn();
+}
+
+//=======================================================================
+//function : ApplyToHexahedrons
+//purpose :
+//=======================================================================
+
+SMESH::point_array*
+ SMESH_Pattern_i::ApplyToHexahedrons(SMESH::SMESH_Mesh_ptr theMesh,
+ const SMESH::long_array& theVolumesIDs,
+ CORBA::Long theNode000Index,
+ CORBA::Long theNode001Index)
+{
+ SMESH::point_array_var points = new SMESH::point_array;
+
+ ::SMESH_Mesh* aMesh = getMesh( theMesh );
+ if ( !aMesh )
+ return points._retn();
+
+ list<const gp_XYZ *> xyzList;
+ set<const SMDS_MeshVolume*> vset;
+ for (int i = 0; i < theVolumesIDs.length(); i++)
+ {
+ CORBA::Long index = theVolumesIDs[i];
+ const SMDS_MeshElement * elem = aMesh->GetMeshDS()->FindElement(index);
+ if ( elem && elem->GetType() == SMDSAbs_Volume && elem->NbNodes() == 8 )
+ vset.insert( static_cast<const SMDS_MeshVolume *>( elem ));
+ }
+ if (myPattern.Apply( vset, theNode000Index, theNode001Index ) &&
+ myPattern.GetMappedPoints( xyzList ))
+ {
+ points->length( xyzList.size() );
+ list<const gp_XYZ *>::iterator xyzIt = xyzList.begin();
+ for ( int i = 0; xyzIt != xyzList.end(); xyzIt++ ) {
+ SMESH::PointStruct & p = points[ i++ ];
+ (*xyzIt)->Coord( p.x, p.y, p.z );
+ }
+ }
+
+ return points._retn();
+}
+
//=======================================================================
//function : MakeMesh
//purpose :
GEOM::GEOM_Object_ptr theVertex000,
GEOM::GEOM_Object_ptr theVertex001);
+ SMESH::point_array* ApplyToMeshFaces(SMESH::SMESH_Mesh_ptr theMesh,
+ const SMESH::long_array& theFacesIDs,
+ CORBA::Long theNodeIndexOnKeyPoint1,
+ CORBA::Boolean theReverse);
+
+ SMESH::point_array* ApplyToHexahedrons(SMESH::SMESH_Mesh_ptr theMesh,
+ const SMESH::long_array& theVolumesIDs,
+ CORBA::Long theNode000Index,
+ CORBA::Long theNode001Index);
+
CORBA::Boolean MakeMesh(SMESH::SMESH_Mesh_ptr theMesh);
SMESH::SMESH_Pattern::ErrorCode GetErrorCode();
private:
- TopoDS_Shape getShape( GEOM::GEOM_Object_ptr & theGeomObject );
-
::SMESH_Mesh* getMesh( SMESH::SMESH_Mesh_ptr & theMesh );
::SMESH_Pattern myPattern;
+++ /dev/null
-# SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
-#
-# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-#
-#
-#
-# File : SMESH_test.py
-# Module : SMESH
-
-import salome
-import geompy
-import smeshpy
-
-import SMESH
-import StdMeshers
-
-# ---- define a box
-
-box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
-idb = geompy.addToStudy(box, "box")
-
-# ---- add first face of box in study
-
-subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
-face = subShapeList[0]
-name = geompy.SubShapeName(face, box)
-idf = geompy.addToStudyInFather(box, face, name)
-
-# ---- add shell from box in study
-
-subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
-shell = subShellList[0]
-name = geompy.SubShapeName(shell, box)
-ids = geompy.addToStudyInFather(box, shell, name)
-
-# ---- add first edge of face in study
-
-edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
-edge = edgeList[0];
-name = geompy.SubShapeName(edge, face)
-ide = geompy.addToStudyInFather(face, edge, name)
-
-# ---- launch SMESH, init a Mesh with the box
-
-gen = smeshpy.smeshpy()
-mesh = gen.CreateMesh(idb)
-
-print "-------------------------- create Hypothesis"
-
-print "-------------------------- LocalLength"
-
-hypo1 = gen.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
-print hypo1.GetName()
-print hypo1.GetId()
-print hypo1.GetLength()
-hypo1.SetLength(100)
-print hypo1.GetLength()
-
-print "-------------------------- bidon"
-
-hyp3 = gen.CreateHypothesis("bidon", "")
-
-print "-------------------------- NumberOfSegments"
-
-hypo3 = gen.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
-hypo3.SetNumberOfSegments(7)
-print hypo3.GetName()
-print hypo3.GetNumberOfSegments()
-print hypo3.GetId()
-
-print "-------------------------- MaxElementArea"
-
-hypo4 = gen.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
-hypo4.SetMaxElementArea(5000)
-print hypo4.GetName()
-print hypo4.GetMaxElementArea()
-print hypo4.GetId()
-
-print "-------------------------- Regular_1D"
-
-algo_1 = gen.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
-print algo_1.GetName()
-print algo_1.GetId()
-listHyp = algo_1.GetCompatibleHypothesis()
-for hyp in listHyp:
- print hyp
-print algo_1.GetId()
-
-print "-------------------------- MEFISTO_2D"
-
-algo_2 = gen.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
-print algo_2.GetName()
-print algo_2.GetId()
-listHyp = algo_2.GetCompatibleHypothesis()
-for hyp in listHyp:
- print hyp
-print algo_2.GetId()
-
-print "-------------------------- add hypothesis to edge"
-
-edge = salome.IDToObject(ide)
-submesh = mesh.GetSubMesh(edge, "SubMeshEdge")
-ret = mesh.AddHypothesis(edge,algo_1)
-print ret
-ret = mesh.AddHypothesis(edge,hypo1)
-print ret
-
-##print "-------------------------- compute edge"
-##ret=gen.Compute(mesh,ide)
-##print ret
-##log=mesh.GetLog(1);
-##for a in log:
-## print a
-
-print "-------------------------- add hypothesis to box"
-
-box = salome.IDToObject(idb)
-submesh = mesh.GetSubMesh(box, "SubMeshBox")
-ret = mesh.AddHypothesis(box,algo_1)
-print ret
-ret = mesh.AddHypothesis(box,hypo1)
-print ret
-ret = mesh.AddHypothesis(box,algo_2)
-print ret
-ret = mesh.AddHypothesis(box,hypo4)
-print ret
-
-print "-------------------------- compute"
-
-ret = gen.Compute(mesh,idf)
-print ret
-log = mesh.GetLog(1);
-for a in log:
- print "-------"
- ii = 0
- ir = 0
- comType = a.commandType
- if comType == 0:
- for i in range(a.number):
- ind = a.indexes[ii]
- ii = ii+1
- r1 = a.coords[ir]
- ir = ir+1
- r2 = a.coords[ir]
- ir = ir+1
- r3 = a.coords[ir]
- ir = ir+1
- print "AddNode %i - %g %g %g" % (ind, r1, r2, r3)
- elif comType == 1:
- for i in range(a.number):
- ind = a.indexes[ii]
- ii = ii+1
- i1 = a.indexes[ii]
- ii = ii+1
- i2 = a.indexes[ii]
- ii = ii+1
- print "AddEdge %i - %i %i" % (ind, i1, i2)
- elif comType == 2:
- for i in range(a.number):
- ind = a.indexes[ii]
- ii = ii+1
- i1 = a.indexes[ii]
- ii = ii+1
- i2 = a.indexes[ii]
- ii = ii+1
- i3 = a.indexes[ii]
- ii = ii+1
- print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)
-
-##print "-------------------------- compute box"
-##ret=gen.Compute(mesh,idb)
-##print ret
-##log=mesh.GetLog(1);
-##print log
-
-##shell=salome.IDToObject(ids)
-##submesh=mesh.GetElementsOnShape(shell)
-##ret=mesh.AddHypothesis(shell,algo_1)
-##print ret
-##ret=mesh.AddHypothesis(shell,hypo1)
-##print ret
-##ret=gen.Compute(mesh,ids)
-##print ret
hole2pyGibi.py \
cyl2geometry.py \
cyl2complementary.py \
+ SMESH_test.py\
SMESH_test0.py\
SMESH_test1.py \
SMESH_test2.py \
SMESH_test3.py \
SMESH_test4.py \
+ SMESH_test5.py \
SMESH_mechanic.py \
SMESH_mechanic_tetra.py \
SMESH_mechanic_editor.py \
SMESH_demo_hexa2_upd.py \
SMESH_hexaedre.py \
SMESH_Sphere.py \
- SMESH_GroupFromGeom.py
+ SMESH_GroupFromGeom.py \
+ SMESH_GroupLyingOnGeom.py
LIB_CLIENT_IDL = SALOMEDS.idl \
SALOME_Exception.idl \
--- /dev/null
+import SMESH
+
+def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
+ aMeshGen = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
+
+ aFilterMgr = aMeshGen.CreateFilterManager()
+ aFilter = aFilterMgr.CreateFilter()
+
+ aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
+ aLyingOnGeom.SetGeom(theShape)
+ aLyingOnGeom.SetElementType(theElemType)
+
+ aFilter.SetPredicate(aLyingOnGeom)
+ anIds = aFilter.GetElementsId(theMesh)
+
+ aGroup = theMesh.CreateGroup(theElemType, theName)
+ aGroup.Add(anIds)
+
+#Example
+from SMESH_test1 import *
+
+smesh.Compute(mesh, box)
+BuildGroupLyingOn(mesh, SMESH.FACE, "Group of faces lying on edge", edge )
+
+salome.sg.updateObjBrowser(1);
--- /dev/null
+# SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : SMESH_test.py
+# Module : SMESH
+
+import salome
+import geompy
+import smeshpy
+
+import SMESH
+import StdMeshers
+
+# ---- define a box
+
+box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
+idb = geompy.addToStudy(box, "box")
+
+# ---- add first face of box in study
+
+subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+face = subShapeList[0]
+name = geompy.SubShapeName(face, box)
+idf = geompy.addToStudyInFather(box, face, name)
+
+# ---- add shell from box in study
+
+subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"])
+shell = subShellList[0]
+name = geompy.SubShapeName(shell, box)
+ids = geompy.addToStudyInFather(box, shell, name)
+
+# ---- add first edge of face in study
+
+edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"])
+edge = edgeList[0];
+name = geompy.SubShapeName(edge, face)
+ide = geompy.addToStudyInFather(face, edge, name)
+
+# ---- launch SMESH, init a Mesh with the box
+
+gen = smeshpy.smeshpy()
+mesh = gen.CreateMesh(idb)
+
+print "-------------------------- create Hypothesis"
+
+print "-------------------------- LocalLength"
+
+hypo1 = gen.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
+print hypo1.GetName()
+print hypo1.GetId()
+print hypo1.GetLength()
+hypo1.SetLength(100)
+print hypo1.GetLength()
+
+print "-------------------------- bidon"
+
+hyp3 = gen.CreateHypothesis("bidon", "")
+
+print "-------------------------- NumberOfSegments"
+
+hypo3 = gen.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
+hypo3.SetNumberOfSegments(7)
+print hypo3.GetName()
+print hypo3.GetNumberOfSegments()
+print hypo3.GetId()
+
+print "-------------------------- MaxElementArea"
+
+hypo4 = gen.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
+hypo4.SetMaxElementArea(5000)
+print hypo4.GetName()
+print hypo4.GetMaxElementArea()
+print hypo4.GetId()
+
+print "-------------------------- Regular_1D"
+
+algo_1 = gen.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
+print algo_1.GetName()
+print algo_1.GetId()
+listHyp = algo_1.GetCompatibleHypothesis()
+for hyp in listHyp:
+ print hyp
+print algo_1.GetId()
+
+print "-------------------------- MEFISTO_2D"
+
+algo_2 = gen.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
+print algo_2.GetName()
+print algo_2.GetId()
+listHyp = algo_2.GetCompatibleHypothesis()
+for hyp in listHyp:
+ print hyp
+print algo_2.GetId()
+
+print "-------------------------- add hypothesis to edge"
+
+edge = salome.IDToObject(ide)
+submesh = mesh.GetSubMesh(edge, "SubMeshEdge")
+ret = mesh.AddHypothesis(edge,algo_1)
+print ret
+ret = mesh.AddHypothesis(edge,hypo1)
+print ret
+
+##print "-------------------------- compute edge"
+##ret=gen.Compute(mesh,ide)
+##print ret
+##log=mesh.GetLog(1);
+##for a in log:
+## print a
+
+print "-------------------------- add hypothesis to box"
+
+box = salome.IDToObject(idb)
+submesh = mesh.GetSubMesh(box, "SubMeshBox")
+ret = mesh.AddHypothesis(box,algo_1)
+print ret
+ret = mesh.AddHypothesis(box,hypo1)
+print ret
+ret = mesh.AddHypothesis(box,algo_2)
+print ret
+ret = mesh.AddHypothesis(box,hypo4)
+print ret
+
+print "-------------------------- compute face"
+
+ret = gen.Compute(mesh,idf)
+print ret
+log = mesh.GetLog(0) # 0 - GetLog without ClearLog after, else if 1 - ClearLog after
+for a in log:
+ print "-------"
+ ii = 0
+ ir = 0
+ comType = a.commandType
+ if comType == 0:
+ for i in range(a.number):
+ ind = a.indexes[ii]
+ ii = ii+1
+ r1 = a.coords[ir]
+ ir = ir+1
+ r2 = a.coords[ir]
+ ir = ir+1
+ r3 = a.coords[ir]
+ ir = ir+1
+ print "AddNode %i - %g %g %g" % (ind, r1, r2, r3)
+ elif comType == 1:
+ for i in range(a.number):
+ ind = a.indexes[ii]
+ ii = ii+1
+ i1 = a.indexes[ii]
+ ii = ii+1
+ i2 = a.indexes[ii]
+ ii = ii+1
+ print "AddEdge %i - %i %i" % (ind, i1, i2)
+ elif comType == 2:
+ for i in range(a.number):
+ ind = a.indexes[ii]
+ ii = ii+1
+ i1 = a.indexes[ii]
+ ii = ii+1
+ i2 = a.indexes[ii]
+ ii = ii+1
+ i3 = a.indexes[ii]
+ ii = ii+1
+ print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)
+
+##print "-------------------------- compute box"
+##ret=gen.Compute(mesh,idb)
+##print ret
+##log=mesh.GetLog(1);
+##print log
+
+##shell=salome.IDToObject(ids)
+##submesh=mesh.GetElementsOnShape(shell)
+##ret=mesh.AddHypothesis(shell,algo_1)
+##print ret
+##ret=mesh.AddHypothesis(shell,hypo1)
+##print ret
+##ret=gen.Compute(mesh,ids)
+##print ret
SetSObjName(anSObj,aFileName)
print anSObj.GetName()
- aFileName = thePath + theFile + "." + str(iMesh) + ".unv"
+ aOutPath = '/tmp/'
+ aFileName = aOutPath + theFile + "." + str(iMesh) + ".unv"
aMesh.ExportUNV(aFileName)
aMesh = smesh.CreateMeshesFromUNV(aFileName)
anSObj = salome.ObjectToSObject(aMesh)
# Compound
# --------
-piece = MakeCompound(d_element)
+comp_all = MakeCompound(d_element)
+piece = BlocksOp.RemoveExtraEdges(comp_all)
+#piece = MakeCompound(d_element)
# Add piece in study
# ------------------
# Compound
# --------
-piece = MakeCompound(cpd)
+comp_all = MakeCompound(cpd)
+piece = BlocksOp.RemoveExtraEdges(comp_all)
# Ajouter la piece dans l'etude
# -----------------------------
# ------
import geompy
-
import salome
import StdMeshers
-
import SMESH
+"""
+ \namespace meshpy
+ \brief Module meshpy
+"""
+
# Variables
# ---------
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init(salome.myStudyId)
-# Hexahedrical meshing
-#
-# Examples: cube2pyGibi.py, lines 270-295
-# cube2partition.py, lines 72-83
-# --------------------
-
class MeshHexaImpl:
+"""
+ Class MeshHexaImpl for Hexahedrical meshing
+
+ Examples: cube2pyGibi.py, lines 270-295
+ cube2partition.py, lines 72-83
+"""
piece = 0
name = 0
mesh = 0
cpt = 0
- # Sets algorithm and hypothesis for 1D discretization of the <shape>:
- # - algorithm "Regular_1D"
- # - hypothesis "NumberOfSegments" with number of segments <n>
- # --------------------
-
- def Mesh1D(self, shape, n):
+ def Mesh1D(self, shape, n, propagate=0):
+ """
+ Define Wires discretization.
+ Sets algorithm and hypothesis for 1D discretization of \a shape:
+ - algorithm "Regular_1D"
+ - hypothesis "NumberOfSegments" with number of segments \a n
+ \param shape Main shape or sub-shape to define wire discretization of
+ \param n Number of segments to split eash wire of the \a shape on
+ \param propagate Boolean flag. If propagate = 1,
+ "Propagation" hypothesis will be applied also to the \a shape
+ """
hyp1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
smeshgui.SetName(salome.ObjectToID(hyp1D), self.name+"/WireDiscretisation/"+str(self.cpt))
self.mesh.AddHypothesis(shape, hyp1D)
smeshgui.SetName(salome.ObjectToID(hyp), self.name+"/Segments_"+str(n)+"/"+str(self.cpt))
self.mesh.AddHypothesis(shape, hyp)
- self.cpt=self.cpt+1
+ if propagate:
+ hypPro=smesh.CreateHypothesis("Propagation", "libStdMeshersEngine.so")
+ smeshgui.SetName(salome.ObjectToID(hypPro), self.name+"/Propagation/"+str(self.cpt))
+ self.mesh.AddHypothesis(shape, hypPro)
- # Constructor
- #
- # Creates mesh on the shape <piece>,
- # sets GUI name of this mesh to <name>.
- # Sets the following global algorithms and hypotheses:
- # - for 1D discretization:
- # - algorithm "Regular_1D"
- # - hypothesis "NumberOfSegments" with number of segments <n>,
- # - for 2D discretization:
- # - algorithm "Quadrangle_2D"
- # - for 3D discretization:
- # - algorithm "Hexa_3D"
- # --------------------
+ self.cpt=self.cpt+1
def __init__(self, piece, n, name):
+ """
+ Constructor
+
+ Creates mesh on the shape \a piece,
+ sets GUI name of this mesh to \a name. \n
+ Sets the following global algorithms and hypotheses:
+ - for 1D discretization:
+ - algorithm "Regular_1D"
+ - hypothesis "NumberOfSegments" with number of segments \a n
+ - for 2D discretization:
+ - algorithm "Quadrangle_2D"
+ - for 3D discretization:
+ - algorithm "Hexa_3D"
+ \param piece Shape to be meshed
+ \param n Global number of segments for wires discretization
+ \param name Name for mesh to be created
+ """
self.piece = piece
self.name = name
smeshgui.SetName(salome.ObjectToID(hyp3D), name+"/ijk")
self.mesh.AddHypothesis(piece, hyp3D)
- # Creates sub-mesh of the mesh, created by constructor.
- # This sub-mesh will be created on edge <edge>.
- # Set algorithm and hypothesis for 1D discretization of the <edge>:
- # - algorithm "Regular_1D"
- # - hypothesis "NumberOfSegments" with number of segments <n>
- # Note: the <edge> will be automatically published in study under the shape, given in constructor.
- # --------------------
-
def local(self, edge, n):
+ """
+ Creates sub-mesh of the mesh, created by constructor.
+ This sub-mesh will be created on edge \a edge.
+ Set algorithm and hypothesis for 1D discretization of the \a edge:
+ - algorithm "Regular_1D"
+ - hypothesis "NumberOfSegments" with number of segments \a n
+ \param edge Sub-edge of the main shape
+ \param n Number of segments to split the \a edge on
+ \note: \a edge will be automatically published in study under the shape, given in constructor.
+ """
geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece))
submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt))
self.Mesh1D(edge, n)
- # Computes mesh, created by constructor.
- # --------------------
+ def Propagate(self, edge, n):
+ """
+ Creates sub-mesh of the mesh, created by constructor.
+ This sub-mesh will be created on edge \a edge and propagate the hypothesis on all correspondant edges.
+ Set algorithm and hypothesis for 1D discretization of the \a edge and all other propagate edges:
+ - algorithm "Regular_1D"
+ - hypothesis "NumberOfSegments" with number of segments \a n
+ - hypothesis "Propagation"
+ \param edge Sub-edge of the main shape
+ \param n Number of segments to split the \a edge and all other propagate edges on
+ \note: \a edge will be automatically published in study under the shape, given in constructor.
+ """
+ geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece))
+ submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt))
+ self.Mesh1D(edge, n, 1)
def Compute(self):
+ """
+ Computes mesh, created by constructor.
+ """
smesh.Compute(self.mesh, self.piece)
salome.sg.updateObjBrowser(1)
- # Creates mesh group based on a geometric group
- # --------------------
-
def Group(self, grp, name=""):
+ """
+ Creates mesh group based on a geometric group
+ \param grp Geometric group
+ \param name Name for mesh group to be created
+ """
if name == "":
name = grp.GetName()
tgeo = geompy.GroupOp.GetType(grp)
type = SMESH.VOLUME
return self.mesh.CreateGroupFromGEOM(type, name, grp)
- # Export mesh in a MED file
- # --------------------
-
def ExportMED(self, filename, groups=1):
+ """
+ Export mesh in a MED file
+ \param filename Name for MED file to be created
+ \param groups Boolean flag. If groups = 1, mesh groups will be also stored in file
+ """
self.mesh.ExportMED(filename, groups)
MeshHexa = MeshHexaImpl
double factor =
length / (1 - pow( alpha,_value[ NB_SEGMENTS_IND ]));
- int i, NbPoints = (int) _value[ NB_SEGMENTS_IND ];
+ int i, NbPoints = 1 + (int) _value[ NB_SEGMENTS_IND ];
for ( i = 2; i < NbPoints; i++ )
{
double param = factor * (1 - pow(alpha, i - 1));
# additionnal information to compil and link file
CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \
- $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \
+ -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \
$(BOOST_CPPFLAGS)
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome
#$(OCC_CXXFLAGS)