From: admin Date: Thu, 20 Jan 2005 06:24:17 +0000 (+0000) Subject: Merge with OCC_development_01 X-Git-Tag: V2_2_0a1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ca429d817a18d6acc571443f6a596575dee03c2f;p=modules%2Fgeom.git Merge with OCC_development_01 --- diff --git a/Makefile.in b/Makefile.in index 933016af0..0abb0bdb2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -169,7 +169,11 @@ tree_block.png \ subblock.png \ group_new.png \ group_edit.png \ -glue.png +glue.png \ +check_blocks_compound.png \ +free_faces.png \ +propagate.png + BIN_SCRIPT= \ VERSION diff --git a/doc/salome/tui/GEOM/doxyfile_py b/doc/salome/tui/GEOM/doxyfile_py new file mode 100755 index 000000000..a76886de1 --- /dev/null +++ b/doc/salome/tui/GEOM/doxyfile_py @@ -0,0 +1,200 @@ +# Doxyfile 1.3-rc1 + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "SALOME - GEOM - 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 = ../GEOM/geompy_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 = diff --git a/doc/salome/tui/GEOM/sources/myheader_py2.html b/doc/salome/tui/GEOM/sources/myheader_py2.html new file mode 100755 index 000000000..372b2247f --- /dev/null +++ b/doc/salome/tui/GEOM/sources/myheader_py2.html @@ -0,0 +1,24 @@ + + + + + + Main Page + + + +  +
+ + + + + + +
+
+
+ + + + diff --git a/doc/salome/tui/GEOM/sources/static/tree.js b/doc/salome/tui/GEOM/sources/static/tree.js index 3193416d8..edeb48ce7 100755 --- a/doc/salome/tui/GEOM/sources/static/tree.js +++ b/doc/salome/tui/GEOM/sources/static/tree.js @@ -44,5 +44,16 @@ aux1 = insFld(foldersTree, gFld("Namespace List", "", "namespaces.html")) aux1 = insFld(foldersTree, gFld("IDL/Python mapping", "")) insDoc(aux1, gLnk("Mapping of GEOMETRY IDL definitions to Python language", "", "page2.html")) +/*!aux1 = insFld(foldersTree, gFld("Python Commands", "", "geompy_doc/main.html")) + insDoc(aux1, gLnk("Package geompy", "", "geompy_doc/namespacegeompy.html")) + insDoc(aux1, gLnk("Namespace Members", "", "geompy_doc/namespacemembers.html")) + insDoc(aux1, gLnk("File geompy.py", "", "geompy_doc/geompy_8py.html")) +*/ + +aux1 = insFld(foldersTree, gFld("Python Commands", "", "geompy_doc/main.html")) + insDoc(aux1, gLnk("Package List", "", "geompy_doc/namespaces.html")) + insDoc(aux1, gLnk("Namespace Members", "", "geompy_doc/namespacemembers.html")) + insDoc(aux1, gLnk("File List", "", "geompy_doc/files.html")) + /*! insDoc(foldersTree, gLnk("Graphical Class Hierarchy", "", "inherits.html")) */ diff --git a/doc/salome/tui/Makefile.in b/doc/salome/tui/Makefile.in index fa010f573..8a2c77608 100644 --- a/doc/salome/tui/Makefile.in +++ b/doc/salome/tui/Makefile.in @@ -16,13 +16,31 @@ doxygen=@DOXYGEN@ @COMMENCE@ +PYTHON_SCRIPTS = \ + geompy.py \ + GEOM_TestMeasures.py + +#PYTHON_SCRIPTS_PY2 = py2/geompy.py py2/GEOM_TestMeasures.py + docs: - cp -fr $(srcdir)/GEOM ./INPUT; \ + cp -fr $(srcdir)/GEOM ./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/GEOM_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)/GEOM/sources/static/*.* ./GEOM/ cp -fr $(srcdir)/GEOM/sources/ GEOM/ cp -fr $(srcdir)/GEOM/HTML/ GEOM/ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 63f649050..2c40235b5 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -814,6 +814,20 @@ module GEOM in long theShapeType, in boolean isSorted); + /*! + * Explode a shape on subshapes of a given type. + * Does the same, as the above method, but returns IDs of sub-shapes, + * not GEOM_Objects. It works faster. + * \param theShape Shape to be exploded. + * \param theShapeType Type of sub-shapes to be retrieved. + * \param isSorted If this parameter is TRUE, sub-shapes will be + * sorted by coordinates of their gravity centers. + * \return List of IDs of sub-shapes of type theShapeType, contained in theShape. + */ + ListOfLong SubShapeAllIDs (in GEOM_Object theShape, + in long theShapeType, + in boolean isSorted); + /*! * Get a sub shape defined by its unique ID inside \a theMainShape * \note The sub shape GEOM_Objects can has ONLY ONE function. @@ -842,6 +856,76 @@ module GEOM * \return The reversed copy of theShape. */ GEOM_Object ChangeOrientation (in GEOM_Object theShape); + + /*! + * Retrieve all free faces from the given shape. + * Free face is a face, which is not shared between two shells of the shape. + * \param theShape Shape to find free faces in. + * \return List of IDs of all free faces, contained in theShape. + */ + ListOfLong GetFreeFacesIDs (in GEOM_Object theShape); + + /*! + * Get all sub-shapes of theShape1 of the given type, shared with theShape2. + * \param theShape1 Shape to find sub-shapes in. + * \param theShape2 Shape to find shared sub-shapes with. + * \param theShapeType Type of sub-shapes to be retrieved. + * \return List of sub-shapes of theShape1, shared with theShape2. + */ + ListOfGO GetSharedShapes (in GEOM_Object theShape1, + in GEOM_Object theShape2, + in long theShapeType); + + /*! + * Get sub-shapes of theShape of the given type, + * laying on the specified plane. + * \param theShape Shape to find sub-shapes of. + * \param theShapeType Type of sub-shapes to be retrieved. + * \param thePlane Face, specifying the plane to find shapes on. + * \return Group of all found sub-shapes. + */ + GEOM_Object GetShapesOnPlane (in GEOM_Object theShape, + in long theShapeType, + in GEOM_Object thePlane); + + /*! + * Get sub-shape of theShape of the given type, + * laying on the specified cylinder. + * \param theShape Shape to find sub-shapes of. + * \param theShapeType Type of sub-shapes to be retrieved. + * \param theAxis Vector (or line, or linear edge), specifying + * axis of the cylinder to find shapes on. + * \param theRadius Radius of the cylinder to find shapes on. + * \return Group of all found sub-shapes. + */ + GEOM_Object GetShapesOnCylinder (in GEOM_Object theShape, + in long theShapeType, + in GEOM_Object theAxis, + in double theRadius); + + /*! + * Get sub-shape of theShape of the given type, + * laying on the specified sphere. + * \param theShape Shape to find sub-shapes of. + * \param theShapeType Type of sub-shapes to be retrieved. + * \param theCenter Point, specifying center of the sphere to find shapes on. + * \param theRadius Radius of the sphere to find shapes on. + * \return Group of all found sub-shapes. + */ + GEOM_Object GetShapesOnSphere (in GEOM_Object theShape, + in long theShapeType, + in GEOM_Object theCenter, + in double theRadius); + + /*! + * Get sub-shape(s) of theShapeWhere, which are + * coincident with \a theShapeWhat or could be a part of it. + * \param theShapeWhere Shape to find sub-shapes of. + * \param theShapeWhat Shape, specifying what to find. + * \return Group of all found sub-shapes or a single found sub-shape. + */ + GEOM_Object GetInPlace (in GEOM_Object theShapeWhere, + in GEOM_Object theShapeWhat); }; /*! @@ -1017,10 +1101,20 @@ module GEOM */ enum BCErrorType { - NOT_BLOCK, /* Each element of the compound should be a Block */ - INVALID_CONNECTION, /* A connection between two Blocks should be an entire face or an entire edge */ - NOT_CONNECTED, /* The compound should be connexe */ - NOT_GLUED /* The glue between two quadrangle faces should be applied */ + /* Each element of the compound should be a Block */ + NOT_BLOCK, + + /* An element is a potential block, but has degenerated and/or seam edge(s). */ + EXTRA_EDGE, + + /* A connection between two Blocks should be an entire face or an entire edge */ + INVALID_CONNECTION, + + /* The compound should be connexe */ + NOT_CONNECTED, + + /* The glue between two quadrangle faces should be applied */ + NOT_GLUED }; /*! @@ -1045,6 +1139,7 @@ module GEOM * - A connection between two Blocks should be an entire quadrangle face or an entire edge. * - The compound should be connexe. * - The glue between two quadrangle faces should be applied. + * \note Single block is also accepted as a valid compound of blocks. * \param theCompound The compound to check. * \return TRUE, if the given shape is a compound of blocks. * \return theErrors Structure, containing discovered errors and incriminated sub-shapes. @@ -1062,6 +1157,23 @@ module GEOM string PrintBCErrors (in GEOM_Object theCompound, in BCErrors theErrors); + /*! + * Remove all seam and degenerated edges from \a theShape. + * Unite faces and edges, sharing one surface. + * \param theShape The compound or single solid to remove irregular edges from. + * \return Improved shape. + */ + GEOM_Object RemoveExtraEdges (in GEOM_Object theShape); + + /*! + * Check, if the given shape is a blocks compound. + * Fix all detected errors. + * \note Single block can be also fixed by this method. + * \param theCompound The compound to check and improve. + * \return Improved compound. + */ + GEOM_Object CheckAndImprove (in GEOM_Object theCompound); + /*! * Get all the blocks, contained in the given compound. * \param theCompound The compound to explode. @@ -1137,6 +1249,20 @@ module GEOM in long theDirFace1V, in long theDirFace2V, in long theNbTimesV); + + /*! + * Special operation - propagation + */ + + /*! + * Build all possible propagation groups. + * Propagation group is a set of all edges, opposite to one (main) + * edge of this group directly or through other opposite edges. + * Notion of Opposite Edge make sence only on quadrangle face. + * \param theShape Shape to build propagation groups on. + * \return List of GEOM_Objects, each of them is a propagation group. + */ + ListOfGO Propagate (in GEOM_Object theShape); }; /*! diff --git a/resources/GEOM_en.xml b/resources/GEOM_en.xml index b2e238212..18030c529 100644 --- a/resources/GEOM_en.xml +++ b/resources/GEOM_en.xml @@ -56,7 +56,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -126,6 +126,7 @@ + @@ -144,6 +145,7 @@ + @@ -165,6 +167,7 @@ + @@ -244,7 +247,7 @@ - + diff --git a/resources/GEOM_fr.xml b/resources/GEOM_fr.xml index b353c215f..f60da5386 100644 --- a/resources/GEOM_fr.xml +++ b/resources/GEOM_fr.xml @@ -62,7 +62,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -110,6 +110,13 @@ + + + + + + + @@ -119,6 +126,7 @@ + @@ -139,6 +147,7 @@ + @@ -212,7 +221,7 @@ - + diff --git a/resources/check_blocks_compound.png b/resources/check_blocks_compound.png new file mode 100644 index 000000000..8196d7e52 Binary files /dev/null and b/resources/check_blocks_compound.png differ diff --git a/resources/free_faces.png b/resources/free_faces.png new file mode 100644 index 000000000..aa13084b0 Binary files /dev/null and b/resources/free_faces.png differ diff --git a/resources/propagate.png b/resources/propagate.png new file mode 100644 index 000000000..c3ff01c59 Binary files /dev/null and b/resources/propagate.png differ diff --git a/src/BlocksGUI/BlocksGUI.cxx b/src/BlocksGUI/BlocksGUI.cxx index 39c125b28..e2707c163 100644 --- a/src/BlocksGUI/BlocksGUI.cxx +++ b/src/BlocksGUI/BlocksGUI.cxx @@ -32,6 +32,7 @@ #include "BlocksGUI_TrsfDlg.h" //#include "BlocksGUI_CheckMultiBlockDlg.h" #include "BlocksGUI_ExplodeDlg.h" +#include "BlocksGUI_PropagateDlg.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" @@ -107,6 +108,9 @@ bool BlocksGUI::OnGUIEvent( int theCommandID, QAD_Desktop* parent ) case 9995: aDlg = new BlocksGUI_ExplodeDlg (parent, Sel); break; + case 99991: + aDlg = new BlocksGUI_PropagateDlg (parent, "", Sel); + break; default: parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); diff --git a/src/BlocksGUI/BlocksGUI_PropagateDlg.cxx b/src/BlocksGUI/BlocksGUI_PropagateDlg.cxx new file mode 100644 index 000000000..2e50ec031 --- /dev/null +++ b/src/BlocksGUI/BlocksGUI_PropagateDlg.cxx @@ -0,0 +1,312 @@ +// GEOM GEOMGUI : GUI for Geometry 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 : BlocksGUI_PropagateDlg.cxx +// Author : VKN +// Module : GEOM +// $Header$ + +using namespace std; +#include "BlocksGUI_PropagateDlg.h" + +#include "QAD_Desktop.h" +#include "GEOMImpl_Types.hxx" + + +//================================================================================= +// class : BlocksGUI_PropagateDlg() +// purpose : Constructs a BlocksGUI_PropagateDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BlocksGUI_PropagateDlg::BlocksGUI_PropagateDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) + :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PROPAGATE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_PROPAGATE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_PROPAGATE_TITLE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_SELECTED_SHAPE" ), this ); + QGroupBox* aSelGrp = new QGroupBox(3, Qt::Horizontal, aMainGrp); + aSelGrp->setFrameStyle(QFrame::NoFrame); + aSelGrp->setInsideMargin(0); + + new QLabel(tr("GEOM_OBJECT"), aSelGrp); + mySelBtn = new QPushButton(aSelGrp); + mySelBtn->setPixmap(image1); + mySelName = new QLineEdit(aSelGrp); + mySelName->setReadOnly(true); + + Layout1->addWidget(aMainGrp, 1, 0); + + /***************************************************************/ + + Init(); +} + + +//================================================================================= +// function : ~BlocksGUI_PropagateDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BlocksGUI_PropagateDlg::~BlocksGUI_PropagateDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BlocksGUI_PropagateDlg::Init() +{ + /* init variables */ + + myObject = GEOM::GEOM_Object::_nil(); + ResultName->setText( "" ); + + myGeomGUI->SetState( 0 ); + + /* signals and slots connections */ + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(mySelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(mySelName, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + activateSelection(); +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : Same than click on apply but close this dialog. +//================================================================================= +void BlocksGUI_PropagateDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool BlocksGUI_PropagateDlg::ClickOnApply() +{ + if ( !onAccept() ) + return false; + + initName(); + + mySelName->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + + activateSelection(); + + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void BlocksGUI_PropagateDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection +//================================================================================= +void BlocksGUI_PropagateDlg::SelectionIntoArgument() +{ + mySelName->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + + if ( mySelection->IObjectCount() == 1 ) { + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + Standard_Boolean aRes; + myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + if ( aRes ) + mySelName->setText( GEOMBase::GetName( myObject ) ); + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BlocksGUI_PropagateDlg::SetEditCurrentArgument() +{ + const QObject* send = sender(); + if ( send == mySelBtn ) { + mySelName->setFocus(); + } + activateSelection(); +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BlocksGUI_PropagateDlg::LineEditReturnPressed() +{ + const QObject* send = sender(); + if( send == mySelName ) { + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void BlocksGUI_PropagateDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BlocksGUI_PropagateDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + + mySelName->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + + myGeomGUI->SetState( 0 ); + activateSelection(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void BlocksGUI_PropagateDlg::enterEvent(QEvent* e) +{ + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void BlocksGUI_PropagateDlg::closeEvent(QCloseEvent* e) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BlocksGUI_PropagateDlg::createOperation() +{ + return getGeomEngine()->GetIBlocksOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BlocksGUI_PropagateDlg::isValid( QString& msg ) +{ + return !myObject->_is_nil() ; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BlocksGUI_PropagateDlg::execute( ObjectList& objects ) +{ + + GEOM::ListOfGO_var aList = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->Propagate( myObject ); + ResultName->setText( "" ); + + if ( !aList->length() ) + return false; + + for ( int i = 0, n = aList->length(); i < n; i++ ) + { + objects.push_back(aList[i]._retn()); + } + + return objects.size() ? true : false; +} + +//================================================================================= +// function : activateSelection +// purpose : Activate selection +//================================================================================= +void BlocksGUI_PropagateDlg::activateSelection() +{ + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_SOLID ); + aMap.Add( GEOM_COMPOUND ); + globalSelection( aMap ); + if (myObject->_is_nil()) { + SelectionIntoArgument(); + } + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} + +//================================================================ +// Function : getFather +// Purpose : Get father object for object to be added in study +// ( called with addInStudy method ) +//================================================================ +GEOM::GEOM_Object_ptr BlocksGUI_PropagateDlg::getFather (GEOM::GEOM_Object_ptr) +{ + return myObject; +} + diff --git a/src/BlocksGUI/BlocksGUI_PropagateDlg.h b/src/BlocksGUI/BlocksGUI_PropagateDlg.h new file mode 100644 index 000000000..230db75d2 --- /dev/null +++ b/src/BlocksGUI/BlocksGUI_PropagateDlg.h @@ -0,0 +1,80 @@ +// GEOM GEOMGUI : GUI for Geometry 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 : BlocksGUI_PropagateDlg.h +// Author : VKN +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_BlocksGUI_PropagateDlg_H +#define DIALOGBOX_BlocksGUI_PropagateDlg_H + +#include "GEOMBase_Skeleton.h" + + +//================================================================================= +// class : BlocksGUI_PropagateDlg +// purpose : +//================================================================================= +class BlocksGUI_PropagateDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BlocksGUI_PropagateDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BlocksGUI_PropagateDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + virtual GEOM::GEOM_Object_ptr getFather(GEOM::GEOM_Object_ptr theObj); + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + + void ActivateThisDialog(); + void DeactivateActiveDialog(); + + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + +private : + void Init(); + void enterEvent(QEvent* e); + void closeEvent(QCloseEvent* e); + void activateSelection(); + +private : + + GEOM::GEOM_Object_var myObject; + QPushButton* mySelBtn; + QLineEdit* mySelName; + +}; + +#endif // DIALOGBOX_BlocksGUI_PropagateDlg_H diff --git a/src/BlocksGUI/Makefile.in b/src/BlocksGUI/Makefile.in index e36dd5fe8..46fda7cb1 100644 --- a/src/BlocksGUI/Makefile.in +++ b/src/BlocksGUI/Makefile.in @@ -44,12 +44,14 @@ LIB_SRC = \ BlocksGUI_QuadFaceDlg.cxx \ BlocksGUI_BlockDlg.cxx \ BlocksGUI_ExplodeDlg.cxx \ + BlocksGUI_PropagateDlg.cxx \ BlocksGUI_TrsfDlg.cxx LIB_MOC = \ BlocksGUI_QuadFaceDlg.h \ BlocksGUI_BlockDlg.h \ BlocksGUI_ExplodeDlg.h \ + BlocksGUI_PropagateDlg.h \ BlocksGUI_TrsfDlg.h LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl diff --git a/src/GEOMAlgo/BlockFix.cdl b/src/GEOMAlgo/BlockFix.cdl new file mode 100644 index 000000000..f8bfaa2a0 --- /dev/null +++ b/src/GEOMAlgo/BlockFix.cdl @@ -0,0 +1,50 @@ +-- File: BlockFix.cdl +-- Created: Tue Dec 7 11:59:05 2004 +-- Author: Pavel Durandin +-- +---Copyright: Open CASCADE SA 2004 + + + + +package BlockFix + +uses + + TColStd, + gp, + Geom, + Geom2d, + GeomAbs, + TopLoc, + TopoDS, + BRepTools, + TopTools, + ShapeBuild + +is + + class SphereSpaceModifier; + + class UnionFaces; + + class UnionEdges; + + class BlockFixAPI; + ---Purpose: API class to perform the fixing of the + -- block + + class PeriodicSurfaceModifier; + + class CheckTool; + + RotateSphereSpace (S: Shape from TopoDS; Tol: Real) + returns Shape from TopoDS; + + FixRanges (S: Shape from TopoDS; Tol: Real) + returns Shape from TopoDS; + ---Purpose: checking and fixing cases where parametric + -- boundaries of face based on periodic surface are not + -- contained in the range of this surface. + +end BlockFix; diff --git a/src/GEOMAlgo/BlockFix.cxx b/src/GEOMAlgo/BlockFix.cxx new file mode 100644 index 000000000..be4d48f62 --- /dev/null +++ b/src/GEOMAlgo/BlockFix.cxx @@ -0,0 +1,196 @@ +// File: BlockFix.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN +// Copyright: Open CASCADE SA 2004 + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + + +//======================================================================= +//function : FixResult +//purpose : auxilary +//======================================================================= +static void FixResult(const TopoDS_Shape& result, + Handle(ShapeBuild_ReShape)& Context, + const Standard_Real Tol) +{ + for (TopExp_Explorer ex_f(result,TopAbs_FACE); ex_f.More(); ex_f.Next()) { + TopoDS_Shape aShape = Context->Apply(ex_f.Current().Oriented(TopAbs_FORWARD)); + // face coud not be dropped or splitted on this step + TopoDS_Face aFace = TopoDS::Face(aShape); + TopLoc_Location L; + Handle(Geom_Surface) Surf = BRep_Tool::Surface(aFace,L); + + if (Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || + Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { + + Standard_Integer nbWires = 0; + for (TopExp_Explorer ex_w(aFace,TopAbs_WIRE); ex_w.More(); ex_w.Next()) { + nbWires++; + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(ex_w.Current()), + aFace, + Precision::Confusion()); + sfw->FixReorder(); + if(sfw->StatusReorder ( ShapeExtend_FAIL )) + continue; + + sfw->SetPrecision(2.*Tol); + sfw->FixShifted(); + + Standard_Boolean isDone = sfw->LastFixStatus ( ShapeExtend_DONE ); + isDone |= sfw->FixDegenerated(); + + // remove degenerated edges from not degenerated points + ShapeAnalysis_Edge sae; + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + Standard_Integer i; + for( i = 1; i<=sewd->NbEdges();i++) { + TopoDS_Edge E = sewd->Edge(i); + if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aFace)) { + sewd->Remove(i); + isDone = Standard_True; + i--; + } + } + + isDone |= sfw->FixLacking(); + + // remove neighbour seam edges + if(isDone) { + for( i = 1; iNbEdges();i++) { + if(sewd->IsSeam(i) && sewd->IsSeam(i+1)) { + isDone = Standard_True; + sewd->Remove(i); + sewd->Remove(i); + i--; + } + } + if(sewd->IsSeam(1) && sewd->IsSeam(sewd->NbEdges())) { + sewd->Remove(1); + sewd->Remove(sewd->NbEdges()); + } + } + + + if(isDone) { + TopoDS_Wire ResWire = sfw->Wire(); + Context->Replace(ex_w.Current(), ResWire); + }; + } + // Implement fix orientation in case of several wires + if(nbWires > 1) { + TopoDS_Face aFixedFace = TopoDS::Face(Context->Apply(aFace)); + Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFixedFace); + if(sff->FixOrientation()) + Context->Replace(aFixedFace,sff->Face()); + } + + } + } +} + + + + + +//======================================================================= +//function : ConvertToAnalytical +//purpose : +//======================================================================= + +TopoDS_Shape BlockFix::RotateSphereSpace (const TopoDS_Shape& S, + const Standard_Real Tol) +{ + + // Create a modification description + Handle(BlockFix_SphereSpaceModifier) SR = new BlockFix_SphereSpaceModifier; + SR->SetTolerance(Tol); + + TopTools_DataMapOfShapeShape context; + BRepTools_Modifier MD; + TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); + + Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; + FixResult(result,RS,Tol); + result = RS->Apply(result); + + ShapeFix_Edge sfe; + for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + } + + ShapeFix::SameParameter(result,Standard_False); + return result; +} + + +//======================================================================= +//function : FixRanges +//purpose : +//======================================================================= + +TopoDS_Shape BlockFix::FixRanges (const TopoDS_Shape& S, + const Standard_Real Tol) +{ + // Create a modification description + Handle(BlockFix_PeriodicSurfaceModifier) SR = new BlockFix_PeriodicSurfaceModifier; + SR->SetTolerance(Tol); + + TopTools_DataMapOfShapeShape context; + BRepTools_Modifier MD; + TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); + + Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; + FixResult(result,RS,Tol); + result = RS->Apply(result); + + ShapeFix_Edge sfe; + for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + } + + ShapeFix::SameParameter(result,Standard_False); + + return result; +} diff --git a/src/GEOMAlgo/BlockFix.hxx b/src/GEOMAlgo/BlockFix.hxx new file mode 100644 index 000000000..c85590ef6 --- /dev/null +++ b/src/GEOMAlgo/BlockFix.hxx @@ -0,0 +1,105 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_HeaderFile +#define _BlockFix_HeaderFile + +#ifndef _Standard_Real_HeaderFile +#include +#endif +class TopoDS_Shape; +class BlockFix_SphereSpaceModifier; +class BlockFix_UnionFaces; +class BlockFix_UnionEdges; +class BlockFix_BlockFixAPI; +class BlockFix_PeriodicSurfaceModifier; +class BlockFix_CheckTool; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class BlockFix { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT static TopoDS_Shape RotateSphereSpace(const TopoDS_Shape& S,const Standard_Real Tol) ; +Standard_EXPORT static TopoDS_Shape FixRanges(const TopoDS_Shape& S,const Standard_Real Tol) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + +friend class BlockFix_SphereSpaceModifier; +friend class BlockFix_UnionFaces; +friend class BlockFix_UnionEdges; +friend class BlockFix_BlockFixAPI; +friend class BlockFix_PeriodicSurfaceModifier; +friend class BlockFix_CheckTool; + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/BlockFix.ixx b/src/GEOMAlgo/BlockFix.ixx new file mode 100644 index 000000000..ad18c4bfa --- /dev/null +++ b/src/GEOMAlgo/BlockFix.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/BlockFix.jxx b/src/GEOMAlgo/BlockFix.jxx new file mode 100644 index 000000000..649432a98 --- /dev/null +++ b/src/GEOMAlgo/BlockFix.jxx @@ -0,0 +1,6 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl b/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl new file mode 100644 index 000000000..b5cfa0e45 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl @@ -0,0 +1,48 @@ +-- File: BlockFix_BlockFixAPI.cdl +-- Created: Tue Dec 7 17:56:09 2004 +-- Author: Pavel Durandin +-- +---Copyright: Open CASCADE SA 2004 + +class BlockFixAPI from BlockFix inherits TShared from MMgt + + ---Purpose: + +uses + + Shape from TopoDS, + ReShape from ShapeBuild + +is + Create returns BlockFixAPI from BlockFix; + ---Purpose: Empty constructor + + SetShape(me: mutable; Shape: Shape from TopoDS); + ---Purpose: Sets the shape to be operated on + ---C++: inline + + Perform(me: mutable); + ---Purpose: + + Shape(me) returns Shape from TopoDS; + ---Purpose: Returns resulting shape. + ---C++: inline + + Context(me:mutable) returns ReShape from ShapeBuild; + ---Purpose: Returns modifiable context for storing the + -- mofifications + ---C++: inline + ---C++: return & + + Tolerance (me:mutable) returns Real; + ---Purpose: Returns modifiable tolerance of recognition + ---C++: inline + ---C++: return & + +fields + + myContext : ReShape from ShapeBuild; + myShape : Shape from TopoDS; + myTolerance : Real from Standard; + +end BlockFixAPI from BlockFix; diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx new file mode 100644 index 000000000..444ddd693 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx @@ -0,0 +1,48 @@ +// File: BlockFix_BlockFixAPI.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN +// Copyright: Open CASCADE SA 2004 + + +#include +#include +#include +#include +#include + +//======================================================================= +//function : ShapeConvert_CanonicAPI +//purpose : +//======================================================================= + +BlockFix_BlockFixAPI::BlockFix_BlockFixAPI() +{ + myTolerance = Precision::Confusion(); +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +void BlockFix_BlockFixAPI::Perform() +{ + + // processing spheres with degenerativities + TopoDS_Shape aShape = Shape(); + myShape = BlockFix::RotateSphereSpace(aShape,myTolerance); + + // faces unification + BlockFix_UnionFaces aFaceUnifier; + aFaceUnifier.GetTolerance() = myTolerance; + TopoDS_Shape aResult; + aResult = aFaceUnifier.Perform(myShape); + + + BlockFix_UnionEdges anEdgeUnifier; + myShape = anEdgeUnifier.Perform(aResult,myTolerance); + + TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance); + myShape = aRes; + +} diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx new file mode 100644 index 000000000..9eb2198db --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx @@ -0,0 +1,118 @@ +// File generated by CPPExt (Transient) +// +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_BlockFixAPI_HeaderFile +#define _BlockFix_BlockFixAPI_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile +#include +#endif + +#ifndef _Handle_ShapeBuild_ReShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _MMgt_TShared_HeaderFile +#include +#endif +class ShapeBuild_ReShape; +class TopoDS_Shape; + + +class BlockFix_BlockFixAPI : public MMgt_TShared { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT BlockFix_BlockFixAPI(); + void SetShape(const TopoDS_Shape& Shape) ; +Standard_EXPORT void Perform() ; + TopoDS_Shape Shape() const; + Handle_ShapeBuild_ReShape& Context() ; + Standard_Real& Tolerance() ; +Standard_EXPORT ~BlockFix_BlockFixAPI(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& BlockFix_BlockFixAPI_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Handle_ShapeBuild_ReShape myContext; +TopoDS_Shape myShape; +Standard_Real myTolerance; + + +}; + + +#include + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx b/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx new file mode 100644 index 000000000..4fc77f490 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx @@ -0,0 +1,76 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +BlockFix_BlockFixAPI::~BlockFix_BlockFixAPI() {} + + + +Standard_EXPORT Handle_Standard_Type& BlockFix_BlockFixAPI_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("BlockFix_BlockFixAPI", + sizeof(BlockFix_BlockFixAPI), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(BlockFix_BlockFixAPI) Handle(BlockFix_BlockFixAPI)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(BlockFix_BlockFixAPI) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(BlockFix_BlockFixAPI))) { + _anOtherObject = Handle(BlockFix_BlockFixAPI)((Handle(BlockFix_BlockFixAPI)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& BlockFix_BlockFixAPI::DynamicType() const +{ + return STANDARD_TYPE(BlockFix_BlockFixAPI) ; +} +Standard_Boolean BlockFix_BlockFixAPI::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(BlockFix_BlockFixAPI) == AType || MMgt_TShared::IsKind(AType)); +} +Handle_BlockFix_BlockFixAPI::~Handle_BlockFix_BlockFixAPI() {} + diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx new file mode 100644 index 000000000..a02004dd5 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx @@ -0,0 +1,9 @@ +#ifndef _ShapeBuild_ReShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_BlockFixAPI_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx new file mode 100644 index 000000000..f3de13aef --- /dev/null +++ b/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx @@ -0,0 +1,42 @@ +#include + +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + +inline void BlockFix_BlockFixAPI::SetShape(const TopoDS_Shape& Shape) +{ + myShape = Shape; +} + +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + +inline TopoDS_Shape BlockFix_BlockFixAPI::Shape() const +{ + return myShape; +} + +//======================================================================= +//function : Context +//purpose : +//======================================================================= + +inline Handle(ShapeBuild_ReShape)& BlockFix_BlockFixAPI::Context() +{ + return myContext; +} + +//======================================================================= +//function : Tolerance +//purpose : +//======================================================================= + +inline Standard_Real& BlockFix_BlockFixAPI::Tolerance() +{ + return myTolerance; +} + diff --git a/src/GEOMAlgo/BlockFix_CheckTool.cdl b/src/GEOMAlgo/BlockFix_CheckTool.cdl new file mode 100644 index 000000000..959ada723 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_CheckTool.cdl @@ -0,0 +1,46 @@ +-- File: BlockFix_CheckTool.cdl +-- Created: Fri Dec 17 10:36:58 2004 +-- Author: Sergey KUUL +-- +---Copyright: Open CASCADE SA 2004 + +class CheckTool from BlockFix + + ---Purpose: + +uses + + Shape from TopoDS, + SequenceOfShape from TopTools + +is + + Create returns CheckTool from BlockFix; + ---Purpose: Empty constructor + + SetShape(me: in out; aShape: Shape from TopoDS); + + Perform(me: in out); + ---Purpose: + + NbPossibleBlocks(me) returns Integer; + + PossibleBlock(me; num: Integer) returns Shape from TopoDS; + + DumpCheckResult(me; S : in out OStream); + ---Purpose: Dumps results of checking + + +fields + + myShape : Shape from TopoDS; + myHasCheck : Boolean; + myNbSolids : Integer; + myNbBlocks : Integer; + myPossibleBlocks : SequenceOfShape from TopTools; + myNbUF : Integer; + myNbUE : Integer; + myNbUFUE : Integer; + myBadRanges : Integer; + +end CheckTool; diff --git a/src/GEOMAlgo/BlockFix_CheckTool.cxx b/src/GEOMAlgo/BlockFix_CheckTool.cxx new file mode 100644 index 000000000..ba902ba5a --- /dev/null +++ b/src/GEOMAlgo/BlockFix_CheckTool.cxx @@ -0,0 +1,224 @@ +// File: BlockFix_CheckTool.cxx +// Created: 17.12.04 11:15:25 +// Author: Sergey KUUL +// Copyright: Open CASCADE SA 2004 + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : BlockFix_CheckTool() +//purpose : Constructor +//======================================================================= + +BlockFix_CheckTool::BlockFix_CheckTool( ) +{ + myHasCheck = Standard_False; + myPossibleBlocks.Clear(); +} + + +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= + +void BlockFix_CheckTool::SetShape(const TopoDS_Shape& aShape) +{ + myHasCheck = Standard_False; + myShape = aShape; + myPossibleBlocks.Clear(); +} + + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +void BlockFix_CheckTool::Perform() +{ + myNbSolids=0; + myNbBlocks=0; + myNbUF=0; + myNbUE=0; + myNbUFUE=0; + TopExp_Explorer exps; + for(exps.Init(myShape, TopAbs_SOLID); exps.More(); exps.Next()) { + TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + myNbSolids++; + Standard_Boolean IsBlock=Standard_True; + Standard_Boolean MayBeUF=Standard_False; + Standard_Boolean MayBeUE=Standard_False; + Standard_Integer nf=0; + TopExp_Explorer expf; + for(expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) nf++; + + if(nf<6) { + IsBlock=Standard_False; + } + else if(nf>6) { + IsBlock=Standard_False; + // check faces unification + TopTools_SequenceOfShape faces; + for( expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { + TopoDS_Face aFace = TopoDS::Face(expf.Current()); + faces.Append(aFace); + } + Standard_Boolean HasFacesForUnification = Standard_False; + for(Standard_Integer i=1; i12) { + IsBlock=Standard_False; + // check edges unification + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + for(expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { + TopoDS_Face aFace = TopoDS::Face(expf.Current()); + TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; + for(expe.Init(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { + TopoDS_Edge edge = TopoDS::Edge(expe.Current()); + if(!aMapEdgeFaces.Contains(edge)) continue; + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter(aList); + for( ; anIter.More(); anIter.Next()) { + TopoDS_Face face = TopoDS::Face(anIter.Value()); + if(face.IsSame(aFace)) continue; + if(aMapFacesEdges.Contains(face)) { + aMapFacesEdges.ChangeFromKey(face).Append(edge); + } + else { + TopTools_ListOfShape ListEdges; + ListEdges.Append(edge); + aMapFacesEdges.Add(face,ListEdges); + } + } + } + Standard_Integer i = 1; + for (; i <= aMapFacesEdges.Extent(); i++) { + const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); + if (ListEdges.Extent() > 1) break; + } + if (i <= aMapFacesEdges.Extent()) { + MayBeUE = Standard_True; + break; + } + } + } + + if(IsBlock) + myNbBlocks++; + else { + if(MayBeUF) { + myPossibleBlocks.Append(aSolid); + if(MayBeUE) + myNbUFUE++; + else + myNbUF++; + } + else if(MayBeUE) { + myNbUE++; + myPossibleBlocks.Append(aSolid); + } + } + + } + + myHasCheck = Standard_True; +} + + +//======================================================================= +//function : NbPossibleBlocks +//purpose : +//======================================================================= + +Standard_Integer BlockFix_CheckTool::NbPossibleBlocks() const +{ + return myPossibleBlocks.Length(); +} + + +//======================================================================= +//function : PossibleBlock +//purpose : +//======================================================================= + +TopoDS_Shape BlockFix_CheckTool::PossibleBlock(const Standard_Integer num) const +{ + TopoDS_Shape res; + if( num>0 && num<=myPossibleBlocks.Length() ) + res = myPossibleBlocks.Value(num); + return res; +} + + +//======================================================================= +//function : DumpCheckResult +//purpose : +//======================================================================= + +void BlockFix_CheckTool::DumpCheckResult(Standard_OStream& S) const +{ + if(!myHasCheck) + S<<"Check not performed!"< +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _TopTools_SequenceOfShape_HeaderFile +#include +#endif +#ifndef _Standard_OStream_HeaderFile +#include +#endif +class TopoDS_Shape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class BlockFix_CheckTool { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT BlockFix_CheckTool(); +Standard_EXPORT void SetShape(const TopoDS_Shape& aShape) ; +Standard_EXPORT void Perform() ; +Standard_EXPORT Standard_Integer NbPossibleBlocks() const; +Standard_EXPORT TopoDS_Shape PossibleBlock(const Standard_Integer num) const; +Standard_EXPORT void DumpCheckResult(Standard_OStream& S) const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +TopoDS_Shape myShape; +Standard_Boolean myHasCheck; +Standard_Integer myNbSolids; +Standard_Integer myNbBlocks; +TopTools_SequenceOfShape myPossibleBlocks; +Standard_Integer myNbUF; +Standard_Integer myNbUE; +Standard_Integer myNbUFUE; +Standard_Integer myBadRanges; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/BlockFix_CheckTool.ixx b/src/GEOMAlgo/BlockFix_CheckTool.ixx new file mode 100644 index 000000000..1b3f08c4b --- /dev/null +++ b/src/GEOMAlgo/BlockFix_CheckTool.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/BlockFix_CheckTool.jxx b/src/GEOMAlgo/BlockFix_CheckTool.jxx new file mode 100644 index 000000000..ed3116843 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_CheckTool.jxx @@ -0,0 +1,6 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_CheckTool_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl new file mode 100644 index 000000000..63598cfe9 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl @@ -0,0 +1,115 @@ +-- File: BlockFix_PeriodicSurfaceModifier.cdl +-- Created: Wed Dec 15 10:03:50 2004 +-- Author: Sergey KUUL +-- +---Copyright: Open CASCADE SA 2004 + +class PeriodicSurfaceModifier from BlockFix inherits Modification from BRepTools + + ---Purpose: + +uses + Vertex from TopoDS, + Edge from TopoDS, + Face from TopoDS, + Location from TopLoc, + Shape from GeomAbs, + Pnt from gp, + Curve from Geom, + Curve from Geom2d, + Surface from Geom, + IndexedMapOfTransient from TColStd, + DataMapOfShapeInteger from TopTools + +is + + Create returns mutable PeriodicSurfaceModifier from BlockFix; + + SetTolerance(me: mutable; Toler: Real); + ---Purpose: Sets the tolerance for recognition of geometry + + NewSurface(me: mutable; F : Face from TopoDS; + S : out Surface from Geom; + L : out Location from TopLoc; + Tol: out Real from Standard; + RevWires : out Boolean from Standard; + RevFace : out Boolean from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the face has been + -- modified. In this case, is the new geometric + -- support of the face, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , are not + -- significant. + + NewCurve(me: mutable; E : Edge from TopoDS; + C : out Curve from Geom; + L : out Location from TopLoc; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the edge has been + -- modified. In this case, is the new geometric + -- support of the edge, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , are not + -- significant. + + NewPoint(me: mutable; V : Vertex from TopoDS; + P : out Pnt from gp; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the vertex has been + -- modified. In this case,

is the new geometric + -- support of the vertex, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- are not significant. + + NewCurve2d(me: mutable; E : Edge from TopoDS; + F : Face from TopoDS; + NewE : Edge from TopoDS; + NewF : Face from TopoDS; + C : out Curve from Geom2d; + Tol : out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the edge has a new + -- curve on surface on the face .In this case, + -- is the new geometric support of the edge, the + -- new location, the new tolerance. + -- + -- Otherwise, returns Standard_False, and , , + -- are not significant. + -- + -- is the new edge created from . + -- is the new face created from . They may be usefull. + + NewParameter(me: mutable; V : Vertex from TopoDS; + E : Edge from TopoDS; + P : out Real from Standard; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the Vertex has a new + -- parameter on the edge . In this case,

is + -- the parameter, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- are not significant. + + Continuity(me: mutable; E : Edge from TopoDS; + F1,F2 : Face from TopoDS; + NewE : Edge from TopoDS; + NewF1,NewF2: Face from TopoDS) + returns Shape from GeomAbs; + ---Purpose: Returns the continuity of between + -- and . + -- + -- is the new edge created from . + -- (resp. ) is the new face created from + -- (resp. ). + + +fields + + myTolerance : Real; + myMapOfFaces : DataMapOfShapeInteger from TopTools; + myMapOfSurfaces: IndexedMapOfTransient from TColStd; + +end PeriodicSurfaceModifier; diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx new file mode 100644 index 000000000..9ca792fed --- /dev/null +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx @@ -0,0 +1,230 @@ +// File: BlockFix_PeriodicSurfaceModifier.cxx +// Created: 15.12.04 10:08:50 +// Author: Sergey KUUL +// Copyright: Open CASCADE SA 2004 + +#include + +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : BlockFix_PeriodicSurfaceModifier() +//purpose : Constructor +//======================================================================= + +BlockFix_PeriodicSurfaceModifier::BlockFix_PeriodicSurfaceModifier ( ) +{ + myMapOfFaces.Clear(); + myMapOfSurfaces.Clear(); +} + + +//======================================================================= +//function : SetTolerance +//purpose : +//======================================================================= + +void BlockFix_PeriodicSurfaceModifier::SetTolerance(const Standard_Real Tol) +{ + myTolerance = Tol; +} + + +//======================================================================= +//function : ModifySurface +//purpose : auxilary +//======================================================================= + +static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, + const Handle(Geom_Surface)& aSurface, + Handle(Geom_Surface)& aNewSurface) +{ + Handle(Geom_Surface) S = aSurface; + + if(S->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { + Handle(Geom_CylindricalSurface) aCyl = + Handle(Geom_CylindricalSurface)::DownCast(S); + Standard_Real Umin, Umax, Vmin, Vmax; + BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); + if( Umin<-Precision::PConfusion() || Umax>2*PI+Precision::PConfusion() ) { + gp_Ax3 ax3 = aCyl->Position(); + gp_Ax1 NDir = ax3.Axis(); + gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion()); + Handle(Geom_CylindricalSurface) aNewCyl = + new Geom_CylindricalSurface(newax3,aCyl->Radius()); + aNewSurface = aNewCyl; + return Standard_True; + } + } + + if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { + Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); + Standard_Real Umin, Umax, Vmin, Vmax; + BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); + if( Umin<-Precision::PConfusion() || Umax>2*PI+Precision::PConfusion() ) { + gp_Ax3 ax3 = aSphere->Position(); + gp_Ax1 NDir = ax3.Axis(); + gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion()); + Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(newax3,aSphere->Radius()); + aNewSurface = aNewSphere; + return Standard_True; + } + } + + return Standard_False; +} + + +//======================================================================= +//function : NewSurface +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewSurface(const TopoDS_Face& F, + Handle(Geom_Surface)& S, + TopLoc_Location& L,Standard_Real& Tol, + Standard_Boolean& RevWires, + Standard_Boolean& RevFace) +{ + TopLoc_Location LS; + Handle(Geom_Surface) SIni = BRep_Tool::Surface(F, LS); + + if(ModifySurface(F, SIni, S)) { + + RevWires = Standard_False; + RevFace = Standard_False; + + L = LS; + Tol = BRep_Tool::Tolerance(F); + + Standard_Integer anIndex = myMapOfSurfaces.Add(S); + myMapOfFaces.Bind(F,anIndex); + return Standard_True; + } + + return Standard_False; +} + + +//======================================================================= +//function : NewCurve +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewCurve(const TopoDS_Edge& /*E*/, + Handle(Geom_Curve)& /*C*/, + TopLoc_Location& /*L*/, + Standard_Real& /*Tol*/) +{ + return Standard_False; +} + + +//======================================================================= +//function : NewPoint +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewPoint(const TopoDS_Vertex& /*V*/, + gp_Pnt& /*P*/, + Standard_Real& /*Tol*/) +{ + return Standard_False; +} + + +//======================================================================= +//function : NewCurve2d +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewCurve2d(const TopoDS_Edge& E, + const TopoDS_Face& F, + const TopoDS_Edge& /*NewE*/, + const TopoDS_Face& /*NewF*/, + Handle(Geom2d_Curve)& C, + Standard_Real& Tol) +{ + //check if undelying surface of the face was modified + if(myMapOfFaces.IsBound(F)) { + Standard_Integer anIndex = myMapOfFaces.Find(F); + + Handle(Geom_Surface) aNewSurf = Handle(Geom_Surface)::DownCast(myMapOfSurfaces.FindKey(anIndex)); + + Standard_Real f,l; + TopLoc_Location LC, LS; + Handle(Geom_Curve) C3d = BRep_Tool::Curve ( E, LC, f, l ); + Handle(Geom_Surface) S = BRep_Tool::Surface(F, LS); + + //taking into accound the orientation of the seam + C = BRep_Tool::CurveOnSurface(E,F,f,l); + Tol = BRep_Tool::Tolerance(E); + + BRep_Builder B; + TopoDS_Edge TempE; + B.MakeEdge(TempE); + B.Add(TempE, TopExp::FirstVertex(E)); + B.Add(TempE, TopExp::LastVertex(E)); + + if(!C3d.IsNull()) + B.UpdateEdge(TempE, Handle(Geom_Curve)::DownCast(C3d->Transformed(LC.Transformation())), Precision::Confusion()); + B.Range(TempE, f, l); + + Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge; + Handle(Geom_Surface) STemp = Handle(Geom_Surface)::DownCast(aNewSurf->Transformed(LS.Transformation())); + TopLoc_Location LTemp; + LTemp.Identity(); + + Standard_Boolean isClosed = BRep_Tool::IsClosed (E, F); + Standard_Real aWorkTol = 2*myTolerance+Tol; + sfe->FixAddPCurve(TempE, STemp, LTemp, isClosed, Max(Precision::Confusion(), aWorkTol)); + sfe->FixSameParameter(TempE); + + //keep the orientation of original edge + TempE.Orientation(E.Orientation()); + C = BRep_Tool::CurveOnSurface(TempE, STemp, LTemp, f, l); + + //surface was modified + return Standard_True; + } + + return Standard_False; +} + + +//======================================================================= +//function : NewParameter +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewParameter(const TopoDS_Vertex& /*V*/, + const TopoDS_Edge& /*E*/, + Standard_Real& /*P*/, + Standard_Real& /*Tol*/) +{ + return Standard_False; +} + + +//======================================================================= +//function : Continuity +//purpose : +//======================================================================= + +GeomAbs_Shape BlockFix_PeriodicSurfaceModifier::Continuity(const TopoDS_Edge& E, + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const TopoDS_Edge& /*NewE*/, + const TopoDS_Face& /*NewF1*/, + const TopoDS_Face& /*NewF2*/) +{ + return BRep_Tool::Continuity(E,F1,F2); +} + diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx new file mode 100644 index 000000000..b55096ce9 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx @@ -0,0 +1,140 @@ +// File generated by CPPExt (Transient) +// +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile +#define _BlockFix_PeriodicSurfaceModifier_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile +#include +#endif + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TColStd_IndexedMapOfTransient_HeaderFile +#include +#endif +#ifndef _BRepTools_Modification_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Surface_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Curve_HeaderFile +#include +#endif +#ifndef _Handle_Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _GeomAbs_Shape_HeaderFile +#include +#endif +class TopoDS_Face; +class Geom_Surface; +class TopLoc_Location; +class TopoDS_Edge; +class Geom_Curve; +class TopoDS_Vertex; +class gp_Pnt; +class Geom2d_Curve; + + +class BlockFix_PeriodicSurfaceModifier : public BRepTools_Modification { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT BlockFix_PeriodicSurfaceModifier(); +Standard_EXPORT void SetTolerance(const Standard_Real Toler) ; +Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,Handle(Geom_Surface)& S,TopLoc_Location& L,Standard_Real& Tol,Standard_Boolean& RevWires,Standard_Boolean& RevFace) ; +Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,Handle(Geom_Curve)& C,TopLoc_Location& L,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,gp_Pnt& P,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& NewE,const TopoDS_Face& NewF,Handle(Geom2d_Curve)& C,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,const TopoDS_Edge& E,Standard_Real& P,Standard_Real& Tol) ; +Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const TopoDS_Edge& NewE,const TopoDS_Face& NewF1,const TopoDS_Face& NewF2) ; +Standard_EXPORT ~BlockFix_PeriodicSurfaceModifier(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& BlockFix_PeriodicSurfaceModifier_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Real myTolerance; +TopTools_DataMapOfShapeInteger myMapOfFaces; +TColStd_IndexedMapOfTransient myMapOfSurfaces; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx new file mode 100644 index 000000000..7bdcfb449 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx @@ -0,0 +1,78 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +BlockFix_PeriodicSurfaceModifier::~BlockFix_PeriodicSurfaceModifier() {} + + + +Standard_EXPORT Handle_Standard_Type& BlockFix_PeriodicSurfaceModifier_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(BRepTools_Modification); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(BRepTools_Modification); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("BlockFix_PeriodicSurfaceModifier", + sizeof(BlockFix_PeriodicSurfaceModifier), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(BlockFix_PeriodicSurfaceModifier) Handle(BlockFix_PeriodicSurfaceModifier)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(BlockFix_PeriodicSurfaceModifier) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier))) { + _anOtherObject = Handle(BlockFix_PeriodicSurfaceModifier)((Handle(BlockFix_PeriodicSurfaceModifier)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& BlockFix_PeriodicSurfaceModifier::DynamicType() const +{ + return STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier) ; +} +Standard_Boolean BlockFix_PeriodicSurfaceModifier::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier) == AType || BRepTools_Modification::IsKind(AType)); +} +Handle_BlockFix_PeriodicSurfaceModifier::~Handle_BlockFix_PeriodicSurfaceModifier() {} + diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx new file mode 100644 index 000000000..0a556d598 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx @@ -0,0 +1,27 @@ +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _Geom_Surface_HeaderFile +#include +#endif +#ifndef _TopLoc_Location_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _Geom_Curve_HeaderFile +#include +#endif +#ifndef _TopoDS_Vertex_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl new file mode 100644 index 000000000..eae4b8a7a --- /dev/null +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl @@ -0,0 +1,120 @@ +-- File: BlockFix_SphereSpaceModifier.cdl +-- Created: Tue Dec 7 12:01:49 2004 +-- Author: Pavel Durandin +-- +---Copyright: Open CASCADE SA 2004 + + +class SphereSpaceModifier from BlockFix inherits Modification from BRepTools + + ---Purpose: Rotation of the parametric space of the sphere in order + -- to avoid the seam and degenerared edge within it + +uses + Vertex from TopoDS, + Edge from TopoDS, + Face from TopoDS, + Location from TopLoc, + Shape from GeomAbs, + Pnt from gp, + Curve from Geom, + Curve from Geom2d, + Surface from Geom, + IndexedMapOfTransient from TColStd, + DataMapOfShapeInteger from TopTools + +is + + Create returns mutable SphereSpaceModifier from BlockFix; + + SetTolerance(me: mutable; Toler: Real); + ---Purpose: Sets the tolerance for recognition of geometry + + NewSurface(me: mutable; F : Face from TopoDS; + S : out Surface from Geom; + L : out Location from TopLoc; + Tol: out Real from Standard; + RevWires : out Boolean from Standard; + RevFace : out Boolean from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the face has been + -- modified. In this case, is the new geometric + -- support of the face, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , are not + -- significant. + + NewCurve(me: mutable; E : Edge from TopoDS; + C : out Curve from Geom; + L : out Location from TopLoc; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the edge has been + -- modified. In this case, is the new geometric + -- support of the edge, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , are not + -- significant. + + NewPoint(me: mutable; V : Vertex from TopoDS; + P : out Pnt from gp; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the vertex has been + -- modified. In this case,

is the new geometric + -- support of the vertex, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- are not significant. + + NewCurve2d(me: mutable; E : Edge from TopoDS; + F : Face from TopoDS; + NewE : Edge from TopoDS; + NewF : Face from TopoDS; + C : out Curve from Geom2d; + Tol : out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the edge has a new + -- curve on surface on the face .In this case, + -- is the new geometric support of the edge, the + -- new location, the new tolerance. + -- + -- Otherwise, returns Standard_False, and , , + -- are not significant. + -- + -- is the new edge created from . + -- is the new face created from . They may be usefull. + + NewParameter(me: mutable; V : Vertex from TopoDS; + E : Edge from TopoDS; + P : out Real from Standard; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the Vertex has a new + -- parameter on the edge . In this case,

is + -- the parameter, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- are not significant. + + Continuity(me: mutable; E : Edge from TopoDS; + F1,F2 : Face from TopoDS; + NewE : Edge from TopoDS; + NewF1,NewF2: Face from TopoDS) + returns Shape from GeomAbs; + ---Purpose: Returns the continuity of between + -- and . + -- + -- is the new edge created from . + -- (resp. ) is the new face created from + -- (resp. ). + + ForRotation(me: mutable; F: Face from TopoDS) returns Boolean; + +fields + + myTolerance : Real; + myMapOfFaces : DataMapOfShapeInteger from TopTools; + myMapOfSpheres: IndexedMapOfTransient from TColStd; + --myMapOfGeom: MapOfShapeTransient from TColStd; + +end SphereSpaceModifier; + diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx new file mode 100644 index 000000000..c5f774d82 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx @@ -0,0 +1,224 @@ +// File: BlockFix.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN +// Copyright: Open CASCADE SA 2004 + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : BlockFix_SphereSpaceModifier +//purpose : +//======================================================================= + +BlockFix_SphereSpaceModifier::BlockFix_SphereSpaceModifier() +{ + myMapOfFaces.Clear(); + myMapOfSpheres.Clear(); +} + +//======================================================================= +//function : SetTolerance +//purpose : +//======================================================================= + +void BlockFix_SphereSpaceModifier::SetTolerance(const Standard_Real Tol) +{ + myTolerance = Tol; +} + + +//======================================================================= +//function : NewSurface +//purpose : +//======================================================================= + + +static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, + const Handle(Geom_Surface)& aSurface, + Handle(Geom_Surface)& aNewSurface) +{ + Handle(Geom_Surface) S = aSurface; + if(S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + Handle(Geom_RectangularTrimmedSurface) RTS = + Handle(Geom_RectangularTrimmedSurface)::DownCast(S); + S = RTS->BasisSurface(); + } + + if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { + Standard_Real Umin, Umax, Vmin, Vmax; + ShapeAnalysis::GetFaceUVBounds(aFace,Umin, Umax, Vmin, Vmax); + Standard_Real PI2 = PI/2.; + if(Vmax > PI2 - Precision::PConfusion() || Vmin < -PI2+::Precision::PConfusion()) { + if(Abs(Vmax-Vmin) < PI2) { + Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); + gp_Sphere sp = aSphere->Sphere(); + gp_Ax3 ax3 = sp.Position(); + gp_Ax3 axnew3(ax3.Axis().Location(), ax3.Direction()^ax3.XDirection(),ax3.XDirection()); + sp.SetPosition(axnew3); + Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(sp); + aNewSurface = aNewSphere; + return Standard_True; + } + } + } + return Standard_False; +} + + +Standard_Boolean BlockFix_SphereSpaceModifier::NewSurface(const TopoDS_Face& F, + Handle(Geom_Surface)& S, + TopLoc_Location& L,Standard_Real& Tol, + Standard_Boolean& RevWires, + Standard_Boolean& RevFace) +{ + TopLoc_Location LS; + Handle(Geom_Surface) SIni = BRep_Tool::Surface(F, LS); + + //check if pole of the sphere in the parametric space + if(ModifySurface(F, SIni, S)) { + + RevWires = Standard_False; + RevFace = Standard_False; + + L = LS; + Tol = BRep_Tool::Tolerance(F); + + Standard_Integer anIndex = myMapOfSpheres.Add(S); + myMapOfFaces.Bind(F,anIndex); + return Standard_True; + } + + return Standard_False; +} + +//======================================================================= +//function : NewCurve +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_SphereSpaceModifier::NewCurve(const TopoDS_Edge& /*E*/,Handle(Geom_Curve)& /*C*/, + TopLoc_Location& /*L*/,Standard_Real& /*Tol*/) +{ + return Standard_False; +} + +//======================================================================= +//function : NewPoint +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_SphereSpaceModifier::NewPoint(const TopoDS_Vertex& /*V*/, + gp_Pnt& /*P*/, + Standard_Real& /*Tol*/) +{ + return Standard_False; +} + +//======================================================================= +//function : NewCurve2d +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_SphereSpaceModifier::NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F, + const TopoDS_Edge& /*NewE*/,const TopoDS_Face& /*NewF*/, + Handle(Geom2d_Curve)& C,Standard_Real& Tol) +{ + //check if undelying surface of the face was modified + if(myMapOfFaces.IsBound(F)) { + Standard_Integer anIndex = myMapOfFaces.Find(F); + + Handle(Geom_Surface) aNewSphere = Handle(Geom_Surface)::DownCast(myMapOfSpheres.FindKey(anIndex)); + + Standard_Real f,l; + TopLoc_Location LC, LS; + Handle(Geom_Curve) C3d = BRep_Tool::Curve ( E, LC, f, l ); + Handle(Geom_Surface) S = BRep_Tool::Surface(F, LS); + + //taking into accound the orientation of the seam + C = BRep_Tool::CurveOnSurface(E,F,f,l); + Tol = BRep_Tool::Tolerance(E); + + BRep_Builder B; + TopoDS_Edge TempE; + B.MakeEdge(TempE); + B.Add(TempE, TopExp::FirstVertex(E)); + B.Add(TempE, TopExp::LastVertex(E)); + + if(!C3d.IsNull()) + B.UpdateEdge(TempE, Handle(Geom_Curve)::DownCast(C3d->Transformed(LC.Transformation())), Precision::Confusion()); + B.Range(TempE, f, l); + + Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge; + Handle(Geom_Surface) STemp = Handle(Geom_Surface)::DownCast(aNewSphere->Transformed(LS.Transformation())); + TopLoc_Location LTemp; + LTemp.Identity(); + + Standard_Boolean isClosed = BRep_Tool::IsClosed (E, F); + Standard_Real aWorkTol = 2*myTolerance+Tol; + sfe->FixAddPCurve(TempE, STemp, LTemp, isClosed, Max(Precision::Confusion(), aWorkTol)); + sfe->FixSameParameter(TempE); + + //keep the orientation of original edge + TempE.Orientation(E.Orientation()); + C = BRep_Tool::CurveOnSurface(TempE, STemp, LTemp, f, l); + + // shifting seam of sphere + if(isClosed && !C.IsNull()) { + Standard_Real f2,l2; + Handle(Geom2d_Curve) c22 = + BRep_Tool::CurveOnSurface(TopoDS::Edge(TempE.Reversed()),STemp, LTemp,f2,l2); + Standard_Real dPreci = Precision::PConfusion()*Precision::PConfusion(); + if((C->Value(f).SquareDistance(c22->Value(f2)) < dPreci) + ||(C->Value(l).SquareDistance(c22->Value(l2)) < dPreci)) { + gp_Vec2d shift(S->UPeriod(),0.); + C->Translate(shift); + } + } + //sphere was modified + return Standard_True; + } + + return Standard_False; +} + + +//======================================================================= +//function : NewParameter +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_SphereSpaceModifier::NewParameter(const TopoDS_Vertex& /*V*/,const TopoDS_Edge& /*E*/, + Standard_Real& /*P*/,Standard_Real& /*Tol*/) +{ + return Standard_False; +} + + +//======================================================================= +//function : Continuity +//purpose : +//======================================================================= + +GeomAbs_Shape BlockFix_SphereSpaceModifier::Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1, + const TopoDS_Face& F2,const TopoDS_Edge& /*NewE*/, + const TopoDS_Face& /*NewF1*/,const TopoDS_Face& /*NewF2*/) +{ + return BRep_Tool::Continuity(E,F1,F2); +} + diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx new file mode 100644 index 000000000..463277a46 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx @@ -0,0 +1,141 @@ +// File generated by CPPExt (Transient) +// +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_SphereSpaceModifier_HeaderFile +#define _BlockFix_SphereSpaceModifier_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile +#include +#endif + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TColStd_IndexedMapOfTransient_HeaderFile +#include +#endif +#ifndef _BRepTools_Modification_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Surface_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Curve_HeaderFile +#include +#endif +#ifndef _Handle_Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _GeomAbs_Shape_HeaderFile +#include +#endif +class TopoDS_Face; +class Geom_Surface; +class TopLoc_Location; +class TopoDS_Edge; +class Geom_Curve; +class TopoDS_Vertex; +class gp_Pnt; +class Geom2d_Curve; + + +class BlockFix_SphereSpaceModifier : public BRepTools_Modification { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT BlockFix_SphereSpaceModifier(); +Standard_EXPORT void SetTolerance(const Standard_Real Toler) ; +Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,Handle(Geom_Surface)& S,TopLoc_Location& L,Standard_Real& Tol,Standard_Boolean& RevWires,Standard_Boolean& RevFace) ; +Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,Handle(Geom_Curve)& C,TopLoc_Location& L,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,gp_Pnt& P,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& NewE,const TopoDS_Face& NewF,Handle(Geom2d_Curve)& C,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,const TopoDS_Edge& E,Standard_Real& P,Standard_Real& Tol) ; +Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const TopoDS_Edge& NewE,const TopoDS_Face& NewF1,const TopoDS_Face& NewF2) ; +Standard_EXPORT Standard_Boolean ForRotation(const TopoDS_Face& F) ; +Standard_EXPORT ~BlockFix_SphereSpaceModifier(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& BlockFix_SphereSpaceModifier_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Real myTolerance; +TopTools_DataMapOfShapeInteger myMapOfFaces; +TColStd_IndexedMapOfTransient myMapOfSpheres; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx new file mode 100644 index 000000000..55b027172 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx @@ -0,0 +1,78 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +BlockFix_SphereSpaceModifier::~BlockFix_SphereSpaceModifier() {} + + + +Standard_EXPORT Handle_Standard_Type& BlockFix_SphereSpaceModifier_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(BRepTools_Modification); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(BRepTools_Modification); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("BlockFix_SphereSpaceModifier", + sizeof(BlockFix_SphereSpaceModifier), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(BlockFix_SphereSpaceModifier) Handle(BlockFix_SphereSpaceModifier)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(BlockFix_SphereSpaceModifier) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(BlockFix_SphereSpaceModifier))) { + _anOtherObject = Handle(BlockFix_SphereSpaceModifier)((Handle(BlockFix_SphereSpaceModifier)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& BlockFix_SphereSpaceModifier::DynamicType() const +{ + return STANDARD_TYPE(BlockFix_SphereSpaceModifier) ; +} +Standard_Boolean BlockFix_SphereSpaceModifier::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(BlockFix_SphereSpaceModifier) == AType || BRepTools_Modification::IsKind(AType)); +} +Handle_BlockFix_SphereSpaceModifier::~Handle_BlockFix_SphereSpaceModifier() {} + diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx new file mode 100644 index 000000000..a2a6afec0 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx @@ -0,0 +1,27 @@ +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _Geom_Surface_HeaderFile +#include +#endif +#ifndef _TopLoc_Location_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _Geom_Curve_HeaderFile +#include +#endif +#ifndef _TopoDS_Vertex_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _BlockFix_SphereSpaceModifier_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cdl b/src/GEOMAlgo/BlockFix_UnionEdges.cdl new file mode 100644 index 000000000..8a6a4b905 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionEdges.cdl @@ -0,0 +1,28 @@ +-- File: BlockFix_UnionEdges.cdl +-- Created: Tue Dec 7 15:24:51 2004 +-- Author: Sergey KUUL +-- + +class UnionEdges from BlockFix + + ---Purpose: + +uses + + Shape from TopoDS, + ReShape from ShapeBuild + +is + + Create returns UnionEdges from BlockFix; + + Perform(me: in out; Shape: Shape from TopoDS; + Tol : Real) + returns Shape from TopoDS; + +fields + + myTolerance : Real; + myContext : ReShape from ShapeBuild; + +end UnionEdges; diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cxx b/src/GEOMAlgo/BlockFix_UnionEdges.cxx new file mode 100644 index 000000000..f36e8c7e1 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionEdges.cxx @@ -0,0 +1,325 @@ +// File: BlockFix_UnionEdges.cxx +// Created: 07.12.04 15:27:30 +// Author: Sergey KUUL + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : BlockFix_UnionEdges() +//purpose : Constructor +//======================================================================= + +BlockFix_UnionEdges::BlockFix_UnionEdges ( ) +{ +} + + +//======================================================================= +//function : MergeEdges +//purpose : auxilary +//======================================================================= +static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, + const TopoDS_Face& aFace, + const Standard_Real Tol, + TopoDS_Edge& anEdge) +{ + // make chain for union + BRep_Builder B; + ShapeAnalysis_Edge sae; + TopoDS_Edge FirstE = TopoDS::Edge(SeqEdges.Value(1)); + TopoDS_Edge LastE = FirstE; + TopoDS_Vertex VF = sae.FirstVertex(FirstE); + TopoDS_Vertex VL = sae.LastVertex(LastE); + TopTools_SequenceOfShape aChain; + aChain.Append(FirstE); + TColStd_MapOfInteger IndUsedEdges; + IndUsedEdges.Add(1); + Standard_Integer j; + for (j = 2; j <= SeqEdges.Length(); j++) { + for(Standard_Integer k=2; k<=SeqEdges.Length(); k++) { + if(IndUsedEdges.Contains(k)) continue; + TopoDS_Edge edge = TopoDS::Edge(SeqEdges.Value(k)); + TopoDS_Vertex VF2 = sae.FirstVertex(edge); + TopoDS_Vertex VL2 = sae.LastVertex(edge); + if(sae.FirstVertex(edge).IsSame(VL)) { + aChain.Append(edge); + LastE = edge; + VL = sae.LastVertex(LastE); + IndUsedEdges.Add(k); + } + else if(sae.LastVertex(edge).IsSame(VF)) { + aChain.Prepend(edge); + FirstE = edge; + VF = sae.FirstVertex(FirstE); + IndUsedEdges.Add(k); + } + } + } + if(aChain.Length()IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d1); + c3d1 = tc->BasisCurve(); + } + TopoDS_Edge edge2 = TopoDS::Edge(aChain.Value(j+1)); + Handle(Geom_Curve) c3d2 = BRep_Tool::Curve(edge2,Loc,fp2,lp2); + if(c3d2.IsNull()) break; + while(c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d2); + c3d2 = tc->BasisCurve(); + } + if( c3d1->IsKind(STANDARD_TYPE(Geom_Line)) && c3d2->IsKind(STANDARD_TYPE(Geom_Line)) ) { + Handle(Geom_Line) L1 = Handle(Geom_Line)::DownCast(c3d1); + Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2); + gp_Dir Dir1 = L1->Position().Direction(); + gp_Dir Dir2 = L2->Position().Direction(); + if(!Dir1.IsEqual(Dir2,Precision::Angular())) continue; + // can union lines => create new edge + TopoDS_Vertex V1 = sae.FirstVertex(edge1); + gp_Pnt PV1 = BRep_Tool::Pnt(V1); + TopoDS_Vertex V2 = sae.LastVertex(edge2); + gp_Pnt PV2 = BRep_Tool::Pnt(V2); + gp_Vec Vec(PV1,PV2); + Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec)); + Standard_Real dist = PV1.Distance(PV2); + Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(L,0.0,dist); + TopoDS_Edge E; + B.MakeEdge (E,tc,Precision::Confusion()); + B.Add (E,V1); B.Add (E,V2); + B.UpdateVertex(V1, 0., E, 0.); + B.UpdateVertex(V2, dist, E, 0.); + ShapeFix_Edge sfe; + sfe.FixAddPCurve(E,aFace,Standard_False); + sfe.FixSameParameter(E); + aChain.Remove(j); + aChain.SetValue(j,E); + j--; + } + if( c3d1->IsKind(STANDARD_TYPE(Geom_Circle)) && c3d2->IsKind(STANDARD_TYPE(Geom_Circle)) ) { + Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(c3d1); + Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2); + gp_Pnt P01 = C1->Location(); + gp_Pnt P02 = C2->Location(); + if(P01.Distance(P02)>Precision::Confusion()) continue; + // can union circles => create new edge + TopoDS_Vertex V1 = sae.FirstVertex(edge1); + gp_Pnt PV1 = BRep_Tool::Pnt(V1); + TopoDS_Vertex V2 = sae.LastVertex(edge2); + gp_Pnt PV2 = BRep_Tool::Pnt(V2); + TopoDS_Vertex VM = sae.LastVertex(edge1); + gp_Pnt PVM = BRep_Tool::Pnt(VM); + GC_MakeCircle MC(PV1,PVM,PV2); + Handle(Geom_Circle) C = MC.Value(); + gp_Pnt P0 = C->Location(); + gp_Dir D1(gp_Vec(P0,PV1)); + gp_Dir D2(gp_Vec(P0,PV2)); + Standard_Real fpar = C->XAxis().Direction().Angle(D1); + Standard_Real lpar = C->XAxis().Direction().Angle(D2); + Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar); + TopoDS_Edge E; + B.MakeEdge (E,tc,Precision::Confusion()); + B.Add (E,V1); B.Add (E,V2); + B.UpdateVertex(V1, fpar, E, 0.); + B.UpdateVertex(V2, lpar, E, 0.); + ShapeFix_Edge sfe; + sfe.FixAddPCurve(E,aFace,Standard_False); + sfe.FixSameParameter(E); + aChain.Remove(j); + aChain.SetValue(j,E); + j--; + } + } + if(j1) { + // second step: union edges with various curves + cout<<"can not make analitical union => make approximation"<Apply(Shape); + + TopTools_IndexedMapOfShape ChangedFaces; + + // processing each solid + TopExp_Explorer exps; + for(exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) { + TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + // processing each face + TopExp_Explorer exp; + for(exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(myContext->Apply(exp.Current().Oriented(TopAbs_FORWARD))); + TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; + + for(TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { + TopoDS_Edge edge = TopoDS::Edge(expe.Current()); + if(!aMapEdgeFaces.Contains(edge)) continue; + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter(aList); + for( ; anIter.More(); anIter.Next()) { + TopoDS_Face face = TopoDS::Face(anIter.Value()); + TopoDS_Face face1 = TopoDS::Face(myContext->Apply(anIter.Value())); + if(face1.IsSame(aFace)) continue; + if(aMapFacesEdges.Contains(face)) { + aMapFacesEdges.ChangeFromKey(face).Append(edge); + } + else { + TopTools_ListOfShape ListEdges; + ListEdges.Append(edge); + aMapFacesEdges.Add(face,ListEdges); + } + } + } + + for(Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) { + const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); + TopTools_SequenceOfShape SeqEdges; + TopTools_ListIteratorOfListOfShape anIter(ListEdges); + for( ; anIter.More(); anIter.Next()) { + SeqEdges.Append(anIter.Value()); + } + if(SeqEdges.Length()==1) continue; + TopoDS_Edge E; + if( MergeEdges(SeqEdges,aFace,Tol,E) ) { + // now we have only one edge - aChain.Value(1) + // we have to replace old ListEdges with this new edge + myContext->Replace(SeqEdges(1),E); + for(Standard_Integer j=2; j<=SeqEdges.Length(); j++) { + myContext->Remove(SeqEdges(j)); + } + TopoDS_Face tmpF = TopoDS::Face(exp.Current()); + if( !ChangedFaces.Contains(tmpF) ) + ChangedFaces.Add(tmpF); + tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i)); + if( !ChangedFaces.Contains(tmpF) ) + ChangedFaces.Add(tmpF); + } + } + + } // end processing each face + + } // end processing each solid + + for(Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) { + TopoDS_Face aFace = TopoDS::Face(myContext->Apply(ChangedFaces.FindKey(i))); + Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace); + sff->SetContext(myContext); + sff->SetPrecision(myTolerance); + sff->SetMinTolerance(myTolerance); + sff->SetMaxTolerance(Max(1.,myTolerance*1000.)); + sff->Perform(); + //Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; + //sfw->SetContext(myContext); + //sfw->SetPrecision(myTolerance); + //sfw->SetMinTolerance(myTolerance); + //sfw->SetMaxTolerance(Max(1.,myTolerance*1000.)); + //sfw->SetFace(aFace); + //for ( TopoDS_Iterator iter(aFace,Standard_False); iter.More(); iter.Next()) { + // TopoDS_Wire wire = TopoDS::Wire ( iter.Value() ); + // sfw->Load(wire); + // sfw->FixReorder(); + // sfw->FixShifted(); + //} + } + + aResult = myContext->Apply(Shape); + return aResult; +} diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.hxx b/src/GEOMAlgo/BlockFix_UnionEdges.hxx new file mode 100644 index 000000000..3b8aa2102 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionEdges.hxx @@ -0,0 +1,99 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_UnionEdges_HeaderFile +#define _BlockFix_UnionEdges_HeaderFile + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Handle_ShapeBuild_ReShape_HeaderFile +#include +#endif +class ShapeBuild_ReShape; +class TopoDS_Shape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class BlockFix_UnionEdges { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT BlockFix_UnionEdges(); +Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape,const Standard_Real Tol) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Real myTolerance; +Handle_ShapeBuild_ReShape myContext; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.ixx b/src/GEOMAlgo/BlockFix_UnionEdges.ixx new file mode 100644 index 000000000..addb6a314 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionEdges.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.jxx b/src/GEOMAlgo/BlockFix_UnionEdges.jxx new file mode 100644 index 000000000..a8b40958b --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionEdges.jxx @@ -0,0 +1,9 @@ +#ifndef _ShapeBuild_ReShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_UnionEdges_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.cdl b/src/GEOMAlgo/BlockFix_UnionFaces.cdl new file mode 100644 index 000000000..7fe6caed2 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionFaces.cdl @@ -0,0 +1,46 @@ +-- File: BlockFix_UnionFaces.cdl +-- Created: Tue Dec 7 17:15:42 2004 +-- Author: Pavel Durandin +-- +---Copyright: Open CASCADE SA 2004 + + +class UnionFaces from BlockFix + +uses + + Face from TopoDS, + Shape from TopoDS + +is + + Create returns UnionFaces from BlockFix; + ---Purpose: Empty constructor + + GetTolerance(me: in out) returns Real; + ---Purpose: Returns modifiable tolerance + ---C++: return& + + Perform (me: in out; Shape: Shape from TopoDS) returns Shape from TopoDS; + ---Purpose: Performs the unification of the fsces + -- whith the same geometry + + IsSameDomain(me; aFace : Face from TopoDS; + aChekedFace: Face from TopoDS) + returns Boolean is virtual; + ---Purpose: Returns true is surfaces have same geometrically domain + -- with given tolerance + + MovePCurves(me; aTarget: in out Face from TopoDS; + aSource: Face from TopoDS) + is virtual; + ---Purpose: Creates pcurves on aTarget face for each edge from + -- aSource one. + +fields + + myTolerance: Real; + +end; + + diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.cxx b/src/GEOMAlgo/BlockFix_UnionFaces.cxx new file mode 100644 index 000000000..2f4e212ae --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionFaces.cxx @@ -0,0 +1,512 @@ +// File: BlockFix_UnionFaces.cxx +// Created: Tue Dec 7 17:15:42 2004 +// Author: Pavel DURANDIN +// Open CASCADE SA 2004 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +//======================================================================= +//function : BlockFix_UnionFaces +//purpose : +//======================================================================= + +BlockFix_UnionFaces::BlockFix_UnionFaces() + : myTolerance(Precision::Confusion()) +{ +} + + +//======================================================================= +//function : GetTolearnce +//purpose : +//======================================================================= + +Standard_Real& BlockFix_UnionFaces::GetTolerance() +{ + return myTolerance; +} + + +//======================================================================= +//function : AddOrdinaryEdges +//purpose : auxilary +//======================================================================= +// adds edges from the shape to the sequence +// seams and equal edges are dropped +// Returns true if one of original edges dropped +static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges, + const TopoDS_Shape aShape, + Standard_Integer& anIndex) +{ + //map of edges + TopTools_MapOfShape aNewEdges; + //add edges without seams + for(TopExp_Explorer exp(aShape,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Shape edge = exp.Current(); + if(aNewEdges.Contains(edge)) + aNewEdges.Remove(edge); + else + aNewEdges.Add(edge); + } + + Standard_Boolean isDropped = Standard_False; + //merge edges and drop seams + for(Standard_Integer i = 1; i <= edges.Length(); i++) { + TopoDS_Shape current = edges(i); + if(aNewEdges.Contains(current)) { + + aNewEdges.Remove(current); + edges.Remove(i); + i--; + + if(!isDropped) { + isDropped = Standard_True; + anIndex = i; + } + } + } + + //add edges to the sequemce + for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next()) + edges.Append(anIter.Key()); + + return isDropped; +} + + +//======================================================================= +//function : ClearRts +//purpose : auxilary +//======================================================================= +static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface) +{ + if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + Handle(Geom_RectangularTrimmedSurface) rts = + Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface); + return rts->BasisSurface(); + } + return aSurface; +} + + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) +{ + Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape; + TopoDS_Shape aResShape = myContext->Apply(Shape); + + // processing each solid + TopExp_Explorer exps; + for(exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) { + TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + // map of processed shapes + TopTools_MapOfShape aProcessed; + + Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; + + Standard_Integer NbModif=0; + Standard_Boolean hasFailed = Standard_False; + Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.),0.1); + // processing each face + TopExp_Explorer exp; + //for( exp.Init(Shape, TopAbs_FACE); exp.More(); exp.Next()) { + for( exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); + + if(aProcessed.Contains(aFace)) + continue; + + Standard_Integer dummy; + TopTools_SequenceOfShape edges; + AddOrdinaryEdges(edges,aFace,dummy); + + TopTools_SequenceOfShape faces; + faces.Append(aFace); + + //surface and location to construct result + TopLoc_Location aBaseLocation; + Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation); + aBaseSurface = ClearRts(aBaseSurface); + + // find adjacent faces to union + Standard_Integer i; + for( i = 1; i <= edges.Length(); i++) { + TopoDS_Edge edge = TopoDS::Edge(edges(i)); + if(BRep_Tool::Degenerated(edge)) + continue; + + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter(aList); + for( ; anIter.More(); anIter.Next()) { + TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD)); + if(anCheckedFace.IsSame(aFace)) + continue; + + if(aProcessed.Contains(anCheckedFace)) + continue; + + if(IsSameDomain(aFace,anCheckedFace)) { + + if(aList.Extent() != 2) { + // non mainfold case is not processed + continue; + } + + // replacing pcurves + TopoDS_Face aMockUpFace; + BRep_Builder B; + B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.); + MovePCurves(aMockUpFace,anCheckedFace); + + if(AddOrdinaryEdges(edges,aMockUpFace,dummy)) { + // sequence edges is modified + i = dummy; + } + + faces.Append(anCheckedFace); + aProcessed.Add(anCheckedFace); + break; + } + } + } + + // all faces collected in the sequence. Perform union of faces + if(faces.Length() > 1) { + NbModif++; + TopoDS_Face aResult; + BRep_Builder B; + B.MakeFace(aResult,aBaseSurface,aBaseLocation,0); + Standard_Integer nbWires = 0; + + // connecting wires + while(edges.Length()>0) { + + Standard_Boolean isEdge3d = Standard_False; + nbWires++; + TopTools_MapOfShape aVertices; + TopoDS_Wire aWire; + B.MakeWire(aWire); + + TopoDS_Edge anEdge = TopoDS::Edge(edges(1)); + edges.Remove(1); + + isEdge3d |= !BRep_Tool::Degenerated(anEdge); + B.Add(aWire,anEdge); + TopoDS_Vertex V1,V2; + TopExp::Vertices(anEdge,V1,V2); + aVertices.Add(V1); + aVertices.Add(V2); + + Standard_Boolean isNewFound = Standard_False; + do { + isNewFound = Standard_False; + for(Standard_Integer j = 1; j <= edges.Length(); j++) { + anEdge = TopoDS::Edge(edges(j)); + TopExp::Vertices(anEdge,V1,V2); + if(aVertices.Contains(V1) || aVertices.Contains(V2)) { + isEdge3d |= !BRep_Tool::Degenerated(anEdge); + aVertices.Add(V1); + aVertices.Add(V2); + B.Add(aWire,anEdge); + edges.Remove(j); + j--; + isNewFound = Standard_True; + } + } + } while (isNewFound); + + // sorting eny type of edges + aWire = TopoDS::Wire(aContext->Apply(aWire)); + + TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD))); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion()); + sfw->FixReorder(); + Standard_Boolean isDegRemoved = Standard_False; + if(!sfw->StatusReorder ( ShapeExtend_FAIL )) { + // clear degenerated edges if at least one with 3d curve exist + if(isEdge3d) { + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + for(Standard_Integer j = 1; j<=sewd->NbEdges();j++) { + TopoDS_Edge E = sewd->Edge(j); + if(BRep_Tool::Degenerated(E)) { + sewd->Remove(j); + isDegRemoved = Standard_True; + j--; + } + } + } + sfw->FixShifted(); + if(isDegRemoved) + sfw->FixDegenerated(); + } + TopoDS_Wire aWireFixed = sfw->Wire(); + aContext->Replace(aWire,aWireFixed); + // add resulting wire + if(isEdge3d) { + B.Add(aResult,aWireFixed); + } + else { + // sorting edges + Handle(ShapeExtend_WireData) sbwd = sfw->WireData(); + Standard_Integer nbEdges = sbwd->NbEdges(); + // sort degenerated edges and create one edge instead of several ones + ShapeAnalysis_WireOrder sawo(Standard_False, 0); + ShapeAnalysis_Edge sae; + Standard_Integer aLastEdge = nbEdges; + for(Standard_Integer j = 1; j <= nbEdges; j++) { + Standard_Real f,l; + //smh protection on NULL pcurve + Handle(Geom2d_Curve) c2d; + if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) { + aLastEdge--; + continue; + } + sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY()); + } + sawo.Perform(); + + // constructind one degenerative edge + gp_XY aStart, anEnd, tmp; + Standard_Integer nbFirst = sawo.Ordered(1); + TopoDS_Edge anOrigE = TopoDS::Edge(sbwd->Edge(nbFirst).Oriented(TopAbs_FORWARD)); + ShapeBuild_Edge sbe; + TopoDS_Vertex aDummyV; + TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV); + sawo.XY(nbFirst,aStart,tmp); + sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd); + + gp_XY aVec = anEnd-aStart; + Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart)); + + B.UpdateEdge(E,aLine,tmpF,0.); + B.Range(E,tmpF,0.,aVec.Modulus()); + Handle(Geom_Curve) C3d; + B.UpdateEdge(E,C3d,0.); + B.Degenerated(E,Standard_True); + TopoDS_Wire aW; + B.MakeWire(aW); + B.Add(aW,E); + B.Add(aResult,aW); + } + + } + + // perform substitution of face + aContext->Replace(aContext->Apply(aFace),aResult); + + + ShapeFix_Face sff (aResult); + //Intializing by tolerances + sff.SetPrecision(myTolerance); + sff.SetMinTolerance(tol); + sff.SetMaxTolerance(Max(1.,myTolerance*1000.)); + //Setting modes + sff.FixOrientationMode() = 0; + //sff.FixWireMode() = 0; + sff.SetContext(aContext); + // Applying the fixes + sff.Perform(); + if(sff.Status(ShapeExtend_FAIL)) + hasFailed = Standard_True; + + // breaking down to several faces + TopoDS_Shape theResult = aContext->Apply(aResult); + for(TopExp_Explorer aFaceExp(theResult,TopAbs_FACE);aFaceExp.More();aFaceExp.Next()) { + TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD)); + Handle(TColGeom_HArray2OfSurface) grid = new TColGeom_HArray2OfSurface ( 1, 1, 1, 1 ); + grid->SetValue ( 1, 1, aBaseSurface ); + Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid ); + ShapeFix_ComposeShell CompShell; + CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision + CompShell.SetContext( aContext ); + + TopTools_SequenceOfShape parts; + ShapeFix_SequenceOfWireSegment wires; + for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) { + Handle(ShapeExtend_WireData) sbwd = + new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() )); + ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED ); + wires.Append(seg); + } + + CompShell.DispatchWires ( parts,wires ); + for (Standard_Integer j=1; j <= parts.Length(); j++ ) { + ShapeFix_Face aFixOrient(TopoDS::Face(parts(j))); + aFixOrient.SetContext(aContext); + aFixOrient.FixOrientation(); + } + + TopoDS_Shape CompRes; + if ( faces.Length() !=1 ) { + TopoDS_Shell S; + B.MakeShell ( S ); + for ( i=1; i <= parts.Length(); i++ ) + B.Add ( S, parts(i) ); + CompRes = S; + } + else CompRes = parts(1); + + aContext->Replace(aCurrent,CompRes); + } + + // remove the remaining faces + for(i = 2; i <= faces.Length(); i++) + aContext->Remove(faces(i)); + } + } + + //TopoDS_Shape aResult = Shape; + if(NbModif>0) { + TopoDS_Shape aResult = aSolid; + if(!hasFailed) { + aResult = aContext->Apply(aSolid); + + ShapeFix_Edge sfe; + for(exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + // ptv add fix same parameter + sfe.FixSameParameter(E, myTolerance); + } + + myContext->Replace(aSolid,aResult); + } + } + else { + for( exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; + sfw->SetContext(myContext); + sfw->SetPrecision(myTolerance); + sfw->SetMinTolerance(myTolerance); + sfw->SetMaxTolerance(Max(1.,myTolerance*1000.)); + sfw->SetFace(aFace); + for ( TopoDS_Iterator iter(aFace,Standard_False); iter.More(); iter.Next()) { + TopoDS_Wire wire = TopoDS::Wire ( iter.Value() ); + sfw->Load(wire); + sfw->FixReorder(); + sfw->FixShifted(); + } + } + } + + } // end processing each solid + + aResShape = myContext->Apply(Shape); + return aResShape; +} + + +//======================================================================= +//function : IsSameDomain +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace, + const TopoDS_Face& aCheckedFace) const +{ + //checking the same handless + TopLoc_Location L1, L2; + Handle(Geom_Surface) S1, S2; + + S1 = BRep_Tool::Surface(aFace,L1); + S2 = BRep_Tool::Surface(aCheckedFace,L2); + + return (S1 == S2 && L1 == L2); +} + + +//======================================================================= +//function : MovePCurves +//purpose : +//======================================================================= + +void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget, + const TopoDS_Face& aSource) const +{ + BRep_Builder B; + for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) { + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()), + aTarget, Precision::Confusion()); + sfw->FixReorder(); + Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL ); + sfw->FixEdgeCurves(); + if(isReoredFailed) + continue; + + sfw->FixShifted(); + sfw->FixDegenerated(); + + // remove degenerated edges from not degenerated points + ShapeAnalysis_Edge sae; + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + for(Standard_Integer i = 1; i<=sewd->NbEdges();i++) { + TopoDS_Edge E = sewd->Edge(i); + if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aTarget)) { + sewd->Remove(i); + i--; + } + } + + TopoDS_Wire ResWire = sfw->Wire(); + B.Add(aTarget,ResWire); + } +} + diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.hxx b/src/GEOMAlgo/BlockFix_UnionFaces.hxx new file mode 100644 index 000000000..a67693762 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionFaces.hxx @@ -0,0 +1,101 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _BlockFix_UnionFaces_HeaderFile +#define _BlockFix_UnionFaces_HeaderFile + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class TopoDS_Shape; +class TopoDS_Face; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class BlockFix_UnionFaces { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT BlockFix_UnionFaces(); +Standard_EXPORT Standard_Real& GetTolerance() ; +Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape) ; +Standard_EXPORT virtual Standard_Boolean IsSameDomain(const TopoDS_Face& aFace,const TopoDS_Face& aChekedFace) const; +Standard_EXPORT virtual void MovePCurves(TopoDS_Face& aTarget,const TopoDS_Face& aSource) const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Real myTolerance; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.ixx b/src/GEOMAlgo/BlockFix_UnionFaces.ixx new file mode 100644 index 000000000..bae71ca14 --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionFaces.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.jxx b/src/GEOMAlgo/BlockFix_UnionFaces.jxx new file mode 100644 index 000000000..8ccb1344a --- /dev/null +++ b/src/GEOMAlgo/BlockFix_UnionFaces.jxx @@ -0,0 +1,9 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _BlockFix_UnionFaces_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/GEOMAlgo.cdl b/src/GEOMAlgo/GEOMAlgo.cdl index 266dee921..b7f770f3a 100755 --- a/src/GEOMAlgo/GEOMAlgo.cdl +++ b/src/GEOMAlgo/GEOMAlgo.cdl @@ -12,21 +12,49 @@ package GEOMAlgo uses TCollection, TColStd, + Geom, Bnd, gp, TopAbs, TopoDS, TopTools, - IntTools + IntTools, + BOPTools, + BOP -is +is + -- enumerations + -- + enumeration State is + ST_UNKNOWN, + ST_IN, + ST_OUT, + ST_ON, + ST_ONIN, + ST_ONOUT, + ST_INOUT + end State; + -- + -- classes + -- deferred class Algo; - deferred class ShapeAlgo; + deferred class ShapeAlgo; + -- + -- gluer class Gluer; + class GlueAnalyser; + class CoupleOfShapes; class PassKey; class PassKeyMapHasher; class Tools; - + -- + -- finder on + deferred class ShapeSolid; + class WireSolid; + class ShellSolid; + class VertexSolid; + class FinderShapeOn; + -- class IndexedDataMapOfPassKeyListOfShape instantiates IndexedDataMap from TCollection (PassKey from GEOMAlgo, ListOfShape from TopTools, @@ -39,6 +67,10 @@ is class IndexedDataMapOfIntegerShape instantiates IndexedDataMap from TCollection (Integer from Standard, Shape from TopoDS, - MapIntegerHasher from TColStd); + MapIntegerHasher from TColStd); + + class ListOfCoupleOfShapes + instantiates List from TCollection (CoupleOfShapes from GEOMAlgo); + end GEOMAlgo; diff --git a/src/GEOMAlgo/GEOMAlgo_Algo.cdl b/src/GEOMAlgo/GEOMAlgo_Algo.cdl index ea2724eb7..c39e7fb32 100755 --- a/src/GEOMAlgo/GEOMAlgo_Algo.cdl +++ b/src/GEOMAlgo/GEOMAlgo_Algo.cdl @@ -21,10 +21,10 @@ is is deferred; CheckData(me:out) - is deferred protected; + is virtual protected; CheckResult(me:out) - is deferred protected; + is virtual protected; ErrorStatus (me) returns Integer from Standard; diff --git a/src/GEOMAlgo/GEOMAlgo_Algo.cxx b/src/GEOMAlgo/GEOMAlgo_Algo.cxx index 345c08b91..8350180e7 100755 --- a/src/GEOMAlgo/GEOMAlgo_Algo.cxx +++ b/src/GEOMAlgo/GEOMAlgo_Algo.cxx @@ -23,6 +23,22 @@ { } //======================================================================= +// function: CheckData +// purpose: +//======================================================================= + void GEOMAlgo_Algo::CheckData() +{ + myErrorStatus=0; +} +//======================================================================= +// function: CheckResult +// purpose: +//======================================================================= + void GEOMAlgo_Algo::CheckResult() +{ + myErrorStatus=0; +} +//======================================================================= // function: ErrorStatus // purpose: //======================================================================= diff --git a/src/GEOMAlgo/GEOMAlgo_Algo.hxx b/src/GEOMAlgo/GEOMAlgo_Algo.hxx index 3d1a8b285..aeb974338 100644 --- a/src/GEOMAlgo/GEOMAlgo_Algo.hxx +++ b/src/GEOMAlgo/GEOMAlgo_Algo.hxx @@ -66,8 +66,8 @@ protected: // Standard_EXPORT GEOMAlgo_Algo(); Standard_EXPORT virtual ~GEOMAlgo_Algo(); -Standard_EXPORT virtual void CheckData() = 0; -Standard_EXPORT virtual void CheckResult() = 0; +Standard_EXPORT virtual void CheckData() ; +Standard_EXPORT virtual void CheckResult() ; // Fields PROTECTED diff --git a/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.cdl b/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.cdl new file mode 100644 index 000000000..bc06cd9cc --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.cdl @@ -0,0 +1,48 @@ +-- File: GEOMAlgo_CoupleOfShapes.cdl +-- Created: Wed Dec 15 13:00:10 2004 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2004 + + +class CoupleOfShapes from GEOMAlgo + + ---Purpose: + +uses + Shape from TopoDS + +--raises + +is + Create + returns CoupleOfShapes from GEOMAlgo; + + SetShapes(me:out; + aS1: Shape from TopoDS; + aS2: Shape from TopoDS); + + SetShape1(me:out; + aS1: Shape from TopoDS); + + SetShape2(me:out; + aS2: Shape from TopoDS); + + Shapes(me; + aS1:out Shape from TopoDS; + aS2:out Shape from TopoDS); + + Shape1(me) + returns Shape from TopoDS; + ---C++:return const & + + Shape2(me) + returns Shape from TopoDS; + ---C++:return const & + +fields + + myShape1: Shape from TopoDS is protected; + myShape2: Shape from TopoDS is protected; + +end CoupleOfShapes; diff --git a/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.cxx b/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.cxx new file mode 100644 index 000000000..04252911e --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.cxx @@ -0,0 +1,65 @@ +// File: GEOMAlgo_CoupleOfShapes.cxx +// Created: Wed Dec 15 13:03:52 2004 +// Author: Peter KURNEV +// + + +#include +//======================================================================= +//function : GEOMAlgo_CoupleOfShapes +//purpose : +//======================================================================= +GEOMAlgo_CoupleOfShapes::GEOMAlgo_CoupleOfShapes() +{} +//======================================================================= +//function : SetShapes +//purpose : +//======================================================================= +void GEOMAlgo_CoupleOfShapes::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) +{ + myShape1=aS1; + myShape2=aS2; +} +//======================================================================= +//function : Shapes +//purpose : +//======================================================================= +void GEOMAlgo_CoupleOfShapes::Shapes(TopoDS_Shape& aS1, + TopoDS_Shape& aS2)const +{ + aS1=myShape1; + aS2=myShape2; +} +//======================================================================= +//function : SetShape1 +//purpose : +//======================================================================= +void GEOMAlgo_CoupleOfShapes::SetShape1(const TopoDS_Shape& aS1) +{ + myShape1=aS1; +} +//======================================================================= +//function : SetShape2 +//purpose : +//======================================================================= +void GEOMAlgo_CoupleOfShapes::SetShape2(const TopoDS_Shape& aS2) +{ + myShape2=aS2; +} +//======================================================================= +//function : Shape1 +//purpose : +//======================================================================= +const TopoDS_Shape& GEOMAlgo_CoupleOfShapes::Shape1()const +{ + return myShape1; +} +//======================================================================= +//function : Shape2 +//purpose : +//======================================================================= +const TopoDS_Shape& GEOMAlgo_CoupleOfShapes::Shape2()const +{ + return myShape2; +} diff --git a/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.hxx b/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.hxx new file mode 100644 index 000000000..26889be5e --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.hxx @@ -0,0 +1,100 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_CoupleOfShapes_HeaderFile +#define _GEOMAlgo_CoupleOfShapes_HeaderFile + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +class TopoDS_Shape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_CoupleOfShapes { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT GEOMAlgo_CoupleOfShapes(); +Standard_EXPORT void SetShapes(const TopoDS_Shape& aS1,const TopoDS_Shape& aS2) ; +Standard_EXPORT void SetShape1(const TopoDS_Shape& aS1) ; +Standard_EXPORT void SetShape2(const TopoDS_Shape& aS2) ; +Standard_EXPORT void Shapes(TopoDS_Shape& aS1,TopoDS_Shape& aS2) const; +Standard_EXPORT const TopoDS_Shape& Shape1() const; +Standard_EXPORT const TopoDS_Shape& Shape2() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +TopoDS_Shape myShape1; +TopoDS_Shape myShape2; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.ixx b/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.ixx new file mode 100644 index 000000000..1e5d2f760 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.jxx b/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.jxx new file mode 100644 index 000000000..07fd4c49f --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_CoupleOfShapes.jxx @@ -0,0 +1,6 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_CoupleOfShapes_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cdl b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cdl new file mode 100644 index 000000000..bd0a29934 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cdl @@ -0,0 +1,83 @@ +-- File: GEOMAlgo_FinderShapeOn.cdl +-- Created: Tue Jan 11 14:35:52 2005 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2005 + + +class FinderShapeOn from GEOMAlgo + inherits ShapeAlgo from GEOMAlgo + + ---Purpose: + +uses + Surface from Geom, + ShapeEnum from TopAbs, + ListOfShape from TopTools, + DataMapOfShapeShape from TopTools, + Shape from TopoDS, + State from GEOMAlgo + +--raises + +is + Create + returns FinderShapeOn from GEOMAlgo; + ---C++: alias "Standard_EXPORT virtual ~GEOMAlgo_FinderShapeOn();" + + Perform(me:out) + is redefined; + + SetSurface(me:out; + aS:Surface from Geom); + + SetShapeType(me:out; + aST:ShapeEnum from TopAbs); + + SetState(me:out; + aSF:State from GEOMAlgo); + + Surface(me) + returns Surface from Geom; + ---C++: return const & + + ShapeType(me) + returns ShapeEnum from TopAbs; + + State(me) + returns State from GEOMAlgo; + + Shapes(me) + returns ListOfShape from TopTools; + ---C++: return const & + + -- + -- protected methods + -- + CheckData(me:out) + is redefined protected; + + MakeArguments(me:out) + is protected; + + Find(me:out) + is protected; + + CopySource(myclass; + aS :Shape from TopoDS; + aImages : out DataMapOfShapeShape from TopTools; + aOriginals: out DataMapOfShapeShape from TopTools; + aSC : out Shape from TopoDS); + + + +fields + mySurface : Surface from Geom is protected; + myShapeType : ShapeEnum from TopAbs is protected; + myState : State from GEOMAlgo is protected; + myArg1 : Shape from TopoDS is protected; + myArg2 : Shape from TopoDS is protected; + myLS : ListOfShape from TopTools is protected; + myImages : DataMapOfShapeShape from TopTools is protected; + +end FinderShapeOn; diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx new file mode 100644 index 000000000..775522cab --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.cxx @@ -0,0 +1,387 @@ +// File: GEOMAlgo_FinderShapeOn.cxx +// Created: Tue Jan 11 14:44:31 2005 +// Author: Peter KURNEV +// + + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include + + +//======================================================================= +//function : GEOMAlgo_FinderShapeOn +//purpose : +//======================================================================= +GEOMAlgo_FinderShapeOn::GEOMAlgo_FinderShapeOn() +: + GEOMAlgo_ShapeAlgo() +{ + myTolerance=0.0001; + myShapeType=TopAbs_VERTEX; + myState=GEOMAlgo_ST_UNKNOWN; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_FinderShapeOn::~GEOMAlgo_FinderShapeOn() +{ +} +//======================================================================= +//function : SetSurface +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::SetSurface(const Handle(Geom_Surface)& aS) +{ + mySurface=aS; +} +//======================================================================= +//function : Surface +//purpose : +//======================================================================= +const Handle(Geom_Surface)& GEOMAlgo_FinderShapeOn::Surface() const +{ + return mySurface; +} +//======================================================================= +//function : SetShapeType +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::SetShapeType(const TopAbs_ShapeEnum aType) +{ + myShapeType=aType; +} +//======================================================================= +//function : ShapeType +//purpose : +//======================================================================= +TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn::ShapeType()const +{ + return myShapeType; +} +//======================================================================= +//function : SetState +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::SetState(const GEOMAlgo_State aState) +{ + myState=aState; +} +//======================================================================= +//function : State +//purpose : +//======================================================================= +GEOMAlgo_State GEOMAlgo_FinderShapeOn::State() const +{ + return myState; +} +//======================================================================= +// function: Shapes +// purpose: +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn::Shapes() const +{ + return myLS; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::Perform() +{ + myErrorStatus=0; + myWarningStatus=0; + myLS.Clear(); + // + if (!myResult.IsNull()){ + myResult.Nullify(); + } + // + CheckData(); + if(myErrorStatus) { + return; + } + // + MakeArguments(); + if(myErrorStatus || myWarningStatus) { + return; + } + // + Find(); + if(myErrorStatus) { + return; + } + // +} +//======================================================================= +//function : Find +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::Find() +{ + myErrorStatus=0; + // + Standard_Boolean bIsDone; + Standard_Integer iErr; + TopTools_ListIteratorOfListOfShape aIt; + BRep_Builder aBB; + BOPTools_DSFiller aDF; + GEOMAlgo_ShapeSolid* pSS; + // + // 1. Prepare DSFiller + aDF.SetShapes (myArg1, myArg2); + bIsDone=aDF.IsDone(); + if (!bIsDone) { + myErrorStatus=30; // wrong args are used for DSFiller + return; + } + aDF.Perform(); + bIsDone=aDF.IsDone(); + if (!bIsDone) { + myErrorStatus=31; // DSFiller failed + return; + } + // + // 2. Find shapes + myLS.Clear(); + // + if (myShapeType==TopAbs_VERTEX) { + pSS=new GEOMAlgo_VertexSolid; + } + else if (myShapeType==TopAbs_EDGE) { + pSS=new GEOMAlgo_WireSolid; + } + else if (myShapeType==TopAbs_FACE) { + pSS=new GEOMAlgo_ShellSolid; + } + // + pSS->SetFiller(aDF); + pSS->Perform(); + iErr=pSS->ErrorStatus(); + if (iErr) { + myErrorStatus=32; // builder ShapeSolid failed + delete pSS; + return; + } + // + const TopTools_ListOfShape& aLS=pSS->Shapes(myState); + // + aIt.Initialize(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSImage=aIt.Value(); + if (myImages.IsBound(aSImage)) { + const TopoDS_Shape& aS=myImages.Find(aSImage); + myLS.Append(aS); + } + else { + myErrorStatus=33;// can not find original shape + return; + } + } + // + delete pSS; +} +//======================================================================= +//function : MakeArguments +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::MakeArguments() +{ + myErrorStatus=0; + // + Standard_Integer i, aNb; + BRepLib_FaceError aFErr; + BRepLib_MakeFace aMF; + TopTools_IndexedMapOfShape aM; + BRep_Builder aBB; + TopoDS_Compound aCmp; + TopoDS_Shell aSh; + TopoDS_Solid aSd; + TopoDS_Shape aSC; + TopTools_DataMapOfShapeShape aOriginals; + TopExp_Explorer aExp; + // + // Argument 1 + aMF.Init(mySurface, Standard_True); + aFErr=aMF.Error(); + if (aFErr!=BRepLib_FaceDone) { + myErrorStatus=20; // can not build the face + return; + } + // + const TopoDS_Shape& aF=aMF.Shape(); + // + // update tolerance + aExp.Init(aF, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aExp.Current()); + aBB.UpdateVertex(aV, myTolerance); + } + aExp.Init(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); + aBB.UpdateEdge(aE, myTolerance); + } + const TopoDS_Face& aFace=TopoDS::Face(aF); + aBB.UpdateFace(aFace, myTolerance); + // + // make solid + aBB.MakeShell(aSh); + aBB.Add(aSh, aFace); + aBB.MakeSolid(aSd); + aBB.Add(aSd, aSh); + myArg1=aSd; + // + // Argument 2 + // + myImages.Clear(); + // + GEOMAlgo_FinderShapeOn::CopySource(myShape, myImages, aOriginals, aSC); + // + TopExp::MapShapes(aSC, myShapeType, aM); + aNb=aM.Extent(); + if (!aNb) { + myWarningStatus=10; // No found subshapes of type myShapeType + return; + } + // + aBB.MakeCompound(aCmp); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=aM(i); + aBB.Add(aCmp, aS); + } + myArg2=aCmp; +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::CheckData() +{ + myErrorStatus=0; + // + if(mySurface.IsNull()) { + myErrorStatus=10; // mySurface=NULL + return; + } + // + if (myShape.IsNull()) { + myErrorStatus=11; // myShape=NULL + return; + } + // + if (!(myShapeType==TopAbs_VERTEX || + myShapeType==TopAbs_EDGE || + myShapeType==TopAbs_FACE)) { + myErrorStatus=12; // unallowed subshape type + return; + } + // + if (myState==GEOMAlgo_ST_UNKNOWN || + myState==GEOMAlgo_ST_INOUT) { + myErrorStatus=13; // unallowed state type + return; + } +} +// +//======================================================================= +//function : CopySource +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::CopySource(const TopoDS_Shape& aE, + TopTools_DataMapOfShapeShape& aImages, + TopTools_DataMapOfShapeShape& aOriginals, + TopoDS_Shape& aEx) +{ + Standard_Boolean bFree; + TopAbs_ShapeEnum aType; + Standard_Integer aR; + BRep_Builder BB; + TopoDS_Iterator aIt; + // + aType=aE.ShapeType(); + // + if (aOriginals.IsBound(aE)) { + aEx=aOriginals.ChangeFind(aE); + if (aType==TopAbs_EDGE) { + return; + } + } + else { + aEx=aE.EmptyCopied(); + aOriginals.Bind(aE, aEx); + aImages.Bind(aEx, aE); + } + // + aR=(Standard_Integer)aType+1; + if (aR>TopAbs_VERTEX) { + return; + } + // + bFree=aEx.Free(); + aEx.Free(Standard_True); + // + aType=(TopAbs_ShapeEnum) aR; + // + aIt.Initialize(aE);//, Standard_False); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aV=aIt.Value(); + TopoDS_Shape aVx; + // + CopySource (aV, aImages, aOriginals, aVx); + // + aVx.Orientation(aV.Orientation()); + BB.Add(aEx, aVx); + } + // + aEx.Free(bFree); +} + +// +// myErrorStatus : +// +// 10 -mySurface=NULL +// 11 -myShape=NULL +// 12 -unallowed type of subshapes +// 13 -unallowed state +// 20 -can not build the face +// 30 -wrong args are used for DSFiller +// 31 -DSFiller failed +// 32 -builder ShapeSolid failed +// 33 -can not find original shape +// +// myWarningStatus +// +// 10 -subshapes of type myShapeType can not be fond in myShape + diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx new file mode 100644 index 000000000..12bf74c16 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.hxx @@ -0,0 +1,133 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_FinderShapeOn_HeaderFile +#define _GEOMAlgo_FinderShapeOn_HeaderFile + +#ifndef _Handle_Geom_Surface_HeaderFile +#include +#endif +#ifndef _TopAbs_ShapeEnum_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_State_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeShape_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_ShapeAlgo_HeaderFile +#include +#endif +class Geom_Surface; +class TopTools_ListOfShape; +class TopoDS_Shape; +class TopTools_DataMapOfShapeShape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_FinderShapeOn : public GEOMAlgo_ShapeAlgo { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT GEOMAlgo_FinderShapeOn(); +Standard_EXPORT virtual ~GEOMAlgo_FinderShapeOn(); +Standard_EXPORT virtual void Perform() ; +Standard_EXPORT void SetSurface(const Handle(Geom_Surface)& aS) ; +Standard_EXPORT void SetShapeType(const TopAbs_ShapeEnum aST) ; +Standard_EXPORT void SetState(const GEOMAlgo_State aSF) ; +Standard_EXPORT const Handle_Geom_Surface& Surface() const; +Standard_EXPORT TopAbs_ShapeEnum ShapeType() const; +Standard_EXPORT GEOMAlgo_State State() const; +Standard_EXPORT const TopTools_ListOfShape& Shapes() const; +Standard_EXPORT static void CopySource(const TopoDS_Shape& aS,TopTools_DataMapOfShapeShape& aImages,TopTools_DataMapOfShapeShape& aOriginals,TopoDS_Shape& aSC) ; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT virtual void CheckData() ; +Standard_EXPORT void MakeArguments() ; +Standard_EXPORT void Find() ; + + + // Fields PROTECTED + // +Handle_Geom_Surface mySurface; +TopAbs_ShapeEnum myShapeType; +GEOMAlgo_State myState; +TopoDS_Shape myArg1; +TopoDS_Shape myArg2; +TopTools_ListOfShape myLS; +TopTools_DataMapOfShapeShape myImages; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.ixx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.ixx new file mode 100644 index 000000000..00afa2d33 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.jxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.jxx new file mode 100644 index 000000000..d9a848049 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn.jxx @@ -0,0 +1,15 @@ +#ifndef _Geom_Surface_HeaderFile +#include +#endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeShape_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_FinderShapeOn_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.cdl b/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.cdl new file mode 100644 index 000000000..ce1cef8f5 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.cdl @@ -0,0 +1,63 @@ +-- File: GEOMAlgo_GlueAnalyser.cdl +-- Created: Wed Dec 15 11:03:03 2004 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2004 + + +class GlueAnalyser from GEOMAlgo + inherits Gluer from GEOMAlgo + ---Purpose: + +uses + ShapeEnum from TopAbs, + ListOfShape from TopTools, + ListOfCoupleOfShapes from GEOMAlgo + +--raises + +is + Create + returns GlueAnalyser from GEOMAlgo; + ---C++: alias "Standard_EXPORT virtual ~GEOMAlgo_GlueAnalyser();" + + Perform(me:out) + is redefined; + + HasSolidsToGlue(me) + returns Boolean from Standard; + + SolidsToGlue(me) + returns ListOfCoupleOfShapes from GEOMAlgo; + ---C++:return const & + + HasSolidsAlone(me) + returns Boolean from Standard; + + SolidsAlone(me) + returns ListOfShape from TopTools; + ---C++:return const & + + DetectVertices(me:out) + is protected; + + DetectEdges(me:out) + is protected; + + DetectFaces(me:out) + is protected; + + DetectShapes(me:out; + aType:ShapeEnum from TopAbs) + is protected; + + DetectSolids (me:out) + is protected; + + + +fields + mySolidsToGlue : ListOfCoupleOfShapes from GEOMAlgo is protected; + mySolidsAlone : ListOfShape from TopTools is protected; + +end GlueAnalyser; diff --git a/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.cxx b/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.cxx new file mode 100644 index 000000000..b2d4e7583 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.cxx @@ -0,0 +1,439 @@ +// File: GEOMAlgo_GlueDetector.cxx +// Created: Wed Dec 15 11:08:09 2004 +// Author: Peter KURNEV +// + + +#include + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_GlueAnalyser::GEOMAlgo_GlueAnalyser() +: + GEOMAlgo_Gluer() +{} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_GlueAnalyser::~GEOMAlgo_GlueAnalyser() +{} +//======================================================================= +//function : HasSolidsToGlue +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_GlueAnalyser::HasSolidsToGlue()const +{ + return !mySolidsToGlue.IsEmpty(); +} +//======================================================================= +//function : HasSolidsAlone +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_GlueAnalyser::HasSolidsAlone()const +{ + return !mySolidsAlone.IsEmpty(); +} +//======================================================================= +//function : SolidsToGlue +//purpose : +//======================================================================= + const GEOMAlgo_ListOfCoupleOfShapes& GEOMAlgo_GlueAnalyser::SolidsToGlue()const +{ + return mySolidsToGlue; +} +//======================================================================= +//function : SolidsAlone +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_GlueAnalyser::SolidsAlone()const +{ + return mySolidsAlone; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::Perform() +{ + myErrorStatus=0; + myWarningStatus=0; + // + mySolidsToGlue.Clear(); + mySolidsAlone.Clear(); + // + CheckData(); + if (myErrorStatus) { + return; + } + // + InnerTolerance(); + if (myErrorStatus) { + return; + } + // + DetectVertices(); + if (myErrorStatus) { + return; + } + // + DetectEdges(); + if (myErrorStatus) { + return; + } + // + DetectFaces(); + if (myErrorStatus) { + return; + } + // + DetectSolids(); + if (myErrorStatus) { + return; + } +} +//======================================================================= +//function : DetectVertices +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::DetectVertices() +{ + myErrorStatus=0; + // + Standard_Integer j, i, aNbV, aIndex, aNbVSD; + TColStd_ListIteratorOfListOfInteger aIt; + Handle(Bnd_HArray1OfBox) aHAB; + Bnd_BoundSortBox aBSB; + TopoDS_Shape aSTmp, aVF; + TopoDS_Vertex aVnew; + TopTools_IndexedMapOfShape aMV, aMVProcessed; + TopTools_ListIteratorOfListOfShape aItS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + GEOMAlgo_IndexedDataMapOfIntegerShape aMIS; + GEOMAlgo_IndexedDataMapOfShapeBox aMSB; + // + TopExp::MapShapes(myShape, TopAbs_VERTEX, aMV); + aNbV=aMV.Extent(); + if (!aNbV) { + myErrorStatus=2; // no vertices in source shape + return; + } + // + aHAB=new Bnd_HArray1OfBox(1, aNbV); + // + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + Bnd_Box aBox; + // + aBox.SetGap(myTol); + BRepBndLib::Add(aV, aBox); + aHAB->SetValue(i, aBox); + aMIS.Add(i, aV); + aMSB.Add(aV, aBox); + } + // + aBSB.Initialize(aHAB); + // + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + // + if (aMVProcessed.Contains(aV)) { + continue; + } + // + const Bnd_Box& aBoxV=aMSB.FindFromKey(aV); + const TColStd_ListOfInteger& aLI=aBSB.Compare(aBoxV); + aNbVSD=aLI.Extent(); + if (!aNbVSD) { + myErrorStatus=3; // it must not be + return; + } + // + // Images + TopTools_ListOfShape aLVSD; + // + aIt.Initialize(aLI); + for (j=0; aIt.More(); aIt.Next(), ++j) { + aIndex=aIt.Value(); + const TopoDS_Shape& aVx=aMIS.FindFromKey(aIndex); + if(!j) { + aVF=aVx; + } + aLVSD.Append(aVx); + aMVProcessed.Add(aVx); + } + myImages.Bind(aVF, aLVSD); + } + // Origins + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + // + aItS.Initialize(aLVSD); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aVSD=aItS.Value(); + if (!myOrigins.IsBound(aVSD)) { + myOrigins.Bind(aVSD, aV); + } + } + } +} +//======================================================================= +//function : DetectFaces +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::DetectFaces() +{ + DetectShapes(TopAbs_FACE); +} +//======================================================================= +//function : DetectEdges +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::DetectEdges() +{ + DetectShapes(TopAbs_EDGE); +} +//======================================================================= +//function : DetectShapes +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::DetectShapes(const TopAbs_ShapeEnum aType) +{ + myErrorStatus=0; + // + Standard_Integer i, aNbF, aNbSDF, iErr; + TopoDS_Shape aNewShape; + TopTools_IndexedMapOfShape aMF; + TopTools_ListIteratorOfListOfShape aItS; + GEOMAlgo_PassKey aPKF; + GEOMAlgo_IndexedDataMapOfPassKeyListOfShape aMPKLF; + // + TopExp::MapShapes(myShape, aType, aMF); + // + aNbF=aMF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopoDS_Shape& aS=aMF(i); + // + aPKF.Clear(); + if (aType==TopAbs_FACE) { + const TopoDS_Face& aF=TopoDS::Face(aS); + FacePassKey(aF, aPKF); + } + else if (aType==TopAbs_EDGE) { + const TopoDS_Edge& aE=TopoDS::Edge(aS); + EdgePassKey(aE, aPKF); + } + // + if (myErrorStatus) { + return; + } + // + if (aMPKLF.Contains(aPKF)) { + TopTools_ListOfShape& aLSDF=aMPKLF.ChangeFromKey(aPKF); + aLSDF.Append(aS); + } + else { + TopTools_ListOfShape aLSDF; + // + aLSDF.Append(aS); + aMPKLF.Add(aPKF, aLSDF); + } + } + // check geometric coincidence + if (myCheckGeometry) { + iErr=GEOMAlgo_Tools::RefineSDShapes(aMPKLF, myTol, myContext); //XX + if (iErr) { + myErrorStatus=200; + return; + } + } + // + // Images/Origins + aNbF=aMPKLF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopTools_ListOfShape& aLSDF=aMPKLF(i); + aNbSDF=aLSDF.Extent(); + if (!aNbSDF) { + myErrorStatus=4; // it must not be + } + // + const TopoDS_Shape& aS1=aLSDF.First(); + aNewShape=aS1; + // + myImages.Bind(aNewShape, aLSDF); + // origins + aItS.Initialize(aLSDF); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aFSD=aItS.Value(); + if (!myOrigins.IsBound(aFSD)) { + myOrigins.Bind(aFSD, aNewShape); + } + } + } +} +//======================================================================= +//function : DetectSolids +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::DetectSolids() +{ + myErrorStatus=0; + // + Standard_Integer i, aNbF, aNbS, aNbC, aNbX; + TopoDS_Compound aCmp; + BRep_Builder aBB; + TopTools_IndexedDataMapOfShapeListOfShape aMFS; + TopTools_IndexedMapOfShape aMx, aMS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + GEOMAlgo_IndexedDataMapOfPassKeyListOfShape aMPKLS; + GEOMAlgo_PassKey aPKSx; + GEOMAlgo_CoupleOfShapes aCS; + // + aBB.MakeCompound(aCmp); + // + TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS); + // + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aIm=aItIm.Key(); + if (aIm.ShapeType()!=TopAbs_FACE) { + continue; + } + // + const TopTools_ListOfShape& aLF=aItIm.Value(); + aNbF=aLF.Extent(); + if (aNbF!=2) { + continue; + } + // + TopoDS_Shape aSx[2], aFx[2]; + // + aFx[0]=aLF.First(); + aFx[1]=aLF.Last(); + for (i=0; i<2; ++i) { + if (!aMFS.Contains(aFx[i])) { + continue;// it must not be so + } + // + const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aFx[i]); + aNbS=aLS.Extent(); + if (aNbS!=1) { + continue; + } + aSx[i]=aLS.First(); + } + // + if (aSx[0].IsNull() || aSx[1].IsNull()) { + continue; + } + // + aPKSx.Clear(); + aPKSx.SetIds(aSx[0], aSx[1]); + // + if (!aMPKLS.Contains(aPKSx)) { + TopTools_ListOfShape aLSx; + // + aLSx.Append(aSx[0]); + aLSx.Append(aSx[1]); + // + aMPKLS.Add(aPKSx, aLSx); + } + } + // + mySolidsToGlue.Clear(); + mySolidsAlone.Clear(); + + // + aNbC=aMPKLS.Extent(); + if (!aNbC) { + return; + } + // + for (i=1; i<=aNbC; ++i) { + const TopTools_ListOfShape& aLSx=aMPKLS(i); + const TopoDS_Shape& aSx1=aLSx.First(); + const TopoDS_Shape& aSx2=aLSx.Last(); + aCS.SetShape1(aSx1); + aCS.SetShape2(aSx2); + mySolidsToGlue.Append(aCS); + // + if (!aMx.Contains(aSx1)) { + aBB.Add(aCmp, aSx1); + aMx.Add(aSx1); + } + if (!aMx.Contains(aSx2)) { + aBB.Add(aCmp, aSx2); + aMx.Add(aSx2); + } + } + myResult=aCmp; + // + // check alone solids + TopExp::MapShapes(myShape, TopAbs_SOLID, aMS); + // + aNbX=aMx.Extent(); + for (i=1; i<=aNbX; ++i) { + const TopoDS_Shape& aSx=aMx(i); + if (!aMS.Contains(aSx)) { + mySolidsAlone.Append(aSx); + } + } +} + +/* +// A + // Make vertices + aMV.Clear(); + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + aMV.Add(aV); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + MakeVertex(aLVSD, aVnew);//ZZ + myImages.Bind(aVnew, aLVSD); + } + // + aNbV=aMV.Extent(); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + myImages.UnBind(aV); + } + // + */ diff --git a/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.hxx b/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.hxx new file mode 100644 index 000000000..4262f95b9 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.hxx @@ -0,0 +1,118 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_GlueAnalyser_HeaderFile +#define _GEOMAlgo_GlueAnalyser_HeaderFile + +#ifndef _GEOMAlgo_ListOfCoupleOfShapes_HeaderFile +#include +#endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_Gluer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _TopAbs_ShapeEnum_HeaderFile +#include +#endif +class GEOMAlgo_ListOfCoupleOfShapes; +class TopTools_ListOfShape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_GlueAnalyser : public GEOMAlgo_Gluer { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT GEOMAlgo_GlueAnalyser(); +Standard_EXPORT virtual ~GEOMAlgo_GlueAnalyser(); +Standard_EXPORT virtual void Perform() ; +Standard_EXPORT Standard_Boolean HasSolidsToGlue() const; +Standard_EXPORT const GEOMAlgo_ListOfCoupleOfShapes& SolidsToGlue() const; +Standard_EXPORT Standard_Boolean HasSolidsAlone() const; +Standard_EXPORT const TopTools_ListOfShape& SolidsAlone() const; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT void DetectVertices() ; +Standard_EXPORT void DetectEdges() ; +Standard_EXPORT void DetectFaces() ; +Standard_EXPORT void DetectShapes(const TopAbs_ShapeEnum aType) ; +Standard_EXPORT void DetectSolids() ; + + + // Fields PROTECTED + // +GEOMAlgo_ListOfCoupleOfShapes mySolidsToGlue; +TopTools_ListOfShape mySolidsAlone; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.ixx b/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.ixx new file mode 100644 index 000000000..da6caa203 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.jxx b/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.jxx new file mode 100644 index 000000000..e44fa2d72 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_GlueAnalyser.jxx @@ -0,0 +1,9 @@ +#ifndef _GEOMAlgo_ListOfCoupleOfShapes_HeaderFile +#include +#endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_GlueAnalyser_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_Gluer.cdl b/src/GEOMAlgo/GEOMAlgo_Gluer.cdl index 84656b54a..a28e365ef 100755 --- a/src/GEOMAlgo/GEOMAlgo_Gluer.cdl +++ b/src/GEOMAlgo/GEOMAlgo_Gluer.cdl @@ -14,11 +14,14 @@ uses ShapeEnum from TopAbs, Shape from TopoDS, Edge from TopoDS, - Face from TopoDS, + Face from TopoDS, + Vertex from TopoDS, + ListOfShape from TopTools, DataMapOfShapeShape from TopTools, DataMapOfShapeListOfShape from TopTools, Context from IntTools, PassKey from GEOMAlgo + --raises is @@ -33,17 +36,17 @@ is returns Boolean from Standard; Perform(me:out) - is redefined; - + is redefined; + + AloneShapes(me) + returns Integer from Standard; + CheckData(me:out) is redefined protected; CheckResult (me:out) is redefined protected; - BuildResult (me:out) - is protected; - MakeVertices(me:out) is protected; @@ -76,6 +79,10 @@ is aPK:out PassKey from GEOMAlgo) is protected; + MakeVertex(me:out; + aLV : ListOfShape from TopTools; + aNewV: out Vertex from TopoDS) + is protected; MakeEdge(me:out; aEdge : Edge from TopoDS; aNewEdge: out Edge from TopoDS) @@ -101,13 +108,10 @@ is ---C++:return const & fields + myCheckGeometry : Boolean from Standard is protected; + myTol : Real from Standard is protected; + myImages : DataMapOfShapeListOfShape from TopTools is protected; + myOrigins : DataMapOfShapeShape from TopTools is protected; + myNbAlone : Integer from Standard is protected; - myCheckGeometry : Boolean from Standard is protected; - - myImages : DataMapOfShapeListOfShape from TopTools is protected; - myOrigins : DataMapOfShapeShape from TopTools is protected; - myContext : Context from IntTools is protected; - myTypeResult: ShapeEnum from TopAbs is protected; - myTol : Real from Standard is protected; - end Gluer; diff --git a/src/GEOMAlgo/GEOMAlgo_Gluer.cxx b/src/GEOMAlgo/GEOMAlgo_Gluer.cxx index ad1a7c79c..bd497c1f3 100755 --- a/src/GEOMAlgo/GEOMAlgo_Gluer.cxx +++ b/src/GEOMAlgo/GEOMAlgo_Gluer.cxx @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -18,7 +19,6 @@ #include #include #include -#include #include #include @@ -45,11 +45,15 @@ #include #include +#include +#include +#include #include #include #include #include +#include #include #include @@ -68,7 +72,7 @@ GEOMAlgo_Gluer::GEOMAlgo_Gluer() myTolerance=0.0001; myTol=myTolerance; myCheckGeometry=Standard_True; - myTypeResult=TopAbs_SOLID; + myNbAlone=0; } //======================================================================= //function : ~GEOMAlgo_Gluer @@ -93,7 +97,14 @@ Standard_Boolean GEOMAlgo_Gluer::CheckGeometry() const { return myCheckGeometry; } - +//======================================================================= +//function : AloneShapes +//purpose : +//======================================================================= +Standard_Integer GEOMAlgo_Gluer::AloneShapes()const +{ + return myNbAlone; +} //======================================================================= //function : Images //purpose : @@ -120,118 +131,139 @@ void GEOMAlgo_Gluer::Perform() myWarningStatus=0; // Standard_Integer i; - const Standard_Integer aNb=9; + const Standard_Integer aNb=8; void (GEOMAlgo_Gluer::* pF[aNb])()={ &GEOMAlgo_Gluer::CheckData, &GEOMAlgo_Gluer::InnerTolerance, &GEOMAlgo_Gluer::MakeVertices, &GEOMAlgo_Gluer::MakeEdges, &GEOMAlgo_Gluer::MakeFaces, &GEOMAlgo_Gluer::MakeShells, - &GEOMAlgo_Gluer::MakeSolids, &GEOMAlgo_Gluer::BuildResult, - &GEOMAlgo_Gluer::CheckResult + &GEOMAlgo_Gluer::MakeSolids, &GEOMAlgo_Gluer::CheckResult }; // - //TimeReset(); - //StartChrono(); - // for (i=0; i*pF[i])(); if (myErrorStatus) { return; } } - // - //StopChrono(); - //TimeShow(); } //======================================================================= -//function : CheckResult +//function : MakeVertices //purpose : //======================================================================= -void GEOMAlgo_Gluer::CheckResult() +void GEOMAlgo_Gluer::MakeVertices() { myErrorStatus=0; // - if (myResult.IsNull()) { - myErrorStatus=6; - return; + Standard_Integer j, i, aNbV, aIndex, aNbVSD; + TColStd_ListIteratorOfListOfInteger aIt; + Handle(Bnd_HArray1OfBox) aHAB; + Bnd_BoundSortBox aBSB; + TopoDS_Shape aSTmp, aVF; + TopoDS_Vertex aVnew; + TopTools_IndexedMapOfShape aMV, aMVProcessed; + TopTools_ListIteratorOfListOfShape aItS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + TopTools_DataMapOfShapeListOfShape aMVV; + GEOMAlgo_IndexedDataMapOfIntegerShape aMIS; + GEOMAlgo_IndexedDataMapOfShapeBox aMSB; + // + TopExp::MapShapes(myShape, TopAbs_VERTEX, aMV); + aNbV=aMV.Extent(); + if (!aNbV) { + myErrorStatus=2; // no vertices in source shape + return; } - // - Standard_Boolean bFound; - Standard_Integer i, j, aNbS, aNbFS, aNbSx; - TopTools_IndexedMapOfShape aMS, aMFS; - TopTools_IndexedDataMapOfShapeListOfShape aMFR; // - TopExp::MapShapesAndAncestors(myResult, TopAbs_FACE, myTypeResult, aMFR); - TopExp::MapShapes(myResult, myTypeResult, aMS); + aHAB=new Bnd_HArray1OfBox(1, aNbV); // - aNbS=aMS.Extent(); - for (i=1; i<=aNbS; ++i) { - const TopoDS_Shape& aSolid=aMS(i); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + Bnd_Box aBox; // - aMFS.Clear(); - TopExp::MapShapes(aSolid, TopAbs_FACE, aMFS); + aBox.SetGap(myTol); + BRepBndLib::Add(aV, aBox); + aHAB->SetValue(i, aBox); + aMIS.Add(i, aV); + aMSB.Add(aV, aBox); + } + // + aBSB.Initialize(aHAB); + // + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); // - bFound=Standard_False; - aNbFS=aMFS.Extent(); - for (j=1; j<=aNbFS; ++j) { - const TopoDS_Shape& aFS=aMFS(j); - if (aMFR.Contains(aFS)) { - const TopTools_ListOfShape& aLSx=aMFR.FindFromKey(aFS); - aNbSx=aLSx.Extent(); - if (aNbSx==2) { - bFound=!bFound; - break; - } - } + if (aMVProcessed.Contains(aV)) { + continue; } // - if (!bFound) { - myWarningStatus=1; - break; + const Bnd_Box& aBoxV=aMSB.FindFromKey(aV); + const TColStd_ListOfInteger& aLI=aBSB.Compare(aBoxV); + aNbVSD=aLI.Extent(); + if (!aNbVSD) { + myErrorStatus=3; // it must not be + return; } + // + // Images + // + TopTools_ListOfShape aLVSD; + // + aIt.Initialize(aLI); + for (j=0; aIt.More(); aIt.Next(), ++j) { + aIndex=aIt.Value(); + const TopoDS_Shape& aVx=aMIS.FindFromKey(aIndex); + if(!j) { + aVF=aVx; + } + aLVSD.Append(aVx); + aMVProcessed.Add(aVx); + } + // + myImages.Bind(aVF, aLVSD); } -} -//======================================================================= -//function : CheckData -//purpose : -//======================================================================= -void GEOMAlgo_Gluer::CheckData() -{ - myErrorStatus=0; // - if (myShape.IsNull()) { - myErrorStatus=5; - return; + // Make new vertices + aMV.Clear(); + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + aNbVSD=aLVSD.Extent(); + if (aNbVSD>1) { + aMV.Add(aV); + MakeVertex(aLVSD, aVnew); + aMVV.Bind(aVnew, aLVSD); + } } - -} -//======================================================================= -//function : InnerTolerance -//purpose : -//======================================================================= -void GEOMAlgo_Gluer::InnerTolerance() -{ - myErrorStatus=0; - // - Standard_Integer i; - Standard_Real aX[3][2], dH, dHmin, aCoef, aTolTresh; - Bnd_Box aBox; // - BRepBndLib::Add(myShape, aBox); - aBox.Get(aX[0][0], aX[1][0], aX[2][0], aX[0][1], aX[1][1], aX[2][1]); + // UnBind old vertices + aNbV=aMV.Extent(); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + myImages.UnBind(aV); + } // - dHmin=aX[0][1]-aX[0][0]; - for (i=1; i<3; ++i) { - dH=aX[i][1]-aX[i][0]; - if (dHaTolTresh) { - myTol=aTolTresh; + // Origins + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + // + aItS.Initialize(aLVSD); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aVSD=aItS.Value(); + if (!myOrigins.IsBound(aVSD)) { + myOrigins.Bind(aVSD, aV); + } + } } } //======================================================================= @@ -242,17 +274,25 @@ void GEOMAlgo_Gluer::MakeSolids() { myErrorStatus=0; // - Standard_Integer i, aNbS; + Standard_Integer aNbS; TopAbs_Orientation anOr; + TopoDS_Compound aCmp; TopoDS_Solid aNewSolid; TopTools_IndexedMapOfShape aMS; - TopExp_Explorer aExp; + TopExp_Explorer aExpS, aExp; BRep_Builder aBB; // - TopExp::MapShapes(myShape, TopAbs_SOLID, aMS); + aBB.MakeCompound(aCmp); + // aNbS=aMS.Extent(); - for (i=1; i<=aNbS; ++i) { - const TopoDS_Solid& aSolid=TopoDS::Solid(aMS(i)); + aExpS.Init(myShape, TopAbs_SOLID); + for (; aExpS.More(); aExpS.Next()) { + const TopoDS_Solid& aSolid=TopoDS::Solid(aExpS.Current()); + if (aMS.Contains(aSolid)) { + continue; + } + aMS.Add(aSolid); + // anOr=aSolid.Orientation(); // aBB.MakeSolid(aNewSolid); @@ -264,11 +304,22 @@ void GEOMAlgo_Gluer::MakeSolids() const TopoDS_Shape& aShellR=myOrigins.Find(aShell); aBB.Add(aNewSolid, aShellR); } + // TopTools_ListOfShape aLS; // aLS.Append(aSolid); myImages.Bind(aNewSolid, aLS); myOrigins.Bind(aSolid, aNewSolid); + // + aBB.Add(aCmp, aNewSolid); + } + // + myResult=aCmp; + // + aNbS=aMS.Extent(); + if (aNbS) { + Standard_Real aTol=1.e-7; + BOP_CorrectTolerances::CorrectCurveOnSurface(myResult); } } //======================================================================= @@ -383,7 +434,7 @@ void GEOMAlgo_Gluer::MakeShapes(const TopAbs_ShapeEnum aType) } // check geometric coincidence if (myCheckGeometry) { - iErr=GEOMAlgo_Tools::RefineSDShapes(aMPKLF, myTol, myContext); //XX + iErr=GEOMAlgo_Tools::RefineSDShapes(aMPKLF, myTol, myContext); if (iErr) { myErrorStatus=200; return; @@ -427,116 +478,101 @@ void GEOMAlgo_Gluer::MakeShapes(const TopAbs_ShapeEnum aType) } } //======================================================================= -//function : MakeVertices +//function : CheckResult //purpose : //======================================================================= -void GEOMAlgo_Gluer::MakeVertices() +void GEOMAlgo_Gluer::CheckResult() { myErrorStatus=0; // - Standard_Boolean bFound; - Standard_Integer i, aNbV, aIndex, aNbVSD; - TColStd_ListIteratorOfListOfInteger aIt; - Handle(Bnd_HArray1OfBox) aHAB; - Bnd_BoundSortBox aBSB; - TopoDS_Shape aSTmp; - TopTools_IndexedMapOfShape aMV; - TopTools_ListIteratorOfListOfShape aItS; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; - GEOMAlgo_IndexedDataMapOfIntegerShape aMIS; - GEOMAlgo_IndexedDataMapOfShapeBox aMSB; - // - TopExp::MapShapes(myShape, TopAbs_VERTEX, aMV); - aNbV=aMV.Extent(); - if (!aNbV) { - myErrorStatus=2; // no vertices in source shape - return; - } - // - aHAB=new Bnd_HArray1OfBox(1, aNbV); - // - for (i=1; i<=aNbV; ++i) { - const TopoDS_Shape& aV=aMV(i); - Bnd_Box aBox; - // - aBox.SetGap(myTol);//XX - BRepBndLib::Add(aV, aBox); - aHAB->SetValue(i, aBox); - aMIS.Add(i, aV); - aMSB.Add(aV, aBox); + if (myResult.IsNull()) { + myErrorStatus=6; + return; } + // + Standard_Boolean bFound; + Standard_Integer i, j, aNbS, aNbFS, aNbSx; + TopTools_IndexedMapOfShape aMS, aMFS; + TopTools_IndexedDataMapOfShapeListOfShape aMFR; // - aBSB.Initialize(aHAB); + TopExp::MapShapesAndAncestors(myResult, TopAbs_FACE, TopAbs_SOLID, aMFR); + TopExp::MapShapes(myResult, TopAbs_SOLID, aMS); // - for (i=1; i<=aNbV; ++i) { - const TopoDS_Shape& aV=aMV(i); - const Bnd_Box& aBoxV=aMSB.FindFromKey(aV); - const TColStd_ListOfInteger& aLI=aBSB.Compare(aBoxV); - aNbVSD=aLI.Extent(); - if (!aNbVSD) { - myErrorStatus=3; // it must not be - return; - } + + myNbAlone=0; + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aSolid=aMS(i); // - // Images - TopTools_ListOfShape aLVSD; - TopoDS_Shape aVF; + aMFS.Clear(); + TopExp::MapShapes(aSolid, TopAbs_FACE, aMFS); // bFound=Standard_False; - aIt.Initialize(aLI); - for (; aIt.More(); aIt.Next()) { - aIndex=aIt.Value(); - const TopoDS_Shape& aVx=aMIS.FindFromKey(aIndex); - if (myImages.IsBound(aVx)) { - bFound=Standard_True; - aVF=aVx; + aNbFS=aMFS.Extent(); + for (j=1; j<=aNbFS; ++j) { + const TopoDS_Shape& aFS=aMFS(j); + if (aMFR.Contains(aFS)) { + const TopTools_ListOfShape& aLSx=aMFR.FindFromKey(aFS); + aNbSx=aLSx.Extent(); + if (aNbSx==2) { + bFound=!bFound; + break; + } } - aLVSD.Append(aVx); } - if (bFound) { - TopTools_ListOfShape& aLVI=myImages.ChangeFind(aVF); - aLVI.Append(aLVSD); - } - else { - myImages.Bind(aV, aLVSD); + // + if (!bFound) { + myWarningStatus=1; + ++myNbAlone; + //break; } } +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::CheckData() +{ + myErrorStatus=0; // - // Refine Images - aItIm.Initialize(myImages); - for (; aItIm.More(); aItIm.Next()) { - TopTools_ListOfShape aLVSDNew; - TopTools_MapOfShape aM; - // - const TopoDS_Shape& aV=aItIm.Key(); - const TopTools_ListOfShape& aLVSD=aItIm.Value(); - aItS.Initialize(aLVSD); - for (; aItS.More(); aItS.Next()) { - const TopoDS_Shape& aVSD=aItS.Value(); - if (aM.Add(aVSD)) { - aLVSDNew.Append(aVSD); - } - } - TopTools_ListOfShape& aLVI=myImages.ChangeFind(aV); - aLVI.Clear(); - aLVI.Append(aLVSDNew); + if (myShape.IsNull()) { + myErrorStatus=5; + return; } +} +//======================================================================= +//function : InnerTolerance +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::InnerTolerance() +{ + myErrorStatus=0; // - // Origins - aItIm.Initialize(myImages); - for (; aItIm.More(); aItIm.Next()) { - const TopoDS_Shape& aV=aItIm.Key(); - // - const TopTools_ListOfShape& aLVSD=myImages.Find(aV); - aItS.Initialize(aLVSD); - for (; aItS.More(); aItS.Next()) { - const TopoDS_Shape& aVSD=aItS.Value(); - if (!myOrigins.IsBound(aVSD)) { - myOrigins.Bind(aVSD, aV); - } + /* + Standard_Integer i; + Standard_Real aX[3][2], dH, dHmin, aCoef, aTolTresh; + Bnd_Box aBox; + // + BRepBndLib::Add(myShape, aBox); + aBox.Get(aX[0][0], aX[1][0], aX[2][0], aX[0][1], aX[1][1], aX[2][1]); + // + dHmin=aX[0][1]-aX[0][0]; + for (i=1; i<3; ++i) { + dH=aX[i][1]-aX[i][0]; + if (dHaTolTresh) { + myTol=aTolTresh; + } + */ + myTol=myTolerance; } //======================================================================= //function : FacePassKey @@ -588,18 +624,68 @@ void GEOMAlgo_Gluer::EdgePassKey(const TopoDS_Edge& aE, aPK.SetIds(aVR1, aVR2); } //======================================================================= +//function : MakeVertex +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeVertex(const TopTools_ListOfShape& aLV, + TopoDS_Vertex& aNewVertex) +{ + Standard_Integer aNbV; + Standard_Real aTolV, aD, aDmax; + gp_XYZ aGC; + gp_Pnt aP3D, aPGC; + TopoDS_Vertex aVx; + BRep_Builder aBB; + TopTools_ListIteratorOfListOfShape aIt; + // + aNbV=aLV.Extent(); + if (!aNbV) { + return; + } + // + // center of gravity + aGC.SetCoord(0.,0.,0.); + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + aVx=TopoDS::Vertex(aIt.Value()); + aP3D=BRep_Tool::Pnt(aVx); + aGC+=aP3D.XYZ(); + } + aGC/=(Standard_Real)aNbV; + aPGC.SetXYZ(aGC); + // + // tolerance value + aDmax=-1.; + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + aVx=TopoDS::Vertex(aIt.Value()); + aP3D=BRep_Tool::Pnt(aVx); + aTolV=BRep_Tool::Tolerance(aVx); + aD=aPGC.Distance(aP3D)+aTolV; + if (aD>aDmax) { + aDmax=aD; + } + } + // + aBB.MakeVertex (aNewVertex, aPGC, aDmax); +} +//======================================================================= //function : MakeEdge //purpose : //======================================================================= void GEOMAlgo_Gluer::MakeEdge(const TopoDS_Edge& aE, TopoDS_Edge& aNewEdge) { + //modified by NIZNHY-PKV Thu Dec 30 11:15:23 2004 f myErrorStatus=0; // + Standard_Boolean bIsDE; Standard_Real aT1, aT2; TopoDS_Vertex aV1, aV2, aVR1, aVR2; TopoDS_Edge aEx; // + bIsDE=BRep_Tool::Degenerated(aE); + // aEx=aE; aEx.Orientation(TopAbs_FORWARD); // @@ -613,7 +699,31 @@ void GEOMAlgo_Gluer::MakeEdge(const TopoDS_Edge& aE, aVR2=TopoDS::Vertex(myOrigins.Find(aV2)); aVR2.Orientation(TopAbs_REVERSED); // - BOPTools_Tools::MakeSplitEdge(aEx, aVR1, aT1, aVR2, aT2, aNewEdge); + if (bIsDE) { + Standard_Real aTol; + BRep_Builder aBB; + TopoDS_Edge E; + TopAbs_Orientation anOrE; + // + anOrE=aE.Orientation(); + aTol=BRep_Tool::Tolerance(aE); + // + E=aEx; + E.EmptyCopy(); + // + aBB.Add (E, aVR1); + aBB.Add (E, aVR2); + aBB.Range(E, aT1, aT2); + aBB.Degenerated(E, Standard_True); + aBB.UpdateEdge(E, aTol); + // + aNewEdge=E; + } + // + else { + BOPTools_Tools::MakeSplitEdge(aEx, aVR1, aT1, aVR2, aT2, aNewEdge); + } + //modified by NIZNHY-PKV Thu Dec 30 11:15:28 2004 t } // //======================================================================= @@ -625,13 +735,14 @@ void GEOMAlgo_Gluer::MakeFace(const TopoDS_Face& aF, { myErrorStatus=0; // - Standard_Boolean bIsToReverse; - Standard_Real aTol; + Standard_Boolean bIsToReverse, bIsUPeriodic; + Standard_Real aTol, aUMin, aUMax, aVMin, aVMax; TopoDS_Edge aER; TopoDS_Wire newWire; TopoDS_Face aFFWD, newFace; TopLoc_Location aLoc; Handle(Geom_Surface) aS; + Handle(Geom2d_Curve) aC2D; TopExp_Explorer aExpW, aExpE; BRep_Builder aBB; // @@ -639,7 +750,9 @@ void GEOMAlgo_Gluer::MakeFace(const TopoDS_Face& aF, aFFWD.Orientation(TopAbs_FORWARD); // aS=BRep_Tool::Surface(aFFWD, aLoc); + bIsUPeriodic=GEOMAlgo_Tools::IsUPeriodic(aS); aTol=BRep_Tool::Tolerance(aFFWD); + BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax); // aBB.MakeFace (newFace, aS, aLoc, aTol); // @@ -651,13 +764,23 @@ void GEOMAlgo_Gluer::MakeFace(const TopoDS_Face& aF, for (; aExpE.More(); aExpE.Next()) { const TopoDS_Edge& aE=TopoDS::Edge(aExpE.Current()); aER=TopoDS::Edge(myOrigins.Find(aE)); + // aER.Orientation(TopAbs_FORWARD); - // build p-curve - BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aER, aFFWD); - // orient image - bIsToReverse=BOPTools_Tools3D::IsSplitToReverse1(aER, aE, myContext); - if (bIsToReverse) { - aER.Reverse(); + if (!BRep_Tool::Degenerated(aER)) {//modified by NIZNHY-PKV Thu Dec 30 11:31:37 2004 ft + // build p-curve + if (bIsUPeriodic) { + GEOMAlgo_Tools::RefinePCurveForEdgeOnFace(aER, aFFWD, aUMin, aUMax); + } + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aER, aFFWD); + + // orient image + bIsToReverse=BOPTools_Tools3D::IsSplitToReverse1(aER, aE, myContext); + if (bIsToReverse) { + aER.Reverse(); + } + } + else { + aER.Orientation(aE.Orientation()); } // aBB.Add(newWire, aER); @@ -683,54 +806,37 @@ Standard_Boolean GEOMAlgo_Gluer::IsToReverse(const TopoDS_Face& aFR, bRet=Standard_False; // aExp.Init(aF, TopAbs_EDGE); - if (!aExp.More()) { - return bRet; - } - const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); - const TopoDS_Edge& aER=TopoDS::Edge(myOrigins.Find(aE)); - // - aC3D=BRep_Tool::Curve(aE, aT1, aT2); - aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); - aC3D->D0(aT, aP); - myContext.ProjectPointOnEdge(aP, aER, aTR); - // - BOPTools_Tools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNF); - if (aF.Orientation()==TopAbs_REVERSED) { - aDNF.Reverse(); - } - // - BOPTools_Tools3D::GetNormalToFaceOnEdge (aER, aFR, aTR, aDNFR); - if (aFR.Orientation()==TopAbs_REVERSED) { - aDNFR.Reverse(); - } - // - aScPr=aDNF*aDNFR; - return (aScPr<0.); -} -// -//======================================================================= -//function : BuildResult -//purpose : -//======================================================================= -void GEOMAlgo_Gluer::BuildResult() -{ - TopoDS_Compound aCmp; - BRep_Builder aBB; - TopAbs_ShapeEnum aType; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; - // - aBB.MakeCompound(aCmp); - // - aItIm.Initialize(myImages); - for (; aItIm.More(); aItIm.Next()) { - const TopoDS_Shape& aIm=aItIm.Key(); - aType=aIm.ShapeType(); - if(aType==myTypeResult) { - aBB.Add(aCmp, aIm); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); + //modified by NIZNHY-PKV Thu Dec 30 11:38:05 2004 f + if (BRep_Tool::Degenerated(aE)) { + continue; + } + //modified by NIZNHY-PKV Thu Dec 30 11:38:08 2004 t + const TopoDS_Edge& aER=TopoDS::Edge(myOrigins.Find(aE)); + // + aC3D=BRep_Tool::Curve(aE, aT1, aT2); + aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); + aC3D->D0(aT, aP); + myContext.ProjectPointOnEdge(aP, aER, aTR); + // + BOPTools_Tools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNF); + if (aF.Orientation()==TopAbs_REVERSED) { + aDNF.Reverse(); } + // + BOPTools_Tools3D::GetNormalToFaceOnEdge (aER, aFR, aTR, aDNFR); + if (aFR.Orientation()==TopAbs_REVERSED) { + aDNFR.Reverse(); + } + // + aScPr=aDNF*aDNFR; + return (aScPr<0.); } - myResult=aCmp; + return bRet; } +// + // // ErrorStatus // @@ -748,81 +854,37 @@ void GEOMAlgo_Gluer::BuildResult() // // 1 - some shapes can not be glued by faces // - /* -// -// CHRONOMETER -// -#include -#include - -static Standard_Real S_ChronoTime; -Standard_STATIC(OSD_Chronometer, S_Chrono); - -static void StartChrono(); -static void StopChrono(); -static void TimeShow(); -static void TimeReset(); -static int HasChrono(); - -//======================================================================= -//function : StartChrono -//purpose : //======================================================================= -void StartChrono() -{ - if (HasChrono()){ - S_Chrono().Reset(); - S_Chrono().Start(); - } -} - -//======================================================================= -//function : StopChrono -//purpose : -//======================================================================= -void StopChrono() -{ - if (HasChrono()) { - Standard_Real Chrono; - S_Chrono().Stop(); - S_Chrono().Show(Chrono); - // - S_ChronoTime+=Chrono; - } -} -//======================================================================= -//function : TimeReset +//function : BuildResult //purpose : //======================================================================= -void TimeReset() +void GEOMAlgo_Gluer::BuildResult() { - if (HasChrono()){ - S_ChronoTime=0; - } -} -//======================================================================= -//function : TimeShow -//purpose : -//======================================================================= -void TimeShow() -{ - if (HasChrono()){ - cout << "Tps: " << S_ChronoTime << endl; - } -} -//======================================================================= -//function : HasChrono -//purpose : -//======================================================================= -int HasChrono() -{ - char *xr=getenv ("XCHRONO"); - if (xr!=NULL){ - if (!strcmp (xr, "yes")) { - return 1; + Standard_Boolean bAdded; + TopoDS_Compound aCmp; + BRep_Builder aBB; + TopAbs_ShapeEnum aType; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + // + aBB.MakeCompound(aCmp); + // + bAdded=Standard_False; + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aIm=aItIm.Key(); + aType=aIm.ShapeType(); + if(aType==TopAbs_SOLID) { + bAdded=Standard_True; + aBB.Add(aCmp, aIm); } } - return 0; + myResult=aCmp; + // + if (bAdded) { + Standard_Real aTol=1.e-7; + BOP_CorrectTolerances::CorrectCurveOnSurface(myResult); + //BRepLib::SameParameter(myResult, aTol, bAdded); + } } */ diff --git a/src/GEOMAlgo/GEOMAlgo_Gluer.hxx b/src/GEOMAlgo/GEOMAlgo_Gluer.hxx index b5cfb0bdd..af5faefa1 100644 --- a/src/GEOMAlgo/GEOMAlgo_Gluer.hxx +++ b/src/GEOMAlgo/GEOMAlgo_Gluer.hxx @@ -25,27 +25,29 @@ #ifndef _Standard_Boolean_HeaderFile #include #endif +#ifndef _Standard_Real_HeaderFile +#include +#endif #ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile #include #endif #ifndef _TopTools_DataMapOfShapeShape_HeaderFile #include #endif -#ifndef _IntTools_Context_HeaderFile -#include -#endif -#ifndef _TopAbs_ShapeEnum_HeaderFile -#include -#endif -#ifndef _Standard_Real_HeaderFile -#include +#ifndef _Standard_Integer_HeaderFile +#include #endif #ifndef _GEOMAlgo_ShapeAlgo_HeaderFile #include #endif +#ifndef _TopAbs_ShapeEnum_HeaderFile +#include +#endif class TopoDS_Edge; class GEOMAlgo_PassKey; class TopoDS_Face; +class TopTools_ListOfShape; +class TopoDS_Vertex; class TopTools_DataMapOfShapeListOfShape; class TopTools_DataMapOfShapeShape; @@ -80,6 +82,7 @@ Standard_EXPORT virtual ~GEOMAlgo_Gluer(); Standard_EXPORT void SetCheckGeometry(const Standard_Boolean aFlag) ; Standard_EXPORT Standard_Boolean CheckGeometry() const; Standard_EXPORT virtual void Perform() ; +Standard_EXPORT Standard_Integer AloneShapes() const; Standard_EXPORT const TopTools_DataMapOfShapeListOfShape& Images() const; Standard_EXPORT const TopTools_DataMapOfShapeShape& Origins() const; @@ -93,7 +96,6 @@ protected: // Standard_EXPORT virtual void CheckData() ; Standard_EXPORT virtual void CheckResult() ; -Standard_EXPORT void BuildResult() ; Standard_EXPORT void MakeVertices() ; Standard_EXPORT void MakeEdges() ; Standard_EXPORT void MakeFaces() ; @@ -103,6 +105,7 @@ Standard_EXPORT void MakeSolids() ; Standard_EXPORT void InnerTolerance() ; Standard_EXPORT void EdgePassKey(const TopoDS_Edge& aE,GEOMAlgo_PassKey& aPK) ; Standard_EXPORT void FacePassKey(const TopoDS_Face& aF,GEOMAlgo_PassKey& aPK) ; +Standard_EXPORT void MakeVertex(const TopTools_ListOfShape& aLV,TopoDS_Vertex& aNewV) ; Standard_EXPORT void MakeEdge(const TopoDS_Edge& aEdge,TopoDS_Edge& aNewEdge) ; Standard_EXPORT void MakeFace(const TopoDS_Face& aFace,TopoDS_Face& aNewEdge) ; Standard_EXPORT Standard_Boolean IsToReverse(const TopoDS_Face& aFR,const TopoDS_Face& aF) ; @@ -111,11 +114,10 @@ Standard_EXPORT Standard_Boolean IsToReverse(const TopoDS_Face& aFR,const Topo // Fields PROTECTED // Standard_Boolean myCheckGeometry; +Standard_Real myTol; TopTools_DataMapOfShapeListOfShape myImages; TopTools_DataMapOfShapeShape myOrigins; -IntTools_Context myContext; -TopAbs_ShapeEnum myTypeResult; -Standard_Real myTol; +Standard_Integer myNbAlone; private: diff --git a/src/GEOMAlgo/GEOMAlgo_Gluer.jxx b/src/GEOMAlgo/GEOMAlgo_Gluer.jxx index cd5241036..f56c73fa8 100644 --- a/src/GEOMAlgo/GEOMAlgo_Gluer.jxx +++ b/src/GEOMAlgo/GEOMAlgo_Gluer.jxx @@ -7,6 +7,12 @@ #ifndef _TopoDS_Face_HeaderFile #include #endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Vertex_HeaderFile +#include +#endif #ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile #include #endif diff --git a/src/GEOMAlgo/GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx b/src/GEOMAlgo/GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx new file mode 100644 index 000000000..34977eb5e --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx @@ -0,0 +1,131 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_HeaderFile +#define _GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoMoreObject; +class Standard_NoSuchObject; +class GEOMAlgo_ListOfCoupleOfShapes; +class GEOMAlgo_CoupleOfShapes; +class GEOMAlgo_ListNodeOfListOfCoupleOfShapes; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_ListIteratorOfListOfCoupleOfShapes { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT GEOMAlgo_ListIteratorOfListOfCoupleOfShapes(); +Standard_EXPORT GEOMAlgo_ListIteratorOfListOfCoupleOfShapes(const GEOMAlgo_ListOfCoupleOfShapes& L); +Standard_EXPORT void Initialize(const GEOMAlgo_ListOfCoupleOfShapes& L) ; + Standard_Boolean More() const; +Standard_EXPORT void Next() ; +Standard_EXPORT GEOMAlgo_CoupleOfShapes& Value() const; + + +friend class GEOMAlgo_ListOfCoupleOfShapes; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Address current; +Standard_Address previous; + + +}; + +#define Item GEOMAlgo_CoupleOfShapes +#define Item_hxx +#define TCollection_ListNode GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_hxx +#define TCollection_ListIterator GEOMAlgo_ListIteratorOfListOfCoupleOfShapes +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_Type_() GEOMAlgo_ListNodeOfListOfCoupleOfShapes_Type_() +#define TCollection_List GEOMAlgo_ListOfCoupleOfShapes +#define TCollection_List_hxx + +#include + +#undef Item +#undef Item_hxx +#undef TCollection_ListNode +#undef TCollection_ListNode_hxx +#undef TCollection_ListIterator +#undef TCollection_ListIterator_hxx +#undef Handle_TCollection_ListNode +#undef TCollection_ListNode_Type_ +#undef TCollection_List +#undef TCollection_List_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_0.cxx b/src/GEOMAlgo/GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_0.cxx new file mode 100644 index 000000000..ee6cbdb6d --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_0.cxx @@ -0,0 +1,52 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + +#ifndef _Standard_NoMoreObject_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_ListOfCoupleOfShapes_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_CoupleOfShapes_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_ListNodeOfListOfCoupleOfShapes_HeaderFile +#include +#endif + + +#define Item GEOMAlgo_CoupleOfShapes +#define Item_hxx +#define TCollection_ListNode GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_hxx +#define TCollection_ListIterator GEOMAlgo_ListIteratorOfListOfCoupleOfShapes +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_Type_() GEOMAlgo_ListNodeOfListOfCoupleOfShapes_Type_() +#define TCollection_List GEOMAlgo_ListOfCoupleOfShapes +#define TCollection_List_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_ListNodeOfListOfCoupleOfShapes.hxx b/src/GEOMAlgo/GEOMAlgo_ListNodeOfListOfCoupleOfShapes.hxx new file mode 100644 index 000000000..ef078a2eb --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ListNodeOfListOfCoupleOfShapes.hxx @@ -0,0 +1,130 @@ +// File generated by CPPExt (Transient) +// +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_ListNodeOfListOfCoupleOfShapes_HeaderFile +#define _GEOMAlgo_ListNodeOfListOfCoupleOfShapes_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes_HeaderFile +#include +#endif + +#ifndef _GEOMAlgo_CoupleOfShapes_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class GEOMAlgo_CoupleOfShapes; +class GEOMAlgo_ListOfCoupleOfShapes; +class GEOMAlgo_ListIteratorOfListOfCoupleOfShapes; + + +class GEOMAlgo_ListNodeOfListOfCoupleOfShapes : public TCollection_MapNode { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +GEOMAlgo_ListNodeOfListOfCoupleOfShapes(const GEOMAlgo_CoupleOfShapes& I,const TCollection_MapNodePtr& n); + GEOMAlgo_CoupleOfShapes& Value() const; +Standard_EXPORT ~GEOMAlgo_ListNodeOfListOfCoupleOfShapes(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOMAlgo_ListNodeOfListOfCoupleOfShapes_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +GEOMAlgo_CoupleOfShapes myValue; + + +}; + +#define Item GEOMAlgo_CoupleOfShapes +#define Item_hxx +#define TCollection_ListNode GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_hxx +#define TCollection_ListIterator GEOMAlgo_ListIteratorOfListOfCoupleOfShapes +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_Type_() GEOMAlgo_ListNodeOfListOfCoupleOfShapes_Type_() +#define TCollection_List GEOMAlgo_ListOfCoupleOfShapes +#define TCollection_List_hxx + +#include + +#undef Item +#undef Item_hxx +#undef TCollection_ListNode +#undef TCollection_ListNode_hxx +#undef TCollection_ListIterator +#undef TCollection_ListIterator_hxx +#undef Handle_TCollection_ListNode +#undef TCollection_ListNode_Type_ +#undef TCollection_List +#undef TCollection_List_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_ListNodeOfListOfCoupleOfShapes_0.cxx b/src/GEOMAlgo/GEOMAlgo_ListNodeOfListOfCoupleOfShapes_0.cxx new file mode 100644 index 000000000..78fd962da --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ListNodeOfListOfCoupleOfShapes_0.cxx @@ -0,0 +1,98 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _GEOMAlgo_CoupleOfShapes_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_ListOfCoupleOfShapes_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_HeaderFile +#include +#endif +GEOMAlgo_ListNodeOfListOfCoupleOfShapes::~GEOMAlgo_ListNodeOfListOfCoupleOfShapes() {} + + + +Standard_EXPORT Handle_Standard_Type& GEOMAlgo_ListNodeOfListOfCoupleOfShapes_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("GEOMAlgo_ListNodeOfListOfCoupleOfShapes", + sizeof(GEOMAlgo_ListNodeOfListOfCoupleOfShapes), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes) Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMAlgo_ListNodeOfListOfCoupleOfShapes))) { + _anOtherObject = Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)((Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& GEOMAlgo_ListNodeOfListOfCoupleOfShapes::DynamicType() const +{ + return STANDARD_TYPE(GEOMAlgo_ListNodeOfListOfCoupleOfShapes) ; +} +Standard_Boolean GEOMAlgo_ListNodeOfListOfCoupleOfShapes::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(GEOMAlgo_ListNodeOfListOfCoupleOfShapes) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes::~Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes() {} +#define Item GEOMAlgo_CoupleOfShapes +#define Item_hxx +#define TCollection_ListNode GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_hxx +#define TCollection_ListIterator GEOMAlgo_ListIteratorOfListOfCoupleOfShapes +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_Type_() GEOMAlgo_ListNodeOfListOfCoupleOfShapes_Type_() +#define TCollection_List GEOMAlgo_ListOfCoupleOfShapes +#define TCollection_List_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_ListOfCoupleOfShapes.hxx b/src/GEOMAlgo/GEOMAlgo_ListOfCoupleOfShapes.hxx new file mode 100644 index 000000000..a8bb21f1e --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ListOfCoupleOfShapes.hxx @@ -0,0 +1,157 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_ListOfCoupleOfShapes_HeaderFile +#define _GEOMAlgo_ListOfCoupleOfShapes_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class GEOMAlgo_ListIteratorOfListOfCoupleOfShapes; +class GEOMAlgo_CoupleOfShapes; +class GEOMAlgo_ListNodeOfListOfCoupleOfShapes; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_ListOfCoupleOfShapes { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT GEOMAlgo_ListOfCoupleOfShapes(); +Standard_EXPORT void Assign(const GEOMAlgo_ListOfCoupleOfShapes& Other) ; + void operator=(const GEOMAlgo_ListOfCoupleOfShapes& Other) +{ + Assign(Other); +} + +Standard_EXPORT Standard_Integer Extent() const; +Standard_EXPORT void Clear() ; +~GEOMAlgo_ListOfCoupleOfShapes() +{ + Clear(); +} + + Standard_Boolean IsEmpty() const; +Standard_EXPORT void Prepend(const GEOMAlgo_CoupleOfShapes& I) ; +Standard_EXPORT void Prepend(const GEOMAlgo_CoupleOfShapes& I,GEOMAlgo_ListIteratorOfListOfCoupleOfShapes& theIt) ; +Standard_EXPORT void Prepend(GEOMAlgo_ListOfCoupleOfShapes& Other) ; +Standard_EXPORT void Append(const GEOMAlgo_CoupleOfShapes& I) ; +Standard_EXPORT void Append(const GEOMAlgo_CoupleOfShapes& I,GEOMAlgo_ListIteratorOfListOfCoupleOfShapes& theIt) ; +Standard_EXPORT void Append(GEOMAlgo_ListOfCoupleOfShapes& Other) ; +Standard_EXPORT GEOMAlgo_CoupleOfShapes& First() const; +Standard_EXPORT GEOMAlgo_CoupleOfShapes& Last() const; +Standard_EXPORT void RemoveFirst() ; +Standard_EXPORT void Remove(GEOMAlgo_ListIteratorOfListOfCoupleOfShapes& It) ; +Standard_EXPORT void InsertBefore(const GEOMAlgo_CoupleOfShapes& I,GEOMAlgo_ListIteratorOfListOfCoupleOfShapes& It) ; +Standard_EXPORT void InsertBefore(GEOMAlgo_ListOfCoupleOfShapes& Other,GEOMAlgo_ListIteratorOfListOfCoupleOfShapes& It) ; +Standard_EXPORT void InsertAfter(const GEOMAlgo_CoupleOfShapes& I,GEOMAlgo_ListIteratorOfListOfCoupleOfShapes& It) ; +Standard_EXPORT void InsertAfter(GEOMAlgo_ListOfCoupleOfShapes& Other,GEOMAlgo_ListIteratorOfListOfCoupleOfShapes& It) ; + + +friend class GEOMAlgo_ListIteratorOfListOfCoupleOfShapes; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT GEOMAlgo_ListOfCoupleOfShapes(const GEOMAlgo_ListOfCoupleOfShapes& Other); + + + // Fields PRIVATE + // +Standard_Address myFirst; +Standard_Address myLast; + + +}; + +#define Item GEOMAlgo_CoupleOfShapes +#define Item_hxx +#define TCollection_ListNode GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_hxx +#define TCollection_ListIterator GEOMAlgo_ListIteratorOfListOfCoupleOfShapes +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_Type_() GEOMAlgo_ListNodeOfListOfCoupleOfShapes_Type_() +#define TCollection_List GEOMAlgo_ListOfCoupleOfShapes +#define TCollection_List_hxx + +#include + +#undef Item +#undef Item_hxx +#undef TCollection_ListNode +#undef TCollection_ListNode_hxx +#undef TCollection_ListIterator +#undef TCollection_ListIterator_hxx +#undef Handle_TCollection_ListNode +#undef TCollection_ListNode_Type_ +#undef TCollection_List +#undef TCollection_List_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_ListOfCoupleOfShapes_0.cxx b/src/GEOMAlgo/GEOMAlgo_ListOfCoupleOfShapes_0.cxx new file mode 100644 index 000000000..2630fd011 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ListOfCoupleOfShapes_0.cxx @@ -0,0 +1,49 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_CoupleOfShapes_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_ListNodeOfListOfCoupleOfShapes_HeaderFile +#include +#endif + + +#define Item GEOMAlgo_CoupleOfShapes +#define Item_hxx +#define TCollection_ListNode GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_hxx +#define TCollection_ListIterator GEOMAlgo_ListIteratorOfListOfCoupleOfShapes +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes +#define TCollection_ListNode_Type_() GEOMAlgo_ListNodeOfListOfCoupleOfShapes_Type_() +#define TCollection_List GEOMAlgo_ListOfCoupleOfShapes +#define TCollection_List_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cdl b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cdl new file mode 100644 index 000000000..8c78910e2 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cdl @@ -0,0 +1,49 @@ +-- File: GEOMAlgo_ShapeSolid.cdl +-- Created: Thu Jan 13 12:44:07 2005 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2005 + + +deferred class ShapeSolid from GEOMAlgo + inherits Algo from GEOMAlgo + + ---Purpose: + +uses + ListOfShape from TopTools, + State from GEOMAlgo, + PDSFiller from BOPTools, + DSFiller from BOPTools +--raises + +is + Initialize + returns ShapeSolid from GEOMAlgo; + + + SetFiller(me:out; + aDSF:DSFiller from BOPTools); + ---C++: alias "Standard_EXPORT virtual ~GEOMAlgo_ShapeSolid();" + + Shapes(me; + aState:State from GEOMAlgo) + returns ListOfShape from TopTools; + ---C++: return const & + + BuildResult (me:out) + is deferred protected; + + Prepare(me:out) + is deferred protected; + +fields + myLSIN : ListOfShape from TopTools is protected; + myLSOUT : ListOfShape from TopTools is protected; + myLSON : ListOfShape from TopTools is protected; + + myLS : ListOfShape from TopTools is protected; + myRank : Integer from Standard is protected; + myDSFiller : PDSFiller from BOPTools is protected; + +end ShapeSolid; diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cxx b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cxx new file mode 100644 index 000000000..72ed66f46 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.cxx @@ -0,0 +1,114 @@ +// File: GEOMAlgo_ShapeSolid.cxx +// Created: Thu Jan 13 12:54:48 2005 +// Author: Peter KURNEV +// + + +#include + +#include +#include + +//======================================================================= +//function : GEOMAlgo_ShapeSolid +//purpose : +//======================================================================= +GEOMAlgo_ShapeSolid::GEOMAlgo_ShapeSolid() +: + GEOMAlgo_Algo(), + myRank(0), + myDSFiller(NULL) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_ShapeSolid::~GEOMAlgo_ShapeSolid() +{ +} +//======================================================================= +//function : SetFiller +//purpose : +//======================================================================= +void GEOMAlgo_ShapeSolid::SetFiller(const BOPTools_DSFiller& aDSFiller) +{ + myDSFiller=(BOPTools_DSFiller*) &aDSFiller; +} + +//======================================================================= +// function: Shapes +// purpose: +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_ShapeSolid::Shapes(const GEOMAlgo_State aState) const +{ + TopTools_ListIteratorOfListOfShape aIt; + // + TopTools_ListOfShape* pLS=(TopTools_ListOfShape*)&myLS; + // + pLS->Clear(); + // + switch (aState) { + case GEOMAlgo_ST_IN: { + aIt.Initialize(myLSIN); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + pLS->Append(aS); + } + } + break; + // + case GEOMAlgo_ST_OUT: { + aIt.Initialize(myLSOUT); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + pLS->Append(aS); + } + } + break; + // + case GEOMAlgo_ST_ON: { + aIt.Initialize(myLSON); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + pLS->Append(aS); + } + } + break; + // + case GEOMAlgo_ST_ONIN: { + aIt.Initialize(myLSON); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + pLS->Append(aS); + } + aIt.Initialize(myLSIN); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + pLS->Append(aS); + } + } + break; + // + case GEOMAlgo_ST_ONOUT: { + aIt.Initialize(myLSON); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + pLS->Append(aS); + } + aIt.Initialize(myLSOUT); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + pLS->Append(aS); + } + } + break; + // + case GEOMAlgo_ST_UNKNOWN: + case GEOMAlgo_ST_INOUT: + default: + break; + } + return myLS; +} + diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.hxx b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.hxx new file mode 100644 index 000000000..050c7b552 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.hxx @@ -0,0 +1,116 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_ShapeSolid_HeaderFile +#define _GEOMAlgo_ShapeSolid_HeaderFile + +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _BOPTools_PDSFiller_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_Algo_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_State_HeaderFile +#include +#endif +class BOPTools_DSFiller; +class TopTools_ListOfShape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_ShapeSolid : public GEOMAlgo_Algo { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT void SetFiller(const BOPTools_DSFiller& aDSF) ; +Standard_EXPORT virtual ~GEOMAlgo_ShapeSolid(); +Standard_EXPORT const TopTools_ListOfShape& Shapes(const GEOMAlgo_State aState) const; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT GEOMAlgo_ShapeSolid(); +Standard_EXPORT virtual void BuildResult() = 0; +Standard_EXPORT virtual void Prepare() = 0; + + + // Fields PROTECTED + // +TopTools_ListOfShape myLSIN; +TopTools_ListOfShape myLSOUT; +TopTools_ListOfShape myLSON; +TopTools_ListOfShape myLS; +Standard_Integer myRank; +BOPTools_PDSFiller myDSFiller; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.ixx b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.ixx new file mode 100644 index 000000000..1ef447531 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/GEOMAlgo_ShapeSolid.jxx b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.jxx new file mode 100644 index 000000000..d0cdc370f --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ShapeSolid.jxx @@ -0,0 +1,9 @@ +#ifndef _BOPTools_DSFiller_HeaderFile +#include +#endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_ShapeSolid_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_ShellSolid.cdl b/src/GEOMAlgo/GEOMAlgo_ShellSolid.cdl new file mode 100644 index 000000000..7489b6a96 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ShellSolid.cdl @@ -0,0 +1,34 @@ +-- File: GEOMAlgo_ShellSolid.cdl +-- Created: Wed Jan 12 12:45:20 2005 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2005 + + +class ShellSolid from GEOMAlgo + inherits ShapeSolid from GEOMAlgo + ---Purpose: + +--uses +--raises + +is + Create + returns ShellSolid from GEOMAlgo; + ---C++: alias "Standard_EXPORT virtual ~GEOMAlgo_ShellSolid();" + + Perform (me:out) + is redefined; + + Prepare(me:out) + is redefined protected; + + BuildResult (me:out) + is redefined protected; + + DetectSDFaces(me:out) + is protected; + +--fields + +end ShellSolid; diff --git a/src/GEOMAlgo/GEOMAlgo_ShellSolid.cxx b/src/GEOMAlgo/GEOMAlgo_ShellSolid.cxx new file mode 100644 index 000000000..cd53db7fe --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ShellSolid.cxx @@ -0,0 +1,416 @@ +// File: GEOMAlgo_ShellSolid.cxx +// Created: Wed Jan 12 12:49:45 2005 +// Author: Peter KURNEV +// + + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static + Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, + const TopoDS_Face& theFace2); + +//======================================================================= +//function : GEOMAlgo_ShellSolid +//purpose : +//======================================================================= +GEOMAlgo_ShellSolid::GEOMAlgo_ShellSolid() +: + GEOMAlgo_ShapeSolid() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_ShellSolid::~GEOMAlgo_ShellSolid() +{ +} +//======================================================================= +// function: +// purpose: +//======================================================================= +void GEOMAlgo_ShellSolid::Perform() +{ + myErrorStatus=0; + // + try { + if (myDSFiller==NULL) { + myErrorStatus=10; + return; + } + if(!myDSFiller->IsDone()) { + myErrorStatus=11; + return; + } + // + Standard_Boolean bIsNewFiller; + // + bIsNewFiller=myDSFiller->IsNewFiller(); + if (bIsNewFiller) { + Prepare(); + myDSFiller->SetNewFiller(!bIsNewFiller); + } + // + myRank=(myDSFiller->DS().Object().ShapeType()==TopAbs_SHELL) ? 1 : 2; + BuildResult(); + } + catch (Standard_Failure) { + myErrorStatus=12; + } +} +//======================================================================= +// function: Prepare +// purpose: +//======================================================================= +void GEOMAlgo_ShellSolid::Prepare() +{ + const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); + // + // 1 States + BOPTools_SolidStateFiller aStateFiller(aPaveFiller); + aStateFiller.Do(); + // + // 2 Project section edges on corresp. faces -> P-Curves on edges. + BOPTools_PCurveMaker aPCurveMaker(aPaveFiller); + aPCurveMaker.Do(); + // + // 3. Degenerated Edges Processing + BOPTools_DEProcessor aDEProcessor(aPaveFiller); + aDEProcessor.Do(); + // + // 4. Detect Same Domain Faces + DetectSDFaces(); +} +//================================================================================= +// function: BuildResult +// purpose: +//================================================================================= +void GEOMAlgo_ShellSolid::BuildResult() +{ + Standard_Boolean bIsTouchCase; + Standard_Integer i, j, nF1, nF2, aNbFFs, aNbS, aNbCurves, nSp, iRank1; + Standard_Integer nE, nF, aNbPB, iBeg, iEnd; + BooleanOperations_StateOfShape aState; + TopExp_Explorer anExp; + TopAbs_ShapeEnum aType; + gp_Pnt2d aP2D; + gp_Pnt aP3D; + // + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + const BOPTools_InterferencePool& anInterfPool=myDSFiller->InterfPool(); + BOPTools_InterferencePool* pInterfPool=(BOPTools_InterferencePool*) &anInterfPool; + BOPTools_CArray1OfSSInterference& aFFs=pInterfPool->SSInterferences(); + const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); + const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); + // + // 1. process pf non-interferring faces + iBeg=1; + iEnd=aDS.NumberOfShapesOfTheObject(); + if (myRank==2) { + iBeg=iEnd+1; + iEnd=aDS.NumberOfSourceShapes(); + } + // + for (i=iBeg; i<=iEnd; ++i) { + aType=aDS.GetShapeType(i); + if (aType!=TopAbs_FACE) { + continue; + } + // + const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(i)); + aState=aDS.GetState(i); + if (aState==BooleanOperations_IN) { + myLSIN.Append(aF1); + } + else if (aState==BooleanOperations_OUT) { + myLSOUT.Append(aF1); + } + } + // + // 2. process pf interferred faces + aNbFFs=aFFs.Extent(); + for (i=1; i<=aNbFFs; ++i) { + BOPTools_SSInterference& aFFi=aFFs(i); + // + nF1=aFFi.Index1(); + nF2=aFFi.Index2(); + iRank1=aDS.Rank(nF1); + nF=(iRank1==myRank) ? nF1 : nF2; + const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF)); + // + bIsTouchCase=aFFi.IsTangentFaces(); + // + if (bIsTouchCase) { + myLSON.Append(aF1); + continue; + } + // + // Has section edges ? + aNbS=0; + BOPTools_SequenceOfCurves& aBCurves=aFFi.Curves(); + aNbCurves=aBCurves.Length(); + for (j=1; j<=aNbCurves; j++) { + BOPTools_Curve& aBC=aBCurves(j); + const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks(); + aNbS=aSectEdges.Extent(); + if (aNbS) { + break; + } + } + // + if (aNbS) { // it has + continue; + } + // + anExp.Init(aF1, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current()); + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + nE=aDS.ShapeIndex(aE, myRank); + const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(nE)); + aNbPB=aLPB.Extent(); + // + if (aNbPB<2) { + nSp=nE; + if (aNbPB) { + const BOPTools_PaveBlock& aPB=aLPB.First(); + nSp=aPB.Edge(); + } + const TopoDS_Shape& aSp=aDS.Shape(nSp); + // + aState=aDS.GetState(nSp); + if (aState==BooleanOperations_IN) { + myLSIN.Append(aF1); + } + else if (aState==BooleanOperations_OUT) { + myLSOUT.Append(aF1); + } + else if (aState==BooleanOperations_ON) { + Standard_Real aTol; + TopAbs_State aSt; + // + //const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape((iRank1==myRank)? nF2 : nF1)); + //aTol=BRep_Tool::Tolerance(aF2); + aTol=1.e-7; + // + BOPTools_Tools3D::PointNearEdge(aE, aF1, aP2D, aP3D); + const TopoDS_Solid& aRefSolid=(myRank==1) ? + TopoDS::Solid(aDS.Tool()) : TopoDS::Solid(aDS.Object()); + // + BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)& aPaveFiller; + IntTools_Context& aCtx=pPF->ChangeContext(); + // + BRepClass3d_SolidClassifier& aSC=aCtx.SolidClassifier(aRefSolid); + aSC.Perform(aP3D, aTol); + aSt=aSC.State(); + if (aSt==TopAbs_IN) { + myLSIN.Append(aF1); + } + else if (aSt==TopAbs_OUT) { + myLSOUT.Append(aF1); + } + } + break; + } // if (aNbPB<2) { + } //for (; anExp.More(); anExp.Next()) + } +} +//======================================================================= +// function: DetectSDFaces +// purpose: +//======================================================================= +void GEOMAlgo_ShellSolid::DetectSDFaces() +{ + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); + BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); + // + Standard_Boolean bFlag; + Standard_Integer i, aNb, nF1, nF2, iZone, aNbSps, iSenseFlag; + gp_Dir aDNF1, aDNF2; + + aNb=aFFs.Extent(); + for (i=1; i<=aNb; i++) { + bFlag=Standard_False; + + BOPTools_SSInterference& aFF=aFFs(i); + + nF1=aFF.Index1(); + nF2=aFF.Index2(); + const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); + const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); + // + // iSenseFlag; + const BOPTools_ListOfPaveBlock& aLPB=aFF.PaveBlocks(); + aNbSps=aLPB.Extent(); + + if (!aNbSps) { + continue; + } + + const BOPTools_PaveBlock& aPB=aLPB.First(); + const TopoDS_Edge& aSpE=TopoDS::Edge(aDS.Shape(aPB.Edge())); + + BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aF1, aDNF1); + BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aF2, aDNF2); + iSenseFlag=BOPTools_Tools3D::SenseFlag (aDNF1, aDNF2); + // + if (iSenseFlag==1 || iSenseFlag==-1) { + // + // + TopoDS_Face aF1FWD=aF1; + aF1FWD.Orientation (TopAbs_FORWARD); + + BOP_WireEdgeSet aWES (aF1FWD); + BOP_SDFWESFiller aWESFiller(nF1, nF2, *myDSFiller); + aWESFiller.SetSenseFlag(iSenseFlag); + aWESFiller.SetOperation(BOP_COMMON); + aWESFiller.Do(aWES); + + BOP_FaceBuilder aFB; + aFB.Do(aWES); + const TopTools_ListOfShape& aLF=aFB.NewFaces(); + + iZone=0; + TopTools_ListIteratorOfListOfShape anIt(aLF); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aFR=anIt.Value(); + + if (aFR.ShapeType()==TopAbs_FACE) { + const TopoDS_Face& aFaceResult=TopoDS::Face(aFR); + // + Standard_Boolean bIsValidIn2D, bNegativeFlag; + bIsValidIn2D=BOPTools_Tools3D::IsValidArea (aFaceResult, bNegativeFlag); + if (bIsValidIn2D) { + if(CheckSameDomainFaceInside(aFaceResult, aF2)) { + iZone=1; + break; + } + } + // + } + } + + if (iZone) { + bFlag=Standard_True; + aFF.SetStatesMap(aWESFiller.StatesMap()); + } + + }// if (iSenseFlag) + + aFF.SetTangentFacesFlag(bFlag); + aFF.SetSenseFlag (iSenseFlag); + }// end of for (i=1; i<=aNb; i++) +} +//======================================================================= +//function : CheckSameDomainFaceInside +//purpose : +//======================================================================= +Standard_Boolean CheckSameDomainFaceInside(const TopoDS_Face& theFace1, + const TopoDS_Face& theFace2) +{ + Standard_Real umin = 0., umax = 0., vmin = 0., vmax = 0.; + BRepTools::UVBounds(theFace1, umin, umax, vmin, vmax); + IntTools_Context aContext; + Handle(Geom_Surface) aSurface = BRep_Tool::Surface(theFace1); + Standard_Real aTolerance = BRep_Tool::Tolerance(theFace1); + + TopExp_Explorer anExpE(theFace1, TopAbs_EDGE); + + for(; anExpE.More(); anExpE.Next()) { + const TopoDS_Edge& anEdge = TopoDS::Edge(anExpE.Current()); + Standard_Real anEdgeTol = BRep_Tool::Tolerance(anEdge); + aTolerance = (aTolerance < anEdgeTol) ? anEdgeTol : aTolerance; + } + aTolerance += BRep_Tool::Tolerance(theFace2); + + Standard_Integer nbpoints = 5; + Standard_Real adeltau = (umax - umin) / (nbpoints + 1); + Standard_Real adeltav = (vmax - vmin) / (nbpoints + 1); + Standard_Real U = umin + adeltau; + GeomAPI_ProjectPointOnSurf& aProjector = aContext.ProjPS(theFace2); + + for(Standard_Integer i = 1; i <= nbpoints; i++, U+=adeltau) { + Standard_Real V = vmin + adeltav; + + for(Standard_Integer j = 1; j <= nbpoints; j++, V+=adeltav) { + gp_Pnt2d aPoint(U,V); + + if(aContext.IsPointInFace(theFace1, aPoint)) { + gp_Pnt aP3d = aSurface->Value(U, V); + aProjector.Perform(aP3d); + + if(aProjector.IsDone()) { + + if(aProjector.LowerDistance() > aTolerance) + return Standard_False; + } + } + } + } + + return Standard_True; +} diff --git a/src/GEOMAlgo/GEOMAlgo_ShellSolid.hxx b/src/GEOMAlgo/GEOMAlgo_ShellSolid.hxx new file mode 100644 index 000000000..16415ecc7 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ShellSolid.hxx @@ -0,0 +1,96 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_ShellSolid_HeaderFile +#define _GEOMAlgo_ShellSolid_HeaderFile + +#ifndef _GEOMAlgo_ShapeSolid_HeaderFile +#include +#endif + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_ShellSolid : public GEOMAlgo_ShapeSolid { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT GEOMAlgo_ShellSolid(); +Standard_EXPORT virtual ~GEOMAlgo_ShellSolid(); +Standard_EXPORT virtual void Perform() ; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT virtual void Prepare() ; +Standard_EXPORT virtual void BuildResult() ; +Standard_EXPORT void DetectSDFaces() ; + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_ShellSolid.ixx b/src/GEOMAlgo/GEOMAlgo_ShellSolid.ixx new file mode 100644 index 000000000..f5b12e14e --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ShellSolid.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/GEOMAlgo_ShellSolid.jxx b/src/GEOMAlgo/GEOMAlgo_ShellSolid.jxx new file mode 100644 index 000000000..e9afe6d41 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_ShellSolid.jxx @@ -0,0 +1,3 @@ +#ifndef _GEOMAlgo_ShellSolid_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_State.hxx b/src/GEOMAlgo/GEOMAlgo_State.hxx new file mode 100644 index 000000000..e1a164c9f --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_State.hxx @@ -0,0 +1,40 @@ +// File generated by CPPExt (Enum) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_State_HeaderFile +#define _GEOMAlgo_State_HeaderFile + +enum GEOMAlgo_State { + GEOMAlgo_ST_UNKNOWN, +GEOMAlgo_ST_IN, +GEOMAlgo_ST_OUT, +GEOMAlgo_ST_ON, +GEOMAlgo_ST_ONIN, +GEOMAlgo_ST_ONOUT, +GEOMAlgo_ST_INOUT +}; + + +#ifndef _Standard_PrimitiveTypes_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_Tools.cdl b/src/GEOMAlgo/GEOMAlgo_Tools.cdl index ac4ea7f7f..54b4c0327 100644 --- a/src/GEOMAlgo/GEOMAlgo_Tools.cdl +++ b/src/GEOMAlgo/GEOMAlgo_Tools.cdl @@ -10,7 +10,8 @@ class Tools from GEOMAlgo ---Purpose: uses - Pnt from gp, + Pnt from gp, + Surface from Geom, Edge from TopoDS, Face from TopoDS, Shape from TopoDS, @@ -72,6 +73,16 @@ is aU :Real from Standard; aV :Real from Standard; aP3D:out Pnt from gp); + + RefinePCurveForEdgeOnFace (myclass; + aE : Edge from TopoDS; + aF : Face from TopoDS; + aU1 : Real from Standard; + aU2 : Real from Standard); + + IsUPeriodic(myclass; + aS:Surface from Geom) + returns Boolean from Standard; --fields end Tools; diff --git a/src/GEOMAlgo/GEOMAlgo_Tools.cxx b/src/GEOMAlgo/GEOMAlgo_Tools.cxx index 452fc7a43..97bdbb03e 100644 --- a/src/GEOMAlgo/GEOMAlgo_Tools.cxx +++ b/src/GEOMAlgo/GEOMAlgo_Tools.cxx @@ -6,9 +6,12 @@ #include #include +#include #include #include +#include +#include #include @@ -23,7 +26,7 @@ #include #include -#include +#include #include #include @@ -31,7 +34,7 @@ #include #include - +// //======================================================================= //function : RefineSDShapes //purpose : @@ -48,8 +51,8 @@ Standard_Integer GEOMAlgo_Tools::RefineSDShapes(GEOMAlgo_IndexedDataMapOfPassKey aNbE=aMPKLE.Extent(); for (i=1; i<=aNbE; ++i) { TopTools_ListOfShape& aLSDE=aMPKLE.ChangeFromIndex(i); - aMEE.Clear(); // + aMEE.Clear(); iErr=GEOMAlgo_Tools::FindSDShapes(aLSDE, aTol, aMEE, aCtx); if (iErr) { return iErr; @@ -104,11 +107,17 @@ Standard_Integer GEOMAlgo_Tools::FindSDShapes(const TopTools_ListOfShape& aLE, TopTools_ListOfShape aLESD; TopTools_ListIteratorOfListOfShape aIt, aIt1; TopTools_IndexedMapOfShape aMProcessed; + TopAbs_ShapeEnum aType; // aNbE=aLE.Extent(); if (!aNbE) { return 3; // Err - } + } + //modified by NIZNHY-PKV Thu Dec 30 10:56:52 2004 f + if (aNbE==1) { + return 0; // Nothing to do + } + //modified by NIZNHY-PKV Thu Dec 30 10:56:56 2004 t // while(1) { aNbEProcessed=aMProcessed.Extent(); @@ -119,10 +128,22 @@ Standard_Integer GEOMAlgo_Tools::FindSDShapes(const TopTools_ListOfShape& aLE, aIt.Initialize(aLE); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aS=aIt.Value(); + // if (aMProcessed.Contains(aS)) { continue; } // + //modified by NIZNHY-PKV Thu Dec 30 10:57:01 2004 f + aType=aS.ShapeType(); + if (aType==TopAbs_EDGE) { + const TopoDS_Edge& aE=TopoDS::Edge(aS); + if (BRep_Tool::Degenerated(aE)) { + aMProcessed.Add(aE); + continue; + } + } + //modified by NIZNHY-PKV Thu Dec 30 10:57:03 2004 t + // aLESD.Clear(); iErr=GEOMAlgo_Tools::FindSDShapes(aS, aLE, aTol, aLESD, aCtx); if (iErr) { @@ -314,84 +335,55 @@ void GEOMAlgo_Tools::PointOnEdge(const TopoDS_Edge& aE, aC3D=BRep_Tool::Curve(aE, aT1, aT2); aC3D->D0(aT, aP3D); } -/* //======================================================================= -//function : FindSDEdges +//function : RefinePCurveForEdgeOnFace //purpose : //======================================================================= -Standard_Integer GEOMAlgo_Tools::FindSDEdges(const TopoDS_Edge& aE1, - const TopTools_ListOfShape& aLE, - const Standard_Real aTol, - TopTools_ListOfShape& aLESD, - IntTools_Context& aCtx) +void GEOMAlgo_Tools::RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Standard_Real aUMin, + const Standard_Real aUMax) { - Standard_Boolean bIsDone; - Standard_Real aT2, aTol2, aD2; - gp_Pnt aP1, aP2; - TopTools_ListIteratorOfListOfShape aIt; + Standard_Real aT1, aT2, aTx, aUx, aTol, aTwoPI; + gp_Pnt2d aP2D; + Handle(Geom_Surface) aS; + Handle(Geom2d_Curve) aC2D; + BRep_Builder aBB; // - aTol2=aTol*aTol; + aTwoPI=PI+PI; // - GEOMAlgo_Tools::PointOnEdge(aE1, aP1); - aIt.Initialize(aLE); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Edge& aE2=TopoDS::Edge(aIt.Value()); - if (aE2.IsSame(aE1)) { - aLESD.Append(aE2); + aC2D=BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2); + if (!aC2D.IsNull()) { + if (BRep_Tool::IsClosed(aE, aF)) { + return; } - else { - bIsDone=aCtx.ProjectPointOnEdge(aP1, aE2, aT2); - if (!bIsDone) { - return 1; - } - GEOMAlgo_Tools::PointOnEdge(aE2, aT2, aP2); - aD2=aP1.SquareDistance(aP2); - if(aD2D0(aTx, aP2D); + aUx=aP2D.X(); + if (aUx < aUMin || aUx > aUMax) { + // need to rebuild + Handle(Geom2d_Curve) aC2Dx; + // + aTol=BRep_Tool::Tolerance(aE); + aBB.UpdateEdge(aE, aC2Dx, aF, aTol); } } - return 0; } //======================================================================= -//function : FindSDFaces +//function : IsUPeriodic //purpose : //======================================================================= -Standard_Integer GEOMAlgo_Tools::FindSDFaces(const TopoDS_Face& aF1, - const TopTools_ListOfShape& aLF, - const Standard_Real aTol, - TopTools_ListOfShape& aLFSD, - IntTools_Context& aCtx) +Standard_Boolean GEOMAlgo_Tools::IsUPeriodic(const Handle(Geom_Surface) &aS) { - Standard_Boolean bIsDone; - Standard_Real aTol2, aD2; - gp_Pnt aP1, aP2; - TopTools_ListIteratorOfListOfShape aIt; + Standard_Boolean bRet; + GeomAbs_SurfaceType aType; + GeomAdaptor_Surface aGAS; // - aTol2=aTol*aTol; + aGAS.Load(aS); + aType=aGAS.GetType(); + bRet=(aType==GeomAbs_Cylinder|| + aType==GeomAbs_Cone || + aType==GeomAbs_Sphere); // - GEOMAlgo_Tools::PointOnFace(aF1, aP1); - aIt.Initialize(aLF); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Face& aF2=TopoDS::Face(aIt.Value()); - if (aF2.IsSame(aF1)) { - aLFSD.Append(aF2); - } - else { - GeomAPI_ProjectPointOnSurf& aProj=aCtx.ProjPS(aF2); - aProj.Perform(aP1); - bIsDone=aProj.IsDone(); - if (!bIsDone) { - return 1; //?? - } - // - aP2=aProj.NearestPoint(); - aD2=aP1.SquareDistance(aP2); - if(aD2 #endif +#ifndef _Handle_Geom_Surface_HeaderFile +#include +#endif class GEOMAlgo_IndexedDataMapOfPassKeyListOfShape; class IntTools_Context; class TopTools_ListOfShape; @@ -39,6 +42,7 @@ class TopoDS_Shape; class gp_Pnt; class TopoDS_Edge; class TopoDS_Face; +class Geom_Surface; #ifndef _Standard_HeaderFile @@ -75,6 +79,8 @@ Standard_EXPORT static void PointOnEdge(const TopoDS_Edge& aE,gp_Pnt& aP3D) ; Standard_EXPORT static void PointOnEdge(const TopoDS_Edge& aE,const Standard_Real aT,gp_Pnt& aP3D) ; Standard_EXPORT static void PointOnFace(const TopoDS_Face& aF,gp_Pnt& aP3D) ; Standard_EXPORT static void PointOnFace(const TopoDS_Face& aF,const Standard_Real aU,const Standard_Real aV,gp_Pnt& aP3D) ; +Standard_EXPORT static void RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,const TopoDS_Face& aF,const Standard_Real aU1,const Standard_Real aU2) ; +Standard_EXPORT static Standard_Boolean IsUPeriodic(const Handle(Geom_Surface)& aS) ; diff --git a/src/GEOMAlgo/GEOMAlgo_Tools.jxx b/src/GEOMAlgo/GEOMAlgo_Tools.jxx index 5538d85d8..7c60f19bd 100644 --- a/src/GEOMAlgo/GEOMAlgo_Tools.jxx +++ b/src/GEOMAlgo/GEOMAlgo_Tools.jxx @@ -22,6 +22,9 @@ #ifndef _TopoDS_Face_HeaderFile #include #endif +#ifndef _Geom_Surface_HeaderFile +#include +#endif #ifndef _GEOMAlgo_Tools_HeaderFile #include #endif diff --git a/src/GEOMAlgo/GEOMAlgo_VertexSolid.cdl b/src/GEOMAlgo/GEOMAlgo_VertexSolid.cdl new file mode 100644 index 000000000..9a7c6232a --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_VertexSolid.cdl @@ -0,0 +1,32 @@ +-- File: GEOMAlgo_VertexSolid.cdl +-- Created: Wed Jan 12 16:34:53 2005 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2005 + + +class VertexSolid from GEOMAlgo + inherits ShapeSolid from GEOMAlgo + + ---Purpose: + +--uses +--raises + +is + Create + returns VertexSolid from GEOMAlgo; + ---C++: alias "Standard_EXPORT virtual ~GEOMAlgo_VertexSolid();" + + Perform (me:out) + is redefined; + + Prepare(me:out) + is redefined protected; + + BuildResult (me:out) + is redefined protected; + +--fields + +end VertexSolid; diff --git a/src/GEOMAlgo/GEOMAlgo_VertexSolid.cxx b/src/GEOMAlgo/GEOMAlgo_VertexSolid.cxx new file mode 100644 index 000000000..1257362ed --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_VertexSolid.cxx @@ -0,0 +1,219 @@ +// File: GEOMAlgo_VertexSolid.cxx +// Created: Wed Jan 12 16:36:40 2005 +// Author: Peter KURNEV +// + + +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_VertexSolid +//purpose : +//======================================================================= +GEOMAlgo_VertexSolid::GEOMAlgo_VertexSolid() +: + GEOMAlgo_ShapeSolid() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_VertexSolid::~GEOMAlgo_VertexSolid() +{ +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= +void GEOMAlgo_VertexSolid::Perform() +{ + myErrorStatus=0; + // + try { + if (myDSFiller==NULL) { + myErrorStatus=10; + return; + } + if(!myDSFiller->IsDone()) { + myErrorStatus=11; + return; + } + // + Standard_Boolean bIsNewFiller; + Standard_Integer aNbF; + TopTools_IndexedMapOfShape aM; + // + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + const TopoDS_Shape& aObj=aDS.Object(); + // + TopExp::MapShapes(aObj, TopAbs_FACE, aM); + aNbF=aM.Extent(); + myRank=(aNbF) ? 2 : 1; + // + bIsNewFiller=myDSFiller->IsNewFiller(); + + if (bIsNewFiller) { + Prepare(); + myDSFiller->SetNewFiller(!bIsNewFiller); + } + BuildResult(); + } + // + catch (Standard_Failure) { + myErrorStatus = 12; + } +} +//======================================================================= +// function: Prepare +// purpose: +//======================================================================= +void GEOMAlgo_VertexSolid::Prepare() +{ + Standard_Integer i, iBeg, iEnd, aNbVV, j, n1, n2, iFound; + Standard_Real aTol; + TopAbs_State aSt; + TopAbs_ShapeEnum aType; + BooleanOperations_StateOfShape aState; + gp_Pnt aP3D; + // + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + BooleanOperations_ShapesDataStructure* pDS=(BooleanOperations_ShapesDataStructure*)&aDS; + const BOPTools_InterferencePool& aIP=myDSFiller->InterfPool(); + BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*) &aIP; + BOPTools_CArray1OfVVInterference& aVVs=pIP->VVInterferences(); + const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller(); + BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF; + IntTools_Context& aCtx=pPF->ChangeContext(); + // + const TopoDS_Shape& aObj=aDS.Object(); + const TopoDS_Shape& aTool=aDS.Tool(); + // + const TopoDS_Solid& aSolid=(myRank==1) ? TopoDS::Solid(aTool) : TopoDS::Solid(aObj); + const TopoDS_Shape& aSV =(myRank==1)? aObj : aTool; + // + BRepClass3d_SolidClassifier& aSC=aCtx.SolidClassifier(aSolid); + // + iBeg=1; + iEnd=aDS.NumberOfShapesOfTheObject(); + if (myRank==2) { + iBeg=iEnd+1; + iEnd=aDS.NumberOfSourceShapes(); + } + // + for (i=iBeg; i<=iEnd; ++i) { + aType=aDS.GetShapeType(i); + if (aType!=TopAbs_VERTEX) { + continue; + } + // + const TopoDS_Vertex& aV=TopoDS::Vertex(aDS.Shape(i)); + // + aState=aDS.GetState(i); + if (aState==BooleanOperations_ON || + aState==BooleanOperations_IN || + aState==BooleanOperations_OUT) { + continue; + } + // + iFound=0; + aNbVV=aVVs.Extent(); + for (j=1; j<=aNbVV; ++j) { + BOPTools_VVInterference& aVV=aVVs(j); + aVV.Indices(n1, n2); + if (n1==i || n2==i) { + pDS->SetState (n1, BooleanOperations_ON); + pDS->SetState (n2, BooleanOperations_ON); + iFound=1; + break; + } + } + if (iFound) { + continue; + } + // + aP3D=BRep_Tool::Pnt(aV); + aTol=1.E-7; + aSC.Perform(aP3D, aTol); + aSt=aSC.State(); + if (aSt==TopAbs_IN) { + pDS->SetState (i, BooleanOperations_IN); + } + else if (aSt==TopAbs_OUT) { + pDS->SetState (i, BooleanOperations_OUT); + } + } +} +//======================================================================= +// function: BuildResult +// purpose: +//======================================================================= +void GEOMAlgo_VertexSolid::BuildResult() +{ + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + // + Standard_Integer i, iBeg, iEnd; + TopAbs_ShapeEnum aType; + BooleanOperations_StateOfShape aState; + // + myLSIN.Clear(); + myLSOUT.Clear(); + myLSON.Clear(); + // + iBeg=1; + iEnd=aDS.NumberOfShapesOfTheObject(); + if (myRank==2) { + iBeg=iEnd+1; + iEnd=aDS.NumberOfSourceShapes(); + } + // + for (i=iBeg; i<=iEnd; ++i) { + aType=aDS.GetShapeType(i); + if (aType!=TopAbs_VERTEX) { + continue; + } + const TopoDS_Shape& aV=aDS.Shape(i); + aState=aDS.GetState(i); + // + if (aState==BooleanOperations_IN) { + myLSIN.Append(aV); + } + else if (aState==BooleanOperations_OUT) { + myLSOUT.Append(aV); + } + else if (aState==BooleanOperations_ON) { + myLSON.Append(aV); + } + } +} diff --git a/src/GEOMAlgo/GEOMAlgo_VertexSolid.hxx b/src/GEOMAlgo/GEOMAlgo_VertexSolid.hxx new file mode 100644 index 000000000..103c7f2f6 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_VertexSolid.hxx @@ -0,0 +1,95 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_VertexSolid_HeaderFile +#define _GEOMAlgo_VertexSolid_HeaderFile + +#ifndef _GEOMAlgo_ShapeSolid_HeaderFile +#include +#endif + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_VertexSolid : public GEOMAlgo_ShapeSolid { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT GEOMAlgo_VertexSolid(); +Standard_EXPORT virtual ~GEOMAlgo_VertexSolid(); +Standard_EXPORT virtual void Perform() ; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT virtual void Prepare() ; +Standard_EXPORT virtual void BuildResult() ; + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_VertexSolid.ixx b/src/GEOMAlgo/GEOMAlgo_VertexSolid.ixx new file mode 100644 index 000000000..e2351fef2 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_VertexSolid.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/GEOMAlgo_VertexSolid.jxx b/src/GEOMAlgo/GEOMAlgo_VertexSolid.jxx new file mode 100644 index 000000000..8c7c253e9 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_VertexSolid.jxx @@ -0,0 +1,3 @@ +#ifndef _GEOMAlgo_VertexSolid_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_WireSolid.cdl b/src/GEOMAlgo/GEOMAlgo_WireSolid.cdl new file mode 100644 index 000000000..d85db1291 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_WireSolid.cdl @@ -0,0 +1,31 @@ +-- File: GEOMAlgo_WireSolid.cdl +-- Created: Wed Jan 12 10:17:00 2005 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2005 + + +class WireSolid from GEOMAlgo + inherits ShapeSolid from GEOMAlgo + ---Purpose: + +--uses +--raises + +is + Create + returns WireSolid from GEOMAlgo; + ---C++: alias "Standard_EXPORT virtual ~GEOMAlgo_WireSolid();" + + Perform (me:out) + is redefined; + + Prepare(me:out) + is redefined protected; + + BuildResult (me:out) + is redefined protected; + +--fields + +end WireSolid; diff --git a/src/GEOMAlgo/GEOMAlgo_WireSolid.cxx b/src/GEOMAlgo/GEOMAlgo_WireSolid.cxx new file mode 100644 index 000000000..faaf3612f --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_WireSolid.cxx @@ -0,0 +1,152 @@ +// File: GEOMAlgo_WireSolid.cxx +// Created: Wed Jan 12 10:19:31 2005 +// Author: Peter KURNEV +// + + +#include + +#include + +#include + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_WireSolid +//purpose : +//======================================================================= +GEOMAlgo_WireSolid::GEOMAlgo_WireSolid() +: + GEOMAlgo_ShapeSolid() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_WireSolid::~GEOMAlgo_WireSolid() +{ +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= +void GEOMAlgo_WireSolid::Perform() +{ + myErrorStatus=0; + // + try { + if (myDSFiller==NULL) { + myErrorStatus=10; + return; + } + if(!myDSFiller->IsDone()) { + myErrorStatus=11; + return; + } + // + Standard_Boolean bIsNewFiller; + // + bIsNewFiller=myDSFiller->IsNewFiller(); + + if (bIsNewFiller) { + Prepare(); + myDSFiller->SetNewFiller(!bIsNewFiller); + } + BuildResult(); + } + // + catch (Standard_Failure) { + myErrorStatus= 12; + } +} +//======================================================================= +// function: Prepare +// purpose: +//======================================================================= +void GEOMAlgo_WireSolid::Prepare() +{ + const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); + // + BOPTools_WireStateFiller aStateFiller(aPaveFiller); + aStateFiller.Do(); + // +} +//======================================================================= +// function: BuildResult +// purpose: +//======================================================================= +void GEOMAlgo_WireSolid::BuildResult() +{ + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); + const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); + // + Standard_Integer i, aNbPB, nSp, iBeg, iEnd; + TopAbs_ShapeEnum aType; + BooleanOperations_StateOfShape aState; + // + myLSIN.Clear(); + myLSOUT.Clear(); + myLSON.Clear(); + // + iBeg=1; + iEnd=aDS.NumberOfShapesOfTheObject(); + if (aDS.Tool().ShapeType()==TopAbs_WIRE) { + iBeg=iEnd+1; + iEnd=aDS.NumberOfSourceShapes(); + } + // + for (i=iBeg; i<=iEnd; ++i) { + aType=aDS.GetShapeType(i); + if (aType==TopAbs_EDGE) { + const TopoDS_Shape& aE=aDS.Shape(i); + const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(i)); + aNbPB=aLPB.Extent(); + // + if (!aNbPB) { + aState=aDS.GetState(i); + // + if (aState==BooleanOperations_IN) { + myLSIN.Append(aE); + } + else if (aState==BooleanOperations_OUT) { + myLSOUT.Append(aE); + } + else if (aState==BooleanOperations_ON) { + myLSON.Append(aE); + } + } + // + else if (aNbPB==1) { + const BOPTools_PaveBlock& aPB=aLPB.First(); + nSp=aPB.Edge(); + const TopoDS_Shape& aSp=aDS.Shape(nSp); + aState=aDS.GetState(nSp); + // + if (aState==BooleanOperations_IN) { + myLSIN.Append(aE); + } + else if (aState==BooleanOperations_OUT) { + myLSOUT.Append(aE); + } + else if (aState==BooleanOperations_ON) { + myLSON.Append(aE); + } + } + } + } +} diff --git a/src/GEOMAlgo/GEOMAlgo_WireSolid.hxx b/src/GEOMAlgo/GEOMAlgo_WireSolid.hxx new file mode 100644 index 000000000..7212908dc --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_WireSolid.hxx @@ -0,0 +1,95 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _GEOMAlgo_WireSolid_HeaderFile +#define _GEOMAlgo_WireSolid_HeaderFile + +#ifndef _GEOMAlgo_ShapeSolid_HeaderFile +#include +#endif + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOMAlgo_WireSolid : public GEOMAlgo_ShapeSolid { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT GEOMAlgo_WireSolid(); +Standard_EXPORT virtual ~GEOMAlgo_WireSolid(); +Standard_EXPORT virtual void Perform() ; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT virtual void Prepare() ; +Standard_EXPORT virtual void BuildResult() ; + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_WireSolid.ixx b/src/GEOMAlgo/GEOMAlgo_WireSolid.ixx new file mode 100644 index 000000000..37b35b408 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_WireSolid.ixx @@ -0,0 +1,26 @@ +// File generated by CPPExt (Value) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#include + + + + diff --git a/src/GEOMAlgo/GEOMAlgo_WireSolid.jxx b/src/GEOMAlgo/GEOMAlgo_WireSolid.jxx new file mode 100644 index 000000000..a37f27e72 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_WireSolid.jxx @@ -0,0 +1,3 @@ +#ifndef _GEOMAlgo_WireSolid_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx b/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx new file mode 100644 index 000000000..1664fde18 --- /dev/null +++ b/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile +#define _Handle_BlockFix_BlockFixAPI_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_MMgt_TShared_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(MMgt_TShared); +class BlockFix_BlockFixAPI; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_BlockFixAPI); + +class Handle(BlockFix_BlockFixAPI) : public Handle(MMgt_TShared) { + public: + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + Handle(BlockFix_BlockFixAPI)():Handle(MMgt_TShared)() {} + Handle(BlockFix_BlockFixAPI)(const Handle(BlockFix_BlockFixAPI)& aHandle) : Handle(MMgt_TShared)(aHandle) + { + } + + Handle(BlockFix_BlockFixAPI)(const BlockFix_BlockFixAPI* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) + { + } + + Handle(BlockFix_BlockFixAPI)& operator=(const Handle(BlockFix_BlockFixAPI)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(BlockFix_BlockFixAPI)& operator=(const BlockFix_BlockFixAPI* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + BlockFix_BlockFixAPI* operator->() + { + return (BlockFix_BlockFixAPI *)ControlAccess(); + } + + BlockFix_BlockFixAPI* operator->() const + { + return (BlockFix_BlockFixAPI *)ControlAccess(); + } + + Standard_EXPORT ~Handle(BlockFix_BlockFixAPI)(); + + Standard_EXPORT static const Handle(BlockFix_BlockFixAPI) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx b/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx new file mode 100644 index 000000000..114b7606a --- /dev/null +++ b/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile +#define _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_BRepTools_Modification_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(BRepTools_Modification); +class BlockFix_PeriodicSurfaceModifier; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier); + +class Handle(BlockFix_PeriodicSurfaceModifier) : public Handle(BRepTools_Modification) { + public: + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + Handle(BlockFix_PeriodicSurfaceModifier)():Handle(BRepTools_Modification)() {} + Handle(BlockFix_PeriodicSurfaceModifier)(const Handle(BlockFix_PeriodicSurfaceModifier)& aHandle) : Handle(BRepTools_Modification)(aHandle) + { + } + + Handle(BlockFix_PeriodicSurfaceModifier)(const BlockFix_PeriodicSurfaceModifier* anItem) : Handle(BRepTools_Modification)((BRepTools_Modification *)anItem) + { + } + + Handle(BlockFix_PeriodicSurfaceModifier)& operator=(const Handle(BlockFix_PeriodicSurfaceModifier)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(BlockFix_PeriodicSurfaceModifier)& operator=(const BlockFix_PeriodicSurfaceModifier* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + BlockFix_PeriodicSurfaceModifier* operator->() + { + return (BlockFix_PeriodicSurfaceModifier *)ControlAccess(); + } + + BlockFix_PeriodicSurfaceModifier* operator->() const + { + return (BlockFix_PeriodicSurfaceModifier *)ControlAccess(); + } + + Standard_EXPORT ~Handle(BlockFix_PeriodicSurfaceModifier)(); + + Standard_EXPORT static const Handle(BlockFix_PeriodicSurfaceModifier) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx b/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx new file mode 100644 index 000000000..2541a6ddf --- /dev/null +++ b/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile +#define _Handle_BlockFix_SphereSpaceModifier_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_BRepTools_Modification_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(BRepTools_Modification); +class BlockFix_SphereSpaceModifier; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_SphereSpaceModifier); + +class Handle(BlockFix_SphereSpaceModifier) : public Handle(BRepTools_Modification) { + public: + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + Handle(BlockFix_SphereSpaceModifier)():Handle(BRepTools_Modification)() {} + Handle(BlockFix_SphereSpaceModifier)(const Handle(BlockFix_SphereSpaceModifier)& aHandle) : Handle(BRepTools_Modification)(aHandle) + { + } + + Handle(BlockFix_SphereSpaceModifier)(const BlockFix_SphereSpaceModifier* anItem) : Handle(BRepTools_Modification)((BRepTools_Modification *)anItem) + { + } + + Handle(BlockFix_SphereSpaceModifier)& operator=(const Handle(BlockFix_SphereSpaceModifier)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(BlockFix_SphereSpaceModifier)& operator=(const BlockFix_SphereSpaceModifier* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + BlockFix_SphereSpaceModifier* operator->() + { + return (BlockFix_SphereSpaceModifier *)ControlAccess(); + } + + BlockFix_SphereSpaceModifier* operator->() const + { + return (BlockFix_SphereSpaceModifier *)ControlAccess(); + } + + Standard_EXPORT ~Handle(BlockFix_SphereSpaceModifier)(); + + Standard_EXPORT static const Handle(BlockFix_SphereSpaceModifier) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo/Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes.hxx b/src/GEOMAlgo/Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes.hxx new file mode 100644 index 000000000..fc17f9463 --- /dev/null +++ b/src/GEOMAlgo/Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes.hxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991 - 2000 by +// Matra Datavision SA. All rights reserved. +// +// Copyright (C) 2001 - 2004 by +// Open CASCADE SA. All rights reserved. +// +// This file is part of the Open CASCADE Technology software. +// +// This software may be distributed and/or modified under the terms and +// conditions of the Open CASCADE Public License as defined by Open CASCADE SA +// and appearing in the file LICENSE included in the packaging of this file. +// +// This software is distributed on an "AS IS" basis, without warranty of any +// kind, and Open CASCADE SA hereby disclaims all such warranties, +// including without limitation, any warranties of merchantability, fitness +// for a particular purpose or non-infringement. Please see the License for +// the specific terms and conditions governing rights and limitations under the +// License. + +#ifndef _Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes_HeaderFile +#define _Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TCollection_MapNode); +class GEOMAlgo_ListNodeOfListOfCoupleOfShapes; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMAlgo_ListNodeOfListOfCoupleOfShapes); + +class Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes) : public Handle(TCollection_MapNode) { + public: + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)():Handle(TCollection_MapNode)() {} + Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)(const Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)(const GEOMAlgo_ListNodeOfListOfCoupleOfShapes* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)& operator=(const Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)& operator=(const GEOMAlgo_ListNodeOfListOfCoupleOfShapes* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMAlgo_ListNodeOfListOfCoupleOfShapes* operator->() + { + return (GEOMAlgo_ListNodeOfListOfCoupleOfShapes *)ControlAccess(); + } + + GEOMAlgo_ListNodeOfListOfCoupleOfShapes* operator->() const + { + return (GEOMAlgo_ListNodeOfListOfCoupleOfShapes *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes)(); + + Standard_EXPORT static const Handle(GEOMAlgo_ListNodeOfListOfCoupleOfShapes) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo/Makefile.in b/src/GEOMAlgo/Makefile.in index 42f3ac46c..ee8b2b62e 100644 --- a/src/GEOMAlgo/Makefile.in +++ b/src/GEOMAlgo/Makefile.in @@ -37,6 +37,8 @@ VPATH=.:@srcdir@ LIB = libGEOMAlgo.la LIB_SRC = \ GEOMAlgo_Algo.cxx \ + GEOMAlgo_CoupleOfShapes.cxx \ + GEOMAlgo_GlueAnalyser.cxx \ GEOMAlgo_Gluer.cxx \ GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfIntegerShape_0.cxx \ GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfPassKeyListOfShape_0.cxx \ @@ -44,10 +46,25 @@ LIB_SRC = \ GEOMAlgo_IndexedDataMapOfIntegerShape_0.cxx \ GEOMAlgo_IndexedDataMapOfPassKeyListOfShape_0.cxx \ GEOMAlgo_IndexedDataMapOfShapeBox_0.cxx \ + GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_0.cxx \ + GEOMAlgo_ListNodeOfListOfCoupleOfShapes_0.cxx \ + GEOMAlgo_ListOfCoupleOfShapes_0.cxx \ GEOMAlgo_PassKey.cxx \ GEOMAlgo_PassKeyMapHasher.cxx \ GEOMAlgo_ShapeAlgo.cxx \ - GEOMAlgo_Tools.cxx + GEOMAlgo_Tools.cxx \ + BlockFix.cxx \ + BlockFix_BlockFixAPI.cxx \ + BlockFix_CheckTool.cxx \ + BlockFix_PeriodicSurfaceModifier.cxx \ + BlockFix_SphereSpaceModifier.cxx \ + BlockFix_UnionEdges.cxx \ + BlockFix_UnionFaces.cxx \ + GEOMAlgo_FinderShapeOn.cxx \ + GEOMAlgo_ShapeSolid.cxx \ + GEOMAlgo_ShellSolid.cxx \ + GEOMAlgo_VertexSolid.cxx \ + GEOMAlgo_WireSolid.cxx LIB_CLIENT_IDL = LIB_SERVER_IDL = @@ -56,7 +73,18 @@ LIB_SERVER_IDL = EXPORT_HEADERS = \ GEOMAlgo_Gluer.hxx \ GEOMAlgo_ShapeAlgo.hxx \ - GEOMAlgo_Algo.hxx + GEOMAlgo_Algo.hxx \ + GEOMAlgo_GlueAnalyser.hxx \ + GEOMAlgo_CoupleOfShapes.hxx \ + GEOMAlgo_ListOfCoupleOfShapes.hxx \ + GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx \ + Handle_GEOMAlgo_ListNodeOfListOfCoupleOfShapes.hxx \ + BlockFix_BlockFixAPI.hxx \ + BlockFix_BlockFixAPI.lxx \ + BlockFix_CheckTool.hxx \ + Handle_BlockFix_BlockFixAPI.hxx \ + GEOMAlgo_State.hxx \ + GEOMAlgo_FinderShapeOn.hxx # idl files EXPORT_IDLS= diff --git a/src/GEOMClient/GEOM_Client.cxx b/src/GEOMClient/GEOM_Client.cxx index b18299bff..35710a506 100644 --- a/src/GEOMClient/GEOM_Client.cxx +++ b/src/GEOMClient/GEOM_Client.cxx @@ -26,7 +26,10 @@ // Module : GEOM // $Header$ +#include + using namespace std; + #include "GEOM_Client.hxx" #include #include "OpUtil.hxx" diff --git a/src/GEOMGUI/GEOM_icons.po b/src/GEOMGUI/GEOM_icons.po index 97e439650..1f9aeab34 100644 --- a/src/GEOMGUI/GEOM_icons.po +++ b/src/GEOMGUI/GEOM_icons.po @@ -344,6 +344,9 @@ msgstr "chamferface.png" msgid "ICON_DLG_CHECKSHAPE" msgstr "check.png" +msgid "ICON_DLG_CHECK_COMPOUND_OF_BLOCKS" +msgstr "check_blocks_compound.png" + #SupressFaceDlg msgid "ICON_DLG_SUPRESS_FACE" msgstr "supressface.png" @@ -486,3 +489,9 @@ msgstr "block_face_4e.png" msgid "ICON_DLG_GLUE_FACES" msgstr "glue.png" + +msgid "ICON_DLG_FREE_FACES" +msgstr "free_faces.png" + +msgid "ICON_DLG_PROPAGATE" +msgstr "propagate.png" diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index d889f8371..45a186b55 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -527,6 +527,25 @@ msgstr "Chamfer" msgid "GEOM_CHECK_SHAPE" msgstr "Check Shape" +#Check Blocks Compound +msgid "GEOM_CHECK_BLOCKS_COMPOUND" +msgstr "Check Blocks Compound" + +#Check Blocks Compound Errors +msgid "GEOM_CHECK_BLOCKS_COMPOUND_ERRORS" +msgstr "Errors" + +#Check Blocks Compound Errors +msgid "GEOM_CHECK_BLOCKS_COMPOUND_HAS_NO_ERRORS" +msgstr "The Compound of Blocks has no errors" + +msgid "GEOM_CHECK_BLOCKS_COMPOUND_HAS_ERRORS" +msgstr "The Compound of Blocks has errors" + +#Check Blocks Compound SubShapes +msgid "GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES" +msgstr "Incriminated Sub-Shapes" + #Whatis msgid "GEOM_WHATIS" msgstr "Whatis" @@ -820,6 +839,10 @@ msgstr "Cylinder Construction" msgid "GEOM_CHECK_TITLE" msgstr "Check Shape Informations" +#: MeasureGUI_CheckCompoundOfBlocks.cxx:61 +msgid "GEOM_CHECK_COMPOUND_BLOCKS_TITLE" +msgstr "Check Blocks Compound" + #: GeometryGUI_CheckShape.cxx:83 msgid "GEOM_CHECK_INFOS" msgstr "Object And Its Topological Informations" @@ -1595,6 +1618,9 @@ msgstr "Detect" msgid "GEOM_FREE_BOUNDARIES" msgstr "Free boundaries" +msgid "GEOM_FREE_FACES" +msgstr "Free faces" + msgid "GEOM_BY_PARAMETER" msgstr "By parameter" @@ -1905,6 +1931,9 @@ msgstr "Glue faces" msgid "GEOM_GLUE" msgstr "Glue" +msgid "GEOM_FREE_FACES_TITLE" +msgstr "Free faces" + ### New object names for RepairGUI ### msgid "SEWING_NEW_OBJ_NAME" msgstr "Sewing" @@ -1933,4 +1962,10 @@ msgstr "SupressFaces" msgid "NON_GEOM_OBJECTS_SELECTED" msgstr "There are objects selected which do not belong to %1 component." +msgid "GEOM_PROPAGATE_TITLE" +msgstr "Propagate" + +msgid "GEOM_PROPAGATE" +msgstr "Propagate" + ### diff --git a/src/GEOMGUI/GEOM_msg_fr.po b/src/GEOMGUI/GEOM_msg_fr.po index e56d06af5..3a3e3c481 100644 --- a/src/GEOMGUI/GEOM_msg_fr.po +++ b/src/GEOMGUI/GEOM_msg_fr.po @@ -516,6 +516,25 @@ msgstr "Chanfrein" msgid "GEOM_CHECK_SHAPE" msgstr "Check Shape" +#Check Blocks Compound +msgid "GEOM_CHECK_BLOCKS_COMPOUND" +msgstr "Check Blocks Compound" + +#Check Blocks Compound Errors +msgid "GEOM_CHECK_BLOCKS_COMPOUND_ERRORS" +msgstr "Errors" + +#Check Blocks Compound Errors +msgid "GEOM_CHECK_BLOCKS_COMPOUND_HAS_NO_ERRORS" +msgstr "The Compound of Blocks has no errors" + +msgid "GEOM_CHECK_BLOCKS_COMPOUND_HAS_ERRORS" +msgstr "The Compound of Blocks has errors" + +#Check Blocks Compound SubShapes +msgid "GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES" +msgstr "Incriminated Sub-Shapes" + #Whatis msgid "GEOM_WHATIS" msgstr "Whatis" @@ -803,6 +822,10 @@ msgstr "Construction d'un Cylindre" msgid "GEOM_CHECK_TITLE" msgstr "Check Shape" +#: MeasureGUI_CheckCompoundOfBlocks.cxx:61 +msgid "GEOM_CHECK_COMPOUND_BLOCKS_TITLE" +msgstr "Check Blocks Compound" + #: GeometryGUI_CheckShape.cxx:83 msgid "GEOM_CHECK_INFOS" msgstr "Objet et ses Informations Topologiques" @@ -1348,3 +1371,15 @@ msgstr "Create a copy" #MZN: to be translated msgid "GEOM_CREATE_SINGLE_SOLID" msgstr "Create a single solid" + +msgid "GEOM_FREE_FACES" +msgstr "Free faces" + +msgid "GEOM_FREE_FACES_TITLE" +msgstr "Free faces" + +msgid "GEOM_PROPAGATE_TITLE" +msgstr "Propagate" + +msgid "GEOM_PROPAGATE" +msgstr "Propagate" diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index f6766b677..6987b1d2a 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -403,17 +403,19 @@ bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) theCommandID == 607 || // MENU REPAIR - REMOVE INTERNAL WIRES theCommandID == 608 || // MENU REPAIR - ADD POINT ON EDGE theCommandID == 609 || // MENU REPAIR - FREE BOUNDARIES + theCommandID == 610 || // MENU REPAIR - FREE FACES theCommandID == 602 ) { // MENU REPAIR - GLUE FACES library = geomGUI->getLibrary( "libRepairGUI.so" ); } - else if( theCommandID == 701 || // MENU MEASURE - PROPERTIES - theCommandID == 702 || // MENU MEASURE - CDG - theCommandID == 703 || // MENU MEASURE - INERTIA - theCommandID == 7041 || // MENU MEASURE - BOUNDING BOX - theCommandID == 7042 || // MENU MEASURE - MIN DISTANCE - theCommandID == 705 || // MENU MEASURE - TOLERANCE - theCommandID == 706 || // MENU MEASURE - WHATIS - theCommandID == 707 || // MENU MEASURE - CHECK + else if( theCommandID == 701 || // MENU MEASURE - PROPERTIES + theCommandID == 702 || // MENU MEASURE - CDG + theCommandID == 703 || // MENU MEASURE - INERTIA + theCommandID == 7041 || // MENU MEASURE - BOUNDING BOX + theCommandID == 7042 || // MENU MEASURE - MIN DISTANCE + theCommandID == 705 || // MENU MEASURE - TOLERANCE + theCommandID == 706 || // MENU MEASURE - WHATIS + theCommandID == 707 || // MENU MEASURE - CHECK + theCommandID == 7072 || // MENU MEASURE - CHECK COMPOUND OF BLOCKS theCommandID == 708 ) { // MENU MEASURE - POINT COORDINATES library = geomGUI->getLibrary( "libMeasureGUI.so" ); } @@ -421,9 +423,10 @@ bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) theCommandID == 801 ) { // MENU GROUP - EDIT library = geomGUI->getLibrary( "libGroupGUI.so" ); } - else if( theCommandID == 9999 || // MENU BLOCKS - HEXAHEDRAL SOLID - theCommandID == 9998 || // MENU BLOCKS - MULTI-TRANSFORMATION - theCommandID == 9997 || // MENU BLOCKS - QUADRANGLE FACE + else if( theCommandID == 9999 || // MENU BLOCKS - HEXAHEDRAL SOLID + theCommandID == 9998 || // MENU BLOCKS - MULTI-TRANSFORMATION + theCommandID == 9997 || // MENU BLOCKS - QUADRANGLE FACE + theCommandID == 99991 || // MENU BLOCKS - PROPAGATE theCommandID == 9995 ) { // MENU BLOCKS - EXPLODE ON BLOCKS library = geomGUI->getLibrary( "libBlocksGUI.so" ); } diff --git a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx index 27073e439..cad20102e 100644 --- a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx @@ -10,10 +10,15 @@ using namespace std; #include "GEOMImpl_Types.hxx" #include "GEOMImpl_ILocalOperations.hxx" #include "GEOMImpl_Block6Explorer.hxx" +#include "GEOMImpl_IBlocksOperations.hxx" + #include "GEOM_Function.hxx" #include "ShHealOper_Sewing.hxx" #include "NMTAlgo_Splitter1.hxx" +#include "BlockFix_BlockFixAPI.hxx" + +#include "utilities.h" #include @@ -456,113 +461,173 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const } else { } - } else { // Multi-transformations + } else { // Multi-transformations and compound improving - TopoDS_Shape aMulti; - GEOMImpl_IBlockTrsf aCI (aFunction); - Handle(GEOM_Function) aRefShape = aCI.GetOriginal(); - TopoDS_Shape aBlockIni = aRefShape->GetValue(); - if (aBlockIni.IsNull()) { - Standard_NullObject::Raise("Null Block"); - } + if (aType == BLOCK_REMOVE_EXTRA || + aType == BLOCK_COMPOUND_IMPROVE) { + + GEOMImpl_IBlockTrsf aCI (aFunction); + Handle(GEOM_Function) aRefShape = aCI.GetOriginal(); + TopoDS_Shape aBlockOrComp = aRefShape->GetValue(); + if (aBlockOrComp.IsNull()) { + Standard_NullObject::Raise("Null Shape given"); + } + + // 1. Improve solids with seam and/or degenerated edges + BlockFix_BlockFixAPI aTool; + //aTool.Tolerance() = toler; + aTool.SetShape(aBlockOrComp); + aTool.Perform(); + + if (aType == BLOCK_REMOVE_EXTRA) { + + aShape = aTool.Shape(); + if (aShape == aBlockOrComp) { + MESSAGE("No modifications have been done"); + } + + } else { // aType == BLOCK_COMPOUND_IMPROVE + + TopoDS_Shape aFixedExtra = aTool.Shape(); + + // 2. Separate non-blocks + TopTools_ListOfShape BLO; // All blocks from the given compound + TopTools_ListOfShape NOT; // Not blocks + TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges + GEOMImpl_IBlocksOperations::AddBlocksFrom(aFixedExtra, BLO, NOT, EXT); - // Copy block to avoid problems (PAL6706) - TColStd_IndexedDataMapOfTransientTransient aMap; - TopoDS_Shape aBlock; - TNaming_CopyShape::CopyTool(aBlockIni, aMap, aBlock); + if (NOT.Extent() > 0) { + MESSAGE("Some non-blocks have been removed"); + } + + // 3. Warn about staying extra-edges + if (EXT.Extent() > 0) { + MESSAGE("Warning: Not all seam or degenerated edges was removed"); + } + + // ??? Throw away standalone blocks ??? + + // 4. Create compound of all blocks + TopoDS_Compound aComp; + BRep_Builder BB; + BB.MakeCompound(aComp); + TopTools_ListIteratorOfListOfShape BLOit (BLO); + for (; BLOit.More(); BLOit.Next()) { + BB.Add(aComp, BLOit.Value()); + } - // Block tolerance in vertices - Standard_Real aTol = prec; - TopExp_Explorer expV (aBlock, TopAbs_VERTEX); - TopTools_MapOfShape mapShape; - for (; expV.More(); expV.Next()) { - if (mapShape.Add(expV.Current())) { - TopoDS_Vertex aV = TopoDS::Vertex(expV.Current()); - aTol = Max(BRep_Tool::Tolerance(aV), aTol); + // 5. Glue Faces + aShape = GEOMImpl_GlueDriver::GlueFaces(aComp, Precision::Confusion()); } - } - if (aType == BLOCK_MULTI_TRANSFORM_1D) { - // Retrieve a faces by Ids - Standard_Integer aFace1Id = aCI.GetFace1U(); - Standard_Integer aFace2Id = aCI.GetFace2U(); - TopoDS_Shape aFace1, aFace2; - if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1Id, aFace1)) { - Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id"); + } else if (aType == BLOCK_MULTI_TRANSFORM_1D || + aType == BLOCK_MULTI_TRANSFORM_2D) { + + TopoDS_Shape aMulti; + GEOMImpl_IBlockTrsf aCI (aFunction); + Handle(GEOM_Function) aRefShape = aCI.GetOriginal(); + TopoDS_Shape aBlockIni = aRefShape->GetValue(); + if (aBlockIni.IsNull()) { + Standard_NullObject::Raise("Null Block"); } - if (aFace1.ShapeType() != TopAbs_FACE) { - Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face"); + + // Copy block to avoid problems (PAL6706) + TColStd_IndexedDataMapOfTransientTransient aMap; + TopoDS_Shape aBlock; + TNaming_CopyShape::CopyTool(aBlockIni, aMap, aBlock); + + // Block tolerance in vertices + Standard_Real aTol = prec; + TopExp_Explorer expV (aBlock, TopAbs_VERTEX); + TopTools_MapOfShape mapShape; + for (; expV.More(); expV.Next()) { + if (mapShape.Add(expV.Current())) { + TopoDS_Vertex aV = TopoDS::Vertex(expV.Current()); + aTol = Max(BRep_Tool::Tolerance(aV), aTol); + } } - if (aFace2Id > 0) { - if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2Id, aFace2)) { + if (aType == BLOCK_MULTI_TRANSFORM_1D) { + // Retrieve a faces by Ids + Standard_Integer aFace1Id = aCI.GetFace1U(); + Standard_Integer aFace2Id = aCI.GetFace2U(); + TopoDS_Shape aFace1, aFace2; + if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1Id, aFace1)) { Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id"); } - if (aFace2.ShapeType() != TopAbs_FACE) { + if (aFace1.ShapeType() != TopAbs_FACE) { Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face"); } - } - - Standard_Integer aNbIter = aCI.GetNbIterU(); - MultiTransformate1D(aBlock, aFace1, aFace2, aNbIter, aMulti); + if (aFace2Id > 0) { + if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2Id, aFace2)) { + Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id"); + } + if (aFace2.ShapeType() != TopAbs_FACE) { + Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face"); + } + } - } else if (aType == BLOCK_MULTI_TRANSFORM_2D) { - // Retrieve a faces by Ids - Standard_Integer aFace1UId = aCI.GetFace1U(); - Standard_Integer aFace2UId = aCI.GetFace2U(); - Standard_Integer aFace1VId = aCI.GetFace1V(); - Standard_Integer aFace2VId = aCI.GetFace2V(); + Standard_Integer aNbIter = aCI.GetNbIterU(); - TopoDS_Shape aFace1U, aFace2U, aFace1V, aFace2V; - if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1UId, aFace1U) || - !GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1VId, aFace1V)) { - Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id"); - } + MultiTransformate1D(aBlock, aFace1, aFace2, aNbIter, aMulti); - if (aFace1U.ShapeType() != TopAbs_FACE || - aFace1V.ShapeType() != TopAbs_FACE) { - Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face"); - } + } else { // aType == BLOCK_MULTI_TRANSFORM_2D + // Retrieve a faces by Ids + Standard_Integer aFace1UId = aCI.GetFace1U(); + Standard_Integer aFace2UId = aCI.GetFace2U(); + Standard_Integer aFace1VId = aCI.GetFace1V(); + Standard_Integer aFace2VId = aCI.GetFace2V(); - if (aFace2UId > 0) { - if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2UId, aFace2U)) { + TopoDS_Shape aFace1U, aFace2U, aFace1V, aFace2V; + if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1UId, aFace1U) || + !GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace1VId, aFace1V)) { Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id"); } - if (aFace2U.ShapeType() != TopAbs_FACE) { + if (aFace1U.ShapeType() != TopAbs_FACE || + aFace1V.ShapeType() != TopAbs_FACE) { Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face"); } - } - if (aFace2VId > 0) { - if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2VId, aFace2V)) { - Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id"); + if (aFace2UId > 0) { + if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2UId, aFace2U)) { + Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id"); + } + + if (aFace2U.ShapeType() != TopAbs_FACE) { + Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face"); + } } - if (aFace2V.ShapeType() != TopAbs_FACE) { - Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face"); + if (aFace2VId > 0) { + if (!GEOMImpl_ILocalOperations::GetSubShape(aBlock, aFace2VId, aFace2V)) { + Standard_NullObject::Raise("Can not retrieve a sub-shape with given Id"); + } + + if (aFace2V.ShapeType() != TopAbs_FACE) { + Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face"); + } } - } - Standard_Integer aNbIterU = aCI.GetNbIterU(); - Standard_Integer aNbIterV = aCI.GetNbIterV(); + Standard_Integer aNbIterU = aCI.GetNbIterU(); + Standard_Integer aNbIterV = aCI.GetNbIterV(); + + MultiTransformate2D(aBlock, + aFace1U, aFace2U, aNbIterU, + aFace1V, aFace2V, aNbIterV, aMulti); + } - MultiTransformate2D(aBlock, - aFace1U, aFace2U, aNbIterU, - aFace1V, aFace2V, aNbIterV, aMulti); + if (aMulti.IsNull()) { + StdFail_NotDone::Raise("Multi-transformation failed"); + } - } else { - return 0; - } + // Glue faces of the multi-block + aShape = GEOMImpl_GlueDriver::GlueFaces(aMulti, aTol); - if (aMulti.IsNull()) { - StdFail_NotDone::Raise("Multi-transformation failed"); + } else { // unknown function type return 0; } - - // Glue faces of the multi-block - aShape = GEOMImpl_GlueDriver::GlueFaces(aMulti, aTol); } if (aShape.IsNull()) return 0; diff --git a/src/GEOMImpl/GEOMImpl_GlueDriver.cxx b/src/GEOMImpl/GEOMImpl_GlueDriver.cxx index cd65a79fc..8eb0ffb4f 100644 --- a/src/GEOMImpl/GEOMImpl_GlueDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_GlueDriver.cxx @@ -12,6 +12,7 @@ using namespace std; #include #include +#include //======================================================================= //function : GEOMImpl_GlueDriver @@ -31,6 +32,74 @@ const Standard_GUID& GEOMImpl_GlueDriver::GetID() return aGlueDriver; } +//======================================================================= +//function : GlueFacesWithWarnings +//purpose : +//======================================================================= +TopoDS_Shape GEOMImpl_GlueDriver::GlueFacesWithWarnings (const TopoDS_Shape& theShape, + const Standard_Real theTolerance, + TCollection_AsciiString& theWarning) const +{ + Standard_Integer iErr, iWrn; + TopoDS_Shape aRes; + GEOMAlgo_Gluer aGluer; + + aGluer.SetShape(theShape); + aGluer.SetTolerance(theTolerance); + aGluer.SetCheckGeometry(Standard_True); + + aGluer.Perform(); + + iErr = aGluer.ErrorStatus(); + if (iErr) { + switch (iErr) { + case 2: + Standard_Failure::Raise("No vertices found in source shape"); + break; + case 5: + Standard_Failure::Raise("Source shape is Null"); + break; + case 6: + Standard_Failure::Raise("Result shape is Null"); + break; + case 200: + Standard_Failure::Raise("Error occured during check of geometric coincidence"); + break; + default: + { + // description of all errors see in GEOMAlgo_Gluer.cxx + TCollection_AsciiString aMsg ("Error in GEOMAlgo_Gluer with code "); + aMsg += TCollection_AsciiString(iErr); + Standard_Failure::Raise(aMsg.ToCString()); + break; + } + } + return aRes; + } + + iWrn = aGluer.WarningStatus(); + if (iWrn) { + switch (iWrn) { + case 1: + { + Standard_Integer nbAlone = aGluer.AloneShapes(); + theWarning = TCollection_AsciiString(nbAlone); + theWarning += " solid(s) can not be glued by faces"; + } + break; + default: + // description of all warnings see in GEOMAlgo_Gluer.cxx + theWarning = "Warning in GEOMAlgo_Gluer with code "; + theWarning += TCollection_AsciiString(iWrn); + break; + } + } + + aRes = aGluer.Result(); + + return aRes; +} + //======================================================================= //function : GlueFaces //purpose : @@ -106,6 +175,7 @@ Standard_Integer GEOMImpl_GlueDriver::Execute(TFunction_Logbook& log) const Standard_Integer aType = aFunction->GetType(); TopoDS_Shape aShape; + TCollection_AsciiString aWrn; if (aType == GLUE_FACES) { Handle(GEOM_Function) aRefBase = aCI.GetBase(); @@ -115,7 +185,7 @@ Standard_Integer GEOMImpl_GlueDriver::Execute(TFunction_Logbook& log) const } Standard_Real tol3d = aCI.GetTolerance(); - aShape = GlueFaces(aShapeBase, tol3d); + aShape = GlueFacesWithWarnings(aShapeBase, tol3d, aWrn); } else { } @@ -125,6 +195,10 @@ Standard_Integer GEOMImpl_GlueDriver::Execute(TFunction_Logbook& log) const log.SetTouched(Label()); + if (!aWrn.IsEmpty()) { + Standard_Failure::Raise(aWrn.ToCString()); + } + return 1; } diff --git a/src/GEOMImpl/GEOMImpl_GlueDriver.hxx b/src/GEOMImpl/GEOMImpl_GlueDriver.hxx index 489f6a11c..c8f2679cd 100644 --- a/src/GEOMImpl/GEOMImpl_GlueDriver.hxx +++ b/src/GEOMImpl/GEOMImpl_GlueDriver.hxx @@ -97,6 +97,7 @@ class Handle(GEOMImpl_GlueDriver) : public Handle(TFunction_Driver) { #include #endif #include +#include class TColStd_SequenceOfExtendedString; @@ -130,6 +131,10 @@ Standard_EXPORT ~GEOMImpl_GlueDriver() {}; Standard_EXPORT static TopoDS_Shape GlueFaces (const TopoDS_Shape& theShape, const Standard_Real theTolerance); +Standard_EXPORT TopoDS_Shape GlueFacesWithWarnings (const TopoDS_Shape& theShape, + const Standard_Real theTolerance, + TCollection_AsciiString& theWarning) const; + // Type management // Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_GlueDriver_Type_(); diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx index 9b7aedc80..1f433c622 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx @@ -12,6 +12,12 @@ using namespace std; #include "GEOM_Function.hxx" +#include "GEOMAlgo_GlueAnalyser.hxx" +#include "GEOMAlgo_CoupleOfShapes.hxx" +#include "GEOMAlgo_ListOfCoupleOfShapes.hxx" +#include "GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx" +#include "BlockFix_CheckTool.hxx" + #include "utilities.h" #include "OpUtil.hxx" #include "Utils_ExceptHandlers.hxx" @@ -19,10 +25,13 @@ using namespace std; #include #include #include +#include #include #include +#include #include +#include #include #include #include @@ -34,23 +43,33 @@ using namespace std; #include #include #include +#include #include #include #include #include #include #include +#include #include #include +#include #include -#include #include + +#include +#include + #include #include #include #include +//#include + +#include + #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= @@ -1214,6 +1233,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint (Handle(GEOM_Object) theShape, Handle(GEOM_Object) thePoint) { +// OSD_Timer timer1, timer2, timer3, timer4, timer5; +// timer1.Start(); + SetErrorCode(KO); //New object @@ -1250,51 +1272,66 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint TopoDS_Vertex aVert = TopoDS::Vertex(anArg); gp_Pnt aPnt = BRep_Tool::Pnt(aVert); + Standard_Real PX, PY, PZ; + aPnt.Coord(PX, PY, PZ); - // 1. Explode blocks on faces - TopTools_MapOfShape mapShape; - Standard_Integer nbFaces = 0; +// timer1.Stop(); +// timer2.Start(); + + // 1. Classify the point relatively each face + Standard_Integer nearest = 2, nbFound = 0; + TopTools_DataMapOfShapeInteger mapShapeDist; TopExp_Explorer exp (aBlockOrComp, TopAbs_FACE); for (; exp.More(); exp.Next()) { - if (mapShape.Add(exp.Current())) { - nbFaces++; - } - } + TopoDS_Shape aFace = exp.Current(); + + if (!mapShapeDist.IsBound(aFace)) { + Standard_Integer aDistance = 2; + + // 1.a. Classify relatively Surface + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace)); + Handle(ShapeAnalysis_Surface) aSurfAna = new ShapeAnalysis_Surface (aSurf); + gp_Pnt2d p2dOnSurf = aSurfAna->ValueOfUV(aPnt, Precision::Confusion()); + gp_Pnt p3dOnSurf = aSurfAna->Value(p2dOnSurf); + Standard_Real aDist = p3dOnSurf.Distance(aPnt); + if (aDist > Precision::Confusion()) { + // OUT of Surface + aDistance = 1; + } else { + // 1.b. Classify relatively the face itself + BRepClass_FaceClassifier FC (TopoDS::Face(aFace), p2dOnSurf, Precision::Confusion()); + if (FC.State() == TopAbs_IN) { + aDistance = -1; + } else if (FC.State() == TopAbs_ON) { + aDistance = 0; + } else { // OUT + aDistance = 1; + } + } - mapShape.Clear(); - Standard_Integer ind = 1; - TopTools_Array1OfShape aFaces (1, nbFaces); - TColStd_Array1OfInteger aDistances (1, nbFaces); - for (exp.Init(aBlockOrComp, TopAbs_FACE); exp.More(); exp.Next()) { - if (mapShape.Add(exp.Current())) { - TopoDS_Shape aFace = exp.Current(); - aFaces(ind) = aFace; - - // 2. Classify the point relatively each face - BRepClass_FaceClassifier FC (TopoDS::Face(aFace), aPnt, Precision::Confusion()); - if (FC.State() == TopAbs_IN) { - aDistances(ind) = -1; - } else if (FC.State() == TopAbs_ON) { - aDistances(ind) = 0; - } else { // OUT - aDistances(ind) = 1; + if (aDistance < nearest) { + nearest = aDistance; + aShape = aFace; + nbFound = 1; + + // A first found face, containing the point inside, will be returned. + // It is the solution, if there are no + // coincident or intersecting faces in the compound. + if (nearest == -1) break; + + } else if (aDistance == nearest) { + nbFound++; + } else { } - ind++; - } - } - // 3. Define face, containing the point or having minimum distance to it - Standard_Integer nearest = 2, nbFound = 0; - for (ind = 1; ind <= nbFaces; ind++) { - if (aDistances(ind) < nearest) { - nearest = aDistances(ind); - aShape = aFaces(ind); - nbFound = 1; - } else if (aDistances(ind) == nearest) { - nbFound++; - } else { - } + mapShapeDist.Bind(aFace, aDistance); + } // if (!mapShapeDist.IsBound(aFace)) } + +// timer2.Stop(); +// timer3.Start(); + + // 2. Define face, containing the point or having minimum distance to it if (nbFound > 1) { if (nearest == 0) { // The point is on boundary of some faces and there are @@ -1306,40 +1343,66 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint // The point is outside some faces and there are // no faces, having the point inside or on boundary. // We will get a nearest face - Standard_Real minDist = RealLast(); - for (ind = 1; ind <= nbFaces; ind++) { - if (aDistances(ind) == 1) { - BRepExtrema_DistShapeShape aDistTool (aVert, aFaces(ind)); - if (!aDistTool.IsDone()) { - SetErrorCode("Can not find a distance from the given point to one of faces"); - return NULL; + Standard_Real bigReal = RealLast(); + Standard_Real minDist = bigReal; + TopTools_DataMapIteratorOfDataMapOfShapeInteger mapShapeDistIter (mapShapeDist); + for (; mapShapeDistIter.More(); mapShapeDistIter.Next()) { + if (mapShapeDistIter.Value() == 1) { + TopoDS_Shape aFace = mapShapeDistIter.Key(); + Standard_Real aDist = bigReal; + + // 2.a. Fast check of distance - if point projection on surface is on face + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace)); + Handle(ShapeAnalysis_Surface) aSurfAna = new ShapeAnalysis_Surface (aSurf); + gp_Pnt2d p2dOnSurf = aSurfAna->ValueOfUV(aPnt, Precision::Confusion()); + gp_Pnt p3dOnSurf = aSurfAna->Value(p2dOnSurf); + aDist = p3dOnSurf.Distance(aPnt); + + BRepClass_FaceClassifier FC (TopoDS::Face(aFace), p2dOnSurf, Precision::Confusion()); + if (FC.State() == TopAbs_OUT) { + if (aDist < minDist) { + // 2.b. Slow check - if point projection on surface is outside of face + BRepExtrema_DistShapeShape aDistTool (aVert, aFace); + if (!aDistTool.IsDone()) { + SetErrorCode("Can not find a distance from the given point to one of faces"); + return NULL; + } + aDist = aDistTool.Value(); + } else { + aDist = bigReal; + } } - Standard_Real aDist = aDistTool.Value(); - if (aDist < minDist) { - minDist = aDist; - aShape = aFaces(ind); - } - } - } - } else { // nearest == -1 - // The point is inside some faces. - // We will get a face with nearest center - Standard_Real minDist = RealLast(); - for (ind = 1; ind <= nbFaces; ind++) { - if (aDistances(ind) == -1) { - GProp_GProps aSystem; - BRepGProp::SurfaceProperties(aFaces(ind), aSystem); - gp_Pnt aCenterMass = aSystem.CentreOfMass(); - Standard_Real aDist = aCenterMass.Distance(aPnt); if (aDist < minDist) { minDist = aDist; - aShape = aFaces(ind); + aShape = aFace; } } } + } else { // nearest == -1 +// // The point is inside some faces. +// // We will get a face with nearest center +// Standard_Real minDist = RealLast(); +// TopTools_DataMapIteratorOfDataMapOfShapeInteger mapShapeDistIter (mapShapeDist); +// for (; mapShapeDistIter.More(); mapShapeDistIter.Next()) { +// if (mapShapeDistIter.Value() == -1) { +// TopoDS_Shape aFace = mapShapeDistIter.Key(); +// GProp_GProps aSystem; +// BRepGProp::SurfaceProperties(aFace, aSystem); +// gp_Pnt aCenterMass = aSystem.CentreOfMass(); +// +// Standard_Real aDist = aCenterMass.Distance(aPnt); +// if (aDist < minDist) { +// minDist = aDist; +// aShape = aFace; +// } +// } +// } } - } + } // if (nbFound > 1) + +// timer3.Stop(); +// timer4.Start(); if (nbFound == 0) { SetErrorCode("There are no faces near the given point"); @@ -1351,6 +1414,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint anArray->SetValue(1, anIndices.FindIndex(aShape)); aResult = GetEngine()->AddSubShape(theShape, anArray); } + +// timer4.Stop(); } catch (Standard_Failure) { Handle(Standard_Failure) aFail = Standard_Failure::Caught(); @@ -1358,6 +1423,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint return NULL; } +// timer5.Start(); + //The GetFaceNearPoint() doesn't change object so no new function is required. Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); @@ -1375,6 +1442,16 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint aFunction->SetDescription(aNewDescr); SetErrorCode(OK); + +// timer5.Stop(); +// +// cout << "Show current face times:" << endl; +// timer1.Show(); +// timer2.Show(); +// timer3.Show(); +// timer4.Show(); +// timer5.Show(); + return aResult; } @@ -1583,9 +1660,92 @@ Standard_Boolean GEOMImpl_IBlocksOperations::IsCompoundOfBlocks * Set of functions, used by CheckCompoundOfBlocks() method */ //============================================================================= -void AddBlocksFrom (const TopoDS_Shape& theShape, - TopTools_ListOfShape& BLO, - TopTools_ListOfShape& NOT) +void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape, + TopTools_ListOfShape& BLO, + TopTools_ListOfShape& NOT, + TopTools_ListOfShape& EXT) +{ + TopAbs_ShapeEnum aType = theShape.ShapeType(); + switch (aType) { + case TopAbs_COMPOUND: + case TopAbs_COMPSOLID: + { + TopoDS_Iterator It (theShape); + for (; It.More(); It.Next()) { + AddBlocksFrom(It.Value(), BLO, NOT, EXT); + } + } + break; + case TopAbs_SOLID: + { + // Check, if there are seam or degenerated edges + BlockFix_CheckTool aTool; + aTool.SetShape(theShape); + aTool.Perform(); + if (aTool.NbPossibleBlocks() > 0) { + EXT.Append(theShape); + } else { + // Count faces and edges in each face to recognize blocks + TopTools_MapOfShape mapFaces; + Standard_Integer nbFaces = 0; + Standard_Boolean hasNonQuadr = Standard_False; + TopExp_Explorer expF (theShape, TopAbs_FACE); + + for (; expF.More(); expF.Next()) { + if (mapFaces.Add(expF.Current())) { + nbFaces++; + if (nbFaces > 6) break; + + // get wire + TopoDS_Shape aF = expF.Current(); + TopExp_Explorer wires (aF, TopAbs_WIRE); + if (!wires.More()) { + // no wire in the face + hasNonQuadr = Standard_True; + break; + } + TopoDS_Shape aWire = wires.Current(); + wires.Next(); + if (wires.More()) { + // multiple wires in the face + hasNonQuadr = Standard_True; + break; + } + + // Check number of edges in the face + Standard_Integer nbEdges = 0; + TopTools_MapOfShape mapEdges; + TopExp_Explorer expW (aWire, TopAbs_EDGE); + for (; expW.More(); expW.Next()) { + if (mapEdges.Add(expW.Current())) { + nbEdges++; + if (nbEdges > 4) break; + } + } + if (nbEdges != 4) { + hasNonQuadr = Standard_True; + } + } + } + + if (nbFaces == 6 && !hasNonQuadr) { + BLO.Append(theShape); + } else { + NOT.Append(theShape); + } + } + } + break; + default: + NOT.Append(theShape); + } +} + +void AddBlocksFromOld (const TopoDS_Shape& theShape, + TopTools_ListOfShape& BLO, + TopTools_ListOfShape& NOT, + TopTools_ListOfShape& DEG, + TopTools_ListOfShape& SEA) { TopAbs_ShapeEnum aType = theShape.ShapeType(); switch (aType) { @@ -1594,7 +1754,7 @@ void AddBlocksFrom (const TopoDS_Shape& theShape, { TopoDS_Iterator It (theShape); for (; It.More(); It.Next()) { - AddBlocksFrom(It.Value(), BLO, NOT); + AddBlocksFromOld(It.Value(), BLO, NOT, DEG, SEA); } } break; @@ -1603,25 +1763,67 @@ void AddBlocksFrom (const TopoDS_Shape& theShape, TopTools_MapOfShape mapFaces; TopExp_Explorer expF (theShape, TopAbs_FACE); Standard_Integer nbFaces = 0; - Standard_Integer nbEdges = 0; + Standard_Boolean hasNonQuadr = Standard_False; + Standard_Boolean hasDegenerated = Standard_False; + Standard_Boolean hasSeam = Standard_False; for (; expF.More(); expF.Next()) { if (mapFaces.Add(expF.Current())) { nbFaces++; if (nbFaces > 6) break; // Check number of edges in the face + Standard_Integer nbEdges = 0; + TopTools_MapOfShape mapEdges; + + // get wire TopoDS_Shape aF = expF.Current(); - TopExp_Explorer expE (aF, TopAbs_EDGE); - nbEdges = 0; - for (; expE.More(); expE.Next()) { - nbEdges++; - if (nbEdges > 4) break; + TopExp_Explorer wires (aF, TopAbs_WIRE); + if (!wires.More()) { + // no wire in the face + hasNonQuadr = Standard_True; + break; + } + TopoDS_Shape aWire = wires.Current(); + wires.Next(); + if (wires.More()) { + // multiple wires in the face + hasNonQuadr = Standard_True; + break; + } + + // iterate on wire + BRepTools_WireExplorer aWE (TopoDS::Wire(aWire), TopoDS::Face(aF)); + for (; aWE.More(); aWE.Next(), nbEdges++) { + if (BRep_Tool::Degenerated(aWE.Current())) { + // degenerated edge found + hasDegenerated = Standard_True; +// break; + } + if (mapEdges.Contains(aWE.Current())) { + // seam edge found + hasSeam = Standard_True; +// break; + } + mapEdges.Add(aWE.Current()); + } + if (nbEdges != 4) { + hasNonQuadr = Standard_True; } - if (nbEdges != 4) break; } } - if (nbFaces == 6 && nbEdges == 4) { - BLO.Append(theShape); + if (nbFaces == 6) { + if (hasDegenerated || hasSeam) { + if (hasDegenerated) { + DEG.Append(theShape); + } + if (hasSeam) { + SEA.Append(theShape); + } + } else if (hasNonQuadr) { + NOT.Append(theShape); + } else { + BLO.Append(theShape); + } } else { NOT.Append(theShape); } @@ -1649,20 +1851,13 @@ Standard_Integer BlocksRelation (const TopoDS_Shape& theBlock1, Bnd_Box B1, B2; BRepBndLib::Add(theBlock1, B1); BRepBndLib::Add(theBlock2, B2); -// BRepBndLib::AddClose(theBlock1, B1); -// BRepBndLib::AddClose(theBlock2, B2); B1.Get(Xmin1, Ymin1, Zmin1, Xmax1, Ymax1, Zmax1); B2.Get(Xmin2, Ymin2, Zmin2, Xmax2, Ymax2, Zmax2); if (Xmax2 < Xmin1 || Xmax1 < Xmin2 || Ymax2 < Ymin1 || Ymax1 < Ymin2 || Zmax2 < Zmin1 || Zmax1 < Zmin2) { -// Standard_Real prec = Precision::Confusion(); -// if (prec < Xmin1 - Xmax2 || prec < Xmin2 - Xmax1 || -// prec < Ymin1 - Ymax2 || prec < Ymin2 - Ymax1 || -// prec < Zmin1 - Zmax2 || prec < Zmin2 - Zmax1) { return REL_NOT_CONNECTED; } - // to be done BRepExtrema_DistShapeShape dst (theBlock1, theBlock2); if (!dst.IsDone()) { @@ -1863,10 +2058,10 @@ Standard_Boolean HasAnyConnection (const Standard_Integer theBlockIndex, //============================================================================= /*! - * CheckCompoundOfBlocks + * CheckCompoundOfBlocksOld */ //============================================================================= -Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks +Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocksOld (Handle(GEOM_Object) theCompound, list& theErrors) { @@ -1883,20 +2078,40 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks // 1. Report non-blocks TopTools_ListOfShape NOT; // Not blocks + TopTools_ListOfShape DEG; // Hexahedral solids, having degenerated edges + TopTools_ListOfShape SEA; // Hexahedral solids, having seam edges TopTools_ListOfShape BLO; // All blocks from the given compound - AddBlocksFrom(aBlockOrComp, BLO, NOT); + AddBlocksFromOld(aBlockOrComp, BLO, NOT, DEG, SEA); if (NOT.Extent() > 0) { isCompOfBlocks = Standard_False; BCError anErr; anErr.error = NOT_BLOCK; - TopTools_ListIteratorOfListOfShape NOTit (NOT); - for (; NOTit.More(); NOTit.Next()) { - anErr.incriminated.push_back(anIndices.FindIndex(NOTit.Value())); + TopTools_ListIteratorOfListOfShape it (NOT); + for (; it.More(); it.Next()) { + anErr.incriminated.push_back(anIndices.FindIndex(it.Value())); } theErrors.push_back(anErr); } + if (DEG.Extent() > 0 || SEA.Extent() > 0) { + isCompOfBlocks = Standard_False; + BCError anErr; + anErr.error = EXTRA_EDGE; + + TopTools_ListIteratorOfListOfShape itDEG (DEG); + for (; itDEG.More(); itDEG.Next()) { + anErr.incriminated.push_back(anIndices.FindIndex(itDEG.Value())); + } + + TopTools_ListIteratorOfListOfShape itSEA (SEA); + for (; itSEA.More(); itSEA.Next()) { + anErr.incriminated.push_back(anIndices.FindIndex(itSEA.Value())); + } + + theErrors.push_back(anErr); + } + Standard_Integer nbBlocks = BLO.Extent(); if (nbBlocks == 0) { isCompOfBlocks = Standard_False; @@ -1962,6 +2177,7 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks TColStd_MapOfInteger aCurrentSet; for (ibl = 1; ibl <= nbBlocks; ibl++) { if (!aProcessedMap.Contains(ibl)) { + aCurrentSet.Clear(); FindConnected(ibl, aRelations, aProcessedMap, aCurrentSet); if (aCurrentSet.Extent() > aLargestSet.Extent()) { aLargestSet = aCurrentSet; @@ -2012,6 +2228,9 @@ TCollection_AsciiString GEOMImpl_IBlocksOperations::PrintBCErrors case NOT_BLOCK: aDescr += "\nNot a Blocks: "; break; + case EXTRA_EDGE: + aDescr += "\nHexahedral solids with degenerated and/or seam edges: "; + break; case INVALID_CONNECTION: aDescr += "\nInvalid connection between two blocks: "; break; @@ -2038,6 +2257,298 @@ TCollection_AsciiString GEOMImpl_IBlocksOperations::PrintBCErrors return aDescr; } +//============================================================================= +/*! + * CheckCompoundOfBlocks + */ +//============================================================================= +Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks + (Handle(GEOM_Object) theCompound, + list& theErrors) +{ + SetErrorCode(KO); + + if (theCompound.IsNull()) return Standard_False; + TopoDS_Shape aBlockOrComp = theCompound->GetValue(); + + Standard_Boolean isCompOfBlocks = Standard_True; + + // Map sub-shapes and their indices + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + + // 1. Separate blocks from non-blocks + TopTools_ListOfShape NOT; // Not blocks + TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges + TopTools_ListOfShape BLO; // All blocks from the given compound + AddBlocksFrom(aBlockOrComp, BLO, NOT, EXT); + + // Report non-blocks + if (NOT.Extent() > 0) { + isCompOfBlocks = Standard_False; + BCError anErr; + anErr.error = NOT_BLOCK; + TopTools_ListIteratorOfListOfShape it (NOT); + for (; it.More(); it.Next()) { + anErr.incriminated.push_back(anIndices.FindIndex(it.Value())); + } + theErrors.push_back(anErr); + } + + // Report solids, having degenerated and/or seam edges + if (EXT.Extent() > 0) { + isCompOfBlocks = Standard_False; + BCError anErr; + anErr.error = EXTRA_EDGE; + TopTools_ListIteratorOfListOfShape it (EXT); + for (; it.More(); it.Next()) { + anErr.incriminated.push_back(anIndices.FindIndex(it.Value())); + } + theErrors.push_back(anErr); + } + + Standard_Integer nbBlocks = BLO.Extent(); + if (nbBlocks == 0) { + isCompOfBlocks = Standard_False; + SetErrorCode(OK); + return isCompOfBlocks; + } + if (nbBlocks == 1) { + SetErrorCode(OK); + return isCompOfBlocks; + } + + // Prepare data for 2. and 3. + TColStd_Array2OfInteger aRelations (1, nbBlocks, 1, nbBlocks); + aRelations.Init(REL_NOT_CONNECTED); + + TopTools_IndexedMapOfShape mapBlocks; + + BRep_Builder BB; + TopoDS_Compound aComp; + BB.MakeCompound(aComp); + + TopTools_ListIteratorOfListOfShape BLOit (BLO); + for (; BLOit.More(); BLOit.Next()) { + mapBlocks.Add(BLOit.Value()); + BB.Add(aComp, BLOit.Value()); + } + + // 2. Find glued blocks (having shared faces) + TopTools_IndexedDataMapOfShapeListOfShape mapFaceBlocks; + GEOMImpl_Block6Explorer::MapShapesAndAncestors + (aComp, TopAbs_FACE, TopAbs_SOLID, mapFaceBlocks); + + Standard_Integer prevInd = 0, curInd = 0; + Standard_Integer ind = 1, nbFaces = mapFaceBlocks.Extent(); + for (; ind <= nbFaces; ind++) { + const TopTools_ListOfShape& aGluedBlocks = mapFaceBlocks.FindFromIndex(ind); + if (aGluedBlocks.Extent() > 1) { // Shared face found + TopTools_ListIteratorOfListOfShape aGluedBlocksIt (aGluedBlocks); + TopoDS_Shape prevBlock, curBlock; + for (; aGluedBlocksIt.More(); aGluedBlocksIt.Next()) { + curBlock = aGluedBlocksIt.Value(); + if (!prevBlock.IsNull()) { + prevInd = mapBlocks.FindIndex(prevBlock); + curInd = mapBlocks.FindIndex(curBlock); + aRelations.SetValue(prevInd, curInd, REL_OK); + aRelations.SetValue(curInd, prevInd, REL_OK); + } + prevBlock = curBlock; + } + } + } + + // 3. Find not glued blocks + GEOMAlgo_GlueAnalyser aGD; + + aGD.SetShape(aComp); + aGD.SetTolerance(Precision::Confusion()); + aGD.SetCheckGeometry(Standard_True); + aGD.Perform(); + + Standard_Integer iErr, iWrn; + iErr = aGD.ErrorStatus(); + if (iErr) { + SetErrorCode("Error in GEOMAlgo_GlueAnalyser"); + return isCompOfBlocks; + } + iWrn = aGD.WarningStatus(); + if (iWrn) { + MESSAGE("Warning in GEOMAlgo_GlueAnalyser"); + } + + // Report not glued blocks + if (aGD.HasSolidsToGlue()) { + isCompOfBlocks = Standard_False; + Standard_Integer aSx1Ind, aSx2Ind; + + const GEOMAlgo_ListOfCoupleOfShapes& aLCS = aGD.SolidsToGlue(); + GEOMAlgo_ListIteratorOfListOfCoupleOfShapes aItCS (aLCS); + for (; aItCS.More(); aItCS.Next()) { + const GEOMAlgo_CoupleOfShapes& aCS = aItCS.Value(); + const TopoDS_Shape& aSx1 = aCS.Shape1(); + const TopoDS_Shape& aSx2 = aCS.Shape2(); + + aSx1Ind = mapBlocks.FindIndex(aSx1); + aSx2Ind = mapBlocks.FindIndex(aSx2); + aRelations.SetValue(aSx1Ind, aSx2Ind, NOT_GLUED); + aRelations.SetValue(aSx2Ind, aSx1Ind, NOT_GLUED); + + BCError anErr; + anErr.error = NOT_GLUED; + anErr.incriminated.push_back(anIndices.FindIndex(aSx1)); + anErr.incriminated.push_back(anIndices.FindIndex(aSx2)); + theErrors.push_back(anErr); + } + } + + // 4. Find largest set of connected (good connection or not glued) blocks + Standard_Integer ibl = 1; + TColStd_MapOfInteger aProcessedMap; + TColStd_MapOfInteger aLargestSet; + TColStd_MapOfInteger aCurrentSet; + for (ibl = 1; ibl <= nbBlocks; ibl++) { + if (!aProcessedMap.Contains(ibl)) { + aCurrentSet.Clear(); + FindConnected(ibl, aRelations, aProcessedMap, aCurrentSet); + if (aCurrentSet.Extent() > aLargestSet.Extent()) { + aLargestSet = aCurrentSet; + } + } + } + + // 5. Report all blocks, isolated from + BCError anErr; + anErr.error = NOT_CONNECTED; + Standard_Boolean hasIsolated = Standard_False; + for (ibl = 1; ibl <= nbBlocks; ibl++) { + if (!aLargestSet.Contains(ibl)) { + aProcessedMap.Clear(); + if (!HasAnyConnection(ibl, aLargestSet, aRelations, aProcessedMap)) { + // report connection absence + hasIsolated = Standard_True; + anErr.incriminated.push_back(anIndices.FindIndex(mapBlocks.FindKey(ibl))); + } + } + } + if (hasIsolated) { + isCompOfBlocks = Standard_False; + theErrors.push_back(anErr); + } + + SetErrorCode(OK); + return isCompOfBlocks; +} + +//============================================================================= +/*! + * RemoveExtraEdges + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges + (Handle(GEOM_Object) theObject) +{ + SetErrorCode(KO); + + if (theObject.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be fixed + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY); + + //Add a function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_REMOVE_EXTRA); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL; + + GEOMImpl_IBlockTrsf aTI (aFunction); + aTI.SetOriginal(aLastFunction); + + //Compute the fixed shape + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Block driver failed to remove extra edges of the given shape"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aCopy->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.RemoveExtraEdges("; + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * CheckAndImprove + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::CheckAndImprove + (Handle(GEOM_Object) theObject) +{ + SetErrorCode(KO); + + if (theObject.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be fixed + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY); + + //Add a function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_COMPOUND_IMPROVE); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL; + + GEOMImpl_IBlockTrsf aTI (aFunction); + aTI.SetOriginal(aLastFunction); + + //Compute the fixed shape + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Block driver failed to improve the given blocks compound"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aCopy->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.CheckAndImprove("; + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + //============================================================================= /*! * ExplodeCompoundOfBlocks @@ -2153,70 +2664,80 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockNearPoint } if (aBlockOrComp.ShapeType() != TopAbs_COMPOUND && aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { - SetErrorCode("Shape is neither a block, nor a compound of blocks"); + SetErrorCode("Shape to find block in is not a compound"); return NULL; } TopoDS_Shape anArg = thePoint->GetValue(); if (anArg.IsNull()) { - SetErrorCode("Null shape is given as argument"); + SetErrorCode("Point is null"); return NULL; } if (anArg.ShapeType() != TopAbs_VERTEX) { - SetErrorCode("Element for block identification is not a vertex"); + SetErrorCode("Shape for block identification is not a vertex"); return NULL; } //Compute the Block value try { TopoDS_Shape aShape; + TopoDS_Vertex aVert = TopoDS::Vertex(anArg); gp_Pnt aPnt = BRep_Tool::Pnt(aVert); + Standard_Real PX, PY, PZ; + aPnt.Coord(PX, PY, PZ); - // 1. Explode compound on blocks - TopTools_MapOfShape mapShape; - Standard_Integer nbSolids = 0; + // 1. Classify the point relatively each block + Standard_Integer nearest = 2, nbFound = 0; + TopTools_DataMapOfShapeInteger mapShapeDist; TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); for (; exp.More(); exp.Next()) { - if (mapShape.Add(exp.Current())) { - nbSolids++; - } - } + TopoDS_Shape aSolid = exp.Current(); + + if (!mapShapeDist.IsBound(aSolid)) { + Standard_Integer aDistance = 2; + + // 1.a. Classify relatively Bounding box + Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; + Bnd_Box BB; + BRepBndLib::Add(aSolid, BB); + BB.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); + if (PX < Xmin || Xmax < PX || + PY < Ymin || Ymax < PY || + PZ < Zmin || Zmax < PZ) { + // OUT of bounding box + aDistance = 1; + } else { + // 1.b. Classify relatively the solid itself + BRepClass3d_SolidClassifier SC (aSolid, aPnt, Precision::Confusion()); + if (SC.State() == TopAbs_IN) { + aDistance = -1; + } else if (SC.State() == TopAbs_ON) { + aDistance = 0; + } else { // OUT + aDistance = 1; + } + } - mapShape.Clear(); - Standard_Integer ind = 1; - TopTools_Array1OfShape aSolids (1, nbSolids); - TColStd_Array1OfInteger aDistances (1, nbSolids); - for (exp.Init(aBlockOrComp, TopAbs_SOLID); exp.More(); exp.Next()) { - if (mapShape.Add(exp.Current())) { - TopoDS_Shape aSolid = exp.Current(); - aSolids(ind) = aSolid; + if (aDistance < nearest) { + nearest = aDistance; + aShape = aSolid; + nbFound = 1; + + // A first found block, containing the point inside, will be returned. + // It is the solution, if there are no intersecting blocks in the compound. + if (nearest == -1) break; - // 2. Classify the point relatively each block - BRepClass3d_SolidClassifier SC (aSolid, aPnt, Precision::Confusion()); - if (SC.State() == TopAbs_IN) { - aDistances(ind) = -1; - } else if (SC.State() == TopAbs_ON) { - aDistances(ind) = 0; - } else { // OUT - aDistances(ind) = 1; + } else if (aDistance == nearest) { + nbFound++; + } else { } - ind++; - } - } - // 3. Define block, containing the point or having minimum distance to it - Standard_Integer nearest = 2, nbFound = 0; - for (ind = 1; ind <= nbSolids; ind++) { - if (aDistances(ind) < nearest) { - nearest = aDistances(ind); - aShape = aSolids(ind); - nbFound = 1; - } else if (aDistances(ind) == nearest) { - nbFound++; - } else { - } + mapShapeDist.Bind(aSolid, aDistance); + } // if (!mapShapeDist.IsBound(aSolid)) } + + // 2. Define block, containing the point or having minimum distance to it if (nbFound > 1) { if (nearest == 0) { // The point is on boundary of some blocks and there are @@ -2229,9 +2750,11 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockNearPoint // no blocks, having the point inside or on boundary. // We will get a nearest block Standard_Real minDist = RealLast(); - for (ind = 1; ind <= nbSolids; ind++) { - if (aDistances(ind) == 1) { - BRepExtrema_DistShapeShape aDistTool (aVert, aSolids(ind)); + TopTools_DataMapIteratorOfDataMapOfShapeInteger mapShapeDistIter (mapShapeDist); + for (; mapShapeDistIter.More(); mapShapeDistIter.Next()) { + if (mapShapeDistIter.Value() == 1) { + TopoDS_Shape aSolid = mapShapeDistIter.Key(); + BRepExtrema_DistShapeShape aDistTool (aVert, aSolid); if (!aDistTool.IsDone()) { SetErrorCode("Can not find a distance from the given point to one of blocks"); return NULL; @@ -2239,29 +2762,31 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockNearPoint Standard_Real aDist = aDistTool.Value(); if (aDist < minDist) { minDist = aDist; - aShape = aSolids(ind); + aShape = aSolid; } } } } else { // nearest == -1 - // The point is inside some blocks. - // We will get a block with nearest center - Standard_Real minDist = RealLast(); - for (ind = 1; ind <= nbSolids; ind++) { - if (aDistances(ind) == -1) { - GProp_GProps aSystem; - BRepGProp::VolumeProperties(aSolids(ind), aSystem); - gp_Pnt aCenterMass = aSystem.CentreOfMass(); - - Standard_Real aDist = aCenterMass.Distance(aPnt); - if (aDist < minDist) { - minDist = aDist; - aShape = aSolids(ind); - } - } - } +// // The point is inside some blocks. +// // We will get a block with nearest center +// Standard_Real minDist = RealLast(); +// TopTools_DataMapIteratorOfDataMapOfShapeInteger mapShapeDistIter (mapShapeDist); +// for (; mapShapeDistIter.More(); mapShapeDistIter.Next()) { +// if (mapShapeDistIter.Value() == -1) { +// TopoDS_Shape aSolid = mapShapeDistIter.Key(); +// GProp_GProps aSystem; +// BRepGProp::VolumeProperties(aSolid, aSystem); +// gp_Pnt aCenterMass = aSystem.CentreOfMass(); +// +// Standard_Real aDist = aCenterMass.Distance(aPnt); +// if (aDist < minDist) { +// minDist = aDist; +// aShape = aSolid; +// } +// } +// } } - } + } // if (nbFound > 1) if (nbFound == 0) { SetErrorCode("There are no blocks near the given point"); @@ -2692,3 +3217,139 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation2D SetErrorCode(OK); return aCopy; } + +//============================================================================= +/*! + * Propagate + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate + (Handle(GEOM_Object) theShape) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return NULL; + + TopoDS_Shape aShape = theShape->GetValue(); + if (aShape.IsNull()) return NULL; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + + TopTools_IndexedDataMapOfShapeListOfShape MEW; + GEOMImpl_Block6Explorer::MapShapesAndAncestors + (aShape, TopAbs_EDGE, TopAbs_WIRE, MEW); + Standard_Integer ie, nbEdges = MEW.Extent(); + + // Result + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + + TopTools_MapOfShape mapAcceptedEdges; + + for (ie = 1; ie <= nbEdges; ie++) { + TopoDS_Shape curE = MEW.FindKey(ie); + + if (mapAcceptedEdges.Contains(curE)) continue; + + // Build the chain + TopTools_ListOfShape currentChain; + TopTools_ListOfShape listPrevEdges; + + currentChain.Append(curE); + listPrevEdges.Append(curE); + mapAcceptedEdges.Add(curE); + + // Collect all edges pass by pass + while (listPrevEdges.Extent() > 0) { + // List of edges, added to chain on this cycle pass + TopTools_ListOfShape listCurEdges; + + // Find the next portion of edges + TopTools_ListIteratorOfListOfShape itE (listPrevEdges); + for (; itE.More(); itE.Next()) { + TopoDS_Shape anE = itE.Value(); + + // Iterate on faces, having edge + TopTools_ListIteratorOfListOfShape itW (MEW.FindFromKey(anE)); + for (; itW.More(); itW.Next()) { + TopoDS_Shape aW = itW.Value(); + TopoDS_Shape anOppE; + + BRepTools_WireExplorer aWE (TopoDS::Wire(aW)); + Standard_Integer nb = 1, found = 0; + TopTools_Array1OfShape anEdges (1,4); + for (; aWE.More(); aWE.Next(), nb++) { + if (nb > 4) { + found = 0; + break; + } + anEdges(nb) = aWE.Current(); + if (anEdges(nb).IsSame(anE)) found = nb; + } + + if (nb == 5 && found > 0) { + // Quadrangle face found, get an opposite edge + Standard_Integer opp = found + 2; + if (opp > 4) opp -= 4; + anOppE = anEdges(opp); + + if (!mapAcceptedEdges.Contains(anOppE)) { + // Add found edge to the chain + currentChain.Append(anOppE); + listCurEdges.Append(anOppE); + mapAcceptedEdges.Add(anOppE); + } + } // if (nb == 5 && found > 0) + } // for (; itF.More(); itF.Next()) + } // for (; itE.More(); itE.Next()) + + listPrevEdges = listCurEdges; + } // while (listPrevEdges.Extent() > 0) + + // Store the chain in the document + Handle(TColStd_HArray1OfInteger) anArray = + new TColStd_HArray1OfInteger (1, currentChain.Extent()); + + // Fill array of sub-shape indices + TopTools_ListIteratorOfListOfShape itSub (currentChain); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + int id = anIndices.FindIndex(itSub.Value()); + anArray->SetValue(index, id); + } + + // Add a new group object + Handle(GEOM_Object) aChain = GetEngine()->AddSubShape(theShape, anArray); + + // Set a GROUP type + aChain->SetType(GEOM_GROUP); + + // Set a sub shape type + TDF_Label aFreeLabel = aChain->GetFreeLabel(); + TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)TopAbs_EDGE); + + // Add the chain to the result + aSeq->Append(aChain); + } + + if (aSeq->IsEmpty()) { + SetErrorCode("There are no quadrangle faces in the shape"); + return aSeq; + } + + // The Propagation doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + // Make a Python command + TCollection_AsciiString aDescr + ("\nlistPropagationChains = IShapesOperations.Propagate("); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry + ")"); + + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); + anOldDescr = anOldDescr + aDescr; + aFunction->SetDescription(anOldDescr); + + SetErrorCode(OK); + return aSeq; +} diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx index 1ea16a053..9c7010594 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx @@ -85,6 +85,7 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations { enum BCErrorType { NOT_BLOCK, + EXTRA_EDGE, INVALID_CONNECTION, NOT_CONNECTED, NOT_GLUED @@ -95,12 +96,24 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations { list incriminated; }; + Standard_Boolean CheckCompoundOfBlocksOld (Handle(GEOM_Object) theCompound, + list& theErrors); + Standard_Boolean CheckCompoundOfBlocks (Handle(GEOM_Object) theCompound, list& theErrors); TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object) theCompound, const list& theErrors); + Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape); + + Handle(GEOM_Object) CheckAndImprove (Handle(GEOM_Object) theCompound); + + static void AddBlocksFrom (const TopoDS_Shape& theShape, + TopTools_ListOfShape& BLO, + TopTools_ListOfShape& NOT, + TopTools_ListOfShape& EXT); + // Extract blocks from blocks compounds Handle(TColStd_HSequenceOfTransient) ExplodeCompoundOfBlocks (Handle(GEOM_Object) theCompound, @@ -131,6 +144,9 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations { const Standard_Integer theDirFace1V, const Standard_Integer theDirFace2V, const Standard_Integer theNbTimesV); + + // Build groups for Propagation of 1D hypotheses + Handle(TColStd_HSequenceOfTransient) Propagate (Handle(GEOM_Object) theShape); }; #endif diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index ee637328b..71ff1b32d 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -13,6 +13,8 @@ using namespace std; #include "GEOMImpl_IShapes.hxx" #include "GEOMImpl_IGlue.hxx" +#include "GEOMImpl_Block6Explorer.hxx" + #include "GEOM_Function.hxx" #include "utilities.h" @@ -22,27 +24,47 @@ using namespace std; #include #include #include +#include #include +#include + #include #include +#include +#include #include #include #include #include +#include +#include +#include #include #include +#include #include #include #include #include +#include +#include +#include +#include +#include + +#include + #include #include +#include #include #include +//#include + #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= @@ -207,7 +229,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) th */ //============================================================================= Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires - (list theShapes, bool isPlanarWanted) + (list theShapes, + const bool isPlanarWanted) { SetErrorCode(KO); @@ -482,6 +505,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces aCI.SetTolerance(theTolerance); //Compute the sub-shape value + Standard_Boolean isWarning = Standard_False; try { if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Shape driver failed to glue faces"); @@ -491,7 +515,12 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces catch (Standard_Failure) { Handle(Standard_Failure) aFail = Standard_Failure::Caught(); SetErrorCode(aFail->GetMessageString()); - return NULL; + // to provide warning + if (!aFunction->GetValue().IsNull()) { + isWarning = Standard_True; + } else { + return NULL; + } } //Make a Python command @@ -505,7 +534,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces aFunction->SetDescription(aDescr); - SetErrorCode(OK); + // to provide warning + if (!isWarning) SetErrorCode(OK); return aGlued; } @@ -519,6 +549,9 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode const Standard_Integer theShapeType, const Standard_Boolean isSorted) { +// OSD_Timer timer1, timer2, timer3, timer4; +// timer1.Start(); + SetErrorCode(KO); if (theShape.IsNull()) return NULL; @@ -556,9 +589,15 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode return aSeq; } +// timer1.Stop(); +// timer2.Start(); + if (isSorted) SortShapes(listShape); +// timer2.Stop(); +// timer3.Start(); + TopTools_IndexedMapOfShape anIndices; TopExp::MapShapes(aShape, anIndices); Handle(TColStd_HArray1OfInteger) anArray; @@ -577,6 +616,9 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode anAsciiList += ","; } +// timer3.Stop(); +// timer4.Start(); + anAsciiList.Trunc(anAsciiList.Length() - 1); anAsciiList += "]"; @@ -601,6 +643,97 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode SetErrorCode(OK); +// timer4.Stop(); + +// cout << "Explosure takes:" << endl; +// timer1.Show(); +// cout << "Sorting takes:" << endl; +// timer2.Show(); +// cout << "Sub-shapes addition takes:" << endl; +// timer3.Show(); +// cout << "Update Description takes:" << endl; +// timer4.Show(); + + return aSeq; +} + +//============================================================================= +/*! + * GetSubShapeAllIDs + */ +//============================================================================= +Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs + (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + const Standard_Boolean isSorted) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return NULL; + TopoDS_Shape aShape = theShape->GetValue(); + if (aShape.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + TopTools_MapOfShape mapShape; + TopTools_ListOfShape listShape; + + if (aShape.ShapeType() == TopAbs_COMPOUND && + (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE || + TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPSOLID || + TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPOUND)) { + TopoDS_Iterator It (aShape, Standard_True, Standard_True); + for (; It.More(); It.Next()) { + if (mapShape.Add(It.Value())) { + if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE || + TopAbs_ShapeEnum(theShapeType) == It.Value().ShapeType()) { + listShape.Append(It.Value()); + } + } + } + } else { + TopExp_Explorer exp (aShape, TopAbs_ShapeEnum(theShapeType)); + for (; exp.More(); exp.Next()) + if (mapShape.Add(exp.Current())) + listShape.Append(exp.Current()); + } + + if (listShape.IsEmpty()) { + SetErrorCode("The given shape has no sub-shapes of the requested type"); + return aSeq; + } + + if (isSorted) + SortShapes(listShape); + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + Handle(TColStd_HArray1OfInteger) anArray; + + TopTools_ListIteratorOfListOfShape itSub (listShape); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + TopoDS_Shape aValue = itSub.Value(); + aSeq->Append(anIndices.FindIndex(aValue)); + } + + //The explode doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString aDescr + ("\nlistSubShapeAllIDs = IShapesOperations.SubShapeAllIDs("); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry + ","); + if (isSorted) + aDescr += (TCollection_AsciiString(theShapeType) + ", 1)"); + else + aDescr += (TCollection_AsciiString(theShapeType) + ", 0)"); + + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); + anOldDescr = anOldDescr + aDescr; + aFunction->SetDescription(anOldDescr); + + SetErrorCode(OK); return aSeq; } @@ -754,6 +887,650 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object) return aReversed; } +//============================================================================= +/*! + * GetFreeFacesIDs + */ +//============================================================================= +Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetFreeFacesIDs + (Handle(GEOM_Object) theShape) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return NULL; + TopoDS_Shape aShape = theShape->GetValue(); + if (aShape.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + TopTools_IndexedDataMapOfShapeListOfShape mapFaceBlocks; + GEOMImpl_Block6Explorer::MapShapesAndAncestors + (aShape, TopAbs_FACE, TopAbs_SOLID, mapFaceBlocks); + + Standard_Integer ind = 1, nbFaces = mapFaceBlocks.Extent(); + + if (nbFaces == 0) { + SetErrorCode("The given shape has no faces"); + return aSeq; + } + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + + Standard_Integer id; + for (; ind <= nbFaces; ind++) { + if (mapFaceBlocks.FindFromIndex(ind).Extent() != 2) { + id = anIndices.FindIndex(mapFaceBlocks.FindKey(ind)); + aSeq->Append(id); + } + } + + //The explode doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString aDescr ("\nlistFreeFacesIDs = IShapesOperations.GetFreeFacesIDs("); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry + ")"); + + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); + anOldDescr = anOldDescr + aDescr; + aFunction->SetDescription(anOldDescr); + + SetErrorCode(OK); + return aSeq; +} + +//============================================================================= +/*! + * GetSharedShapes + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes + (Handle(GEOM_Object) theShape1, + Handle(GEOM_Object) theShape2, + const Standard_Integer theShapeType) +{ + SetErrorCode(KO); + + if (theShape1.IsNull() || theShape2.IsNull()) return NULL; + + TopoDS_Shape aShape1 = theShape1->GetValue(); + TopoDS_Shape aShape2 = theShape2->GetValue(); + + if (aShape1.IsNull() || aShape2.IsNull()) return NULL; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape1, anIndices); + Handle(TColStd_HArray1OfInteger) anArray; + + TopTools_IndexedMapOfShape mapShape1; + TopExp::MapShapes(aShape1, TopAbs_ShapeEnum(theShapeType), mapShape1); + + Handle(GEOM_Object) anObj; + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + + TopTools_MapOfShape mapShape2; + TopExp_Explorer exp (aShape2, TopAbs_ShapeEnum(theShapeType)); + for (; exp.More(); exp.Next()) { + TopoDS_Shape aSS = exp.Current(); + if (mapShape2.Add(aSS) && mapShape1.Contains(aSS)) { + anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aSS)); + anObj = GetEngine()->AddSubShape(theShape1, anArray); + aSeq->Append(anObj); + } + } + + if (aSeq->IsEmpty()) { + SetErrorCode("The given shapes have no shared sub-shapes of the requested type"); + return aSeq; + } + + //The explode doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape1->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString aDescr + ("\nlistSharedShapes = IShapesOperations.GetSharedShapes("); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theShape1->GetEntry(), anEntry); + aDescr += (anEntry + ","); + TDF_Tool::Entry(theShape2->GetEntry(), anEntry); + aDescr += (anEntry + ","); + aDescr += TCollection_AsciiString(theShapeType) + ")"; + + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); + anOldDescr = anOldDescr + aDescr; + aFunction->SetDescription(anOldDescr); + + SetErrorCode(OK); + return aSeq; +} + +//============================================================================= +/*! + * GetShapesOnPlane + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnPlane + (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + Handle(GEOM_Object) thePlane) +{ + SetErrorCode(KO); + + if (theShape.IsNull() || thePlane.IsNull()) return NULL; + + TopoDS_Shape aShape = theShape->GetValue(); + TopoDS_Shape aPlane = thePlane->GetValue(); + + if (aShape.IsNull() || aPlane.IsNull()) return NULL; + + TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(theShapeType); + if (aShapeType != TopAbs_VERTEX && + aShapeType != TopAbs_EDGE && + aShapeType != TopAbs_FACE) { + SetErrorCode("Not implemented for the given sub-shape type"); + return NULL; + } + + //Get plane parameters + if (aPlane.IsNull() || aPlane.ShapeType() != TopAbs_FACE) return NULL; + TopoDS_Face aFace = TopoDS::Face(aPlane); + Handle(Geom_Surface) surf = BRep_Tool::Surface(aFace); + Handle(Geom_Plane) pln = Handle(Geom_Plane)::DownCast(surf); + if (pln.IsNull()) { + SetErrorCode("Not planar face given"); + return NULL; + } + const gp_Ax3 pos = pln->Position(); + const gp_Pnt loc = pos.Location(); + const gp_Dir dir = pos.Direction(); + + //Find sub-shapes on the plane + TopTools_ListOfShape listSS; + TopTools_MapOfShape mapShapes; + TopExp_Explorer exp (aShape, aShapeType); + for (; exp.More(); exp.Next()) { + TopoDS_Shape aSS = exp.Current(); + if (mapShapes.Add(aSS)) { + switch (aShapeType) { + case TopAbs_VERTEX: + { + TopoDS_Vertex aV = TopoDS::Vertex(aSS); + gp_Pnt aP = BRep_Tool::Pnt(aV); + gp_Vec vecToLoc (aP, loc); + if (vecToLoc.IsNormal(dir, Precision::Angular())) { + listSS.Append(aSS); + } + } + break; + case TopAbs_EDGE: + { + TopoDS_Edge anEdge = TopoDS::Edge(aSS); + Standard_Real f, l; + Handle(Geom2d_Curve) PC; + Handle(Geom_Surface) cur_surf; + TopLoc_Location L; + Standard_Integer i = 0; + + // iterate on the surfaces of the edge + while (Standard_True) { + i++; + BRep_Tool::CurveOnSurface(anEdge, PC , cur_surf, L, f, l, i); + if (cur_surf.IsNull()) break; + + Handle(Geom_Plane) cur_pln = Handle(Geom_Plane)::DownCast(cur_surf); + if (!cur_pln.IsNull()) { + const gp_Ax3 cur_pos = cur_pln->Position(); + const gp_Pnt cur_loc = cur_pos.Location(); + const gp_Dir cur_dir = cur_pos.Direction(); + gp_Vec vecToLoc (cur_loc, loc); + if (vecToLoc.IsNormal(dir, Precision::Angular()) && + cur_dir.IsParallel(dir, Precision::Angular())) { + listSS.Append(aSS); + } + } + } + } + break; + case TopAbs_FACE: + { + TopoDS_Face aF = TopoDS::Face(aSS); + Handle(Geom_Surface) cur_surf = BRep_Tool::Surface(aF); + Handle(Geom_Plane) cur_pln = Handle(Geom_Plane)::DownCast(cur_surf); + if (!cur_pln.IsNull()) { + const gp_Ax3 cur_pos = cur_pln->Position(); + const gp_Pnt cur_loc = cur_pos.Location(); + const gp_Dir cur_dir = cur_pos.Direction(); + gp_Vec vecToLoc (cur_loc, loc); + if (vecToLoc.IsNormal(dir, Precision::Angular()) && + cur_dir.IsParallel(dir, Precision::Angular())) { + listSS.Append(aSS); + } + } + } + break; + default: + break; + } + } + } + + if (listSS.Extent() < 1) { + SetErrorCode("Not a single sub-shape of the requested type found on the given plane"); + return NULL; + } + + //Fill array of indices + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + + Handle(TColStd_HArray1OfInteger) anArray = + new TColStd_HArray1OfInteger (1, listSS.Extent()); + TopTools_ListIteratorOfListOfShape itSub (listSS); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + int id = anIndices.FindIndex(itSub.Value()); + anArray->SetValue(index, id); + } + + //Add a new group object + Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theShape, anArray); + + //Set a GROUP type + aGroup->SetType(GEOM_GROUP); + + //Set a sub shape type + TDF_Label aFreeLabel = aGroup->GetFreeLabel(); + TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IShapesOperations.GetShapesOnPlane("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + TCollection_AsciiString(theShapeType) + ","; + TDF_Tool::Entry(thePlane->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + Handle(GEOM_Function) aFunction = aGroup->GetFunction(1); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aGroup; +} + +//============================================================================= +/*! + * GetShapesOnCylinder + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnCylinder + (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + Handle(GEOM_Object) theAxis, + const Standard_Real theRadius) +{ + SetErrorCode(KO); + + if (theShape.IsNull() || theAxis.IsNull()) return NULL; + + TopoDS_Shape aShape = theShape->GetValue(); + TopoDS_Shape anAxis = theAxis->GetValue(); + + if (aShape.IsNull() || anAxis.IsNull()) return NULL; + + TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(theShapeType); + if (aShapeType != TopAbs_VERTEX && + aShapeType != TopAbs_EDGE && + aShapeType != TopAbs_FACE) { + SetErrorCode("Not implemented for the given sub-shape type"); + return NULL; + } + + //Axis of the cylinder + if (anAxis.ShapeType() != TopAbs_EDGE) { + SetErrorCode("Not an edge given for the axis"); + return NULL; + } + TopoDS_Edge anEdge = TopoDS::Edge(anAxis); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2, Standard_True); + if (V1.IsNull() || V2.IsNull()) { + SetErrorCode("Bad edge given for the axis"); + return NULL; + } + gp_Pnt loc = BRep_Tool::Pnt(V1); + gp_Vec aVec (loc, BRep_Tool::Pnt(V2)); + gp_Dir dir (aVec); + gp_Lin aLin (loc, aVec); + + //Find sub-shapes on the cylinder + TopTools_ListOfShape listSS; + TopTools_MapOfShape mapShapes; + TopExp_Explorer exp (aShape, aShapeType); + for (; exp.More(); exp.Next()) { + TopoDS_Shape aSS = exp.Current(); + if (mapShapes.Add(aSS)) { + switch (aShapeType) { + case TopAbs_VERTEX: + { + TopoDS_Vertex aV = TopoDS::Vertex(aSS); + gp_Pnt aP = BRep_Tool::Pnt(aV); + if (Abs(aLin.Distance(aP) - theRadius) < Precision::Confusion()) { + listSS.Append(aSS); + } + } + break; + case TopAbs_EDGE: + { + TopoDS_Edge anEdge = TopoDS::Edge(aSS); + Standard_Real f, l; + Handle(Geom2d_Curve) PC; + Handle(Geom_Surface) cur_surf; + TopLoc_Location L; + Standard_Integer i = 0; + + // iterate on the surfaces of the edge + while (Standard_True) { + i++; + BRep_Tool::CurveOnSurface(anEdge, PC , cur_surf, L, f, l, i); + if (cur_surf.IsNull()) break; + + Handle(Geom_CylindricalSurface) cur_cyl = + Handle(Geom_CylindricalSurface)::DownCast(cur_surf); + if (!cur_cyl.IsNull()) { + const gp_Ax3 cur_pos = cur_cyl->Position(); + const gp_Pnt cur_loc = cur_pos.Location(); + const gp_Dir cur_dir = cur_pos.Direction(); + const Standard_Real cur_rad = cur_cyl->Radius(); + gp_Vec vecToLoc (cur_loc, loc); + if (vecToLoc.IsParallel(dir, Precision::Angular()) && + cur_dir.IsParallel(dir, Precision::Angular()) && + Abs(cur_rad - theRadius) < Precision::Confusion()) { + listSS.Append(aSS); + } + } + } + } + break; + case TopAbs_FACE: + { + TopoDS_Face aF = TopoDS::Face(aSS); + Handle(Geom_Surface) cur_surf = BRep_Tool::Surface(aF); + Handle(Geom_CylindricalSurface) cur_cyl = + Handle(Geom_CylindricalSurface)::DownCast(cur_surf); + if (!cur_cyl.IsNull()) { + const gp_Ax3 cur_pos = cur_cyl->Position(); + const gp_Pnt cur_loc = cur_pos.Location(); + const gp_Dir cur_dir = cur_pos.Direction(); + const Standard_Real cur_rad = cur_cyl->Radius(); + gp_Vec vecToLoc (cur_loc, loc); + if (vecToLoc.IsParallel(dir, Precision::Angular()) && + cur_dir.IsParallel(dir, Precision::Angular()) && + Abs(cur_rad - theRadius) < Precision::Confusion()) { + listSS.Append(aSS); + } + } + } + break; + default: + break; + } + } + } + + if (listSS.Extent() < 1) { + SetErrorCode("Not a single sub-shape of the requested type found on the given cylinder"); + return NULL; + } + + //Fill array of indices + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + + Handle(TColStd_HArray1OfInteger) anArray = + new TColStd_HArray1OfInteger (1, listSS.Extent()); + TopTools_ListIteratorOfListOfShape itSub (listSS); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + int id = anIndices.FindIndex(itSub.Value()); + anArray->SetValue(index, id); + } + + //Add a new group object + Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theShape, anArray); + + //Set a GROUP type + aGroup->SetType(GEOM_GROUP); + + //Set a sub shape type + TDF_Label aFreeLabel = aGroup->GetFreeLabel(); + TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IShapesOperations.GetShapesOnCylinder("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + TCollection_AsciiString(theShapeType) + ","; + TDF_Tool::Entry(theAxis->GetEntry(), anEntry); + aDescr += anEntry + TCollection_AsciiString(theRadius) + ")"; + + Handle(GEOM_Function) aFunction = aGroup->GetFunction(1); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aGroup; +} + +//============================================================================= +/*! + * GetShapesOnSphere + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnSphere + (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + Handle(GEOM_Object) theCenter, + const Standard_Real theRadius) +{ + SetErrorCode(KO); + + if (theShape.IsNull() || theCenter.IsNull()) return NULL; + + TopoDS_Shape aShape = theShape->GetValue(); + TopoDS_Shape aCenter = theCenter->GetValue(); + + if (aShape.IsNull() || aCenter.IsNull()) return NULL; + + TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(theShapeType); + if (aShapeType != TopAbs_VERTEX && + aShapeType != TopAbs_EDGE && + aShapeType != TopAbs_FACE) { + SetErrorCode("Not implemented for the given sub-shape type"); + return NULL; + } + + //Center of the sphere + if (aCenter.ShapeType() != TopAbs_VERTEX) return NULL; + gp_Pnt aC = BRep_Tool::Pnt(TopoDS::Vertex(aCenter)); + + //Find sub-shapes on the sphere + TopTools_ListOfShape listSS; + TopTools_MapOfShape mapShapes; + TopExp_Explorer exp (aShape, aShapeType); + for (; exp.More(); exp.Next()) { + TopoDS_Shape aSS = exp.Current(); + if (mapShapes.Add(aSS)) { + switch (aShapeType) { + case TopAbs_VERTEX: + { + TopoDS_Vertex aV = TopoDS::Vertex(aSS); + gp_Pnt aP = BRep_Tool::Pnt(aV); + if (Abs(aP.Distance(aC) - theRadius) < Precision::Confusion()) { + listSS.Append(aSS); + } + } + break; + case TopAbs_EDGE: + { + TopoDS_Edge anEdge = TopoDS::Edge(aSS); + Standard_Real f, l; + Handle(Geom2d_Curve) PC; + Handle(Geom_Surface) cur_surf; + TopLoc_Location L; + Standard_Integer i = 0; + + // iterate on the surfaces of the edge + while (Standard_True) { + i++; + BRep_Tool::CurveOnSurface(anEdge, PC , cur_surf, L, f, l, i); + if (cur_surf.IsNull()) break; + + Handle(Geom_SphericalSurface) cur_sph = + Handle(Geom_SphericalSurface)::DownCast(cur_surf); + if (!cur_sph.IsNull()) { + const gp_Ax3 cur_pos = cur_sph->Position(); + const gp_Pnt cur_loc = cur_pos.Location(); + const Standard_Real cur_rad = cur_sph->Radius(); + if (cur_loc.Distance(aC) < Precision::Confusion() && + Abs(cur_rad - theRadius) < Precision::Confusion()) { + listSS.Append(aSS); + } + } + } + } + break; + case TopAbs_FACE: + { + TopoDS_Face aF = TopoDS::Face(aSS); + Handle(Geom_Surface) cur_surf = BRep_Tool::Surface(aF); + Handle(Geom_SphericalSurface) cur_sph = + Handle(Geom_SphericalSurface)::DownCast(cur_surf); + if (!cur_sph.IsNull()) { + const gp_Ax3 cur_pos = cur_sph->Position(); + const gp_Pnt cur_loc = cur_pos.Location(); + const Standard_Real cur_rad = cur_sph->Radius(); + if (cur_loc.Distance(aC) < Precision::Confusion() && + Abs(cur_rad - theRadius) < Precision::Confusion()) { + listSS.Append(aSS); + } + } + } + break; + default: + break; + } + } + } + + if (listSS.Extent() < 1) { + SetErrorCode("Not a single sub-shape of the requested type found on the given sphere"); + return NULL; + } + + //Fill array of indices + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + + Handle(TColStd_HArray1OfInteger) anArray = + new TColStd_HArray1OfInteger (1, listSS.Extent()); + TopTools_ListIteratorOfListOfShape itSub (listSS); + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + int id = anIndices.FindIndex(itSub.Value()); + anArray->SetValue(index, id); + } + + //Add a new group object + Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theShape, anArray); + + //Set a GROUP type + aGroup->SetType(GEOM_GROUP); + + //Set a sub shape type + TDF_Label aFreeLabel = aGroup->GetFreeLabel(); + TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aGroup->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IShapesOperations.GetShapesOnSphere("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + TCollection_AsciiString(theShapeType) + ","; + TDF_Tool::Entry(theCenter->GetEntry(), anEntry); + aDescr += anEntry + TCollection_AsciiString(theRadius) + ")"; + + Handle(GEOM_Function) aFunction = aGroup->GetFunction(1); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aGroup; +} + +//============================================================================= +/*! + * GetInPlace + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace + (Handle(GEOM_Object) theShapeWhere, + Handle(GEOM_Object) theShapeWhat) +{ + SetErrorCode(KO); + + if (theShapeWhere.IsNull() || theShapeWhat.IsNull()) return NULL; + + TopoDS_Shape aWhere = theShapeWhere->GetValue(); + TopoDS_Shape aWhat = theShapeWhat->GetValue(); + + if (aWhere.IsNull() || aWhat.IsNull()) return NULL; + + //Fill array of indices + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aWhere, anIndices); + +// Handle(TColStd_HArray1OfInteger) anArray = +// new TColStd_HArray1OfInteger (1, listSS.Extent()); +// TopTools_ListIteratorOfListOfShape itSub (listSS); +// for (int index = 1; itSub.More(); itSub.Next(), ++index) { +// int id = anIndices.FindIndex(itSub.Value()); +// anArray->SetValue(index, id); +// } +// +// //Add a new group object +// Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theShape, anArray); +// +// //Set a GROUP type +// aGroup->SetType(GEOM_GROUP); +// +// //Set a sub shape type +// TDF_Label aFreeLabel = aGroup->GetFreeLabel(); +// TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType); +// +// //Make a Python command +// TCollection_AsciiString anEntry, aDescr; +// TDF_Tool::Entry(aGroup->GetEntry(), anEntry); +// aDescr += anEntry; +// aDescr += " = IShapesOperations.GetInPlace("; +// TDF_Tool::Entry(theShapeWhere->GetEntry(), anEntry); +// aDescr += anEntry + ","; +// TDF_Tool::Entry(theShapeWhat->GetEntry(), anEntry); +// aDescr += anEntry + ")"; +// +// Handle(GEOM_Function) aFunction = aGroup->GetFunction(1); +// aFunction->SetDescription(aDescr); + +// SetErrorCode(OK); +// return aGroup; + SetErrorCode("Not implemented"); + return NULL; +} + //======================================================================= //function : SortShapes diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx index 9ae51717a..469f88541 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -6,6 +6,7 @@ #include #include +#include #include @@ -23,9 +24,10 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations { Handle(GEOM_Object) MakeWire (list theEdgesAndWires); - Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, bool isPlanarWanted); + Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted); - Handle(GEOM_Object) MakeFaceWires (list theWires, bool isPlanarWanted); + Handle(GEOM_Object) MakeFaceWires (list theWires, + const bool isPlanarWanted); Handle(GEOM_Object) MakeShell (list theShapes); @@ -42,6 +44,10 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations { const Standard_Integer theShapeType, const Standard_Boolean isSorted); + Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + const Standard_Boolean isSorted); + Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape, const Standard_Integer theID); @@ -50,6 +56,29 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations { Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes); + Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape); + + Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object) theShape1, + Handle(GEOM_Object) theShape2, + const Standard_Integer theShapeType); + + Handle(GEOM_Object) GetShapesOnPlane (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + Handle(GEOM_Object) thePlane); + + Handle(GEOM_Object) GetShapesOnCylinder (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + Handle(GEOM_Object) theAxis, + const Standard_Real theRadius); + + Handle(GEOM_Object) GetShapesOnSphere (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + Handle(GEOM_Object) theCenter, + const Standard_Real theRadius); + + Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere, + Handle(GEOM_Object) theShapeWhat); + static void SortShapes (TopTools_ListOfShape& SL); private: diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index fa8aed6dc..982ef59ae 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -202,7 +202,9 @@ #define BLOCK_TWO_FACES 5 #define BLOCK_MULTI_TRANSFORM_1D 6 #define BLOCK_MULTI_TRANSFORM_2D 7 -#define BLOCK_COMPOUND_GLUE 8 +#define BLOCK_COMPOUND_GLUE 8 +#define BLOCK_REMOVE_EXTRA 9 +#define BLOCK_COMPOUND_IMPROVE 10 // Marker #define MARKER_CS 1 diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index c744b4b9b..56ad67851 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -1,3 +1,5 @@ +#include + using namespace std; #include "GEOM_Gen_i.hh" diff --git a/src/GEOM_I/GEOM_IBlocksOperations_i.cc b/src/GEOM_I/GEOM_IBlocksOperations_i.cc index a5aeb7ee8..4c1d25cdd 100644 --- a/src/GEOM_I/GEOM_IBlocksOperations_i.cc +++ b/src/GEOM_I/GEOM_IBlocksOperations_i.cc @@ -657,6 +657,9 @@ CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks case GEOMImpl_IBlocksOperations::NOT_BLOCK: anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK; break; + case GEOMImpl_IBlocksOperations::EXTRA_EDGE: + anError->error = GEOM::GEOM_IBlocksOperations::EXTRA_EDGE; + break; case GEOMImpl_IBlocksOperations::INVALID_CONNECTION: anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION; break; @@ -720,6 +723,9 @@ char* GEOM_IBlocksOperations_i::PrintBCErrors case GEOM::GEOM_IBlocksOperations::NOT_BLOCK: errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK; break; + case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE: + errStruct.error = GEOMImpl_IBlocksOperations::EXTRA_EDGE; + break; case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION: errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION; break; @@ -746,6 +752,64 @@ char* GEOM_IBlocksOperations_i::PrintBCErrors return CORBA::string_dup(aDescr.ToCString()); } +//============================================================================= +/*! + * RemoveExtraEdges + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference Objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return aGEOMObject._retn(); + + //Get the result + Handle(GEOM_Object) anObject = + GetOperations()->RemoveExtraEdges(aShape); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * CheckAndImprove + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::CheckAndImprove (GEOM::GEOM_Object_ptr theCompound) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theCompound == NULL) return aGEOMObject._retn(); + + //Get the reference Objects + Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject + (theCompound->GetStudyID(), theCompound->GetEntry()); + + if (aCompound.IsNull()) return aGEOMObject._retn(); + + //Get the result + Handle(GEOM_Object) anObject = + GetOperations()->CheckAndImprove(aCompound); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * GetBlockNearPoint @@ -937,3 +1001,37 @@ GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D return GetObject(anObject); } + +//============================================================================= +/*! + * Propagate + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IBlocksOperations_i::Propagate (GEOM::GEOM_Object_ptr theShape) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL) return aSeq._retn(); + + //Get the reference Shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return aSeq._retn(); + + //Get the Propagation chains + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->Propagate(aShape); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} diff --git a/src/GEOM_I/GEOM_IBlocksOperations_i.hh b/src/GEOM_I/GEOM_IBlocksOperations_i.hh index 32c5085da..52d81ffa6 100644 --- a/src/GEOM_I/GEOM_IBlocksOperations_i.hh +++ b/src/GEOM_I/GEOM_IBlocksOperations_i.hh @@ -91,6 +91,10 @@ class GEOM_IBlocksOperations_i : char* PrintBCErrors (GEOM::GEOM_Object_ptr theCompound, const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors); + GEOM::GEOM_Object_ptr RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape); + + GEOM::GEOM_Object_ptr CheckAndImprove (GEOM::GEOM_Object_ptr theCompound); + // Extract blocks from blocks compounds GEOM::ListOfGO* ExplodeCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound, const CORBA::Long theMinNbFaces, @@ -119,6 +123,9 @@ class GEOM_IBlocksOperations_i : const CORBA::Long theDirFace2V, const CORBA::Long theNbTimesV); + // Build groups for Propagation of 1D hypotheses + GEOM::ListOfGO* Propagate (GEOM::GEOM_Object_ptr theShape); + ::GEOMImpl_IBlocksOperations* GetOperations() { return (::GEOMImpl_IBlocksOperations*)GetImpl(); } }; diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.cc b/src/GEOM_I/GEOM_IShapesOperations_i.cc index 4f8236d4a..9bfdf7f6b 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.cc +++ b/src/GEOM_I/GEOM_IShapesOperations_i.cc @@ -108,7 +108,8 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire */ //============================================================================= GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace - (GEOM::GEOM_Object_ptr theWire, CORBA::Boolean isPlanarWanted) + (GEOM::GEOM_Object_ptr theWire, + const CORBA::Boolean isPlanarWanted) { GEOM::GEOM_Object_var aGEOMObject; @@ -138,7 +139,7 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace //============================================================================= GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires (const GEOM::ListOfGO& theWires, - CORBA::Boolean isPlanarWanted) + const CORBA::Boolean isPlanarWanted) { GEOM::GEOM_Object_var aGEOMObject; @@ -323,10 +324,12 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces if (aShape.IsNull()) return aGEOMObject._retn(); - //Perform the glueing + //Perform the gluing Handle(GEOM_Object) anObject = GetOperations()->MakeGlueFaces(aShape, theTolerance); - if (!GetOperations()->IsDone() || anObject.IsNull()) + //if (!GetOperations()->IsDone() || anObject.IsNull()) + // to allow warning + if (anObject.IsNull()) return aGEOMObject._retn(); return GetObject(anObject); @@ -342,10 +345,15 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr the const CORBA::Boolean isSorted) { GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - if (theShape == NULL) return aSeq._retn(); - Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject(theShape->GetStudyID(), theShape->GetEntry()); - Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeExplode(aShape, theShapeType, isSorted); - if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn(); + if (theShape == NULL) return aSeq._retn(); + + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->MakeExplode(aShape, theShapeType, isSorted); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); Standard_Integer aLength = aHSeq->Length(); aSeq->length(aLength); @@ -355,6 +363,33 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr the return aSeq._retn(); } +//============================================================================= +/*! + * SubShapeAllIDs + */ +//============================================================================= +GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + const CORBA::Boolean isSorted) +{ + GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong; + if (theShape == NULL) return aSeq._retn(); + + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + Handle(TColStd_HSequenceOfInteger) aHSeq = + GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = aHSeq->Value(i); + + return aSeq._retn(); +} + //============================================================================= /*! * GetSubShape @@ -422,7 +457,7 @@ CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theSh //============================================================================= /*! - * ReverseOrientation + * ChangeOrientation */ //============================================================================= GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation @@ -449,3 +484,207 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation return GetObject(anObject); } +//============================================================================= +/*! + * GetFreeFacesIDs + */ +//============================================================================= +GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape) +{ + GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong; + if (theShape == NULL) return aSeq._retn(); + + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + Handle(TColStd_HSequenceOfInteger) aHSeq = + GetOperations()->GetFreeFacesIDs(aShape); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = aHSeq->Value(i); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * GetSharedShapes + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes + (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + const CORBA::Long theShapeType) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + if (theShape1 == NULL || + theShape2 == NULL) return aSeq._retn(); + + Handle(GEOM_Object) aShape1 = GetOperations()->GetEngine()->GetObject + (theShape1->GetStudyID(), theShape1->GetEntry()); + Handle(GEOM_Object) aShape2 = GetOperations()->GetEngine()->GetObject + (theShape2->GetStudyID(), theShape2->GetEntry()); + + if (aShape1.IsNull() || + aShape2.IsNull()) return aSeq._retn(); + + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * GetShapesOnPlane + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnPlane + (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr thePlane) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL || + thePlane == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aPlane = GetOperations()->GetEngine()->GetObject + (thePlane->GetStudyID(), thePlane->GetEntry()); + + if (aShape.IsNull() || + aPlane.IsNull()) return aGEOMObject._retn(); + + //Get Shapes On Plane + Handle(GEOM_Object) anObject = + GetOperations()->GetShapesOnPlane(aShape, theShapeType, aPlane); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetShapesOnCylinder + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnCylinder + (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theAxis, + const CORBA::Double theRadius) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL || + theAxis == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject + (theAxis->GetStudyID(), theAxis->GetEntry()); + + if (aShape.IsNull() || + anAxis.IsNull()) return aGEOMObject._retn(); + + //Get Shapes On Cylinder + Handle(GEOM_Object) anObject = + GetOperations()->GetShapesOnCylinder(aShape, theShapeType, anAxis, theRadius); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetShapesOnSphere + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnSphere + (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theCenter, + const CORBA::Double theRadius) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL || + theCenter == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject + (theCenter->GetStudyID(), theCenter->GetEntry()); + + if (aShape.IsNull() || + aCenter.IsNull()) return aGEOMObject._retn(); + + //Get Shapes On Sphere + Handle(GEOM_Object) anObject = + GetOperations()->GetShapesOnSphere(aShape, theShapeType, aCenter, theRadius); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetInPlace + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace + (GEOM::GEOM_Object_ptr theShapeWhere, + GEOM::GEOM_Object_ptr theShapeWhat) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShapeWhere == NULL || + theShapeWhat == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aShapeWhere = GetOperations()->GetEngine()->GetObject + (theShapeWhere->GetStudyID(), theShapeWhere->GetEntry()); + Handle(GEOM_Object) aShapeWhat = GetOperations()->GetEngine()->GetObject + (theShapeWhat->GetStudyID(), theShapeWhat->GetEntry()); + + if (aShapeWhere.IsNull() || + aShapeWhat.IsNull()) return aGEOMObject._retn(); + + //Get Shapes in place of aShapeWhat + Handle(GEOM_Object) anObject = + GetOperations()->GetInPlace(aShapeWhere, aShapeWhat); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.hh b/src/GEOM_I/GEOM_IShapesOperations_i.hh index 4a63bb1f5..dea3af329 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.hh +++ b/src/GEOM_I/GEOM_IShapesOperations_i.hh @@ -16,7 +16,8 @@ class GEOM_IShapesOperations_i : public virtual GEOM_IOperations_i { public: - GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IShapesOperations* theImpl); ~GEOM_IShapesOperations_i(); @@ -26,10 +27,10 @@ class GEOM_IShapesOperations_i : GEOM::GEOM_Object_ptr MakeWire (const GEOM::ListOfGO& theEdgesAndWires); GEOM::GEOM_Object_ptr MakeFace (GEOM::GEOM_Object_ptr theWire, - CORBA::Boolean isPlanarWanted); + const CORBA::Boolean isPlanarWanted); GEOM::GEOM_Object_ptr MakeFaceWires (const GEOM::ListOfGO& theWires, - CORBA::Boolean isPlanarWanted); + const CORBA::Boolean isPlanarWanted); GEOM::GEOM_Object_ptr MakeShell (const GEOM::ListOfGO& theFacesAndShells); @@ -43,8 +44,12 @@ class GEOM_IShapesOperations_i : const CORBA::Double theTolerance); GEOM::ListOfGO* MakeExplode (GEOM::GEOM_Object_ptr theShape, - const CORBA::Long theShapeType, - const CORBA::Boolean isSorted); + const CORBA::Long theShapeType, + const CORBA::Boolean isSorted); + + GEOM::ListOfLong* SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + const CORBA::Boolean isSorted); GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape, const CORBA::Long theID); @@ -54,6 +59,29 @@ class GEOM_IShapesOperations_i : GEOM::GEOM_Object_ptr ChangeOrientation (GEOM::GEOM_Object_ptr theShape); + GEOM::ListOfLong* GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape); + + GEOM::ListOfGO* GetSharedShapes (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + const CORBA::Long theShapeType); + + GEOM::GEOM_Object_ptr GetShapesOnPlane (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr thePlane); + + GEOM::GEOM_Object_ptr GetShapesOnCylinder (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theAxis, + const CORBA::Double theRadius); + + GEOM::GEOM_Object_ptr GetShapesOnSphere (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + GEOM::GEOM_Object_ptr theCenter, + const CORBA::Double theRadius); + + GEOM::GEOM_Object_ptr GetInPlace (GEOM::GEOM_Object_ptr theShapeWhere, + GEOM::GEOM_Object_ptr theShapeWhat); + ::GEOMImpl_IShapesOperations* GetOperations() { return (::GEOMImpl_IShapesOperations*)GetImpl(); } }; diff --git a/src/GEOM_I_Superv/Makefile.in b/src/GEOM_I_Superv/Makefile.in index 961912a81..90ab6307f 100644 --- a/src/GEOM_I_Superv/Makefile.in +++ b/src/GEOM_I_Superv/Makefile.in @@ -53,7 +53,7 @@ EXPORT_HEADERS = # additionnal information to compil and link file CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += -lGEOMEngine -lSalomeNS -lSalomeContainer -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeGenericObj +LDFLAGS += -lGEOMEngine -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeContainer -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeGenericObj # additional file to be cleaned MOSTLYCLEAN = diff --git a/src/GEOM_SWIG/GEOM_Spanner.py b/src/GEOM_SWIG/GEOM_Spanner.py index fd08520ac..cc336a7b4 100644 --- a/src/GEOM_SWIG/GEOM_Spanner.py +++ b/src/GEOM_SWIG/GEOM_Spanner.py @@ -25,30 +25,6 @@ # Module : GEOM # $Header$ -def GetFaceNearPoint (geompy, block, pnt): - anObj = geompy.BlocksOp.GetFaceNearPoint(block, pnt) - if anObj is None: - print "GetFaceNearPoint : ", geompy.BlocksOp.GetErrorCode() - return anObj - -def GetOppositeFace (geompy, block, face): - anObj = geompy.BlocksOp.GetOppositeFace(block, face) - if anObj is None: - print "GetOppositeFace : ", geompy.BlocksOp.GetErrorCode() - return anObj - -def GetFaceByNormale (geompy, block, vec): - anObj = geompy.BlocksOp.GetFaceByNormale(block, vec) - if anObj is None: - print "GetFaceByNormale : ", geompy.BlocksOp.GetErrorCode() - return anObj - -def GetBlockNearPoint (geompy, comp, pnt): - anObj = geompy.BlocksOp.GetBlockNearPoint(comp, pnt) - if anObj is None: - print "GetBlockNearPoint : ", geompy.BlocksOp.GetErrorCode() - return anObj - ############# MakeSpanner ############# def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = None, hasGUI = 0): @@ -96,9 +72,7 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = Edge21 = geompy.MakeEdge(p_15_0, p_15_20) id_edge21 = geompy.addToStudy(Edge21, "1 Edge for Block 2") - Edge22 = BlocksOp.GetEdge(Block1, p_10_0, p_10_25) - if Edge22 is None: - print "BlocksOp.GetEdge(Block1, p_10_0, p_10_25) : ", BlocksOp.GetErrorCode() + Edge22 = geompy.GetEdge(Block1, p_10_0, p_10_25) id_edge22 = geompy.addToStudy(Edge22, "2 Edge for Block 2") Face21 = geompy.MakeQuad2Edges(Edge21, Edge22); @@ -114,7 +88,7 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = p_15_10_1 = geompy.MakeVertex(15., 10., 1.) - Face31 = GetFaceNearPoint(geompy, Block2, p_15_10_1) + Face31 = geompy.GetFaceNearPoint(Block2, p_15_10_1) id_face31 = geompy.addToStudy(Face31, "1 Face for Block 3") Prism1 = geompy.MakePrismVecH(Face31, vx, 5); @@ -140,7 +114,7 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = ### Block 4 ### - Face41 = GetOppositeFace(geompy, Block3, Face31) + Face41 = geompy.GetOppositeFace(Block3, Face31) id_face41 = geompy.addToStudy(Face41, "1 Face for Block 4") p_25_5 = geompy.MakeVertex(25., 5., 0.) @@ -222,7 +196,7 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = p_30_0_1 = geompy.MakeVertex(30., 0., 1.) - Face2s = GetFaceNearPoint(geompy, Block1s, p_30_0_1) + Face2s = geompy.GetFaceNearPoint(Block1s, p_30_0_1) id_face2s = geompy.addToStudy(Face2s, "2 Face of Block 1s") f2s_ind = geompy.LocalOp.GetSubShapeIndex(Block1s, Face2s) @@ -241,10 +215,10 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = p_55_0_1 = geompy.MakeVertex(55., 0., 1.) p_55_110_1 = geompy.MakeVertex(55., -110., 1.) - Face11l = GetFaceNearPoint(geompy, Block5, p_55_0_1) + Face11l = geompy.GetFaceNearPoint(Block5, p_55_0_1) id_face11l = geompy.addToStudy(Face11l, "1 Face for Linking Block 1") - Face12l = GetFaceNearPoint(geompy, Gear, p_55_110_1) + Face12l = geompy.GetFaceNearPoint(Gear, p_55_110_1) id_face12l = geompy.addToStudy(Face12l, "2 Face for Linking Block 1") Block1l = geompy.MakeHexa2Faces(Face11l, Face12l) @@ -255,10 +229,10 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = p_25_0_1 = geompy.MakeVertex(25., 0., 1.) p_45_110_1 = geompy.MakeVertex(45., -110., 1.) - Face21l = GetFaceNearPoint(geompy, Block4, p_25_0_1) + Face21l = geompy.GetFaceNearPoint(Block4, p_25_0_1) id_face21l = geompy.addToStudy(Face21l, "1 Face for Linking Block 2") - Face22l = GetFaceNearPoint(geompy, Gear, p_45_110_1) + Face22l = geompy.GetFaceNearPoint(Gear, p_45_110_1) id_face22l = geompy.addToStudy(Face22l, "2 Face for Linking Block 2") Block2l = geompy.MakeHexa2Faces(Face21l, Face22l) @@ -269,10 +243,10 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = p_55_30_1 = geompy.MakeVertex(55., 30., 1.) p_65_110_1 = geompy.MakeVertex(65., -110., 1.) - Face31l = GetFaceNearPoint(geompy, Mirror1, p_55_30_1) + Face31l = geompy.GetFaceNearPoint(Mirror1, p_55_30_1) id_face31l = geompy.addToStudy(Face31l, "1 Face for Linking Block 3") - Face32l = GetFaceNearPoint(geompy, Gear, p_65_110_1) + Face32l = geompy.GetFaceNearPoint(Gear, p_65_110_1) id_face32l = geompy.addToStudy(Face32l, "2 Face for Linking Block 3") Block3l = geompy.MakeHexa2Faces(Face31l, Face32l) @@ -284,22 +258,22 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = Handle = geompy.MakeGlueFaces(CompLB, 1e-5) id_handle = geompy.addToStudy(Handle, "Handle") - Block1h = GetBlockNearPoint(geompy, Handle, p_45_110_1) + Block1h = geompy.GetBlockNearPoint(Handle, p_45_110_1) id_block1h = geompy.addToStudyInFather(Handle, Block1h, "Block 1 of Handle") - Block2h = GetBlockNearPoint(geompy, Handle, p_65_110_1) + Block2h = geompy.GetBlockNearPoint(Handle, p_65_110_1) id_block2h = geompy.addToStudyInFather(Handle, Block2h, "Block 2 of Handle") - Face11h = GetFaceByNormale(geompy, Block1h, vx) + Face11h = geompy.GetFaceByNormale(Block1h, vx) id_face11h = geompy.addToStudyInFather(Block1h, Face11h, "Face 1") - Face12h = GetOppositeFace(geompy, Block1h, Face11h) + Face12h = geompy.GetOppositeFace(Block1h, Face11h) id_face12h = geompy.addToStudyInFather(Block1h, Face12h, "Face 2") - Face21h = GetFaceByNormale(geompy, Block2h, vx) + Face21h = geompy.GetFaceByNormale(Block2h, vx) id_face21h = geompy.addToStudyInFather(Block2h, Face21h, "Face 1") - Face22h = GetOppositeFace(geompy, Block2h, Face21h) + Face22h = geompy.GetOppositeFace(Block2h, Face21h) id_face22h = geompy.addToStudyInFather(Block2h, Face22h, "Face 2") Block3h = BlocksOp.GetBlockByParts(Handle, [Face11h, Face21h]) @@ -322,7 +296,7 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = ### Check the Spanner ### - isCompOfBlocks6 = BlocksOp.IsCompoundOfBlocks(Spanner, 6, 6) + isCompOfBlocks6 = BlocksOp.CheckCompoundOfBlocks(Spanner) if isCompOfBlocks6 == 0: print "Spanner is not a compound of hexahedral solids" else: @@ -334,14 +308,12 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = ### Get Blocks 4 and 5 from the spanner ### - Face42_sp = BlocksOp.GetFaceByEdges(Spanner, Edge41, Edge42) - if Face42_sp is None: - print "BlocksOp.GetFaceByEdges(Spanner, Edge41, Edge42) : ", BlocksOp.GetErrorCode() + Face42_sp = geompy.GetFaceByEdges(Spanner, Edge41, Edge42) id_face42_sp = geompy.addToStudyInFather(Spanner, Face42_sp, "Face 4_2") - Blocks_f4_sp = BlocksOp.GetBlocksByParts(Spanner, [Face42_sp]) - if Blocks_f4_sp is None: - print "BlocksOp.GetBlocksByParts() : ", BlocksOp.GetErrorCode() + Blocks_f4_sp = geompy.GetBlocksByParts(Spanner, [Face42_sp]) + + isMRot2D = 0 for aBlock in Blocks_f4_sp: name = geompy.SubShapeName(aBlock, Spanner) @@ -349,17 +321,18 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = f42_sp_ind = geompy.LocalOp.GetSubShapeIndex(aBlock, Face42_sp) - Face_5_horiz = GetFaceByNormale(geompy, aBlock, vz) + Face_5_horiz = geompy.GetFaceByNormale(aBlock, vz) f_5_horiz_ind = geompy.LocalOp.GetSubShapeIndex(aBlock, Face_5_horiz) MRot = geompy.MakeMultiTransformation2D(aBlock, f42_sp_ind, 0, 3, f_5_horiz_ind, 0, 5) if MRot is not None: + isMRot2D = 1 p_z100 = geompy.MakeVertex(0., 0., 100.) MRot_tr = geompy.MakeTranslationTwoPoints(MRot, p0, p_z100) id_MRot_tr = geompy.addToStudy(MRot_tr, "Multi-rotated block 5") - if BlocksOp.IsDone() == 0: - print "Operation failed" + if isMRot2D == 0: + print "2D Multi Transformation failed" ### Get one face of the Gear ### @@ -368,9 +341,7 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = p_40_0_tr = geompy.MakeTranslationTwoPoints(p_40_0 , p0, p_60_150_0) p_40_0_r_tr = geompy.MakeTranslationTwoPoints(p_40_0_r, p0, p_60_150_0) - Face_g_1 = BlocksOp.GetFaceByPoints(Gear, p_20_0_tr, p_20_0_r_tr, p_40_0_tr, p_40_0_r_tr) - if Face_g_1 is None: - print "BlocksOp.GetFaceByPoints(Gear, ...) : ", BlocksOp.GetErrorCode() + Face_g_1 = geompy.GetFaceByPoints(Gear, p_20_0_tr, p_20_0_r_tr, p_40_0_tr, p_40_0_r_tr) id_face_g_1 = geompy.addToStudyInFather(Gear, Face_g_1, "Face of Gear by four points") edgesNb = geompy.ShapesOp.NumberOfEdges(Face_g_1) @@ -393,12 +364,12 @@ def MakeSpanner (salome, geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = # ---- add a middle block of spanner handle in study p_45_0_1 = geompy.MakeVertex(45., 0., 1.) - BlockMh = GetBlockNearPoint(geompy, Spanner, p_45_0_1) + BlockMh = geompy.GetBlockNearPoint(Spanner, p_45_0_1) id_blockMh = geompy.addToStudyInFather(Spanner, BlockMh, "Middle Block of Spanner Handle") # ---- add the top face of the middle block in study - FaceTop = GetFaceByNormale(geompy, BlockMh, vz) + FaceTop = geompy.GetFaceByNormale(BlockMh, vz) id_facetop = geompy.addToStudyInFather(BlockMh, FaceTop, "Top Face") # ---- add long edges of the top face in study diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 4d24d8009..67e626578 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -157,9 +157,12 @@ def TestAll (geompy, math): #Transform objects Translation = geompy.MakeTranslationTwoPoints(Box, px, pz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr + TranslVect = geompy.MakeTranslationVector(Box, vxyz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr Rotation = geompy.MakeRotation(Box, vz, angle1) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr Scale = geompy.MakeScaleTransform(Box, p0, factor) # Mirror = geompy.MakeMirrorByPlane(Box, Plane) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + MirrorAxis = geompy.MakeMirrorByAxis(Box, Line1) # + MirrorPnt = geompy.MakeMirrorByPoint(Box, p200) # Position = geompy.MakePosition(Box, cs1, cs2) #(3 GEOM_Object_ptr)->GEOM_Object_ptr Offset = geompy.MakeOffset(Box, 10.) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr Orientation = geompy.ChangeOrientation(Box) @@ -210,7 +213,8 @@ def TestAll (geompy, math): print "CheckShape(Prism) = ", CheckShape #Partition objects - Partition = geompy.MakePartition([Box], [Plane]) #(2 Lists Of GEOM_Object_ptr)->GEOM_Object_ptr + Partition = geompy.MakePartition([Box], [Plane]) #(2 Lists Of GEOM_Object_ptr)->GEOM_Object_ptr + Partition1 = geompy.MakeHalfPartition(Box, Plane) #(2 GEOM_Object_ptr)->GEOM_Object_ptr #Add In Study @@ -286,9 +290,12 @@ def TestAll (geompy, math): id_Sewing = geompy.addToStudy(Sewing, "Sewing") id_Translation = geompy.addToStudy(Translation, "Translation") + id_TranslVect = geompy.addToStudy(TranslVect , "Translation along vector") id_Rotation = geompy.addToStudy(Rotation, "Rotation") id_Scale = geompy.addToStudy(Scale, "Scale") - id_Mirror = geompy.addToStudy(Mirror, "Mirror") + id_Mirror = geompy.addToStudy(Mirror, "Mirror by Plane") + id_MirrorAxis = geompy.addToStudy(MirrorAxis, "Mirror by Axis") + id_MirrorPnt = geompy.addToStudy(MirrorPnt, "Mirror by Point") id_Position = geompy.addToStudy(Position, "Positioned box") id_Offset = geompy.addToStudy(Offset, "Offset") id_Orientation = geompy.addToStudy(Orientation, "Orientation") @@ -305,7 +312,8 @@ def TestAll (geompy, math): id_CDG = geompy.addToStudy(CDG, "CDG") id_Archimede = geompy.addToStudy(Archimede, "Archimede") - id_Partition = geompy.addToStudy(Partition, "Partition") + id_Partition = geompy.addToStudy(Partition, "Partition") + id_Partition1 = geompy.addToStudy(Partition1, "Half Partition") #Decompose objects SubFace = geompy.SubShape(Box, geompy.ShapeType["FACE"], [2]) diff --git a/src/GEOM_SWIG/GEOM_TestOthers.py b/src/GEOM_SWIG/GEOM_TestOthers.py index b2524c07a..356e23fc5 100644 --- a/src/GEOM_SWIG/GEOM_TestOthers.py +++ b/src/GEOM_SWIG/GEOM_TestOthers.py @@ -141,6 +141,16 @@ def TestOtherOperations (geompy, math): id_ImportIGES = geompy.addToStudy(ImportIGES, "ImportIGES") id_ImportSTEP = geompy.addToStudy(ImportSTEP, "ImportSTEP") + # NumberOfFaces + NumberOfFaces = geompy.NumberOfFaces(Box) + if NumberOfFaces != 6: + print "Bad number of faces in BOX!" + + # NumberOfEdges + NumberOfEdges = geompy.NumberOfEdges(Box) + if NumberOfEdges != 12: + print "Bad number of edges in BOX!" + # MakeBlockExplode Compound = geompy.MakeCompound([Box, Sphere]) MakeBlockExplode = geompy.MakeBlockExplode(Compound, 6, 6) @@ -197,3 +207,103 @@ def TestOtherOperations (geompy, math): print "Group of Box's faces includes the following IDs:" for ObjectID in GetObjectIDs: print " ", ObjectID + + BoxCopy = geompy.GetMainShape(CreateGroup) + + # ----------------------------------------------------------------------------- + # enumeration ShapeTypeString as a dictionary + # ----------------------------------------------------------------------------- + ShapeTypeString = {'0':"COMPOUND", '1':"COMPSOLID", '2':"SOLID", '3':"SHELL", '4':"FACE", '5':"WIRE", '6':"EDGE", '7':"VERTEX", '8':"SHAPE"} + + GroupType = geompy.GetType(CreateGroup) + print "Type of elements of the created group is ", ShapeTypeString[`GroupType`] + + # Prepare data for the following operations + p0 = geompy.MakeVertex(0, 0, 0) + b0 = geompy.MakeBox(-50, -50, -50, 50, 50, 50) + s0 = geompy.MakeSphereR(100) + + id_b0 = geompy.addToStudy(b0, "b0") + id_s0 = geompy.addToStudy(s0, "s0") + + v_0pp = geompy.MakeVectorDXDYDZ( 0, 1, 1) + v_0np = geompy.MakeVectorDXDYDZ( 0, -1, 1) + v_p0p = geompy.MakeVectorDXDYDZ( 1, 0, 1) + v_n0p = geompy.MakeVectorDXDYDZ(-1, 0, 1) + v_pp0 = geompy.MakeVectorDXDYDZ( 1, 1, 0) + v_np0 = geompy.MakeVectorDXDYDZ(-1, 1, 0) + + pln_0pp = geompy.MakePlane(p0, v_0pp, 200) + pln_0np = geompy.MakePlane(p0, v_0np, 200) + pln_p0p = geompy.MakePlane(p0, v_p0p, 200) + pln_n0p = geompy.MakePlane(p0, v_n0p, 200) + pln_pp0 = geompy.MakePlane(p0, v_pp0, 200) + pln_np0 = geompy.MakePlane(p0, v_np0, 200) + + part_tool = geompy.MakePartition([b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0], + [], + [], + [b0]) + id_part_tool = geompy.addToStudy(part_tool, "part_tool") + + part = geompy.MakePartition([s0], [part_tool]) + geompy.addToStudy(part, "part") + + # GetFreeFacesIDs + anIDs = geompy.GetFreeFacesIDs(part) + freeFaces = geompy.GetSubShape(part, anIDs) + + geompy.addToStudy(freeFaces, "freeFaces") + + # RemoveExtraEdges + freeFacesWithoutExtra = geompy.RemoveExtraEdges(freeFaces) + + geompy.addToStudy(freeFacesWithoutExtra, "freeFacesWithoutExtra") + + # GetSharedShapes + sharedFaces = geompy.GetSharedShapes(part, freeFacesWithoutExtra, geompy.ShapeType["FACE"]) + + for shFace in sharedFaces: + geompy.addToStudy(shFace, "sharedFace") + + # CheckAndImprove + blocksComp = geompy.CheckAndImprove(part) + + geompy.addToStudy(blocksComp, "blocksComp") + + # Propagate + listChains = geompy.Propagate(blocksComp) + + for chain in listChains: + geompy.addToStudyInFather(blocksComp, chain, "propagation chain") + + # GetPoint(theShape, theX, theY, theZ, theEpsilon) + # + # (-50, 50, 50) .-----. (50, 50, 50) + # pb0_top_1 | | + # | . pmidle + # | | + # (-50, -50, 50) '-----' (50, -50, 50) + # + pb0_top_1 = geompy.GetPoint(blocksComp, -50, 50, 50, 0.01) + pb0_bot_1 = geompy.GetPoint(blocksComp, -50, -50, -50, 0.01) + + geompy.addToStudyInFather(blocksComp, pb0_top_1, "point from blocksComp (-50, 50, 50)") + geompy.addToStudyInFather(blocksComp, pb0_bot_1, "point from blocksComp (-50, -50, -50)") + + # GetEdgeNearPoint(theShape, thePoint) + pmidle = geompy.MakeVertex(50, 0, 50) + edge1 = geompy.GetEdgeNearPoint(blocksComp, pmidle) + + geompy.addToStudyInFather(blocksComp, edge1, "edge near point (50, 0, 50)") + + # GetBlockByParts(theCompound, theParts) + b0_image = geompy.GetBlockByParts(blocksComp, [pb0_top_1, pb0_bot_1, edge1]) + + geompy.addToStudyInFather(blocksComp, b0_image, "b0 image") + + # GetShapesOnPlane(theShape, theShapeType, thePlane) + # GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius) + # GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius) + + # GetInPlace(theShapeWhere, theShapeWhat) diff --git a/src/GEOM_SWIG/batchmode_geompy.py b/src/GEOM_SWIG/batchmode_geompy.py index ab0a90fe8..b6008af41 100644 --- a/src/GEOM_SWIG/batchmode_geompy.py +++ b/src/GEOM_SWIG/batchmode_geompy.py @@ -103,8 +103,8 @@ GroupOp = geom.GetIGroupOperations (myStudyId) # Basic primitives # ----------------------------------------------------------------------------- -def MakeVertex(x,y,z): - anObj = BasicOp.MakePointXYZ(x,y,z) +def MakeVertex(theX, theY, theZ): + anObj = BasicOp.MakePointXYZ(theX, theY, theZ) if BasicOp.IsDone() == 0: print "MakePointXYZ : ", BasicOp.GetErrorCode() return anObj @@ -371,6 +371,18 @@ def MakeCompound(ListShape): print "MakeCompound : ", ShapesOp.GetErrorCode() return anObj +def NumberOfFaces(theShape): + nb_faces = ShapesOp.NumberOfFaces(theShape) + if ShapesOp.IsDone() == 0: + print "NumberOfFaces : ", ShapesOp.GetErrorCode() + return nb_faces + +def NumberOfEdges(theShape): + nb_edges = ShapesOp.NumberOfEdges(theShape) + if ShapesOp.IsDone() == 0: + print "NumberOfEdges : ", ShapesOp.GetErrorCode() + return nb_edges + def ChangeOrientation(Shape): anObj = ShapesOp.ChangeOrientation(Shape) if ShapesOp.IsDone() == 0: @@ -381,6 +393,42 @@ def OrientationChange(Shape): anObj = ChangeOrientation(Shape) return anObj +def GetFreeFacesIDs(theShape): + anIDs = ShapesOp.GetFreeFacesIDs(theShape) + if ShapesOp.IsDone() == 0: + print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode() + return anIDs + +def GetSharedShapes(theShape1, theShape2, theShapeType): + aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType) + if ShapesOp.IsDone() == 0: + print "GetSharedShapes : ", ShapesOp.GetErrorCode() + return aList + +#def GetShapesOnPlane(theShape, theShapeType, thePlane): +# anObj = ShapesOp.GetShapesOnPlane(theShape, theShapeType, thePlane) +# if ShapesOp.IsDone() == 0: +# print "GetShapesOnPlane : ", ShapesOp.GetErrorCode() +# return anObj +# +#def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius): +# anObj = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius) +# if ShapesOp.IsDone() == 0: +# print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode() +# return anObj +# +#def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius): +# anObj = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius) +# if ShapesOp.IsDone() == 0: +# print "GetShapesOnSphere : ", ShapesOp.GetErrorCode() +# return anObj +# +#def GetInPlace(theShapeWhere, theShapeWhat): +# anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat) +# if ShapesOp.IsDone() == 0: +# print "GetInPlace : ", ShapesOp.GetErrorCode() +# return anObj + # ----------------------------------------------------------------------------- # Access to sub-shapes by their unique IDs inside the main shape. # ----------------------------------------------------------------------------- @@ -408,12 +456,24 @@ def SubShapeAll(aShape, aType): print "MakeExplode : ", ShapesOp.GetErrorCode() return ListObj -def SubShapeAllSorted(aShape,aType): +def SubShapeAllIDs(aShape, aType): + ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0) + if ShapesOp.IsDone() == 0: + print "SubShapeAllIDs : ", ShapesOp.GetErrorCode() + return ListObj + +def SubShapeAllSorted(aShape, aType): ListObj = ShapesOp.MakeExplode(aShape,aType,1) if ShapesOp.IsDone() == 0: print "MakeExplode : ", ShapesOp.GetErrorCode() return ListObj +def SubShapeAllSortedIDs(aShape, aType): + ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1) + if ShapesOp.IsDone() == 0: + print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode() + return ListObj + # Obtain a compound of sub-shapes of , # selected by they indices in list of all sub-shapes of type def SubShape(aShape, aType, ListOfInd): @@ -551,6 +611,12 @@ def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit, RemoveWebs, ListMaterials); return anObj +def MakeHalfPartition(theShape, thePlane): + anObj = BoolOp.MakeHalfPartition(theShape, thePlane) + if BoolOp.IsDone() == 0: + print "MakeHalfPartition : ", BoolOp.GetErrorCode() + return anObj + # ----------------------------------------------------------------------------- # Transform objects # ----------------------------------------------------------------------------- @@ -567,6 +633,12 @@ def MakeTranslation(aShape,dx,dy,dz): print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode() return anObj +def MakeTranslationVector(theObject, theVector): + anObj = TrsfOp.TranslateVectorCopy(theObject, theVector) + if TrsfOp.IsDone() == 0: + print "TranslateVectorCopy : ", TrsfOp.GetErrorCode() + return anObj + def MakeRotation(aShape,axis,angle): anObj = TrsfOp.RotateCopy(aShape,axis,angle) if TrsfOp.IsDone() == 0: @@ -585,6 +657,18 @@ def MakeMirrorByPlane(aShape,aPlane): print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode() return anObj +def MakeMirrorByAxis(theObject, theAxis): + anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis) + if TrsfOp.IsDone() == 0: + print "MirrorAxisCopy : ", TrsfOp.GetErrorCode() + return anObj + +def MakeMirrorByPoint(theObject, thePoint): + anObj = TrsfOp.MirrorPointCopy(theObject, thePoint) + if TrsfOp.IsDone() == 0: + print "MirrorPointCopy : ", TrsfOp.GetErrorCode() + return anObj + def MakePosition(aShape,theStartLCS,theEndLCS): anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS) if TrsfOp.IsDone() == 0: @@ -815,6 +899,100 @@ def MakeHexa2Faces(F1, F2): print "MakeHexa2Faces : ", BlocksOp.GetErrorCode() return anObj +def GetPoint(theShape, theX, theY, theZ, theEpsilon): + anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon) + if BlocksOp.IsDone() == 0: + print "GetPoint : ", BlocksOp.GetErrorCode() + return anObj + +def GetEdge(theShape, thePoint1, thePoint2): + anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2) + if BlocksOp.IsDone() == 0: + print "GetEdge : ", BlocksOp.GetErrorCode() + return anObj + +def GetEdgeNearPoint(theShape, thePoint): + anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint) + if BlocksOp.IsDone() == 0: + print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode() + return anObj + +def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4): + anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4) + if BlocksOp.IsDone() == 0: + print "GetFaceByPoints : ", BlocksOp.GetErrorCode() + return anObj + +def GetFaceByEdges(theShape, theEdge1, theEdge2): + anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2) + if BlocksOp.IsDone() == 0: + print "GetFaceByEdges : ", BlocksOp.GetErrorCode() + return anObj + +def GetOppositeFace(theBlock, theFace): + anObj = BlocksOp.GetOppositeFace(theBlock, theFace) + if BlocksOp.IsDone() == 0: + print "GetOppositeFace : ", BlocksOp.GetErrorCode() + return anObj + +def GetFaceNearPoint(theShape, thePoint): + anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint) + if BlocksOp.IsDone() == 0: + print "GetFaceNearPoint : ", BlocksOp.GetErrorCode() + return anObj + +def GetFaceByNormale(theBlock, theVector): + anObj = BlocksOp.GetFaceByNormale(theBlock, theVector) + if BlocksOp.IsDone() == 0: + print "GetFaceByNormale : ", BlocksOp.GetErrorCode() + return anObj + +def CheckCompoundOfBlocks(theCompound): + (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound) + if BlocksOp.IsDone() == 0: + print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode() + else: + if IsValid == 0: + Descr = BlocksOp.PrintBCErrors(theCompound, BCErrors) + print Descr + return IsValid + +def RemoveExtraEdges(theShape): + anObj = BlocksOp.RemoveExtraEdges(theShape) + if BlocksOp.IsDone() == 0: + print "RemoveExtraEdges : ", BlocksOp.GetErrorCode() + return anObj + +def CheckAndImprove(theShape): + anObj = BlocksOp.CheckAndImprove(theShape) + if BlocksOp.IsDone() == 0: + print "CheckAndImprove : ", BlocksOp.GetErrorCode() + return anObj + +def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces): + aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces) + if BlocksOp.IsDone() == 0: + print "MakeBlockExplode : ", BlocksOp.GetErrorCode() + return aList + +def GetBlockNearPoint(theCompound, thePoint): + anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint) + if BlocksOp.IsDone() == 0: + print "GetBlockNearPoint : ", BlocksOp.GetErrorCode() + return anObj + +def GetBlockByParts(theCompound, theParts): + anObj = BlocksOp.GetBlockByParts(theCompound, theParts) + if BlocksOp.IsDone() == 0: + print "GetBlockByParts : ", BlocksOp.GetErrorCode() + return anObj + +def GetBlocksByParts(theCompound, theParts): + aList = BlocksOp.GetBlocksByParts(theCompound, theParts) + if BlocksOp.IsDone() == 0: + print "GetBlocksByParts : ", BlocksOp.GetErrorCode() + return aList + def MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes): anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes) if BlocksOp.IsDone() == 0: @@ -829,21 +1007,11 @@ def MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU, print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode() return anObj -def MakeBlockExplode(Compound, MinNbFaces, MaxNbFaces): - aList = BlocksOp.ExplodeCompoundOfBlocks(Compound, MinNbFaces, MaxNbFaces) - if BlocksOp.IsDone() == 0: - print "MakeBlockExplode : ", BlocksOp.GetErrorCode() - return aList - -def CheckCompoundOfBlocks(Compound): - (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(Compound) +def Propagate(theShape): + listChains = BlocksOp.Propagate(theShape) if BlocksOp.IsDone() == 0: - print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode() - else: - if IsValid == 0: - Descr = BlocksOp.PrintBCErrors(Compound, BCErrors) - print Descr - return IsValid + print "Propagate : ", BlocksOp.GetErrorCode() + return listChains # ----------------------------------------------------------------------------- # Group operations @@ -871,6 +1039,20 @@ def GetObjectIDs(Group): print "GetObjectIDs : ", GroupOp.GetErrorCode() return ListIDs +def GetType(theGroup): + aType = GroupOp.GetType(theGroup) + if GroupOp.IsDone() == 0: + print "GetType : ", GroupOp.GetErrorCode() + return aType + +def GetMainShape(theGroup): + anObj = GroupOp.GetMainShape(theGroup) + if GroupOp.IsDone() == 0: + print "GetMainShape : ", GroupOp.GetErrorCode() + return anObj + +# Add Path to the system path +# def addPath(Path): if (sys.path.count(Path) < 1): sys.path.append(Path) diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index b2bc785ac..4aef913f1 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -29,6 +29,11 @@ from salome import * import GEOM +""" + \namespace geompy + \brief Module geompy +""" + g = lcc.FindOrLoadComponent("FactoryServer", "GEOM") geom = g._narrow( GEOM.GEOM_Gen ) myBuilder = myStudy.NewBuilder() @@ -46,10 +51,11 @@ if father is None: gg = ImportComponentGUI("GEOM") -# * Get name for sub-shape aSubObj of shape aMainObj -# -# * Example: see GEOM_TestAll.py -# +""" + * Get name for sub-shape aSubObj of shape aMainObj + + * Example: see GEOM_TestAll.py +""" def SubShapeName(aSubObj, aMainObj): aSubId = orb.object_to_string(aSubObj) aMainId = orb.object_to_string(aMainObj) @@ -57,10 +63,11 @@ def SubShapeName(aSubObj, aMainObj): name = gg.getShapeTypeString(aSubId) + "_%d"%(index) return name -# * Publish in study aShape with name aName -# -# * Example: see GEOM_TestAll.py -# +""" + * Publish in study aShape with name aName + + * Example: see GEOM_TestAll.py +""" def addToStudy(aShape, aName): try: aSObject = geom.AddInStudy(myStudy, aShape, aName, None) @@ -69,10 +76,11 @@ def addToStudy(aShape, aName): return "" return aShape.GetStudyEntry() -# * Publish in study aShape with name aName as sub-object of previously published aFather -# -# * Example: see GEOM_TestAll.py -# +""" + * Publish in study aShape with name aName as sub-object of previously published aFather + + * Example: see GEOM_TestAll.py +""" def addToStudyInFather(aFather, aShape, aName): try: aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather) @@ -108,154 +116,165 @@ GroupOp = geom.GetIGroupOperations (myStudyId) # Basic primitives # ----------------------------------------------------------------------------- -# * Create point by three coordinates. -# * \param theX The X coordinate of the point. -# * \param theY The Y coordinate of the point. -# * \param theZ The Z coordinate of the point. -# * \return New GEOM_Object, containing the created point. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create point by three coordinates. + * \param theX The X coordinate of the point. + * \param theY The Y coordinate of the point. + * \param theZ The Z coordinate of the point. + * \return New GEOM_Object, containing the created point. + + * Example: see GEOM_TestAll.py +""" def MakeVertex(theX, theY, theZ): anObj = BasicOp.MakePointXYZ(theX, theY, theZ) if BasicOp.IsDone() == 0: print "MakePointXYZ : ", BasicOp.GetErrorCode() return anObj -# * Create a point, distant from the referenced point -# * on the given distances along the coordinate axes. -# * \param theReference The referenced point. -# * \param theX Displacement from the referenced point along OX axis. -# * \param theY Displacement from the referenced point along OY axis. -# * \param theZ Displacement from the referenced point along OZ axis. -# * \return New GEOM_Object, containing the created point. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a point, distant from the referenced point + * on the given distances along the coordinate axes. + * \param theReference The referenced point. + * \param theX Displacement from the referenced point along OX axis. + * \param theY Displacement from the referenced point along OY axis. + * \param theZ Displacement from the referenced point along OZ axis. + * \return New GEOM_Object, containing the created point. + + * Example: see GEOM_TestAll.py +""" def MakeVertexWithRef(theReference, theX, theY, theZ): anObj = BasicOp.MakePointWithReference(theReference, theX, theY, theZ) if BasicOp.IsDone() == 0: print "MakePointWithReference : ", BasicOp.GetErrorCode() return anObj -# * Create a point, corresponding to the given parameter on the given curve. -# * \param theRefCurve The referenced curve. -# * \param theParameter Value of parameter on the referenced curve. -# * \return New GEOM_Object, containing the created point. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a point, corresponding to the given parameter on the given curve. + * \param theRefCurve The referenced curve. + * \param theParameter Value of parameter on the referenced curve. + * \return New GEOM_Object, containing the created point. + + * Example: see GEOM_TestAll.py +""" def MakeVertexOnCurve(theRefCurve, theParameter): anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter) if BasicOp.IsDone() == 0: print "MakePointOnCurve : ", BasicOp.GetErrorCode() return anObj -# * Create a vector with the given components. -# * \param theDX X component of the vector. -# * \param theDY Y component of the vector. -# * \param theDZ Z component of the vector. -# * \return New GEOM_Object, containing the created vector. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a vector with the given components. + * \param theDX X component of the vector. + * \param theDY Y component of the vector. + * \param theDZ Z component of the vector. + * \return New GEOM_Object, containing the created vector. + + * Example: see GEOM_TestAll.py +""" def MakeVectorDXDYDZ(theDX, theDY, theDZ): anObj = BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ) if BasicOp.IsDone() == 0: print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode() return anObj -# * Create a vector between two points. -# * \param thePnt1 Start point for the vector. -# * \param thePnt2 End point for the vector. -# * \return New GEOM_Object, containing the created vector. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a vector between two points. + * \param thePnt1 Start point for the vector. + * \param thePnt2 End point for the vector. + * \return New GEOM_Object, containing the created vector. + + * Example: see GEOM_TestAll.py +""" def MakeVector(thePnt1, thePnt2): anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2) if BasicOp.IsDone() == 0: print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode() return anObj -# * Create a line, passing through the given point -# * and parrallel to the given direction -# * \param thePnt Point. The resulting line will pass through it. -# * \param theDir Direction. The resulting line will be parallel to it. -# * \return New GEOM_Object, containing the created line. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a line, passing through the given point + * and parrallel to the given direction + * \param thePnt Point. The resulting line will pass through it. + * \param theDir Direction. The resulting line will be parallel to it. + * \return New GEOM_Object, containing the created line. + + * Example: see GEOM_TestAll.py +""" def MakeLine(thePnt, theDir): anObj = BasicOp.MakeLine(thePnt, theDir) if BasicOp.IsDone() == 0: print "MakeLine : ", BasicOp.GetErrorCode() return anObj -# * Create a line, passing through the given points -# * \param thePnt1 First of two points, defining the line. -# * \param thePnt2 Second of two points, defining the line. -# * \return New GEOM_Object, containing the created line. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a line, passing through the given points + * \param thePnt1 First of two points, defining the line. + * \param thePnt2 Second of two points, defining the line. + * \return New GEOM_Object, containing the created line. + + * Example: see GEOM_TestAll.py +""" def MakeLineTwoPnt(thePnt1, thePnt2): anObj = BasicOp.MakeLineTwoPnt(thePnt1, thePnt2) if BasicOp.IsDone() == 0: print "MakeLineTwoPnt : ", BasicOp.GetErrorCode() return anObj -# * Create a plane, passing through the given point -# * and normal to the given vector. -# * \param thePnt Point, the plane has to pass through. -# * \param theVec Vector, defining the plane normal direction. -# * \param theTrimSize Half size of a side of quadrangle face, representing the plane. -# * \return New GEOM_Object, containing the created plane. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a plane, passing through the given point + * and normal to the given vector. + * \param thePnt Point, the plane has to pass through. + * \param theVec Vector, defining the plane normal direction. + * \param theTrimSize Half size of a side of quadrangle face, representing the plane. + * \return New GEOM_Object, containing the created plane. + + * Example: see GEOM_TestAll.py +""" def MakePlane(thePnt, theVec, theTrimSize): anObj = BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize) if BasicOp.IsDone() == 0: print "MakePlanePntVec : ", BasicOp.GetErrorCode() return anObj -# * Create a plane, passing through the three given points -# * \param thePnt1 First of three points, defining the plane. -# * \param thePnt2 Second of three points, defining the plane. -# * \param thePnt3 Fird of three points, defining the plane. -# * \param theTrimSize Half size of a side of quadrangle face, representing the plane. -# * \return New GEOM_Object, containing the created plane. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a plane, passing through the three given points + * \param thePnt1 First of three points, defining the plane. + * \param thePnt2 Second of three points, defining the plane. + * \param thePnt3 Fird of three points, defining the plane. + * \param theTrimSize Half size of a side of quadrangle face, representing the plane. + * \return New GEOM_Object, containing the created plane. + + * Example: see GEOM_TestAll.py +""" def MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize): anObj = BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize) if BasicOp.IsDone() == 0: print "MakePlaneThreePnt : ", BasicOp.GetErrorCode() return anObj -# * Create a plane, similar to the existing one, but with another size of representing face. -# * \param theFace Referenced plane. -# * \param theTrimSize New half size of a side of quadrangle face, representing the plane. -# * \return New GEOM_Object, containing the created plane. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a plane, similar to the existing one, but with another size of representing face. + * \param theFace Referenced plane. + * \param theTrimSize New half size of a side of quadrangle face, representing the plane. + * \return New GEOM_Object, containing the created plane. + + * Example: see GEOM_TestAll.py +""" def MakePlaneFace(theFace, theTrimSize): anObj = BasicOp.MakePlaneFace(theFace, theTrimSize) if BasicOp.IsDone() == 0: print "MakePlaneFace : ", BasicOp.GetErrorCode() return anObj -# * Create a local coordinate system. -# * \param OX,OY,OZ Three coordinates of coordinate system origin. -# * \param XDX,XDY,XDZ Three components of OX direction -# * \param YDX,YDY,YDZ Three components of OY direction -# * \return New GEOM_Object, containing the created coordinate system. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a local coordinate system. + * \param OX,OY,OZ Three coordinates of coordinate system origin. + * \param XDX,XDY,XDZ Three components of OX direction + * \param YDX,YDY,YDZ Three components of OY direction + * \return New GEOM_Object, containing the created coordinate system. + + * Example: see GEOM_TestAll.py +""" def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ): anObj = BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ) if BasicOp.IsDone() == 0: @@ -266,132 +285,140 @@ def MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ): # Curves # ----------------------------------------------------------------------------- -# * Create an arc of circle, passing through three given points. -# * \param thePnt1 Start point of the arc. -# * \param thePnt2 Middle point of the arc. -# * \param thePnt3 End point of the arc. -# * \return New GEOM_Object, containing the created arc. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create an arc of circle, passing through three given points. + * \param thePnt1 Start point of the arc. + * \param thePnt2 Middle point of the arc. + * \param thePnt3 End point of the arc. + * \return New GEOM_Object, containing the created arc. + + * Example: see GEOM_TestAll.py +""" def MakeArc(thePnt1, thePnt2, thePnt3): anObj = CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3) if CurvesOp.IsDone() == 0: print "MakeArc : ", CurvesOp.GetErrorCode() return anObj -# * Create a circle with given center, normal vector and radius. -# * \param thePnt Circle center. -# * \param theVec Vector, normal to the plane of the circle. -# * \param theR Circle radius. -# * \return New GEOM_Object, containing the created circle. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a circle with given center, normal vector and radius. + * \param thePnt Circle center. + * \param theVec Vector, normal to the plane of the circle. + * \param theR Circle radius. + * \return New GEOM_Object, containing the created circle. + + * Example: see GEOM_TestAll.py +""" def MakeCircle(thePnt, theVec, theR): anObj = CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR) if CurvesOp.IsDone() == 0: print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode() return anObj -# * Create a circle, passing through three given points -# * \param thePnt1,thePnt2,thePnt3 Points, defining the circle. -# * \return New GEOM_Object, containing the created circle. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a circle, passing through three given points + * \param thePnt1,thePnt2,thePnt3 Points, defining the circle. + * \return New GEOM_Object, containing the created circle. + + * Example: see GEOM_TestAll.py +""" def MakeCircleThreePnt(thePnt1, thePnt2, thePnt3): anObj = CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3) if CurvesOp.IsDone() == 0: print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode() return anObj -# * Create an ellipse with given center, normal vector and radiuses. -# * \param thePnt Ellipse center. -# * \param theVec Vector, normal to the plane of the ellipse. -# * \param theRMajor Major ellipse radius. -# * \param theRMinor Minor ellipse radius. -# * \return New GEOM_Object, containing the created ellipse. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create an ellipse with given center, normal vector and radiuses. + * \param thePnt Ellipse center. + * \param theVec Vector, normal to the plane of the ellipse. + * \param theRMajor Major ellipse radius. + * \param theRMinor Minor ellipse radius. + * \return New GEOM_Object, containing the created ellipse. + + * Example: see GEOM_TestAll.py +""" def MakeEllipse(thePnt, theVec, theRMajor, theRMinor): anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor) if CurvesOp.IsDone() == 0: print "MakeEllipse : ", CurvesOp.GetErrorCode() return anObj -# * Create a polyline on the set of points. -# * \param thePoints Sequence of points for the polyline. -# * \return New GEOM_Object, containing the created polyline. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a polyline on the set of points. + * \param thePoints Sequence of points for the polyline. + * \return New GEOM_Object, containing the created polyline. + + * Example: see GEOM_TestAll.py +""" def MakePolyline(thePoints): anObj = CurvesOp.MakePolyline(thePoints) if CurvesOp.IsDone() == 0: print "MakePolyline : ", CurvesOp.GetErrorCode() return anObj -# * Create bezier curve on the set of points. -# * \param thePoints Sequence of points for the bezier curve. -# * \return New GEOM_Object, containing the created bezier curve. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create bezier curve on the set of points. + * \param thePoints Sequence of points for the bezier curve. + * \return New GEOM_Object, containing the created bezier curve. + + * Example: see GEOM_TestAll.py +""" def MakeBezier(thePoints): anObj = CurvesOp.MakeSplineBezier(thePoints) if CurvesOp.IsDone() == 0: print "MakeSplineBezier : ", CurvesOp.GetErrorCode() return anObj -# * Create B-Spline curve on the set of points. -# * \param thePoints Sequence of points for the B-Spline curve. -# * \return New GEOM_Object, containing the created B-Spline curve. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create B-Spline curve on the set of points. + * \param thePoints Sequence of points for the B-Spline curve. + * \return New GEOM_Object, containing the created B-Spline curve. + + * Example: see GEOM_TestAll.py +""" def MakeInterpol(thePoints): anObj = CurvesOp.MakeSplineInterpolation(thePoints) if CurvesOp.IsDone() == 0: print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode() return anObj -# * Create a sketcher (wire or face), following the textual description, -# * passed through \a theCommand argument. \n -# * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n -# * Format of the description string have to be the following: -# * -# * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]" -# * -# * Where: -# * - x1, y1 are coordinates of the first sketcher point (zero by default), -# * - CMD is one of -# * - "R angle" : Set the direction by angle -# * - "D dx dy" : Set the direction by DX & DY -# * . -# * \n -# * - "TT x y" : Create segment by point at X & Y -# * - "T dx dy" : Create segment by point with DX & DY -# * - "L length" : Create segment by direction & Length -# * - "IX x" : Create segment by direction & Intersect. X -# * - "IY y" : Create segment by direction & Intersect. Y -# * . -# * \n -# * - "C radius length" : Create arc by direction, radius and length(in degree) -# * . -# * \n -# * - "WW" : Close Wire (to finish) -# * - "WF" : Close Wire and build face (to finish) -# * -# * \param theCommand String, defining the sketcher in local -# * coordinates of the working plane. -# * \param theWorkingPlane Nine double values, defining origin, -# * OZ and OX directions of the working plane. -# * \return New GEOM_Object, containing the created wire. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a sketcher (wire or face), following the textual description, + * passed through \a theCommand argument. \n + * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n + * Format of the description string have to be the following: + * + * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]" + * + * Where: + * - x1, y1 are coordinates of the first sketcher point (zero by default), + * - CMD is one of + * - "R angle" : Set the direction by angle + * - "D dx dy" : Set the direction by DX & DY + * . + * \n + * - "TT x y" : Create segment by point at X & Y + * - "T dx dy" : Create segment by point with DX & DY + * - "L length" : Create segment by direction & Length + * - "IX x" : Create segment by direction & Intersect. X + * - "IY y" : Create segment by direction & Intersect. Y + * . + * \n + * - "C radius length" : Create arc by direction, radius and length(in degree) + * . + * \n + * - "WW" : Close Wire (to finish) + * - "WF" : Close Wire and build face (to finish) + * + * \param theCommand String, defining the sketcher in local + * coordinates of the working plane. + * \param theWorkingPlane Nine double values, defining origin, + * OZ and OX directions of the working plane. + * \return New GEOM_Object, containing the created wire. + + * Example: see GEOM_TestAll.py +""" def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]): anObj = CurvesOp.MakeSketcher(theCommand, theWorkingPlane) if CurvesOp.IsDone() == 0: @@ -402,230 +429,246 @@ def MakeSketcher(theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]): # Create 3D Primitives # ----------------------------------------------------------------------------- -# * Create a box by coordinates of two opposite vertices. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a box by coordinates of two opposite vertices. + + * Example: see GEOM_TestAll.py +""" def MakeBox(x1,y1,z1,x2,y2,z2): pnt1 = MakeVertex(x1,y1,z1) pnt2 = MakeVertex(x2,y2,z2) return MakeBoxTwoPnt(pnt1,pnt2) -# * Create a box with specified dimensions along the coordinate axes -# * and with edges, parallel to the coordinate axes. -# * Center of the box will be at point (DX/2, DY/2, DZ/2). -# * \param theDX Length of Box edges, parallel to OX axis. -# * \param theDY Length of Box edges, parallel to OY axis. -# * \param theDZ Length of Box edges, parallel to OZ axis. -# * \return New GEOM_Object, containing the created box. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a box with specified dimensions along the coordinate axes + * and with edges, parallel to the coordinate axes. + * Center of the box will be at point (DX/2, DY/2, DZ/2). + * \param theDX Length of Box edges, parallel to OX axis. + * \param theDY Length of Box edges, parallel to OY axis. + * \param theDZ Length of Box edges, parallel to OZ axis. + * \return New GEOM_Object, containing the created box. + + * Example: see GEOM_TestAll.py +""" def MakeBoxDXDYDZ(theDX, theDY, theDZ): anObj = PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ) if PrimOp.IsDone() == 0: print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode() return anObj -# * Create a box with two specified opposite vertices, -# * and with edges, parallel to the coordinate axes -# * \param thePnt1 First of two opposite vertices. -# * \param thePnt2 Second of two opposite vertices. -# * \return New GEOM_Object, containing the created box. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a box with two specified opposite vertices, + * and with edges, parallel to the coordinate axes + * \param thePnt1 First of two opposite vertices. + * \param thePnt2 Second of two opposite vertices. + * \return New GEOM_Object, containing the created box. + + * Example: see GEOM_TestAll.py +""" def MakeBoxTwoPnt(thePnt1, thePnt2): anObj = PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2) if PrimOp.IsDone() == 0: print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode() return anObj -# * Create a cylinder with given base point, axis, radius and height. -# * \param thePnt Central point of cylinder base. -# * \param theAxis Cylinder axis. -# * \param theR Cylinder radius. -# * \param theH Cylinder height. -# * \return New GEOM_Object, containing the created cylinder. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a cylinder with given base point, axis, radius and height. + * \param thePnt Central point of cylinder base. + * \param theAxis Cylinder axis. + * \param theR Cylinder radius. + * \param theH Cylinder height. + * \return New GEOM_Object, containing the created cylinder. + + * Example: see GEOM_TestAll.py +""" def MakeCylinder(thePnt, theAxis, theR, theH): anObj = PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH) if PrimOp.IsDone() == 0: print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode() return anObj -# * Create a cylinder with given radius and height at -# * the origin of coordinate system. Axis of the cylinder -# * will be collinear to the OZ axis of the coordinate system. -# * \param theR Cylinder radius. -# * \param theH Cylinder height. -# * \return New GEOM_Object, containing the created cylinder. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a cylinder with given radius and height at + * the origin of coordinate system. Axis of the cylinder + * will be collinear to the OZ axis of the coordinate system. + * \param theR Cylinder radius. + * \param theH Cylinder height. + * \return New GEOM_Object, containing the created cylinder. + + * Example: see GEOM_TestAll.py +""" def MakeCylinderRH(theR, theH): anObj = PrimOp.MakeCylinderRH(theR, theH) if PrimOp.IsDone() == 0: print "MakeCylinderRH : ", PrimOp.GetErrorCode() return anObj -# * Create a sphere with given center and radius. -# * \param thePnt Sphere center. -# * \param theR Sphere radius. -# * \return New GEOM_Object, containing the created sphere. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a sphere with given center and radius. + * \param thePnt Sphere center. + * \param theR Sphere radius. + * \return New GEOM_Object, containing the created sphere. + + * Example: see GEOM_TestAll.py +""" def MakeSpherePntR(thePnt, theR): anObj = PrimOp.MakeSpherePntR(thePnt, theR) if PrimOp.IsDone() == 0: print "MakeSpherePntR : ", PrimOp.GetErrorCode() return anObj -# * Create a sphere with given center and radius. -# * \param x,y,z Coordinates of sphere center. -# * \param theR Sphere radius. -# * \return New GEOM_Object, containing the created sphere. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a sphere with given center and radius. + * \param x,y,z Coordinates of sphere center. + * \param theR Sphere radius. + * \return New GEOM_Object, containing the created sphere. + + * Example: see GEOM_TestAll.py +""" def MakeSphere(x, y, z, theR): point = MakeVertex(x, y, z) anObj = MakeSpherePntR(point, theR) return anObj -# * Create a sphere with given radius at the origin of coordinate system. -# * \param theR Sphere radius. -# * \return New GEOM_Object, containing the created sphere. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a sphere with given radius at the origin of coordinate system. + * \param theR Sphere radius. + * \return New GEOM_Object, containing the created sphere. + + * Example: see GEOM_TestAll.py +""" def MakeSphereR(theR): anObj = PrimOp.MakeSphereR(theR) if PrimOp.IsDone() == 0: print "MakeSphereR : ", PrimOp.GetErrorCode() return anObj -# * Create a cone with given base point, axis, height and radiuses. -# * \param thePnt Central point of the first cone base. -# * \param theAxis Cone axis. -# * \param theR1 Radius of the first cone base. -# * \param theR2 Radius of the second cone base. -# * \note If both radiuses are non-zero, the cone will be truncated. -# * \note If the radiuses are equal, a cylinder will be created instead. -# * \param theH Cone height. -# * \return New GEOM_Object, containing the created cone. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a cone with given base point, axis, height and radiuses. + * \param thePnt Central point of the first cone base. + * \param theAxis Cone axis. + * \param theR1 Radius of the first cone base. + * \param theR2 Radius of the second cone base. + * \note If both radiuses are non-zero, the cone will be truncated. + * \note If the radiuses are equal, a cylinder will be created instead. + * \param theH Cone height. + * \return New GEOM_Object, containing the created cone. + + * Example: see GEOM_TestAll.py +""" def MakeCone(thePnt, theAxis, theR1, theR2, theH): anObj = PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH) if PrimOp.IsDone() == 0: print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode() return anObj -# * Create a cone with given height and radiuses at -# * the origin of coordinate system. Axis of the cone will -# * be collinear to the OZ axis of the coordinate system. -# * \param theR1 Radius of the first cone base. -# * \param theR2 Radius of the second cone base. -# * \note If both radiuses are non-zero, the cone will be truncated. -# * \note If the radiuses are equal, a cylinder will be created instead. -# * \param theH Cone height. -# * \return New GEOM_Object, containing the created cone. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a cone with given height and radiuses at + * the origin of coordinate system. Axis of the cone will + * be collinear to the OZ axis of the coordinate system. + * \param theR1 Radius of the first cone base. + * \param theR2 Radius of the second cone base. + * \note If both radiuses are non-zero, the cone will be truncated. + * \note If the radiuses are equal, a cylinder will be created instead. + * \param theH Cone height. + * \return New GEOM_Object, containing the created cone. + + * Example: see GEOM_TestAll.py +""" def MakeConeR1R2H(theR1, theR2, theH): anObj = PrimOp.MakeConeR1R2H(theR1, theR2, theH) if PrimOp.IsDone() == 0: print "MakeConeR1R2H : ", PrimOp.GetErrorCode() return anObj -# * Create a torus with given center, normal vector and radiuses. -# * \param thePnt Torus central point. -# * \param theVec Torus axis of symmetry. -# * \param theRMajor Torus major radius. -# * \param theRMinor Torus minor radius. -# * \return New GEOM_Object, containing the created torus. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a torus with given center, normal vector and radiuses. + * \param thePnt Torus central point. + * \param theVec Torus axis of symmetry. + * \param theRMajor Torus major radius. + * \param theRMinor Torus minor radius. + * \return New GEOM_Object, containing the created torus. + + * Example: see GEOM_TestAll.py +""" def MakeTorus(thePnt, theVec, theRMajor, theRMinor): anObj = PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor) if PrimOp.IsDone() == 0: print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode() return anObj -# * Create a torus with given radiuses at the origin of coordinate system. -# * \param theRMajor Torus major radius. -# * \param theRMinor Torus minor radius. -# * \return New GEOM_Object, containing the created torus. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a torus with given radiuses at the origin of coordinate system. + * \param theRMajor Torus major radius. + * \param theRMinor Torus minor radius. + * \return New GEOM_Object, containing the created torus. + + * Example: see GEOM_TestAll.py +""" def MakeTorusRR(theRMajor, theRMinor): anObj = PrimOp.MakeTorusRR(theRMajor, theRMinor) if PrimOp.IsDone() == 0: print "MakeTorusRR : ", PrimOp.GetErrorCode() return anObj -# * Create a shape by extrusion of the base shape along a vector, defined by two points. -# * \param theBase Base shape to be extruded. -# * \param thePoint1 First end of extrusion vector. -# * \param thePoint2 Second end of extrusion vector. -# * \return New GEOM_Object, containing the created prism. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a shape by extrusion of the base shape along a vector, defined by two points. + * \param theBase Base shape to be extruded. + * \param thePoint1 First end of extrusion vector. + * \param thePoint2 Second end of extrusion vector. + * \return New GEOM_Object, containing the created prism. + + * Example: see GEOM_TestAll.py +""" def MakePrism(theBase, thePoint1, thePoint2): anObj = PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2) if PrimOp.IsDone() == 0: print "MakePrismTwoPnt : ", PrimOp.GetErrorCode() return anObj -# * Create a shape by extrusion of the base shape along the vector, -# * i.e. all the space, transfixed by the base shape during its translation -# * along the vector on the given distance. -# * \param theBase Base shape to be extruded. -# * \param theVec Direction of extrusion. -# * \param theH Prism dimension along theVec. -# * \return New GEOM_Object, containing the created prism. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a shape by extrusion of the base shape along the vector, + * i.e. all the space, transfixed by the base shape during its translation + * along the vector on the given distance. + * \param theBase Base shape to be extruded. + * \param theVec Direction of extrusion. + * \param theH Prism dimension along theVec. + * \return New GEOM_Object, containing the created prism. + + * Example: see GEOM_TestAll.py +""" def MakePrismVecH(theBase, theVec, theH): anObj = PrimOp.MakePrismVecH(theBase, theVec, theH) if PrimOp.IsDone() == 0: print "MakePrismVecH : ", PrimOp.GetErrorCode() return anObj -# * Create a shape by extrusion of the base shape along -# * the path shape. The path shape can be a wire or an edge. -# * \param theBase Base shape to be extruded. -# * \param thePath Path shape to extrude the base shape along it. -# * \return New GEOM_Object, containing the created pipe. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a shape by extrusion of the base shape along + * the path shape. The path shape can be a wire or an edge. + * \param theBase Base shape to be extruded. + * \param thePath Path shape to extrude the base shape along it. + * \return New GEOM_Object, containing the created pipe. + + * Example: see GEOM_TestAll.py +""" def MakePipe(theBase, thePath): anObj = PrimOp.MakePipe(theBase, thePath) if PrimOp.IsDone() == 0: print "MakePipe : ", PrimOp.GetErrorCode() return anObj -# * Create a shape by revolution of the base shape around the axis -# * on the given angle, i.e. all the space, transfixed by the base -# * shape during its rotation around the axis on the given angle. -# * \param theBase Base shape to be rotated. -# * \param theAxis Rotation axis. -# * \param theAngle Rotation angle in radians. -# * \return New GEOM_Object, containing the created revolution. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a shape by revolution of the base shape around the axis + * on the given angle, i.e. all the space, transfixed by the base + * shape during its rotation around the axis on the given angle. + * \param theBase Base shape to be rotated. + * \param theAxis Rotation axis. + * \param theAngle Rotation angle in radians. + * \return New GEOM_Object, containing the created revolution. + + * Example: see GEOM_TestAll.py +""" def MakeRevolution(theBase, theAxis, theAngle): anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle) if PrimOp.IsDone() == 0: @@ -636,140 +679,273 @@ def MakeRevolution(theBase, theAxis, theAngle): # Create base shapes # ----------------------------------------------------------------------------- -# * Create a linear edge with specified ends. -# * \param thePnt1 Point for the first end of edge. -# * \param thePnt2 Point for the second end of edge. -# * \return New GEOM_Object, containing the created edge. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a linear edge with specified ends. + * \param thePnt1 Point for the first end of edge. + * \param thePnt2 Point for the second end of edge. + * \return New GEOM_Object, containing the created edge. + + * Example: see GEOM_TestAll.py +""" def MakeEdge(thePnt1, thePnt2): anObj = ShapesOp.MakeEdge(thePnt1, thePnt2) if ShapesOp.IsDone() == 0: print "MakeEdge : ", ShapesOp.GetErrorCode() return anObj -# * Create a wire from the set of edges and wires. -# * \param theEdgesAndWires List of edges and/or wires. -# * \return New GEOM_Object, containing the created wire. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a wire from the set of edges and wires. + * \param theEdgesAndWires List of edges and/or wires. + * \return New GEOM_Object, containing the created wire. + + * Example: see GEOM_TestAll.py +""" def MakeWire(theEdgesAndWires): anObj = ShapesOp.MakeWire(theEdgesAndWires) if ShapesOp.IsDone() == 0: print "MakeWire : ", ShapesOp.GetErrorCode() return anObj -# * Create a face on the given wire. -# * \param theWire Wire to build the face on. -# * \param isPlanarWanted If TRUE, only planar face will be built. -# * If impossible, NULL object will be returned. -# * \return New GEOM_Object, containing the created face. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a face on the given wire. + * \param theWire Wire to build the face on. + * \param isPlanarWanted If TRUE, only planar face will be built. + * If impossible, NULL object will be returned. + * \return New GEOM_Object, containing the created face. + + * Example: see GEOM_TestAll.py +""" def MakeFace(theWire, isPlanarWanted): anObj = ShapesOp.MakeFace(theWire, isPlanarWanted) if ShapesOp.IsDone() == 0: print "MakeFace : ", ShapesOp.GetErrorCode() return anObj -# * Create a face on the given wires set. -# * \param theWires List of wires to build the face on. -# * \param isPlanarWanted If TRUE, only planar face will be built. -# * If impossible, NULL object will be returned. -# * \return New GEOM_Object, containing the created face. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a face on the given wires set. + * \param theWires List of wires to build the face on. + * \param isPlanarWanted If TRUE, only planar face will be built. + * If impossible, NULL object will be returned. + * \return New GEOM_Object, containing the created face. + + * Example: see GEOM_TestAll.py +""" def MakeFaceWires(theWires, isPlanarWanted): anObj = ShapesOp.MakeFaceWires(theWires, isPlanarWanted) if ShapesOp.IsDone() == 0: print "MakeFaceWires : ", ShapesOp.GetErrorCode() return anObj -# * Shortcut to MakeFaceWires() -# -# * Example: see GEOM_TestOthers.py -# +""" + * Shortcut to MakeFaceWires() + + * Example: see GEOM_TestOthers.py +""" def MakeFaces(theWires, isPlanarWanted): anObj = MakeFaceWires(theWires, isPlanarWanted) return anObj -# * Create a shell from the set of faces and shells. -# * \param theFacesAndShells List of faces and/or shells. -# * \return New GEOM_Object, containing the created shell. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a shell from the set of faces and shells. + * \param theFacesAndShells List of faces and/or shells. + * \return New GEOM_Object, containing the created shell. + + * Example: see GEOM_TestAll.py +""" def MakeShell(theFacesAndShells): anObj = ShapesOp.MakeShell(theFacesAndShells) if ShapesOp.IsDone() == 0: print "MakeShell : ", ShapesOp.GetErrorCode() return anObj -# * Create a solid, bounded by the given shells. -# * \param theShells Sequence of bounding shells. -# * \return New GEOM_Object, containing the created solid. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a solid, bounded by the given shells. + * \param theShells Sequence of bounding shells. + * \return New GEOM_Object, containing the created solid. + + * Example: see GEOM_TestAll.py +""" def MakeSolid(theShells): anObj = ShapesOp.MakeSolidShells(theShells) if ShapesOp.IsDone() == 0: print "MakeSolid : ", ShapesOp.GetErrorCode() return anObj -# * Create a compound of the given shapes. -# * \param theShapes List of shapes to put in compound. -# * \return New GEOM_Object, containing the created compound. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a compound of the given shapes. + * \param theShapes List of shapes to put in compound. + * \return New GEOM_Object, containing the created compound. + + * Example: see GEOM_TestAll.py +""" def MakeCompound(theShapes): anObj = ShapesOp.MakeCompound(theShapes) if ShapesOp.IsDone() == 0: print "MakeCompound : ", ShapesOp.GetErrorCode() return anObj -# * Reverses an orientation the given shape. -# * \param theShape Shape to be reversed. -# * \return The reversed copy of theShape. -# -# * Example: see GEOM_TestAll.py -# +""" + * Gives quantity of faces in the given shape. + * \param theShape Shape to count faces of. + * \return Quantity of faces. + + * Example: see GEOM_TestOthers.py +""" +def NumberOfFaces(theShape): + nb_faces = ShapesOp.NumberOfFaces(theShape) + if ShapesOp.IsDone() == 0: + print "NumberOfFaces : ", ShapesOp.GetErrorCode() + return nb_faces + +""" + * Gives quantity of edges in the given shape. + * \param theShape Shape to count edges of. + * \return Quantity of edges. + + * Example: see GEOM_TestOthers.py +""" +def NumberOfEdges(theShape): + nb_edges = ShapesOp.NumberOfEdges(theShape) + if ShapesOp.IsDone() == 0: + print "NumberOfEdges : ", ShapesOp.GetErrorCode() + return nb_edges + +""" + * Reverses an orientation the given shape. + * \param theShape Shape to be reversed. + * \return The reversed copy of theShape. + + * Example: see GEOM_TestAll.py +""" def ChangeOrientation(theShape): anObj = ShapesOp.ChangeOrientation(theShape) if ShapesOp.IsDone() == 0: print "ChangeOrientation : ", ShapesOp.GetErrorCode() return anObj -# * Shortcut to ChangeOrientation() -# -# * Example: see GEOM_TestOthers.py -# +""" + * Shortcut to ChangeOrientation() + + * Example: see GEOM_TestOthers.py +""" def OrientationChange(theShape): anObj = ChangeOrientation(theShape) return anObj +""" + * Retrieve all free faces from the given shape. + * Free face is a face, which is not shared between two shells of the shape. + * \param theShape Shape to find free faces in. + * \return List of IDs of all free faces, contained in theShape. + + * Example: see GEOM_TestOthers.py +""" +def GetFreeFacesIDs(theShape): + anIDs = ShapesOp.GetFreeFacesIDs(theShape) + if ShapesOp.IsDone() == 0: + print "GetFreeFacesIDs : ", ShapesOp.GetErrorCode() + return anIDs + +""" + * Get all sub-shapes of theShape1 of the given type, shared with theShape2. + * \param theShape1 Shape to find sub-shapes in. + * \param theShape2 Shape to find shared sub-shapes with. + * \param theShapeType Type of sub-shapes to be retrieved. + * \return List of sub-shapes of theShape1, shared with theShape2. + + * Example: see GEOM_TestOthers.py +""" +def GetSharedShapes(theShape1, theShape2, theShapeType): + aList = ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType) + if ShapesOp.IsDone() == 0: + print "GetSharedShapes : ", ShapesOp.GetErrorCode() + return aList + +""" + * Get sub-shapes of theShape of the given type, + * laying on the specified plane. + * \param theShape Shape to find sub-shapes of. + * \param theShapeType Type of sub-shapes to be retrieved. + * \param thePlane Face, specifying the plane to find shapes on. + * \return Group of all found sub-shapes. + + * Example: see GEOM_TestOthers.py +""" +def GetShapesOnPlane(theShape, theShapeType, thePlane): + anObj = ShapesOp.GetShapesOnPlane(theShape, theShapeType, thePlane) + if ShapesOp.IsDone() == 0: + print "GetShapesOnPlane : ", ShapesOp.GetErrorCode() + return anObj + +""" + * Get sub-shape of theShape of the given type, + * laying on the specified cylinder. + * \param theShape Shape to find sub-shapes of. + * \param theShapeType Type of sub-shapes to be retrieved. + * \param theAxis Vector (or line, or linear edge), specifying + * axis of the cylinder to find shapes on. + * \param theRadius Radius of the cylinder to find shapes on. + * \return Group of all found sub-shapes. + + * Example: see GEOM_TestOthers.py +""" +def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius): + anObj = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius) + if ShapesOp.IsDone() == 0: + print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode() + return anObj + +""" + * Get sub-shape of theShape of the given type, + * laying on the specified sphere. + * \param theShape Shape to find sub-shapes of. + * \param theShapeType Type of sub-shapes to be retrieved. + * \param theCenter Point, specifying center of the sphere to find shapes on. + * \param theRadius Radius of the sphere to find shapes on. + * \return Group of all found sub-shapes. + + * Example: see GEOM_TestOthers.py +""" +def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius): + anObj = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius) + if ShapesOp.IsDone() == 0: + print "GetShapesOnSphere : ", ShapesOp.GetErrorCode() + return anObj + +""" + * Get sub-shape(s) of theShapeWhere, which are + * coincident with \a theShapeWhat or could be a part of it. + * \param theShapeWhere Shape to find sub-shapes of. + * \param theShapeWhat Shape, specifying what to find. + * \return Group of all found sub-shapes or a single found sub-shape. + + * Example: see GEOM_TestOthers.py +""" +def GetInPlace(theShapeWhere, theShapeWhat): + anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat) + if ShapesOp.IsDone() == 0: + print "GetInPlace : ", ShapesOp.GetErrorCode() + return anObj + # ----------------------------------------------------------------------------- # Access to sub-shapes by their unique IDs inside the main shape. # ----------------------------------------------------------------------------- -# * Obtain a composite sub-shape of , composed from sub-shapes -# * of , selected by their unique IDs inside -# -# * Example: see GEOM_TestAll.py -# +""" + * Obtain a composite sub-shape of , composed from sub-shapes + * of , selected by their unique IDs inside + + * Example: see GEOM_TestAll.py +""" def GetSubShape(aShape, ListOfID): anObj = geom.AddSubShape(aShape,ListOfID) return anObj -# * Obtain unique ID of sub-shape inside -# -# * Example: see GEOM_TestAll.py -# +""" + * Obtain unique ID of sub-shape inside + + * Example: see GEOM_TestAll.py +""" def GetSubShapeID(aShape, aSubShape): anID = LocalOp.GetSubShapeIndex(aShape, aSubShape) if LocalOp.IsDone() == 0: @@ -780,39 +956,67 @@ def GetSubShapeID(aShape, aSubShape): # Decompose objects # ----------------------------------------------------------------------------- -# * Explode a shape on subshapes of a given type. -# * \param theShape Shape to be exploded. -# * \param theShapeType Type of sub-shapes to be retrieved. -# * \return List of sub-shapes of type theShapeType, contained in theShape. -# -# * Example: see GEOM_TestAll.py -# +""" + * Explode a shape on subshapes of a given type. + * \param theShape Shape to be exploded. + * \param theShapeType Type of sub-shapes to be retrieved. + * \return List of sub-shapes of type theShapeType, contained in theShape. + + * Example: see GEOM_TestAll.py +""" def SubShapeAll(aShape, aType): ListObj = ShapesOp.MakeExplode(aShape,aType,0) if ShapesOp.IsDone() == 0: print "MakeExplode : ", ShapesOp.GetErrorCode() return ListObj -# * Explode a shape on subshapes of a given type. -# * Sub-shapes will be sorted by coordinates of their gravity centers. -# * \param theShape Shape to be exploded. -# * \param theShapeType Type of sub-shapes to be retrieved. -# * \return List of sub-shapes of type theShapeType, contained in theShape. -# -# * Example: see GEOM_TestAll.py -# +""" + * Explode a shape on subshapes of a given type. + * \param theShape Shape to be exploded. + * \param theShapeType Type of sub-shapes to be retrieved. + * \return List of IDs of sub-shapes. +""" +def SubShapeAllIDs(aShape, aType): + ListObj = ShapesOp.SubShapeAllIDs(aShape,aType,0) + if ShapesOp.IsDone() == 0: + print "SubShapeAllIDs : ", ShapesOp.GetErrorCode() + return ListObj + +""" + * Explode a shape on subshapes of a given type. + * Sub-shapes will be sorted by coordinates of their gravity centers. + * \param theShape Shape to be exploded. + * \param theShapeType Type of sub-shapes to be retrieved. + * \return List of sub-shapes of type theShapeType, contained in theShape. + + * Example: see GEOM_TestAll.py +""" def SubShapeAllSorted(aShape, aType): ListObj = ShapesOp.MakeExplode(aShape,aType,1) if ShapesOp.IsDone() == 0: print "MakeExplode : ", ShapesOp.GetErrorCode() return ListObj -# * Obtain a compound of sub-shapes of , -# * selected by they indices in list of all sub-shapes of type . -# * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type] -# -# * Example: see GEOM_TestAll.py -# +""" + * Explode a shape on subshapes of a given type. + * Sub-shapes will be sorted by coordinates of their gravity centers. + * \param theShape Shape to be exploded. + * \param theShapeType Type of sub-shapes to be retrieved. + * \return List of IDs of sub-shapes. +""" +def SubShapeAllSortedIDs(aShape, aType): + ListIDs = ShapesOp.SubShapeAllIDs(aShape,aType,1) + if ShapesOp.IsDone() == 0: + print "SubShapeAllSortedIDs : ", ShapesOp.GetErrorCode() + return ListObj + +""" + * Obtain a compound of sub-shapes of , + * selected by they indices in list of all sub-shapes of type . + * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type] + + * Example: see GEOM_TestAll.py +""" def SubShape(aShape, aType, ListOfInd): ListOfIDs = [] AllShapeList = SubShapeAll(aShape, aType) @@ -821,12 +1025,13 @@ def SubShape(aShape, aType, ListOfInd): anObj = GetSubShape(aShape, ListOfIDs) return anObj -# * Obtain a compound of sub-shapes of , -# * selected by they indices in sorted list of all sub-shapes of type . -# * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type] -# -# * Example: see GEOM_TestAll.py -# +""" + * Obtain a compound of sub-shapes of , + * selected by they indices in sorted list of all sub-shapes of type . + * Each index is in range [1, Nb_Sub-Shapes_Of_Given_Type] + + * Example: see GEOM_TestAll.py +""" def SubShapeSorted(aShape, aType, ListOfInd): ListOfIDs = [] AllShapeList = SubShapeAllSorted(aShape, aType) @@ -839,131 +1044,140 @@ def SubShapeSorted(aShape, aType, ListOfInd): # Healing operations # ----------------------------------------------------------------------------- -# * Apply a sequence of Shape Healing operators to the given object. -# * \param theShape Shape to be processed. -# * \param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.). -# * \param theParameters List of names of parameters -# * ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.). -# * \param theValues List of values of parameters, in the same order -# * as parameters are listed in \a theParameters list. -# * \return New GEOM_Object, containing processed shape. -# -# * Example: see GEOM_TestHealing.py -# +""" + * Apply a sequence of Shape Healing operators to the given object. + * \param theShape Shape to be processed. + * \param theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.). + * \param theParameters List of names of parameters + * ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.). + * \param theValues List of values of parameters, in the same order + * as parameters are listed in \a theParameters list. + * \return New GEOM_Object, containing processed shape. + + * Example: see GEOM_TestHealing.py +""" def ProcessShape(theShape, theOperators, theParameters, theValues): anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues) if HealOp.IsDone() == 0: print "ProcessShape : ", HealOp.GetErrorCode() return anObj -# * Remove faces from the given object (shape). -# * \param theObject Shape to be processed. -# * \param theFaces Indices of faces to be removed, if EMPTY then the method -# * removes ALL faces of the given object. -# * \return New GEOM_Object, containing processed shape. -# -# * Example: see GEOM_TestHealing.py -# +""" + * Remove faces from the given object (shape). + * \param theObject Shape to be processed. + * \param theFaces Indices of faces to be removed, if EMPTY then the method + * removes ALL faces of the given object. + * \return New GEOM_Object, containing processed shape. + + * Example: see GEOM_TestHealing.py +""" def SuppressFaces(theObject, theFaces): anObj = HealOp.SuppressFaces(theObject, theFaces) if HealOp.IsDone() == 0: print "SuppressFaces : ", HealOp.GetErrorCode() return anObj -# * Sewing of some shapes into single shape. -# -# * Example: see GEOM_TestHealing.py -# +""" + * Sewing of some shapes into single shape. + + * Example: see GEOM_TestHealing.py +""" def MakeSewing(ListShape, theTolerance): comp = MakeCompound(ListShape) anObj = Sew(comp, theTolerance) return anObj -# * Sewing of the given object. -# * \param theObject Shape to be processed. -# * \param theTolerance Required tolerance value. -# * \return New GEOM_Object, containing processed shape. -# -# * Example: see MakeSewing() above -# +""" + * Sewing of the given object. + * \param theObject Shape to be processed. + * \param theTolerance Required tolerance value. + * \return New GEOM_Object, containing processed shape. + + * Example: see MakeSewing() above +""" def Sew(theObject, theTolerance): anObj = HealOp.Sew(theObject, theTolerance) if HealOp.IsDone() == 0: print "Sew : ", HealOp.GetErrorCode() return anObj -# * Remove internal wires and edges from the given object (face). -# * \param theObject Shape to be processed. -# * \param theWires Indices of wires to be removed, if EMPTY then the method -# * removes ALL internal wires of the given object. -# * \return New GEOM_Object, containing processed shape. -# -# * Example: see GEOM_TestHealing.py -# +""" + * Remove internal wires and edges from the given object (face). + * \param theObject Shape to be processed. + * \param theWires Indices of wires to be removed, if EMPTY then the method + * removes ALL internal wires of the given object. + * \return New GEOM_Object, containing processed shape. + + * Example: see GEOM_TestHealing.py +""" def SuppressInternalWires(theObject, theWires): anObj = HealOp.RemoveIntWires(theObject, theWires) if HealOp.IsDone() == 0: print "SuppressInternalWires : ", HealOp.GetErrorCode() return anObj -# * Remove internal closed contours (holes) from the given object. -# * \param theObject Shape to be processed. -# * \param theWires Indices of wires to be removed, if EMPTY then the method -# * removes ALL internal holes of the given object -# * \return New GEOM_Object, containing processed shape. -# -# * Example: see GEOM_TestHealing.py -# +""" + * Remove internal closed contours (holes) from the given object. + * \param theObject Shape to be processed. + * \param theWires Indices of wires to be removed, if EMPTY then the method + * removes ALL internal holes of the given object + * \return New GEOM_Object, containing processed shape. + + * Example: see GEOM_TestHealing.py +""" def SuppressHoles(theObject, theWires): anObj = HealOp.FillHoles(theObject, theWires) if HealOp.IsDone() == 0: print "SuppressHoles : ", HealOp.GetErrorCode() return anObj -# * Close an open wire. -# * \param theObject Shape to be processed. -# * \param theWires Indexes of edge(s) and wire(s) to be closed within theObject's shape, -# * if -1, then theObject itself is a wire. -# * \param isCommonVertex If TRUE : closure by creation of a common vertex, -# * If FALS : closure by creation of an edge between ends. -# * \return New GEOM_Object, containing processed shape. -# -# * Example: see GEOM_TestHealing.py -# +""" + * Close an open wire. + * \param theObject Shape to be processed. + * \param theWires Indexes of edge(s) and wire(s) to be closed within theObject's shape, + * if -1, then theObject itself is a wire. + * \param isCommonVertex If TRUE : closure by creation of a common vertex, + * If FALS : closure by creation of an edge between ends. + * \return New GEOM_Object, containing processed shape. + + * Example: see GEOM_TestHealing.py +""" def CloseContour(theObject, theWires, isCommonVertex): anObj = HealOp.CloseContour(theObject, theWires, isCommonVertex) if HealOp.IsDone() == 0: print "CloseContour : ", HealOp.GetErrorCode() return anObj -# * Addition of a point to a given edge object. -# * \param theObject Shape to be processed. -# * \param theEdgeIndex Index of edge to be divided within theObject's shape, -# * if -1, then theObject itself is the edge. -# * \param theValue Value of parameter on edge or length parameter, -# * depending on \a isByParameter. -# * \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1], -# * if FALSE : \a theValue is treated as a length parameter [0..1] -# * \return New GEOM_Object, containing processed shape. -# -# * Example: see GEOM_TestHealing.py -# +""" + * Addition of a point to a given edge object. + * \param theObject Shape to be processed. + * \param theEdgeIndex Index of edge to be divided within theObject's shape, + * if -1, then theObject itself is the edge. + * \param theValue Value of parameter on edge or length parameter, + * depending on \a isByParameter. + * \param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1], + * if FALSE : \a theValue is treated as a length parameter [0..1] + * \return New GEOM_Object, containing processed shape. + + * Example: see GEOM_TestHealing.py +""" def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter): anObj = HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter) if HealOp.IsDone() == 0: print "DivideEdge : ", HealOp.GetErrorCode() return anObj -# * Get a list of wires (wrapped in GEOM_Object-s), -# * that constitute a free boundary of the given shape. -# * \param theObject Shape to get free boundary of. -# * \return [status, theClosedWires, theOpenWires] -# * status: FALSE, if an error(s) occured during the method execution. -# * theClosedWires: Closed wires on the free boundary of the given shape. -# * theOpenWires: Open wires on the free boundary of the given shape. -# -# * Example: see GEOM_TestHealing.py -# +""" + * Get a list of wires (wrapped in GEOM_Object-s), + * that constitute a free boundary of the given shape. + * \param theObject Shape to get free boundary of. + * \return [status, theClosedWires, theOpenWires] + * status: FALSE, if an error(s) occured during the method execution. + * theClosedWires: Closed wires on the free boundary of the given shape. + * theOpenWires: Open wires on the free boundary of the given shape. + + * Example: see GEOM_TestHealing.py +""" def GetFreeBoundary(theObject): anObj = HealOp.GetFreeBoundary(theObject) if HealOp.IsDone() == 0: @@ -974,40 +1188,43 @@ def GetFreeBoundary(theObject): # Create advanced objects # ----------------------------------------------------------------------------- -# * Create a copy of the given object -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a copy of the given object + + * Example: see GEOM_TestAll.py +""" def MakeCopy(theOriginal): anObj = InsertOp.MakeCopy(theOriginal) if InsertOp.IsDone() == 0: print "MakeCopy : ", InsertOp.GetErrorCode() return anObj -# * Create a filling from the given compound of contours. -# * \param theShape the compound of contours -# * \param theMinDeg a minimal degree -# * \param theMaxDeg a maximal degree -# * \param theTol2D a 2d tolerance -# * \param theTol3D a 3d tolerance -# * \param theNbIter a number of iteration -# * \return New GEOM_Object, containing the created filling surface. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create a filling from the given compound of contours. + * \param theShape the compound of contours + * \param theMinDeg a minimal degree + * \param theMaxDeg a maximal degree + * \param theTol2D a 2d tolerance + * \param theTol3D a 3d tolerance + * \param theNbIter a number of iteration + * \return New GEOM_Object, containing the created filling surface. + + * Example: see GEOM_TestAll.py +""" def MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter): anObj = PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter) if PrimOp.IsDone() == 0: print "MakeFilling : ", PrimOp.GetErrorCode() return anObj -# * Replace coincident faces in theShape by one face. -# * \param theShape Initial shape. -# * \param theTolerance Maximum distance between faces, which can be considered as coincident. -# * \return New GEOM_Object, containing a copy of theShape without coincident faces. -# -# * Example: see GEOM_Spanner.py -# +""" + * Replace coincident faces in theShape by one face. + * \param theShape Initial shape. + * \param theTolerance Maximum distance between faces, which can be considered as coincident. + * \return New GEOM_Object, containing a copy of theShape without coincident faces. + + * Example: see GEOM_Spanner.py +""" def MakeGlueFaces(theShape, theTolerance): anObj = ShapesOp.MakeGlueFaces(theShape, theTolerance) if ShapesOp.IsDone() == 0: @@ -1018,51 +1235,54 @@ def MakeGlueFaces(theShape, theTolerance): # Boolean (Common, Cut, Fuse, Section) # ----------------------------------------------------------------------------- -# * Perform one of boolean operations on two given shapes. -# * \param theShape1 First argument for boolean operation. -# * \param theShape2 Second argument for boolean operation. -# * \param theOperation Indicates the operation to be done: -# * 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section. -# * \return New GEOM_Object, containing the result shape. -# -# * Example: see GEOM_TestAll.py -# +""" + * Perform one of boolean operations on two given shapes. + * \param theShape1 First argument for boolean operation. + * \param theShape2 Second argument for boolean operation. + * \param theOperation Indicates the operation to be done: + * 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section. + * \return New GEOM_Object, containing the result shape. + + * Example: see GEOM_TestAll.py +""" def MakeBoolean(theShape1, theShape2, theOperation): anObj = BoolOp.MakeBoolean(theShape1, theShape2, theOperation) if BoolOp.IsDone() == 0: print "MakeBoolean : ", BoolOp.GetErrorCode() return anObj -# * Shortcuts to MakeBoolean() for certain operations -# -# * Example: see GEOM_TestOthers.py -# +""" + * Shortcuts to MakeBoolean() for certain operations + + * Example: see GEOM_TestOthers.py +""" def MakeCommon(s1, s2): return MakeBoolean(s1, s2, 1) -# + def MakeCut(s1, s2): return MakeBoolean(s1, s2, 2) -# + def MakeFuse(s1, s2): return MakeBoolean(s1, s2, 3) -# + def MakeSection(s1, s2): return MakeBoolean(s1, s2, 4) -# * Perform partition operation. -# * \param ListShapes Shapes to be intersected. -# * \param ListTools Shapes to intersect theShapes. -# * \param ListKeepInside Shapes, outside which the results will be deleted. -# * Each shape from theKeepInside must belong to theShapes also. -# * \param ListRemoveInside Shapes, inside which the results will be deleted. -# * Each shape from theRemoveInside must belong to theShapes also. -# * \param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum). -# * \param RemoveWebs If TRUE, perform Glue 3D algorithm. -# * \param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE. -# * \return New GEOM_Object, containing the result shapes. -# -# * Example: see GEOM_TestAll.py -# +""" + * Perform partition operation. + * \param ListShapes Shapes to be intersected. + * \param ListTools Shapes to intersect theShapes. + * \param ListKeepInside Shapes, outside which the results will be deleted. + * Each shape from theKeepInside must belong to theShapes also. + * \param ListRemoveInside Shapes, inside which the results will be deleted. + * Each shape from theRemoveInside must belong to theShapes also. + * \param Limit Type of resulting shapes (corresponding to TopAbs_ShapeEnum). + * \param RemoveWebs If TRUE, perform Glue 3D algorithm. + * \param ListMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE. + * \return New GEOM_Object, containing the result shapes. + + * Example: see GEOM_TestAll.py +""" def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]): anObj = BoolOp.MakePartition(ListShapes, ListTools, @@ -1072,10 +1292,11 @@ def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside= print "MakePartition : ", BoolOp.GetErrorCode() return anObj -# * Shortcut to MakePartition() -# -# * Example: see GEOM_TestOthers.py -# +""" + * Shortcut to MakePartition() + + * Example: see GEOM_TestOthers.py +""" def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]): anObj = MakePartition(ListShapes, ListTools, @@ -1083,100 +1304,166 @@ def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit, RemoveWebs, ListMaterials); return anObj +""" + * Perform partition of the Shape with the Plane + * \param theShape Shape to be intersected. + * \param thePlane Tool shape, to intersect theShape. + * \return New GEOM_Object, containing the result shape. + + * Example: see GEOM_TestAll.py +""" +def MakeHalfPartition(theShape, thePlane): + anObj = BoolOp.MakeHalfPartition(theShape, thePlane) + if BoolOp.IsDone() == 0: + print "MakeHalfPartition : ", BoolOp.GetErrorCode() + return anObj + # ----------------------------------------------------------------------------- # Transform objects # ----------------------------------------------------------------------------- -# * Translate the given object along the vector, specified -# * by its end points, creating its copy before the translation. -# * \param theObject The object to be translated. -# * \param thePoint1 Start point of translation vector. -# * \param thePoint2 End point of translation vector. -# * \return New GEOM_Object, containing the translated object. -# -# * Example: see GEOM_TestAll.py -# +""" + * Translate the given object along the vector, specified + * by its end points, creating its copy before the translation. + * \param theObject The object to be translated. + * \param thePoint1 Start point of translation vector. + * \param thePoint2 End point of translation vector. + * \return New GEOM_Object, containing the translated object. + + * Example: see GEOM_TestAll.py +""" def MakeTranslationTwoPoints(theObject, thePoint1, thePoint2): anObj = TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2) if TrsfOp.IsDone() == 0: print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode() return anObj -# * Translate the given object along the vector, specified -# * by its components, creating its copy before the translation. -# * \param theObject The object to be translated. -# * \param theDX,theDY,theDZ Components of translation vector. -# * \return New GEOM_Object, containing the translated object. -# -# * Example: see GEOM_TestAll.py -# +""" + * Translate the given object along the vector, specified + * by its components, creating its copy before the translation. + * \param theObject The object to be translated. + * \param theDX,theDY,theDZ Components of translation vector. + * \return New GEOM_Object, containing the translated object. + + * Example: see GEOM_TestAll.py +""" def MakeTranslation(theObject, theDX, theDY, theDZ): anObj = TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ) if TrsfOp.IsDone() == 0: print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode() return anObj -# * Rotate the given object around the given axis -# * on the given angle, creating its copy before the rotatation. -# * \param theObject The object to be rotated. -# * \param theAxis Rotation axis. -# * \param theAngle Rotation angle in radians. -# * \return New GEOM_Object, containing the rotated object. -# -# * Example: see GEOM_TestAll.py -# +""" + * Translate the given object along the given vector, + * creating its copy before the translation. + * \param theObject The object to be translated. + * \param theVector The translation vector. + * \return New GEOM_Object, containing the translated object. + + * Example: see GEOM_TestAll.py +""" +def MakeTranslationVector(theObject, theVector): + anObj = TrsfOp.TranslateVectorCopy(theObject, theVector) + if TrsfOp.IsDone() == 0: + print "TranslateVectorCopy : ", TrsfOp.GetErrorCode() + return anObj + +""" + * Rotate the given object around the given axis + * on the given angle, creating its copy before the rotatation. + * \param theObject The object to be rotated. + * \param theAxis Rotation axis. + * \param theAngle Rotation angle in radians. + * \return New GEOM_Object, containing the rotated object. + + * Example: see GEOM_TestAll.py +""" def MakeRotation(theObject, theAxis, theAngle): anObj = TrsfOp.RotateCopy(theObject, theAxis, theAngle) if TrsfOp.IsDone() == 0: print "RotateCopy : ", TrsfOp.GetErrorCode() return anObj -# * Scale the given object by the factor, creating its copy before the scaling. -# * \param theObject The object to be scaled. -# * \param thePoint Center point for scaling. -# * \param theFactor Scaling factor value. -# * \return New GEOM_Object, containing the scaled shape. -# -# * Example: see GEOM_TestAll.py -# +""" + * Scale the given object by the factor, creating its copy before the scaling. + * \param theObject The object to be scaled. + * \param thePoint Center point for scaling. + * \param theFactor Scaling factor value. + * \return New GEOM_Object, containing the scaled shape. + + * Example: see GEOM_TestAll.py +""" def MakeScaleTransform(theObject, thePoint, theFactor): anObj = TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor) if TrsfOp.IsDone() == 0: print "ScaleShapeCopy : ", TrsfOp.GetErrorCode() return anObj -# * Create an object, symmetrical -# * to the given one relatively the given plane. -# * \param theObject The object to be mirrored. -# * \param thePlane Plane of symmetry. -# * \return New GEOM_Object, containing the mirrored shape. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create an object, symmetrical + * to the given one relatively the given plane. + * \param theObject The object to be mirrored. + * \param thePlane Plane of symmetry. + * \return New GEOM_Object, containing the mirrored shape. + + * Example: see GEOM_TestAll.py +""" def MakeMirrorByPlane(theObject, thePlane): anObj = TrsfOp.MirrorPlaneCopy(theObject, thePlane) if TrsfOp.IsDone() == 0: print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode() return anObj -# * Modify the Location of the given object by LCS -# * creating its copy before the setting -# -# * Example: see GEOM_TestAll.py -# +""" + * Create an object, symmetrical + * to the given one relatively the given axis. + * \param theObject The object to be mirrored. + * \param theAxis Axis of symmetry. + * \return New GEOM_Object, containing the mirrored shape. + + * Example: see GEOM_TestAll.py +""" +def MakeMirrorByAxis(theObject, theAxis): + anObj = TrsfOp.MirrorAxisCopy(theObject, theAxis) + if TrsfOp.IsDone() == 0: + print "MirrorAxisCopy : ", TrsfOp.GetErrorCode() + return anObj + +""" + * Create an object, symmetrical + * to the given one relatively the given point. + * \param theObject The object to be mirrored. + * \param thePoint Point of symmetry. + * \return New GEOM_Object, containing the mirrored shape. + + * Example: see GEOM_TestAll.py +""" +def MakeMirrorByPoint(theObject, thePoint): + anObj = TrsfOp.MirrorPointCopy(theObject, thePoint) + if TrsfOp.IsDone() == 0: + print "MirrorPointCopy : ", TrsfOp.GetErrorCode() + return anObj + +""" + * Modify the Location of the given object by LCS + * creating its copy before the setting + + * Example: see GEOM_TestAll.py +""" def MakePosition(theObject, theStartLCS, theEndLCS): anObj = TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS) if TrsfOp.IsDone() == 0: print "PositionShapeCopy : ", TrsfOp.GetErrorCode() return anObj -# * Create new object as offset of the given one. -# * \param theObject The base object for the offset. -# * \param theOffset Offset value. -# * \return New GEOM_Object, containing the offset object. -# -# * Example: see GEOM_TestAll.py -# +""" + * Create new object as offset of the given one. + * \param theObject The base object for the offset. + * \param theOffset Offset value. + * \return New GEOM_Object, containing the offset object. + + * Example: see GEOM_TestAll.py +""" def MakeOffset(theObject, theOffset): anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset) if TrsfOp.IsDone() == 0: @@ -1187,35 +1474,37 @@ def MakeOffset(theObject, theOffset): # Patterns # ----------------------------------------------------------------------------- -# * Translate the given object along the given vector a given number times -# * \param theObject The object to be translated. -# * \param theVector Direction of the translation. -# * \param theStep Distance to translate on. -# * \param theNbTimes Quantity of translations to be done. -# * \return New GEOM_Object, containing compound of all -# * the shapes, obtained after each translation. -# -# * Example: see GEOM_TestAll.py -# +""" + * Translate the given object along the given vector a given number times + * \param theObject The object to be translated. + * \param theVector Direction of the translation. + * \param theStep Distance to translate on. + * \param theNbTimes Quantity of translations to be done. + * \return New GEOM_Object, containing compound of all + * the shapes, obtained after each translation. + + * Example: see GEOM_TestAll.py +""" def MakeMultiTranslation1D(theObject, theVector, theStep, theNbTimes): anObj = TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes) if TrsfOp.IsDone() == 0: print "MultiTranslate1D : ", TrsfOp.GetErrorCode() return anObj -# * Conseqently apply two specified translations to theObject specified number of times. -# * \param theObject The object to be translated. -# * \param theVector1 Direction of the first translation. -# * \param theStep1 Step of the first translation. -# * \param theNbTimes1 Quantity of translations to be done along theVector1. -# * \param theVector2 Direction of the second translation. -# * \param theStep2 Step of the second translation. -# * \param theNbTimes2 Quantity of translations to be done along theVector2. -# * \return New GEOM_Object, containing compound of all -# * the shapes, obtained after each translation. -# -# * Example: see GEOM_TestAll.py -# +""" + * Conseqently apply two specified translations to theObject specified number of times. + * \param theObject The object to be translated. + * \param theVector1 Direction of the first translation. + * \param theStep1 Step of the first translation. + * \param theNbTimes1 Quantity of translations to be done along theVector1. + * \param theVector2 Direction of the second translation. + * \param theStep2 Step of the second translation. + * \param theNbTimes2 Quantity of translations to be done along theVector2. + * \return New GEOM_Object, containing compound of all + * the shapes, obtained after each translation. + + * Example: see GEOM_TestAll.py +""" def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1, theVector2, theStep2, theNbTimes2): anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1, @@ -1224,57 +1513,61 @@ def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1, print "MultiTranslate2D : ", TrsfOp.GetErrorCode() return anObj -# * Rotate the given object around the given axis a given number times. -# * Rotation angle will be 2*PI/theNbTimes. -# * \param theObject The object to be rotated. -# * \param theAxis The rotation axis. -# * \param theNbTimes Quantity of rotations to be done. -# * \return New GEOM_Object, containing compound of all the -# * shapes, obtained after each rotation. -# -# * Example: see GEOM_TestAll.py -# +""" + * Rotate the given object around the given axis a given number times. + * Rotation angle will be 2*PI/theNbTimes. + * \param theObject The object to be rotated. + * \param theAxis The rotation axis. + * \param theNbTimes Quantity of rotations to be done. + * \return New GEOM_Object, containing compound of all the + * shapes, obtained after each rotation. + + * Example: see GEOM_TestAll.py +""" def MultiRotate1D(theObject, theAxis, theNbTimes): anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes) if TrsfOp.IsDone() == 0: print "MultiRotate1D : ", TrsfOp.GetErrorCode() return anObj -# * Rotate the given object around the -# * given axis on the given angle a given number -# * times and multi-translate each rotation result. -# * Translation direction passes through center of gravity -# * of rotated shape and its projection on the rotation axis. -# * \param theObject The object to be rotated. -# * \param theAxis Rotation axis. -# * \param theAngle Rotation angle in graduces. -# * \param theNbTimes1 Quantity of rotations to be done. -# * \param theStep Translation distance. -# * \param theNbTimes2 Quantity of translations to be done. -# * \return New GEOM_Object, containing compound of all the -# * shapes, obtained after each transformation. -# -# * Example: see GEOM_TestAll.py -# +""" + * Rotate the given object around the + * given axis on the given angle a given number + * times and multi-translate each rotation result. + * Translation direction passes through center of gravity + * of rotated shape and its projection on the rotation axis. + * \param theObject The object to be rotated. + * \param theAxis Rotation axis. + * \param theAngle Rotation angle in graduces. + * \param theNbTimes1 Quantity of rotations to be done. + * \param theStep Translation distance. + * \param theNbTimes2 Quantity of translations to be done. + * \return New GEOM_Object, containing compound of all the + * shapes, obtained after each transformation. + + * Example: see GEOM_TestAll.py +""" def MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2): anObj = TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2) if TrsfOp.IsDone() == 0: print "MultiRotate2D : ", TrsfOp.GetErrorCode() return anObj -# * The same, as MultiRotate1D(), but axis is given by direction and point -# -# * Example: see GEOM_TestOthers.py -# +""" + * The same, as MultiRotate1D(), but axis is given by direction and point + + * Example: see GEOM_TestOthers.py +""" def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes): aVec = MakeLine(aPoint,aDir) anObj = MultiRotate1D(aShape,aVec,aNbTimes) return anObj -# * The same, as MultiRotate2D(), but axis is given by direction and point -# -# * Example: see GEOM_TestOthers.py -# +""" + * The same, as MultiRotate2D(), but axis is given by direction and point + + * Example: see GEOM_TestOthers.py +""" def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2): aVec = MakeLine(aPoint,aDir) anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2) @@ -1284,29 +1577,31 @@ def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2): # Local operations # ----------------------------------------------------------------------------- -# * Perform a fillet on all edges of the given shape. -# * \param theShape Shape, to perform fillet on. -# * \param theR Fillet radius. -# * \return New GEOM_Object, containing the result shape. -# -# * Example: see GEOM_TestOthers.py -# +""" + * Perform a fillet on all edges of the given shape. + * \param theShape Shape, to perform fillet on. + * \param theR Fillet radius. + * \return New GEOM_Object, containing the result shape. + + * Example: see GEOM_TestOthers.py +""" def MakeFilletAll(theShape, theR): anObj = LocalOp.MakeFilletAll(theShape, theR) if LocalOp.IsDone() == 0: print "MakeFilletAll : ", LocalOp.GetErrorCode() return anObj -# * Perform a fillet on the specified edges/faces of the given shape -# * \param theShape Shape, to perform fillet on. -# * \param theR Fillet radius. -# * \param theShapeType Type of shapes in . -# * \param theListShapes Global indices of edges/faces to perform fillet on. -# * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID(). -# * \return New GEOM_Object, containing the result shape. -# -# * Example: see GEOM_TestAll.py -# +""" + * Perform a fillet on the specified edges/faces of the given shape + * \param theShape Shape, to perform fillet on. + * \param theR Fillet radius. + * \param theShapeType Type of shapes in . + * \param theListShapes Global indices of edges/faces to perform fillet on. + * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID(). + * \return New GEOM_Object, containing the result shape. + + * Example: see GEOM_TestAll.py +""" def MakeFillet(theShape, theR, theShapeType, theListShapes): anObj = None if theShapeType == ShapeType["EDGE"]: @@ -1317,59 +1612,63 @@ def MakeFillet(theShape, theR, theShapeType, theListShapes): print "MakeFillet : ", LocalOp.GetErrorCode() return anObj -# * Perform a symmetric chamfer on all edges of the given shape. -# * \param theShape Shape, to perform chamfer on. -# * \param theD Chamfer size along each face. -# * \return New GEOM_Object, containing the result shape. -# -# * Example: see GEOM_TestOthers.py -# +""" + * Perform a symmetric chamfer on all edges of the given shape. + * \param theShape Shape, to perform chamfer on. + * \param theD Chamfer size along each face. + * \return New GEOM_Object, containing the result shape. + + * Example: see GEOM_TestOthers.py +""" def MakeChamferAll(theShape, theD): anObj = LocalOp.MakeChamferAll(theShape, theD) if LocalOp.IsDone() == 0: print "MakeChamferAll : ", LocalOp.GetErrorCode() return anObj -# * Perform a chamfer on edges, common to the specified faces, -# * with distance D1 on the Face1 -# * \param theShape Shape, to perform chamfer on. -# * \param theD1 Chamfer size along \a theFace1. -# * \param theD2 Chamfer size along \a theFace2. -# * \param theFace1,theFace2 Global indices of two faces of \a theShape. -# * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID(). -# * \return New GEOM_Object, containing the result shape. -# -# * Example: see GEOM_TestAll.py -# +""" + * Perform a chamfer on edges, common to the specified faces, + * with distance D1 on the Face1 + * \param theShape Shape, to perform chamfer on. + * \param theD1 Chamfer size along \a theFace1. + * \param theD2 Chamfer size along \a theFace2. + * \param theFace1,theFace2 Global indices of two faces of \a theShape. + * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID(). + * \return New GEOM_Object, containing the result shape. + + * Example: see GEOM_TestAll.py +""" def MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2): anObj = LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2) if LocalOp.IsDone() == 0: print "MakeChamferEdge : ", LocalOp.GetErrorCode() return anObj -# * Perform a chamfer on all edges of the specified faces, -# * with distance D1 on the first specified face (if several for one edge) -# * \param theShape Shape, to perform chamfer on. -# * \param theD1 Chamfer size along face from \a theFaces. If both faces, -# * connected to the edge, are in \a theFaces, \a theD1 -# * will be get along face, which is nearer to \a theFaces beginning. -# * \param theD2 Chamfer size along another of two faces, connected to the edge. -# * \param theFaces Sequence of global indices of faces of \a theShape. -# * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeIndex(). -# * \return New GEOM_Object, containing the result shape. -# -# * Example: see GEOM_TestAll.py -# +""" + * Perform a chamfer on all edges of the specified faces, + * with distance D1 on the first specified face (if several for one edge) + * \param theShape Shape, to perform chamfer on. + * \param theD1 Chamfer size along face from \a theFaces. If both faces, + * connected to the edge, are in \a theFaces, \a theD1 + * will be get along face, which is nearer to \a theFaces beginning. + * \param theD2 Chamfer size along another of two faces, connected to the edge. + * \param theFaces Sequence of global indices of faces of \a theShape. + * \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID(). + * \return New GEOM_Object, containing the result shape. + + * Example: see GEOM_TestAll.py +""" def MakeChamferFaces(theShape, theD1, theD2, theFaces): anObj = LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces) if LocalOp.IsDone() == 0: print "MakeChamferFaces : ", LocalOp.GetErrorCode() return anObj -# * Shortcut to MakeChamferEdge() and MakeChamferFaces() -# -# * Example: see GEOM_TestOthers.py -# +""" + * Shortcut to MakeChamferEdge() and MakeChamferFaces() + + * Example: see GEOM_TestOthers.py +""" def MakeChamfer(aShape,d1,d2,aShapeType,ListShape): anObj = None if aShapeType == ShapeType["EDGE"]: @@ -1378,17 +1677,18 @@ def MakeChamfer(aShape,d1,d2,aShapeType,ListShape): anObj = MakeChamferFaces(aShape,d1,d2,ListShape) return anObj -# * Perform an Archimde operation on the given shape with given parameters. -# * The object presenting the resulting face is returned -# * \param theShape Shape to be put in water. -# * \param theWeight Weight og the shape. -# * \param theWaterDensity Density of the water. -# * \param theMeshDeflection Deflection of the mesh, using to compute the section. -# * \return New GEOM_Object, containing a section of \a theShape -# * by a plane, corresponding to water level. -# -# * Example: see GEOM_TestAll.py -# +""" + * Perform an Archimde operation on the given shape with given parameters. + * The object presenting the resulting face is returned + * \param theShape Shape to be put in water. + * \param theWeight Weight og the shape. + * \param theWaterDensity Density of the water. + * \param theMeshDeflection Deflection of the mesh, using to compute the section. + * \return New GEOM_Object, containing a section of \a theShape + * by a plane, corresponding to water level. + + * Example: see GEOM_TestAll.py +""" def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection): anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection) if LocalOp.IsDone() == 0: @@ -1399,120 +1699,129 @@ def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection): # Information objects # ----------------------------------------------------------------------------- -# * Get point coordinates -# * \return [x, y, z] -# -# * Example: see GEOM_TestMeasures.py -# +""" + * Get point coordinates + * \return [x, y, z] + + * Example: see GEOM_TestMeasures.py +""" def PointCoordinates(Point): aTuple = MeasuOp.PointCoordinates(Point) if MeasuOp.IsDone() == 0: print "PointCoordinates : ", MeasuOp.GetErrorCode() return aTuple -# * Get summarized length of all wires, -# * area of surface and volume of the given shape. -# * \param theShape Shape to define properties of. -# * \return [theLength, theSurfArea, theVolume] -# * theLength: Summarized length of all wires of the given shape. -# * theSurfArea: Area of surface of the given shape. -# * theVolume: Volume of the given shape. -# -# * Example: see GEOM_TestMeasures.py -# +""" + * Get summarized length of all wires, + * area of surface and volume of the given shape. + * \param theShape Shape to define properties of. + * \return [theLength, theSurfArea, theVolume] + * theLength: Summarized length of all wires of the given shape. + * theSurfArea: Area of surface of the given shape. + * theVolume: Volume of the given shape. + + * Example: see GEOM_TestMeasures.py +""" def BasicProperties(theShape): aTuple = MeasuOp.GetBasicProperties(theShape) if MeasuOp.IsDone() == 0: print "BasicProperties : ", MeasuOp.GetErrorCode() return aTuple -# * Get parameters of bounding box of the given shape -# * \param theShape Shape to obtain bounding box of. -# * \return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax] -# * Xmin,Xmax: Limits of shape along OX axis. -# * Ymin,Ymax: Limits of shape along OY axis. -# * Zmin,Zmax: Limits of shape along OZ axis. -# -# * Example: see GEOM_TestMeasures.py -# +""" + * Get parameters of bounding box of the given shape + * \param theShape Shape to obtain bounding box of. + * \return [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax] + * Xmin,Xmax: Limits of shape along OX axis. + * Ymin,Ymax: Limits of shape along OY axis. + * Zmin,Zmax: Limits of shape along OZ axis. + + * Example: see GEOM_TestMeasures.py +""" def BoundingBox(theShape): aTuple = MeasuOp.GetBoundingBox(theShape) if MeasuOp.IsDone() == 0: print "BoundingBox : ", MeasuOp.GetErrorCode() return aTuple -# * Get inertia matrix and moments of inertia of theShape. -# * \param theShape Shape to calculate inertia of. -# * \return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz] -# * I(1-3)(1-3): Components of the inertia matrix of the given shape. -# * Ix,Iy,Iz: Moments of inertia of the given shape. -# -# * Example: see GEOM_TestMeasures.py -# +""" + * Get inertia matrix and moments of inertia of theShape. + * \param theShape Shape to calculate inertia of. + * \return [I11,I12,I13, I21,I22,I23, I31,I32,I33, Ix,Iy,Iz] + * I(1-3)(1-3): Components of the inertia matrix of the given shape. + * Ix,Iy,Iz: Moments of inertia of the given shape. + + * Example: see GEOM_TestMeasures.py +""" def Inertia(theShape): aTuple = MeasuOp.GetInertia(theShape) if MeasuOp.IsDone() == 0: print "Inertia : ", MeasuOp.GetErrorCode() return aTuple -# * Get minimal distance between the given shapes. -# * \param theShape1,theShape2 Shapes to find minimal distance between. -# * \return Value of the minimal distance between the given shapes. -# -# * Example: see GEOM_TestMeasures.py -# +""" + * Get minimal distance between the given shapes. + * \param theShape1,theShape2 Shapes to find minimal distance between. + * \return Value of the minimal distance between the given shapes. + + * Example: see GEOM_TestMeasures.py +""" def MinDistance(theShape1, theShape2): aTuple = MeasuOp.GetMinDistance(theShape1, theShape2) if MeasuOp.IsDone() == 0: print "MinDistance : ", MeasuOp.GetErrorCode() return aTuple[0] -# * Get min and max tolerances of sub-shapes of theShape -# * \param theShape Shape, to get tolerances of. -# * \return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax] -# * FaceMin,FaceMax: Min and max tolerances of the faces. -# * EdgeMin,EdgeMax: Min and max tolerances of the edges. -# * VertMin,VertMax: Min and max tolerances of the vertices. -# -# * Example: see GEOM_TestMeasures.py -# +""" + * Get min and max tolerances of sub-shapes of theShape + * \param theShape Shape, to get tolerances of. + * \return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax] + * FaceMin,FaceMax: Min and max tolerances of the faces. + * EdgeMin,EdgeMax: Min and max tolerances of the edges. + * VertMin,VertMax: Min and max tolerances of the vertices. + + * Example: see GEOM_TestMeasures.py +""" def Tolerance(theShape): aTuple = MeasuOp.GetTolerance(theShape) if MeasuOp.IsDone() == 0: print "Tolerance : ", MeasuOp.GetErrorCode() return aTuple -# * Obtain description of the given shape (number of sub-shapes of each type) -# * \param theShape Shape to be described. -# * \return Description of the given shape. -# -# * Example: see GEOM_TestMeasures.py -# +""" + * Obtain description of the given shape (number of sub-shapes of each type) + * \param theShape Shape to be described. + * \return Description of the given shape. + + * Example: see GEOM_TestMeasures.py +""" def WhatIs(theShape): aDescr = MeasuOp.WhatIs(theShape) if MeasuOp.IsDone() == 0: print "WhatIs : ", MeasuOp.GetErrorCode() return aDescr -# * Get a point, situated at the centre of mass of theShape. -# * \param theShape Shape to define centre of mass of. -# * \return New GEOM_Object, containing the created point. -# -# * Example: see GEOM_TestMeasures.py -# +""" + * Get a point, situated at the centre of mass of theShape. + * \param theShape Shape to define centre of mass of. + * \return New GEOM_Object, containing the created point. + + * Example: see GEOM_TestMeasures.py +""" def MakeCDG(theShape): anObj = MeasuOp.GetCentreOfMass(theShape) if MeasuOp.IsDone() == 0: print "GetCentreOfMass : ", MeasuOp.GetErrorCode() return anObj -# * Check a topology of the given shape. -# * \param theShape Shape to check validity of. -# * \return TRUE, if the shape "seems to be valid" from the topological point of view. -# * If theShape is invalid, prints a description of problem. -# -# * Example: see GEOM_TestMeasures.py -# +""" + * Check a topology of the given shape. + * \param theShape Shape to check validity of. + * \return TRUE, if the shape "seems to be valid" from the topological point of view. + * If theShape is invalid, prints a description of problem. + + * Example: see GEOM_TestMeasures.py +""" def CheckShape(theShape): (IsValid, Status) = MeasuOp.CheckShape(theShape) if MeasuOp.IsDone() == 0: @@ -1526,57 +1835,61 @@ def CheckShape(theShape): # Import/Export objects # ----------------------------------------------------------------------------- -# * Import a shape from the BREP or IGES or STEP file -# * (depends on given format) with given name. -# * \param theFileName The file, containing the shape. -# * \param theFormatName Specify format for the file reading. -# * Available formats can be obtained with InsertOp.ImportTranslators() method. -# * \return New GEOM_Object, containing the imported shape. -# -# * Example: see GEOM_TestOthers.py -# +""" + * Import a shape from the BREP or IGES or STEP file + * (depends on given format) with given name. + * \param theFileName The file, containing the shape. + * \param theFormatName Specify format for the file reading. + * Available formats can be obtained with InsertOp.ImportTranslators() method. + * \return New GEOM_Object, containing the imported shape. + + * Example: see GEOM_TestOthers.py +""" def Import(theFileName, theFormatName): anObj = InsertOp.Import(theFileName, theFormatName) if InsertOp.IsDone() == 0: print "Import : ", InsertOp.GetErrorCode() return anObj -# * Shortcuts to Import() for certain formats -# -# * Example: see GEOM_TestOthers.py -# +""" + * Shortcuts to Import() for certain formats + + * Example: see GEOM_TestOthers.py +""" def ImportBREP(theFileName): return Import(theFileName, "BREP") -# + def ImportIGES(theFileName): return Import(theFileName, "IGES") -# + def ImportSTEP(theFileName): return Import(theFileName, "STEP") -# * Export the given shape into a file with given name. -# * \param theObject Shape to be stored in the file. -# * \param theFileName Name of the file to store the given shape in. -# * \param theFormatName Specify format for the shape storage. -# * Available formats can be obtained with InsertOp.ImportTranslators() method. -# -# * Example: see GEOM_TestOthers.py -# +""" + * Export the given shape into a file with given name. + * \param theObject Shape to be stored in the file. + * \param theFileName Name of the file to store the given shape in. + * \param theFormatName Specify format for the shape storage. + * Available formats can be obtained with InsertOp.ImportTranslators() method. + + * Example: see GEOM_TestOthers.py +""" def Export(theObject, theFileName, theFormatName): InsertOp.Export(theObject, theFileName, theFormatName) if InsertOp.IsDone() == 0: print "Export : ", InsertOp.GetErrorCode() -# * Shortcuts to Export() for certain formats -# -# * Example: see GEOM_TestOthers.py -# +""" + * Shortcuts to Export() for certain formats + + * Example: see GEOM_TestOthers.py +""" def ExportBREP(theObject, theFileName): return Export(theObject, theFileName, "BREP") -# + def ExportIGES(theObject, theFileName): return Export(theObject, theFileName, "IGES") -# + def ExportSTEP(theObject, theFileName): return Export(theObject, theFileName, "STEP") @@ -1584,133 +1897,204 @@ def ExportSTEP(theObject, theFileName): # Block operations # ----------------------------------------------------------------------------- -# * Create a quadrangle face from four edges. Order of Edges is not -# * important. It is not necessary that edges share the same vertex. -# * \param E1,E2,E3,E4 Edges for the face bound. -# * \return New GEOM_Object, containing the created face. -# -# * Example: see GEOM_Spanner.py -# +""" + * Create a quadrangle face from four edges. Order of Edges is not + * important. It is not necessary that edges share the same vertex. + * \param E1,E2,E3,E4 Edges for the face bound. + * \return New GEOM_Object, containing the created face. + + * Example: see GEOM_Spanner.py +""" def MakeQuad(E1, E2, E3, E4): anObj = BlocksOp.MakeQuad(E1, E2, E3, E4) if BlocksOp.IsDone() == 0: print "MakeQuad : ", BlocksOp.GetErrorCode() return anObj -# * Create a quadrangle face on two edges. -# * The missing edges will be built by creating the shortest ones. -# * \param E1,E2 Two opposite edges for the face. -# * \return New GEOM_Object, containing the created face. -# -# * Example: see GEOM_Spanner.py -# +""" + * Create a quadrangle face on two edges. + * The missing edges will be built by creating the shortest ones. + * \param E1,E2 Two opposite edges for the face. + * \return New GEOM_Object, containing the created face. + + * Example: see GEOM_Spanner.py +""" def MakeQuad2Edges(E1, E2): anObj = BlocksOp.MakeQuad2Edges(E1, E2) if BlocksOp.IsDone() == 0: print "MakeQuad2Edges : ", BlocksOp.GetErrorCode() return anObj -# * Create a quadrangle face with specified corners. -# * The missing edges will be built by creating the shortest ones. -# * \param V1,V2,V3,V4 Corner vertices for the face. -# * \return New GEOM_Object, containing the created face. -# -# * Example: see GEOM_Spanner.py -# +""" + * Create a quadrangle face with specified corners. + * The missing edges will be built by creating the shortest ones. + * \param V1,V2,V3,V4 Corner vertices for the face. + * \return New GEOM_Object, containing the created face. + + * Example: see GEOM_Spanner.py +""" def MakeQuad4Vertices(V1, V2, V3, V4): anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4) if BlocksOp.IsDone() == 0: print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode() return anObj -# * Create a hexahedral solid, bounded by the six given faces. Order of -# * faces is not important. It is not necessary that Faces share the same edge. -# * \param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid. -# * \return New GEOM_Object, containing the created solid. -# -# * Example: see GEOM_Spanner.py -# +""" + * Create a hexahedral solid, bounded by the six given faces. Order of + * faces is not important. It is not necessary that Faces share the same edge. + * \param F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid. + * \return New GEOM_Object, containing the created solid. + + * Example: see GEOM_Spanner.py +""" def MakeHexa(F1, F2, F3, F4, F5, F6): anObj = BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6) if BlocksOp.IsDone() == 0: print "MakeHexa : ", BlocksOp.GetErrorCode() return anObj -# * Create a hexahedral solid between two given faces. -# * The missing faces will be built by creating the smallest ones. -# * \param F1,F2 Two opposite faces for the hexahedral solid. -# * \return New GEOM_Object, containing the created solid. -# -# * Example: see GEOM_Spanner.py -# +""" + * Create a hexahedral solid between two given faces. + * The missing faces will be built by creating the smallest ones. + * \param F1,F2 Two opposite faces for the hexahedral solid. + * \return New GEOM_Object, containing the created solid. + + * Example: see GEOM_Spanner.py +""" def MakeHexa2Faces(F1, F2): anObj = BlocksOp.MakeHexa2Faces(F1, F2) if BlocksOp.IsDone() == 0: print "MakeHexa2Faces : ", BlocksOp.GetErrorCode() return anObj -# * Multi-transformate block and glue the result. -# * Transformation is defined so, as to superpose direction faces. -# * \param Block Hexahedral solid to be multi-transformed. -# * \param DirFace1 ID of First direction face. -# * \param DirFace2 ID of Second direction face. -# * \param NbTimes Quantity of transformations to be done. -# * \note Unique ID of sub-shape can be obtained, using method GetSubShapeID(). -# * \return New GEOM_Object, containing the result shape. -# -# * Example: see GEOM_Spanner.py -# -def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes): - anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes) +""" + * Get a vertex, found in the given shape by its coordinates. + * \param theShape Block or a compound of blocks. + * \param theX,theY,theZ Coordinates of the sought vertex. + * \param theEpsilon Maximum allowed distance between the resulting + * vertex and point with the given coordinates. + * \return New GEOM_Object, containing the found vertex. + + * Example: see GEOM_TestOthers.py +""" +def GetPoint(theShape, theX, theY, theZ, theEpsilon): + anObj = BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon) if BlocksOp.IsDone() == 0: - print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode() + print "GetPoint : ", BlocksOp.GetErrorCode() return anObj -# * Multi-transformate block and glue the result. -# * \param Block Hexahedral solid to be multi-transformed. -# * \param DirFace1U,DirFace2U IDs of Direction faces for the first transformation. -# * \param DirFace1V,DirFace2V IDs of Direction faces for the second transformation. -# * \param NbTimesU,NbTimesV Quantity of transformations to be done. -# * \return New GEOM_Object, containing the result shape. -# -# * Example: see GEOM_Spanner.py -# -def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU, - DirFace1V, DirFace2V, NbTimesV): - anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU, - DirFace1V, DirFace2V, NbTimesV) +""" + * Get an edge, found in the given shape by two given vertices. + * \param theShape Block or a compound of blocks. + * \param thePoint1,thePoint2 Points, close to the ends of the desired edge. + * \return New GEOM_Object, containing the found edge. + + * Example: see GEOM_Spanner.py +""" +def GetEdge(theShape, thePoint1, thePoint2): + anObj = BlocksOp.GetEdge(theShape, thePoint1, thePoint2) if BlocksOp.IsDone() == 0: - print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode() + print "GetEdge : ", BlocksOp.GetErrorCode() return anObj -# * Get all the blocks, contained in the given compound. -# * \param theCompound The compound to explode. -# * \param theMinNbFaces If solid has lower number of faces, it is not a block. -# * \param theMaxNbFaces If solid has higher number of faces, it is not a block. -# * \note If theMaxNbFaces = 0, the maximum number of faces is not restricted. -# * \return List of GEOM_Objects, containing the retrieved blocks. -# -# * Example: see GEOM_TestOthers.py -# -def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces): - aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces) +""" + * Find an edge of the given shape, which has minimal distance to the given point. + * \param theShape Block or a compound of blocks. + * \param thePoint Point, close to the desired edge. + * \return New GEOM_Object, containing the found edge. + + * Example: see GEOM_TestOthers.py +""" +def GetEdgeNearPoint(theShape, thePoint): + anObj = BlocksOp.GetEdgeNearPoint(theShape, thePoint) if BlocksOp.IsDone() == 0: - print "MakeBlockExplode : ", BlocksOp.GetErrorCode() - return aList + print "GetEdgeNearPoint : ", BlocksOp.GetErrorCode() + return anObj -# * Check, if the compound of blocks is given. -# * To be considered as a compound of blocks, the -# * given shape must satisfy the following conditions: -# * - Each element of the compound should be a Block (6 faces and 12 edges). -# * - A connection between two Blocks should be an entire quadrangle face or an entire edge. -# * - The compound should be connexe. -# * - The glue between two quadrangle faces should be applied. -# * \param theCompound The compound to check. -# * \return TRUE, if the given shape is a compound of blocks. -# * If theCompound is not valid, prints all discovered errors. -# -# * Example: see GEOM_TestOthers.py -# +""" + * Returns a face, found in the given shape by four given corner vertices. + * \param theShape Block or a compound of blocks. + * \param thePoint1-thePoint4 Points, close to the corners of the desired face. + * \return New GEOM_Object, containing the found face. + + * Example: see GEOM_Spanner.py +""" +def GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4): + anObj = BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4) + if BlocksOp.IsDone() == 0: + print "GetFaceByPoints : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Get a face of block, found in the given shape by two given edges. + * \param theShape Block or a compound of blocks. + * \param theEdge1,theEdge2 Edges, close to the edges of the desired face. + * \return New GEOM_Object, containing the found face. + + * Example: see GEOM_Spanner.py +""" +def GetFaceByEdges(theShape, theEdge1, theEdge2): + anObj = BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2) + if BlocksOp.IsDone() == 0: + print "GetFaceByEdges : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Find a face, opposite to the given one in the given block. + * \param theBlock Must be a hexahedral solid. + * \param theFace Face of \a theBlock, opposite to the desired face. + * \return New GEOM_Object, containing the found face. + + * Example: see GEOM_Spanner.py +""" +def GetOppositeFace(theBlock, theFace): + anObj = BlocksOp.GetOppositeFace(theBlock, theFace) + if BlocksOp.IsDone() == 0: + print "GetOppositeFace : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Find a face of the given shape, which has minimal distance to the given point. + * \param theShape Block or a compound of blocks. + * \param thePoint Point, close to the desired face. + * \return New GEOM_Object, containing the found face. + + * Example: see GEOM_Spanner.py +""" +def GetFaceNearPoint(theShape, thePoint): + anObj = BlocksOp.GetFaceNearPoint(theShape, thePoint) + if BlocksOp.IsDone() == 0: + print "GetFaceNearPoint : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Find a face of block, whose outside normale has minimal angle with the given vector. + * \param theShape Block or a compound of blocks. + * \param theVector Vector, close to the normale of the desired face. + * \return New GEOM_Object, containing the found face. + + * Example: see GEOM_Spanner.py +""" +def GetFaceByNormale(theBlock, theVector): + anObj = BlocksOp.GetFaceByNormale(theBlock, theVector) + if BlocksOp.IsDone() == 0: + print "GetFaceByNormale : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Check, if the compound of blocks is given. + * To be considered as a compound of blocks, the + * given shape must satisfy the following conditions: + * - Each element of the compound should be a Block (6 faces and 12 edges). + * - A connection between two Blocks should be an entire quadrangle face or an entire edge. + * - The compound should be connexe. + * - The glue between two quadrangle faces should be applied. + * \param theCompound The compound to check. + * \return TRUE, if the given shape is a compound of blocks. + * If theCompound is not valid, prints all discovered errors. + + * Example: see GEOM_Spanner.py +""" def CheckCompoundOfBlocks(theCompound): (IsValid, BCErrors) = BlocksOp.CheckCompoundOfBlocks(theCompound) if BlocksOp.IsDone() == 0: @@ -1721,60 +2105,230 @@ def CheckCompoundOfBlocks(theCompound): print Descr return IsValid +""" + * Remove all seam and degenerated edges from \a theShape. + * Unite faces and edges, sharing one surface. + * \param theShape The compound or single solid to remove irregular edges from. + * \return Improved shape. + + * Example: see GEOM_TestOthers.py +""" +def RemoveExtraEdges(theShape): + anObj = BlocksOp.RemoveExtraEdges(theShape) + if BlocksOp.IsDone() == 0: + print "RemoveExtraEdges : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Check, if the given shape is a blocks compound. + * Fix all detected errors. + * \note Single block can be also fixed by this method. + * \param theCompound The compound to check and improve. + * \return Improved compound. + + * Example: see GEOM_TestOthers.py +""" +def CheckAndImprove(theShape): + anObj = BlocksOp.CheckAndImprove(theShape) + if BlocksOp.IsDone() == 0: + print "CheckAndImprove : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Get all the blocks, contained in the given compound. + * \param theCompound The compound to explode. + * \param theMinNbFaces If solid has lower number of faces, it is not a block. + * \param theMaxNbFaces If solid has higher number of faces, it is not a block. + * \note If theMaxNbFaces = 0, the maximum number of faces is not restricted. + * \return List of GEOM_Objects, containing the retrieved blocks. + + * Example: see GEOM_TestOthers.py +""" +def MakeBlockExplode(theCompound, theMinNbFaces, theMaxNbFaces): + aList = BlocksOp.ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces) + if BlocksOp.IsDone() == 0: + print "MakeBlockExplode : ", BlocksOp.GetErrorCode() + return aList + +""" + * Find block, containing the given point inside its volume or on boundary. + * \param theCompound Compound, to find block in. + * \param thePoint Point, close to the desired block. If the point lays on + * boundary between some blocks, we return block with nearest center. + * \return New GEOM_Object, containing the found block. + + * Example: see GEOM_Spanner.py +""" +def GetBlockNearPoint(theCompound, thePoint): + anObj = BlocksOp.GetBlockNearPoint(theCompound, thePoint) + if BlocksOp.IsDone() == 0: + print "GetBlockNearPoint : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Find block, containing all the elements, passed as the parts, or maximum quantity of them. + * \param theCompound Compound, to find block in. + * \param theParts List of faces and/or edges and/or vertices to be parts of the found block. + * \return New GEOM_Object, containing the found block. + + * Example: see GEOM_TestOthers.py +""" +def GetBlockByParts(theCompound, theParts): + anObj = BlocksOp.GetBlockByParts(theCompound, theParts) + if BlocksOp.IsDone() == 0: + print "GetBlockByParts : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Return all blocks, containing all the elements, passed as the parts. + * \param theCompound Compound, to find blocks in. + * \param theParts List of faces and/or edges and/or vertices to be parts of the found blocks. + * \return List of GEOM_Objects, containing the found blocks. + + * Example: see GEOM_Spanner.py +""" +def GetBlocksByParts(theCompound, theParts): + aList = BlocksOp.GetBlocksByParts(theCompound, theParts) + if BlocksOp.IsDone() == 0: + print "GetBlocksByParts : ", BlocksOp.GetErrorCode() + return aList + +""" + * Multi-transformate block and glue the result. + * Transformation is defined so, as to superpose direction faces. + * \param Block Hexahedral solid to be multi-transformed. + * \param DirFace1 ID of First direction face. + * \param DirFace2 ID of Second direction face. + * \param NbTimes Quantity of transformations to be done. + * \note Unique ID of sub-shape can be obtained, using method GetSubShapeID(). + * \return New GEOM_Object, containing the result shape. + + * Example: see GEOM_Spanner.py +""" +def MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes): + anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes) + if BlocksOp.IsDone() == 0: + print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Multi-transformate block and glue the result. + * \param Block Hexahedral solid to be multi-transformed. + * \param DirFace1U,DirFace2U IDs of Direction faces for the first transformation. + * \param DirFace1V,DirFace2V IDs of Direction faces for the second transformation. + * \param NbTimesU,NbTimesV Quantity of transformations to be done. + * \return New GEOM_Object, containing the result shape. + + * Example: see GEOM_Spanner.py +""" +def MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU, + DirFace1V, DirFace2V, NbTimesV): + anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFace1U, DirFace2U, NbTimesU, + DirFace1V, DirFace2V, NbTimesV) + if BlocksOp.IsDone() == 0: + print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode() + return anObj + +""" + * Build all possible propagation groups. + * Propagation group is a set of all edges, opposite to one (main) + * edge of this group directly or through other opposite edges. + * Notion of Opposite Edge make sence only on quadrangle face. + * \param theShape Shape to build propagation groups on. + * \return List of GEOM_Objects, each of them is a propagation group. + + * Example: see GEOM_TestOthers.py +""" +def Propagate(theShape): + listChains = BlocksOp.Propagate(theShape) + if BlocksOp.IsDone() == 0: + print "Propagate : ", BlocksOp.GetErrorCode() + return listChains + # ----------------------------------------------------------------------------- # Group operations # ----------------------------------------------------------------------------- -# * Creates a new group which will store sub shapes of theMainShape -# * \param theMainShape is a GEOM object on which the group is selected -# * \param theShapeType defines a shape type of the group -# * \return a newly created GEOM group -# -# * Example: see GEOM_TestOthers.py -# +""" + * Creates a new group which will store sub shapes of theMainShape + * \param theMainShape is a GEOM object on which the group is selected + * \param theShapeType defines a shape type of the group + * \return a newly created GEOM group + + * Example: see GEOM_TestOthers.py +""" def CreateGroup(theMainShape, theShapeType): anObj = GroupOp.CreateGroup(theMainShape, theShapeType) if GroupOp.IsDone() == 0: print "CreateGroup : ", GroupOp.GetErrorCode() return anObj -# * Adds a sub object with ID theSubShapeId to the group -# * \param theGroup is a GEOM group to which the new sub shape is added -# * \param theSubShapeID is a sub shape ID in the main object. -# * \note Use method GetSubShapeID() to get an unique ID of the sub shape -# -# * Example: see GEOM_TestOthers.py -# +""" + * Adds a sub object with ID theSubShapeId to the group + * \param theGroup is a GEOM group to which the new sub shape is added + * \param theSubShapeID is a sub shape ID in the main object. + * \note Use method GetSubShapeID() to get an unique ID of the sub shape + + * Example: see GEOM_TestOthers.py +""" def AddObject(theGroup, theSubShapeID): GroupOp.AddObject(theGroup, theSubShapeID) if GroupOp.IsDone() == 0: print "AddObject : ", GroupOp.GetErrorCode() -# * Removes a sub object with ID \a theSubShapeId from the group -# * \param theGroup is a GEOM group from which the new sub shape is removed -# * \param theSubShapeID is a sub shape ID in the main object. -# * \note Use method GetSubShapeID() to get an unique ID of the sub shape -# -# * Example: see GEOM_TestOthers.py -# +""" + * Removes a sub object with ID \a theSubShapeId from the group + * \param theGroup is a GEOM group from which the new sub shape is removed + * \param theSubShapeID is a sub shape ID in the main object. + * \note Use method GetSubShapeID() to get an unique ID of the sub shape + + * Example: see GEOM_TestOthers.py +""" def RemoveObject(theGroup, theSubShapeID): GroupOp.RemoveObject(theGroup, theSubShapeID) if GroupOp.IsDone() == 0: print "RemoveObject : ", GroupOp.GetErrorCode() -# * Returns a list of sub objects ID stored in the group -# * \param theGroup is a GEOM group for which a list of IDs is requested -# -# * Example: see GEOM_TestOthers.py -# +""" + * Returns a list of sub objects ID stored in the group + * \param theGroup is a GEOM group for which a list of IDs is requested + + * Example: see GEOM_TestOthers.py +""" def GetObjectIDs(theGroup): ListIDs = GroupOp.GetObjects(theGroup) if GroupOp.IsDone() == 0: print "GetObjectIDs : ", GroupOp.GetErrorCode() return ListIDs -# Add Path to the system path -# +""" + * Returns a type of sub objects stored in the group + * \param theGroup is a GEOM group which type is returned. + + * Example: see GEOM_TestOthers.py +""" +def GetType(theGroup): + aType = GroupOp.GetType(theGroup) + if GroupOp.IsDone() == 0: + print "GetType : ", GroupOp.GetErrorCode() + return aType + +""" + * Returns a main shape associated with the group + * \param theGroup is a GEOM group for which a main shape object is requested + * \return a GEOM object which is a main shape for theGroup + + * Example: see GEOM_TestOthers.py +""" +def GetMainShape(theGroup): + anObj = GroupOp.GetMainShape(theGroup) + if GroupOp.IsDone() == 0: + print "GetMainShape : ", GroupOp.GetErrorCode() + return anObj + +""" + * Add Path to the system path +""" def addPath(Path): if (sys.path.count(Path) < 1): sys.path.append(Path) diff --git a/src/MeasureGUI/Makefile.in b/src/MeasureGUI/Makefile.in index dd2706fd9..10c55309d 100644 --- a/src/MeasureGUI/Makefile.in +++ b/src/MeasureGUI/Makefile.in @@ -56,6 +56,7 @@ LIB_SRC = MeasureGUI.cxx \ MeasureGUI_MaxToleranceDlg.cxx \ MeasureGUI_WhatisDlg.cxx \ MeasureGUI_CheckShapeDlg.cxx \ + MeasureGUI_CheckCompoundOfBlocksDlg.cxx \ MeasureGUI_PointDlg.cxx LIB_MOC = \ @@ -74,6 +75,7 @@ LIB_MOC = \ MeasureGUI_MaxToleranceDlg.h \ MeasureGUI_WhatisDlg.h \ MeasureGUI_CheckShapeDlg.h \ + MeasureGUI_CheckCompoundOfBlocksDlg.h \ MeasureGUI_PointDlg.h LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl diff --git a/src/MeasureGUI/MeasureGUI.cxx b/src/MeasureGUI/MeasureGUI.cxx index 2eb28d73e..0fb757c6f 100644 --- a/src/MeasureGUI/MeasureGUI.cxx +++ b/src/MeasureGUI/MeasureGUI.cxx @@ -39,6 +39,7 @@ #include "MeasureGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE #include "MeasureGUI_WhatisDlg.h" // Method WHATIS #include "MeasureGUI_CheckShapeDlg.h" // Method CHECKSHAPE +#include "MeasureGUI_CheckCompoundOfBlocksDlg.h" // Method CHECKCOMPOUND #include "MeasureGUI_PointDlg.h" // Method POINTCOORDINATES MeasureGUI* MeasureGUI::myGUIObject = 0; @@ -87,15 +88,16 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, QAD_Desktop* parent ) switch ( theCommandID ) { - case 701 : new MeasureGUI_PropertiesDlg ( parent, Sel ); break; // LENGTH, AREA AND VOLUME - case 702 : new MeasureGUI_CenterMassDlg ( parent, Sel ); break; // CENTER MASS - case 703 : new MeasureGUI_InertiaDlg ( parent, Sel ); break; // INERTIA - case 7041: new MeasureGUI_BndBoxDlg ( parent, Sel ); break; // BOUNDING BOX - case 7042: new MeasureGUI_DistanceDlg ( parent, Sel ); break; // MIN DISTANCE - case 705 : new MeasureGUI_MaxToleranceDlg( parent, Sel ); break; // MAXTOLERANCE - case 706 : new MeasureGUI_WhatisDlg ( parent, Sel ); break; // WHATIS - case 707 : new MeasureGUI_CheckShapeDlg ( parent, Sel ); break; // CHECKSHAPE - case 708 : new MeasureGUI_PointDlg ( parent, Sel ); break; // POINT COORDINATES + case 701 : new MeasureGUI_PropertiesDlg ( parent, Sel ); break; // LENGTH, AREA AND VOLUME + case 702 : new MeasureGUI_CenterMassDlg ( parent, Sel ); break; // CENTER MASS + case 703 : new MeasureGUI_InertiaDlg ( parent, Sel ); break; // INERTIA + case 7041 : new MeasureGUI_BndBoxDlg ( parent, Sel ); break; // BOUNDING BOX + case 7042 : new MeasureGUI_DistanceDlg ( parent, Sel ); break; // MIN DISTANCE + case 705 : new MeasureGUI_MaxToleranceDlg( parent, Sel ); break; // MAXTOLERANCE + case 706 : new MeasureGUI_WhatisDlg ( parent, Sel ); break; // WHATIS + case 707 : new MeasureGUI_CheckShapeDlg ( parent, Sel ); break; // CHECKSHAPE + case 7072 : new MeasureGUI_CheckCompoundOfBlocksDlg ( parent, Sel ); break; // CHECKCOMPOUND + case 708 : new MeasureGUI_PointDlg ( parent, Sel ); break; // POINT COORDINATES default: parent->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; } diff --git a/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx b/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx new file mode 100644 index 000000000..b2b8cdf33 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx @@ -0,0 +1,369 @@ +// GEOM GEOMGUI : GUI for Geometry 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 : MeasureGUI_CheckCompoundOfBlocksDlg.cxx +// Author : VKN +// Module : GEOM +// $Header$ + +#include "MeasureGUI_CheckCompoundOfBlocksDlg.h" +#include "MeasureGUI_1Sel1TextView_QTD.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include "utilities.h" +#include "QAD_Desktop.h" +#include +#include +#include "GEOMBase.h" +#include "GEOMImpl_Types.hxx" + +#include +#include +#include +#include +#include +#include +// QT Includes +#include +#include +#include + +//VRV: porting on Qt 3.0.5 +#if QT_VERSION >= 0x030005 +#include +#endif +//VRV: porting on Qt 3.0.5 + +#define TEXTEDIT_FONT_FAMILY "Courier" +#define TEXTEDIT_FONT_SIZE 11 + +//================================================================================= +// class : MeasureGUI_CheckCompoundOfBlocksDlg() +// purpose : Constructs a MeasureGUI_CheckCompoundOfBlocksDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +MeasureGUI_CheckCompoundOfBlocksDlg::MeasureGUI_CheckCompoundOfBlocksDlg( QWidget* parent, SALOME_Selection* Sel ) +: MeasureGUI_Skeleton( parent, "MeasureGUI_CheckCompoundOfBlocksDlg", Sel ) +{ + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_DLG_CHECK_COMPOUND_OF_BLOCKS" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_SELECT" ) ) ); + + setCaption( tr( "GEOM_CHECK_BLOCKS_COMPOUND" ) ); + + /***************************************************************/ + + GroupConstructors->setTitle( tr( "GEOM_CHECK_BLOCKS_COMPOUND" ) ); + RadioButton1->setPixmap( image0 ); + + myGrp = new MeasureGUI_1Sel1TextView_QTD( this, "myGrp" ); + myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) ); + myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); + myGrp->TextEdit1->setReadOnly( TRUE ); + + QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE ); + aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias ); + myGrp->TextEdit1->setFont( aFont ); + myGrp->PushButton1->setPixmap( image1 ); + myGrp->LineEdit1->setReadOnly( true ); + + + /***************************************************************/ + QGridLayout* aGBLayout = new QGridLayout( myGrp->GroupBox1->layout() ); + aGBLayout->setAlignment( Qt::AlignTop ); + QGridLayout* Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + myErrorsLbl = new QLabel( tr( "GEOM_CHECK_BLOCKS_COMPOUND_ERRORS" ), myGrp, "Errors" ); + Layout2->addWidget( myErrorsLbl, 0, 0 ); + + myErrorsLBox = new QListBox( myGrp, "ListBlockCompoundErrors" ); + myErrorsLBox->setMinimumSize( 100, 100 ); + Layout2->addWidget( myErrorsLBox, 1, 0 ); + + + mySubShapesLbl = new QLabel( tr( "GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES" ), myGrp, "BlockCompoundSubShapes" ); + Layout2->addWidget( mySubShapesLbl, 0, 1 ); + + mySubShapesLBox = new QListBox( myGrp, "ListSubShapes" ); + mySubShapesLBox->setMinimumSize( 100, 100 ); + mySubShapesLBox->setSelectionMode(QListBox::Extended); + Layout2->addWidget( mySubShapesLBox, 1, 1 ); + aGBLayout->addLayout( Layout2, 1, 0 ); + + Layout1->addWidget( myGrp, 1, 0 ); + connect( myErrorsLBox, SIGNAL( selectionChanged() ), SLOT( onErrorsListSelectionChanged() ) ); + connect( mySubShapesLBox, SIGNAL( selectionChanged() ), SLOT( onSubShapesListSelectionChanged() ) ); + /* Initialisation */ + Init( Sel ); +} + + +//================================================================================= +// function : ~MeasureGUI_CheckCompoundOfBlocksDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_CheckCompoundOfBlocksDlg::~MeasureGUI_CheckCompoundOfBlocksDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_CheckCompoundOfBlocksDlg::Init( SALOME_Selection* Sel ) +{ + activateSelection(); + mySelBtn = myGrp->PushButton1; + mySelEdit = myGrp->LineEdit1; + MeasureGUI_Skeleton::Init( Sel ); +} + +//================================================================================= +// function : getBCErrors +// purpose : +//================================================================================= +bool MeasureGUI_CheckCompoundOfBlocksDlg::getBCErrors( bool& theIsCompoundOfBlocks, + GEOM::GEOM_IBlocksOperations::BCErrors& theErrors) +{ + if ( myObj->_is_nil() ) + return false; + else + { + try + { + GEOM::GEOM_IBlocksOperations::BCErrors_var aErrs; + theIsCompoundOfBlocks = + GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->CheckCompoundOfBlocks( myObj, aErrs ); + theErrors = aErrs; + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + return false; + } + + return getOperation()->IsDone(); + } +} + +//================================================================================= +// function : processObject +// purpose : +//================================================================================= +void MeasureGUI_CheckCompoundOfBlocksDlg::processObject() +{ + QString aMsg (""); + bool isCompoundOfBlocks; + GEOM::GEOM_IBlocksOperations::BCErrors aErrs; + if ( !getBCErrors( isCompoundOfBlocks, aErrs ) ) + { + myGrp->TextEdit1->setText( aMsg ); + myErrorsLBox->clear(); + mySubShapesLBox->clear(); + erasePreview(); + return; + } + + if (isCompoundOfBlocks) { + aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_HAS_NO_ERRORS" ); + } else { + aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_HAS_ERRORS" ); + } + myGrp->TextEdit1->setText(aMsg); + QStringList aErrList; + QString aErrStr( "" ); + QString aConSfx( " # " ); + QString aGluedSfx( " # " ); + int aConNum = 1; + int aGluedNum = 1; + for ( int i = 0, n = aErrs.length(); i < n; i++ ) + { + aErrStr = ""; + switch ( aErrs[i].error ) + { + case GEOM::GEOM_IBlocksOperations::NOT_BLOCK : + aErrStr = "Not a Block"; + break; + case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE : + aErrStr = "Extra Edge"; + break; + case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION : + aErrStr = "Invalid Connection"; + aErrStr += aConSfx; + aErrStr += QString::number(aConNum); + aConNum++; + break; + case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED : + aErrStr = "Not Connected"; + break; + case GEOM::GEOM_IBlocksOperations::NOT_GLUED : + aErrStr = "Not Glued"; + aErrStr += aGluedSfx; + aErrStr += QString::number(aGluedNum); + aGluedNum++; + break; + default : + aErrStr = ""; + break; + } + if ( !aErrStr.isEmpty() ) + aErrList.append(aErrStr); + } + myErrorsLBox->clear(); + mySubShapesLBox->clear(); + myErrorsLBox->insertStringList(aErrList); + return; +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr MeasureGUI_CheckCompoundOfBlocksDlg::createOperation() +{ + return getGeomEngine()->GetIBlocksOperations(getStudyId()); +} + +//================================================================================= +// function : onErrorsListSelectionChanged +// purpose : +//================================================================================= +void MeasureGUI_CheckCompoundOfBlocksDlg::onErrorsListSelectionChanged() +{ + erasePreview(); + int aCurItem = myErrorsLBox->currentItem(); + if ( aCurItem < 0 ) + return; + bool isCompoundOfBlocks; + GEOM::GEOM_IBlocksOperations::BCErrors aErrs; + if ( !getBCErrors( isCompoundOfBlocks, aErrs ) ) + { + myGrp->TextEdit1->setText( "" ); + myErrorsLBox->clear(); + mySubShapesLBox->clear(); + return; + } + + GEOM::GEOM_IBlocksOperations::BCError aErr = aErrs[aCurItem]; + GEOM::ListOfLong aObjLst = aErr.incriminated; + TopoDS_Shape aSelShape; + TopoDS_Shape aSubShape; + TopTools_IndexedMapOfShape anIndices; + QStringList aSubShapeList; + QString aSubShapeName(""); + Standard_CString aTypeString; + if ( !myObj->_is_nil() && GEOMBase::GetShape( myObj, aSelShape ) ) + { + TopExp::MapShapes( aSelShape, anIndices); + for ( int i = 0, n = aObjLst.length(); i < n; i++ ) + { + aSubShapeName = ""; + aSubShape = anIndices.FindKey(aObjLst[i]); + if ( GEOMBase::GetShapeTypeString( aSubShape, aTypeString ) ) + aSubShapeName = QString(aTypeString) + QString("_") + QString::number(aObjLst[i]); + if ( !aSubShapeName.isEmpty() ) + aSubShapeList.append(aSubShapeName); + } + } + mySubShapesLBox->clear(); + mySubShapesLBox->insertStringList(aSubShapeList); + return; +} + +//================================================================================= +// function : onSubShapesListSelectionChanged +// purpose : +//================================================================================= +void MeasureGUI_CheckCompoundOfBlocksDlg::onSubShapesListSelectionChanged() +{ + erasePreview(); + int aErrCurItem = myErrorsLBox->currentItem(); + if ( aErrCurItem < 0 ) + return; + QValueList aIds; + for ( int i = 0, n = mySubShapesLBox->count(); i < n; i++ ) + { + if ( mySubShapesLBox->isSelected( i ) ) + aIds.append( i ); + } + if ( aIds.count() < 1 ) + return; + bool isCompoundOfBlocks; + GEOM::GEOM_IBlocksOperations::BCErrors aErrs; + if ( !getBCErrors( isCompoundOfBlocks, aErrs ) ) + { + myGrp->TextEdit1->setText( "" ); + myErrorsLBox->clear(); + mySubShapesLBox->clear(); + return; + } + + GEOM::GEOM_IBlocksOperations::BCError aErr = aErrs[aErrCurItem]; + GEOM::ListOfLong aObjLst = aErr.incriminated; + TopoDS_Shape aSelShape; + TopoDS_Shape aSubShape; + TopTools_IndexedMapOfShape anIndices; + if ( !myObj->_is_nil() && GEOMBase::GetShape( myObj, aSelShape ) ) + { + QString aMess; + if ( !isValid( aMess ) ) + { + return; + } + SALOME_Prs* aPrs = 0; + TopExp::MapShapes( aSelShape, anIndices); + QValueList::iterator it; + for ( it = aIds.begin(); it != aIds.end(); ++it ) + { + aSubShape = anIndices.FindKey(aObjLst[(*it)]); + try + { + getDisplayer()->SetColor( Quantity_NOC_RED ); + getDisplayer()->SetToActivate( false ); + aPrs = !aSubShape.IsNull() ? getDisplayer()->BuildPrs( aSubShape ) : 0; + if ( aPrs ) + displayPreview( aPrs, true ); + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + } + } + } + return; +} + +//================================================================================= +// function : activateSelection +// purpose : activate selection of faces, shells, and solids +//================================================================================= +void MeasureGUI_CheckCompoundOfBlocksDlg::activateSelection() +{ + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_SOLID ); + aMap.Add( GEOM_COMPOUND ); + globalSelection( aMap ); +} diff --git a/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.h b/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.h new file mode 100644 index 000000000..b961bf88c --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.h @@ -0,0 +1,78 @@ +// GEOM GEOMGUI : GUI for Geometry 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 : MeasureGUI_CheckCompoundOfBlocksDlg.h +// Author : VKN +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_CHECKCOMPOUNDOFBLOCKSDLG_H +#define DIALOGBOX_CHECKCOMPOUNDOFBLOCKSDLG_H + +#include "MeasureGUI_Skeleton.h" + +class MeasureGUI_1Sel1TextView_QTD; +class QListBox; +class QLabel; + +//================================================================================= +// class : MeasureGUI_CheckCompoundOfBlocksDlg +// purpose : +//================================================================================= +class MeasureGUI_CheckCompoundOfBlocksDlg : public MeasureGUI_Skeleton +{ + Q_OBJECT + +public: + MeasureGUI_CheckCompoundOfBlocksDlg( QWidget* theParent, + SALOME_Selection* theSel ); + ~MeasureGUI_CheckCompoundOfBlocksDlg(); +protected: + + // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual void processObject(); + +private slots: + + void onErrorsListSelectionChanged(); + void onSubShapesListSelectionChanged(); + +private: + + void Init( SALOME_Selection* theSel ); + bool getBCErrors( bool& theIsCompoundOfBlocks, + GEOM::GEOM_IBlocksOperations::BCErrors& theErrors); + void activateSelection(); + +private: + + MeasureGUI_1Sel1TextView_QTD* myGrp; + QLabel* myErrorsLbl; + QListBox* myErrorsLBox; + QLabel* mySubShapesLbl; + QListBox* mySubShapesLBox; + +}; + +#endif // DIALOGBOX_CHECKCOMPOUNDOFBLOCKSDLG_H diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.cxx b/src/NMTAlgo/NMTAlgo_Splitter1.cxx index 260ac90ec..36d711377 100644 --- a/src/NMTAlgo/NMTAlgo_Splitter1.cxx +++ b/src/NMTAlgo/NMTAlgo_Splitter1.cxx @@ -285,12 +285,20 @@ // aNbSd=aMSd.Extent(); if (!aNbSd) { + //modified by NIZNHY-PKV Thu Dec 23 15:07:46 2004 f + Standard_Boolean bFound; + //modified by NIZNHY-PKV Thu Dec 23 15:07:49 2004 t TopoDS_Shape aSd; // const TopoDS_Shape& aFC=myImageShape.Image(aS).First(); - NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd); - // - aMSd.Add(aSd); + //modified by NIZNHY-PKV Thu Dec 23 15:08:17 2004 f + //NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd); + //aMSd.Add(aSd); + bFound=NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd); + if (!aSd.IsNull()) { + aMSd.Add(aSd); + } + //modified by NIZNHY-PKV Thu Dec 23 15:09:02 2004 t } aMCS.Add(aS, aMSd); } //for ( ;aItS.More(); aItS.Next()) diff --git a/src/NMTAlgo/NMTAlgo_Splitter_1.cxx b/src/NMTAlgo/NMTAlgo_Splitter_1.cxx index 2c057d7f0..8461a444b 100644 --- a/src/NMTAlgo/NMTAlgo_Splitter_1.cxx +++ b/src/NMTAlgo/NMTAlgo_Splitter_1.cxx @@ -106,7 +106,13 @@ if (myClosedShapes.Contains(aS)) { // // internal faces compound + //modified by NIZNHY-PKV Thu Dec 23 16:34:05 2004 f + Standard_Integer aNbIF; + // + aNbIF=myInternalFaces.Extent(); + //modified by NIZNHY-PKV Thu Dec 23 16:34:07 2004 t TopoDS_Shape aIFC=FindFacesInside(aS, Standard_True); + aNbIF=myInternalFaces.Extent(); aShellMaker.AddSectionFaces(aIFC); } // @@ -248,15 +254,15 @@ // get data for internal faces search // =================================== // - // compound of split faces of theShape - const TopoDS_Shape& CSF = myImageShape.Image(theShape).First(); - // TopTools_MapOfShape MSE, MFP; TopTools_DataMapOfShapeListOfShape DMSEFP; + TopTools_IndexedDataMapOfShapeListOfShape DMEF; TopTools_MapIteratorOfMapOfShape itm; TopTools_ListOfShape EmptyL; TopTools_ListIteratorOfListOfShape itl; - + // + // compound of split faces of theShape + const TopoDS_Shape& CSF=myImageShape.Image(theShape).First(); // MSE filling: map of new section edges of CSF expl.Init(CSF, TopAbs_EDGE); for (; expl.More(); expl.Next()) { @@ -265,7 +271,6 @@ } // // DMEF: map edge of CSF - faces of CSF - TopTools_IndexedDataMapOfShapeListOfShape DMEF; TopExp::MapShapesAndAncestors(CSF, TopAbs_EDGE, TopAbs_FACE, DMEF); // // Fill @@ -302,75 +307,75 @@ } }//for (;itl.More(); itl.Next()) // - // add tool faces... (is absent) - // // =========================== // find faces inside theShape // =========================== Standard_Boolean skipAlreadyAdded = Standard_False; - Standard_Boolean GoodOri, inside; + Standard_Boolean GoodOri, inside, sameDom1, sameDom2, isSectionE; Standard_Real dot; + TopoDS_Face aFace1, anOrigFace, origF1, origF2; //, anOrigFace2; TopTools_ListOfShape KeepFaces; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit; - + // // iterate on section edges, check faces of other shapes // sharing section edges and put internal faces to KeepFaces Mapit.Initialize(DMSEFP); for (; Mapit.More() ; Mapit.Next() ) { // a new edge of theShape const TopoDS_Edge& E = TopoDS::Edge (Mapit.Key()); - // an original edge of which E is a split - //const TopoDS_Edge& OrigE = TopoDS::Edge (myImagesEdges.Root(E)); - // does OrigE itself splits a face - Standard_Boolean isSectionE=IsSectionEdge(E);//(OrigE); - + // + isSectionE=IsSectionEdge(E); + // // split faces of other shapes sharing E TopTools_ListOfShape& LSF = DMSEFP.ChangeFind(E); + // itl.Initialize( LSF ); while (itl.More()) { // a split faces of other shape - TopoDS_Face aFace1 = TopoDS::Face(itl.Value()); + aFace1 = TopoDS::Face(itl.Value()); // remove aFace1 form DMSEFP and MFP LSF.Remove( itl ); // == itl.Next(); if (!MFP.Remove( aFace1 )) continue; // was not is MFP ( i.e already checked) + // // check if aFace1 was already added to 2 shells if (!All && myAddedFacesMap.Contains(aFace1) && myAddedFacesMap.Contains(aFace1.Reversed())) { skipAlreadyAdded = Standard_True; - //modified by NIZNHY-PKV Wed Feb 11 16:11:53 2004 f - //continue; - //modified by NIZNHY-PKV Wed Feb 11 16:35:48 2004 t } // // find another face which originates from the same face as aFace1: // usually aFace2 is internal if aFace1 is not and vice versa - TopoDS_Shape anOrigFace = aFace1; + anOrigFace = aFace1; if (myImagesFaces.IsImage(aFace1)){ - anOrigFace = myImagesFaces.Root(aFace1); + anOrigFace = TopoDS::Face(myImagesFaces.Root(aFace1)); } // - TopoDS_Shape aFace2; - if ( !isSectionE ) { - while (itl.More()) { - aFace2 = itl.Value(); + //modified by NIZNHY-PKV Fri Dec 24 10:59:45 2004 f + /* + TopoDS_Face aFace2; + // + if (!isSectionE) { + while (itl.More()) { //#2 + aFace2 = TopoDS::Face(itl.Value()); // - TopoDS_Shape anOrigFace2 = aFace2; + anOrigFace2 = aFace2; if (myImagesFaces.IsImage(aFace2)) { - anOrigFace2 = myImagesFaces.Root(aFace2); + anOrigFace2 = TopoDS::Face(myImagesFaces.Root(aFace2)); } // if (!MFP.Contains( aFace2 )) { LSF.Remove( itl ); continue; } - //if (anOrigFace.IsSame( myImagesFaces.Root( aFace2 ))) + // if (anOrigFace.IsSame(anOrigFace2)) { break; } itl.Next(); - } + }// while (itl.More()) { #2 + // if (itl.More()) { // aFace2 found, remove it from maps LSF.Remove( itl ); MFP.Remove(aFace2); @@ -379,94 +384,91 @@ aFace2.Nullify(); } itl.Initialize( LSF ); - } - + } // if (!isSectionE) { + */ + //modified by NIZNHY-PKV Fri Dec 24 10:59:52 2004 t + // // check that anOrigFace is not same domain with CSF faces it intersects - - const TopTools_ListOfShape& FL = DMEF.FindFromKey(E); //faces of CSF sharing E - - const TopoDS_Shape& origF1 = myImagesFaces.IsImage(FL.First()) ? - myImagesFaces.Root(FL.First()) : FL.First(); - const TopoDS_Shape& origF2 = myImagesFaces.IsImage(FL.Last()) ? - myImagesFaces.Root(FL.Last()) : FL.Last(); // - Standard_Boolean sameDom1 = anOrigFace.IsSame( origF1 ); - Standard_Boolean sameDom2 = anOrigFace.IsSame( origF2 ); - - if (!(sameDom1 || sameDom2) && HasSameDomainF( TopoDS::Face(anOrigFace) )) { - sameDom1 = IsSameDomainF( TopoDS::Face(anOrigFace), TopoDS::Face(origF1)); + //faces of CSF sharing E + // + const TopTools_ListOfShape& FL = DMEF.FindFromKey(E); + const TopoDS_Face& aFE1=TopoDS::Face(FL.First()); + const TopoDS_Face& aFE2=TopoDS::Face(FL.Last()); + // + origF1=aFE1; + if (myImagesFaces.IsImage(aFE1)) { + origF1=TopoDS::Face(myImagesFaces.Root(aFE1)); + } + origF2=aFE2; + if (myImagesFaces.IsImage(aFE2)) { + origF2=TopoDS::Face(myImagesFaces.Root(aFE2)); + } + // + sameDom1 = anOrigFace.IsSame( origF1 ); + sameDom2 = anOrigFace.IsSame( origF2 ); + // + if (!(sameDom1 || sameDom2) && HasSameDomainF(anOrigFace)) { + sameDom1 = IsSameDomainF(anOrigFace, origF1); if (origF1 == origF2) { sameDom2 = sameDom1; } - else{ - IsSameDomainF( TopoDS::Face(anOrigFace), TopoDS::Face(origF2)); - } } + // if (sameDom1 && sameDom2){ continue; } + // if (sameDom1 || sameDom2) { - inside = NMTAlgo_Loop3d::IsInside (E, - TopoDS::Face(FL.First()), - TopoDS::Face(FL.Last()), - 1, dot, GoodOri); - if (inside || (dot + Precision::Angular() >= 1.0)) + inside = NMTAlgo_Loop3d::IsInside (E, aFE1, aFE2, 1, dot, GoodOri); + if (inside || (dot + Precision::Angular() >= 1.0)) { continue; // E is convex between origF1 and origF2 or they are tangent + } } // - // keep one of found faces - + // Keep one of found faces + // //face of CSF sharing E - const TopoDS_Shape& aShapeFace = sameDom1 ? FL.Last() : FL.First(); + const TopoDS_Face& aShapeFace = sameDom1 ? aFE2 : aFE1; // analyse aFace1 state - inside = NMTAlgo_Loop3d::IsInside (E, TopoDS::Face(aShapeFace), aFace1, - 1, dot, GoodOri); -// if (inside && isSectionE) { + inside = NMTAlgo_Loop3d::IsInside (E, aShapeFace, aFace1, 1, dot, GoodOri); if (inside) { //IFV 27.08.04 // aFace1 must be tested with both adjacent faces of CSF - const TopoDS_Shape& aShapeFace2 = sameDom1 ? FL.First() : FL.Last(); + const TopoDS_Face& aShapeFace2 = sameDom1 ? aFE1 : aFE2; if (aShapeFace2 != aShapeFace){ - inside = NMTAlgo_Loop3d::IsInside (E, TopoDS::Face(aShapeFace2), aFace1, - 1, dot, GoodOri); + inside = + NMTAlgo_Loop3d::IsInside(E, aShapeFace2, aFace1, 1, dot, GoodOri); } } // // store internal face - if (inside) - KeepFaces.Append(aFace1); - + if (inside) { + KeepFaces.Append(aFace1); + } + // + //modified by NIZNHY-PKV Fri Dec 24 11:02:55 2004 f + /* else if (!aFace2.IsNull()) { if (dot + Precision::Angular() >= 1.0) { - // aFace2 state is not clear, it will be analysed alone, - // put it back to the maps - MFP.Add( aFace2 ); - LSF.Append( aFace2 ); + // aFace2 state is not clear, it will be analysed alone, put it back to the maps + MFP.Add(aFace2); + LSF.Append(aFace2); } - else - KeepFaces.Append(aFace2); + else { + KeepFaces.Append(aFace2); + } } - } - } - + */ + //modified by NIZNHY-PKV Fri Dec 24 11:03:03 2004 t + }// while (itl.More()) { + }// for (; Mapit.More() ; Mapit.Next() ) { + // // =================================================== // add not distributed faces connected with KeepFaces // =================================================== - // ultimate list of internal faces TopTools_ListOfShape KeptFaces; // - // add to MFP not split tool faces as well, they may be connected with - // tool faces interfering with theShape - /* - itm.Initialize(myMapTools); - for (; itm.More(); itm.Next() ) { - const TopoDS_Shape& aToolFace = itm.Key(); - if (!myImageShape.HasImage(aToolFace)){ - MFP.Add (aToolFace); - } - } - */ - // if (MFP.IsEmpty()) KeptFaces.Append (KeepFaces); // diff --git a/src/NMTAlgo/NMTAlgo_Splitter_2.cxx b/src/NMTAlgo/NMTAlgo_Splitter_2.cxx index 0c1dc8f04..d50bc6d3d 100644 --- a/src/NMTAlgo/NMTAlgo_Splitter_2.cxx +++ b/src/NMTAlgo/NMTAlgo_Splitter_2.cxx @@ -31,7 +31,7 @@ //======================================================================= //function : KeepShapesInside -//purpose : remove shapes that are outside of S from resul +//purpose : remove shapes that are outside of S from result //======================================================================= void NMTAlgo_Splitter::KeepShapesInside (const TopoDS_Shape& S) { @@ -102,121 +102,150 @@ //======================================================================= //function : RemoveShapesInside -//purpose : remove shapes that are inside S from resul +//purpose : remove shapes that are inside S from result //======================================================================= - void NMTAlgo_Splitter::RemoveShapesInside (const TopoDS_Shape& S) + void NMTAlgo_Splitter::RemoveShapesInside (const TopoDS_Shape& aS) { TopoDS_Iterator it; - if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid - for (it.Initialize( S ); it.More(); it.Next()) - RemoveShapesInside( it.Value()); + TopAbs_ShapeEnum aTypeS; + // + aTypeS=aS.ShapeType(); + if (aTypeS < TopAbs_SOLID) { // compound or compsolid + it.Initialize(aS); + for (; it.More(); it.Next()) { + const TopoDS_Shape& aSx=it.Value(); + RemoveShapesInside(aSx); + } return; } - Standard_Boolean isTool = Standard_False; - if (!myImageShape.HasImage( S )) { - //isTool = CheckTool( S ); - //if (!isTool) return; + // + Standard_Boolean bFromTool, bIsClosed; + Standard_Integer i, aNbE; + TopoDS_Shape aIntFacesComp; + TopoDS_Compound aC; + TopTools_IndexedMapOfShape MIF; // map of internal faces + TopTools_MapOfShape RFM; + TopTools_MapIteratorOfMapOfShape itF; + TopTools_IndexedDataMapOfShapeListOfShape aMEF; + // + bFromTool=myToolShapes.Contains(aS); + // + if (!myImageShape.HasImage(aS)) { + return; + } + // + aIntFacesComp = FindFacesInside(aS, Standard_False, Standard_True); + // + TopExp::MapShapes(aIntFacesComp, TopAbs_FACE, MIF); + if (MIF.IsEmpty()) { return; } - - TopoDS_Shape IntFacesComp = FindFacesInside( S, Standard_False, Standard_True); - TopTools_IndexedMapOfShape MIF; // map of internal faces - TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF); - - if (MIF.IsEmpty()) return; - // add to MIF split faces of S - if (myImageShape.HasImage(S)) - TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MIF); - + const TopoDS_Shape& aSIm=myImageShape.Image(aS).First(); + TopExp::MapShapes(aSIm, TopAbs_FACE, MIF); + // // leave in the result only those shapes not having all face in MIF - - TopoDS_Compound C; - myBuilder.MakeCompound(C); - - // RMF : faces of removed shapes that encounter once - TopTools_MapOfShape RFM; - - for (it.Initialize( myShape ); it.More(); it.Next()) { - - TopExp_Explorer expResF( it.Value(), TopAbs_FACE ); - for (; expResF.More(); expResF.Next()) - if (!MIF.Contains( expResF.Current())) + myBuilder.MakeCompound(aC); + // + // RFM : faces of removed shapes that encounter once + it.Initialize(myShape); + for (; it.More(); it.Next()) { + TopExp_Explorer expResF; + // + const TopoDS_Shape& aSR=it.Value(); + // + expResF.Init(aSR, TopAbs_FACE); + for (; expResF.More(); expResF.Next()) { + const TopoDS_Shape& aFR=expResF.Current(); + if (!MIF.Contains(aFR)) { break; - - if (expResF.More()) + } + } + // + if (expResF.More()) { // add shape to result - myBuilder.Add( C, it.Value() ); - else + myBuilder.Add(aC, aSR); + } + else { // add faces of a removed shape to RFM - for (expResF.ReInit(); expResF.More(); expResF.Next()) { - const TopoDS_Shape& F = expResF.Current(); - if ( ! RFM.Remove ( F )) - RFM.Add( F ); - } + if (!bFromTool) { //modified by NIZNHY-PKV Thu Dec 23 09:55:39 2004 ft + for (expResF.ReInit(); expResF.More(); expResF.Next()) { + const TopoDS_Shape& aF = expResF.Current(); + if (!RFM.Remove(aF)) { + RFM.Add(aF); + } + } + }//modified by NIZNHY-PKV Thu Dec 23 09:55:29 2004 ft + } + }// for (; it.More(); it.Next()) + // + if (bFromTool) { + myShape=aC; + return; } - - if (!isTool) { - - // rebuild S, it must remain in the result - - Standard_Boolean isClosed = Standard_False; - switch (S.ShapeType()) { - case TopAbs_SOLID : - isClosed = Standard_True; break; - case TopAbs_SHELL: { - TopTools_IndexedDataMapOfShapeListOfShape MEF; - TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, MEF); - Standard_Integer i; - for (i=1; isClosed && i<=MEF.Extent(); ++i) - isClosed = ( MEF(i).Extent() != 1 ); - break; + // + // bIsClosed + bIsClosed = Standard_False; + if (aTypeS==TopAbs_SOLID) { + bIsClosed = Standard_True; + } + else if (aTypeS==TopAbs_SHELL) { + aMEF.Clear(); + TopExp::MapShapesAndAncestors(aS, TopAbs_EDGE, TopAbs_FACE, aMEF); + aNbE=aMEF.Extent(); + for (i=1; bIsClosed && i<=aNbE; ++i) { + bIsClosed=(aMEF(i).Extent()!=1); } - default: - isClosed = Standard_False; + } + // + // rebuild S, it must remain in the result + if (bIsClosed) { + // add to a new shape external faces of removed shapes, ie those in RFM + TopoDS_Shell aShell; + // + myBuilder.MakeShell(aShell); + // exclude redundant internal face with edges encounterd only once + aMEF.Clear(); + itF.Initialize (RFM); + for (; itF.More(); itF.Next()) { + const TopoDS_Shape& aF=itF.Key(); + TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF); } - if (isClosed) { - - // add to a new shape external faces of removed shapes, ie those in RFM - - TopoDS_Shell Shell; - myBuilder.MakeShell( Shell ); - - // exclude redundant internal face with edges encounterd only once - TopTools_IndexedDataMapOfShapeListOfShape MEF; - TopTools_MapIteratorOfMapOfShape itF (RFM); - for ( ; itF.More(); itF.Next()) - TopExp::MapShapesAndAncestors(itF.Key(), TopAbs_EDGE, TopAbs_FACE, MEF); - - // add only faces forming a closed shell - for (itF.Reset() ; itF.More(); itF.Next()) - { - TopExp_Explorer expE (itF.Key(), TopAbs_EDGE); - for (; expE.More(); expE.Next()) - if (MEF.FindFromKey(expE.Current()).Extent() == 1) - break; - if (!expE.More()) - myBuilder.Add( Shell, itF.Key()); + // add only faces forming a closed shell + for (itF.Reset() ; itF.More(); itF.Next()) { + const TopoDS_Shape& aF=itF.Key(); + TopExp_Explorer expE (aF, TopAbs_EDGE); + for (; expE.More(); expE.Next()) { + if (aMEF.FindFromKey(expE.Current()).Extent()==1) { + break; + } } - - if (S.ShapeType() == TopAbs_SOLID) { - TopoDS_Solid Solid; - myBuilder.MakeSolid( Solid ); - myBuilder.Add (Solid, Shell); - myBuilder.Add (C, Solid); + if (!expE.More()) { + myBuilder.Add(aShell, aF); } - else - myBuilder.Add (C, Shell); + } + // + if (aTypeS==TopAbs_SOLID) { + TopoDS_Solid aSolid; + // + myBuilder.MakeSolid(aSolid); + myBuilder.Add (aSolid, aShell); + myBuilder.Add (aC, aSolid); } else { - if (myImageShape.HasImage( S )) { - for (it.Initialize( myImageShape.Image(S).First()); it.More(); it.Next()) - myBuilder.Add (C, it.Value()); - } + myBuilder.Add (aC, aShell); + } + } // if (bIsClosed) { + // + else { + it.Initialize(aSIm); + for (; it.More(); it.Next()) { + const TopoDS_Shape& aSx=it.Value(); + myBuilder.Add (aC, aSx); } } - - myShape = C; + // + myShape=aC; } //======================================================================= diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index 459e098a8..db0e73fcd 100644 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -51,7 +51,7 @@ LIB_SRC = GEOM_Actor.cxx \ GEOM_InteractiveObject.cxx \ GEOM_AISTrihedron.cxx \ GEOM_VTKTrihedron.cxx - + LIB_CLIENT_IDL = # Executables targets @@ -60,7 +60,7 @@ BIN_SRC = CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS+=$(QT_MT_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) -lSalomeObject -L${KERNEL_ROOT_DIR}/lib/salome +LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS) $(VTK_LIBS) $(OGL_LIBS) -lSalomeObject -L${KERNEL_ROOT_DIR}/lib/salome %_moc.cxx: %.h $(MOC) $< -o $@ diff --git a/src/RepairGUI/Makefile.in b/src/RepairGUI/Makefile.in index 8bd14a9a5..c9ccb325f 100644 --- a/src/RepairGUI/Makefile.in +++ b/src/RepairGUI/Makefile.in @@ -49,6 +49,7 @@ LIB_SRC = RepairGUI.cxx \ RepairGUI_RemoveHolesDlg.cxx \ RepairGUI_DivideEdgeDlg.cxx \ RepairGUI_FreeBoundDlg.cxx \ + RepairGUI_FreeFacesDlg.cxx \ RepairGUI_GlueDlg.cxx LIB_MOC = \ @@ -60,6 +61,7 @@ LIB_MOC = \ RepairGUI_RemoveHolesDlg.h \ RepairGUI_DivideEdgeDlg.h \ RepairGUI_FreeBoundDlg.h \ + RepairGUI_FreeFacesDlg.h \ RepairGUI_GlueDlg.h LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl diff --git a/src/RepairGUI/RepairGUI.cxx b/src/RepairGUI/RepairGUI.cxx index 5b97e0d78..18bcd8bba 100644 --- a/src/RepairGUI/RepairGUI.cxx +++ b/src/RepairGUI/RepairGUI.cxx @@ -41,6 +41,7 @@ #include "RepairGUI_RemoveIntWiresDlg.h"// Method REMOVE INTERNAL WIRES #include "RepairGUI_DivideEdgeDlg.h" // Method DEVIDE EDGE #include "RepairGUI_FreeBoundDlg.h" // Method FREE BOUNDARIES +#include "RepairGUI_FreeFacesDlg.h" // Method FREE FACES #include "RepairGUI_GlueDlg.h" // Method GLUE FACES #include "utilities.h" @@ -118,6 +119,9 @@ bool RepairGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 609: // FREE BOUNDARIES aDlg = new RepairGUI_FreeBoundDlg( parent, Sel ); break; + case 610: // FREE FACES + aDlg = new RepairGUI_FreeFacesDlg( parent, "", Sel ); + break; default: parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); break; diff --git a/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx b/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx new file mode 100644 index 000000000..54b50e964 --- /dev/null +++ b/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx @@ -0,0 +1,326 @@ +// GEOM GEOMGUI : GUI for Geometry 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 : RepairGUI_FreeFacesDlg.cxx +// Author : VKN +// Module : GEOM +// $Header$ + +using namespace std; +#include "RepairGUI_FreeFacesDlg.h" + +#include "QAD_Desktop.h" +#include "QAD_WaitCursor.h" + +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "GEOMImpl_Types.hxx" +#include +#include +#include "GEOMBase.h" +#include "GeometryGUI.h" +#include "GEOM_Displayer.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "SALOME_Selection.h" +#include "SALOME_Prs.h" + + +#include +#include +#include +#include +#include +#define SPACING 5 +#define MARGIN 10 +#define MIN_WIDTH 200 + + +//================================================================================= +// class : RepairGUI_FreeFacesDlg() +// purpose : Constructs a RepairGUI_FreeFacesDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg(QWidget* parent, const char* name, SALOME_Selection* theSelection, bool modal, WFlags fl) +:QDialog( parent, "RepairGUI_FreeBoundDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + myDisplayer = 0; + + setSizeGripEnabled( TRUE ); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_FREE_FACES_TITLE")); + + /***************************************************************/ + + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_SELECTED_SHAPE" ), this ); + + + QGroupBox* aSelGrp = new QGroupBox( 1, Qt::Vertical, aMainGrp ); + + aSelGrp->setInsideMargin( 0 ); + aSelGrp->setFrameStyle( QFrame::NoFrame ); + new QLabel( tr( "GEOM_OBJECT" ), aSelGrp ); + mySelBtn = new QPushButton( aSelGrp ); + mySelBtn->setPixmap( image1 ); + myEdit = new QLineEdit( aSelGrp ); + myEdit->setReadOnly( true ); + myEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myEdit->setMinimumWidth( MIN_WIDTH ); + + QFrame* aFrame = new QFrame( this ); + aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + QPushButton* aCloseBtn = new QPushButton( tr( "GEOM_BUT_CLOSE" ), aFrame ); + QHBoxLayout* aBtnLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + aBtnLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aBtnLay->addWidget( aCloseBtn ); + aBtnLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + + QVBoxLayout* aLay = new QVBoxLayout( this ); + aLay->setSpacing( SPACING ); + aLay->setMargin( MARGIN ); + aLay->addWidget( aMainGrp ); + aLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aLay->addWidget( aFrame ); + + connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ); + connect( mySelBtn, SIGNAL( clicked() ), + this, SLOT ( onSetEditCurrentArgument() ) ); + /***************************************************************/ + + Init( theSelection ); +} + + +//================================================================================= +// function : ~RepairGUI_FreeFacesDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_FreeFacesDlg::~RepairGUI_FreeFacesDlg() +{ +} + + +//================================================================================= +// function : onClose +// purpose : SLOT. Called when "close" button pressed. Close dialog +//================================================================================= +void RepairGUI_FreeFacesDlg::onClose() +{ + globalSelection(); + disconnect( mySelection, 0, this, 0 ); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox( 0 ); + reject(); + erasePreview(); +} + +//================================================================================= +// function : onDeactivate +// purpose : Deactivate this dialog +//================================================================================= +void RepairGUI_FreeFacesDlg::onDeactivate() +{ + setEnabled(false); + globalSelection(); + disconnect( mySelection, 0, this, 0 ); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox( 0 ); +} + +//================================================================================= +// function : onActivate +// purpose : Activate this dialog +//================================================================================= +void RepairGUI_FreeFacesDlg::onActivate() +{ + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); + setEnabled( true ); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox( this ); + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT ( onSelectionDone() ) ); + activateSelection(); +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_FreeFacesDlg::Init(SALOME_Selection* theSel) +{ + myObj = GEOM::GEOM_Object::_nil(); + + mySelection = theSel; + + /* signals and slots connections */ + GeometryGUI* aGeomGUI = GeometryGUI::GetGeomGUI(); + connect( aGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT ( onDeactivate() ) ); + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT ( onSelectionDone() ) ); + + activateSelection(); + onSelectionDone(); +} + +//================================================================================= +// function : onSelectionDone +// purpose : SLOT. Called when selection changed. +//================================================================================= +void RepairGUI_FreeFacesDlg::onSelectionDone() +{ + erasePreview(); + if( mySelection->IObjectCount() != 1 ) + { + myEdit->setText( "" ); + return; + } + + Standard_Boolean isOk = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), isOk ); + + if ( !isOk || anObj->_is_nil() || !GEOMBase::IsShape( anObj ) ) + { + myEdit->setText( "" ); + return; + } + else + { + myObj = anObj; + displayPreview( false, true, true, 3 ); + } +} + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void RepairGUI_FreeFacesDlg::enterEvent(QEvent* e) +{ + onActivate(); +} + +//================================================================================= +// function : activateSelection +// purpose : activate selection of faces, shells, and solids +//================================================================================= +void RepairGUI_FreeFacesDlg::activateSelection() +{ + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_SOLID ); + aMap.Add( GEOM_COMPOUND ); + globalSelection( aMap ); +} + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_FreeFacesDlg::closeEvent(QCloseEvent* e) +{ + onClose(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr RepairGUI_FreeFacesDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool RepairGUI_FreeFacesDlg::isValid( QString& msg ) +{ + return !myObj->_is_nil() ; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects ) +{ + bool aResult = false; + GEOM::ListOfLong_var aFaceLst = + GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->GetFreeFacesIDs( myObj ); + TopoDS_Shape aSelShape; + TopoDS_Shape aFace; + TopTools_IndexedMapOfShape anIndices; + if ( !myObj->_is_nil() && GEOMBase::GetShape( myObj, aSelShape ) ) + { + myEdit->setText( GEOMBase::GetName( myObj ) ); + QString aMess; + if ( !isValid( aMess ) ) + { + erasePreview( true ); + return false; + } + + TopExp::MapShapes( aSelShape, anIndices); + SALOME_Prs* aPrs = 0; + QAD_WaitCursor wc; + + for ( int i = 0, n = aFaceLst->length(); i < n; i++ ) + { + aFace = anIndices.FindKey( aFaceLst[i] ); + try + { + getDisplayer()->SetColor( Quantity_NOC_RED ); + getDisplayer()->SetToActivate( false ); + aPrs = !aFace.IsNull() ? getDisplayer()->BuildPrs( aFace ) : 0; + if ( aPrs ) + displayPreview( aPrs, true ); + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + } + } + } + return aResult; +} + +//================================================================ +// Function : getDisplayer +// Purpose : +//================================================================ +GEOM_Displayer* RepairGUI_FreeFacesDlg::getDisplayer() +{ + if ( !myDisplayer ) + myDisplayer = new GEOM_Displayer(); + return myDisplayer; +} + +//================================================================================= +// function : SetEditCurrentArgument +// purpose : +//================================================================================= +void RepairGUI_FreeFacesDlg::onSetEditCurrentArgument() +{ + myEdit->setFocus(); + onSelectionDone(); +} + diff --git a/src/RepairGUI/RepairGUI_FreeFacesDlg.h b/src/RepairGUI/RepairGUI_FreeFacesDlg.h new file mode 100644 index 000000000..a8fd91d2d --- /dev/null +++ b/src/RepairGUI/RepairGUI_FreeFacesDlg.h @@ -0,0 +1,86 @@ +// GEOM GEOMGUI : GUI for Geometry 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 : RepairGUI_FreeFacesDlg.h +// Author : VKN +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_FreeFaces_H +#define DIALOGBOX_FreeFaces_H + +#include +#include "GEOMBase_Helper.h" + +class GEOM_Displayer; +class SALOME_Selection; +class SALOME_Prs; +class QPushButton; +class QLineEdit; + +//================================================================================= +// class : RepairGUI_FreeFacesDlg +// purpose : +//================================================================================= +class RepairGUI_FreeFacesDlg : public QDialog, + public GEOMBase_Helper +{ + Q_OBJECT + +public: + RepairGUI_FreeFacesDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~RepairGUI_FreeFacesDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + +private : + + void Init(SALOME_Selection*); + void enterEvent(QEvent* e); + void closeEvent(QCloseEvent* e); + void activateSelection(); + GEOM_Displayer* getDisplayer(); + +private slots: + + void onClose(); + void onDeactivate(); + void onActivate(); + void onSelectionDone(); + void onSetEditCurrentArgument(); + +private : + + GEOM_Displayer* myDisplayer; + GEOM::GEOM_Object_var myObj; + SALOME_Selection* mySelection; + QPushButton* mySelBtn; + QLineEdit* myEdit; + +}; + +#endif // DIALOGBOX_FreeFaces_H diff --git a/src/RepairGUI/RepairGUI_GlueDlg.cxx b/src/RepairGUI/RepairGUI_GlueDlg.cxx index 11e585864..6a5b0d07a 100644 --- a/src/RepairGUI/RepairGUI_GlueDlg.cxx +++ b/src/RepairGUI/RepairGUI_GlueDlg.cxx @@ -29,12 +29,16 @@ using namespace std; #include "RepairGUI_GlueDlg.h" +#include "DlgRef_1Sel_Ext.h" + #include "QAD_Desktop.h" #include "QAD_SpinBoxDbl.h" +#include "QAD_MessageBox.h" +#include "QAD_WaitCursor.h" #include "OCCViewer_Viewer3d.h" -#include "DlgRef_1Sel_Ext.h" #include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOMEGUI_QtCatchCorbaException.hxx" #include "GEOMImpl_Types.hxx" @@ -143,7 +147,7 @@ void RepairGUI_GlueDlg::ClickOnOk() //================================================================================= bool RepairGUI_GlueDlg::ClickOnApply() { - if ( !onAccept() ) + if ( !onAcceptLocal() ) return false; initName(); @@ -288,10 +292,143 @@ bool RepairGUI_GlueDlg::isValid( QString& msg ) bool RepairGUI_GlueDlg::execute( ObjectList& objects ) { bool aResult = false; - GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->MakeGlueFaces( myObject, myTolEdt->value() ); + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow + ( getOperation() )->MakeGlueFaces( myObject, myTolEdt->value() ); aResult = !anObj->_is_nil(); if ( aResult ) objects.push_back( anObj._retn() ); return aResult; } + +//================================================================ +// Function : clearShapeBufferLocal +// Purpose : +//================================================================ +void RepairGUI_GlueDlg::clearShapeBufferLocal( GEOM::GEOM_Object_ptr theObj ) +{ + if ( CORBA::is_nil( theObj ) ) + return; + + string IOR = GeometryGUI::GetORB()->object_to_string( theObj ); + TCollection_AsciiString asciiIOR( strdup( IOR.c_str() ) ); + GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( asciiIOR ); + + if ( !getStudy() || CORBA::is_nil( getStudy()->getStudyDocument() ) ) + return; + + SALOMEDS::Study_var aStudy = getStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( IOR.c_str() ); + if ( CORBA::is_nil( aSObj ) ) + return; + + SALOMEDS::ChildIterator_var anIt = aStudy->NewChildIterator( aSObj ); + for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) { + SALOMEDS::GenericAttribute_var anAttr; + if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + TCollection_AsciiString asciiIOR( anIOR->Value() ); + GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( asciiIOR ); + } + } +} + +//================================================================ +// Function : onAccept +// Purpose : This method should be called from dialog's slots onOk() and onApply() +// It perfroms user input validation, then it +// performs a proper operation and manages transactions, etc. +//================================================================ +bool RepairGUI_GlueDlg::onAcceptLocal( const bool publish, const bool useTransaction ) +{ + QAD_Study* aDoc = QAD_Application::getDesktop()->getActiveStudy(); + SALOMEDS::Study_var aStudy = aDoc->getStudyDocument(); + + bool aLocked = aStudy->GetProperties()->IsLocked(); + if ( aLocked ) { + MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked"); + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return false; + } + + QString msg; + if ( !isValid( msg ) ) { + showError( msg ); + return false; + } + + erasePreview( false ); + + try { + if ( ( !publish && !useTransaction ) || openCommand() ) { + QAD_WaitCursor wc; + QAD_Application::getDesktop()->putInfo( "" ); + ObjectList objects; + // JFA 28.12.2004 if ( !execute( objects ) || !getOperation()->IsDone() ) { + if ( !execute( objects ) ) { // JFA 28.12.2004 // To enable warnings + wc.stop(); + abortCommand(); + showError(); + } + else { + const int nbObjs = objects.size(); + bool withChildren = false; + for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) { + if ( publish ) { + QString aName(""); + if ( nbObjs > 1 ) + aName = strlen( getNewObjectName() ) ? GEOMBase::GetDefaultName( getNewObjectName() ) : GEOMBase::GetDefaultName( getPrefix( *it ) ); + else { + aName = getNewObjectName(); + // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName() + if ( aName.isEmpty() ) + aName = GEOMBase::GetDefaultName( getPrefix( *it ) ); + } + addInStudy( *it, aName.latin1() ); + withChildren = false; + display( *it, false ); + } + else { // asv : fix of PAL6454. If publish==false, then the original shape was modified, and need to be re-cached in GEOM_Client + // before redisplay + clearShapeBufferLocal( *it ); + withChildren = true; + redisplay( *it, withChildren, false ); + } + } + + if ( nbObjs ) { + commitCommand(); + updateObjBrowser(); + QAD_Application::getDesktop()->putInfo( QObject::tr("GEOM_PRP_DONE") ); + } + else { + abortCommand(); + } + + // JFA 28.12.2004 BEGIN // To enable warnings + if ( !getOperation()->_is_nil() ) { + if ( !getOperation()->IsDone() ) { + wc.stop(); + QString msgw = QObject::tr( getOperation()->GetErrorCode() ); + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + QObject::tr( "WRN_WARNING" ), + msgw, + QObject::tr( "BUT_OK" )); + } + } + // JFA 28.12.2004 END + } + } + } + catch( const SALOME::SALOME_Exception& e ) { + QtCatchCorbaException( e ); + abortCommand(); + } + + updateViewer(); + + return true; +} diff --git a/src/RepairGUI/RepairGUI_GlueDlg.h b/src/RepairGUI/RepairGUI_GlueDlg.h index 41aba949a..4278198c8 100644 --- a/src/RepairGUI/RepairGUI_GlueDlg.h +++ b/src/RepairGUI/RepairGUI_GlueDlg.h @@ -58,6 +58,10 @@ private : void closeEvent(QCloseEvent* e); void initSelection(); + bool onAcceptLocal( const bool publish = true, const bool useTransaction = true ); + void clearShapeBufferLocal( GEOM::GEOM_Object_ptr ); + // Reimplementation of onAccept for local case of this class. + GEOM::GEOM_Object_var myObject; DlgRef_1Sel_Ext* GroupPoints;